3D Widgets Ortho Mode
Hey Everyone,
I'm trying to create a widget for my windowing system that draws a 3d Model in screen coordinates. I've tried a few things but can't quite seem to figure out what I'm doing wrong. I can get the object to translate but it's all clipped up. However if I don't screw with the matricies and keep my mode in perspective and not ortho and utilize world coordinates my model draws fine, it's when I try and draw it in ortho mode it gets screwed up. I set the z value to 0, before drawing in ortho mode, but that doesn't work. I can post more in depth code if that would help more.
In short here is pseudo code:
Render()
{
//draw the scene
DrawWorld();
//now draw the ui
DrawUI();
}
DrawUI()
{
SetViewOrtho();
glDisable(GL_DEPTH_TEST);
DrawWindowTexture();
Draw3DWidget();
DrawOtherWindows();
glEnable(GL_DEPTH_TEST);
SetViewPerspective();
}
Draw3DWidget()
{
glEnable(GL_DEPTH_TEST);
DrawModel();
glDisable(GL_DEPTH_TEST);
}
I'm trying to create a widget for my windowing system that draws a 3d Model in screen coordinates. I've tried a few things but can't quite seem to figure out what I'm doing wrong. I can get the object to translate but it's all clipped up. However if I don't screw with the matricies and keep my mode in perspective and not ortho and utilize world coordinates my model draws fine, it's when I try and draw it in ortho mode it gets screwed up. I set the z value to 0, before drawing in ortho mode, but that doesn't work. I can post more in depth code if that would help more.
In short here is pseudo code:
Render()
{
//draw the scene
DrawWorld();
//now draw the ui
DrawUI();
}
DrawUI()
{
SetViewOrtho();
glDisable(GL_DEPTH_TEST);
DrawWindowTexture();
Draw3DWidget();
DrawOtherWindows();
glEnable(GL_DEPTH_TEST);
SetViewPerspective();
}
Draw3DWidget()
{
glEnable(GL_DEPTH_TEST);
DrawModel();
glDisable(GL_DEPTH_TEST);
}
There isn't really enough code in your post to figure out the problem for sure, but maybe you're hitting the near and/or far clipping planes in your orthographic projection? What does your glOrtho() call look like, and how large is your object on the z axis?
Also, you re-enable depth testing to draw your 3D model. What's in the depth buffer at that point? It may be interfering with the drawing. You could clear the depth buffer when you start drawing your interface to see if that helps.
Failing that, you might need to post a screenshot to show us what is happening, and more code might not be a bad idea.
Failing that, you might need to post a screenshot to show us what is happening, and more code might not be a bad idea.
Ah I can't believe I didn't see that. Thems you are correct, I was hitting the near and far clip plan on my ortho projection. My cube was a unit cube however it was being scaled and hitting the planes.
Thanks for the insight, I guess oversight happens at 3am
Thanks for the insight, I guess oversight happens at 3am
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| ortho vs frustrum speed difference | Madrayken | 2 | 2,018 |
Jul 28, 2009 11:19 AM Last Post: Madrayken |
|

