PDA

View Full Version : question on glRasterPos function & GL_QUADS



Rectless
07-11-2005, 06:47 AM
Hello,

I am trying to render a solid filled quad onto my window. I am wanting it in screen coordinates so I am using glRasterPos2d. But for some reason, the quad is not rendering. Can you render such things to screen coordinates using glRasterPos? The reason why I am doing this is because I am rendering some pixmap fonts to the screen using the FTGL library and want to put a solid "background" for the text. Since the fonts are pixmaps, I have to render them using glRasterPos. Using the method below I can render the fonts to the screen fine, but for some reason it is not working. Below is the code I am using to output the quad to the screen.

//---------------------------------------------//
glPushAttrib(GL_CURRENT_BIT);
widthL = (float)pwinM->widthM.GetValue();
heightL = (float)pwinM->heightM.GetValue();

glViewport( 0, 0, (int)widthL, (int)heightL );
islightingL = MLF_GetState(GL_LIGHTING);
isdepthL = MLF_GetState(GL_DEPTH_TEST);

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D( 0.0f, widthL, 0.0f, heightL );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

/* this is just getting the color to use for the background */
glColor3d(pNodeA->polyM->bgd_redM.GetValue(),
pNodeA->polyM->bgd_greenM.GetValue(),
pNodeA->polyM->bgd_blueM.GetValue() );

/* setting the raster pos, yes I know that I don't have to use 3d and that I can use 2d, but it doesn't make a difference either way since the Z value is 0.0f */
glRasterPos3d(pNodeA->polyM->xposM.GetValue() * widthL, (pNodeA->polyM->yposM.GetValue() * heightL) , 0.0f );

/* minhL = minimum height, maxhL = maximum height, maxwL = maximum width, all are computed earlier in the function. I can provide code for that but it basically gets the length of the string using the ftgl font library functions */
glBegin(GL_QUADS);
glVertex2f(-0.01f,minhL);
glVertex2f(maxwL,minhL);
glVertex2f(maxwL,maxhL);
glVertex2f(-0.01f,maxhL);
glEnd();

glPopAttrib();

//---------------------------------------------//

I appreciate any help/advice anyone can give me on this. I believe that this should be an easier problem to solve but for some reason it is eluding me.

Thanks again

powerpad
07-11-2005, 09:23 PM
I don't think that glRasterPos works for the quad, because screen coordinates and world coordinates/ model coordinates are two different things. (although I have heard about an extension that is supposed to that)

Rectless
07-12-2005, 03:25 AM
Thank you powerpad, that is what I was afraid of and needed someone to confirm. Any suggestions on how I could get a quad to render in the same place on the screen as my text then?