#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include <GL/glut.h>
static int Width = 400;
unsigned stride;
};
-#define NUM_MODES 14
+#define NUM_MODES 14
+#define INVALID_MODE 14
+#define INVALID_STRIDE 15
struct interleave_info info[ NUM_MODES ][4] = {
{ NONE, NONE, NONE, V2F },
"GL_T4F_C4F_N3F_V4F",
};
-unsigned interleave_mode = 0;
+static unsigned interleave_mode = 0;
+static GLboolean use_invalid_mode = GL_FALSE;
+static GLboolean use_invalid_stride = GL_FALSE;
#define DEREF(item,idx) (void *) & ((char *)curr_info[item].data)[idx * curr_info[item].stride]
unsigned i;
unsigned offset;
+ GLenum err;
+ GLenum format;
+ GLsizei stride;
glClearColor(0.2, 0.2, 0.8, 0);
glTranslatef(3.0, 0, 0);
- glInterleavedArrays( GL_V2F + interleave_mode, 0, data );
- glDrawArrays( GL_TRIANGLES, 0, 12 );
+
+ format = (use_invalid_mode)
+ ? (rand() & ~0x2A00) : GL_V2F + interleave_mode;
+ stride = (use_invalid_stride) ? -abs(rand()) : 0;
+
+ (void) glGetError();
+ glInterleavedArrays( format, 0, data );
+ err = glGetError();
+ if ( err ) {
+ printf("glInterleavedArrays(0x%04x, %d, %p) generated the error 0x%04x\n",
+ format, stride, data, err );
+ }
+ else {
+ glDrawArrays( GL_TRIANGLES, 0, 12 );
+ }
glPopMatrix();
static void ModeMenu( int entry )
{
- interleave_mode = entry;
+ if ( entry == INVALID_MODE ) {
+ use_invalid_mode = GL_TRUE;
+ use_invalid_stride = GL_FALSE;
+ }
+ else if ( entry == INVALID_STRIDE ) {
+ use_invalid_mode = GL_FALSE;
+ use_invalid_stride = GL_TRUE;
+ }
+ else {
+ use_invalid_mode = GL_FALSE;
+ use_invalid_stride = GL_FALSE;
+ interleave_mode = entry;
+ }
}
static void Init( void )
{
unsigned i;
+ srand( time( NULL ) );
+
glutInit( &argc, argv );
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( Width, Height );
glutAddMenuEntry( mode_names[i], i);
}
+ glutAddMenuEntry( "Random invalid mode", INVALID_MODE);
+ glutAddMenuEntry( "Random invalid stride", INVALID_STRIDE);
+
glutAttachMenu(GLUT_RIGHT_BUTTON);
Init();