mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-30 20:13:22 +08:00
Fix: framebuffer color format.
This commit is contained in:
@@ -104,7 +104,7 @@ int main()
|
||||
GLuint colorBuffer;
|
||||
glGenTextures(1, &colorBuffer);
|
||||
glBindTexture(GL_TEXTURE_2D, colorBuffer);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, SCR_WIDTH, SCR_HEIGHT, 0, GL_RGB, GL_FLOAT, NULL);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, SCR_WIDTH, SCR_HEIGHT, 0, GL_RGBA, GL_FLOAT, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
// - Create depth buffer (renderbuffer)
|
||||
@@ -333,7 +333,7 @@ void Do_Movement()
|
||||
keysPressed[GLFW_KEY_SPACE] = true;
|
||||
}
|
||||
|
||||
// Change parallax height scale
|
||||
// Change exposure of the scene's HDR camera
|
||||
if (keys[GLFW_KEY_Q])
|
||||
exposure -= 0.5 * deltaTime;
|
||||
else if (keys[GLFW_KEY_E])
|
||||
|
||||
@@ -141,7 +141,7 @@ int main()
|
||||
// - Color + Specular color buffer
|
||||
glGenTextures(1, &gAlbedoSpec);
|
||||
glBindTexture(GL_TEXTURE_2D, gAlbedoSpec);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SCR_WIDTH, SCR_HEIGHT, 0, GL_RGBA, GL_FLOAT, NULL);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SCR_WIDTH, SCR_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, gAlbedoSpec, 0);
|
||||
@@ -230,6 +230,9 @@ int main()
|
||||
// 2.5. Copy content of geometry's depth buffer to default framebuffer's depth buffer
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, gBuffer);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); // Write to default framebuffer
|
||||
// blit to default framebuffer. Note that this may or may not work as the internal formats of both the FBO and default framebuffer have to match.
|
||||
// the internal formats are implementation defined. This works on all of my systems, but if it doesn't on yours you'll likely have to write to the
|
||||
// depth buffer in another stage (or somehow see to match the default framebuffer's internal format with the FBO's internal format).
|
||||
glBlitFramebuffer(0, 0, SCR_WIDTH, SCR_HEIGHT, 0, 0, SCR_WIDTH, SCR_HEIGHT, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user