|
[OpenGL] Draw in 2d after drawing in 3d |
BrknPhoenix
Member #7,304
June 2006
|
What I'm wondering, is let's say the 3d scene is drawn. Is there a way to then draw in 2d flat on the screen? For example, if I wanted to have a HUD or mouse cursor over the scene, could I just draw those straight to the screen flat? I know I could figure out all the business as to where those things would be in 3d space and constantly move them with the camera, but it'd be a lot easier if there was just a way to draw it 2d after the 3d was done |
Kitty Cat
Member #2,815
October 2002
|
After drawing the 3d scene, simply reset the modelview and projection matrix, then set an ortho mode (glOrtho).
-- |
BrknPhoenix
Member #7,304
June 2006
|
It doesn't appear to be working. My mouse cursor, which worked in 2D, has stopped showing up when 3D was added. I put in the code that you suggested and nothing happened differently. |
Kitty Cat
Member #2,815
October 2002
|
Show the code. Can't tell what's wrong without seeing what you're doing. -- |
BrknPhoenix
Member #7,304
June 2006
|
Initial setup else if (projection_type == FRUSTUM) { glMatrixMode(GL_PROJECTION); glEnable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); glLoadIdentity(); gluPerspective(45.0f, (GLfloat)SCREEN_WIDTH / (GLfloat)SCREEN_HEIGHT, 1.0f, 1000.0f); glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); } } This is the drawing function: void objGfx::DoDraw(int s) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Do3D(s); Do2D(s); allegro_gl_flip(); } 3D function void objGfx::Do3D(int s) { switch (s) { case SCENE_TITLE: glMatrixMode(GL_MODELVIEW); glLoadIdentity(); break; case SCENE_NONE: glClearColor(0.0f, 0.0f, 0.0f, 0.0f); default: break; } } 2D Function
|
Kitty Cat
Member #2,815
October 2002
|
What are the Mouse and Draw objects? At a glance, everything you pasted looks alright, so the problem is somewhere else. -- |
BrknPhoenix
Member #7,304
June 2006
|
edit: I figured out the problem actually does have to do with how the mouse is being drawn, but I don't know what. I've since moved on to an attempt at a different solution. Draw->Sprite
Mouse everything
Note the Mouse->Draw function isn't actually used... I just forgot to take it out, hehe |
|