Lighting not appearing in OpenGL - c++

I've been trying to implement lighting for my OpenGL project, but so far I haven't been able to get any lighting effects.
I know that many things could go wrong, so I've tried hardcoding my normals (and using only a few triangles), but still I don't get anything.
In my scene, I have a few objects laying down along the "ground" at 0,0,0, hoping to see light coming down from above on them. They have a very basic texture on them which would easily show if they were lit up or not.
I initialize my scene like this:
glEnable(GL_CULL_FACE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glShadeModel(GL_SMOOTH);
glEnable(GL_COLOR_MATERIAL);
glTranslatef(0,0,0);
GLfloat ambientLight[] = { 0.2f, 0.2f, 0.2f, 0.2f };
GLfloat diffuseLight[] = { 0.8f, 0.8f, 0.8, 1.0f };
GLfloat specularLight[] = { 0.5f, 0.5f, 0.5f, 1.0f };
GLfloat position[] = {0, 100.0f, 0, 1.0f };
glLightModelfv(GL_AMBIENT, ambientLight);
glLightModelfv(GL_DIFFUSE, ambientLight);
glLightModelfv(GL_SPECULAR, specularLight);
glLightModelfv(GL_POSITION, position);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);
glLightfv(GL_LIGHT0, GL_POSITION, position);
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
GLfloat shine [] = {50};
GLfloat diffuse[] = {1.0f, 0.f, 0.f, 1.0f};
GLfloat spec[] = {1.0f, 0.f, 0.f, 1.0f};
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE,diffuse);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR,spec);
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS,shine);
And when I go to render:
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, tiles[x]->image.width(), tiles[x]->image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, tiles[x]->image.bits());
glNormal3d(0,1,0); //Will eventually calculate
glDrawArrays(GL_TRIANGLES, 0, 3);
glDrawArrays(GL_TRIANGLES, 3, 3);
"Tiles" is just a class of mine that holds an image and corresponding vectors for my objects. The "vertices" that are called is just a list of vectors (so each object has 6 vectors = 2 triangles.
My fragment shader:
uniform sampler2D texture;
in vec4 gl_Color;
in vec2 varyingTextureCoordinate;
out vec4 fragColor;
void main(void)
{
fragColor = texture2D(texture, varyingTextureCoordinate);
}
And my vertex shader:
uniform mat4 mvpMatrix;
in vec4 vertex;
in vec2 textureCoordinate;
out vec2 varyingTextureCoordinate;
void main(void)
{
varyingTextureCoordinate = textureCoordinate;
gl_Position = mvpMatrix * vertex;
}
Is my lack of lighting due to a conflict with the texture? No matter how I change that normal, I don't get any lighting.

I think you're trying to combine pre-programmable shader opengl and shader open gl here. I recommend learning how to implement lighting by utilizing as much shader code as possible
BennyBox has a great youtube series on OpenGL covering shaders and engine design
Here is his git repo and the java version.

Related

can't see lighting in openGL

I'm new to openGL and I drew a cube, then I place a camera inside the cube.
What I'm trying to achieve now is lighting the cube.
This is how I tried:
void draw(GLFWwindow* window)
{
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
// Create light components
GLfloat ambientLight[] = { 0.2f, 0.2f, 0.2f, 1.0f };
GLfloat diffuseLight[] = { 0.8f, 0.8f, 0.8, 1.0f };
GLfloat specularLight[] = { 0.5f, 0.5f, 0.5f, 1.0f };
GLfloat position[] = { -1.5f, 1.0f, -1.0f, 1.0f };
// Assign created components to GL_LIGHT0
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);
glLightfv(GL_LIGHT0, GL_POSITION, position);
int width, height;
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glm::mat4 projection = glm::perspective(PI / 4, 1.f / 1.f, 1.0f, 10.0f);
glm::mat4 view = glm::lookAt(glm::vec3(0.0f, 0.0f, -1.3f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
glm::mat4 model = glm::rotate(glm::mat4(1.f), PI, glm::vec3(0.0f, 1.0f, 0.0f));
....
....
}
But I don't see any lightings
But I don't see any lightings
Welcome to the world of the old-and-busted fixed function pipeline. You're using OpenGL as it was done 20 years ago. The mode of illumination you're using is doing the lighting calculations only at the vertex locations and then simply blends the resulting color over the triangles (or quads). Obviously that won't work if there's a lot of change in illumination over the span of a single triangle.
In your case the light source is very close to your cube, so that's not going to work. You should address this by ditching the fixed function pipeline (FFP) and use shaders. Seriously, the FFP has been out of fashion for some 13 years (first GLSL capable GPUs arrived on the market in 2003). FFP has been emulated with shaders created in-situ ever since.
Also (judging from your other questions related to drawing a cube) you don't supply face normals. Normals are essential to doing illumination calculations, so you'll have to supply those as well.

GL_TEXTURE_2D making problems for lighting?

I wanted to ask you about texture and lighting.
I am using a 3ds Object in OpenGL, and a BITMAP texture. It is working perfectly. When I use lighting it didn't reflect the light. While I was searching I just commented the line: glEnable(GL_TEXTURE_2D); and the Texture was gone but lighting works!
Is there any opportunity that I can leave TEXTURE and also add lighting? Why is this happening? Anyone any idea?
EDITED
this is in INIT() function
void initialize(){
glEnable(GL_DEPTH_TEST); // We enable the depth test (also called z buffer)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // Polygon rasterization mode (polygon filled)
glEnable(GL_TEXTURE_2D); // This Enable the Texture mapping
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
// Light model parameters:
// -------------------------------------------
GLfloat lmKa[] = {0.0, 0.0, 0.0, 0.0 };
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmKa);
glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, 1.0);
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, 0.0);
// -------------------------------------------
// Spotlight Attenuation
GLfloat spot_direction[] = {1.0, -1.0, -1.0 };
GLint spot_exponent = 30;
GLint spot_cutoff = 180;
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spot_direction);
glLighti(GL_LIGHT0, GL_SPOT_EXPONENT, spot_exponent);
glLighti(GL_LIGHT0, GL_SPOT_CUTOFF, spot_cutoff);
GLfloat Kc = 1.0;
GLfloat Kl = 0.0;
GLfloat Kq = 0.0;
glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION,Kc);
glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, Kl);
glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, Kq);
// -------------------------------------------
// Lighting parameters:
GLfloat light_pos[] = {0.0f, 5.0f, 5.0f, 1.0f};
GLfloat light_Ka[] = {1.0f, 0.5f, 0.5f, 1.0f};
GLfloat light_Kd[] = {1.0f, 0.1f, 0.1f, 1.0f};
GLfloat light_Ks[] = {1.0f, 1.0f, 1.0f, 1.0f};
glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
glLightfv(GL_LIGHT0, GL_AMBIENT, light_Ka);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_Kd);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_Ks);
// -------------------------------------------
// Material parameters:
GLfloat material_Ka[] = {0.5f, 0.0f, 0.0f, 1.0f};
GLfloat material_Kd[] = {0.4f, 0.4f, 0.5f, 1.0f};
GLfloat material_Ks[] = {0.8f, 0.8f, 0.0f, 1.0f};
GLfloat material_Ke[] = {0.1f, 0.0f, 0.0f, 0.0f};
GLfloat material_Se = 20.0f;
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, material_Ka);
glMaterialfv(GL_FRONT, GL_DIFFUSE, material_Kd);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, material_Ks);
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, material_Ke);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material_Se);
}
this is the DISPLAY() function (I am using QT)
void pointGL(){
if(change)
{
ThreeDModels objectClass;
objectClass.SpaceShip();
change = false;
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glPushMatrix();
glScalef(0.05, 0.05, 0.05);
ThreeDModels objectiModel;
objectiModel.objectCreation(l_index);
glPopMatrix();
}
Method which other method for Loading 3ds object and add Texture
void ThreeDModels::SpaceShip()
{
Load3DS(&objecti, "C:/Users/Documents/3DModelRendering/3DModels/Spaceship/spaceship.3ds");
int a = LoadBitmap2("C:/Users/Documents/3DModelRendering/3DModels/Spaceship/spaceshiptexture.bmp");
}
void ThreeDModels::objectCreation(int l_index)
{
glBegin(GL_TRIANGLES); // glBegin and glEnd delimit the vertices that define a primitive (in our case triangles)
for (l_index = 0; l_index<objecti.polygons_qty; l_index++)
{
//----------------- FIRST VERTEX -----------------
// Texture coordinates of the first vertex
glTexCoord2f(objecti.mapcoord[objecti.polygon[l_index].a].u,
objecti.mapcoord[objecti.polygon[l_index].a].v);
// Coordinates of the first vertex
glVertex3f(objecti.vertex[objecti.polygon[l_index].a].x,
objecti.vertex[objecti.polygon[l_index].a].y,
objecti.vertex[objecti.polygon[l_index].a].z); //Vertex definition
//----------------- SECOND VERTEX -----------------
// Texture coordinates of the second vertex
glTexCoord2f(objecti.mapcoord[objecti.polygon[l_index].b].u,
objecti.mapcoord[objecti.polygon[l_index].b].v);
// Coordinates of the second vertex
glVertex3f(objecti.vertex[objecti.polygon[l_index].b].x,
objecti.vertex[objecti.polygon[l_index].b].y,
objecti.vertex[objecti.polygon[l_index].b].z);
//----------------- THIRD VERTEX -----------------
// Texture coordinates of the third vertex
glTexCoord2f(objecti.mapcoord[objecti.polygon[l_index].c].u,
objecti.mapcoord[objecti.polygon[l_index].c].v);
// Coordinates of the Third vertex
glVertex3f(objecti.vertex[objecti.polygon[l_index].c].x,
objecti.vertex[objecti.polygon[l_index].c].y,
objecti.vertex[objecti.polygon[l_index].c].z);
}
glEnd();
}
I found the Answer guys:
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); was in the LoadBitmap() method, just removing this one, and it worked ;D

