Skip to content

Commit 4a9de05

Browse files
committed
CRenderTarget: Use the default framebuffer in case HW.pBaseRT is set.
1 parent f579ec5 commit 4a9de05

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

src/Layers/xrRender/R_Backend.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class ECORE_API CBackend
9393
private:
9494
// Render-targets
9595
#ifdef USE_OGL
96+
GLuint pFB;
9697
GLuint pRT[4];
9798
GLuint pZB;
9899
#else
@@ -252,8 +253,10 @@ class ECORE_API CBackend
252253
IC const Fmatrix& get_xform_project ();
253254

254255
#ifdef USE_OGL
256+
IC void set_FB (GLuint FB=0);
255257
IC void set_RT (GLuint RT, u32 ID=0);
256258
IC void set_ZB (GLuint ZB);
259+
IC GLuint get_FB ();
257260
IC GLuint get_RT (u32 ID=0);
258261
IC GLuint get_ZB ();
259262
#else

src/Layers/xrRenderGL/glR_Backend_Runtime.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ IC void CBackend::set_xform(u32 ID, const Fmatrix& M)
1111
//VERIFY(!"Implement CBackend::set_xform");
1212
}
1313

14+
IC GLuint CBackend::get_FB()
15+
{
16+
return pFB;
17+
}
18+
19+
IC void CBackend::set_FB(GLuint FB)
20+
{
21+
if (FB != pFB)
22+
{
23+
PGO(Msg("PGO:set_FB"));
24+
pFB = FB;
25+
CHK_GL(glBindFramebuffer(GL_FRAMEBUFFER, pFB));
26+
}
27+
}
28+
1429
IC void CBackend::set_RT(GLuint RT, u32 ID)
1530
{
1631
if (RT != pRT[ID])

src/Layers/xrRenderPC_GL/gl_rendertarget.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ void CRenderTarget::u_setrt(const ref_rt& _1, const ref_rt& _2, const ref_rt& _3
2121
dwHeight = _1->dwHeight;
2222
GLuint cnt = 0;
2323
GLenum buffers[3] = { GL_NONE };
24+
RCache.set_FB(HW.pFB);
2425
if (_1)
2526
{
2627
buffers[cnt++] = GL_COLOR_ATTACHMENT0;
@@ -50,6 +51,7 @@ void CRenderTarget::u_setrt(const ref_rt& _1, const ref_rt& _2, GLuint zb)
5051
dwHeight = _1->dwHeight;
5152
GLuint cnt = 0;
5253
GLenum buffers[2] = { GL_NONE };
54+
RCache.set_FB(HW.pFB);
5355
if (_1)
5456
{
5557
buffers[cnt++] = GL_COLOR_ATTACHMENT0;
@@ -73,20 +75,24 @@ void CRenderTarget::u_setrt(u32 W, u32 H, GLuint _1, GLuint _2, GLuint _3, GLuin
7375
dwHeight = H;
7476
GLuint cnt = 0;
7577
GLenum buffers[3] = { GL_NONE };
76-
if (_1 == HW.pBaseRT) buffers[cnt++] = GL_BACK;
77-
else if (_1)
78+
if (_1 == HW.pBaseRT)
79+
{
80+
RCache.set_FB();
81+
return;
82+
}
83+
84+
RCache.set_FB(HW.pFB);
85+
if (_1)
7886
{
7987
buffers[cnt++] = GL_COLOR_ATTACHMENT0;
8088
RCache.set_RT(_1, 0);
8189
}
82-
if (_2 == HW.pBaseRT) buffers[cnt++] = GL_BACK;
83-
else if (_2)
90+
if (_2)
8491
{
8592
buffers[cnt++] = GL_COLOR_ATTACHMENT1;
8693
RCache.set_RT(_2, 1);
8794
}
88-
if (_3 == HW.pBaseRT) buffers[cnt++] = GL_BACK;
89-
else if (_3)
95+
if (_3)
9096
{
9197
buffers[cnt++] = GL_COLOR_ATTACHMENT2;
9298
RCache.set_RT(_3, 2);
@@ -815,7 +821,7 @@ CRenderTarget::CRenderTarget ()
815821
// Autogen mipmaps
816822
glGenTextures(1, &t_noise_surf_mipped);
817823
CHK_GL(glBindTexture(GL_TEXTURE_2D, t_noise_surf_mipped));
818-
CHK_GL(glTexStorage2D(GL_TEXTURE_2D, 0, GL_RGBA8, TEX_jitter, TEX_jitter));
824+
CHK_GL(glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, TEX_jitter, TEX_jitter));
819825
t_noise_mipped = RImplementation.Resources->_CreateTexture(r2_jitter_mipped);
820826
t_noise_mipped->surface_set(GL_TEXTURE_2D, t_noise_surf_mipped);
821827

0 commit comments

Comments
 (0)