Skip to main content
GameDev.net gamedev.net
🔒 Locked

glRasterPos

Started by ube83 Feb 20, 2003 at 5:55 AM 9 replies 2.8k views
Original Post
ube83
ube83
i''m having trouble with glRasterPos(). I''m trying to render text (font created with wglUseFontBitmaps) in ortho mode. I used glRasterPos to position the text. I didn''t see the font, so i checked if the raster position was loadad correctly, kinda like this: float f[4]; glRasterPos4f(0.0f, 0.0f, 0.0f, 1.0f); glGetFloatv(GL_CURRENT_RASTER_POSITION, f); The problem is: f[1] contains 600.0f. The msdn documentation to glRasterPos says the function only fails if it is located between glBegin/glEnd, but in my case, it isnt. Does anyone know what the problem could be? Thanks in advance
Maximus
Maximus
Try reading the value of f[0].. everyone knows that arrays begin at 0

Edit: whoops misunderstood what was happening there...
Try passing &f[0] as the parameter. It shoudlnt make any difference, though strangely enough it has helped fix things for me in the past.

[edited by - Maximus on February 20, 2003 6:58:28 AM]
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
ube83
ube83
the array''s fine... i just put it in there to see if opengl took the new rasterpos. i think it''s some problem with opengl i don''t know (i''m still learnig it).
bakery2k1
bakery2k1
Remember RasterPos is passed through the modelview and projection matrices. What are those at the time of calling RasterPos?
ube83
ube83
i set the projection matrix with glOrtho and the modelview matrix is an identity matrix.
bakery2k1
bakery2k1
What are the settings for glOrtho?
merlin9x9
merlin9x9
Don''t forget that every time you modify one a matrix, the new matrix is multiplied with the current one. So unless that''s what you want, make sure to do glLoadIdentity.

quote:
What are the settings for glOrtho?

MSDN. Google.
bakery2k1
bakery2k1
Sorry. What I meant was "What settings are YOU using for glOrtho". I hoped this would help me answer the OP's problem.


[edited by - bakery2k1 on February 21, 2003 8:41:00 AM]
ube83
ube83
Hi,

i set up orthographic mode like this:

glOrtho(0, m_dwWidth, m_dwHeight, 0, 0, 1);

where m_dwWidth/m_dwHeight are the screen size.

After this call i save the Projection Matrix (with glGetFloat) and when I want to change to ortho mode, I just call glLoadMatrix(). I did this to speed up the program (i didn''t want to call glOrtho all the time). Could this be the problem?

@ merlin9x9:
yes, I call glLoadIdentity() before i call glRasterPos().
Brother Bob
Brother Bob
When you read back the raster position, you get the position in window coordinates. If you set the raster position to (0,0,0) with that projection matrix, it will end up in the upper right corner, which has has the Y-coordinate 600 assuming m_dwHeight is equal to 600 when calling glOrtho. So if m_dwHeight is 600 then everything is correct.

[edited by - Brother Bob on February 22, 2003 8:15:43 AM]
ube83
ube83
thank you, i guess that solved my problem.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.