Example usage for org.lwjgl.opengl GL11 glGetInteger

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

Introduction

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

Prototype

@NativeType("void")
public static int glGetInteger(@NativeType("GLenum") int pname) 

Source Link

Document

Returns the current integer value of the specified state variable.

Usage

From source file:blusunrize.immersiveengineering.api.ManualPageMultiblock.java

@Override
public void renderPage(GuiManual gui, int x, int y, int mx, int my) {
    boolean openBuffer = false;
    int stackDepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH);
    try {/*from   w  w  w .java 2  s  . c  om*/
        if (multiblock.getStructureManual() != null) {
            if (!canTick) {
                //               renderInfo.reset();
                //            renderInfo.setShowLayer(9);
                //LAYER CACHING!!
            } else if (++tick % 20 == 0)
                renderInfo.step();

            int structureLength = renderInfo.structureLength;
            int structureWidth = renderInfo.structureWidth;
            int structureHeight = renderInfo.structureHeight;

            int yOffTotal = (int) (transY - y
                    + scale * Math.sqrt(renderInfo.structureHeight * renderInfo.structureHeight
                            + renderInfo.structureWidth * renderInfo.structureWidth
                            + renderInfo.structureLength * renderInfo.structureLength) / 2);

            GlStateManager.enableRescaleNormal();
            GlStateManager.pushMatrix();
            RenderHelper.disableStandardItemLighting();
            //         GL11.glEnable(GL11.GL_DEPTH_TEST);
            //         GL11.glDepthFunc(GL11.GL_ALWAYS);
            //         GL11.glDisable(GL11.GL_CULL_FACE);
            int i = 0;
            ItemStack highlighted = ItemStack.EMPTY;

            final BlockRendererDispatcher blockRender = Minecraft.getMinecraft().getBlockRendererDispatcher();

            float f = (float) Math.sqrt(structureHeight * structureHeight + structureWidth * structureWidth
                    + structureLength * structureLength);

            GlStateManager.translate(transX, transY,
                    Math.max(structureHeight, Math.max(structureWidth, structureLength)));
            GlStateManager.scale(scale, -scale, 1);
            GlStateManager.rotate(rotX, 1, 0, 0);
            GlStateManager.rotate(90 + rotY, 0, 1, 0);

            GlStateManager.translate((float) structureLength / -2f, (float) structureHeight / -2f,
                    (float) structureWidth / -2f);

            GlStateManager.disableLighting();

            if (Minecraft.isAmbientOcclusionEnabled())
                GlStateManager.shadeModel(GL11.GL_SMOOTH);
            else
                GlStateManager.shadeModel(GL11.GL_FLAT);

            gui.mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            int idx = 0;
            if (showCompleted && multiblock.canRenderFormedStructure())
                multiblock.renderFormedStructure();
            else
                for (int h = 0; h < structureHeight; h++)
                    for (int l = 0; l < structureLength; l++)
                        for (int w = 0; w < structureWidth; w++) {
                            BlockPos pos = new BlockPos(l, h, w);
                            if (!blockAccess.isAirBlock(pos)) {
                                GlStateManager.translate(l, h, w);
                                boolean b = multiblock.overwriteBlockRender(renderInfo.data[h][l][w], idx++);
                                GlStateManager.translate(-l, -h, -w);
                                if (!b) {
                                    IBlockState state = blockAccess.getBlockState(pos);
                                    Tessellator tessellator = Tessellator.getInstance();
                                    BufferBuilder buffer = tessellator.getBuffer();
                                    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
                                    openBuffer = true;
                                    blockRender.renderBlock(state, pos, blockAccess, buffer);
                                    tessellator.draw();
                                    openBuffer = false;
                                }
                            }
                        }

            GlStateManager.popMatrix();

            RenderHelper.disableStandardItemLighting();
            GlStateManager.disableRescaleNormal();

            GlStateManager.enableBlend();
            RenderHelper.disableStandardItemLighting();

            manual.fontRenderer.setUnicodeFlag(true);
            if (localizedText != null && !localizedText.isEmpty())
                manual.fontRenderer.drawSplitString(localizedText, x, y + yOffTotal, 120,
                        manual.getTextColour());

            manual.fontRenderer.setUnicodeFlag(false);
            if (componentTooltip != null) {
                manual.fontRenderer.drawString("?", x + 116, y + yOffTotal / 2 - 4, manual.getTextColour(),
                        false);
                if (mx >= x + 116 && mx < x + 122 && my >= y + yOffTotal / 2 - 4 && my < y + yOffTotal / 2 + 4)
                    gui.drawHoveringText(componentTooltip, mx, my, manual.fontRenderer);
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    if (openBuffer)
        try {
            Tessellator.getInstance().draw();
        } catch (Exception e) {
        }
    int newStackDepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH);
    while (newStackDepth > stackDepth) {
        GlStateManager.popMatrix();
        newStackDepth--;
    }
}

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

License:MIT License

/**
 * Stores the current texture state. stack depth: 1
 *//*from  ww  w.  j  av  a2s. c o m*/
public static void pushTextureState() {
    if (textureState != -1) {
        System.err.println("RenderUtils:Texture State Overflow");
        return;
    }
    textureState = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
}

From source file:cn.lambdalib.util.client.shader.GLSLMesh.java

License:MIT License

@Override
public void draw(Material mat) {
    //System.out.println("Current program: " + GL11.glGetInteger(GL20.GL_CURRENT_PROGRAM));
    mat.onRenderStage(RenderStage.START);
    mat.onRenderStage(RenderStage.TRANSFORM);
    mat.onRenderStage(RenderStage.BEFORE_TESSELLATE);
    draw(GL11.glGetInteger(GL20.GL_CURRENT_PROGRAM));
    mat.onRenderStage(RenderStage.END);//from ww  w  . j  ava 2  s.c o m
}

From source file:com.badlogic.gdx.backends.lwjgl.LwjglGraphics.java

License:Apache License

private static void extractExtensions() {
    extensions = new Array<String>();
    if (isOpenGLOrHigher(3, 2)) {
        int numExtensions = GL11.glGetInteger(GL30.GL_NUM_EXTENSIONS);
        for (int i = 0; i < numExtensions; ++i)
            extensions.add(org.lwjgl.opengl.GL30.glGetStringi(GL20.GL_EXTENSIONS, i));
    } else {/*from  w  w  w. j  a va 2 s  . c o  m*/
        extensions.addAll(org.lwjgl.opengl.GL11.glGetString(GL20.GL_EXTENSIONS).split(" "));
    }
}

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

private static int checkMaximumTextureSize() {
    return GL11.glGetInteger(GL11.GL_MAX_TEXTURE_SIZE);
}

From source file:com.google.gapid.glviewer.ShaderSource.java

License:Apache License

private static boolean isAtLeastVersion(int major, int minor) {
    int val = GL11.glGetInteger(GL30.GL_MAJOR_VERSION);
    return (val > major) || (val == major && GL11.glGetInteger(GL30.GL_MINOR_VERSION) >= minor);
}

From source file:com.opengrave.og.MainThread.java

License:Open Source License

public void createConfig() {
    boolean isSet = config.getBoolean("set", false);
    System.out.println("Running OpenGL : " + GL11.glGetString(GL11.GL_VERSION));

    String glsl = GL11.glGetString(GL20.GL_SHADING_LANGUAGE_VERSION).split(" ")[0];
    System.out.println(glsl + " " + Float.parseFloat(glsl));
    if (Float.parseFloat(glsl) < 1.299f) { // Stupid float accuracy. < 1.30
        System.out.println("This program requires GLSL 1.30 as an absolute minimum");
        System.exit(130);// w  ww .  ja  v  a2s  . c  om
    }
    if (!isSet) {
        int textures = GL11.glGetInteger(GL20.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS) - 3;
        System.out.println("Maximum spare textures (minus reserved) : " + textures);
        config.setBoolean("shadows", true);
        if (textures < 4) {
            System.out.println("Setting no point-light shadows");
            config.setInteger("lightCount", 0);
        } else if (textures < 8) {
            System.out.println("Setting 4 point-lights with shadows");
            config.setInteger("lightCount", 4);
        } else if (textures < 16) {
            System.out.println("Setting 8 point-lights with shadows");
            config.setInteger("lightCount", 8);
        } else {
            System.out.println("Setting 16 point-lights with shadows");
            // config.setInteger("lightCount", 16);
            // TODO Create lighting-more
            config.setInteger("lightCount", 8);
        }

        // TODO Check for GL 3.0 and turn off shadows/lightCount if below
        // if (!GLContext.getCapabilities().OpenGL30) {
        // System.out.println("This program does not support OpenGL versions before 3.0. Setting absolute minimum detail");
        // if (!isSet) {
        // // We'll assume the worst.
        // config.setInteger("lightCount", 0);
        // config.setBoolean("shadows", false);
        // }
        // }
        Resources.removeShadersWithLighting();
        config.setBoolean("set", true);
    }
}

From source file:com.samrj.devil.gl.RBO.java

/**
 * @return Whether this render buffer is bound.
 *//*from   ww w .  j  av  a 2 s. com*/
public final boolean isBound() {
    return !deleted && GL11.glGetInteger(GL30.GL_RENDERBUFFER_BINDING) == id;
}

From source file:com.samrj.devil.gl.RBO.java

final int tempBind() {
    int oldID = GL11.glGetInteger(GL30.GL_RENDERBUFFER_BINDING);
    if (oldID != id)
        GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, id);
    return oldID;
}

From source file:com.samrj.devil.gl.Texture.java

License:Open Source License

/**
 * @return Whether this texture is bound to the currently active texture channel.
 *///ww w .  jav  a  2 s  .  c o m
public final boolean isBound() {
    return !deleted && GL11.glGetInteger(binding) == id;
}