From e4cc84d5b38efea2dc0f763ad4ffbb0bab47797d Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 18 Aug 2012 21:54:31 +0000 Subject: [PATCH] gpu: finalise the framebuffer object Direct3D implementation. --- src/gpu/framebuffer.cpp | 2 +- tutorial/08_fbo.lolfx | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/gpu/framebuffer.cpp b/src/gpu/framebuffer.cpp index 816d710a..2d66fcf8 100644 --- a/src/gpu/framebuffer.cpp +++ b/src/gpu/framebuffer.cpp @@ -64,7 +64,7 @@ FrameBuffer::FrameBuffer(ivec2 size) #if defined USE_D3D9 || defined _XBOX if (FAILED(g_d3ddevice->CreateTexture(size.x, size.y, 1, D3DUSAGE_RENDERTARGET, - D3DFMT_R8G8B8, D3DPOOL_DEFAULT, + D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_data->m_texture, NULL))) Abort(); if (FAILED(m_data->m_texture->GetSurfaceLevel(0, &m_data->m_surface))) diff --git a/tutorial/08_fbo.lolfx b/tutorial/08_fbo.lolfx index 70ccb453..f2d6f3f3 100644 --- a/tutorial/08_fbo.lolfx +++ b/tutorial/08_fbo.lolfx @@ -53,15 +53,40 @@ void main(void) -- HLSL.Vert -- void main(float2 in_Position : POSITION, + out float2 pass_Position : TEXCOORD0, out float4 out_Position : POSITION) { + pass_Position = in_Position; out_Position = float4(in_Position, 0.0, 1.0); } -- HLSL.Frag -- -void main(out float4 out_FragColor : COLOR) +void main(in float2 pass_Position : TEXCOORD0, + uniform sampler2D in_Texture, + uniform float in_Flag, + uniform float3 in_Point, + uniform float3 in_Color, + out float4 out_FragColor : COLOR) { - out_FragColor = float4(0.7, 0.2, 0.5, 1.0); + if (in_Flag == 0.0) + { + 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; + 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; + ta += 3.0 * u * u - 2.0 * u * u * u; + } + + out_FragColor = float4(tc * in_Color, ta + 0.1); + } + else + { + float2 texcoords = pass_Position * 0.5 + float2(0.5, 0.5); + out_FragColor = float4(tex2D(in_Texture, texcoords).xyz, 1.0); + } }