From 1c5cdd8c502b826acb5c257b0472e568999af7e4 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Fri, 24 Aug 2012 13:28:43 +0000 Subject: [PATCH] tutorial: fix the FBO demo on the Xbox360. --- tutorial/08_fbo.cpp | 13 +++++++++++++ tutorial/08_fbo.lolfx | 8 +++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tutorial/08_fbo.cpp b/tutorial/08_fbo.cpp index e1afe7c9..f06eb240 100644 --- a/tutorial/08_fbo.cpp +++ b/tutorial/08_fbo.cpp @@ -90,6 +90,19 @@ public: /* FIXME: we should just disable depth test in the shader */ Video::Clear(ClearMask::Depth); m_shader->Bind(); + +#if _XBOX + /* FIXME: the Xbox enforces full EDRAM clears on each frame, so + * we cannot expect the render target contents to be preserved. + * This code snippet should be moved inside the FrameBuffer class. */ + m_shader->SetUniform(m_uni_flag, 1.f); + m_shader->SetUniform(m_uni_texture, m_fbo->GetTexture(), 0); + m_vdecl->SetStream(m_vbo, m_coord); + m_vdecl->Bind(); + m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 2); + m_vdecl->Unbind(); +#endif + m_shader->SetUniform(m_uni_flag, 0.f); m_shader->SetUniform(m_uni_point, m_hotspot); m_shader->SetUniform(m_uni_color, m_color); diff --git a/tutorial/08_fbo.lolfx b/tutorial/08_fbo.lolfx index f2d6f3f3..73c0dcd0 100644 --- a/tutorial/08_fbo.lolfx +++ b/tutorial/08_fbo.lolfx @@ -34,7 +34,7 @@ void main(void) float tc = 0.0, ta = 0.0; { float s = 6.0 + 3.0 * in_Point.z; - vec2 p = pass_Position - in_Point.xy * 0.8; + vec2 p = pass_Position - in_Point.xy * 0.9; float t = clamp(1.2 - dot(s * p, s * p), 0.0, 1.0); float u = t * t * t * t; tc += 3.0 * t * t - 2.0 * t * t * t; @@ -74,7 +74,7 @@ void main(in float2 pass_Position : TEXCOORD0, float tc = 0.0, ta = 0.0; { float s = 6.0 + 3.0 * in_Point.z; - float2 p = pass_Position - in_Point.xy * 0.8; + float2 p = pass_Position - in_Point.xy * 0.9; float t = clamp(1.2 - dot(s * p, s * p), 0.0, 1.0); float u = t * t * t * t; tc += 3.0 * t * t - 2.0 * t * t * t; @@ -85,7 +85,9 @@ void main(in float2 pass_Position : TEXCOORD0, } else { - float2 texcoords = pass_Position * 0.5 + float2(0.5, 0.5); + float2 texcoords = pass_Position * float2(0.5, -0.5) + float2(0.5, 0.5); + /* FIXME: this should be passed as a uniform or something */ + texcoords += float2(0.5 / 800.0, 0.5 / 600.0); out_FragColor = float4(tex2D(in_Texture, texcoords).xyz, 1.0); } }