Fix lighting
This commit is contained in:
parent
332475c340
commit
59002546e6
|
@ -105,8 +105,17 @@ void APIENTRY glLightfv(GLenum light, GLenum pname, const GLfloat *params) {
|
|||
case GL_SPECULAR:
|
||||
memcpy(LIGHTS[idx].specular, params, sizeof(GLfloat) * 4);
|
||||
break;
|
||||
case GL_POSITION:
|
||||
case GL_POSITION: {
|
||||
_matrixLoadModelView();
|
||||
memcpy(LIGHTS[idx].position, params, sizeof(GLfloat) * 4);
|
||||
|
||||
mat_trans_single4(
|
||||
LIGHTS[idx].position[0],
|
||||
LIGHTS[idx].position[1],
|
||||
LIGHTS[idx].position[2],
|
||||
LIGHTS[idx].position[3]
|
||||
);
|
||||
}
|
||||
break;
|
||||
case GL_CONSTANT_ATTENUATION:
|
||||
case GL_LINEAR_ATTENUATION:
|
||||
|
@ -252,7 +261,12 @@ void calculateLightingContribution(const GLint light, const GLfloat* pos, const
|
|||
GLfloat d;
|
||||
vec3f_length(L.x, L.y, L.z, d);
|
||||
|
||||
vec3f_normalize(L.x, L.y, L.z);
|
||||
GLfloat oneOverL = 1.0f / d;
|
||||
|
||||
L.x *= oneOverL;
|
||||
L.y *= oneOverL;
|
||||
L.z *= oneOverL;
|
||||
|
||||
vec3f_normalize(V.x, V.y, V.z);
|
||||
|
||||
GLfloat NdotL;
|
||||
|
|
|
@ -245,7 +245,6 @@ void DrawTexturedQuad(int tex, float x, float y, float z)
|
|||
glVertexPointer(3, GL_FLOAT, 0, vertex_data);
|
||||
glDrawArrays(GL_QUADS, 0, 4);
|
||||
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
|
@ -259,10 +258,10 @@ void DrawGLScene()
|
|||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
|
||||
glLoadIdentity(); // Reset The View
|
||||
//glTranslatef(-5.0f, -5.0f, -10.0f);
|
||||
glTranslatef(-50.0f, 0.0f, -200.0f);
|
||||
|
||||
GLfloat l1_pos[] = {50 + sin(delta) * 100.0f, 25.0, 1.0, 1.0};
|
||||
glTranslatef(-50.0f, 0.0f, -100.0f);
|
||||
|
||||
GLfloat l1_pos[] = {50 + sin(delta) * 100.0f, 6.0, 5.0, 1.0};
|
||||
delta += 0.03;
|
||||
|
||||
glLightfv(GL_LIGHT1, GL_POSITION, l1_pos);
|
||||
|
|
Loading…
Reference in New Issue
Block a user