Search in sources :

Example 1 with PixelFormat

use of org.lwjgl.opengl.PixelFormat in project jmonkeyengine by jMonkeyEngine.

the class LwjglCanvas method acquirePixelFormat.

/**
     * It seems it is best to use one pixel format for all shared contexts.
     * @see <a href="http://developer.apple.com/library/mac/#qa/qa1248/_index.html">http://developer.apple.com/library/mac/#qa/qa1248/_index.html</a>
     */
protected PixelFormat acquirePixelFormat(boolean forPbuffer) {
    if (forPbuffer) {
        // crashes on bad drivers
        if (pbufferFormat == null) {
            pbufferFormat = new PixelFormat(settings.getBitsPerPixel(), settings.getAlphaBits(), settings.getDepthBits(), settings.getStencilBits(), // samples
            0, 0, 0, 0, settings.useStereo3D());
        }
        return pbufferFormat;
    } else {
        if (canvasFormat == null) {
            int samples = getNumSamplesToUse();
            canvasFormat = new PixelFormat(settings.getBitsPerPixel(), settings.getAlphaBits(), settings.getDepthBits(), settings.getStencilBits(), samples, 0, 0, 0, settings.useStereo3D());
        }
        return canvasFormat;
    }
}
Also used : PixelFormat(org.lwjgl.opengl.PixelFormat)

Example 2 with PixelFormat

use of org.lwjgl.opengl.PixelFormat in project lwjgl by LWJGL.

the class UniqueRendererRTT method init.

// Initialize texture renderer
protected Pbuffer init(final int width, final int height, final int texID) {
    Pbuffer pbuffer = null;
    try {
        final RenderTexture rt = new RenderTexture(true, false, false, false, RenderTexture.RENDER_TEXTURE_2D, 0);
        pbuffer = new Pbuffer(width, height, new PixelFormat(16, 0, 0, 0, 0), rt, null);
        // Initialise state of the pbuffer context.
        pbuffer.makeCurrent();
        PbufferTest.initGLState(width, height, 0.5f);
        glBindTexture(GL_TEXTURE_2D, texID);
        Display.makeCurrent();
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(-1);
    }
    return pbuffer;
}
Also used : RenderTexture(org.lwjgl.opengl.RenderTexture) PixelFormat(org.lwjgl.opengl.PixelFormat) Pbuffer(org.lwjgl.opengl.Pbuffer) LWJGLException(org.lwjgl.LWJGLException)

Example 3 with PixelFormat

use of org.lwjgl.opengl.PixelFormat in project lwjgl by LWJGL.

the class PbufferTest method initialize.

/**
   * Initializes the test
   */
