1 view / multiple views typical structure for a game

Started by mireazma, February 25, 2014, 22:58:23

Previous topic - Next topic

mireazma

I'm a beginner with OpenGL and I'm trying to make a 3D game (like everyone else, I suppose).
Can you guys advise me on the structure of a game? I'm trying to figure it out for a view (camera) and then I want to implement multiple simultaneous cameras. What approaches are there for these? Is there a recommended standard for the skeleton of a game?

For 1 camera, this is what I do in theory:
at game start:
Display.setDisplayMode(...);
Display.create();
...
glEnable(GL_DEPTH_TEST | ...);


at certain times, when I need to create or update models:
setup VBO, VAO etc.
at certain times, e.g. when changing camera:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(...);
glMatrixMode(GL_MODELVIEW);
// is this necessary here: glLoadIdentity()?;


in a loop I do:
- game input
- game logic
- game render which is
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* this is where it gets fuzzy: what do I have to do and in what order?
 * when to use gluLookAt(), when to transform the camera and when the models?
 * how am I supposed to relate these transforms with the matrices written above(GL_PERSPECTIVE and GL_MODELVIEW)?
*/
// camera transform
glTranslatef(...);
glRotatef(x, y, z);// all rotations in a call
// model transform
glTranslatef(...);
glRotatef(x, y, z);
// draw VBO's
...
//anything else?
...


After this, how to adapt the code for say, 2 simultaneous views?

I know it's probably too much to start with and too much for a single topic but I said I shouldn't create another separate topic for the multi-view.