From 2e07a03a4e6af3b63cb407934d3ea444feb80cf1 Mon Sep 17 00:00:00 2001 From: kappa1 Date: Tue, 1 Dec 2009 15:12:52 +0000 Subject: [PATCH] added the Display.setInitialBackground(r,g,b) method, this will allow you to select the initial background color of the lwjgl Display window. Useful to create more polished applications and smoother looking applets. --- src/java/org/lwjgl/opengl/Display.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/java/org/lwjgl/opengl/Display.java b/src/java/org/lwjgl/opengl/Display.java index eb4b9a10..c498f84c 100644 --- a/src/java/org/lwjgl/opengl/Display.java +++ b/src/java/org/lwjgl/opengl/Display.java @@ -116,6 +116,9 @@ public final class Display { private static boolean window_created = false; private static boolean parent_resized; + + /** Initial Background Color of Display */ + private static float r = 0, g = 0, b = 0; private static ComponentListener component_listener = new ComponentAdapter() { public void componentResized(ComponentEvent e) { @@ -861,6 +864,20 @@ public final class Display { } } } + + /** + * Set the initial color of the Display. This method is called before the Display is created and will set the + * background color to the one specified in this method. + * + * @param red - color value between 0 - 1 + * @param green - color value between 0 - 1 + * @param blue - color value between 0 - 1 + */ + public static void setInitialBackground(float red, float green, float blue) { + r = red; + g = green; + b = blue; + } private static void makeCurrentAndSetSwapInterval() throws LWJGLException { makeCurrent(); @@ -869,6 +886,8 @@ public final class Display { } private static void initContext() { + // set background clear color + GL11.glClearColor(r, g, b, 1.0f); // Clear window to avoid the desktop "showing through" GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); update();