|
@ -175,6 +175,10 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
fbo.AttachDepthBuffer("depth", viewportWidth, viewportHeight); |
|
|
fbo.AttachDepthBuffer("depth", viewportWidth, viewportHeight); |
|
|
fbo.Finish(); |
|
|
fbo.Finish(); |
|
|
|
|
|
|
|
|
|
|
|
FBO fbo2; |
|
|
|
|
|
fbo2.AttachColorBuffer("color", GL_COLOR_ATTACHMENT0, GL_RGBA, viewportWidth, viewportHeight); |
|
|
|
|
|
fbo2.AttachDepthBuffer("depth", viewportWidth, viewportHeight); |
|
|
|
|
|
fbo2.Finish(); |
|
|
|
|
|
|
|
|
ShowWindow(hwnd, SW_SHOW); |
|
|
ShowWindow(hwnd, SW_SHOW); |
|
|
UpdateWindow(hwnd); |
|
|
UpdateWindow(hwnd); |
|
@ -192,13 +196,11 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
TranslateMessage(&msg); |
|
|
TranslateMessage(&msg); |
|
|
DispatchMessage(&msg); |
|
|
DispatchMessage(&msg); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
|
|
|
|
|
|
|
|
|
glEnable(GL_DEPTH_TEST); |
|
|
glEnable(GL_DEPTH_TEST); |
|
|
glUseProgram(gpuProgram.mProgram); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fbo.Bind(); |
|
|
fbo.Bind(); |
|
|
|
|
|
glUseProgram(gpuProgram.mProgram); |
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
glUniform4fv(gpuProgram.GetLocation("U_AmbientLightColor"), 1, ambientLightColor); |
|
|
glUniform4fv(gpuProgram.GetLocation("U_AmbientLightColor"), 1, ambientLightColor); |
|
|
glUniform4fv(gpuProgram.GetLocation("U_AmbientMaterial"), 1, ambientMaterial); |
|
|
glUniform4fv(gpuProgram.GetLocation("U_AmbientMaterial"), 1, ambientMaterial); |
|
@ -215,12 +217,20 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
glUniformMatrix4fv(gpuProgram.GetLocation("V"), 1, GL_FALSE, glm::value_ptr(viewMatrix)); |
|
|
glUniformMatrix4fv(gpuProgram.GetLocation("V"), 1, GL_FALSE, glm::value_ptr(viewMatrix)); |
|
|
glUniformMatrix4fv(gpuProgram.GetLocation("P"), 1, GL_FALSE, glm::value_ptr(projectionMatrix)); |
|
|
glUniformMatrix4fv(gpuProgram.GetLocation("P"), 1, GL_FALSE, glm::value_ptr(projectionMatrix)); |
|
|
glUniformMatrix4fv(gpuProgram.GetLocation("NM"), 1, GL_FALSE, glm::value_ptr(normalMatrix)); |
|
|
glUniformMatrix4fv(gpuProgram.GetLocation("NM"), 1, GL_FALSE, glm::value_ptr(normalMatrix)); |
|
|
|
|
|
|
|
|
obj.Bind(gpuProgram.GetLocation("pos"), gpuProgram.GetLocation("texcoord"), gpuProgram.GetLocation("normal")); |
|
|
obj.Bind(gpuProgram.GetLocation("pos"), gpuProgram.GetLocation("texcoord"), gpuProgram.GetLocation("normal")); |
|
|
obj.Draw(); |
|
|
obj.Draw(); |
|
|
|
|
|
glUseProgram(0); |
|
|
fbo.Unbind(); |
|
|
fbo.Unbind(); |
|
|
|
|
|
|
|
|
glUseProgram(0); |
|
|
|
|
|
|
|
|
//blur * 2
|
|
|
|
|
|
fbo2.Bind(); |
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
|
|
|
glUseProgram(gaussianProgram.mProgram); |
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, fbo.GetBuffer("color")); |
|
|
|
|
|
glUniform1i(gaussianProgram.GetLocation("U_MainTexture"), 0); |
|
|
|
|
|
fsq.Draw(gaussianProgram.GetLocation("pos"), gaussianProgram.GetLocation("texcoord")); |
|
|
|
|
|
fbo2.Unbind(); |
|
|
|
|
|
|
|
|
glFlush(); |
|
|
glFlush(); |
|
|
|
|
|
|
|
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
|
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
|
@ -242,6 +252,8 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
fsq.DrawToLeftBottom(dilationProgram.GetLocation("pos"), dilationProgram.GetLocation("texcoord")); |
|
|
fsq.DrawToLeftBottom(dilationProgram.GetLocation("pos"), dilationProgram.GetLocation("texcoord")); |
|
|
|
|
|
|
|
|
glUseProgram(gaussianProgram.mProgram); |
|
|
glUseProgram(gaussianProgram.mProgram); |
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, fbo2.GetBuffer("color")); |
|
|
|
|
|
glUniform1i(originalProgram.GetLocation("U_MainTexture"), 0); |
|
|
fsq.DrawToRightBottom(gaussianProgram.GetLocation("pos"), gaussianProgram.GetLocation("texcoord")); |
|
|
fsq.DrawToRightBottom(gaussianProgram.GetLocation("pos"), gaussianProgram.GetLocation("texcoord")); |
|
|
|
|
|
|
|
|
SwapBuffers(dc); |
|
|
SwapBuffers(dc); |
|
|