PDA

View Full Version : Drawing Two Cubes with same VBO and separate VAOs



OneCleverGorilla
05-29-2017, 02:27 PM
So I'm following along with the LearnOpenGL (https://learnopengl.com/#!Lighting/Colors) tutorial and I'm running into an issue with drawing two cubes, one of which represents light source (for demonstration purposes I suppose). My problem may lie in my misunderstanding of lighting in OpenGL and how it relates to VAOs, but I'm able to draw my target cube (which will illustrate the various lighting parameters) but I can't seem to get my "light source cube" to draw. Both cubes use the same VBO since they're the same shape but separate VAOs. Does one of these VAOs strictly define the light source or does it define the "light source cube"? Or both? And the strange thing is if I change the color of the light source cube itself, my light color also changes even though I have a separate fragment shader for the light source set at white light. I'm able to tell my light color is changing since my target object color is also changing (for example if I change my light source cube color to (1.0, 0.0, 0.0) then the target cube will appear more red than the color I define it (1.0, 0.5, 0.31). Source found in this Github link (https://github.com/tjmann95/OpenGL-Learning).

I really appreciate any advice!