private void initialize() {
    try {
        //find displaymode
        pbuffer = new Pbuffer(512, 512, new PixelFormat(), null, null);
        mode = findDisplayMode(800, 600, 16);
        Display.setDisplayMode(mode);
        // start of in windowed mode
        Display.create();
        //      gl = new GLWindow("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
        if ((Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) == 0) {
            System.out.println("No Pbuffer support!");
            System.exit(1);
        }
        System.out.println("Pbuffer support detected");
        glInit();
        initPbuffer();
        Keyboard.create();
        quadPosition = new Vector2f(100f, 100f);
        quadVelocity = new Vector2f(1.0f, 1.0f);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Vector2f(org.lwjgl.util.vector.Vector2f) PixelFormat(org.lwjgl.opengl.PixelFormat) Pbuffer(org.lwjgl.opengl.Pbuffer) LWJGLException(org.lwjgl.LWJGLException)

Example 4 with PixelFormat

use of org.lwjgl.opengl.PixelFormat in project lwjgl by LWJGL.

the class UniqueRenderer method init.

protected Pbuffer init(final int width, final int height, final int texID) {
    Pbuffer pbuffer = null;
    try {
        pbuffer = new Pbuffer(width, height, new PixelFormat(16, 0, 0, 0, 0), null, null);
        // Initialise state of the pbuffer context.
        pbuffer.makeCurrent();
        PbufferTest.initGLState(width, height, 0.5f);
        glBindTexture(GL_TEXTURE_2D, texID);
        Display.makeCurrent();
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(-1);
    }
    return pbuffer;
}
Also used : PixelFormat(org.lwjgl.opengl.PixelFormat) Pbuffer(org.lwjgl.opengl.Pbuffer) LWJGLException(org.lwjgl.LWJGLException)

Example 5 with PixelFormat

use of org.lwjgl.opengl.PixelFormat in project libgdx by libgdx.

the class LwjglGraphics method createDisplayPixelFormat.

private void createDisplayPixelFormat(boolean useGL30, int gles30ContextMajor, int gles30ContextMinor) {
    try {
        if (useGL30) {
            ContextAttribs context = new ContextAttribs(gles30ContextMajor, gles30ContextMinor).withForwardCompatible(false).withProfileCore(true);
            try {
                Display.create(new PixelFormat(config.r + config.g + config.b, config.a, config.depth, config.stencil, config.samples), context);
            } catch (Exception e) {
                System.out.println("LwjglGraphics: OpenGL " + gles30ContextMajor + "." + gles30ContextMinor + "+ core profile (GLES 3.0) not supported.");
                createDisplayPixelFormat(false, gles30ContextMajor, gles30ContextMinor);
                return;
            }
            System.out.println("LwjglGraphics: created OpenGL " + gles30ContextMajor + "." + gles30ContextMinor + "+ core profile (GLES 3.0) context. This is experimental!");
            usingGL30 = true;
        } else {
            Display.create(new PixelFormat(config.r + config.g + config.b, config.a, config.depth, config.stencil, config.samples));
            usingGL30 = false;
        }
        bufferFormat = new BufferFormat(config.r, config.g, config.b, config.a, config.depth, config.stencil, config.samples, false);
    } catch (Exception ex) {
        Display.destroy();
        try {
            Thread.sleep(200);
        } catch (InterruptedException ignored) {
        }
        try {
            Display.create(new PixelFormat(0, 16, 8));
            if (getDisplayMode().bitsPerPixel == 16) {
                bufferFormat = new BufferFormat(5, 6, 5, 0, 16, 8, 0, false);
            }
            if (getDisplayMode().bitsPerPixel == 24) {
                bufferFormat = new BufferFormat(8, 8, 8, 0, 16, 8, 0, false);
            }
            if (getDisplayMode().bitsPerPixel == 32) {
                bufferFormat = new BufferFormat(8, 8, 8, 8, 16, 8, 0, false);
            }
        } catch (Exception ex2) {
            Display.destroy();
            try {
                Thread.sleep(200);
            } catch (InterruptedException ignored) {
            }
            try {
                Display.create(new PixelFormat());
            } catch (Exception ex3) {
                if (!softwareMode && config.allowSoftwareMode) {
                    softwareMode = true;
                    System.setProperty("org.lwjgl.opengl.Display.allowSoftwareOpenGL", "true");
                    createDisplayPixelFormat(useGL30, gles30ContextMajor, gles30ContextMinor);
                    return;
                }
                throw new GdxRuntimeException("OpenGL is not supported by the video driver.", ex3);
            }
            if (getDisplayMode().bitsPerPixel == 16) {
                bufferFormat = new BufferFormat(5, 6, 5, 0, 8, 0, 0, false);
            }
            if (getDisplayMode().bitsPerPixel == 24) {
                bufferFormat = new BufferFormat(8, 8, 8, 0, 8, 0, 0, false);
            }
            if (getDisplayMode().bitsPerPixel == 32) {
                bufferFormat = new BufferFormat(8, 8, 8, 8, 8, 0, 0, false);
            }
        }
    }
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) PixelFormat(org.lwjgl.opengl.PixelFormat) ContextAttribs(org.lwjgl.opengl.ContextAttribs) LWJGLException(org.lwjgl.LWJGLException) GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException)

Aggregations

PixelFormat (org.lwjgl.opengl.PixelFormat)6 LWJGLException (org.lwjgl.LWJGLException)5 Pbuffer (org.lwjgl.opengl.Pbuffer)4 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)1 ContextAttribs (org.lwjgl.opengl.ContextAttribs)1 RenderTexture (org.lwjgl.opengl.RenderTexture)1 Vector2f (org.lwjgl.util.vector.Vector2f)1