|
@ -194,9 +194,12 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
fsq.Init(); |
|
|
fsq.Init(); |
|
|
|
|
|
|
|
|
//³õʼ»¯FBO
|
|
|
//³õʼ»¯FBO
|
|
|
FBO fbo; |
|
|
|
|
|
fbo.AttachColorBuffer("color", GL_COLOR_ATTACHMENT0, GL_RGBA, viewportWidth, viewportHeight); |
|
|
|
|
|
fbo.AttachDepthBuffer("depth", viewportWidth, viewportHeight); |
|
|
|
|
|
|
|
|
FBO fbo[2]; |
|
|
|
|
|
fbo[0].AttachColorBuffer("color", GL_COLOR_ATTACHMENT0, GL_RGBA, viewportWidth, viewportHeight); |
|
|
|
|
|
fbo[0].AttachDepthBuffer("depth", viewportWidth, viewportHeight); |
|
|
|
|
|
fbo[1].AttachColorBuffer("color", GL_COLOR_ATTACHMENT0, GL_RGBA, viewportWidth, viewportHeight); |
|
|
|
|
|
fbo[1].AttachDepthBuffer("depth", viewportWidth, viewportHeight); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FBO HDRfbo; |
|
|
FBO HDRfbo; |
|
|
HDRfbo.AttachColorBuffer("color", GL_COLOR_ATTACHMENT0, GL_RGBA, viewportWidth, viewportHeight); |
|
|
HDRfbo.AttachColorBuffer("color", GL_COLOR_ATTACHMENT0, GL_RGBA, viewportWidth, viewportHeight); |
|
@ -207,7 +210,7 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
ShowWindow(hwnd, SW_SHOW); |
|
|
ShowWindow(hwnd, SW_SHOW); |
|
|
UpdateWindow(hwnd); |
|
|
UpdateWindow(hwnd); |
|
|
|
|
|
|
|
|
glClearColor(0.1f, 0.1f, 0.1f, 1.0f); |
|
|
|
|
|
|
|
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
|
|
MSG msg; |
|
|
MSG msg; |
|
|
while (true) |
|
|
while (true) |
|
|
{ |
|
|
{ |
|
@ -260,14 +263,43 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
glUseProgram(0); |
|
|
glUseProgram(0); |
|
|
HDRfbo.Unbind(); |
|
|
HDRfbo.Unbind(); |
|
|
|
|
|
|
|
|
fbo.Bind(); |
|
|
|
|
|
|
|
|
/* blur start */ |
|
|
|
|
|
fbo[0].Bind(); |
|
|
glUseProgram(gaussianProgram.mProgram); |
|
|
glUseProgram(gaussianProgram.mProgram); |
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
glActiveTexture(GL_TEXTURE0); |
|
|
glActiveTexture(GL_TEXTURE0); |
|
|
glBindTexture(GL_TEXTURE_2D, HDRfbo.GetBuffer("hdrcolor")); |
|
|
glBindTexture(GL_TEXTURE_2D, HDRfbo.GetBuffer("hdrcolor")); |
|
|
glUniform1i(gaussianProgram.GetLocation("U_MainTexture"), 0); |
|
|
glUniform1i(gaussianProgram.GetLocation("U_MainTexture"), 0); |
|
|
fsq.Draw(gaussianProgram.GetLocation("pos"), gaussianProgram.GetLocation("texcoord")); |
|
|
fsq.Draw(gaussianProgram.GetLocation("pos"), gaussianProgram.GetLocation("texcoord")); |
|
|
fbo.Unbind(); |
|
|
|
|
|
|
|
|
fbo[0].Unbind(); |
|
|
|
|
|
|
|
|
|
|
|
fbo[1].Bind(); |
|
|
|
|
|
glUseProgram(gaussianProgram.mProgram); |
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
|
|
|
glActiveTexture(GL_TEXTURE0); |
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, fbo[0].GetBuffer("color")); |
|
|
|
|
|
glUniform1i(gaussianProgram.GetLocation("U_MainTexture"), 0); |
|
|
|
|
|
fsq.Draw(gaussianProgram.GetLocation("pos"), gaussianProgram.GetLocation("texcoord")); |
|
|
|
|
|
fbo[1].Unbind(); |
|
|
|
|
|
|
|
|
|
|
|
fbo[0].Bind(); |
|
|
|
|
|
glUseProgram(gaussianProgram.mProgram); |
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
|
|
|
glActiveTexture(GL_TEXTURE0); |
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, fbo[1].GetBuffer("color")); |
|
|
|
|
|
glUniform1i(gaussianProgram.GetLocation("U_MainTexture"), 0); |
|
|
|
|
|
fsq.Draw(gaussianProgram.GetLocation("pos"), gaussianProgram.GetLocation("texcoord")); |
|
|
|
|
|
fbo[0].Unbind(); |
|
|
|
|
|
|
|
|
|
|
|
fbo[1].Bind(); |
|
|
|
|
|
glUseProgram(gaussianProgram.mProgram); |
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
|
|
|
glActiveTexture(GL_TEXTURE0); |
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, fbo[0].GetBuffer("color")); |
|
|
|
|
|
glUniform1i(gaussianProgram.GetLocation("U_MainTexture"), 0); |
|
|
|
|
|
fsq.Draw(gaussianProgram.GetLocation("pos"), gaussianProgram.GetLocation("texcoord")); |
|
|
|
|
|
fbo[1].Unbind(); |
|
|
|
|
|
/* blur end */ |
|
|
|
|
|
|
|
|
glFlush(); |
|
|
glFlush(); |
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
@ -284,7 +316,7 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
fsq.DrawToRightTop(hdrProgram.GetLocation("pos"), hdrProgram.GetLocation("texcoord")); |
|
|
fsq.DrawToRightTop(hdrProgram.GetLocation("pos"), hdrProgram.GetLocation("texcoord")); |
|
|
|
|
|
|
|
|
glUseProgram(gaussianProgram.mProgram); |
|
|
glUseProgram(gaussianProgram.mProgram); |
|
|
glBindTexture(GL_TEXTURE_2D, fbo.GetBuffer("color")); |
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, fbo[1].GetBuffer("color")); |
|
|
glUniform1i(gaussianProgram.GetLocation("U_MainTexture"), 0); |
|
|
glUniform1i(gaussianProgram.GetLocation("U_MainTexture"), 0); |
|
|
fsq.DrawToLeftBottom(gaussianProgram.GetLocation("pos"), gaussianProgram.GetLocation("texcoord")); |
|
|
fsq.DrawToLeftBottom(gaussianProgram.GetLocation("pos"), gaussianProgram.GetLocation("texcoord")); |
|
|
|
|
|
|
|
@ -293,7 +325,7 @@ INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ |
|
|
glBindTexture(GL_TEXTURE_2D, HDRfbo.GetBuffer("color")); |
|
|
glBindTexture(GL_TEXTURE_2D, HDRfbo.GetBuffer("color")); |
|
|
glUniform1i(combineProgram.GetLocation("U_MainTexture"), 0); |
|
|
glUniform1i(combineProgram.GetLocation("U_MainTexture"), 0); |
|
|
glActiveTexture(GL_TEXTURE1); |
|
|
glActiveTexture(GL_TEXTURE1); |
|
|
glBindTexture(GL_TEXTURE_2D, HDRfbo.GetBuffer("hdrcolor")); |
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, fbo[1].GetBuffer("color")); |
|
|
glUniform1i(combineProgram.GetLocation("U_HDRTexture"), 1); |
|
|
glUniform1i(combineProgram.GetLocation("U_HDRTexture"), 1); |
|
|
fsq.DrawToRightBottom(combineProgram.GetLocation("pos"), combineProgram.GetLocation("texcoord")); |
|
|
fsq.DrawToRightBottom(combineProgram.GetLocation("pos"), combineProgram.GetLocation("texcoord")); |
|
|
|
|
|
|
|
|