Example usage for org.lwjgl.opengl GL11 GL_TRUE

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

Introduction

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

Prototype

int GL_TRUE

To view the source code for org.lwjgl.opengl GL11 GL_TRUE.

Click Source Link

Document

Boolean

Usage

From source file:org.getspout.spout.config.MipMapUtils.java

License:Open Source License

public static void initalizeTexture(int textureId) {
    GL11.glBindTexture(3553, textureId);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);

    int textureWidth = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH);
    int tileWidth = textureWidth / 16;

    setMipmapLevels(textureId, (int) Math.round(Math.log((double) tileWidth) / Math.log(2D)));

    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, getMipmapLevels(textureId));

    ContextCapabilities capabilities = GLContext.getCapabilities();
    if (capabilities.OpenGL30) {
        MipMapUtils.mode = 1;//  ww w.  j  a  v a2  s .c o  m
    } else if (capabilities.GL_EXT_framebuffer_object) {
        MipMapUtils.mode = 2;
    } else if (capabilities.OpenGL14) {
        MipMapUtils.mode = 3;
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_GENERATE_MIPMAP, GL11.GL_TRUE);
    }
}

From source file:org.jogamp.glg2d.impl.shader.AbstractShaderPipeline.java

License:Apache License

protected void checkShaderThrowException(int shaderId) {
    int result = GL20.glGetShaderi(shaderId, GL20.GL_COMPILE_STATUS);
    if (result == GL11.GL_TRUE) {
        return;/*from  ww  w  .  j  a va2  s.co m*/
    }

    int loglen = GL20.glGetShaderi(shaderId, GL20.GL_INFO_LOG_LENGTH);
    String error = GL20.glGetShaderInfoLog(shaderId, loglen);

    throw new ShaderException(error);
}

From source file:org.jogamp.glg2d.impl.shader.AbstractShaderPipeline.java

License:Apache License

protected void checkProgramThrowException(int programId, int statusFlag) {
    int result = GL20.glGetProgrami(programId, statusFlag);
    if (result == GL11.GL_TRUE) {
        return;/*  w ww .j  a  va 2s  .c o  m*/
    }

    int loglen = GL20.glGetShaderi(programId, GL20.GL_INFO_LOG_LENGTH);
    String error = GL20.glGetShaderInfoLog(programId, loglen);
    throw new ShaderException(error);
}

From source file:org.lwjgl.system.jglfw.PlatformWin.java

License:Open Source License

@Override
public int getJoystickParam(int joy, int param) {
    if (!isJoystickPresent(joy))
        return 0;

    // We got this far, the joystick is present
    if (param == GLFW_PRESENT)
        return GL11.GL_TRUE;

    // Get joystick capabilities
    ByteBuffer jc = apiBuffer().buffer();
    joyGetDevCaps(joy - GLFW_JOYSTICK_1, jc, JOYCAPS.SIZEOF);

    int caps = JOYCAPS.capsGet(jc);
    int hats = (caps & JOYCAPS_HASPOV) != 0 && (caps & JOYCAPS_POV4DIR) != 0 ? 1 : 0;

    switch (param) {
    case GLFW_AXES:
        // Return number of joystick axes
        return JOYCAPS.numAxesGet(jc);

    case GLFW_BUTTONS:
        // Return number of joystick buttons
        return JOYCAPS.numButtonsGet(jc) + hats * 4;

    default:// w w w.j  a v a  2  s. c  o m
        break;
    }

    return 0;
}

From source file:org.spout.engine.renderer.shader.ClientShader.java

License:Open Source License

