#endif
R_Viewport_InitOrtho(&viewport, &identitymatrix, 0, 0, vid.mode.width, vid.mode.height, 0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100, NULL);
- R_Mesh_SetRenderTargets(0, NULL, NULL, NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(0);
R_SetViewport(&viewport);
GL_ScissorTest(false);
GL_ColorMask(1,1,1,1);
qglGenFramebuffers(1, (GLuint*)&temp);CHECKGLERROR
#ifndef USE_GLES2
- R_Mesh_SetRenderTargets(temp, NULL, NULL, NULL, NULL, NULL); // This breaks GLES2.
+ R_Mesh_SetRenderTargets(temp); // This breaks GLES2.
// GL_ARB_framebuffer_object (GL3-class hardware) - depth stencil attachment
#endif
}
}
-void R_Mesh_SetRenderTargets(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, rtexture_t *colortexture2, rtexture_t *colortexture3, rtexture_t *colortexture4)
+void R_Mesh_SetRenderTargets(int fbo)
{
- unsigned int i;
- unsigned int j;
- rtexture_t *textures[5];
- Vector4Set(textures, colortexture, colortexture2, colortexture3, colortexture4);
- textures[4] = depthtexture;
- // unbind any matching textures immediately, otherwise D3D will complain about a bound texture being used as a render target
- for (j = 0;j < 5;j++)
- if (textures[j])
- for (i = 0;i < MAX_TEXTUREUNITS;i++)
- if (gl_state.units[i].texture == textures[j])
- R_Mesh_TexBind(i, NULL);
// set up framebuffer object or render targets for the active rendering API
switch (vid.renderpath)
{
oldestPBOindex = 0;
// Ensure we'll read from the default FB
- R_Mesh_SetRenderTargets(0, NULL, NULL, NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(0);
// If necessary, scale the newest frame with linear filtering
if (cls.capturevideo.FBO)
void R_Mesh_Start(void)
{
BACKENDACTIVECHECK
- R_Mesh_SetRenderTargets(0, NULL, NULL, NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(0);
#ifdef DEBUGGL // gl_printcheckerror isn't registered in normal builds
if (gl_printcheckerror.integer && !gl_paranoid.integer)
{
// restores backend state, used when done with 3D rendering
void R_Mesh_Finish(void)
{
- R_Mesh_SetRenderTargets(0, NULL, NULL, NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(0);
}
r_meshbuffer_t *R_Mesh_CreateMeshBuffer(const void *data, size_t size, const char *name, qbool isindexbuffer, qbool isuniformbuffer, qbool isdynamic, qbool isindex16)
void GL_CaptureVideo_EndVideo(void);
int R_Mesh_CreateFramebufferObject(rtexture_t *depthtexture, rtexture_t *colortexture, rtexture_t *colortexture2, rtexture_t *colortexture3, rtexture_t *colortexture4);
void R_Mesh_DestroyFramebufferObject(int fbo);
-void R_Mesh_SetRenderTargets(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, rtexture_t *colortexture2, rtexture_t *colortexture3, rtexture_t *colortexture4);
+void R_Mesh_SetRenderTargets(int fbo);
unsigned int GL_Backend_CompileProgram(int vertexstrings_count, const char **vertexstrings_list, int geometrystrings_count, const char **geometrystrings_list, int fragmentstrings_count, const char **fragmentstrings_list);
void GL_Backend_FreeProgram(unsigned int prog);
R_Viewport_InitPerspectiveInfinite(&r_refdef.view.viewport, &r_refdef.view.matrix, viewx, viewy_adjusted, viewwidth, viewheight, r_refdef.view.frustum_x, r_refdef.view.frustum_y, r_refdef.nearclip, customclipplane);
else
R_Viewport_InitPerspective(&r_refdef.view.viewport, &r_refdef.view.matrix, viewx, viewy_adjusted, viewwidth, viewheight, r_refdef.view.frustum_x, r_refdef.view.frustum_y, r_refdef.nearclip, r_refdef.farclip, customclipplane);
- R_Mesh_SetRenderTargets(viewfbo, viewdepthtexture, viewcolortexture, NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(viewfbo);
R_SetViewport(&r_refdef.view.viewport);
}
viewy_adjusted = viewfbo ? viewy : vid.mode.height - viewheight - viewy;
R_Viewport_InitOrtho(&viewport, &identitymatrix, viewx, viewy_adjusted, viewwidth, viewheight, 0, 0, x2, y2, -10, 100, NULL);
- R_Mesh_SetRenderTargets(viewfbo, viewdepthtexture, viewcolortexture, NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(viewfbo);
R_SetViewport(&viewport);
GL_Scissor(viewport.x, viewport.y, viewport.width, viewport.height);
GL_Color(1, 1, 1, 1);
CHECKGLERROR
prev = r_fb.rt_screen;
cur = R_RenderTarget_Get(r_fb.bloomwidth, r_fb.bloomheight, TEXTYPE_UNUSED, false, textype, TEXTYPE_UNUSED, TEXTYPE_UNUSED, TEXTYPE_UNUSED);
- R_Mesh_SetRenderTargets(cur->fbo, NULL, cur->colortexture[0], NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(cur->fbo);
R_SetViewport(&bloomviewport);
GL_CullFace(GL_NONE);
GL_DepthTest(false);
{
prev = cur;
cur = R_RenderTarget_Get(r_fb.bloomwidth, r_fb.bloomheight, TEXTYPE_UNUSED, false, textype, TEXTYPE_UNUSED, TEXTYPE_UNUSED, TEXTYPE_UNUSED);
- R_Mesh_SetRenderTargets(cur->fbo, NULL, cur->colortexture[0], NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(cur->fbo);
x *= 2;
r = bound(0, r_bloom_colorexponent.value / x, 1); // always 0.5 to 1
if(x <= 2)
{
prev = cur;
cur = R_RenderTarget_Get(r_fb.bloomwidth, r_fb.bloomheight, TEXTYPE_UNUSED, false, textype, TEXTYPE_UNUSED, TEXTYPE_UNUSED, TEXTYPE_UNUSED);
- R_Mesh_SetRenderTargets(cur->fbo, NULL, cur->colortexture[0], NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(cur->fbo);
// blend on at multiple vertical offsets to achieve a vertical blur
// TODO: do offset blends using GLSL
// TODO instead of changing the texcoords, change the target positions to prevent artifacts at edges
if (r_refdef.view.isoverlay)
{
// TODO: FIXME: move this into its own backend function maybe? [2/5/2008 Andreas]
- R_Mesh_SetRenderTargets(0, NULL, NULL, NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(0);
GL_Clear(GL_DEPTH_BUFFER_BIT, NULL, 1.0f, 0);
R_TimeReport("depthclear");
void R_Shadow_RenderMode_Reset(void)
{
R_Mesh_ResetTextureState();
- R_Mesh_SetRenderTargets(r_shadow_viewfbo, r_shadow_viewdepthtexture, r_shadow_viewcolortexture, NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(r_shadow_viewfbo);
R_SetViewport(&r_refdef.view.viewport);
GL_Scissor(r_shadow_lightscissor[0], r_shadow_lightscissor[1], r_shadow_lightscissor[2], r_shadow_lightscissor[3]);
GL_DepthRange(0, 1);
R_Mesh_ResetTextureState();
R_Shadow_RenderMode_Reset();
if (r_shadow_shadowmap2ddepthbuffer)
- R_Mesh_SetRenderTargets(r_shadow_fbo2d, r_shadow_shadowmap2ddepthbuffer, r_shadow_shadowmap2ddepthtexture, NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(r_shadow_fbo2d);
else
- R_Mesh_SetRenderTargets(r_shadow_fbo2d, r_shadow_shadowmap2ddepthtexture, NULL, NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(r_shadow_fbo2d);
R_SetupShader_DepthOrShadow(true, r_shadow_shadowmap2ddepthbuffer != NULL, false); // FIXME test if we have a skeletal model?
GL_PolygonOffset(r_shadow_shadowmapping_polygonfactor.value, r_shadow_shadowmapping_polygonoffset.value);
GL_DepthMask(true);
R_Mesh_ResetTextureState();
R_Shadow_RenderMode_Reset();
if (r_shadow_shadowmap2ddepthbuffer)
- R_Mesh_SetRenderTargets(r_shadow_fbo2d, r_shadow_shadowmap2ddepthbuffer, r_shadow_shadowmap2ddepthtexture, NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(r_shadow_fbo2d);
else
- R_Mesh_SetRenderTargets(r_shadow_fbo2d, r_shadow_shadowmap2ddepthtexture, NULL, NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(r_shadow_fbo2d);
R_SetupShader_DepthOrShadow(true, r_shadow_shadowmap2ddepthbuffer != NULL, false); // FIXME test if we have a skeletal model?
GL_PolygonOffset(r_shadow_shadowmapping_polygonfactor.value, r_shadow_shadowmapping_polygonoffset.value);
GL_DepthMask(true);
R_EntityMatrix(&identitymatrix);
GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
if (rsurface.rtlight->specularscale > 0 && r_shadow_gloss.integer > 0)
- R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusespecularfbo, r_shadow_prepassgeometrydepthbuffer, r_shadow_prepasslightingdiffusetexture, r_shadow_prepasslightingspeculartexture, NULL, NULL);
+ R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusespecularfbo);
else
- R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusefbo, r_shadow_prepassgeometrydepthbuffer, r_shadow_prepasslightingdiffusetexture, NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusefbo);
r_shadow_usingshadowmap2d = shadowmapping;
GL_BlendFunc(GL_ONE, GL_ZERO);
GL_Color(1,1,1,1);
GL_DepthTest(true);
- R_Mesh_SetRenderTargets(r_shadow_prepassgeometryfbo, r_shadow_prepassgeometrydepthbuffer, r_shadow_prepassgeometrynormalmaptexture, NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(r_shadow_prepassgeometryfbo);
Vector4Set(clearcolor, 0.5f,0.5f,0.5f,1.0f);
GL_Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, clearcolor, 1.0f, 0);
if (r_timereport_active)
GL_ColorMask(1,1,1,1);
GL_Color(1,1,1,1);
GL_DepthTest(true);
- R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusespecularfbo, r_shadow_prepassgeometrydepthbuffer, r_shadow_prepasslightingdiffusetexture, r_shadow_prepasslightingspeculartexture, NULL, NULL);
+ R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusespecularfbo);
Vector4Set(clearcolor, 0, 0, 0, 0);
GL_Clear(GL_COLOR_BUFFER_BIT, clearcolor, 1.0f, 0);
if (r_timereport_active)
// set up the geometry pass fbo (depth + normalmap)
r_shadow_prepassgeometryfbo = R_Mesh_CreateFramebufferObject(r_shadow_prepassgeometrydepthbuffer, r_shadow_prepassgeometrynormalmaptexture, NULL, NULL, NULL);
- R_Mesh_SetRenderTargets(r_shadow_prepassgeometryfbo, r_shadow_prepassgeometrydepthbuffer, r_shadow_prepassgeometrynormalmaptexture, NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(r_shadow_prepassgeometryfbo);
// render depth into a renderbuffer and other important properties into the normalmap texture
// set up the lighting pass fbo (diffuse + specular)
r_shadow_prepasslightingdiffusespecularfbo = R_Mesh_CreateFramebufferObject(r_shadow_prepassgeometrydepthbuffer, r_shadow_prepasslightingdiffusetexture, r_shadow_prepasslightingspeculartexture, NULL, NULL);
- R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusespecularfbo, r_shadow_prepassgeometrydepthbuffer, r_shadow_prepasslightingdiffusetexture, r_shadow_prepasslightingspeculartexture, NULL, NULL);
+ R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusespecularfbo);
// render diffuse into one texture and specular into another,
// with depth and normalmap bound as textures,
// with depth bound as attachment as well
// set up the lighting pass fbo (diffuse)
r_shadow_prepasslightingdiffusefbo = R_Mesh_CreateFramebufferObject(r_shadow_prepassgeometrydepthbuffer, r_shadow_prepasslightingdiffusetexture, NULL, NULL, NULL);
- R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusefbo, r_shadow_prepassgeometrydepthbuffer, r_shadow_prepasslightingdiffusetexture, NULL, NULL, NULL);
+ R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusefbo);
// render diffuse into one texture,
// with depth and normalmap bound as textures,
// with depth bound as attachment as well