/** * Org.: DefeatThePurpose Entertainment * User: Suds (Scott Drew) * Date: 16/08/12 * Time: 8:12 PM */ public class Box { public static void renderRectangle(Rectangle rectangle, float lineWidth, Colour colour) { glColor3f(colour.getR(), colour.getG(), colour.getB()); glBegin(GL_QUADS); glVertex2i(rectangle.getX(), rectangle.getY()); glVertex2i(rectangle.getX() + rectangle.getW(), rectangle.getY()); glVertex2i(rectangle.getX() + rectangle.getW(), rectangle.getY() + rectangle.getH()); glVertex2i(rectangle.getX(), rectangle.getY() + rectangle.getH()); glEnd(); glLineWidth(lineWidth); // render slightly darker border glColor3f(colour.getR() * 0.8f, colour.getG() * 0.8f, colour.getB() * 0.8f); glBegin(GL_LINE_LOOP); glVertex2i(rectangle.getX(), rectangle.getY()); glVertex2i(rectangle.getX() + rectangle.getW(), rectangle.getY()); glVertex2i(rectangle.getX() + rectangle.getW(), rectangle.getY() + rectangle.getH()); glVertex2i(rectangle.getX(), rectangle.getY() + rectangle.getH()); glEnd(); } } // This method is found in my Button class: public void render() { // Render box Box.renderRectangle(_bounds, 2.0f, _colour); // render text in centre of box _font.drawString(_bounds.getX() + (_bounds.getW() / 2) - (_font.getWidth(_text) / 2), _bounds.getY() + (_bounds.getH() / 2) - (_font.getHeight(_text) / 2), _text); } // snippet from initGL() --> Is ALL of the gl calls other than those above. glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glViewport(0, 0, 800,480); glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, 800, 480, 0, 1, -1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_TEXTURE_2D); // These screenshots highlight the problem. // The code as above: // https://dl.dropbox.com/u/18809996/tuvgxscreenies/darkmodderbutton.png // Commenting out JUST line 40: the _font.drawString() call: // https://dl.dropbox.com/u/18809996/tuvgxscreenies/notext.png // Notice that all the colours are DIFFERENT NOW. WTF!? // _font is an instance of org.newdawn.slick.UnicodeFont // All of the code directly applied to _font: _font.addAsciiGlyphs(); _font.addGlyphs(400, 600); _font.getEffects().add(new ShadowEffect(Color.BLACK, 1, 1, 1.0f)); _font.getEffects().add(new ColorEffect(Color.WHITE)); _font.setPaddingLeft(1); _font.setPaddingRight(1); try { _font.loadGlyphs(); } catch (SlickException e) { e.printStackTrace(); } // The initial problem stems from all the buttons being the wrong colour in the first place. The no text // screenie has all the correct colours, but they are on the wrong buttons. The code setting the colours // is correct. I've checked it a half dozen times. Theres no mixing orders, or swapping an R for a G // value, or anything like that. The issue is definitely somewhere in the code in this paste. :-/