OpenGL Initialization

The next routine that we need to discuss is init() from Example 1.1. Once again, here’s the code to refresh your memory.

void init(void){    glGenVertexArrays(NumVAOs, VAOs);    glBindVertexArray(VAOs[Triangles]);    GLfloat  vertices[NumVertices][2] = {        { -0.90, -0.90 },  // Triangle 1        {  0.85, -0.90 },        { -0.90,  0.85 },        {  0.90, -0.85 },  // Triangle 2        {  0.90,  0.90 },        { -0.85,  0.90 }    };    glGenBuffers(NumBuffers, Buffers);    glBindBuffer(GL_ARRAY_BUFFER, Buffers[ArrayBuffer]);    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices),                 vertices, GL_STATIC_DRAW);    ShaderInfo  shaders[] = {       { GL_VERTEX_SHADER, "triangles.vert" ...

Get OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.