glMultiDrawElements();
Alright, first of, I just bought the Red Book, and I am working my way though it steadily (albeit slowly). I am only one 6th of the way through it, and have stumbled to MultiDrawElements. now using the code from the book, I got a few errors which I could not find a solution too. However backtracking a bit, I accomplished the task using twho "glDrawElements()". For those of you who care, could you load up a new project following Keith's kind tutorial: http://onesadcookie.com/~keith/XcodeGLUT/
Then add this code to the main.c:
Hit Compile/Run, and you should get one warning and a small line down in the left hand corner at a 45°. Any ideas?
Then add this code to the main.c:
Code:
#include <stdlib.h>
#include <GLUT/glut.h>
#include <stdio.h>
void setupPointer(void)
{
static GLint vertices[] = {25, 25,
75, 75,
100, 125,
150, 75,
200, 175,
250, 150,
300, 125,
100, 200,
150, 250,
200, 225,
250, 300,
300, 250};
glEnableClientState (GL_VERTEX_ARRAY);
glVertexPointer (2, GL_INT, 0, vertices);
}
void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);
setupPointer ();
}
void display(void)
{
static GLubyte oneIndices[] = {0, 1, 2, 3, 4, 5, 6};
static GLubyte twoIndices[] = {1, 7, 8, 9, 10, 11};
static GLsizei count[] = {7, 6};
static GLvoid * indices[2] = {oneIndices, twoIndices};
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
glMultiDrawElements (GL_LINE_STRIP, count, GL_UNSIGNED_BYTE, indices, 2);
glFlush ();
}
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluOrtho2D (0.0, (GLdouble) w, 0.0, (GLdouble) h);
}
void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 27: // This is the ESC key
exit(0);
break;
}
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (350, 350);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}Hit Compile/Run, and you should get one warning and a small line down in the left hand corner at a 45°. Any ideas?
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Crash in glMultiDrawElements | Cochrane | 1 | 3,494 |
Aug 12, 2007 02:41 PM Last Post: OneSadCookie |
|

