Example usage for org.lwjgl.opengl GL11 glShadeModel

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

Introduction

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

Prototype

public static native void glShadeModel(@NativeType("GLenum") int mode);

Source Link

Document

Sets the current shade mode.

Usage

From source file:Obj.java

License:Open Source License

public void enableStates() {
    if (this.isSmoothShadingEnabled()) {
        GL11.glShadeModel(GL_SMOOTH);
    } else {//  ww  w . j a v  a2 s .  com
        GL11.glShadeModel(GL_FLAT);
    }
}

From source file:additionalpipes.client.gui.components.GuiSlotEx.java

License:Minecraft Mod Public

/**
 * draws the slot to the screen, pass in mouse's current x and y and partial ticks
 *//*from ww w. ja v a  2  s .com*/
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    this.mouseX = mouseX;
    this.mouseY = mouseY;
    drawBackground();
    int size = getSize();
    int slotLeft = xPos + marginLeft + 2;
    int slotRight = xPos + width - 2;
    if (getHiddenHeight() > 0) {
        slotRight = getScrollBarX() - 2;
    }

    if (Mouse.isButtonDown(0)) {
        if (initialClickY == -1.0F) {
            boolean slotClicked = true;

            if (mouseX >= xPos && mouseX < xPos + width && mouseY >= yPos && mouseY < yPos + height) {
                int mouseSlotY = mouseY - yPos - marginTop + (int) amountScrolled - getGradientHeight();
                int hovered = mouseSlotY / slotHeight;
                if (/*mouseX < slotLeft || mouseX > slotRight || */hovered < -1 || hovered >= size) {
                    hovered = -1;
                }

                boolean doubleClick = hovered == selectedElement
                        && Minecraft.getSystemTime() - lastClicked < 250L;
                lastClicked = Minecraft.getSystemTime();
                elementClicked(hovered, mouseX - xPos, doubleClick);

                if (hovered >= 0) {
                    selectedElement = hovered;
                } else if (mouseX >= slotLeft && mouseX <= slotRight && mouseSlotY < 0) {
                    marginClicked(mouseX - slotLeft,
                            mouseY - yPos + (int) amountScrolled - getGradientHeight());
                    slotClicked = false;
                }

                int scrollBarX = getScrollBarX();
                if (mouseX >= scrollBarX && mouseX < scrollBarX + scrollBarWidth) {
                    scrollMultiplier = -1.0F;
                    int hiddenHeight = getHiddenHeight();

                    if (hiddenHeight < 1) {
                        hiddenHeight = 1;
                    }

                    int slotBottom = height * height / getContentHeight();

                    if (slotBottom < 32) {
                        slotBottom = 32;
                    }

                    if (slotBottom > height - getGradientHeight() * 2) {
                        slotBottom = height - getGradientHeight() * 2;
                    }

                    scrollMultiplier /= (float) (height - slotBottom) / (float) hiddenHeight;
                } else {
                    scrollMultiplier = 1.0F;
                }

                if (slotClicked) {
                    initialClickY = mouseY;
                } else {
                    initialClickY = -2.0F;
                }
            } else {
                initialClickY = -2.0F;
            }
        } else if (initialClickY >= 0.0F) {
            float scroll = amountScrolled;
            amountScrolled -= (mouseY - initialClickY) * scrollMultiplier;
            bindAmountScrolled();
            if (scroll != amountScrolled) {
                initialClickY = mouseY;
            }
        }
    } else if (mouseX >= xPos && mouseX < xPos + width && mouseY >= yPos && mouseY < yPos + height) {
        while (!mc.gameSettings.touchscreen && Mouse.next()) {
            int wheel = Mouse.getEventDWheel();

            if (wheel != 0) {
                if (wheel > 0) {
                    wheel = -1;
                } else if (wheel < 0) {
                    wheel = 1;
                }

                amountScrolled += wheel * slotHeight / 2;
                bindAmountScrolled();
            }
        }

        initialClickY = -1.0F;
    }

    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_FOG);
    Tessellator tessellator = Tessellator.instance;
    drawContainerBackground(tessellator);
    int scrolledTop = yPos + getGradientHeight() - (int) amountScrolled;
    if (!drawGradient) {
        scrolledTop += 2;
    }

    if (drawMarginTop) {
        drawMarginTop(slotLeft, scrolledTop, tessellator);
    }

    for (int i = 0; i < size; ++i) {
        int slotTop = scrolledTop + i * slotHeight + marginTop;
        int slotHeight = this.slotHeight - 4;

        if (slotTop <= yPos + height && slotTop + slotHeight >= yPos) {
            if (showSelectionBox && isSelected(i)) {
                int outlineLeft = slotLeft - 2;
                int outlineRight = slotRight + 2;
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                GL11.glDisable(GL11.GL_TEXTURE_2D);
                tessellator.startDrawingQuads();
                tessellator.setColorOpaque_I(0x808080);
                tessellator.addVertexWithUV(outlineLeft, slotTop + slotHeight + 2, 0.0D, 0.0D, 1.0D);
                tessellator.addVertexWithUV(outlineRight, slotTop + slotHeight + 2, 0.0D, 1.0D, 1.0D);
                tessellator.addVertexWithUV(outlineRight, slotTop - 2, 0.0D, 1.0D, 0.0D);
                tessellator.addVertexWithUV(outlineLeft, slotTop - 2, 0.0D, 0.0D, 0.0D);
                tessellator.setColorOpaque_I(0x000000);
                tessellator.addVertexWithUV(outlineLeft + 1, slotTop + slotHeight + 1, 0.0D, 0.0D, 1.0D);
                tessellator.addVertexWithUV(outlineRight - 1, slotTop + slotHeight + 1, 0.0D, 1.0D, 1.0D);
                tessellator.addVertexWithUV(outlineRight - 1, slotTop - 1, 0.0D, 1.0D, 0.0D);
                tessellator.addVertexWithUV(outlineLeft + 1, slotTop - 1, 0.0D, 0.0D, 0.0D);
                tessellator.draw();
                GL11.glEnable(GL11.GL_TEXTURE_2D);
            }

            drawSlot(i, slotLeft, slotTop, slotHeight, tessellator);
        }
    }

    GL11.glDisable(GL11.GL_DEPTH_TEST);
    drawOverlay();

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    drawGradient(tessellator);
    drawScrollBar(tessellator);

    drawFinish(mouseX, mouseY);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_BLEND);
}

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

License:Apache License

/**
 * Initialise the GL display/* w w w. jav  a 2 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:appeng.client.render.BaseBlockRender.java

License:Open Source License

public void renderTile(final B block, final T tile, final Tessellator tess, final double x, final double y,
        final double z, final float f, final RenderBlocks renderer) {
    renderer.uvRotateBottom = renderer.uvRotateTop = renderer.uvRotateEast = renderer.uvRotateWest = renderer.uvRotateNorth = renderer.uvRotateSouth = 0;

    final ForgeDirection up = ForgeDirection.UP;
    final ForgeDirection forward = ForgeDirection.SOUTH;
    this.applyTESRRotation(x, y, z, forward, up);

    Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
    RenderHelper.disableStandardItemLighting();

    if (Minecraft.isAmbientOcclusionEnabled()) {
        GL11.glShadeModel(GL11.GL_SMOOTH);
    } else {//from  w w  w .  ja va2  s  .c o m
        GL11.glShadeModel(GL11.GL_FLAT);
    }

    GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

    tess.setTranslation(-tile.xCoord, -tile.yCoord, -tile.zCoord);
    tess.startDrawingQuads();

    // note that this is a terrible approach...
    renderer.setRenderBoundsFromBlock(block);
    renderer.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);

    tess.draw();
    tess.setTranslation(0, 0, 0);
    RenderHelper.enableStandardItemLighting();

    renderer.uvRotateBottom = renderer.uvRotateTop = renderer.uvRotateEast = renderer.uvRotateWest = renderer.uvRotateNorth = renderer.uvRotateSouth = 0;
}

From source file:appeng.client.render.blocks.RenderBlockCrank.java

License:Open Source License

@Override
public void renderTile(final BlockCrank blk, final TileCrank tile, final Tessellator tess, final double x,
        final double y, final double z, final float f, final RenderBlocks renderBlocks) {
    if (tile.getUp() == null || tile.getUp() == ForgeDirection.UNKNOWN) {
        return;/*from   w  ww .  ja  v a  2  s  .c o m*/
    }

    Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
    RenderHelper.disableStandardItemLighting();

    if (Minecraft.isAmbientOcclusionEnabled()) {
        GL11.glShadeModel(GL11.GL_SMOOTH);
    } else {
        GL11.glShadeModel(GL11.GL_FLAT);
    }

    GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

    this.applyTESRRotation(x, y, z, tile.getForward(), tile.getUp());

    GL11.glTranslated(0.5, 0, 0.5);
    GL11.glRotatef(tile.getVisibleRotation(), 0, 1, 0);
    GL11.glTranslated(-0.5, 0, -0.5);

    tess.setTranslation(-tile.xCoord, -tile.yCoord, -tile.zCoord);
    tess.startDrawingQuads();
    renderBlocks.renderAllFaces = true;
    renderBlocks.blockAccess = tile.getWorldObj();

    renderBlocks.setRenderBounds(0.5D - 0.05, 0.5D - 0.5, 0.5D - 0.05, 0.5D + 0.05, 0.5D + 0.1, 0.5D + 0.05);

    renderBlocks.renderStandardBlock(blk, tile.xCoord, tile.yCoord, tile.zCoord);

    renderBlocks.setRenderBounds(0.70D - 0.15, 0.55D - 0.05, 0.5D - 0.05, 0.70D + 0.15, 0.55D + 0.05,
            0.5D + 0.05);

    renderBlocks.renderStandardBlock(blk, tile.xCoord, tile.yCoord, tile.zCoord);

    tess.draw();
    tess.setTranslation(0, 0, 0);
    RenderHelper.enableStandardItemLighting();
}

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();/*  www  . j av a  2 s  . c o 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);
}

From source file:cn.academy.core.client.render.block.RenderDynamicBlock.java

License:GNU General Public License

@Override
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float pt) {
    Block blockType = t.getBlockType();//from w  w w  .  ja  va 2s  .c  o  m

    Tessellator tes = Tessellator.instance;
    tes.setColorOpaque_F(1.0F, 1.0F, 1.0F);

    renderBlocks.blockAccess = t.getWorldObj();

    {
        if (Minecraft.isAmbientOcclusionEnabled()) {
            GL11.glShadeModel(GL11.GL_SMOOTH);
        } else {
            GL11.glShadeModel(GL11.GL_FLAT);
        }
        RenderHelper.disableStandardItemLighting();

        RenderUtils.loadTexture(TextureMap.locationBlocksTexture);

        tes.startDrawingQuads();
        tes.setTranslation(x - t.xCoord, y - t.yCoord, z - t.zCoord);

        renderBlocks.renderBlockAllFaces(blockType, t.xCoord, t.yCoord, t.zCoord);
        tes.setTranslation(0, 0, 0);
        tes.draw();

        RenderHelper.enableStandardItemLighting();
    }
}

From source file:cn.academy.core.client.render.RenderEntityBlock.java

License:GNU General Public License

@Override
public void doRender(Entity e, double x, double y, double z, float pt, float b) {
    EntityBlock entity = (EntityBlock) e;

    if (entity.block != null) {
        GL11.glPushMatrix();//from ww w .j  a  va2  s .  c o m
        {
            Tessellator tes = Tessellator.instance;
            tes.setColorOpaque_F(1.0F, 1.0F, 1.0F);

            renderBlocks.blockAccess = e.worldObj;
            {
                if (Minecraft.isAmbientOcclusionEnabled()) {
                    GL11.glShadeModel(GL11.GL_SMOOTH);
                } else {
                    GL11.glShadeModel(GL11.GL_FLAT);
                }
                RenderHelper.disableStandardItemLighting();

                RenderUtils.loadTexture(TextureMap.locationBlocksTexture);

                //x += b * entity.motionX;
                //y += b * entity.motionY;
                //z += b * entity.motionZ;

                int ix = (int) entity.posX, iy = (int) entity.posY, iz = (int) entity.posZ;

                GL11.glTranslated(x, y, z);

                GL11.glRotatef(MathUtils.lerpf(entity.lastYaw, entity.yaw, pt), 0, 1, 0);
                GL11.glRotatef(MathUtils.lerpf(entity.lastPitch, entity.pitch, pt), 1, 0, 0);

                GL11.glTranslated(-ix - 0.5, -iy - 0.5, -iz - 0.5);

                tes.startDrawingQuads();
                renderBlocks.renderBlockAllFaces(entity.block, ix, iy, iz);
                tes.setTranslation(0, 0, 0);
                tes.draw();

                RenderHelper.enableStandardItemLighting();
            }
        }
        GL11.glPopMatrix();
    }

    if (entity.tileEntity != null) {
        entity.tileEntity.blockType = entity.block;
        TileEntitySpecialRenderer tesr = TileEntityRendererDispatcher.instance
                .getSpecialRenderer(entity.tileEntity);
        if (tesr != null) {
            try {
                tesr.renderTileEntityAt(entity.tileEntity, x - 0.5, y, z - 0.5, pt);
            } catch (Exception ex) {
                AcademyCraft.log.error("Error handling EntityBlock TE rendering: " + tesr.getClass());
                ex.printStackTrace();
            }
        }
    }
}

From source file:cn.lambdalib.util.client.HudUtils.java

License:MIT License

public static void drawGradientRect(int x0, int y0, int x1, int y1, int color1, int color2) {
    float f = (color1 >> 24 & 255) / 255.0F;
    float f1 = (color1 >> 16 & 255) / 255.0F;
    float f2 = (color1 >> 8 & 255) / 255.0F;
    float f3 = (color1 & 255) / 255.0F;
    float f4 = (color2 >> 24 & 255) / 255.0F;
    float f5 = (color2 >> 16 & 255) / 255.0F;
    float f6 = (color2 >> 8 & 255) / 255.0F;
    float f7 = (color2 & 255) / 255.0F;
    GL11.glDisable(GL11.GL_TEXTURE_2D);// www .  j av  a  2  s . c  o m
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    Tessellator t = Tessellator.instance;
    t.startDrawingQuads();
    t.setColorRGBA_F(f1, f2, f3, f);
    t.addVertex(x1, y0, -90D);
    t.addVertex(x0, y0, -90D);
    t.setColorRGBA_F(f5, f6, f7, f4);
    t.addVertex(x0, y1, -90D);
    t.addVertex(x1, y1, -90D);
    t.draw();
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:cn.liutils.util.HudUtils.java

License:Open Source License

public static void drawGradientRect(int par1, int par2, int par3, int par4, int par5, int par6) {
    float f = (par5 >> 24 & 255) / 255.0F;
    float f1 = (par5 >> 16 & 255) / 255.0F;
    float f2 = (par5 >> 8 & 255) / 255.0F;
    float f3 = (par5 & 255) / 255.0F;
    float f4 = (par6 >> 24 & 255) / 255.0F;
    float f5 = (par6 >> 16 & 255) / 255.0F;
    float f6 = (par6 >> 8 & 255) / 255.0F;
    float f7 = (par6 & 255) / 255.0F;
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*  w ww.  ja  v a2  s.  co  m*/
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    Tessellator t = Tessellator.instance;
    t.startDrawingQuads();
    t.setColorRGBA_F(f1, f2, f3, f);
    t.addVertex(par3, par2, -90D);
    t.addVertex(par1, par2, -90D);
    t.setColorRGBA_F(f5, f6, f7, f4);
    t.addVertex(par1, par4, -90D);
    t.addVertex(par3, par4, -90D);
    t.draw();
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}