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:RobotDemo.java

private void loop() {
    GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    GL11.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);

    while (GLFW.glfwWindowShouldClose(window) != GL11.GL_TRUE) {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glPushMatrix();//from  ww w  . j  a v a  2s . c  o  m
        for (Robot r : robots)
            r.draw();
        GL11.glPopMatrix();
        GLFW.glfwSwapBuffers(window);
        GLFW.glfwPollEvents();
    }
}

From source file:$.DrawSystem.java

License:Open Source License

@Override
    protected void processEntities(ImmutableBag<Entity> entities) {
        GL11.glClearColor(0.1f, 0, 0, 1f);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
        List<Entity> entititesSortedByZ = new ArrayList<>(entities.size());
        for (int i = 0, n = entities.size(); i < n; ++i) {
            final Entity e = entities.get(i);
            if (e.isEnabled()) {
                entititesSortedByZ.add(e);
            }/*from   w  ww  .  j a  va2  s.  com*/
        }
        Collections.sort(entititesSortedByZ, zComparator);

        GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_TRANSFORM_BIT | GL11.GL_HINT_BIT | GL11.GL_COLOR_BUFFER_BIT
                | GL11.GL_SCISSOR_BIT | GL11.GL_LINE_BIT | GL11.GL_TEXTURE_BIT);
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();

        updateViewPort();
        GL11.glViewport(viewPort.x, viewPort.y, viewPort.width, viewPort.height);
        GLU.gluOrtho2D(-toolkit.getVirtualResolutionWidth() / 2.0f, toolkit.getVirtualResolutionWidth() / 2.0f,
                toolkit.getVirtualResolutionHeight() / 2.0f, -toolkit.getVirtualResolutionHeight() / 2.0f);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LINE_SMOOTH);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_SCISSOR_TEST);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);

        Game game = (Game) world;
        Entity hero = game.getHero();
        if (null != hero) {
            Sprite heroSprite = spriteMapper.get(hero);
            Vector heroPos = spriteProjector.project(heroSprite.getPosition());
            GL11.glTranslatef(-heroPos.x, -heroPos.y, 0.0f);
        }

        for (Entity e : entititesSortedByZ) {
            MainMenu mainMenu = mainMenuMapper.getSafe(e);
            if (null != mainMenu) {
                mainMenu.draw();
            }
            DialogueComponent dialog = dialogMapper.getSafe(e);
            if (null != dialog) {
                dialog.draw();
            }
            Level level = levelMapper.getSafe(e);
            if (null != level) {
                drawLevel(level);
            }
            Sprite sprite = spriteMapper.getSafe(e);
            if (null != sprite) {
                drawSprite(sprite);
            }
        }
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPopMatrix();
        GL11.glPopAttrib();

    }

From source file:a1.gui.GUI_Map.java

License:Open Source License

public void CreateLightMap() {

    //Coord screen_size = new Coord(Config.getScreenWidth(), Config.getScreenHeight());
    //Coord screen_coord = new Coord(GUI.map.mc).sub(screen_size.div(2));
    List<Coord> lst = new ArrayList<Coord>();

    for (RenderPart p : render_parts) {
        Drawable d = p.owner.getattr(Drawable.class);
        if (d != null) {
            if (d.name.contains("fir")) {
                lst.add(p.dc);/*  w w  w  .j  ava2  s  . c o m*/
            }
            if (d.name.contains("player")) {
                lst.add(p.dc);
            }
        }
    }

    //      for (Obj o : ObjCache.objs.values()) {
    //         Drawable d = o.getattr(Drawable.class);
    //         if (d != null) {
    //            if (d.name.contains("tree")) {
    //               if (o.getpos().in_rect(screen_coord, screen_size))
    //                  lst.add(o.getpos());
    //            }
    //         }
    //      }

    if (first) {
        first = false;
        boolean FBOEnabled = GLContext.getCapabilities().GL_EXT_framebuffer_object;
        if (!FBOEnabled)
            Log.info("No FBO");
        myFBOId = EXTFramebufferObject.glGenFramebuffersEXT();
        //LightMap = GL11.glGenTextures();

        EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, myFBOId);
        EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
                EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, LightMap, 0);
        EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0);
    }

    //ByteBuffer bb = ByteBuffer.allocate(1024 * 1024 * 4);
    //GL11.glReadPixels(0, 0, 1024, 768, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, bb);

    // ? FBO  ?  ?
    EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, myFBOId);
    //      GL11.glPushAttrib(GL11.GL_VIEWPORT_BIT);
    //  ?
    //      GL11.glViewport( 0, 0, 1024, 1024 );
    //      
    // ? 
    //   ?
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glClearColor(0.3f, 0.3f, 0.4f, 1.0f);
    GL11.glClear(GL_COLOR_BUFFER_BIT);

    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);

    //  ? ? ?
    for (Coord c : lst)
        DrawLight(c, 100, 100);

    /*GL11.glTranslatef(0, 0, -6f);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex3f(0, 0, 0);
    GL11.glVertex3f(200, 0, 0);
    GL11.glVertex3f(200, 200, 0);
    GL11.glVertex3f(0, 200, 0);
    GL11.glEnd();*/
    //      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0);
    //      GL11.glPopAttrib();

    //      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    //      
    //  
    //GL11.glBindTexture(GL11.GL_TEXTURE_2D, LightMap);
    //Render2D.CheckError();

    //    ?  - ? 
    //GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, 0, 0, 1024, 1024, 0);
    //GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1024, 1024);
    //Render2D.CheckError();

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

}

