use of org.lwjgl.opengl.Pbuffer 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;
}
use of org.lwjgl.opengl.Pbuffer 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;
}
use of org.lwjgl.opengl.Pbuffer 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();
}
}
use of org.lwjgl.opengl.Pbuffer in project jmonkeyengine by jMonkeyEngine.
the class LwjglCanvas method makePbufferAvailable.
/**
* Makes sure the pbuffer is available and ready for use
*/
protected void makePbufferAvailable() throws LWJGLException {
if (pbuffer != null && pbuffer.isBufferLost()) {
logger.log(Level.WARNING, "PBuffer was lost!");
pbuffer.destroy();
pbuffer = null;
}
if (pbuffer == null) {
pbuffer = new Pbuffer(1, 1, acquirePixelFormat(true), null);
pbuffer.makeCurrent();
logger.log(Level.FINE, "OGL: Pbuffer has been created");
// Any created objects are no longer valid
if (!runningFirstTime) {
renderer.resetGLObjects();
}
}
pbuffer.makeCurrent();
if (!pbuffer.isCurrent()) {
throw new LWJGLException("Pbuffer cannot be made current");
}
}
use of org.lwjgl.opengl.Pbuffer in project lwjgl by LWJGL.
the class PbufferTest method render.
private void render() {
if (pbuffer.isBufferLost()) {
System.out.println("Buffer contents lost - will recreate the buffer");
pbuffer.destroy();
try {
pbuffer = new Pbuffer(512, 512, new PixelFormat(), null, null);
initPbuffer();
} catch (LWJGLException e) {
e.printStackTrace();
}
}
try {
pbuffer.makeCurrent();
} catch (LWJGLException e) {
throw new RuntimeException(e);
}
// Pbuffer rendering
// clear background
glClear(GL_COLOR_BUFFER_BIT);
// draw white quad
glPushMatrix();
{
glTranslatef(quadPosition.x, quadPosition.y, 0);
glRotatef(angle, 0.0f, 0.0f, 1.0f);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
{
glVertex2i(-50, -50);
glVertex2i(50, -50);
glVertex2i(50, 50);
glVertex2i(-50, 50);
}
glEnd();
}
glPopMatrix();
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 512, 512, 0);
try {
Display.makeCurrent();
} catch (LWJGLException e) {
throw new RuntimeException(e);
}
// OpenGL window rendering
glClear(GL_COLOR_BUFFER_BIT);
// draw white quad
glPushMatrix();
{
glTranslatef(quadPosition.x, quadPosition.y, 0);
glRotatef(angle, 0.0f, 0.0f, 1.0f);
glColor3f(1.0f, 1.0f, 0.0f);
glBegin(GL_QUADS);
{
glTexCoord2f(0f, 0f);
glVertex2i(-50, -50);
glTexCoord2f(1f, 0f);
glVertex2i(50, -50);
glTexCoord2f(1f, 1f);
glVertex2i(50, 50);
glTexCoord2f(0f, 1f);
glVertex2i(-50, 50);
}
glEnd();
}
glPopMatrix();
}
Aggregations