开发者

How to Set text color in OpenGl

I am new to openGL and wanted to set the text color tried the glColor3f function but it changes the drawing color开发者_开发百科 as i only want to change the text color what should i do?


You could push the current colour onto the attribute stack, change the colour, draw the text, and then pop the stack to restore the original colour:

glPushAttrib(GL_CURRENT_BIT);
glColor3f(...);
// Draw your text
glPopAttrib(); // This sets the colour back to its original value


glColor3f is the correct call, but you must be aware that color is a global state, so setting it will make everything be drawn in that color until you change it again. So do something like this:

glColor3f(your text color)
draw text
glColor3f(your normal color (white maybe))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