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:com.dinasgames.engine.graphics.GL.java

public static void clearColor(GLColor color) {
    if (version >= 11) {
        GL11.glClearColor(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    }/* w  w  w .ja v a 2  s  .c  o m*/
}

From source file:com.flowpowered.caustic.lwjgl.gl20.GL20Context.java

License:MIT License

@Override
public void setClearColor(Vector4f color) {
    checkCreated();//from ww  w.  ja  va 2s. c  om
    GL11.glClearColor(color.getX(), color.getY(), color.getZ(), color.getW());
    // Check for errors
    LWJGLUtil.checkForGLError();
}

From source file:com.gameminers.ethereal.architect.ModelCanvas.java

License:Open Source License

@Override
protected void paintGL() {
    try {//from   w  w w.j a v a  2  s .c o m
        if (getWidth() != current_width || getHeight() != current_height) {
            current_width = getWidth();
            current_height = getHeight();
            GL11.glViewport(0, 0, current_width, current_height);
        }
        GL11.glClearColor(0.0f, 0.6f, 0.5f, 1.0f);
        GL11.glClearDepth(1.0);
        GL11.glColor3f(1, 1, 1);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
        GL11.glLoadIdentity();
        GLU.gluPerspective(45.0f, (float) getWidth() / (float) getHeight(), 0.1f, 1000.0f);
        GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPushMatrix();
        GL11.glTranslatef(0, 0, zoom);
        GL11.glRotatef(angle, 0f, 1f, 0f);
        GL11.glRotatef(tilt, 1f, 0f, 0f);
        GL11.glTranslatef(-16, -16, -16);
        if (lit) {
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_LIGHT0);
            GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, lightPosition);
            GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, lightAmbient);
        } else {
            GL11.glDisable(GL11.GL_LIGHTING);
        }
        if (textured) {
            GL11.glEnable(GL11.GL_TEXTURE_2D);
        } else {
            GL11.glDisable(GL11.GL_TEXTURE_2D);
        }
        if (model != null) {
            if (model.isAmbientOcclusionEnabled()) {
                GL11.glShadeModel(GL11.GL_SMOOTH);
            } else {
                GL11.glShadeModel(GL11.GL_FLAT);
            }
            for (ModelElement ele : model.getElements()) {
                GL11.glPushMatrix();
                if (ele.isShade()) {
                    GL11.glEnable(GL11.GL_LIGHTING);
                } else {
                    GL11.glDisable(GL11.GL_LIGHTING);
                }
                float fromX = ele.getFrom()[0];
                float fromY = ele.getFrom()[1];
                float fromZ = ele.getFrom()[2];
                float toX = ele.getTo()[0];
                float toY = ele.getTo()[1];
                float toZ = ele.getTo()[2];

                float fX = (fromX > toX ? fromX : toX);
                float fY = (fromY > toY ? fromY : toY);
                float fZ = (fromZ > toZ ? fromZ : toZ);
                float tX = (fromX > toX ? toX : fromX);
                float tY = (fromY > toY ? toY : fromY);
                float tZ = (fromZ > toZ ? toZ : fromZ);

                GL11.glTranslatef(fX, fY, fZ);
                float scaleX = tX - fX;
                float scaleY = tY - fY;
                float scaleZ = tZ - fZ;
                GL11.glBegin(GL11.GL_QUADS);
                GL11.glNormal3f(0, 0, -1f);
                for (int i = 0; i < vertices.length / 3; i++) {
                    int faceIdx = i / 4;
                    ModelFace face;
                    switch (faceIdx) {
                    case 0:
                        face = ele.getFaces().getNorth();
                        break;
                    case 1:
                        face = ele.getFaces().getSouth();
                        break;
                    case 2:
                        face = ele.getFaces().getUp();
                        break;
                    case 3:
                        face = ele.getFaces().getDown();
                        break;
                    case 4:
                        face = ele.getFaces().getWest();
                        break;
                    case 5:
                        face = ele.getFaces().getEast();
                        break;
                    default:
                        face = null;
                        break;
                    }
                    int idx = i * 3;
                    float vX = vertices[idx] * scaleX;
                    float vY = vertices[idx + 1] * scaleY;
                    float vZ = vertices[idx + 2] * scaleZ;
                    /*float u;
                    float v;
                    GL11.glTexCoord2f(u, v);*/
                    GL11.glVertex3f(vX, vY, vZ);
                }
                GL11.glEnd();
                GL11.glPopMatrix();
            }
        }
        GL11.glPopMatrix();
        swapBuffers();
        repaint();
    } catch (LWJGLException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.gameminers.mav.Mav.java

License:Open Source License

private static void drawBasicScreen(String s, float dim) {
    Rendering.setUpGL();//from   w  w  w  . j  av a  2  s  . c om
    Rendering.beforeFrame(Display.getWidth(), Display.getHeight());
    GL11.glClearColor(0, 0, 0, 1);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    Fonts.light[2].drawString((Display.getWidth() / 2) - (Fonts.light[2].getWidth(s) / 2), 160, s, Color.white);
    Rendering.drawTriangle(Display.getWidth() / 2f, 90, 74, 0.5f, 0.5f, 0.5f, 0.5f, 0);
    Rendering.drawTriangle(Display.getWidth() / 2f, 90, 64, 0.5f, 0.5f, 0.5f, 1, 0.5f);
    Rendering.drawTriangle(Display.getWidth() / 2f, 90, 56, 0, 0, 0, 1, 1f);
    Rendering.drawRectangle(0, 0, Display.getWidth(), Display.getHeight(), 0, 0, 0, dim, 1);
    Display.update();
}

From source file:com.gameminers.mav.personality.poly.PolygonPersonality.java

License:Open Source License

@Override
public void renderBackground() {
    /*long delta = System.currentTimeMillis()-Mav.lastInputEvent;
    if (delta > IDLE_TIME) {// w w w .  j  a  v a  2s. c o  m
       bgLum = (1.0f-(Math.min(delta-IDLE_TIME, IDLE_FADE_OUT_TIME)/IDLE_FADE_OUT_TIME))*0.3f;
       framesSinceFade = 0;
    } else {
       framesSinceFade++;
       bgLum = Math.min(0.3f, framesSinceFade/IDLE_FADE_IN_FRAMES);
    }*/
    float[] rgb = RenderState.getColor(bgLum);
    GL11.glClearColor(rgb[0], rgb[1], rgb[2], 1f);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
}

From source file:com.github.kajdreef.mazerunnermvn.Launcher.java

/**
 * Initialize the display./*  w  w  w .ja  v a2  s. com*/
 */
public void initDisplayLWJGL() {
    PixelFormat pixelFormat = new PixelFormat();
    ContextAttribs contextAtrributes = new ContextAttribs(3, 2).withForwardCompatible(true)
            .withProfileCore(true);

    try {
        Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
        Display.setTitle("MazeRunner");
        Display.create(pixelFormat, contextAtrributes);
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(-1);
    }

    GL11.glClearColor(0.4f, 0.6f, 0.9f, 0f);
    GL11.glViewport(0, 0, WIDTH, HEIGHT);

    // Enable depth test so the objects are rendered in the right way.
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glDepthMask(true);

    GL11.glEnable(GL11.GL_CULL_FACE);
}

From source file:com.github.reisnera.gameboylfb.App.java

License:GNU General Public License

public App() {
    // Set up error callback
    glfwSetErrorCallback(errorCallback = errorCallbackPrint(System.err));

    if (glfwInit() != GL11.GL_TRUE) {
        throw new IllegalStateException("Unable to initialize GLFW");
    }//from   ww  w . j  a va2 s .c o m
    glfwDefaultWindowHints();
    glfwWindowHint(GLFW_VISIBLE, GL11.GL_FALSE); // the window will stay hidden after creation
    glfwWindowHint(GLFW_RESIZABLE, GL11.GL_FALSE);

    window = glfwCreateWindow(WIDTH, HEIGHT, "gameboylfb", MemoryUtil.NULL, MemoryUtil.NULL);
    if (window == MemoryUtil.NULL) {
        throw new RuntimeException("Failed to create the GLFW window");
    }

    // Setup a key callback. It will be called every time a key is pressed, repeated or released.
    // It needs a window handle before it can be set
    glfwSetKeyCallback(window, keyCallback = new GLFWKeyCallback() {
        @Override
        public void invoke(long window, int key, int scancode, int action, int mods) {
            if (key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE)
                glfwSetWindowShouldClose(window, GL11.GL_TRUE); // We will detect this in our rendering loop
        }
    });

    // Get the resolution of the primary monitor
    ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
    // Center our window
    glfwSetWindowPos(window, (GLFWvidmode.width(vidmode) - WIDTH) / 2,
            (GLFWvidmode.height(vidmode) - HEIGHT) / 2);

    // Make the OpenGL context current
    glfwMakeContextCurrent(window);
    // Enable v-sync
    glfwSwapInterval(1);

    // Make the window visible
    glfwShowWindow(window);
    //GL.createCapabilities(true); // Load LWJGL's current context without deprecated functions
    GLContext.createFromCurrent(); // use this line instead with the 3.0.0a build

    // Clear buffer to Game Boy off-state display color
    GL11.glClearColor(0.605f, 0.734f, 0.059f, 1.0f);
}

From source file:com.google.gapid.glviewer.GeometryScene.java

License:Apache License

@Override
public void init(Renderer renderer) {
    float[] background = new float[] { .2f, .2f, .2f, 1f };

    LOG.log(FINE, "GL Version:   " + GL11.glGetString(GL11.GL_VERSION));
    LOG.log(FINE, "GLSL Version: " + GL11.glGetString(GL20.GL_SHADING_LANGUAGE_VERSION));

    shaders = Shaders.init(renderer);//from w w  w  .j ava 2s  .  c  om
    if (renderable != null) {
        renderable.init(renderer);
    }

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glClearColor(background[0], background[1], background[2], background[3]);
    GL11.glPointSize(4);
    GL30.glBindVertexArray(GL30.glGenVertexArrays());
}

From source file:com.google.gapid.glviewer.gl.Renderer.java

License:Apache License

/** Clears the viewport with the given solid color */
public static void clear(Color c) {
    GL11.glClearColor(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, 1f);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
}

From source file:com.google.gapid.glviewer.Viewer.java

License:Apache License

@Override
public void init() {
    float[] background = new float[] { .2f, .2f, .2f, 1f };

    LOG.log(FINE, "GL Version:   " + GL11.glGetString(GL11.GL_VERSION));
    LOG.log(FINE, "GLSL Version: " + GL11.glGetString(GL20.GL_SHADING_LANGUAGE_VERSION));

    shaders = Shaders.init();//from  w  w  w .ja v a2s  .  co m
    if (renderable != null) {
        renderable.init();
    }

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glClearColor(background[0], background[1], background[2], background[3]);
    GL11.glPointSize(4);
    GL30.glBindVertexArray(GL30.glGenVertexArrays());
}