summaryrefslogtreecommitdiff
path: root/progs
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2003-10-14 15:49:12 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2003-10-14 15:49:12 +0000
commit4524274377f0a9cb088fa9b16105cfb92e3c2d3c (patch)
tree8b23e267e7d0a9fee25a6e8e04cc4a07812a7b74 /progs
parent0bb281ba2184313eb211a230dc99697d0c064268 (diff)
exercise more vertex buffer object functions
Diffstat (limited to 'progs')
-rw-r--r--progs/tests/bufferobj.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/progs/tests/bufferobj.c b/progs/tests/bufferobj.c
index 9653f998d0..df7d57f8e0 100644
--- a/progs/tests/bufferobj.c
+++ b/progs/tests/bufferobj.c
@@ -159,12 +159,30 @@ static void SpecialKey( int key, int x, int y )
static void MakeObject1(struct object *obj)
{
GLfloat *v, *c;
+ void *p;
+ int i;
glGenBuffersARB(1, &obj->BufferID);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, 1000, NULL, GL_STATIC_DRAW_ARB);
v = (GLfloat *) glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
+ /* do some sanity tests */
+ glGetBufferPointervARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAP_POINTER_ARB, &p);
+ assert(p == v);
+
+ glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &i);
+ assert(i == 1000);
+
+ glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_ACCESS_ARB, &i);
+ assert(i == GL_WRITE_ONLY_ARB);
+
+ glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_USAGE_ARB, &i);
+ assert(i == GL_STATIC_DRAW_ARB);
+
+ glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAPPED_ARB, &i);
+ assert(i);
+
/* Make rectangle */
v[0] = -1; v[1] = -1; v[2] = 0;
v[3] = 1; v[4] = -1; v[5] = 0;
@@ -181,6 +199,12 @@ static void MakeObject1(struct object *obj)
obj->NumElements = 0;
glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
+
+ glGetBufferPointervARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAP_POINTER_ARB, &p);
+ assert(!p);
+
+ glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAPPED_ARB, &i);
+ assert(!i);
}
@@ -212,20 +236,18 @@ static void MakeObject2(struct object *obj)
static void MakeObject3(struct object *obj)
{
+ GLfloat vertexData[1000];
GLfloat *v, *c;
GLuint *i;
-
- glGenBuffersARB(1, &obj->BufferID);
- glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID);
- glBufferDataARB(GL_ARRAY_BUFFER_ARB, 1000, NULL, GL_STATIC_DRAW_ARB);
- v = (GLfloat *) glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
+ int bytes;
/* Make rectangle */
+ v = vertexData;
v[0] = -1; v[1] = -0.5; v[2] = 0;
v[3] = 1; v[4] = -0.5; v[5] = 0;
v[6] = 1; v[7] = 0.5; v[8] = 0;
v[9] = -1; v[10] = 0.5; v[11] = 0;
- c = v + 12;
+ c = vertexData + 12;
c[0] = 0; c[1] = 0; c[2] = 1;
c[3] = 0; c[4] = 0; c[5] = 1;
c[6] = 0; c[7] = 1; c[8] = 1;
@@ -234,7 +256,12 @@ static void MakeObject3(struct object *obj)
obj->VertexOffset = 0;
obj->ColorOffset = 3 * sizeof(GLfloat) * obj->NumVerts;
- glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
+ bytes = obj->NumVerts * (3 + 3) * sizeof(GLfloat);
+
+ /* Don't use glMap/UnmapBuffer for this object */
+ glGenBuffersARB(1, &obj->BufferID);
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID);
+ glBufferDataARB(GL_ARRAY_BUFFER_ARB, bytes, vertexData, GL_STATIC_DRAW_ARB);
/* Setup a buffer of indices to test the ELEMENTS path */
glGenBuffersARB(1, &obj->ElementsBufferID);