Module: Mesa
Branch: master
Commit: d5ccbea63cb9ba96cd4c0e2f40824ec1939c806c
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d5ccbea63cb9ba96cd4c0e2f40824ec1939c806c

Author: Brian Paul <[email protected]>
Date:   Wed Mar 10 14:32:56 2010 -0700

progs/trivial: make clear-fbo-scissor.c work with other GL drivers

NVIDIA's driver requires that the texture that we're going to render into
be complete.  Need to set min/mag filters to non-mipmap modes.

Plus added other error/debug checks.

---

 progs/trivial/clear-fbo-scissor.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/progs/trivial/clear-fbo-scissor.c 
b/progs/trivial/clear-fbo-scissor.c
index 5ec0b57..28c613c 100644
--- a/progs/trivial/clear-fbo-scissor.c
+++ b/progs/trivial/clear-fbo-scissor.c
@@ -11,6 +11,7 @@
 #include <string.h>
 #include <GL/glew.h>
 #include <GL/glut.h>
+#include <GL/glu.h>
 
 
 static int Width = 512, Height = 512;
@@ -18,12 +19,20 @@ static GLuint MyFB, MyRB;
 static GLboolean UseTex = GL_FALSE;
 
 
-#define CheckError() assert(glGetError() == 0)
+#define CheckError() \
+   do { \
+      GLenum err = glGetError(); \
+      if (err != GL_NO_ERROR) \
+         printf("Error: %s\n", gluErrorString(err)); \
+      assert(err == GL_NO_ERROR); \
+   } while (0)
 
 
 static void
 Init(void)
 {
+   GLenum status;
+
    fprintf(stderr, "GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));
    fprintf(stderr, "GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
    fprintf(stderr, "GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
@@ -45,6 +54,8 @@ Init(void)
       glBindTexture(GL_TEXTURE_2D, tex);
       glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0,
                    GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
       glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, 
                                 GL_COLOR_ATTACHMENT0_EXT,
                                 GL_TEXTURE_2D, tex, 0);
@@ -59,6 +70,11 @@ Init(void)
       glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
    }
 
+   status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+   if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+      fprintf(stderr, "Framebuffer object is incomplete (0x%x)!\n", status);
+   }
+
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
 }
 
@@ -134,6 +150,8 @@ Draw(void)
       glClear(GL_COLOR_BUFFER_BIT);
    }
 
+   CheckError();
+
    /* gray triangle in middle, pointing up */
    glColor3f(0.5, 0.5, 0.5);
    glBegin(GL_TRIANGLES);

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to