- immediate mode
- The easiest way to do drawing in OpenGL is using the Immediate Mode. For this, you use the glBegin() function which takes as one parameter the “mode” or type of object you want to draw.
glBegin(GL_LINE_LOOP);//start drawing a line loop
glVertex3f(-1.0f,0.0f,0.0f);//left of window
glVertex3f(0.0f,-1.0f,0.0f);//bottom of window
glVertex3f(1.0f,0.0f,0.0f);//right of window
glVertex3f(0.0f,1.0f,0.0f);//top of window
glEnd();//end drawing of line loop- display list
- Display list is a group of OpenGL commands that have been stored (compiled) for later execution. Once a display list is created, all vertex and pixel data are evaluated and copied into the display list memory on the server machine. It is only one time process. After the display list has been prepared (compiled), you can reuse it repeatedly without re-evaluating and re-transmitting data over and over again to draw each frame.
// create one display list
GLuint index = glGenLists(1);
// compile the display list, store a triangle in it
glNewList(index, GL_COMPILE);
glBegin(GL_TRIANGLES);
glVertex3fv(v0);
glVertex3fv(v1);
glVertex3fv(v2);
glEnd();
glEndList();
...
// draw the display list
glCallList(index);- vertex array
- This means that your vertices and vertex attributes and indices are in RAM.
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(3, GL_FLOAT, 0, Colors);
glVertexPointer(3, GL_FLOAT, 0, Vertices);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
2013年3月11日 星期一
immediate mode? display list? vertex array?
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言