如何在OpenGl中设置文本颜色 [英] How to Set text color in OpenGl

查看:133
本文介绍了如何在OpenGl中设置文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是openGL的新手,想尝试使用glColor3f函数设置文本颜色,但是它更改了绘图颜色,因为我只想更改文本颜色该怎么办?

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

这篇关于如何在OpenGl中设置文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