Example usage for org.lwjgl.opengl GL11 glPolygonMode

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

Introduction

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

Prototype

public static void glPolygonMode(@NativeType("GLenum") int face, @NativeType("GLenum") int mode) 

Source Link

Document

Controls the interpretation of polygons for rasterization.

Usage

From source file:com.grillecube.engine.renderer.model.ModelRenderer.java

private void render(CameraProjective camera) {

    if (this._models == null) {
        return;/*from   w  ww . java 2 s  .c o  m*/
    }

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

    GL11.glEnable(GL11.GL_DEPTH_TEST);

    if (this.getParent().getGLFWWindow().isKeyPressed(GLFW.GLFW_KEY_F)) {
        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
    }

    // enable model program
    this._program_model.useStart();
    {
        // load global uniforms
        this._program_model.loadUniforms(camera);

        // for each model instance to render
        for (ModelInstance instance : this._models) {

            // the skin to use
            ModelSkin skin = instance.getModel().getSkin(instance.getSkinID());

            if (skin == null) {
                continue;
            }

            // render each of it parts
            ModelPartInstance[] instances = instance.getPartInstances();

            for (int i = 0; i < instances.length; i++) {

                ModelPartInstance part = instances[i];

                // load uniforms
                this._program_model.loadInstanceUniforms(part.getTransformationMatrix());
                // bind the part
                part.getModelPart().bind();
                // unable skin
                ModelPartSkin partskin = skin.getPart(i);
                part.getModelPart().toggleSkin(partskin);
                // render
                part.getModelPart().render();
                //
            }
            //
            // render equipment
            // if (instance.getEntity() instanceof EntityModeledLiving) {
            // EntityModeledLiving entity = (EntityModeledLiving)
            // instance.getEntity();
            // Item[] items = entity.getEquipments();
            //
            // // if the entity actually has equipmment
            // if (items != null) {
            // // for each of it equipments
            // for (Item item : items) {
            // // get it model
            // Model model = item.getModel();
            // // unable the skin
            // // model.toggleSkin(item.getSkinID());
            //
            // // TODO RENDER IT
            // }
            // }
            // }
        }
    }
    this._program_model.useStop();
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_BLEND);

    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
}

From source file:com.grillecube.engine.renderer.model.ModelRenderer.java

@Override
public void renderShadow(ShadowCamera shadow_camera) {

    if (this._models == null) {
        return;//from w  w  w  .  jav a 2 s .  c  o  m
    }

    GL11.glEnable(GL11.GL_DEPTH_TEST);

    if (this.getParent().getGLFWWindow().isKeyPressed(GLFW.GLFW_KEY_F)) {
        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
    }

    // enable model program
    this._program_model_shadow.useStart();
    {
        // load global uniforms
        this._program_model_shadow.loadUniforms(shadow_camera);

        // for each model instance to render
        for (ModelInstance instance : this._models) {

            // the skin to use
            ModelSkin skin = instance.getModel().getSkin(instance.getSkinID());
            if (skin == null) {
                continue;
            }

            // render each of it parts
            for (int i = 0; i < instance.getPartInstances().length; i++) {

                ModelPartInstance part = instance.getPartInstances()[i];

                // load uniforms
                this._program_model_shadow.loadInstanceUniforms(part);
                // bind the part
                part.getModelPart().bind();
                // unable skin
                ModelPartSkin partskin = skin.getPart(i);
                part.getModelPart().toggleSkin(partskin);
                // render
                part.getModelPart().render();
            }

            // render equipment
            if (instance.getEntity() instanceof EntityModeledLiving) {
                EntityModeledLiving entity = (EntityModeledLiving) instance.getEntity();
                Item[] items = entity.getEquipments();

                // if the entity actually has equipmment
                if (items != null) {
                    // for each of it equipments
                    for (Item item : items) {
                        // get it model
                        Model model = item.getModel();
                        // unable the skin
                        // model.toggleSkin(item.getSkinID());

                        // TODO RENDER IT
                    }
                }
            }
        }
    }
    this._program_model_shadow.useStop();
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_BLEND);

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

}

From source file:com.grillecube.engine.renderer.world.terrain.TerrainRenderer.java

@Override
public void render() {

    if (!this._can_render) {
        return;/* ww  w . j av a2 s .  c  o  m*/
    }

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glCullFace(GL11.GL_BACK);

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

    if (this.getParent().getGLFWWindow().isKeyPressed(GLFW.GLFW_KEY_F)) {
        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
    }

    this.render(super.getCamera());

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

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_CULL_FACE);
}

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

