Search in sources :

Example 6 with GL

use of com.jogamp.opengl.GL in project jmonkeyengine by jMonkeyEngine.

the class TextureUtil method getImageFormat.

public static GLImageFormat getImageFormat(Format fmt, boolean isSrgb) {
    GL gl = GLContext.getCurrentGL();
    switch(fmt) {
        case ABGR8:
            if (!gl.isExtensionAvailable("GL_EXT_abgr") && !abgrToRgbaConversionEnabled) {
                setFormat(Format.ABGR8, GL.GL_RGBA, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, false);
                abgrToRgbaConversionEnabled = true;
            }
            break;
        case BGR8:
            if (!gl.isExtensionAvailable("GL_VERSION_1_2") && !gl.isExtensionAvailable("EXT_bgra")) {
                return null;
            }
            break;
        case DXT1:
        case DXT1A:
        case DXT3:
        case DXT5:
            if (!gl.isExtensionAvailable("GL_EXT_texture_compression_s3tc")) {
                return null;
            }
            break;
        case Depth:
        case Depth16:
        case Depth24:
        case Depth32:
            if (!gl.isExtensionAvailable("GL_VERSION_1_4") && !gl.isExtensionAvailable("ARB_depth_texture")) {
                return null;
            }
            break;
        case Depth24Stencil8:
            if (!gl.isExtensionAvailable("GL_VERSION_3_0")) {
                return null;
            }
            break;
        case Luminance16F:
        case Luminance16FAlpha16F:
        case Luminance32F:
            if (!gl.isExtensionAvailable("GL_ARB_texture_float")) {
                return null;
            }
            break;
        case RGB16F:
        case RGB32F:
        case RGBA16F:
        case RGBA32F:
            if (!gl.isExtensionAvailable("GL_VERSION_3_0") && !gl.isExtensionAvailable("GL_ARB_texture_float")) {
                return null;
            }
            break;
        case Depth32F:
            if (!gl.isExtensionAvailable("GL_VERSION_3_0") && !gl.isExtensionAvailable("GL_NV_depth_buffer_float")) {
                return null;
            }
            break;
        case RGB9E5:
        case RGB16F_to_RGB9E5:
            if (!gl.isExtensionAvailable("GL_VERSION_3_0") && !gl.isExtensionAvailable("GL_EXT_texture_shared_exponent")) {
                return null;
            }
            break;
        case RGB111110F:
        case RGB16F_to_RGB111110F:
            if (!gl.isExtensionAvailable("GL_VERSION_3_0") && !gl.isExtensionAvailable("GL_EXT_packed_float")) {
                return null;
            }
            break;
    }
    if (isSrgb) {
        return getSrgbFormat(fmt);
    }
    return formatToGL[fmt.ordinal()];
}
Also used : GL(com.jogamp.opengl.GL)

Example 7 with GL

use of com.jogamp.opengl.GL in project artisynth_core by artisynth.

the class GLTextRenderer method replaceTexture.

@Override
protected void replaceTexture(int width, int height, ByteBuffer buff) {
    GL gl = renderer.getGL();
    gl.glTexImage2D(texture.getTarget(), 0, GL.GL_RGBA, width, height, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, buff);
    gl.glGenerateMipmap(texture.getTarget());
}
Also used : GL(com.jogamp.opengl.GL)

Example 8 with GL

use of com.jogamp.opengl.GL in project artisynth_core by artisynth.

the class GLViewer method dispose.

/**
 * Called any time GL context is switched! e.g. moving window to new display
 */
public void dispose(GLAutoDrawable drawable) {
    myCommittedViewerState = null;
    GL gl = drawable.getGL();
    if (mySelector != null) {
        mySelector.dispose(gl);
    }
    garbage(gl);
}
Also used : GL(com.jogamp.opengl.GL)

Example 9 with GL

use of com.jogamp.opengl.GL in project artisynth_core by artisynth.

the class GLViewer method display.

public void display(GLAutoDrawable drawable) {
    // System.out.println ("GLViewer display(GLAutoDrawable drawable) called with " + drawable.getClass ());
    // assign current drawable
    this.drawable = drawable;
    // reset attributes due to possible change by GLJPanel
    if (useGLJPanel) {
        myCommittedViewerState = null;
        myCommittedColor = null;
        myCurrentMaterialModified = true;
    }
    int flags = myRenderFlags.get();
    // check if gamma property needs to be changed
    if (gammaCorrectionRequested) {
        GL gl = drawable.getGL();
        if (gammaCorrectionEnabled) {
            gl.glEnable(GL2GL3.GL_FRAMEBUFFER_SRGB);
        } else {
            gl.glDisable(GL2GL3.GL_FRAMEBUFFER_SRGB);
        }
        gammaCorrectionRequested = false;
    }
    int depthBits = drawable.getChosenGLCapabilities().getDepthBits();
    if (depthBits != myFrustum.depthBits) {
        myFrustum.depthBits = depthBits;
        computeProjectionMatrix();
    }
    display(drawable, flags);
    // clear current drawable
    this.drawable = null;
}
Also used : GL(com.jogamp.opengl.GL)

Aggregations

GL (com.jogamp.opengl.GL)9 Image (com.jme3.texture.Image)2 Format (com.jme3.texture.Image.Format)2 ByteBuffer (java.nio.ByteBuffer)2 JoglGL (com.jme3.renderer.jogl.JoglGL)1 IntBuffer (java.nio.IntBuffer)1 Logger (maspack.util.Logger)1