OpenGL – why is GL_ELEMENT_ARRAY_BUFFER for indices?

GL_ELEMENT_ARRAY_BUFFER is used to indicate the buffer you’re presenting contains the indices of each element in the “other” (GL_ARRAY_BUFFER) buffer. So, as a very basic example with vertices only (no other data), if you have an index buffer: {0, 1, 2} {0, 2, 3} and the data buffer contains: {{0, 0, 0}, {1, 0, 0}, {1, … Read more

What is the difference between FreeGLUT vs GLFW?

FreeGLUT: Based on the GLUT API. GLUT has been around for about as long as OpenGL itself. Many tutorials and examples out there use GLUT. Takes care of implementing the event loop and works through callbacks (good for simple stuff, makes things like precisely timed animation loops and low latency input much harder though). GLFW: … Read more

How to solve stbi_load error of “no SOI”?

I’m loading a picuture by stbi_load, but there was an error of no SOI. I had used the picture in another project and it was loaded successfully. So I think the path of picture and the picuture is valid. But I don’t know why the error occured? Here are some of the main code: I use loadTextureFromFile(“./Data/awesomeface.png”, GL_TRUE); to … Read more

What does it mean to normalize a value?

It’s a mathematical term and this link explains its meaning in quite simple terms: Operations in 2D and 3D computer graphics are often performed using copies of vectors that have been normalized ie. converted to unit vectors… Normalizing a vector involves two steps: calculate its length, then, divide each of its (xy or xyz) components by its length…

understanding glVertexAttribPointer?

@datenwolf already covered the key aspect in a comment above. To elaborate some more: You do not have to bind GL_ARRAY_BUFFER again before the glDrawElements() call. What matters is that the buffer you want to source a given attribute from is bound when you make the glVertexAttribPointer() call for that attribute. The best way to picture this is that when you make this … Read more