mirror of
https://github.com/DrBeef/Doom3Quest.git
synced 2024-11-27 14:22:18 +00:00
Changes to make use of temporary frame buffer more obvious
This commit is contained in:
parent
d2bf0dcb11
commit
096a83652b
1 changed files with 17 additions and 14 deletions
|
@ -5,14 +5,16 @@ GPL3
|
||||||
#include "renderer/tr_local.h"
|
#include "renderer/tr_local.h"
|
||||||
#include "renderer/VertexCache.h"
|
#include "renderer/VertexCache.h"
|
||||||
|
|
||||||
static GLuint m_framebuffer[3];
|
#define FRAMEBUFFER_POOL_SIZE
|
||||||
static GLuint m_depthbuffer[3];
|
|
||||||
|
static GLuint m_framebuffer[FRAMEBUFFER_POOL_SIZE];
|
||||||
|
static GLuint m_depthbuffer[FRAMEBUFFER_POOL_SIZE];
|
||||||
|
|
||||||
static int m_framebuffer_width, m_framebuffer_height;
|
static int m_framebuffer_width, m_framebuffer_height;
|
||||||
static GLuint m_framebuffer_texture[3];
|
static GLuint m_framebuffer_texture[FRAMEBUFFER_POOL_SIZE];
|
||||||
|
|
||||||
static GLint drawFboId = 0;
|
static GLint drawFboId = 0;
|
||||||
static int calldepth = 0;
|
static int currentFramebufferIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
void R_InitFrameBuffer()
|
void R_InitFrameBuffer()
|
||||||
|
@ -20,7 +22,7 @@ void R_InitFrameBuffer()
|
||||||
m_framebuffer_width = glConfig.vidWidth;
|
m_framebuffer_width = glConfig.vidWidth;
|
||||||
m_framebuffer_height = glConfig.vidHeight;
|
m_framebuffer_height = glConfig.vidHeight;
|
||||||
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < FRAMEBUFFER_POOL_SIZE; ++i) {
|
||||||
// Create texture
|
// Create texture
|
||||||
glGenTextures(1, &m_framebuffer_texture[i]);
|
glGenTextures(1, &m_framebuffer_texture[i]);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_framebuffer_texture[i]);
|
glBindTexture(GL_TEXTURE_2D, m_framebuffer_texture[i]);
|
||||||
|
@ -43,18 +45,18 @@ void R_InitFrameBuffer()
|
||||||
|
|
||||||
void R_FrameBufferStart()
|
void R_FrameBufferStart()
|
||||||
{
|
{
|
||||||
if (calldepth == 0) {
|
if (currentFramebufferIndex == 0) {
|
||||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &drawFboId);
|
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &drawFboId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render to framebuffer
|
// Render to framebuffer
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer[calldepth]);
|
glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer[currentFramebufferIndex]);
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_framebuffer_texture[calldepth], 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_framebuffer_texture[currentFramebufferIndex], 0);
|
||||||
|
|
||||||
// Attach combined depth+stencil
|
// Attach combined depth+stencil
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthbuffer[calldepth]);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthbuffer[currentFramebufferIndex]);
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthbuffer[calldepth]);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthbuffer[currentFramebufferIndex]);
|
||||||
|
|
||||||
GLenum result = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
GLenum result = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
if(result != GL_FRAMEBUFFER_COMPLETE)
|
if(result != GL_FRAMEBUFFER_COMPLETE)
|
||||||
|
@ -65,18 +67,19 @@ void R_FrameBufferStart()
|
||||||
glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
|
glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
|
||||||
qglClear( GL_COLOR_BUFFER_BIT );
|
qglClear( GL_COLOR_BUFFER_BIT );
|
||||||
|
|
||||||
calldepth++;
|
//Increment index in case this gets called again
|
||||||
|
currentFramebufferIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void R_FrameBufferEnd()
|
void R_FrameBufferEnd()
|
||||||
{
|
{
|
||||||
calldepth--;
|
currentFramebufferIndex--;
|
||||||
|
|
||||||
if (calldepth == 0) {
|
if (currentFramebufferIndex == 0) {
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, drawFboId);
|
glBindFramebuffer(GL_FRAMEBUFFER, drawFboId);
|
||||||
} else {
|
} else {
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer[calldepth-1]);
|
glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer[currentFramebufferIndex - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue