Reputation: 647
I am trying to render 2 2d rectangles after each other, I have the height and the width of the 2 rectangles together. Now when I set the color for the 2nd quad the first quad inherits my first color?
I have tried to use popmatrix along with pushmatrix but that makes no difference. I have also tried resetting the colors with glColor4f(1,1,1,1).
Here is my code:
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);
}
And my util setcolor method:
public static void setColor(Color c) {
glColor4f(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f);
}
Upvotes: 1
Views: 98
Reputation: 26
You appear to be drawing the second rectangle over top of the first, thus making it appear you've changed the colour of the first.
use the coordinates below for the second cube instead
glVertex2d(0, titleHeight);
glVertex2d(area.width, titleHeight);
glVertex2d(area.width, area.height + titleHeight);
glVertex2d(0, area.height + titleHeight);
This will place the second rectangle below the first, and give it a height of area.height.
Upvotes: 1