// Test case for Ubuntu bug #450901 (xserver-xorg-video-intel) // Written by Camilla Berglund // // Triggers the problem when using glDrawElements on (at least one) GMA965 with // Karmic amd64 and all packages up-to-date as of Sun Nov 1 01:39:14 UTC 2009 // // Works as expected on (at least one) GMA915 with Jaunty x86 equally up-to-date // // Unusual dependencies: libglfw-dev libglew-dev // Build using: gcc -o ibo ibo.c -lGLEW `pkg-config --libs libglfw` #include #include #include #include typedef struct { GLfloat x; GLfloat y; } Vertex; // One 1x1 CCW quad static Vertex vertices[] = { { -0.5f, -0.5f }, { 0.5f, -0.5f }, { 0.5f, 0.5f }, { -0.5f, 0.5f }, }; // Two CCW triangles static GLuint indices[] = { 0, 1, 2, 0, 2, 3, }; static void GLFWCALL window_size_callback(int width, int height) { glViewport(0, 0, width, height); } int main(void) { GLuint vbuf, ibuf; if (!glfwInit()) { fprintf(stderr, "Failed to initialize GLFW\n"); exit(EXIT_FAILURE); } if (!glfwOpenWindow(640, 480, 8, 8, 8, 0, 0, 0, GLFW_WINDOW)) { fprintf(stderr, "Failed to initialize GLFW\n"); glfwTerminate(); exit(EXIT_FAILURE); } glfwSetWindowSizeCallback(window_size_callback); glfwSetWindowTitle("Press Space for bug"); glfwSwapInterval(1); if (glewInit() != GLEW_OK) { fprintf(stderr, "Failed to initialize GLEW\n"); glfwTerminate(); exit(EXIT_FAILURE); } glGenBuffersARB(1, &vbuf); glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbuf); glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(vertices), vertices, GL_STATIC_DRAW_ARB); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, NULL); glGenBuffersARB(1, &ibuf); glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ibuf); glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, sizeof(indices), indices, GL_STATIC_DRAW_ARB); glMatrixMode(GL_PROJECTION); glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f); glMatrixMode(GL_MODELVIEW); glColor3f(1.f, 0.f, 0.f); do { glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); glRotatef(glfwGetTime() * 100.f, 0.f, 0.f, 1.f); if (glfwGetKey(GLFW_KEY_SPACE) == GLFW_PRESS) glDrawElements(GL_TRIANGLES, sizeof(indices) / sizeof(GLuint), GL_UNSIGNED_INT, NULL); else glDrawArrays(GL_TRIANGLE_FAN, 0, sizeof(vertices) / sizeof(Vertex)); glfwSwapBuffers(); } while (glfwGetWindowParam(GLFW_OPENED)); glfwTerminate(); exit(EXIT_SUCCESS); }