License:Open Source License

public void renderSemiTransparent(Matrix4f matrix) {
    Util.checkErr();/*from w ww.  j a v  a 2s.  c  o m*/
    doRenderSemiTransparent(matrix);
    if (MainThread.main.input.getLastHovered() != null) {
        Pickable lr = MainThread.main.input.getLastHovered().getRenderable();
        if (this instanceof BaseObject && lr instanceof BaseObject) {
            if (lr == this) {
                BaseObject notThis = (BaseObject) this;
                if (notThis.drawOutline) {
                    // Setup for outline draw
                    GL11.glDepthFunc(GL11.GL_LESS);
                    GL11.glEnable(GL11.GL_DEPTH_TEST);
                    GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_LINE);
                    GL11.glLineWidth(10f);
                    GL11.glCullFace(GL11.GL_FRONT);
                    GL11.glEnable(GL11.GL_CULL_FACE);

                    GL11.glEnable(GL11.GL_BLEND);
                    GL11.glEnable(GL11.GL_LINE_SMOOTH);
                    GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
                    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

                    // Draw

                    RenderStyle rs = notThis.getRenderStyle();
                    notThis.setRenderStyle(RenderStyle.HALO);

                    doRender(matrix);

                    notThis.setRenderStyle(rs);

                    // Return to correct state
                    GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_FILL);
                    GL11.glLineWidth(1f);
                    GL11.glCullFace(GL11.GL_BACK);
                    GL11.glDisable(GL11.GL_CULL_FACE);
                    GL11.glEnable(GL11.GL_BLEND);
                }
            }
        }
    }
    Util.checkErr();
    for (Node node : children) {
        Matrix4f childMatrix = matrix.mult(node.getMatrix(), null);
        node.renderSemiTransparent(childMatrix);
        Util.checkErr();
    }
}

From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java

License:Mozilla Public License

private void drawOverdraw(int level) {
    GL11.glPushAttrib(GL11.GL_STENCIL_BUFFER_BIT);

    GL11.glStencilFunc(level == 5 ? GL11.GL_LEQUAL : GL11.GL_EQUAL, level, 0xf);
    GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);

    GL11.glTranslatef(mNode.bounds.x, -mNode.bounds.y, 0.0f);

    if (level == 2) {
        loadColor(ColorType.OVERDRAW_BLUE);
    } else if (level == 3) {
        loadColor(ColorType.OVERDRAW_GREEN);
    } else if (level == 4) {
        loadColor(ColorType.OVERDRAW_RED_LOW);
    } else if (level > 4) {
        loadColor(ColorType.OVERDRAW_RED_HIGH);
    }/*from   ww w.jav  a 2 s .c  o  m*/

    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex3f(0.0f, 0.0f, 0.0f);
    GL11.glVertex3f(mNode.bounds.width, 0.0f, 0.0f);
    GL11.glVertex3f(mNode.bounds.width, -mNode.bounds.height, 0.0f);
    GL11.glVertex3f(0.0f, -mNode.bounds.height, 0.0f);
    GL11.glEnd();

    GL11.glPopAttrib();
}

From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java

License:Mozilla Public License

private void drawImage(Node node, int textureId, boolean isBackground) {
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
    loadColor(ColorType.COLOR_WHITE);

    GL11.glEnable(GL11.GL_TEXTURE_2D);/* w  ww.j  a  v a 2s . co  m*/
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(0.0f, 0.0f, 0.0f);
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(node.bounds.width, 0.0f, 0.0f);
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(node.bounds.width, -node.bounds.height, 0.0f);
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(0.0f, -node.bounds.height, 0.0f);
    GL11.glEnd();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
}

From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java

License:Mozilla Public License

