use of org.lwjgl.opengl.PixelFormat 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