|
|
@ -79,6 +79,10 @@ 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_SpecularLightColor"); |
|
|
|
gpuProgram.DetectUniform("U_SpecularMaterial"); |
|
|
|
gpuProgram.DetectUniform("U_EyePos"); |
|
|
|
|
|
|
|
//init 3d model
|
|
|
|
ObjModel model; |
|
|
|
model.Init("res/model/Sphere.obj"); |
|
|
@ -94,6 +98,9 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
|
float diffuseLightColor[] = { 1.0f,1.0f,1.0f,1.0f }; |
|
|
|
float diffuseMaterial[] = { 0.8f,0.8f,0.8f,1.0f }; |
|
|
|
float lightPos[] = {1.0f,1.0f,0.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 projectionMatrix = glm::perspective(50.0f, 800.0f / 600.0f, 0.1f, 1000.0f); |
|
|
@ -131,6 +138,10 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
|
glUniform4fv(gpuProgram.GetLocation("U_DiffuseLightColor"), 1, diffuseLightColor); |
|
|
|
glUniform4fv(gpuProgram.GetLocation("U_DiffuseMaterial"), 1, diffuseMaterial); |
|
|
|
glUniform3fv(gpuProgram.GetLocation("U_LightPos"), 1, lightPos); |
|
|
|
glUniform4fv(gpuProgram.GetLocation("U_SpecularLightColor"), 1, specularLightColor); |
|
|
|
glUniform4fv(gpuProgram.GetLocation("U_SpecularMaterial"), 1, specularMaterial); |
|
|
|
glUniform3fv(gpuProgram.GetLocation("U_EyePos"), 1, eyePos); |
|
|
|
|
|
|
|
model.Bind(gpuProgram.GetLocation("pos"), gpuProgram.GetLocation("texcoord"), gpuProgram.GetLocation("normal")); |
|
|
|
model.Draw(); |
|
|
|
glUseProgram(0); |
|
|
|