我的代码在某处出现了问题,但是对于我绘制的任意数量的基元,尽管调用glClearColor然后使用glColor3f选择颜色,但出现的颜色是完全随机的......
所以在我的Rendering类中,我循环遍历所有对象并调用它们的绘图方法,对于它们看起来像的原始图形:
inline void PrimitiveDrawer::drawWireframePrism(Vector3 pos, float radius, Vector3 col){
glClearColor( 1.0f, 1.0f, 1.0f, 1.0f );
glColor3f(col.x, col.y, col.z);
glLineWidth(3);
glBegin (GL_LINE_LOOP);
...
glEnd()
Run Code Online (Sandbox Code Playgroud)
但无论我选择什么颜色,我总会得到不同的颜色...有趣的想法是,我用这种方法绘制的所有原始线都假定它们绑定的模型的颜色(它们是网格的边界体积).它可能与我使用的模型加载器有关吗?
这会影响每个形状(在模型周围的形状之外),其中每个GL_LINE都采用相同的颜色(由于某种原因为绿色),包括我试图绘制的glutBitMapCharacter ......这是我认为困扰我的主要因素.我想选择文字绘图的颜色,目前我在做:
void renderBitmapString(float x, float y, void *font,char *string)
{
char *c;
glRasterPos2f(x, y);
for (c=string; *c != '\0'; c++) {
glutBitmapCharacter(font, *c);
}
}
void drawText(char text[20], float x, float y){
glPushMatrix();
setOrthographicProjection();
glLoadIdentity();
glClearColor( 0, 0, 0, 0 );
glColor4f(0, 0, 1, 1);
renderBitmapString(x, y,(void *)font, text);
resetPerspectiveProjection();
glPopMatrix();
}
Run Code Online (Sandbox Code Playgroud)
但文字出现绿色而不是蓝色?
glClearColor
与此无关glColor
.glClearColor
设置调用使用的颜色glClear(GL_COLOR_BUFFER_BIT)
以清除帧缓冲区.
其他对象的颜色向我发出声音,忘记禁用纹理.glDiable(GL_TEXTURE_2D);
在完成绘制纹理的东西之后添加一个.
归档时间: |
|
查看次数: |
1521 次 |
最近记录: |