fix assorted bugs, works now

(cherry picked from commit 55d4f32fc2)
This commit is contained in:
Brian
2007-10-24 13:55:22 -06:00
committed by Michel Dänzer
parent 13a2be4446
commit e8d5be9c76

View File

@@ -1,13 +1,9 @@
/* /*
* GL_ARB_multitexture demo * GL_ARB_pixel_buffer_object test
* *
* Command line options: * Command line options:
* -info print GL implementation information * -w WIDTH -h HEIGHT sets window size
* *
*
* Brian Paul November 1998 This program is in the public domain.
* Modified on 12 Feb 2002 for > 2 texture units.
*/ */
#define GL_GLEXT_PROTOTYPES #define GL_GLEXT_PROTOTYPES
@@ -25,6 +21,8 @@
#define PBO 11 #define PBO 11
#define QUIT 100 #define QUIT 100
static GLuint DrawPBO;
static GLboolean Animate = GL_TRUE; static GLboolean Animate = GL_TRUE;
static GLboolean use_pbo = 1; static GLboolean use_pbo = 1;
static GLboolean whole_rect = 1; static GLboolean whole_rect = 1;
@@ -49,7 +47,7 @@ static void Idle( void )
} }
} }
static int max( int a, int b ) { return a > b ? a : b; } /*static int max( int a, int b ) { return a > b ? a : b; }*/
static int min( int a, int b ) { return a < b ? a : b; } static int min( int a, int b ) { return a < b ? a : b; }
static void DrawObject() static void DrawObject()
@@ -62,6 +60,7 @@ static void DrawObject()
* release the old copy of the texture and allocate a new one * release the old copy of the texture and allocate a new one
* without waiting for outstanding rendering to complete. * without waiting for outstanding rendering to complete.
*/ */
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO);
glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_EXT, size, NULL, GL_STREAM_DRAW_ARB); glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_EXT, size, NULL, GL_STREAM_DRAW_ARB);
{ {
@@ -69,7 +68,7 @@ static void DrawObject()
printf("char %d\n", (unsigned char)(Drift * 255)); printf("char %d\n", (unsigned char)(Drift * 255));
memset(image, size, (unsigned char)(Drift * 255)); memset(image, (unsigned char)(Drift * 255), size);
glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT); glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT);
} }
@@ -86,7 +85,9 @@ static void DrawObject()
if (image == NULL) if (image == NULL)
image = malloc(size); image = malloc(size);
memset(image, size, (unsigned char)(Drift * 255)); glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
memset(image, (unsigned char)(Drift * 255), size);
/* BGRA should be the fast path for regular uploads as well. /* BGRA should be the fast path for regular uploads as well.
*/ */
@@ -227,12 +228,12 @@ static void SpecialKey( int key, int x, int y )
static void Init( int argc, char *argv[] ) static void Init( int argc, char *argv[] )
{ {
const char *exten = (const char *) glGetString(GL_EXTENSIONS); const char *exten = (const char *) glGetString(GL_EXTENSIONS);
GLuint texObj, DrawPBO; GLuint texObj;
GLint size; GLint size;
if (!strstr(exten, "GL_ARB_multitexture")) { if (!strstr(exten, "GL_ARB_pixel_buffer_object")) {
printf("Sorry, GL_ARB_multitexture not supported by this renderer.\n"); printf("Sorry, GL_ARB_pixel_buffer_object not supported by this renderer.\n");
exit(1); exit(1);
} }