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:Model.Render.java

public void pripravi() {
    GL11.glClearColor(1, 0, 0, 1);
}

From source file:modeledit.ModelView3D.java

License:Open Source License

private void glInit() {
    try {//  ww  w .  j a v  a  2 s  . com
        this.makeCurrent();
    } catch (Exception e) {
        return;
        //           e.printStackTrace();
    }
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_CULL_FACE);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GLU.gluPerspective(40, ((float) this.getWidth()) / ((float) this.getHeight()), 1, 100);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glShadeModel(GL11.GL_SMOOTH);
    //      GL11.glPolygonMode(GL11.GL_FRONT,GL11.GL_LINE); 
    //      GL11.glEnable(GL11.GL_TEXTURE_2D); // Enable Texture Mapping

    GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, get(whiteLight));
    GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, get(whiteLight));

    GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, get(ambientLight));

    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_LIGHT0);

    GLUtils.glLightPos(1.0f, 1.0f, 1.0f);

    //       GL11.glTexParameteri(GL11.GL_TEXTURE_2D,GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
    //       GL11.glTexParameteri(GL11.GL_TEXTURE_2D,GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);

}

From source file:net.ae97.notlet.client.GameInstance.java

License:Open Source License

public static void createTextures() throws LWJGLException {
    Display.setDisplayMode(new DisplayMode(width, height));
    Display.create();//from   w  w  w. j  av a 2 s  . co m
    Display.setVSyncEnabled(true);

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    // enable alpha blending
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glViewport(0, 0, width, height);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, width, height, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    Font awtFont = new Font("Times New Roman", Font.BOLD, 18);
    font = new TrueTypeFont(awtFont, true);

    try {
        textureMapping.put("SMALLLET",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("SMALLLET.png")));
        textureMapping.put("healthbar",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("healthbar.png")));
        textureMapping.put("score",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("score.png")));
        textureMapping.put("arrow",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("arrow.png")));
        textureMapping.put("dirt",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("dirt.png")));
        textureMapping.put("rangerD",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("rangerD.png")));
        textureMapping.put("rangerL",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("rangerL.png")));
        textureMapping.put("rangerR",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("rangerR.png")));
        textureMapping.put("rangerU",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("rangerU.png")));
        textureMapping.put("skele",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("skele.png")));
        textureMapping.put("slime",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("slime.png")));
        textureMapping.put("hp", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("hp.png")));
        textureMapping.put("pb", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("pb.png")));
        textureMapping.put("wall",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("wall.png")));
        textureMapping.put("exit",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("exit.png")));
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:net.BiggerOnTheInside.Binder.Binder.java

License:Open Source License

/**
 * <p>Sets up OpenGL.</p>/*from w w  w  .ja  va2s.com*/
 */
public void initGL() {
    int width = displayMode.getWidth();
    int height = displayMode.getHeight();

    /* Enable 2D texturing. */
    GL11.glEnable(GL11.GL_TEXTURE_2D);

    /* Make all models smoothly textured. */
    GL11.glShadeModel(GL11.GL_SMOOTH);

    /* Set the background color to that signature blue. */
    GL11.glClearColor(0.9f, 1.0f, 1.0f, 0.0f);

    /* Set the clear depth to all-the-way */
    GL11.glClearDepth(1.0);

    /* Enable the depth system. */
    GL11.glEnable(GL11.GL_DEPTH_TEST);

    /* Set the function for depth to GL_LEQUAL. */
    GL11.glDepthFunc(GL11.GL_LEQUAL);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    /* Enable face culling, basically don't render this face relative to the camera's position. */
    GL11.glEnable(GL11.GL_CULL_FACE);

    /* Set OpenGL to cull the back face of our spatials. */
    GL11.glCullFace(GL11.GL_BACK);

    /* Set the matrix mode to projection. */
    GL11.glMatrixMode(GL11.GL_PROJECTION);

    /* Reset the OpenGL configuration, loading our above prefrences. */
    //GL11.glLoadIdentity();

    /* Set the perspective. */
    GLU.gluPerspective(45.0f, (float) displayMode.getWidth() / (float) displayMode.getHeight(), 0.1f, 100.0f);

    /* Set the matrix mode to be model view. */
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    /* Set the perspective correction hint to finest quality. */
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
}

