mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2024-12-05 03:33:27 +01:00
add multisampled fbo support + multisampled fixes
This commit is contained in:
parent
4304701e5e
commit
60aca24ec6
@ -47,7 +47,11 @@ FBOBuilder& FBOBuilder::attachTexture(std::shared_ptr<Texture> tex, GLuint attac
|
||||
}
|
||||
|
||||
//glFramebufferTexture2D(target, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex->getHandle(), 0);
|
||||
glFramebufferTexture2D(target, attachment_type, GL_TEXTURE_2D, tex->getHandle(), 0);
|
||||
if (tex->samples == 0u) {
|
||||
glFramebufferTexture2D(target, attachment_type, GL_TEXTURE_2D, tex->getHandle(), 0);
|
||||
} else {
|
||||
glFramebufferTexture2D(target, attachment_type, GL_TEXTURE_2D_MULTISAMPLE, tex->getHandle(), 0);
|
||||
}
|
||||
_fbo->_texAttachments.push_back(tex); // keep a ref at the fbo
|
||||
|
||||
return *this;
|
||||
|
@ -17,10 +17,10 @@ Texture::Texture(
|
||||
uint32_t handle,
|
||||
int32_t width_, int32_t height_,
|
||||
int32_t internalFormat, int32_t format, int32_t type,
|
||||
uint32_t samples
|
||||
uint32_t samples_
|
||||
) : _handle(handle), width(width_), height(height_),
|
||||
_internalFormat(internalFormat), _format(format), _type(type),
|
||||
_samples(samples) {
|
||||
samples(samples_),
|
||||
_internalFormat(internalFormat), _format(format), _type(type) {
|
||||
}
|
||||
|
||||
Texture::~Texture(void) {
|
||||
@ -34,7 +34,7 @@ void Texture::unbind(void) const {
|
||||
|
||||
void Texture::bind(uint32_t slot) const {
|
||||
glActiveTexture(GL_TEXTURE0 + slot);
|
||||
if (_samples == 0) {
|
||||
if (samples == 0) {
|
||||
glBindTexture(GL_TEXTURE_2D, _handle);
|
||||
} else {
|
||||
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, _handle);
|
||||
@ -44,12 +44,12 @@ void Texture::bind(uint32_t slot) const {
|
||||
void Texture::resize(int32_t new_width, int32_t new_height) {
|
||||
// if (glTexImage2D == true)
|
||||
|
||||
if (_samples == 0) {
|
||||
if (samples == 0) {
|
||||
glBindTexture(GL_TEXTURE_2D, _handle);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, _internalFormat, new_width, new_height, 0, _format, _type, NULL);
|
||||
} else {
|
||||
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, _handle);
|
||||
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, _samples, _internalFormat, new_width, new_height, 0);
|
||||
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, samples, _internalFormat, new_width, new_height, 0);
|
||||
}
|
||||
|
||||
// HACK: super dirty
|
||||
|
@ -30,11 +30,12 @@ namespace MM::OpenGL {
|
||||
int32_t const width;
|
||||
int32_t const height;
|
||||
//int32_t const bpp; // bits per pixel
|
||||
uint32_t const samples{0u}; // sample count, 0 == off
|
||||
|
||||
private:
|
||||
int32_t const _internalFormat;
|
||||
int32_t const _format;
|
||||
int32_t const _type;
|
||||
uint32_t const _samples{0u}; // sample count, 0 == off
|
||||
|
||||
public:
|
||||
~Texture();
|
||||
|
@ -31,5 +31,12 @@ namespace MM::OpenGL {
|
||||
}
|
||||
};
|
||||
|
||||
struct TextureLoaderEmptyMultiSampled final {
|
||||
template<typename... Args>
|
||||
std::shared_ptr<Texture> load(Args&& ... args) const {
|
||||
return Texture::createEmptyMultiSampled(std::forward<Args>(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
} // MM::OpenGL
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user