Example usage for org.lwjgl.opengl GL11 glClearColor

List of usage examples for org.lwjgl.opengl GL11 glClearColor

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glClearColor.

Prototype

public static void glClearColor(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green,
        @NativeType("GLfloat") float blue, @NativeType("GLfloat") float alpha) 

Source Link

Document

Sets the clear value for fixed-point and floating-point color buffers in RGBA mode.

Usage

From source file:vertigo.graphics.lwjgl.LWJGL_Renderer.java

License:Open Source License

public void display() {
    GL11.glClearColor(red, green, blue, 1.0f);
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_COLOR_BUFFER_BIT);
    world.accept(visitor);/*w w  w . ja  va2s. co m*/
    for (Shape shape : shapes) {
        // shape
        drawShape(shape);
    }

}

From source file:voxicity.Voxicity.java

License:Open Source License

static void init(Arguments args) {
    // Load the specified config file
    Config config = new Config(args.get_value("config", "voxicity.properties"));

    String mode = args.get_value("mode", "client");

    if (mode.equals("server")) {
        // Start the server, it spawns its own thread
        // and takes over from here
        new Server(config).run();
    } else if (mode.equals("client")) {
        try {/*from  w w  w  .  ja va  2  s  .  co  m*/
            System.out.println("Intializing display");
            Display.setDisplayMode(new DisplayMode(1200, 720));
            Display.create();
            Display.setTitle("Voxicity");
            System.out.println("Display created");
        } catch (LWJGLException e) {
            System.out.println("Unable to open Display");
            e.printStackTrace();
            System.exit(1);
        }

        System.out.println("Setting up OpenGL states");
        GL11.glShadeModel(GL11.GL_SMOOTH);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glClearColor(126.0f / 255.0f, 169.0f / 255.0f, 254.0f / 255.0f, 1.0f);
        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

        System.out.println("Number of texture units: " + GL11.glGetInteger(GL13.GL_MAX_TEXTURE_UNITS));
        System.out.println(
                "Number of image texture units: " + GL11.glGetInteger(GL20.GL_MAX_TEXTURE_IMAGE_UNITS));
        System.out.println(
                "Number of vertex texture units: " + GL11.glGetInteger(GL20.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS));
        System.out.println("Number of combined vertex/image texture units: "
                + GL11.glGetInteger(GL20.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS));

        try {
            LWJGLRenderer gui_renderer = new LWJGLRenderer();
            LoginGUI login_gui = new LoginGUI();
            ThemeManager theme = ThemeManager.createThemeManager(Voxicity.class.getResource("/login.xml"),
                    gui_renderer);
            GUI gui = new GUI(login_gui, gui_renderer);
            gui.applyTheme(theme);

            while (!login_gui.is_login_pressed()) {
                GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
                gui.update();
                Display.update();

                if (Display.isCloseRequested()) {
                    Display.destroy();
                    System.exit(0);
                }
            }

            Socket client_s = new Socket(login_gui.get_server_name(), 11000);
            Client client = new Client(config, new NetworkConnection(client_s));
            client.run();

            System.out.println("Destroying display");
            Display.destroy();
        }

        // Catch exceptions from the game init and main game-loop

        catch (LWJGLException e) {
            System.out.println(e);
            e.printStackTrace();
            System.exit(1);
        } catch (IOException e) {
            System.out.println(e);
            e.printStackTrace();
            System.exit(1);
        } catch (Exception e) {
            System.out.println(e);
            e.printStackTrace();
        }
    } else {
        System.out.println("Invalid mode: " + mode);
    }
}

From source file:zildo.fwk.opengl.OpenGLGestion.java

License:Open Source License

