I use the slick-util library to render textures and text.
The problem is that after rendering the text, all the textures are shown in the form of a black square. Text Render Code:
private static TrueTypeFont font = new TrueTypeFont(new Font("Arial", 0, 15), true); public static void renderCenteredTextInRectangle(int x, int y, int width, int height, String title, Color color) { enableBlend(); { font.drawString(x + (width / 2) - (font.getWidth(title) / 2), y + (height / 2) - (font.getHeight(title) / 2), title, color); } disableBlend(); } Texture Render Code:
public static void renderTexturedRectangle(int x, int y, int width, int height, Texture texture) { glBegin(GL_QUADS); { glTexCoord2f(0, 0); glVertex2i(x, y); glTexCoord2f(1, 0); glVertex2i(x + width, y); glTexCoord2f(1, 1); glVertex2i(x + width, y + height); glTexCoord2f(0, 1); glVertex2i(x, y + height); } glEnd(); } Remaining methods:
public static void enableBlend() { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } public static void disableBlend() { glDisable(GL_BLEND); } Render buttons:
public void draw() { int color = 213; if (isHovered()) color = 170; GLHelper.setColor(color, color, color, 0); GLHelper.renderRectangle(this.x, this.y, this.width, this.height); GLHelper.renderCenteredTextInRectangle(this.x, this.y, this.width, this.height, this.title, Color.black); } If you remove the render text, the textures are shown normally.
And yes, the color of the first button should be the same as the second, but the color of the button changes to the color of the last (bottom right) pixel of the texture. Ap.
