Java Code Examples for org.lwjgl.opengl.GL#setCapabilities()

The following examples show how to use org.lwjgl.opengl.GL#setCapabilities() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: vboWithRGBA.java    From ldparteditor with MIT License 6 votes vote down vote up
@Override
public void drawScene(float mouseX, float mouseY) {
    final GLCanvas canvas = cp.getCanvas();

    if (!canvas.isCurrent()) {
        canvas.setCurrent();
        GL.setCapabilities(cp.getCapabilities());
    }
    
    GL11.glColorMask(true, true, true, true);

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
    
    Rectangle bounds = cp.getBounds();
    GL11.glViewport(0, 0, bounds.width, bounds.height);
    
    shaderProgram.use();
    GL30.glBindVertexArray(VAO);
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 3);
    GL30.glBindVertexArray(0);
    
    canvas.swapBuffers();
}
 
Example 2
Source File: vboWithIndices.java    From ldparteditor with MIT License 6 votes vote down vote up
@Override
public void drawScene(float mouseX, float mouseY) {
    final GLCanvas canvas = cp.getCanvas();

    if (!canvas.isCurrent()) {
        canvas.setCurrent();
        GL.setCapabilities(cp.getCapabilities());
    }
    
    GL11.glColorMask(true, true, true, true);

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
    
    Rectangle bounds = cp.getBounds();
    GL11.glViewport(0, 0, bounds.width, bounds.height);
    
    shaderProgram.use();
    GL30.glBindVertexArray(VAO);
    // GL20.glEnableVertexAttribArray(POSITION_SHADER_LOCATION); // <-- Not necessary!
    GL11.glDrawElements(GL11.GL_TRIANGLES, 6, GL11.GL_UNSIGNED_INT, 0);
    // GL20.glDisableVertexAttribArray(POSITION_SHADER_LOCATION); // <-- Not necessary!
    GL30.glBindVertexArray(0);
    
    canvas.swapBuffers();
}
 
Example 3
Source File: OpenGLRenderer.java    From ldparteditor with MIT License 6 votes vote down vote up
/**
 * Disposes old textures
 */
public synchronized void disposeOldTextures() {
    final GLCanvas canvas = c3d.getCanvas();
    if (!canvas.isCurrent()) {
        canvas.setCurrent();
        GL.setCapabilities(c3d.getCapabilities());
    }
    Iterator<GTexture> ti = textureSet.iterator();
    for (GTexture tex = null; ti.hasNext() && (tex = ti.next()) != null;) {
        if (tex.isTooOld()) {
            NLogger.debug(getClass(), "Dispose old texture: {0}", tex); //$NON-NLS-1$
            tex.dispose(this);
            ti.remove();
        }
    }
}
 
Example 4
Source File: Window.java    From LWJGUI with MIT License 5 votes vote down vote up
/**
 * Unloads any native resource, destroys the OpenGL context and it's data.
 * 
 * <p>
 * This function must only be called from the window thread.
 * </p>
 */
public void dispose() {
	scene.dispose();
	context.dispose();
	glfwMakeContextCurrent(NULL);
	GL.setCapabilities(null);
	this.destroy = true;
}
 
Example 5
Source File: OpenGLRenderer.java    From ldparteditor with MIT License 5 votes vote down vote up
/**
 * Disposes all textures
 */
public void disposeAllTextures() {
    final GLCanvas canvas = c3d.getCanvas();
    if (!canvas.isCurrent()) {
        canvas.setCurrent();
        GL.setCapabilities(c3d.getCapabilities());
    }
    for (Iterator<GTexture> it = textureSet.iterator() ; it.hasNext();) {
        GTexture tex = it.next();
        NLogger.debug(getClass(), "Dispose texture: {0}", tex); //$NON-NLS-1$
        tex.dispose(this);
        it.remove();
    }
}