Reputation: 1047
I'm creating a labyrinth in opengl, and I'm trying to create a minimap. For that, I thought of creating a viewport inside of a viewport. I have three methods, one for creating the walls, another for the floor, and another for the minimap. The walls and floor go in the main viewport, and the minimap in the second viewport. I'm using Display Lists to create the walls and floor. I can create both viewports, but my problem is I don't know where to call the method to create the minimap.
I don't know if it will be of any help, but here is my display list method:
void createDisplayLists(int janelaID)
{
//Creates the walls
modelo.labirinto[janelaID] = glGenLists(2);
glNewList(modelo.labirinto[janelaID], GL_COMPILE);
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_ENABLE_BIT);
desenhaLabirinto();
glPopAttrib();
glEndList();
//Creates the floor
modelo.chao[janelaID] = modelo.labirinto[janelaID] + 1;
glNewList(modelo.chao[janelaID], GL_COMPILE);
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_ENABLE_BIT);
desenhaChao(CHAO_DIMENSAO, modelo.texID[janelaID][ID_TEXTURA_CHAO]);
glPopAttrib();
glEndList();
}
Upvotes: 0
Views: 987
Reputation: 162164
OpenGL is not a scene graph, it's a state based drawing API. Things get turned into pixel the moment you make the calls (effectively; in practice things get batched and executed asynchronously, but this doesn't matter for the case).
So the gist of it is:
draw_stuff_into_viewport_A():
glViewport(viewport_A)
setup_projection(project_A)
draw_A_stuff()
draw_stuff_into_viewport_B():
glViewport(viewport_B)
setup_projection(project_B)
draw_B_stuff()
display():
glClear(...)
draw_stuff_into_viewport_A()
draw_stuff_into_viewport_B()
swapBuffers()
Upvotes: 1