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:org.ode4j.drawstuff.internal.DrawStuffGL.java

License:Open Source License

@Override
public void dsSetDrawMode(int mode) {
    switch (mode) {
    case DS_POLYFILL:
        GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL);
        break;/*w w w .j a v  a  2 s  . c o m*/
    case DS_WIREFRAME:
        GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_LINE);
        break;
    }
}

From source file:org.spout.engine.SpoutRenderer.java

License:Open Source License

public void render(float dt) {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    final Camera camera = client.getPlayer().getType(Camera.class);
    final SkydomeComponent skydome = client.getWorld().get(SkydomeComponent.class);

    // Render reflected world
    if (useReflexion) {
        reflected.activate();//from  www  .j  ava  2  s.  c  o m
        GL11.glCullFace(GL11.GL_FRONT);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        if (camera != null) {
            camera.updateReflectedView();

            if (skydome != null && skydome.getModel() != null) {
                skydome.getModel().getRenderMaterial().getShader().setUniform("View", camera.getRotation());
                skydome.getModel().getRenderMaterial().getShader().setUniform("Projection",
                        camera.getProjection());
                skydome.getModel().getRenderMaterial().getShader().setUniform("Model", Matrix4.IDENTITY);
                BaseMesh reflectedSkydomeMesh = (BaseMesh) skydome.getModel().getMesh();
                if (!reflectedSkydomeMesh.isBatched()) {
                    reflectedSkydomeMesh.batch();
                }
                reflectedSkydomeMesh.render(skydome.getModel().getRenderMaterial());
            }
        }

        worldRenderer.render();
        entityRenderer.render(dt);

        GL11.glCullFace(GL11.GL_BACK);
        reflected.release();
    }

    // Render normal world
    t.activate();
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    if (camera != null) {
        camera.updateView();

        if (skydome != null && skydome.getModel() != null) {
            skydome.getModel().getRenderMaterial().getShader().setUniform("View", camera.getRotation());
            skydome.getModel().getRenderMaterial().getShader().setUniform("Projection", camera.getProjection());
            skydome.getModel().getRenderMaterial().getShader().setUniform("Model", Matrix4.IDENTITY);
            BaseMesh skydomeMesh = (BaseMesh) skydome.getModel().getMesh();
            if (!skydomeMesh.isBatched()) {
                skydomeMesh.batch();
            }
            skydomeMesh.render(skydome.getModel().getRenderMaterial());
        }
    }

    long start = System.nanoTime();
    worldRenderer.render();
    worldTime = System.nanoTime() - start;
    start = System.nanoTime();
    entityRenderer.render(dt);
    entityTime = System.nanoTime() - start;
    start = System.nanoTime();

    t.release();

    // Render gui
    if (wireframe) {
        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
    }

    screenBatcher.render(Matrix4.IDENTITY);
    if (useReflexion) {
        reflectedDebugBatch.render(Matrix4.IDENTITY);
    }

    //GUI -> Render all widgets
    for (Screen screen : screenStack.getVisibleScreens()) {
        for (Widget widget : screen.getWidgets()) {
            ((SpoutWidget) widget).render();
        }
    }

    //GUI -> Give the main screen the mouse if no input screen is set
    final Screen input = screenStack.getInputScreen();
    if (input == null) {
        Mouse.setGrabbed(true);
    } else {
        Mouse.setGrabbed(input.grabsMouse());
    }

    //GUI -> Update debug info
    if (showDebugInfos) {
        int id = 0;
        Point position = client.getPlayer().getPhysics().getPosition();
        debugScreen.spoutUpdate(id++, "Spout client! Logged as " + client.getPlayer().getDisplayName()
                + " in world: " + client.getWorld().getName());
        debugScreen.spoutUpdate(id++,
                "x: " + position.getX() + "y: " + position.getY() + "z: " + position.getZ());
        debugScreen.spoutUpdate(id++, "FPS: " + client.getScheduler().getFps() + " ("
                + (client.getScheduler().isRendererOverloaded() ? "Overloaded" : "Normal") + ")");
        debugScreen.spoutUpdate(id++, "Chunks Loaded: " + client.getWorld().getNumLoadedChunks());
        debugScreen.spoutUpdate(id++,
                "Total ChunkMeshBatchAggregators in Renderer: " + worldRenderer.getTotalChunks() + "");
        debugScreen.spoutUpdate(id++,
                "Chunks Drawn: "
                        + ((int) ((float) worldRenderer.getRenderedChunks()
                                / (float) (worldRenderer.getTotalChunks()) * 100))
                        + "%" + " (" + worldRenderer.getRenderedChunks() + ")");
        debugScreen.spoutUpdate(id++, "Occluded Chunks: "
                + (int) ((float) worldRenderer.getOccludedChunks() / worldRenderer.getTotalChunks() * 100)
                + "% (" + worldRenderer.getOccludedChunks() + ")");
        debugScreen.spoutUpdate(id++,
                "Cull Chunks: "
                        + (int) ((float) worldRenderer.getCulledChunks() / worldRenderer.getTotalChunks() * 100)
                        + "% (" + worldRenderer.getCulledChunks() + ")");
        debugScreen.spoutUpdate(id++, "Entities: " + entityRenderer.getRenderedEntities());
        debugScreen.spoutUpdate(id++,
                "Buffer: " + worldRenderer.addedBatch + " / " + worldRenderer.updatedBatch);
        debugScreen.spoutUpdate(id++, "Mesh batch queue size: "
                + ((SpoutClient) Spout.getEngine()).getRenderer().getWorldRenderer().getBatchWaiting());
    }

    for (Screen screen : screenStack.getVisibleScreens()) {
        for (Widget widget : screen.getWidgets()) {
            ((SpoutWidget) widget).render();
        }
    }

    guiTime = System.nanoTime() - start;

    if (wireframe) {
        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
    }
}