private void doCompileShader(String vsource, String fsource) {
    if (((Client) Spout.getEngine()).getRenderMode() == RenderMode.GL11) {
        return;//from   ww w.  jav  a 2s. c  o m
    }

    //Create a new Shader object on the GPU
    program = GL20.glCreateProgram();

    int vShader = ShaderHelper.compileShader(vsource, GL20.GL_VERTEX_SHADER);
    GL20.glAttachShader(program, vShader);

    int fShader = ShaderHelper.compileShader(fsource, GL20.GL_FRAGMENT_SHADER);
    GL20.glAttachShader(program, fShader);

    GL20.glLinkProgram(program);

    int status = GL20.glGetProgram(program, GL20.GL_LINK_STATUS);
    if (status != GL11.GL_TRUE) {
        String error = GL20.glGetProgramInfoLog(program, 255);
        throw new ShaderCompileException("Link Error: " + error);
    }
    if (validateShader) {
        GL20.glValidateProgram(this.program);
        if (GL20.glGetProgram(program, GL20.GL_VALIDATE_STATUS) != GL11.GL_TRUE) {
            String info = GL20.glGetProgramInfoLog(program, 255);
            System.out.println("Validate Log: \n" + info);
        }

        System.out.println("Attached Shaders: " + GL20.glGetProgram(program, GL20.GL_ATTACHED_SHADERS));
        int activeAttributes = GL20.glGetProgram(program, GL20.GL_ACTIVE_ATTRIBUTES);
        System.out.println("Active Attributes: " + activeAttributes);
        int maxAttributeLength = GL20.glGetProgram(program, GL20.GL_ACTIVE_ATTRIBUTE_MAX_LENGTH);
        for (int i = 0; i < activeAttributes; i++) {
            System.out.println("\t" + GL20.glGetActiveAttrib(program, i, maxAttributeLength));
        }

        int activeUniforms = GL20.glGetProgram(program, GL20.GL_ACTIVE_UNIFORMS);
        System.out.println("Active Uniforms: " + activeUniforms);
        int maxUniformLength = GL20.glGetProgram(program, GL20.GL_ACTIVE_UNIFORM_MAX_LENGTH);
        for (int i = 0; i < activeUniforms; i++) {
            System.out.println("\t" + GL20.glGetActiveUniform(program, i, maxUniformLength));
        }
    }
    System.out.println("Compiled Shader with id: " + program);
}

From source file:org.spout.engine.renderer.shader.ShaderHelper.java

License:Open Source License

public static int compileShader(String source, int type) {

    int shader = GL20.glCreateShader(type);
    GL20.glShaderSource(shader, source);
    GL20.glCompileShader(shader);//from  ww w .  j  av a  2s  .  c  o  m
    int status = GL20.glGetShader(shader, GL20.GL_COMPILE_STATUS);

    if (status != GL11.GL_TRUE) {
        String error = GL20.glGetShaderInfoLog(shader, 255);
        throw new ShaderCompileException("Compile Error in "
                + ((type == GL20.GL_FRAGMENT_SHADER) ? "Fragment Shader" : "VertexShader") + ": " + error);
    }
    return shader;
}

From source file:org.spoutcraft.client.config.MipMapUtils.java

License:Open Source License

public static void initalizeTexture(int textureId) {
    SpoutClient.getHandle().renderEngine.bindTexture(textureId);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);

    int textureWidth = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH);
    int tileWidth = textureWidth / 16;

    setMipmapLevels(textureId, (int) Math.round(Math.log((double) tileWidth) / Math.log(2D)));

    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, getMipmapLevels(textureId));

    ContextCapabilities capabilities = GLContext.getCapabilities();
    if (capabilities.OpenGL30) {
        MipMapUtils.mode = 1;//  w w  w  . j av a2s.  com
    } else if (capabilities.GL_EXT_framebuffer_object) {
        MipMapUtils.mode = 2;
    } else if (capabilities.OpenGL14) {
        MipMapUtils.mode = 3;
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_GENERATE_MIPMAP, GL11.GL_TRUE);
    }
}

From source file:org.spoutcraft.client.gui.MCRenderDelegate.java

License:Open Source License

public void drawTexture(Texture textureBinding, int width, int height, Color color, boolean blend, int left,
        int top, boolean mipmap, int filter) {
    if (textureBinding == null) {
        return;/* www .  j  a  va2  s  . c o m*/
    }
    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    boolean wasBlend = GL11.glGetBoolean(GL11.GL_BLEND);
    if (blend) {
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(770, 771);
    }
    GL11.glDepthMask(false);
    bindColor(color);
    SpoutClient.getHandle().renderEngine.bindTexture(textureBinding.getTextureID());
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filter);
    if (mipmap) {
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, 8);

        ContextCapabilities capabilities = GLContext.getCapabilities();
        if (capabilities.OpenGL30) {
            GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
        } else if (capabilities.GL_EXT_framebuffer_object) {
            EXTFramebufferObject.glGenerateMipmapEXT(GL11.GL_TEXTURE_2D);
        } else if (capabilities.OpenGL14) {
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_GENERATE_MIPMAP, GL11.GL_TRUE);
        }
    }

    double tLeft = 0, tTop = 0, rWidth = textureBinding.getWidth(), rHeight = textureBinding.getHeight(),
            tWidth = rWidth, tHeight = rHeight;
    if (top >= 0 && left >= 0) {
        tWidth = Math.min(tWidth,
                (width / (double) textureBinding.getImageWidth()) * textureBinding.getWidth());
        tHeight = Math.min(tHeight,
                (height / (double) textureBinding.getImageHeight()) * textureBinding.getHeight());
        tLeft = Math.min(
                Math.max(0, (left / (double) textureBinding.getImageWidth())) * textureBinding.getWidth(),
                rWidth);
        tTop = Math.min(
                Math.max(0, (top / (double) textureBinding.getImageHeight()) * textureBinding.getHeight()),
                rHeight);
    }
    tHeight = -tHeight;
    tTop = rHeight - tTop;

    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(0.0D, height, -90, tLeft, tTop + tHeight); // draw corners
    tessellator.addVertexWithUV(width, height, -90, tLeft + tWidth, tTop + tHeight);
    tessellator.addVertexWithUV(width, 0.0D, -90, tLeft + tWidth, tTop);
    tessellator.addVertexWithUV(0.0D, 0.0D, -90, tLeft, tTop);

    tessellator.draw();
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
    if (blend && !wasBlend) {
        GL11.glDisable(GL11.GL_BLEND);
    }
}

