1
我想呈現2個2d矩形後,我有兩個矩形的高度和寬度在一起。現在當我設置第二個四色的顏色時,第一個四色繼承我的第一個顏色?OpenGL 1.1改變顏色改變以前的顏色?
我試着用pushmatrix和popmatrix一起使用,但這沒什麼區別。我也嘗試用glColor4f(1,1,1,1)重置顏色。
這裏是我的代碼:
protected void renderComponent(Frame component) {
Rectangle area = new Rectangle(component.getArea());
int fontHeight = theme.getFontRenderer().FONT_HEIGHT;
int titleHeight = 25;
translateComponent(component, false);
glEnable(GL_BLEND);
glDisable(GL_CULL_FACE);
glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if(component.isMinimized()){
}
glBegin(GL_QUADS);
{
RenderUtil.setColor(titleColor);
glVertex2d(0, 0);
glVertex2d(area.width, 0);
glVertex2d(area.width, titleHeight);
glVertex2d(0, titleHeight);
}
glEnd();
glBegin(GL_QUADS);
{
RenderUtil.setColor(component.getBackgroundColor());
glVertex2d(0, 0);
glVertex2d(area.width, 0);
glVertex2d(area.width, area.height + titleHeight);
glVertex2d(0, area.height + titleHeight);
}
glEnd();
glEnable(GL_TEXTURE_2D);
theme.getFontRenderer().func_175063_a(component.getTitle(), getCenteredX(area.width, component.getTitle()), 6, RenderUtil.toRGBA(component.getForegroundColor()));
glEnable(GL_CULL_FACE);
glDisable(GL_BLEND);
}
而且我UTIL的setColor方法:
public static void setColor(Color c) {
glColor4f(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f);
}
我覺得很蠢,我錯過了,謝謝:) – czaarek99