From source file:org.spout.engine.SpoutRenderer.java

License:Open Source License

public void toggleWireframe() {
    if (wireframe) {
        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
        wireframe = false;/*from ww  w.  j ava2s.co m*/
    } else {
        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
        wireframe = true;
    }
}

From source file:org.terasology.rendering.dag.stateChanges.SetWireframe.java

License:Apache License

@Override
public void process() {
    GL11.glPolygonMode(GL_FRONT_AND_BACK, mode);
}

From source file:org.terasology.rendering.dag.tasks.SetWireframeTask.java

License:Apache License

@Override
public void execute() {
    GL11.glPolygonMode(GL_FRONT_AND_BACK, mode);
}

From source file:org.terasology.rendering.opengl.GraphicState.java

License:Apache License

/**
 * Sets the state to render in wireframe.
 *
 * @param wireframeIsEnabledInRenderingDebugConfig If True enables wireframe rendering. False, does nothing.
 *//*  w ww  . j av  a  2s  . c o m*/
public void enableWireframeIf(boolean wireframeIsEnabledInRenderingDebugConfig) {
    if (wireframeIsEnabledInRenderingDebugConfig) {
        GL11.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    }
}

From source file:org.terasology.rendering.opengl.GraphicState.java

License:Apache License

/**
 * Disables wireframe rendering. Used together with enableWireFrameIf().
 *
 * @param wireframeIsEnabledInRenderingDebugConfig If True disables wireframe rendering. False, does nothing.
 *///w  w w. j  av  a  2 s .c o m
public void disableWireframeIf(boolean wireframeIsEnabledInRenderingDebugConfig) {
    if (wireframeIsEnabledInRenderingDebugConfig) {
        GL11.glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    }
}

From source file:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static void glPolygonMode(int a, int b) {
    GL11.glPolygonMode(a, b);
}

From source file:zildo.fwk.gfx.Ortho.java

License:Open Source License

/**
 * Draw an empty box on foreground (z=1), same way that box.
 * /*from  ww  w.j  ava2s.co m*/
 * @param x
 * @param y
 * @param w
 * @param h
 * @param palColor
 * @param color
 */
public void boxv(int x, int y, int p_w, int p_h, int palColor, Vector4f color) {
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
    box(x, y, p_w, p_h, palColor, color);
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);

}

From source file:zildo.platform.opengl.LwjglOrtho.java

License:Open Source License

/**
 * Draw an empty box on foreground (z=1), same way that box.
 * /*from   w  w w.j a  v a  2  s  .  co m*/
 * @param x
 * @param y
 * @param w
 * @param h
 * @param palColor
 * @param color
 */
@Override
public void boxv(int x, int y, int p_w, int p_h, int palColor, Vector4f color) {
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
    box(x, y, p_w, p_h, palColor, color);
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);

}