Correct calculations of floats in OpenGL ES -


i'm making game in 3d. correct in code, although i'm confused 1 thing.

when setting perspective (gluperspective) set znear = 0.1f , zfar = 100.0f. far good. now, wanna move things in x or y direction via gltranslate.... but, origo starts in absolute centrum of screen. have zfar , znear, why isn't x , y coordinates? if move sprite -2.0f left on x-axis , make gltranslate... handle that, out of screen. , z-axis not behave that. that's make lot more difficult handle calculations in directions. it's quite hard add unique float value object , add these randomly make them stay inside screen.

so, have problem calculate corrects value each object. have missed something? should change or thinkig of something? reason important because need know absolute left , right of screen make these calculations.

this onsurfacechanged:

public void onsurfacechanged(gl10 gl, int width, int height) {    gl.glviewport(0, 0, width, height);     gl.glmatrixmode(gl10.gl_projection);    gl.glloadidentity();     glu.gluperspective(gl, 45.0f, (float)width / (float)height,                           0.1f, 100.0f);    gl.glmatrixmode(gl10.gl_modelview);    gl.glloadidentity(); } 

thanks in advance!

when use gluperspective transforming coordinates 3d world space 2d screen space, using matrix looks @ (0,0,0) default (i.e. x= 0, y = 0 in center of screen). when set object coordinates doing in world space, not screen space.

if want 2d graphics (where things given coordinates respective position on screen want use gluortho2d instead.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -