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.darkona.adventurebackpack.client.render.CopygirlRenderUtils.java

License:Open Source License

public static void renderItemIn3d(ItemStack stack) {
    TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
    // Not sure why but this can be null when the world loads.
    if (textureManager == null) {
        return;/*  w  ww  .  j av a  2  s  .c  o  m*/
    }
    Item item = stack.getItem();

    GL11.glPushMatrix();

    Tessellator tessellator = Tessellator.instance;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
    GL11.glTranslatef(-0.5F, -0.5F, 1 / 32.0F);

    int passes = item.getRenderPasses(stack.getItemDamage());
    for (int pass = 0; pass < passes; pass++) {
        textureManager.bindTexture(((stack.getItemSpriteNumber() == 0) ? TextureMap.locationBlocksTexture
                : TextureMap.locationItemsTexture));
        IIcon icon = item.getIcon(stack, pass);
        if (icon != null) {
            float minU = icon.getMinU();
            float maxU = icon.getMaxU();
            float minV = icon.getMinV();
            float maxV = icon.getMaxV();
            CopygirlRenderUtils.setColorFromInt(item.getColorFromItemStack(stack, pass));
            ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(),
                    icon.getIconHeight(), 0.0625F);
        }
    }

    if (stack.hasEffect(0)) {
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        textureManager.bindTexture(glint);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
        float f7 = 0.76F;
        GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPushMatrix();
        float f8 = 0.125F;
        GL11.glScalef(f8, f8, f8);
        float f9 = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F;
        GL11.glTranslatef(f9, 0.0F, 0.0F);
        GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
        GL11.glPopMatrix();
        GL11.glPushMatrix();
        GL11.glScalef(f8, f8, f8);
        f9 = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F;
        GL11.glTranslatef(-f9, 0.0F, 0.0F);
        GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
    }

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);

    GL11.glPopMatrix();
}

From source file:com.dbi.games.fortress.ui.MainAppWindow.java

License:Open Source License

/**
 * Creates new form MainAppWin//from w ww  . j  a v  a 2  s. c  o m
 */
public MainAppWindow() {
    initComponents();

    glCanvas.addComponentListener(new ComponentListener() {
        public void componentShown(ComponentEvent e) {
            setNeedValidation();
        }

        public void componentResized(ComponentEvent e) {
            setNeedValidation();
        }

        public void componentMoved(ComponentEvent e) {
            setNeedValidation();
        }

        public void componentHidden(ComponentEvent e) {
            setNeedValidation();
        }
    });

    File currentDir = new File("lib/natives");
    if (!currentDir.exists()) {
        //            JOptionPane.showMessageDialog(null, "directory location: "+currentDir.getAbsolutePath()+" does not exist!");
        currentDir = new File("build/libs/natives");
    }
    Logger.getLogger("LWJGLThread").log(Level.INFO, "LWJGL directory is " + currentDir.getAbsolutePath());

    System.setProperty("org.lwjgl.librarypath", currentDir.getAbsolutePath());

    Thread glThread = new Thread("GLThread") {

        @Override
        public void run() {
            long lastFrame = System.nanoTime();
            long currentFrame;
            try {
                Display.setParent(glCanvas);
                Display.create();

                GL11.glEnable(GL11.GL_TEXTURE_2D);
                GL11.glEnable(GL11.GL_BLEND);
                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                GL11.glDisable(GL11.GL_DEPTH_TEST);
                GL11.glClearColor(0f, 0f, 0f, 0f);
                GL11.glMatrixMode(GL11.GL_PROJECTION);
                GL11.glLoadIdentity();
                GL11.glOrtho(0f, (float) glCanvas.getWidth(), (float) glCanvas.getHeight(), 0f, -1, 1);
                GL11.glMatrixMode(GL11.GL_MODELVIEW);
                GL11.glLoadIdentity();
                GL11.glViewport(0, 0, glCanvas.getWidth(), glCanvas.getHeight());

                MainEngine.get().graphicsEngine().buildDefaultRenderers();

                while (MainEngine.get().isRunning()) {
                    try {
                        currentFrame = System.nanoTime();

                        MainEngine.get().renderScene(currentFrame - lastFrame);

                        lastFrame = currentFrame;

                        Display.update();

                        if (needUpdateViewport) {
                            needUpdateViewport = false;

                            GL11.glMatrixMode(GL11.GL_PROJECTION);
                            GL11.glLoadIdentity();
                            GL11.glOrtho(0, glCanvas.getWidth(), glCanvas.getHeight(), 0, -1, 1);
                            GL11.glViewport(0, 0, glCanvas.getWidth(), glCanvas.getHeight());
                        }
                    } catch (Throwable ex) {
                        ex.printStackTrace();
                        Logger.getLogger("LWJGLThread").log(Level.SEVERE,
                                "There was a SEROUS uncaught error in the render thread.  Shutting down.  Please restart!",
                                ex);
                        MainEngine.get().shutdown();
                    }
                }
            } catch (Throwable ex) {
                throw new RuntimeException("There was an issue starting LWJGL!", ex);
            }
        }

    };
    glThread.start();
}

From source file:com.dinasgames.engine.graphics.RenderTarget.java

public void resetGLStates() {

    //if(true){return;}

    if (activate(true)) {
        //GL11.glShadeModel(GL11.GL_SMOOTH);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);//from  w w w . j a  v  a  2  s .  c o  m
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
        GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
        //GL11.glEnable(GL13.GL_MULTISAMPLE);
        mCache.glStatesSet = true;

        applyBlendMode(BlendMode.BlendAlpha);
        applyTransform(Transform.Identity);
        applyTexture(null);

        mCache.useVertexCache = false;

        setView(new View(getView()));

    }
}

From source file:com.dyonovan.neotech.pipes.entities.EnergyResourceEntity.java

License:Creative Commons License

@Override
public void renderResource(float tickPartial) {
    GlStateManager.pushMatrix();//from w w w  . j  av  a2 s .c o m
    GlStateManager.pushAttrib();

    RenderManager manager = Minecraft.getMinecraft().getRenderManager();
    GL11.glTranslated(xPos - manager.renderPosX, yPos - manager.renderPosY, zPos - manager.renderPosZ);

    RenderUtils.bindTexture(new ResourceLocation(Reference.MOD_ID(), "textures/entity/energyEntity.png"));

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

    //TODO Find another way to render power
    //RenderHelper.setupBillboard(Minecraft.getMinecraft().thePlayer);

    WorldRenderer renderer = Tessellator.getInstance().getWorldRenderer();
    renderer.startDrawingQuads();
    renderer.addVertexWithUV(-0.2, -0.2, -0.2, 0, 0);
    renderer.addVertexWithUV(-0.2, 0.2, -0.2, 0, 1);
    renderer.addVertexWithUV(0.2, 0.2, -0.2, 1, 1);
    renderer.addVertexWithUV(0.2, -0.2, -0.2, 1, 0);
    Tessellator.getInstance().draw();

    GlStateManager.enableLighting();

    RenderUtils.bindMinecraftBlockSheet();

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GlStateManager.popAttrib();
    GlStateManager.popMatrix();
}

From source file:com.dyonovan.neotech.pipes.entities.FluidResourceEntity.java

License:Creative Commons License

@Override
public void renderResource(float tickPartial) {
    if (resource != null && resource.getFluid() != null) {
        GlStateManager.pushMatrix();/*from w  w w .j  a  va  2 s. com*/
        GlStateManager.pushAttrib();

        RenderManager manager = Minecraft.getMinecraft().getRenderManager();
        GL11.glTranslated(xPos - manager.renderPosX, yPos - manager.renderPosY, zPos - manager.renderPosZ);

        RenderUtils.bindMinecraftBlockSheet();
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GlStateManager.disableLighting();

        TextureAtlasSprite fluidIcon = resource.getFluid().getFluid().getIcon();
        RenderHelper.renderCubeWithTexture(-0.2, -0.2, -0.2, 0.2, 0.2, 0.2, fluidIcon.getMinU(),
                fluidIcon.getMinV(), fluidIcon.getMaxU(), fluidIcon.getMaxV());

        GlStateManager.enableLighting();
        RenderUtils.bindMinecraftBlockSheet();

        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GlStateManager.popAttrib();
        GlStateManager.popMatrix();
    }
}

From source file:com.dyonovan.tcnodetracker.lib.truetyper.FontHelper.java

License:Open Source License

public static void drawString(String s, float x, float y, TrueTypeFont font, float scaleX, float scaleY,
        float rotationZ, float... rgba) {
    Minecraft mc = Minecraft.getMinecraft();
    ScaledResolution sr = new ScaledResolution(mc.getMinecraft(), mc.displayWidth, mc.displayHeight);
    if (mc.gameSettings.hideGUI) {
        return;/*from   w w w.  j a va 2 s.  com*/
    }
    int amt = 1;
    if (sr.getScaleFactor() == 1) {
        amt = 2;
    }

    FloatBuffer matrixData = BufferUtils.createFloatBuffer(16);
    GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, matrixData);
    FontHelper.set2DMode(matrixData);
    GL11.glPushMatrix();
    y = mc.displayHeight - (y * sr.getScaleFactor()) - (((font.getLineHeight() / amt)));
    float tx = (x * sr.getScaleFactor()) + (font.getWidth(s) / 2);
    float tranx = tx + 2;
    float trany = y + (font.getLineHeight() / 2);
    GL11.glTranslatef(tranx, trany, 0);
    GL11.glRotatef(rotationZ, 0f, 0f, 1f);
    GL11.glTranslatef(-tranx, -trany, 0);

    GL11.glEnable(GL11.GL_BLEND);
    if (s.contains(formatEscape)) {
        String[] pars = s.split(formatEscape);
        float totalOffset = 0;
        for (int i = 0; i < pars.length; i++) {
            String par = pars[i];
            float[] c = rgba;
            if (i > 0) {
                c = Formatter.getFormatted(par.charAt(0));
                par = par.substring(1, par.length());
            }
            font.drawString((x * sr.getScaleFactor() + totalOffset), y, par, scaleX / amt, scaleY / amt, c);
            totalOffset += font.getWidth(par);
        }
    } else {
        font.drawString((x * sr.getScaleFactor()), y, s, scaleX / amt, scaleY / amt, rgba);
    }
    GL11.glPopMatrix();
    GL11.glDisable(GL11.GL_BLEND);
    FontHelper.set3DMode();
}

From source file:com.eagle.adventurersalchemy.render.AlchemicalFireItemRender.java

License:Open Source License

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    AlchemicalFireModel model = new AlchemicalFireModel();

    GL11.glPushMatrix();/*from w  w  w  . j av  a2s  . c  o m*/
    if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
        GL11.glTranslatef(0.5F, 2.0F, 0.5F);
    } else if (RenderItem.renderInFrame) {
        GL11.glTranslatef(0.0F, 2.4F, 0.0F);
    } else if (type == ItemRenderType.EQUIPPED) {
        GL11.glTranslatef(0.5F, 1.9F, 0.5F);
        GL11.glEnable(GL11.GL_CULL_FACE);
    } else if (type == ItemRenderType.INVENTORY) {
        GL11.glTranslatef(0.5F, 1.7F, 0.5F);
    } else if (type == ItemRenderType.ENTITY) {
        GL11.glTranslatef(0.0F, 1.2F, 0.0F);
    } else {
        GL11.glTranslatef(0.5F, 1.2F, 0.5F);
    }

    Minecraft.getMinecraft().getTextureManager()
            .bindTexture(new ResourceLocation(Dictionary.TEXTURE_ALCHEMICAL_FIRE));

    GL11.glPushMatrix();
    GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);

    model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

    GL11.glPopMatrix();
    GL11.glPopMatrix();
}

From source file:com.enderville.mod.client.gui.mainmenu.MenuBaseEnderVille.java

License:LGPL

private void drawPanorama(int par1, int par2, float par3) {
    Tessellator tessellator = Tessellator.instance;
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();//from   www  . ja v a 2  s.  c  o m
    GL11.glLoadIdentity();
    Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDepthMask(false);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    byte b0 = 8;

    for (int k = 0; k < b0 * b0; ++k) {
        GL11.glPushMatrix();
        float f1 = ((float) (k % b0) / (float) b0 - 0.5F) / 64.0F;
        float f2 = ((float) (k / b0) / (float) b0 - 0.5F) / 64.0F;
        float f3 = 0.0F;
        GL11.glTranslatef(f1, f2, f3);
        GL11.glRotatef(MathHelper.sin(((float) this.panoramaTimer + par3) / 400.0F) * 25.0F + 20.0F, 1.0F, 0.0F,
                0.0F);
        GL11.glRotatef(-((float) this.panoramaTimer + par3) * 0.1F, 0.0F, 1.0F, 0.0F);

        for (int l = 0; l < 6; ++l) {
            GL11.glPushMatrix();

            if (l == 1) {
                GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
            }

            if (l == 2) {
                GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
            }

            if (l == 3) {
                GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
            }

            if (l == 4) {
                GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
            }

            if (l == 5) {
                GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
            }

            this.mc.getTextureManager().bindTexture(titlePanoramaPaths[l]);
            tessellator.startDrawingQuads();
            tessellator.setColorRGBA_I(16777215, 255 / (k + 1));
            float f4 = 0.0F;
            tessellator.addVertexWithUV(-1.0D, -1.0D, 1.0D, (double) (0.0F + f4), (double) (0.0F + f4));
            tessellator.addVertexWithUV(1.0D, -1.0D, 1.0D, (double) (1.0F - f4), (double) (0.0F + f4));
            tessellator.addVertexWithUV(1.0D, 1.0D, 1.0D, (double) (1.0F - f4), (double) (1.0F - f4));
            tessellator.addVertexWithUV(-1.0D, 1.0D, 1.0D, (double) (0.0F + f4), (double) (1.0F - f4));
            tessellator.draw();
            GL11.glPopMatrix();
        }

        GL11.glPopMatrix();
        GL11.glColorMask(true, true, true, false);
    }

    tessellator.setTranslation(0.0D, 0.0D, 0.0D);
    GL11.glColorMask(true, true, true, true);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
}

From source file:com.enderville.mod.client.gui.mainmenu.MenuBaseEnderVille.java

License:LGPL

/**
 * Rotate and blurs the skybox view in the main menu
 *//*www  .j a va2 s  . co  m*/
private void rotateAndBlurSkybox(float par1) {
    this.mc.getTextureManager().bindTexture(this.viewportTextureLocation);
    GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColorMask(true, true, true, false);
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    byte b0 = 3;

    for (int i = 0; i < b0; ++i) {
        //            tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F / (float)(i + 1));
        int j = this.width;
        int k = this.height;
        float f1 = (float) (i - b0 / 2) / 256.0F;
        tessellator.addVertexWithUV((double) j, (double) k, (double) this.zLevel, (double) (0.0F + f1), 0.0D);
        tessellator.addVertexWithUV((double) j, 0.0D, (double) this.zLevel, (double) (1.0F + f1), 0.0D);
        tessellator.addVertexWithUV(0.0D, 0.0D, (double) this.zLevel, (double) (1.0F + f1), 1.0D);
        tessellator.addVertexWithUV(0.0D, (double) k, (double) this.zLevel, (double) (0.0F + f1), 1.0D);
    }

    tessellator.draw();
    GL11.glColorMask(true, true, true, true);
}

From source file:com.enderville.mod.client.gui.mainmenu.MenuBaseEnderVille.java

License:LGPL

/**
 * Renders the skybox in the main menu//ww  w  .java 2 s  .c om
 */
private void renderSkybox(int par1, int par2, float par3) {
    GL11.glViewport(0, 0, 256, 256);
    this.drawPanorama(par1, par2, par3);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    float f1 = this.width > this.height ? 120.0F / (float) this.width : 120.0F / (float) this.height;
    float f2 = (float) this.height * f1 / 256.0F;
    float f3 = (float) this.width * f1 / 256.0F;
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    //        tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F);
    int k = this.width;
    int l = this.height;
    tessellator.addVertexWithUV(0.0D, (double) l, (double) this.zLevel, (double) (0.5F - f2),
            (double) (0.5F + f3));
    tessellator.addVertexWithUV((double) k, (double) l, (double) this.zLevel, (double) (0.5F - f2),
            (double) (0.5F - f3));
    tessellator.addVertexWithUV((double) k, 0.0D, (double) this.zLevel, (double) (0.5F + f2),
            (double) (0.5F - f3));
    tessellator.addVertexWithUV(0.0D, 0.0D, (double) this.zLevel, (double) (0.5F + f2), (double) (0.5F + f3));
    tessellator.draw();
}