OpenGL Lighting Not Shading

I'm attempting too add basic lighting to my scene. So far even without GLSL. It appears that my lighting doesn't work. And what I mean by that is everything has no shade at all (everything is lit up).
I know the picture isn't the best, but thats partly because of the texture is shaded in the image.
Here is my init code:
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Clear to black with full alpha
glEnable(GL_DEPTH_TEST); // Enable depth testing
glDepthFunc(GL_LEQUAL); // Specify depth testing function
glClearDepth(1.0); // Clear the full extent of the depth buffer (default)
glEnable(GL_CULL_FACE); // Enable face culling
glCullFace(GL_BACK); // Cull back faces of polygons
glFrontFace(GL_CCW);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glShadeModel(GL_SMOOTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColorMaterial ( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
glEnable ( GL_COLOR_MATERIAL );
GLfloat ambientLight[] = { 0.2f, 0.2f, 0.2f, 0.2f };
GLfloat diffuseLight[] = { 0.8f, 0.8f, 0.8, 1.0f };
GLfloat specularLight[] = { 0.5f, 0.5f, 0.5f, 1.0f };
GLfloat position[] = {0, 100.0f, 0, 1.0f };
glLightModelfv(GL_AMBIENT, ambientLight);
glLightModelfv(GL_DIFFUSE, ambientLight);
glLightModelfv(GL_SPECULAR, specularLight);
glLightModelfv(GL_POSITION, position);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);
glLightfv(GL_LIGHT0, GL_POSITION, position);
Draw code:
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glEnable(GL_NORMALIZE);
//For loop of the lights...
glLightfv(GL_LIGHT0+m_lights.at(i)->id, GL_POSITION, glm_to_array(m_lights.at(i)->position));
glEnable(GL_LIGHT0+m_lights.at(i)->id);
//Draw geometry here...
And yes, I am retrieving the normals from the mesh file and inserting the glNormal3f of every face. (GL_TRIANGLES) And even the plane the model sits on never gets affected even if I completely change the normal to random values.
Plane Example:
if(m_shader_programme){
glUseProgram(m_shader_programme);
}
if(m_texture_id){
glBindTexture(GL_TEXTURE_2D, m_texture_id);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
}
glBegin(GL_TRIANGLES);
glNormal3f(0.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, m_sizey/10);
glVertex3f(m_sizex, m_height, m_sizey);
glTexCoord2f(m_sizex/10, m_sizey/10);
glVertex3f(m_sizex, m_height, -m_sizey);
glTexCoord2f(m_sizex/10, 0.0f);
glVertex3f(-m_sizex, m_height, -m_sizey);
glNormal3f(0.0f, 1.0f, 0.0f);
glTexCoord2f(m_sizex/10, 0.0f);
glVertex3f(-m_sizex, m_height, -m_sizey);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-m_sizex, m_height, m_sizey);
glTexCoord2f(0.0f, m_sizey/10);
glVertex3f(m_sizex, m_height, m_sizey);
glEnd();
if(m_shader_programme){
glUseProgram(0);
}
if(m_texture_id){
glBindTexture(GL_TEXTURE_2D, 0);
}
GLSL Fragment Shader:
#version 120
uniform sampler2D tex;
void main()
{
vec4 color = texture2D(tex,gl_TexCoord[0].st);
gl_FragColor = color;
}
Vertex Shader:
#version 120
void main() {
vec3 normal, lightDir;
vec4 diffuse, ambient, globalAmbient;
float NdotL;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
normal = normalize(gl_NormalMatrix * gl_Normal);
lightDir = normalize(vec3(gl_LightSource[0].position));
NdotL = max(dot(normal, lightDir), 0.0);
diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;
/* Compute the ambient and globalAmbient terms */
ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
globalAmbient = gl_LightModel.ambient * gl_FrontMaterial.ambient;
gl_FrontColor = NdotL * diffuse + globalAmbient + ambient;
gl_Position = ftransform();
}
System Specs
OS X (Yosemite) 10.10.13 (64bit)
Renderer: NVIDIA GeForce GTX 780M
OpenGL Engine OpenGL version supported 2.1 NVIDIA-10.2.7 310.41.25f01
Just encase anyone is wondering why I'm not using OpenGL 3.x is because GL 3.x doesn't appear to play nice on my machine.
Your fragment shader:
vec4 color = texture2D(tex,gl_TexCoord[0].st);
gl_FragColor = color;
Simply discards all the computations you did in the vertex shader and samples the texture color. You need to multiply the texture sample by the interpolated color value:
vec4 color = texture2D(tex, gl_TexCoord[0].st) * gl_Color;
^~~~~~
gl_FragColor = color;