From source file:net.bryanbergen.lwjgl.display.Window.java

public void setBackground(Color background) {
    this.background = background;
    GL11.glClearColor((float) background.getRed(), (float) background.getGreen(), (float) background.getBlue(),
            (float) background.getAlpha());
}

From source file:net.bryanbergen.lwjgl.display.Window.java

private void initGLFW() {
    if (GLFW.glfwInit() != GL_TRUE) {
        throw new IllegalStateException("Failed to initialize GLFW");
    }/*from   w ww.  j av  a2  s .com*/

    GLFW.glfwDefaultWindowHints();
    GLFW.glfwWindowHint(GLFW_VISIBLE, visible ? GL_TRUE : GL_FALSE);
    GLFW.glfwWindowHint(GLFW_RESIZABLE, resizable ? GL_TRUE : GL_FALSE);

    windowHandle = GLFW.glfwCreateWindow(dimension.getWidth(), dimension.getHeight(), title,
            fullscreen ? GLFW.glfwGetPrimaryMonitor() : NULL, NULL);

    if (windowHandle == NULL) {
        throw new RuntimeException("Failed to initialized GLFW Window");
    }

    GLFWVidMode vidmode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
    GLFW.glfwSetWindowPos(windowHandle, (vidmode.width() - dimension.getWidth()) / 2,
            (vidmode.height() - dimension.getHeight()) / 2);

    GLFW.glfwMakeContextCurrent(windowHandle);

    initCallbacks();

    GLFW.glfwSwapInterval(vsync ? 1 : 0);
    GL.createCapabilities();

    GL11.glClearColor((float) background.getRed(), (float) background.getGreen(), (float) background.getBlue(),
            (float) background.getAlpha());

}

From source file:net.fabricmc.base.launch.FabricClientTweaker.java

License:Apache License

private void createEarlyDisplay() {
    File gameDir = new File(args.get("--gameDir"));
    Properties def = new Properties();
    def.setProperty("fullscreen", "false");
    def.setProperty("overrideWidth", "0");
    def.setProperty("overrideHeight", "0");
    Properties props = new Properties(def);
    try {/*w w  w .j av  a  2 s  . c  o m*/
        props.load(Files.newReader(new File(gameDir, "options.txt"), StandardCharsets.UTF_8));
    } catch (FileNotFoundException e) {
    } catch (IOException e) {
        e.printStackTrace();
    }
    boolean fullscreen = args.containsKey("--fullscreen")
            || Boolean.parseBoolean(props.getProperty("fullscreen"));
    int overrideWidth = Integer.parseInt(props.getProperty("overrideWidth"));
    int overrideHeight = Integer.parseInt(props.getProperty("overrideHeight"));
    int width = 854;
    int height = 480;
    if (overrideWidth > 0) {
        width = overrideWidth;
    } else if (args.containsKey("--width")) {
        width = Math.max(1, Integer.parseInt(args.get("--width")));
    }
    if (overrideHeight > 0) {
        height = overrideHeight;
    } else if (args.containsKey("--height")) {
        height = Math.max(1, Integer.parseInt(args.get("--height")));
    }
    String ver = args.get("--version");
    if (ver == null) {
        ver = "Unknown";
    } else {
        int index = ver.indexOf('-');
        if (index != -1) {
            ver = ver.substring(0, index);
        }
    }
    try {
        Display.setDisplayMode(new DisplayMode(width, height));
        Display.setFullscreen(fullscreen);
        Display.setResizable(true);
        Display.setTitle("Minecraft " + ver);
        try {
            Display.create(new PixelFormat().withDepthBits(24));
        } catch (LWJGLException e) {
            e.printStackTrace();
            Display.create();
        }
        GL11.glClearColor(1, 1, 1, 1);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
        Display.update();
    } catch (LWJGLException e1) {
        e1.printStackTrace();
        Throwables.propagate(e1);
    }
}

From source file:net.kubin.world.World.java

License:Apache License

