O'Reilly logo

OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition by Bill M. Licea-Kane, John M. Kessenich, Graham Sellers, Dave Shreiner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required