I'm trying to learn the modern, full programmable OpenGL using LWJGL. At the moment I know how to parse files for models, use them in VBOs and draw them to the screen. I also have a first-person style camera that lets me freely move around and look at whatever I want.
Is glLight completely out of date? All lighting should be done with shaders, right?
I know how to apply shaders to models, is there a way to create a fragment shader that acts on everything? Is that the modern approach to light?
My render code for models looks like this:
glPushMatrix(); glRotatef(rotation, rx, ry, rz); glTranslatef(x, y, z); glScalef(sx, sy, sz); glBindBuffer(GL_ARRAY_BUFFER, vbos); glVertexPointer(3, GL_FLOAT, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, vbos); glNormalPointer(GL_FLOAT, 0, 0L); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glUseProgram(shaderProgram); glColor4f(r, g, b, 1f); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 10f); glDrawArrays(GL_TRIANGLES, 0, model.getFaces().size() * 3); glUseProgram(0); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glBindBuffer(GL_ARRAY_BUFFER, 0); glPopMatrix();
Am I enabling and disabling the shader program at the correct times? Are glColor4f and glMaterialf worthless if shaders are used properly? Am I pushing and popping the matrix at the right time?
Thanks! I've read a lot but even with my Linear Algebra experience a lot of the math is hard to visualize.