From source file:prueba.Main.java

private void init() {
    // Setup an error callback. The default implementation
    // will print the error message in System.err.
    glfwSetErrorCallback(errorCallback = errorCallbackPrint(System.err));

    // Initialize GLFW. Most GLFW functions will not work before doing this.
    if (glfwInit() != GL11.GL_TRUE) {
        throw new IllegalStateException("Unable to initialize GLFW");
    }/*w  ww .j a  v  a 2s  .c o  m*/

    // Configure our window
    glfwDefaultWindowHints(); // optional, the current window hints are already the default
    glfwWindowHint(GLFW_VISIBLE, GL_FALSE); // the window will stay hidden after creation
    glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); // the window will be resizable

    int WIDTH = 600;
    int HEIGHT = 600;

    // Create the window
    window = glfwCreateWindow(WIDTH, HEIGHT, "Simulator by mghfdez", NULL, NULL);
    if (window == NULL) {
        throw new RuntimeException("Failed to create the GLFW window");
    }

    // Setup a key callback. It will be called every time a key is pressed, repeated or released.
    glfwSetKeyCallback(window, keyCallback = new GLFWKeyCallback() {
        @Override
        public void invoke(long window, int key, int scancode, int action, int mods) {
            if (key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE) {
                glfwSetWindowShouldClose(window, GL_TRUE); // We will detect this in our rendering loop
            }
        }
    });

    // Get the resolution of the primary monitor
    ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
    // Center our window
    glfwSetWindowPos(window, (GLFWvidmode.width(vidmode) - WIDTH) / 2,
            (GLFWvidmode.height(vidmode) - HEIGHT) / 2);

    // Make the OpenGL context current
    glfwMakeContextCurrent(window);
    // Enable v-sync
    glfwSwapInterval(1);

    // Make the window visible
    glfwShowWindow(window);
}

From source file:se.angergard.engine.display.Display.java

License:Apache License

public static void create(DisplayDef def) {

    glfwSetErrorCallback(errorCallback = errorCallbackPrint(System.err));

    if (glfwInit() != GL_TRUE) {
        throw new IllegalStateException("Unable to initialize GLFW");
    }/*from  ww w.j  av  a 2  s.c o m*/

    glfwDefaultWindowHints();
    glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
    glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
    glfwWindowHint(GLFW_DECORATED, GL_TRUE);
    // TODO: Fix this, important to MAC OS
    // glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

    window = glfwCreateWindow(def.width, def.height, def.title, NULL, NULL);

    if (window == NULL) {
        throw new RuntimeException("Failed to create the GLFW window");
    }

    GLFW.glfwSetWindowSizeCallback(window, new GLFWWindowSizeCallback() {
        @Override
        public void invoke(long window, int width, int height) {
            System.out.println("Hej " + width + ", " + height);
            Display.width = width;
            Display.height = height;
        }
    });

    GLFW.glfwSetWindowCloseCallback(window, new GLFWWindowCloseCallback() {

        @Override
        public void invoke(long window) {
            RenderingEngine.dispose();
            glfwSetWindowShouldClose(window, GL11.GL_TRUE);
        }

    });

    glfwSetWindowPos(window, def.xPosition, def.yPosition);

    glfwMakeContextCurrent(window);
    glfwSwapInterval(1);

    glfwShowWindow(window);

    GLContext.createFromCurrent();

    // Only enable depth test if using 3d.

    glEnable(GL_TEXTURE_2D);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    GL14.glBlendEquation(GL14.GL_FUNC_ADD); // Not really neccessary

    RenderUtil.setClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    Logger.log(Values.VERSION);
    Logger.log("Your OpenGL version is " + glGetString(GL_VERSION));
    Logger.log("Created Display with the following settings : " + def.toString());

}