The Glinterleavedarrays function has three parameters: mode, Stride,pointer.
Mode: Indicates which vertex arrays are turned on and the data types used by the vertex array. The remaining vertex arrays are closed. There are 14 groups in total. Specifically, you can participate in the OPENGL Programming Guide 2.6.6 Mixed arrays section.
Stride: Indicates the interval between vertex data. Typically 0
Pointer: pointer, pointing to the vertex array data.
Using Glinterleavedarrays can improve the performance of your application. and the exact layout of the data is known, reducing the likelihood of errors. But Glinterleavedarrays is not a drawing function, so a function like gldrawarrays,gldrawelements must also be called after the call.
The following code:
Mixed arrays. cpp: The entry point that defines the console application. #include "stdafx.h" #include <gl/glut.h>void init () {glclearcolor (0,0,0,0);} void display () {glclear (gl_color_buffer_bit); Glfloat colverarray[] = {1,0,0,-0.5,0,0,0,1,0,0,0,0.5,0,0,1,0.2,0.8,0,};glinterleavedarrays (GL_C3F_V3F,0, Colverarray); Gldrawarrays (gl_triangle_strip,0,3); Glflush ();} int _tmain (int argc, _tchar* argv[]) {Glutinit (&ARGC, (char * *) argv); Glutinitwindowsize (500,500); Glutinitwindowposition (100,100); Glutcreatewindow ("Using mixed arrays"); init (); Glutdisplayfunc (display); Glutmainloop (); return 0;}
Run:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
See OpenGL Write code (7) using a mixed array (glinterleavedarrays)