Some questions about camera position

Started by @, May 09, 2014, 08:35:18

Previous topic - Next topic

@

Right now, this is how i have initialized opengl:

Quote
updateScreen();
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0.f, 0.f, 0.f, 1.f);

public void updateScreen() {      
   final int rw = (int) (Display.getWidth() / scale());
   final int rh = (int) (Display.getHeight() / scale());
      
   final float x = vx;
   final float y = vy;
   final float w = x + rw;
   final float h = y + rh;
   
   glViewport(0, 0, Display.getWidth(), Display.getHeight());
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrtho(x, w, y, h, 1.f, -1.f);
   glMatrixMode(GL_MODELVIEW);
}

updateScreen is also use for whenever i move the camera. Now:

1)Is this code "good enough" ?
2)I wanted to move the camera using glulookat, but suddenly nothing appears on the screen. I read it is a common mistake, but i can't figure out how to fix it.

Cornix

1) If you use ortho on the projection matrix you are using a 2D perspective.
2) GluLookAt is for 3D perspectives.
3) If you want to move a 2D camera you just translate the matrix along the X/Y-Axes.

@

Thanks cornix, then i suppose i leave it just like that.