private void drawDepth(Node node, float depth, int mode) {
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, mode);
    GL11.glBegin(mode == GL11.GL_FILL ? GL11.GL_QUAD_STRIP : GL11.GL_LINES);

    // Top-left.// w  w w  .j  a v a2 s  .  co m
    GL11.glVertex3f(0.0f, 0.0f, 0.0f);
    GL11.glVertex3f(0.0f, 0.0f, depth);

    // Top-right.
    GL11.glVertex3f(node.bounds.width, 0.0f, 0.0f);
    GL11.glVertex3f(node.bounds.width, 0.0f, depth);

    // Bottom-right.
    GL11.glVertex3f(node.bounds.width, -node.bounds.height, 0.0f);
    GL11.glVertex3f(node.bounds.width, -node.bounds.height, depth);

    // Bottom-left.
    GL11.glVertex3f(0.0f, -node.bounds.height, 0.0f);
    GL11.glVertex3f(0.0f, -node.bounds.height, depth);

    // Complete the quad strip.
    if (mode == GL11.GL_FILL) {
        // Top-left.
        GL11.glVertex3f(0.0f, 0.0f, 0.0f);
        GL11.glVertex3f(0.0f, 0.0f, depth);
    }

    GL11.glEnd();
}

From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java

License:Mozilla Public License

private void drawFrontFace(Node node, float depth, int mode) {
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, mode);
    GL11.glBegin(GL11.GL_QUADS);/*from  w  w  w.j  a  va 2  s  .c o  m*/
    GL11.glVertex3f(0.0f, 0.0f, depth);
    GL11.glVertex3f(node.bounds.width, 0.0f, depth);
    GL11.glVertex3f(node.bounds.width, -node.bounds.height, depth);
    GL11.glVertex3f(0.0f, -node.bounds.height, depth);
    GL11.glEnd();
}

From source file:com.xrbpowered.gl.examples.ExampleClient.java

License:Open Source License

@Override
public void redraw(RenderTarget target) {
    if (uiGraphPane.isVisible())
        uiGraphPane.repaint();/*from w  w  w.j a va  2 s.  com*/

    RenderTarget drawTarget = target;
    if (offscreenBuffers != null) {
        offscreenBuffers.use();
        drawTarget = offscreenBuffers;
    }

    GL11.glClearColor(CLEAR_COLOR.getRed() / 255f, CLEAR_COLOR.getGreen() / 255f, CLEAR_COLOR.getBlue() / 255f,
            0f);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    if (wireframe)
        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
    drawObjects(drawTarget);
    if (wireframe)
        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);

    if (offscreenBuffers != null) {
        offscreenBuffers.resolve();
        target.use();
        drawOffscreenBuffers(offscreenBuffers, target);
    }
}

From source file:fr.ign.cogit.geoxygene.appli.render.DisplayableRenderer.java

License:Open Source License

private boolean render(Collection<GLComplex> cComplexes, NamedRenderingParametersMap cParameters,
        GLProgram glpRenderProgram) throws GLException, NoninvertibleTransformException {
    boolean success = false;
    glEnable(GL11.GL_BLEND);//from www  . ja v a 2s  .c o m
    glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    // Set the general shared uniforms.
    cParameters.put(fboWidth,
            GLContext.getActiveGlContext().getSharedUniform(GeoxygeneConstants.GL_VarName_FboWidth));
    cParameters.put(fboHeight,
            GLContext.getActiveGlContext().getSharedUniform(GeoxygeneConstants.GL_VarName_FboHeight));
    cParameters.put(screenWidth,
            GLContext.getActiveGlContext().getSharedUniform(GeoxygeneConstants.GL_VarName_ScreenWidth));
    cParameters.put(screenHeight,
            GLContext.getActiveGlContext().getSharedUniform(GeoxygeneConstants.GL_VarName_ScreenHeight));
    cParameters.put(time, GLContext.getActiveGlContext().getSharedUniform("time"));
    // Activate the Program
    GLContext active_context = GLContext.getActiveGlContext();
    GLProgram program = null;
    if (this.wireframe_rendering) {
        glDisable(GL_TEXTURE_2D);
        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
        program = RenderingMethodDescriptor.retrieveMethod("Degraded").getGLProgram();
    } else {
        program = glpRenderProgram;
    }

    // Get the UniformSetter for this program.
    active_context.setCurrentProgram(program);
    GLProgramUniformSetter setter = active_context.getSetter(program);
    success = setter.set(cParameters, program);
    if (success) {
        AffineTransform atWorld2Screen = this.viewport.getModelToViewTransform();
        RenderingStatistics.doStartRendering(this);
        for (GLComplex complex : cComplexes) {
            success &= DisplayableRenderer.rendercomplex(complex, program, atWorld2Screen);
        }
    }
    glDisable(GL11.GL_BLEND);
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
    active_context.setCurrentProgram(null);
    return success;
}