
can someone please simplify this code snipet?
this code snipet is in the middle of a group of calls...i'm not too familiar (actually, i'm not familiar at all) with ortho's and viewports...but i kinda scratched and clawed my way to something that keeps the text positioned in the same spot...but i don't know if i'm writing redundant code...could someone help me out and remove any pieces of OpenGL code that are redundant or unecessary or completely insane calls that shouldn't be there?
double pd[4];
glGetDoublev(GL_VIEWPORT, pd);
glPushMatrix();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// create bitmaps for the device context font's first 256 glyphs
wglUseFontBitmaps(m_pCDC->GetSafeHdc(), 0, 256, 1000);
glOrtho(0.0, pd[2], pd[3], 0, -1.0, 1.0);
glRasterPos2d((10/676) * pd[2] +10, 20);
// set up for a string-drawing display list call
glListBase(1000);
glLoadIdentity();
// draw a string using font display lists
glCallLists(strlen(str), GL_UNSIGNED_BYTE, str);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
following this snipet, i use this code to return to the OpenGL drawing mode that i guess is loaded by default (i'm using an MFC app with my view class derived from a CGLEnabledView class that's derived from CView and is OpenGL enabled...basically i just put straight OpenGL code in the OnDrawGL (OnDraw has been eliminated and taken over by the CGLEnabledClass) and presto! openGL to the screen)
i got this from the on size...it seems to undo the ortho changes above...but is it necessary to call after my glOrtho use above?
glPushMatrix();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(40.0,(pd[2]/pd[3]),0.1f, 10.0f);
glTranslatef(0.0f,0.0f,-4.f);
glMatrixMode(GL_MODELVIEW);
<...proceed with bulk of drawing code...>
thanks for the help, i really don't understand the implementation of them very well (sorry folks, i'm trying, i've got the red book and the super bible, but apparently i'm slow to learn this
)
[edited by - cxx on August 8, 2002 12:47:38 AM]

This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement