我的代碼在某處出現問題,但對於我繪製的任何數量的基元,儘管調用glClearColor,然後用glColor3f選擇顏色,出現的顏色完全是隨機的...glColor不工作,出現隨機顏色
所以在我的渲染I類循環中的所有對象,並調用其繪製方法,對原語,看起來像:
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()
但無論我選擇,我總是得到不同的人用什麼顏色......有趣認爲我用這種方法繪製的所有基本線都假定它們所綁定的模型的顏色(它們應該是爲網格綁定卷)...它可能與我正在使用的模型加載器有關嗎?
這影響到每個GL_LINE假定相同顏色(包括我試圖繪製的glutBitMapCharacter)的每個形狀(模型周圍的形狀),其中每個GL_LINE假定相同的顏色...這是主要考慮的問題我,我想挑顏色文本圖紙,目前我做的:
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();
}
但文本出現綠色而不是藍色的?
你爲什麼總是調用'glClearColor',這完全沒用,除非跟着一個'glClear'。 –