Archived

This topic is now archived and is closed to further replies.

dta1

Ortho

Recommended Posts

dta1    122
How come I can''t see the Sphere in this code. If I delete the 2d I can but with it it seems to disappear. glClearColor(0.0f,0.0f,0.0f,0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); // Reset matrix glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); auxWireSphere(10); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glPushMatrix(); glViewport(0,0, screenWidth, screenHeight); // Reset viewport to new dimensions glMatrixMode(GL_PROJECTION); // Make changes on the projection matrix glLoadIdentity(); glOrtho(0, screenWidth -1 ,0, screenHeight -1, -1,1); glPixelStorei(GL_UNPACK_ALIGNMENT, 4); glRasterPos2i( ballmove+30, 10 ); glDrawPixels(myTGA->imageWidth,myTGA->imageHeight,GL_RGB,GL_UNSIGNED_BYTE,myTGA->imageData); glPixelZoom(ballmove/24,1); glRasterPos2i( 500, 10 ); glDrawPixels(myTGA->imageWidth,myTGA->imageHeight,GL_RGB,GL_UNSIGNED_BYTE,myTGA->imageData); glPixelZoom(1,1); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); SwapBuffers(g_hDC); glFlush(); TranslateMessage(&msg); DispatchMessage(&msg); I think it disappears cause I move it away some how.

Share this post


Link to post
Share on other sites
mkaltner    122
I could be wrong, but you''re missing your gluPerspective stuff.
You''re enabling GL_DEPTH_TEST but not actually setting up the 3D viewport with gluPerspective equviliant.

So, before you draw the 3D object, do a gluPerspective setup similar to your glOrtho setup.

- Mike

Share this post


Link to post
Share on other sites
eldee    122
with glOrtho, the gluPerspective isnt necessary (at least i dont think, im not using it in my engine so i doubt it''s required...)

but you have to remember, when you use
glOrtho, you''re rearranging how the coordinate system is used.
for example:

when you use
glOrtho(0.0, 640.0, 480.0, 0.0, -10.0, 10.0);

the normal perspective coordinate system is changed..
ie)

glBegin(GL_QUADS);
glVertex3f(1.0f, 1.0f, 1.0f);
.... ect

would read in as 1 pixel...
instead, you''d do something like this:

glBegin(GL_QUADS);
glVertex2d(100,100);
.... ect

hope this helps a little...



-eldee
;another space monkey;

Share this post


Link to post
Share on other sites
dta1    122
It works if I do like this put it''s probably not a good way to do it.

glPushMatrix();
glViewport(0,0, screenWidth, screenHeight); // Reset viewport to new dimensions
//glMatrixMode(GL_PROJECTION); // Make changes on the projection matrix
//glLoadIdentity();

glOrtho(0, screenWidth -1 ,0, screenHeight -1, -1,1);

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Dont really know ...

but I think there''s something wrong with your glOrtho() setup,
try to use something like 30 or so as the last param.

Share this post


Link to post
Share on other sites