I have been working on a game for a while now. Its time to give the world some light. I managed to get the light to work, but only in the same shader as the player. Do objects that dont use the player shader dont get any light. Can someone please help me figure out how I can have a light shader that will blend and work with the pther objects in the game. This is a 2D game, using C++ and opengl, custom engine.
Thanks in advance.
You will have to add the light code to the other objects shaders too.
But, if you have enough experience you could use a deferred renderer and only have a single lighting stage which only uses a single shader for all objects, a deferred renderer will also speed up your engine a lot!
If your ready? Check out https://learnopengl.com/#!Advanced-Lighting/Deferred-Shading
that depends on the program object (shaders) they use
why dont you use the same program object (shaders) for all objects ?
think of the program object (shaders) as a kind of pencil: they only draw the scene, WHAT they draw depends on the data they get as vertex attributes, if you want a circle, send the vertices for the circle, if you want a rectangle, send other vertices
glDrawArrays(…, A, B);
put all vertices for all type of shapes into the same buffer object and keep track of the vertex offset (A) and vertex count (B) for each shape, and if necessary keep track of the mode they use (just in case not all shapes use GL_TRIANGLES)