public void render() {
    /* Prepare Matrixes */
    Game.getInstance().initSceneRendering();
    Configuration configuration = Kubin.getConfiguration();

    /* Look through the camera with high viewing distance to render the sky */
    _player.getFirstPersonCamera().lookThrough(512.0f);

    /* Set the fog color based on time */
    _fogColor.set(Kubin.getConfiguration().getFogColor());
    _fogColor.scale(_sunlight - 0.05f);//  w w w . j a  v a  2 s .  c o  m
    GL11.glFog(GL11.GL_FOG_COLOR, GLUtils.wrapDirect(_fogColor.x(), _fogColor.y(), _fogColor.z(), 1.0f));
    GL11.glClearColor(_fogColor.x(), _fogColor.y(), _fogColor.z(), 1.0f);

    /* Render the sky */
    GL11.glFogf(GL11.GL_FOG_START, 200);
    GL11.glFogf(GL11.GL_FOG_END, 400);
    _sky.renderSky();

    /* Restore the fog distance */
    GL11.glFogf(GL11.GL_FOG_START, configuration.getViewingDistance() * 0.55f);
    GL11.glFogf(GL11.GL_FOG_END, configuration.getViewingDistance());

    /* Select the visible blocks */
    selectVisibleChunks(_player.getFirstPersonCamera().getViewFrustum());

    /* Bind the terrain texture */
    //GL11.glEnable(GL11.GL_TEXTURE_2D);
    //TextureStorage.getTexture("terrain").bind();

    PerformanceMonitor.getInstance().start(Operation.RENDER_OPAQUE);

    for (int i = 0; i < _visibleChunks.size(); ++i) {
        _visibleChunks.get(i).render(MeshType.OPAQUE);
    }

    PerformanceMonitor.getInstance().stop(Operation.RENDER_OPAQUE);
    PerformanceMonitor.getInstance().start(Operation.RENDER_TRANSLUCENT);

    for (int i = 0; i < _visibleChunks.size(); ++i) {
        _visibleChunks.get(i).render(MeshType.TRANSLUCENT);
    }

    PerformanceMonitor.getInstance().stop(Operation.RENDER_TRANSLUCENT);
    PerformanceMonitor.getInstance().start(Operation.RENDER_MANUAL);

    for (int i = 0; i < _visibleChunks.size(); ++i) {
        _visibleChunks.get(i).renderManualBlocks();
    }

    PerformanceMonitor.getInstance().stop(Operation.RENDER_MANUAL);

    /* Render the clouds */
    GL11.glFogf(GL11.GL_FOG_START, 200);
    GL11.glFogf(GL11.GL_FOG_END, 400);
    _sky.renderClouds();

    _player.render();

    renderOverlay();
}

From source file:net.neilcsmith.praxis.video.opengl.internal.GLRenderer.java

License:Apache License

public void clear() {
    activate();/*from ww w  . ja v  a  2  s  .c  o m*/
    tex0 = null;
    idx = 0;
    if (surface == null) {
        LOGGER.finest("Clearing screen");
        GL11.glClearColor(0, 0, 0, 1);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    } else {
        LOGGER.finest("Clearing surface");
        if (surface.hasAlpha()) {
            GL11.glClearColor(0, 0, 0, 0);
        } else {
            GL11.glClearColor(0, 0, 0, 1);
        }
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    }
}

From source file:net.phatcode.rel.multimedia.Renderer.java

License:Open Source License

Renderer(int screenWidth, int screenHeight) {
    try {/*  w  ww  . j  a v  a2 s  .c  o m*/
        Display.setDisplayMode(new DisplayMode(screenWidth, screenHeight));
        Display.create();
        Display.setTitle("AnyaBasic 0.4.0 beta");
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    this.screenWidth = screenWidth;
    this.screenHeight = screenHeight;

    GL11.glViewport(0, 0, screenWidth, screenHeight);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();

    GL11.glOrtho(0, screenWidth, screenHeight, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glLoadIdentity();

    GL11.glShadeModel(GL11.GL_SMOOTH); //set shading to smooth(try GL_FLAT)
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); //set Clear color to BLACK
    GL11.glClearDepth(1.0f); //Set Depth buffer to 1(z-Buffer)
    GL11.glDisable(GL11.GL_DEPTH_TEST); //Disable Depth Testing so that our z-buffer works

    GL11.glDepthFunc(GL11.GL_LEQUAL);

    GL11.glEnable(GL11.GL_COLOR_MATERIAL);

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);

    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(0.375f, 0.375f, 0); // magic trick

}