Rewritten. Works as a charm now.

This commit is contained in:
FakeShemp
2016-03-03 03:28:21 +01:00
parent 28e9ba1208
commit 7ea26d10ee
19 changed files with 224 additions and 199 deletions
+16 -16
View File
@@ -16,6 +16,7 @@ Texture2D::~Texture2D()
}
}
RenderBuffer::~RenderBuffer()
{
if (m_ResourceHandle != 0) {
@@ -51,7 +52,6 @@ void FrameBuffer::Generate()
switch ((*it)->m_ResourceType) {
case GL_TEXTURE_2D:
glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0);
attachments.push_back((*it)->m_Attachment);
GLERROR("FrameBuffer generate: glFramebufferTexture2D");
break;
case GL_RENDERBUFFER:
@@ -60,13 +60,13 @@ void FrameBuffer::Generate()
break;
case GL_TEXTURE_2D_ARRAY:
glFramebufferTexture(GL_FRAMEBUFFER, (*it)->m_Attachment, *(*it)->m_ResourceHandle, 0);
attachments.push_back((*it)->m_Attachment);
GLERROR("FrameBuffer generate: GL_TEXTURE_2D_ARRAY");
GLERROR("FrameBuffer generate: glFramebufferTexture2DArray");
break;
}
GLERROR("2");
if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT && (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) {
// Need GL_DEPTH_ATTACHMENT for shadows
if (/*(*it)->m_Attachment != GL_DEPTH_ATTACHMENT &&*/ (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) {
attachments.push_back((*it)->m_Attachment);
}
GLERROR("Attachment");
@@ -74,19 +74,19 @@ void FrameBuffer::Generate()
}
GLERROR("3");
GLenum* bufferTextures = &attachments[0];
glDrawBuffers(attachments.size(), bufferTextures);
if (GLERROR("GLBufferAttachement error")) {
printf(": AttachmentSize %i", attachments.size());
}
GLenum* bufferTextures = &attachments[0];
glDrawBuffers(attachments.size(), bufferTextures);
if (GLERROR("GLBufferAttachement error")) {
printf(": AttachmentSize %i", attachments.size());
}
if (GLenum frameBufferStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
GLERROR("Framebuffer incomplete");
//LOG_ERROR("FrameBuffer incomplete: 0x%x\n", frameBufferStatus);
exit(EXIT_FAILURE);
}
GLERROR("END");
if (GLenum frameBufferStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
GLERROR("Framebuffer incomplete");
//LOG_ERROR("FrameBuffer incomplete: 0x%x\n", frameBufferStatus);
exit(EXIT_FAILURE);
}
GLERROR("END");
}
}
void FrameBuffer::Bind()