-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added --fp16 and --fp32 options to reduce color banding
These options will use more GPU memory and incur a performance penalty, and may not be supported on all hardware. They create an additional floating point FBO at full screen resolution, which is then transferred to the default FBO by rendering a full screen quad.
- Loading branch information
1 parent
5e9207c
commit 22ff617
Showing
7 changed files
with
201 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
Copyright (c) 2024 Anthony J. Thibault | ||
This software is licensed under the MIT License. See LICENSE for more details. | ||
*/ | ||
|
||
#include "framebuffer.h" | ||
|
||
#ifdef __ANDROID__ | ||
#include <EGL/egl.h> | ||
#include <EGL/eglext.h> | ||
#include <GLES3/gl3.h> | ||
#include <GLES3/gl3ext.h> | ||
#else | ||
#include <GL/glew.h> | ||
#define GL_GLEXT_PROTOTYPES 1 | ||
#include <SDL2/SDL_opengl.h> | ||
#include <SDL2/SDL_opengl_glext.h> | ||
#endif | ||
|
||
#include "texture.h" | ||
|
||
FrameBuffer::FrameBuffer() | ||
{ | ||
glGenFramebuffers(1, &fbo); | ||
} | ||
|
||
FrameBuffer::~FrameBuffer() | ||
{ | ||
glDeleteFramebuffers(1, &fbo); | ||
fbo = 0; | ||
} | ||
|
||
void FrameBuffer::Bind() const | ||
{ | ||
glBindFramebuffer(GL_FRAMEBUFFER, fbo); | ||
} | ||
|
||
void FrameBuffer::AttachColor(std::shared_ptr<Texture> colorTex) | ||
{ | ||
Bind(); | ||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTex->texture, 0); | ||
colorAttachment = colorTex; | ||
} | ||
|
||
void FrameBuffer::AttachDepth(std::shared_ptr<Texture> depthTex) | ||
{ | ||
Bind(); | ||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTex->texture, 0); | ||
depthAttachment = depthTex; | ||
} | ||
|
||
void FrameBuffer::AttachStencil(std::shared_ptr<Texture> stencilTex) | ||
{ | ||
Bind(); | ||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, stencilTex->texture, 0); | ||
stencilAttachment = stencilTex; | ||
} | ||
|
||
bool FrameBuffer::IsComplete() const | ||
{ | ||
return glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
Copyright (c) 2024 Anthony J. Thibault | ||
This software is licensed under the MIT License. See LICENSE for more details. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <stdint.h> | ||
#include <memory> | ||
|
||
struct Texture; | ||
|
||
struct FrameBuffer | ||
{ | ||
FrameBuffer(); | ||
~FrameBuffer(); | ||
|
||
void Bind() const; | ||
void AttachColor(std::shared_ptr<Texture> colorTex); | ||
void AttachDepth(std::shared_ptr<Texture> depthTex); | ||
void AttachStencil(std::shared_ptr<Texture> stencilTex); | ||
|
||
bool IsComplete() const; | ||
|
||
std::shared_ptr<Texture> GetColorTexture() const { return colorAttachment; } | ||
std::shared_ptr<Texture> GetDepthTexture() const { return depthAttachment; } | ||
std::shared_ptr<Texture> GetStencilTexture() const { return stencilAttachment; } | ||
|
||
uint32_t fbo; | ||
std::shared_ptr<Texture> colorAttachment; | ||
std::shared_ptr<Texture> depthAttachment; | ||
std::shared_ptr<Texture> stencilAttachment; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters