Various OpenGL questions
Since I have several questions at once, I thought I would post them under one thread instead of 3 separate threads.
I'm not sure how I would use prospective and orthographic at the same time (within one viewport). Or maybe I am not thinking about the problem in the right way, but I am trying to draw 2D and 3D at the same time. For example, having a heath bar overlay while having a 3D scene in the background.
My current implementation is below:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gluOrtho2D(-1, 1, -1, 1);
I am also working with models. I can load the models and textures just find as well as display the mesh. However, the texture comes out as which ever color I have been using previously. My implementation for textures is:
Should I be disabling / enabling a command?
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
When I do not use glColor(...) commands the texture works just fine.
I was also wondering what the best choice is for loading in models with bone structure support. I have ms3d and obj, but I believe 3ds is a fairly good choice (correct me if I am wrong). I was going to go along with ms3d, but I haven't found too many exporters for it so far. If you have a recommendation (that does not require a dll), please provide the site (preferably with an example).
Thank you for your help!
1) gluOrtho2D multiplies an orthographic projection matrix onto the current matrix. Think where it should be put. Remember that the matrix mode indicates which matrix stack is being manipulated.
2) GL_DECAL does a copy of the texture onto the surface, while GL_MODULATE takes into account lighting, materials and added colors. ( Default OpenGL environment mode is GL_MODULATE )
3) I haven't worked with models for a while now. Someone else? :D
Thanks for the response, sorry for responding so late.
For question number one, I placed the projection order in both locations. Where is is right now, the ortho draws are drawn as 3D. However, when applying the ortho draws first before all the other normal projection commands, then the ortho draws correctly, but the other 3D draws are non-existant. Again my goal it to have a 3D scene with cameras while having a 2D overlay on the screen, such as portraying a health bar, or various other non-3D data.
For question number two. Thanks for the info on GL_MODULATE, I am looking for something very close to that. I need for the texture to take into account of my lighting, but not the blended color. Right now, my model does blend in with which ever color I assigned last. Is there a way to tell it which color to blend to (and by how much).
Once again, thanks for the response!
For the second question, disable or don't enable GL_COLOR_MATERIAL. That should solve your problem.
For the first:
My approach is to switch to GL_PROJECTION matrix mode, push an identity matrix, call gluOrtho2D() and switch back to GL_MODELVIEW.
When done with drawing your 2D graphics, switch to GL_PROJECTION matrix mode again, pop the matrix and switch back to GL_MODELVIEW. :D
The first projection matrix should already be filled with your 3D gluPerspective() matrix.
Don't forget though that even your 2D coordinates are affected by the current GL_MODELVIEW matrix. So remember to push an identity matrix before drawing 2D graphics.
There we go, questions number one and two are solved. I also found that setting the blend color to white could also fix the problem with blending to a color.
If anyone could answer question number 3 that would be great!