width and height
Hello
I want to know how i can get the most left, right, top, bottom points in my scene.
Let say i do the following:
gluLookAt(0, 0, 300, 0, 0, 0, 0, 1, 0);
So let say i want to draw a square on left side of the screen...
i would do:
glTranslatef(-222, 0, 0); // here -222 is a fictionnal value representing the leftern visible point i found using trials and errors
Is there a "proper" way to do this?
Also, when drawing an object... let say my square... is there a way to know if the square will be visible before it is drawn?
ex:
glTranslatef(9999.0f, 9999.0f,0.0f);
using the x, y , z values used for the translation, before ... i would test if the square will be visible or not. if it will, i draw it, if not, i dont...
thanks
-Oli
For drawing quad on left side just switch to ortho mode before you draw it.
For testing if visivle or not. If it''s just a quad don''t even bother. It will be faster to just draw it. If you *must* test it use some kind of raytracing trough scene or use nv_occlusion_query.
You should never let your fears become the boundaries of your dreams.
For testing if visivle or not. If it''s just a quad don''t even bother. It will be faster to just draw it. If you *must* test it use some kind of raytracing trough scene or use nv_occlusion_query.
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
thanks for the lightning fast replay Darkwing!
but im little new to the OpenGL universe...
Could you give me a brief example please?
thanks
-Oli
but im little new to the OpenGL universe...
Could you give me a brief example please?
thanks
-Oli
copy/paste from my old engine:
hope it helps..
You should never let your fears become the boundaries of your dreams.
[edited by - _DarkWIng_ on September 26, 2003 2:41:47 PM]
// Change to 2D mode (ortho)void GLWindow::SwitchTo2D() { GLWindowSettings *settings = GLWindowSettings::GetSingleton(); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( 0.0, settings->width, settings->height, 0.0f, -1.0f, 1.0f ); glMatrixMode( GL_MODELVIEW ); glDisable( GL_DEPTH_TEST ); glLoadIdentity();}// Change to 3D mode (projection)void GLWindow::SwitchTo3D() { GLWindowSettings *settings = GLWindowSettings::GetSingleton(); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glEnable( GL_DEPTH_TEST ); gluPerspective( settings->FOV, settings->aspect, settings->nearClipPlane, settings->farClipPlane ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity();}
hope it helps..
You should never let your fears become the boundaries of your dreams.
[edited by - _DarkWIng_ on September 26, 2003 2:41:47 PM]
You should never let your fears become the boundaries of your dreams.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement