Skip to content

Commit

Permalink
CRenderTarget: Use the default framebuffer in case HW.pBaseRT is set.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Nov 29, 2015
1 parent f579ec5 commit 4a9de05
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/Layers/xrRender/R_Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class ECORE_API CBackend
private:
// Render-targets
#ifdef USE_OGL
GLuint pFB;
GLuint pRT[4];
GLuint pZB;
#else
Expand Down Expand Up @@ -252,8 +253,10 @@ class ECORE_API CBackend
IC const Fmatrix& get_xform_project ();

#ifdef USE_OGL
IC void set_FB (GLuint FB=0);
IC void set_RT (GLuint RT, u32 ID=0);
IC void set_ZB (GLuint ZB);
IC GLuint get_FB ();
IC GLuint get_RT (u32 ID=0);
IC GLuint get_ZB ();
#else
Expand Down
15 changes: 15 additions & 0 deletions src/Layers/xrRenderGL/glR_Backend_Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ IC void CBackend::set_xform(u32 ID, const Fmatrix& M)
//VERIFY(!"Implement CBackend::set_xform");
}

IC GLuint CBackend::get_FB()
{
return pFB;
}

IC void CBackend::set_FB(GLuint FB)
{
if (FB != pFB)
{
PGO(Msg("PGO:set_FB"));
pFB = FB;
CHK_GL(glBindFramebuffer(GL_FRAMEBUFFER, pFB));
}
}

IC void CBackend::set_RT(GLuint RT, u32 ID)
{
if (RT != pRT[ID])
Expand Down
20 changes: 13 additions & 7 deletions src/Layers/xrRenderPC_GL/gl_rendertarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ void CRenderTarget::u_setrt(const ref_rt& _1, const ref_rt& _2, const ref_rt& _3
dwHeight = _1->dwHeight;
GLuint cnt = 0;
GLenum buffers[3] = { GL_NONE };
RCache.set_FB(HW.pFB);
if (_1)
{
buffers[cnt++] = GL_COLOR_ATTACHMENT0;
Expand Down Expand Up @@ -50,6 +51,7 @@ void CRenderTarget::u_setrt(const ref_rt& _1, const ref_rt& _2, GLuint zb)
dwHeight = _1->dwHeight;
GLuint cnt = 0;
GLenum buffers[2] = { GL_NONE };
RCache.set_FB(HW.pFB);
if (_1)
{
buffers[cnt++] = GL_COLOR_ATTACHMENT0;
Expand All @@ -73,20 +75,24 @@ void CRenderTarget::u_setrt(u32 W, u32 H, GLuint _1, GLuint _2, GLuint _3, GLuin
dwHeight = H;
GLuint cnt = 0;
GLenum buffers[3] = { GL_NONE };
if (_1 == HW.pBaseRT) buffers[cnt++] = GL_BACK;
else if (_1)
if (_1 == HW.pBaseRT)
{
RCache.set_FB();
return;
}

RCache.set_FB(HW.pFB);
if (_1)
{
buffers[cnt++] = GL_COLOR_ATTACHMENT0;
RCache.set_RT(_1, 0);
}
if (_2 == HW.pBaseRT) buffers[cnt++] = GL_BACK;
else if (_2)
if (_2)
{
buffers[cnt++] = GL_COLOR_ATTACHMENT1;
RCache.set_RT(_2, 1);
}
if (_3 == HW.pBaseRT) buffers[cnt++] = GL_BACK;
else if (_3)
if (_3)
{
buffers[cnt++] = GL_COLOR_ATTACHMENT2;
RCache.set_RT(_3, 2);
Expand Down Expand Up @@ -815,7 +821,7 @@ CRenderTarget::CRenderTarget ()
// Autogen mipmaps
glGenTextures(1, &t_noise_surf_mipped);
CHK_GL(glBindTexture(GL_TEXTURE_2D, t_noise_surf_mipped));
CHK_GL(glTexStorage2D(GL_TEXTURE_2D, 0, GL_RGBA8, TEX_jitter, TEX_jitter));
CHK_GL(glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, TEX_jitter, TEX_jitter));
t_noise_mipped = RImplementation.Resources->_CreateTexture(r2_jitter_mipped);
t_noise_mipped->surface_set(GL_TEXTURE_2D, t_noise_surf_mipped);

Expand Down

0 comments on commit 4a9de05

Please sign in to comment.