OpenGL - Smooth rendering doesn't work

here is my Setup() function:
void Setup() // TOUCH IT !!
{
glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
glEnable(GL_COLOR_MATERIAL);
//Parameter handling
glShadeModel (GL_SMOOTH);
//glEnable(GL_NORMALIZE);
glDepthFunc(GL_LEQUAL); //renders a fragment if its z value is less or equal of the stored value
glClearDepth(1);
//Set up light source
GLfloat light_position[] = { 20.0, 0.0, 0.0, 0.0 };
GLfloat ambientLight[] = { 0.3, 0.3, 0.3, 1.0 };
GLfloat diffuseLight[] = { 0.8f, 0.8f, 0.8f, 1.0 };
glLightfv( GL_LIGHT0, GL_POSITION, light_position);
glLightfv( GL_LIGHT0, GL_AMBIENT, ambientLight );
glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuseLight );
glEnable(GL_LIGHT0);
// polygon rendering mode
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glEnable(GL_CULL_FACE);
glFrontFace(GL_CCW);
glColorMaterial( GL_FRONT, GL_EMISSION );
// material identities
float specReflection[] = { 1.0f, 1.0f, 1.0f, 1.0f };
float ambReflection[] = { 1.0f, 1.0f, 1.0f, 1.0f };
float diffReflection[] = { 1.0f, 1.0f, 1.0f, 1.0f };
glMaterialfv(GL_FRONT, GL_SPECULAR, specReflection);
glMaterialfv(GL_FRONT, GL_AMBIENT, ambReflection);
glMaterialfv(GL_FRONT, GL_DIFFUSE, diffReflection);
glMateriali(GL_FRONT,GL_SHININESS,20);
//// about texture
//glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
// Black background
glClearColor(0.0f,0.0f,0.0f,1.0f);
}
here is my CalcNormal() function, where normals are being calculated. v1 and v2 are two vectors of a triangle:
Point CalcNormal(Point v1, Point v2)
{
Point normal;
normal.x = v1.y*v2.z - v1.z*v2.y;
normal.y = -v1.x*v2.z + v2.x*v1.z;
normal.z = v1.x*v2.y - v2.x*v1.y;
float dist1 = sqrt( pow(v1.x,2) + pow(v1.y,2) + pow(v1.z,2));
float dist2 = sqrt( pow(v2.x,2) + pow(v2.y,2) + pow(v2.z,2));
float dist = dist1*dist2;
normal.x = normal.x/dist;
normal.y = normal.y/dist;
normal.z = normal.z/dist;
return normal;
}
here is the vectors i send to CalcNormal():
Point n;
Point a1, a2;
a1.x=triangles.at(i).p2.x-triangles.at(i).p1.x; a1.y=triangles.at(i).p2.y-triangles.at(i).p1.y; a1.z=triangles.at(i).p2.z-triangles.at(i).p1.z;
a2.x=triangles.at(i).p3.x-triangles.at(i).p1.x; a2.y=triangles.at(i).p3.y-triangles.at(i).p1.y; a2.z=triangles.at(i).p3.z-triangles.at(i).p1.z;
n = CalcNormal(a1, a2);
and the result is like this:
rendering result
For smooth shading to be effective, you also need smooth normals - per vertex. The code you have posted so far shown only per-triangle normal calculations. In that case, the result will still look flat.
The easiest way to get smooth normals is, after you have calculated a normal per triangle, to average all normals of the adjacent triangles of each vertex. More complex schemes use a weighted average based on some function of the area of the triangles. There are also some heuristics whcih try to conserve hard edges, but as it is always the case with heuristics, there will always be some corner cases. Ideally, the normals are created when the model is created and stored in the file.

