Sign in to follow this  

glRasterPos2i(...) - What goes wrong here?

This topic is 4858 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, I have the problem that calls to glRasterPos2i have no effect at all. In my case I am trying to display a texture mapped font but the text remains always in the lower left corner at glRasterPos2i(0, 0). Here is a short snipped of what I'm talking about: // enter ortho mode: glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D(0, m_iWidth, 0, m_iHeight); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); // display fps: glColor3f(1.0f, 1.0f, 1.0f); glRasterPos2i(200, 200); m_lpFont->Print("FPS: %2.0f", m_fFPS); // exit ortho mode: glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); The m_lpFont->Print(...) method looks like this: void CFont::Print(const char* szString, ...) { char cText[1024]; va_list args; if (szString == NULL) { return; } va_start(args, szString); vsprintf(cText, szString, args); va_end(args); if (m_lpTexture->GetData() == 0) { return; } glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, m_lpTexture->GetID()); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glPushAttrib(GL_LIST_BIT); glListBase(m_iCallList); glCallLists(strlen(cText), GL_UNSIGNED_BYTE, cText); glPopAttrib(); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); } Has anyone of you an idea what goes wrong here? With a fullscreen window of 1024x768 the text should be displayed at 200, 200, in fact far from 0, 0! But nothing happens if I change the glRasterPos2i values. Thanks for some feedback in advance! Greetings, STORM!

Share this post


Link to post
Share on other sites
If you draw a texture mapped fonts, I doubt you're using glBitmap or glDrawPixels.. glRasterPos is used for those kinds of pixel/bitmap writes.
You probably want to set the position with glTranslate*

Share this post


Link to post
Share on other sites
Yeah, great, you're right!

I just replaced the glRasterPos2i call with

glTranslatef(200.0f, 200.0f, 0.0f);

and now the text is displayed at the assumed position!

Thanks!
STORM

Share this post


Link to post
Share on other sites

This topic is 4858 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this