See OpenGL Write code (7) using a mixed array (glinterleavedarrays)

Source: Internet
Author: User


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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.