Example usage for org.lwjgl.opengl GL11 glEnable

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

Introduction

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

Prototype

public static void glEnable(@NativeType("GLenum") int target) 

Source Link

Document

Enables the specified OpenGL state.

Usage

From source file:com.opengrave.og.engine.RenderView.java

License:Open Source License

public void render(int totalx, int totaly, int width, int height) {
    this.totalx = totalx;
    this.totaly = totaly;
    this.width = width;
    this.height = height;
    if (sceneNode == null) {
        System.out.println("No scene node to render");
        return;/* ww w  . j a  v a  2 s  .  c o  m*/
    }
    if (cam == null) {
        System.out.println("No camera to render from");
        return;
    }
    Shadow2D skyLight = sceneNode.getSkyLight();
    if (shadows && hasshadows) {
        // For each light source we map out a texture using a quick
        // render.
        prepare3DShadow();

        skyLight.getFramebuffer().bindDraw();
        // GL11.glEnable(GL32.GL_DEPTH_CLAMP); // TODO Simu;ate depth clamp in shadow shader when z < 0. This way we force distanced objects to still cast a shadow.
        sceneNode.renderShadows(ident, skyLight);
        skyLight.getFramebuffer().unbindDraw();
        int count = 0;
        ArrayList<PointLightNode> lightList = new ArrayList<PointLightNode>();
        sceneNode.getAllLights(lightList, ident, cam.getLocation().toVector4());
        Collections.sort(lightList, new PointLightSorter());
        for (PointLightNode light : lightList) {
            if (light.getColour().x > 0 || light.getColour().y > 0 || light.getColour().z > 0) {
                // Render each face
                if (lightShadows.size() == count) {
                    ShadowCube shadow = new ShadowCube(MainThread.config.getInteger("shadowSize", 1024));
                    lightShadows.add(shadow);
                }
                ShadowCube shadow = lightShadows.get(count);
                shadow.setLight(light);
                for (int i = 0; i < 6; i++) {
                    shadow.getFramebuffer().bindDraw(i);
                    Util.checkErr();
                    shadow.setFace(i);
                    Util.checkErr();
                    sceneNode.renderShadows(ident, shadow);
                    Util.checkErr();
                    shadow.getFramebuffer().unbindDraw();
                    Util.checkErr();
                }

                count++;
            }
            if (count == 16) {
                break;
            }
        }
        GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);

    }
    GL11.glViewport(totalx, totaly, width, height);
    GL11.glScissor(totalx, totaly, width, height);
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    GL11.glClearColor(clearCol.x, clearCol.y, clearCol.z, clearCol.w);
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT | (clear ? GL11.GL_COLOR_BUFFER_BIT : 0));
    Util.checkErr();

    prepare3DOpaque();
    sceneNode.render(ident);
    Util.checkErr();
    prepare3DTransparent();
    sceneNode.renderSemiTransparent(ident);
    MouseRenderableHoverEvent lF = MainThread.main.input.getLastHovered();
    if (lF != null) {
        if (lF.getRenderable() instanceof BaseObject) {
            /*
             * GL11.glDepthFunc(GL11.GL_LESS);
             * GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
             * GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_LINE);
             * 
             * GL11.glLineWidth(10f);
             * GL11.glCullFace(GL11.GL_FRONT);
             * GL11.glEnable(GL11.GL_CULL_FACE);
             * GL11.glDisable(GL11.GL_BLEND);
             * BaseObject bo = (BaseObject) lF.getRenderable();
             * RenderStyle rs = bo.getRenderStyle();
             * bo.setRenderStyle(RenderStyle.HALO);
             * sceneNode.renderOne(ident, bo, ident);
             * 
             * GL11.glDisable(GL11.GL_BLEND);
             * 
             * bo.setRenderStyle(rs);
             * GL11.glCullFace(GL11.GL_BACK);
             * GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
             * GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_FILL);
             * 
             * GL11.glLineWidth(1f);
             * sceneNode.renderOne(ident, bo, ident);
             */

        }
    }

    revertSettings();
    GL11.glDisable(GL11.GL_SCISSOR_TEST);

}

From source file:com.opengrave.og.engine.RenderView.java

License:Open Source License

private void prepare3DShadow() {
    GL11.glDisable(GL11.GL_BLEND);//w ww.  jav  a 2 s  . c om
    GL11.glDepthFunc(GL11.GL_LESS);
    // GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
    // GL11.glPolygonOffset(1.1f, 10f);
    GL11.glCullFace(GL11.GL_FRONT);
    GL11.glEnable(GL11.GL_CULL_FACE);
}

From source file:com.opengrave.og.engine.RenderView.java

License:Open Source License

private void revertSettings() {
    GL11.glViewport(0, 0, MainThread.lastW, MainThread.lastH);
    GL11.glDisable(GL11.GL_CULL_FACE);//from  w  w w  . j  av a  2  s . co m
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
}

From source file:com.opengrave.og.engine.RenderView.java

