|
|
@ -79,13 +79,15 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
|
gpuProgram.DetectUniform("U_DiffuseLightColor"); |
|
|
|
gpuProgram.DetectUniform("U_DiffuseMaterial"); |
|
|
|
gpuProgram.DetectUniform("U_LightPos"); |
|
|
|
gpuProgram.DetectUniform("U_LightDirection"); |
|
|
|
gpuProgram.DetectUniform("U_Cutoff"); |
|
|
|
gpuProgram.DetectUniform("U_SpecularLightColor"); |
|
|
|
gpuProgram.DetectUniform("U_SpecularMaterial"); |
|
|
|
gpuProgram.DetectUniform("U_EyePos"); |
|
|
|
|
|
|
|
//init 3d model
|
|
|
|
ObjModel model; |
|
|
|
model.Init("res/model/Sphere.obj"); |
|
|
|
model.Init("res/model/Quad.obj"); |
|
|
|
|
|
|
|
float identity[] = { |
|
|
|
1.0f,0,0,0, |
|
|
@ -97,12 +99,14 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
|
float ambientMaterial[] = { 0.2f,0.2f,0.2f,1.0f }; |
|
|
|
float diffuseLightColor[] = { 1.0f,1.0f,1.0f,1.0f }; |
|
|
|
float diffuseMaterial[] = { 0.6f,0.6f,0.6f,1.0f }; |
|
|
|
float lightPos[] = {3.0f,3.0f,0.0f,1.0f}; |
|
|
|
float lightPos[] = {0.0f,1.5f,-3.0f,1.0f}; |
|
|
|
float spotLightDirection[] = {0.0f, -1.0f, 0.0f, 1.0f}; |
|
|
|
float spotLightCutoff = 15.0f; |
|
|
|
float specularLightColor[] = { 1.0f,1.0f,1.0f,1.0f }; |
|
|
|
float specularMaterial[] = { 1.0f,1.0f,1.0f,1.0f }; |
|
|
|
float eyePos[] = { 0.0f,0.0f,0.0f }; |
|
|
|
|
|
|
|
glm::mat4 modelMatrix = glm::translate<float>(0.0f,0.0f,-3.0f); |
|
|
|
glm::mat4 modelMatrix = glm::translate<float>(0.0f, -0.5f, -3.0f) * glm::rotate(-90.0f, 1.0f, 0.0f, 0.0f)*glm::scale(2.0f,2.0f,2.0f); |
|
|
|
glm::mat4 projectionMatrix = glm::perspective(50.0f, 800.0f / 600.0f, 0.1f, 1000.0f); |
|
|
|
|
|
|
|
glm::mat4 normalMatrix = glm::inverseTranspose(modelMatrix); |
|
|
@ -138,6 +142,8 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
|
glUniform4fv(gpuProgram.GetLocation("U_DiffuseLightColor"), 1, diffuseLightColor); |
|
|
|
glUniform4fv(gpuProgram.GetLocation("U_DiffuseMaterial"), 1, diffuseMaterial); |
|
|
|
glUniform4fv(gpuProgram.GetLocation("U_LightPos"), 1, lightPos); |
|
|
|
glUniform4fv(gpuProgram.GetLocation("U_LightDirection"), 1, spotLightDirection); |
|
|
|
glUniform1f(gpuProgram.GetLocation("U_Cutoff"), spotLightCutoff); |
|
|
|
glUniform4fv(gpuProgram.GetLocation("U_SpecularLightColor"), 1, specularLightColor); |
|
|
|
glUniform4fv(gpuProgram.GetLocation("U_SpecularMaterial"), 1, specularMaterial); |
|
|
|
glUniform3fv(gpuProgram.GetLocation("U_EyePos"), 1, eyePos); |
|
|
|