summaryrefslogtreecommitdiff
path: root/src/renderergl2/tr_backend.c
diff options
context:
space:
mode:
authorSmileTheory <SmileTheory@gmail.com>2016-01-21 22:31:41 -0800
committerTim Angus <tim@ngus.net>2016-04-07 11:53:16 +0100
commit8032873df3b9f0ca2498cf79c3874a50406cc427 (patch)
treea9d9cdd16955c4a15262bd8ba211f9a754f342f5 /src/renderergl2/tr_backend.c
parent1adb3a37252948d4e3bc65fafbb3438cb027458f (diff)
OpenGL2: Some FBO related cleanup/fixes.
Diffstat (limited to 'src/renderergl2/tr_backend.c')
-rw-r--r--src/renderergl2/tr_backend.c52
1 files changed, 13 insertions, 39 deletions
diff --git a/src/renderergl2/tr_backend.c b/src/renderergl2/tr_backend.c
index e6dd3cfa..ae475b02 100644
--- a/src/renderergl2/tr_backend.c
+++ b/src/renderergl2/tr_backend.c
@@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "tr_local.h"
+#include "tr_fbo.h"
#include "tr_dsa.h"
backEndData_t *backEndData;
@@ -378,31 +379,20 @@ void RB_BeginDrawingView (void) {
if (glRefConfig.framebufferObject)
{
+ FBO_t *fbo = backEnd.viewParms.targetFbo;
+
// FIXME: HUGE HACK: render to the screen fbo if we've already postprocessed the frame and aren't drawing more world
// drawing more world check is in case of double renders, such as skyportals
- if (backEnd.viewParms.targetFbo == NULL)
+ if (fbo == NULL && !(backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL)))
+ fbo = tr.renderFbo;
+
+ if (tr.renderCubeFbo && fbo == tr.renderCubeFbo)
{
- if (!tr.renderFbo || (backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL)))
- {
- FBO_Bind(NULL);
- }
- else
- {
- FBO_Bind(tr.renderFbo);
- }
+ cubemap_t *cubemap = &tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex];
+ FBO_AttachImage(fbo, cubemap->image, GL_COLOR_ATTACHMENT0_EXT, backEnd.viewParms.targetFboLayer);
}
- else
- {
- FBO_Bind(backEnd.viewParms.targetFbo);
- // FIXME: hack for cubemap testing
- if (tr.renderCubeFbo && backEnd.viewParms.targetFbo == tr.renderCubeFbo)
- {
- cubemap_t *cubemap = &tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex];
- //qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, backEnd.viewParms.targetFbo->colorImage[0]->texnum, 0);
- qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, cubemap->image->texnum, 0);
- }
- }
+ FBO_Bind(fbo);
}
//
@@ -781,14 +771,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
// FIXME: HUGE hack
if (glRefConfig.framebufferObject)
{
- if (!tr.renderFbo || backEnd.framePostProcessed)
- {
- FBO_Bind(NULL);
- }
- else
- {
- FBO_Bind(tr.renderFbo);
- }
+ FBO_Bind(backEnd.framePostProcessed ? NULL : tr.renderFbo);
}
RB_SetGL2D();
@@ -874,16 +857,7 @@ const void *RB_StretchPic ( const void *data ) {
// FIXME: HUGE hack
if (glRefConfig.framebufferObject)
- {
- if (!tr.renderFbo || backEnd.framePostProcessed)
- {
- FBO_Bind(NULL);
- }
- else
- {
- FBO_Bind(tr.renderFbo);
- }
- }
+ FBO_Bind(backEnd.framePostProcessed ? NULL : tr.renderFbo);
RB_SetGL2D();
@@ -1696,7 +1670,7 @@ const void *RB_ExportCubemaps(const void *data)
for (j = 0; j < 6; j++)
{
- qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + j, cubemap->image->texnum, 0);
+ FBO_AttachImage(tr.renderCubeFbo, cubemap->image, GL_COLOR_ATTACHMENT0_EXT, j);
qglReadPixels(0, 0, r_cubemapSize->integer, r_cubemapSize->integer, GL_RGBA, GL_UNSIGNED_BYTE, p);
p += sideSize;
}