java - OpenGL/Android -- Setting up a 2D OpenGL orthogonal coordinate system that matches the screen pixels -
i trying circles drawn onscreen using opengl es 1.5 android. draw, want able input x=300, y=500, , draw circle centered @ coordinate (e.g. @ (300,500) pixel on screen). currently, draw , translate circles, not precise, don't know how want it: here's broken code last attempt:
//doesn't take w/h ratio consideration, not sure how implement gl.glviewport(0, 0, windowwidth, windowheight); gl.glorthof(0,windowwidth, 0, windowheight, 1, 2); glu.glulookat(gl, 0, 0, 5, 0, 0, 0, 0, 1, 0); //and drawing circle, desired x , y coordinates: (int j = 0; j < number_triangles; j++) { x = math.cos(theta) + xcoor; y = math.sin(theta) + ycoor; z = 1; theta += 2 * math.pi / (number_triangles); }
if doing 2d graphics, i'd recommend gluortho2d(left,right,bottom,top). way have exact control on coordinates map each edge of screen.
so, example, have:
gl.glviewport(0,0,windowwidth,windowheight); glu.gluortho2d(-2.0f, 2.0f, -2.0f, 2.0f);
for (int j = .....
Comments
Post a Comment