#include <GL/glut.h>
static int Width = 400, Height = 400;
-static GLuint MyFB;
+static GLuint MyFB, MyRB;
static void
free(buffer);
glutSwapBuffers();
+ CheckError(__LINE__);
}
}
+static void
+CleanUp(void)
+{
+ glDeleteFramebuffersEXT(1, &MyFB);
+ glDeleteRenderbuffersEXT(1, &MyRB);
+ assert(!glIsFramebufferEXT(MyFB));
+ assert(!glIsRenderbufferEXT(MyRB));
+ exit(0);
+}
+
+
static void
Key( unsigned char key, int x, int y )
{
(void) y;
switch (key) {
case 27:
- exit(0);
+ CleanUp();
break;
}
glutPostRedisplay();
static void
Init( void )
{
- GLuint rb;
GLint i;
if (!glutExtensionSupported("GL_EXT_framebuffer_object")) {
assert(!glIsFramebufferEXT(MyFB));
/* Note, continue to use MyFB below */
- glGenRenderbuffersEXT(1, &rb);
- assert(rb);
- assert(!glIsRenderbufferEXT(rb));
- glDeleteRenderbuffersEXT(1, &rb);
- assert(!glIsRenderbufferEXT(rb));
- rb = 42; /* an arbitrary ID */
+ glGenRenderbuffersEXT(1, &MyRB);
+ assert(MyRB);
+ assert(!glIsRenderbufferEXT(MyRB));
+ glDeleteRenderbuffersEXT(1, &MyRB);
+ assert(!glIsRenderbufferEXT(MyRB));
+ MyRB = 42; /* an arbitrary ID */
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
assert(glIsFramebufferEXT(MyFB));
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
- assert(glIsRenderbufferEXT(rb));
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, MyRB);
+ assert(glIsRenderbufferEXT(MyRB));
glGetIntegerv(GL_RENDERBUFFER_BINDING_EXT, &i);
- assert(i == rb);
+ assert(i == MyRB);
glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &i);
assert(i == MyFB);
+ CheckError(__LINE__);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT,
- GL_RENDERBUFFER_EXT, rb);
+ GL_RENDERBUFFER_EXT, MyRB);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+ CheckError(__LINE__);
+
{
GLint r, g, b, a;
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
GL_RENDERBUFFER_BLUE_SIZE_EXT, &b);
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
GL_RENDERBUFFER_ALPHA_SIZE_EXT, &a);
+ CheckError(__LINE__);
printf("renderbuffer RGBA sizes = %d %d %d %d\n", r, g, b, a);
glGetIntegerv(GL_RED_BITS, &r);
printf("Visual RGBA sizes = %d %d %d %d\n", r, g, b, a);
}
- CheckError(__LINE__);
-
/* restore to default */
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ CheckError(__LINE__);
}