License:Open Source License

public void prepare3DTransparent() {
    Util.checkErr();/*  w  w  w  . j  ava2 s.  c  o  m*/
    GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
    Util.checkErr();
    GL11.glEnable(GL11.GL_BLEND);
    Util.checkErr();
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    Util.checkErr();
    GL11.glDisable(GL11.GL_CULL_FACE);
}

From source file:com.opengrave.og.engine.RenderView.java

License:Open Source License

private void prepare3DOpaque() {
    GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);

    GL11.glDisable(GL11.GL_BLEND);/* w ww.  ja v  a  2s  .c o  m*/
    GL11.glDepthFunc(GL11.GL_LESS);
    GL11.glCullFace(GL11.GL_BACK);
    GL11.glEnable(GL11.GL_CULL_FACE);
}

From source file:com.opengrave.og.gui.ScrollBox.java

License:Open Source License

/**
 * Special cases Ho!// w w w  .  java2  s  .  c  om
 */
@Override
public void render(int totalx, int totaly) {
    synchronized (children) {
        UIElement e = children.get(0);

        // GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        // GL11.glEnable(GL11.GL_DEPTH_TEST);
        // GL11.glDepthFunc(GL11.GL_LESS);
        // Render box at location
        // location2d = new Vector3f(totalx, totaly, 0);
        // render(null, RenderStyle.NORMAL);
        // GL11.glDepthFunc(GL11.GL_EQUAL);
        // Render contents minus scroll ammount
        if (width < 0 || height < 0) {
            return;
        }
        GL11.glScissor(totalx, MainThread.lastH - (totaly + height), width, height);
        GL11.glEnable(GL11.GL_SCISSOR_TEST);
        e.render(totalx, (int) (totaly - scrolly));
        // GL11.glDepthFunc(GL11.GL_LESS);
        GL11.glDisable(GL11.GL_SCISSOR_TEST);

    }
}

From source file:com.opengrave.og.gui.ScrollBox.java

License:Open Source License

public void renderForPicking(int totalx, int totaly) {
    synchronized (children) {
        UIElement e = children.get(0);//from  ww w  .  j  a  v a 2s  .c  o  m

        // GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        // GL11.glEnable(GL11.GL_DEPTH_TEST);
        // GL11.glDepthFunc(GL11.GL_LESS);
        // Render box at location
        // location2d = new Vector3f(totalx, totaly, 0);
        // render(null, RenderStyle.NORMAL);
        // GL11.glDepthFunc(GL11.GL_EQUAL);
        // Render contents minus scroll ammount
        if (width < 0 || height < 0) {
            return;
        }
        GL11.glScissor(x, MainThread.lastH - (totaly + height), width, height);
        GL11.glEnable(GL11.GL_SCISSOR_TEST);

        e.renderForPicking(totalx, (int) (totaly - scrolly));
        GL11.glDisable(GL11.GL_SCISSOR_TEST);
    }
}

From source file:com.opengrave.og.light.Depth2DFramebuffer.java

License:Open Source License

@Override
public void bindDraw() {
    Util.checkErr();/*from  www .  j  a va 2  s.  com*/

    for (int i = GL13.GL_TEXTURE0; i < GL13.GL_TEXTURE31; i++) {
        GL13.glActiveTexture(i);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
        GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, 0);
        GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, 0);
    }
    Util.checkErr();
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer);
    Util.checkErr();
    GL11.glDisable(GL11.GL_BLEND);
    Util.checkErr();
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LESS);
    GL11.glDepthMask(true);
    Util.checkErr();
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    Util.checkErr();
    GL11.glViewport(0, 0, framebufferSize, framebufferSize);

}

From source file:com.opengrave.og.light.Depth2DFramebuffer.java

License:Open Source License

public void dumpTestingImage() {
    // TESTING/*from   w  w  w.j a va 2s  . c  o  m*/
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    int pID = Resources.loadShader("test.vs", "test.fs").getProgram();
    GL20.glUseProgram(pID);
    int shadow = GL20.glGetUniformLocation(pID, "shadowMap");
    GL20.glUniform1i(shadow, 0);
    GL30.glBindVertexArray(vao_ID);
    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);
    shadowMap.bind(GL13.GL_TEXTURE0);
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, count * 3);
    shadowMap.unbind();
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);

    GL20.glUseProgram(0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL30.glBindVertexArray(0);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    // END TESTING
}

From source file:com.opengrave.og.light.DepthCubeFramebuffer.java

License:Open Source License

public void bindDraw(int direction) {
    Util.checkErr();/* w  ww .j  av  a  2  s  . c o m*/
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer);
    shadowMap.bindToFrameBuffer(direction);
    Util.checkErr();

    Util.checkErr();
    GL11.glDisable(GL11.GL_BLEND);
    Util.checkErr();
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LESS);
    GL11.glDepthMask(true);
    Util.checkErr();
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    Util.checkErr();
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glViewport(0, 0, framebufferSize, framebufferSize);

}