Reputation: 2210
I am completely new to OpenGL and graphics programming in general and so I quickly picked up the OpenGL Red Book. I have just started reading but I can't understand the following piece of code. This probably has something to do with me not being very familiar with the C++ enums, but how can we use NumVAOs and NumBuffers when declaring the GLuint arrays? Doesn't this make two 1 element arrays? Is there any reason that they are declared like this?
Here is the code:
#include <iostream>
using namespace std;
#include "vgl.h"
#include "LoadShaders.h"
enum VAO_IDs { Triangles, NumVAOs };
enum Buffer_IDs { ArrayBuffer, NumBuffers };
enum Attrib_IDs { vPosition = 0 };
GLuint VAOs[NumVAOs];
GLuint Buffers[NumBuffers];
const GLuint NumVertices = 6;
Upvotes: 0
Views: 176
Reputation: 22043
The idea behind this is that taking for example
enum VAO_IDs { Triangles, NumVAOs };
That when you need more VAOs you add the id's for them before NumVAOs which will cause NumVAOs to always have as a value the number of VAO's you are using.
Thought I do not see why you would want to structure your code this way but maybe that becomes clear later in the book.
Upvotes: 1