Can I use fixed glEnable(GL_LIGHTING) alongside fragment/vertex shaders?

I have browsed many online articles and adding lighting seems very straight forward but I'm not able to get a result. I'm using OpenGL 3.0 and I use a vertex and fragment shaders for my animating model. Btw, I'm new to OpenGL.
Disregarding the lighting I have everything working fine with the 3D char running around the environment.
glEnable(GL_DEPTH_TEST);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
*snip*
glEnable(GL_LIGHTING);
glEnable (GL_LIGHT0);
float ambientLight0[] = { 0.2f, 0.2f, 0.2f, 1.0f };
float diffuseLight0[] = { 0.8f, 0.8f, 0.8f, 1.0f };
float specularLight0[] = { 0.5f, 0.5f, 0.5f, 1.0f };
float position0[] = { -2.5f, 1.0f, -1.0f, 1.0f };
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight0);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight0);
glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight0);
glLightfv(GL_LIGHT0, GL_POSITION, position0);
//glEnable(GL_COLOR_MATERIAL);
//float mcolor[] = { 1.0f, 0.0f, 0.0f, 1.0f };
//glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mcolor);
m_Beast.onRender();
Here's how m_Beast.onRender() looks:
glPushMatrix();
Vector3 pos = getPosition();
glTranslatef(pos.x, pos.y, pos.z);
glBindTexture(GL_TEXTURE_2D, m_beastTextureID);
static float modelviewMatrix[16];
static float projectionMatrix[16];
glGetFloatv(GL_MODELVIEW_MATRIX, modelviewMatrix);
glGetFloatv(GL_PROJECTION_MATRIX, projectionMatrix);
m_shaderProgram->bindShader();
m_shaderProgram->sendUniform4x4("modelview_matrix", modelviewMatrix);
m_shaderProgram->sendUniform4x4("projection_matrix", projectionMatrix);
m_shaderProgram->sendUniformTexture("texture0", 0);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer);
glVertexAttribPointer((GLint)0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, m_texCoordBuffer);
glVertexAttribPointer((GLint)1, 2, GL_FLOAT, GL_FALSE, 0, 0);
glDrawArrays(GL_TRIANGLES, 0, m_interpolatedFrame.vertices.size());
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(0);
glPopMatrix();
I just want a quick way to get some directional lighting on my model. I'm really not interesting in writing a lighting shader at this point.
As soon as you use vertex shaders, you must implement the lighting calculations yourself. In older OpenGL one could still use the fixed function vertex pipeline and program only the fragment stage. But with OpenGL-3 and onwards you're required to do it all.
However you shouldn't feel too bad about this. In the end you'll write less, because the huge plethora of function calls required to configure fixed function, can be replaced by much shorter and concise shader code.