Attached is a test program that renders an indexed GL_LINES primitive using both glDrawElements and glDrawRangeElements (selected by pressing the 'v' key). There seems to be a problem with glDrawRangeElements when the (min, max) range is (0, 1) and I am only drawing one line. If I increase the max range it seems to have no problem (even though I am still only rendering the first line. scott P.S. Happy New Year everyone. -- Scott McMillan mailto:[EMAIL PROTECTED] Cambridge Research Associates http://www.cambridge.com 1430 Spring Hill Road, Ste. 200 Voice: (703) 790-0505 x7235 McLean, VA 22102 Fax: (703) 790-0370
#include <GL/gl.h> #include <GL/glu.h> #include <GL/glut.h> #include <stdio.h> #include <stdlib.h> int vertex_arrays_flag = 1; GLfloat vertices[8][3] = {{-3, 1, -10}, {-3,-1, -10}, {-1, 1, -10}, {-1,-1, -10}, { 1, 1, -10}, { 1,-1, -10}, { 3, 1, -10}, { 3,-1, -10}}; unsigned int indices[8] = {0,1,2,3,4,5,6,7}; void init(void) { glClearColor(0.0, 0.0, 0.0, 0.0); glPolygonMode(GL_FRONT, GL_LINE); } float num = 3.0; void display(void) { int i; glClear(GL_COLOR_BUFFER_BIT); if (vertex_arrays_flag == 1) { glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, vertices); glDrawRangeElements(GL_LINES, 0, 1, /* HERE: Change this to 7 and things work */ 2, GL_UNSIGNED_INT, indices); glDisableClientState(GL_VERTEX_ARRAY); } else { glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, vertices); glDrawElements(GL_LINES, 2, GL_UNSIGNED_INT, indices); glDisableClientState(GL_VERTEX_ARRAY); } glutSwapBuffers(); } void reshape(int w, int h) { glViewport(0, 0, (GLsizei)w, (GLsizei)h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, (GLfloat)w/(GLfloat)h, 1.0, 100.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: exit(0); break; case 'v': vertex_arrays_flag = 1 - vertex_arrays_flag; fprintf(stderr, "Using glDrawRangeElements: %d\n", vertex_arrays_flag); break; } } int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); glutInitWindowSize(500,500); glutInitWindowPosition(50,50); glutCreateWindow(argv[0]); init(); glutDisplayFunc(display); glutIdleFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; }