PDA

View Full Version : A problem on displaying objects with different colors.



earth_walker
07-11-2003, 01:41 PM
Hi!

I tried to draw a triangle in red and some characters in blue, but failed.

In the code, I tried in 2 places to set the color of characters to be blue, but the actual displayed color is always the same as the triangle.

Can you tell me how to fix it?

Thank you!

following is the code:

FormCreate



{attmpt to define the character bitmap color}
glColor3f(0,0,1);
wglUseFontBitmaps(Form1.Canvas.Handle, 48, 10, 1);
wglUseFontBitmaps(Form1.Canvas.Handle, 65, 26, 11);


MyDraw routine



procedure TForm1.MyDraw;
begin
glClearColor(0,1,0,0);
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
gluLookAt(0,0,0, 0,0,1, 0,1,0);
glTranslate(Xshift,Yshift,0);
glScalef(Xscale,Yscale,Zscale);

//draw graph
glColor3f(1,0,0);
glBegin(GL_LINE_LOOP);
glVertex3f(0, 0.4,1);
glVertex3f(0.5,-0.5,1);
glVertex3f(-0.5,0.3,1);
glEnd;

//display the characters
glRasterPos3f(0,0,2);
{attmpt to change color}
glColor3f(0,0,1);
glCallList(12);
glCallList(13);

SwapBuffers(Canvas.Handle);
end;

Relic
07-12-2003, 03:58 AM
glRasterPos fetches the current state for the following bitmaps. Change the current states BEFORE glRatserPos to have an effect.
In your code:
glColor(red)
glRasterPos
glCallList(12)
glColor(blue)
glRasterPos
glCallList(13)

earth_walker
07-12-2003, 09:29 PM
Thank you!