From source file:akarnokd.opengl.experiment.FontExample.java

License:Apache License

/**
 * Initialise the GL display/*from   w  w w  .  j a v  a2 s .  co m*/
 * 
 * @param width The width of the display
 * @param height The height of the display
 */
private void initGL(int width, int height) {
    try {
        Display.setDisplayMode(new DisplayMode(width, height));
        Display.create();
        Display.setVSyncEnabled(true);
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(0);
    }

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);

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

    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);
}

From source file:ar.com.quark.backend.lwjgl.opengl.DesktopGLES20.java

License:Apache License

/**
 * {@inheritDoc}/*from  w w  w.  j ava2 s. co  m*/
 */
@Override
public void glClearColor(float red, float green, float blue, float alpha) {
    GL11.glClearColor(red, green, blue, alpha);
}

From source file:bd.ac.seu.lwjgldemo.Renderer.java

private void drawSomething() {
    GL11.glClearColor(0, 0, 0, 1);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

    GL11.glColor3f(1, 1, 0);// w ww .j  a  v  a  2 s . c  o m

    GL11.glPushMatrix();
    GL11.glRotatef(angle, 0, 0, 1);
    /*
    GL11.glBegin(GL11.GL_QUADS);
    for (int row = 0; row < vertices.length; row = row + 3) {
    double x = vertices[row];
    double y = vertices[row + 1];
    double z = vertices[row + 2];
    GL11.glVertex3d(x, y, z);
    }
    GL11.glEnd();
    */

    GL30.glBindVertexArray(vaoId);
    GL20.glEnableVertexAttribArray(0);

    // Draw the vertices
    GL11.glDrawArrays(GL11.GL_QUADS, 0, vertices.length / 3);

    // Put everything back to default (deselect)
    GL20.glDisableVertexAttribArray(0);
    GL30.glBindVertexArray(0);

    GL11.glPopMatrix();

    angle = angle + .10f;
    frameCounter++;
    long currentTime = System.nanoTime();
    long timeDifference = currentTime - lastTime;
    double fps = 1000000000.0 / timeDifference;
    System.out.printf("FPS: %.3f\n", fps);
    lastTime = currentTime;
}

From source file:br.com.perin.renderEngine.Renderer.java

public void prepare() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    GL11.glClearColor(1, 0, 0, 1);
}

From source file:br.org.archimedes.gui.opengl.OpenGLWrapper.java

License:Open Source License

/**
 * Initializes the OpenGL for the specified GLCanvas.
 * /*from  w w  w  .  ja va  2  s. c  o  m*/
 * @param canvas
 *            The GLCanvas to be initialized.
 */
protected void initGL(GLCanvas canvas) {

    GLCanvas current = currentCanvas;
    setCurrentCanvas(canvas);
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    setCurrentCanvas(current);
}

From source file:br.org.archimedes.gui.opengl.OpenGLWrapper.java

License:Open Source License

/**
 * Clears the OpenGL canvas.//from   www  . j ava  2 s  . c om
 */
public void clear() {
    Color currentBkColor = br.org.archimedes.Utils.getWorkspace().getBackgroundColor();
    GL11.glClearColor((float) currentBkColor.getR(), (float) currentBkColor.getG(),
            (float) currentBkColor.getB(), 0);

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    resize();
}

From source file:cellularautomata.CellularAutomata.java

public static void renderGL() {
    try { //Trys to create a game window size 500x700.
        Display.setDisplayMode(new org.lwjgl.opengl.DisplayMode(800, 600));
        Display.create();// w  w w. j av a  2s  . co  m
    } catch (LWJGLException e) { //Catches exception if game window is not created.
        e.printStackTrace();
        System.exit(0);
    }

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //Sets colour to white.
    GL11.glClearDepth(1);

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

    GL11.glViewport(0, 0, 800, 600);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, 800, 600, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    Display.setVSyncEnabled(vsync);
}