private void initGL() {
    GL11.glEnable(GL11.GL_TEXTURE_2D); // Enable Texture Mapping
    GL11.glShadeModel(GL11.GL_SMOOTH); // Enable Smooth Shading
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
    GL11.glClearDepth(1.0f); // Depth Buffer Setup
    GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing
    GL11.glDepthFunc(GL11.GL_LEQUAL); // The Type Of Depth Testing To Do

    // initProjectionScene();

    GL11.glEnable(GL11.GL_CULL_FACE);// w  w w . j  ava 2s. co  m

    ByteBuffer temp = ByteBuffer.allocateDirect(16);
    temp.order(ByteOrder.nativeOrder());
    GL11.glLight(GL11.GL_LIGHT1, GL11.GL_AMBIENT, (FloatBuffer) temp.asFloatBuffer().put(lightAmbient).flip()); // Setup The Ambient
    // Light
    GL11.glLight(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, (FloatBuffer) temp.asFloatBuffer().put(lightDiffuse).flip()); // Setup The Diffuse
    // Light
    GL11.glLight(GL11.GL_LIGHT1, GL11.GL_POSITION,
            (FloatBuffer) temp.asFloatBuffer().put(lightPosition).flip()); // Position The
    // Light
    GL11.glEnable(GL11.GL_LIGHT1); // Enable Light One

    // GL11.glEnable(GL11.GL_LIGHTING);

    Display.setVSyncEnabled(true);

}

From source file:zildo.platform.opengl.LwjglOpenGLGestion.java

License:Open Source License

private void initGL() {
    GL11.glEnable(GL11.GL_TEXTURE_2D); // Enable Texture Mapping
    GL11.glShadeModel(GL11.GL_SMOOTH); // Enable Smooth Shading
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
    GL11.glClearDepth(1.0f); // Depth Buffer Setup
    GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing
    GL11.glDepthFunc(GL11.GL_LEQUAL); // The Type Of Depth Testing To Do

    // initProjectionScene();

    GL11.glEnable(GL11.GL_CULL_FACE);//from   w w  w  .  j av  a 2s . c  om

    ByteBuffer temp = ByteBuffer.allocateDirect(16);
    temp.order(ByteOrder.nativeOrder());
    GL11.glLight(GL11.GL_LIGHT1, GL11.GL_AMBIENT, (FloatBuffer) temp.asFloatBuffer().put(lightAmbient).flip()); // Setup The Ambient
                                                                                                                // Light
    GL11.glLight(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, (FloatBuffer) temp.asFloatBuffer().put(lightDiffuse).flip()); // Setup The Diffuse
                                                                                                                // Light
    GL11.glLight(GL11.GL_LIGHT1, GL11.GL_POSITION,
            (FloatBuffer) temp.asFloatBuffer().put(lightPosition).flip()); // Position The
                                                                                                                          // Light
    GL11.glEnable(GL11.GL_LIGHT1); // Enable Light One

    // GL11.glEnable(GL11.GL_LIGHTING);

    Display.setVSyncEnabled(true);

}

From source file:zsawyer.mods.stereoscopic3d.MinecraftCopy.java

License:Open Source License

/**
 * Displays a new screen./*from   w  ww .j  a  v  a  2s.com*/
 */
public static void loadScreen() throws LWJGLException {
    ScaledResolution var1 = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
    GL11.glClear(16640);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0.0D, var1.getScaledWidth_double(), var1.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
    GL11.glViewport(0, 0, mc.displayWidth, mc.displayHeight);
    GL11.glClearColor(0.0F, 0.0F, 0.0F, 0.0F);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_FOG);
    Tessellator var2 = Tessellator.instance;
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.renderEngine.getTexture("/title/mojang.png"));
    var2.startDrawingQuads();
    var2.setColorOpaque_I(16777215);
    var2.addVertexWithUV(0.0D, (double) mc.displayHeight, 0.0D, 0.0D, 0.0D);
    var2.addVertexWithUV((double) mc.displayWidth, (double) mc.displayHeight, 0.0D, 0.0D, 0.0D);
    var2.addVertexWithUV((double) mc.displayWidth, 0.0D, 0.0D, 0.0D, 0.0D);
    var2.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
    var2.draw();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    var2.setColorOpaque_I(16777215);
    short var3 = 256;
    short var4 = 256;
    mc.scaledTessellator((var1.getScaledWidth() - var3) / 2, (var1.getScaledHeight() - var4) / 2, 0, 0, var3,
            var4);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_FOG);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
    Display.swapBuffers();
}