diff --git a/src/gpu/line.lolfx b/src/gpu/line.lolfx index a225c965..deac8552 100644 --- a/src/gpu/line.lolfx +++ b/src/gpu/line.lolfx @@ -2,9 +2,9 @@ #version 130 -attribute vec4 in_Position; -attribute vec4 in_Color; -varying vec4 pass_Color; +in vec4 in_Position; +in vec4 in_Color; +out vec4 pass_color; uniform mat4 u_projection; uniform mat4 u_view; @@ -16,7 +16,7 @@ void main() else gl_Position = u_projection * u_view * vec4(in_Position.xyz, 1.0); - pass_Color = in_Color; + pass_color = in_Color; } [frag.glsl] @@ -27,31 +27,11 @@ void main() precision mediump float; #endif -varying vec4 pass_Color; +in vec4 pass_color; +out vec4 out_color; void main() { - gl_FragColor = pass_Color; -} - -[vert.hlsl] - -void main(float4 in_Position : POSITION, - float4 in_Color : COLOR, - uniform float4x4 u_projection, - uniform float4x4 u_view, - out float4 out_Color : COLOR, - out float4 out_Position : POSITION) -{ - out_Position = mul(u_projection, mul(u_view, in_Position)); - out_Color = in_Color; -} - -[frag.hlsl] - -void main(float4 in_Color : COLOR, - out float4 out_FragColor : COLOR) -{ - out_FragColor = in_Color; + out_color = pass_color; } diff --git a/src/gpu/postprocess.lolfx b/src/gpu/postprocess.lolfx index c3efbd60..a4810768 100644 --- a/src/gpu/postprocess.lolfx +++ b/src/gpu/postprocess.lolfx @@ -26,8 +26,9 @@ varying vec2 pass_Position; void main(void) { - vec2 texcoords = pass_Position * 0.5 + vec2(0.5, 0.5); - texcoords += 0.02 * sin(0.05 * gl_FragCoord.xy); + vec2 pos = pass_Position; + + vec2 texcoords = pos * 0.5 + vec2(0.5, 0.5); vec4 color = vec4(texture2D(u_texture, texcoords).rgb, 1.0); gl_FragColor = color; } diff --git a/src/gpu/tile.lolfx b/src/gpu/tile.lolfx index 26743852..dc1abd62 100644 --- a/src/gpu/tile.lolfx +++ b/src/gpu/tile.lolfx @@ -2,9 +2,9 @@ #version 130 -attribute vec3 in_Position; -attribute vec2 in_TexCoord; -varying vec2 pass_TexCoord; +in vec3 in_Position; +in vec2 in_TexCoord; +out vec2 pass_texcoord; uniform mat4 u_projection; uniform mat4 u_view; @@ -14,7 +14,7 @@ void main() { gl_Position = u_projection * u_view * u_model * vec4(in_Position, 1.0); - pass_TexCoord = in_TexCoord; + pass_texcoord = in_TexCoord; } [frag.glsl] @@ -25,41 +25,17 @@ void main() precision mediump float; #endif +in vec2 pass_texcoord; +out vec4 out_color; + uniform sampler2D u_texture; uniform vec2 u_texsize; -varying vec2 pass_TexCoord; void main() { - vec4 col = texture2D(u_texture, pass_TexCoord); + vec4 col = texture2D(u_texture, pass_texcoord); if (col.a == 0.0) discard; - gl_FragColor = col; -} - -[vert.hlsl] - -void main(float4 in_Position : POSITION, - float2 in_TexCoord : TEXCOORD0, - uniform float4x4 u_projection, - uniform float4x4 u_view, - uniform float4x4 u_model, - uniform float2 u_texsize, - out float2 out_TexCoord : TEXCOORD0, - out float4 out_Position : POSITION) -{ - float2 delta = float2(0.0, 0.0); - out_Position = mul(u_projection, mul(u_view, mul(u_model, in_Position))); - out_TexCoord = in_TexCoord + delta; -} - -[frag.hlsl] - -void main(float2 in_TexCoord : TEXCOORD0, - uniform sampler2D u_texture, - out float4 out_FragColor : COLOR) -{ - float4 col = tex2D(u_texture, in_TexCoord); - out_FragColor = col; + out_color = col; } diff --git a/src/scene.cpp b/src/scene.cpp index 10cad82c..7c2a4662 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2015 Sam Hocevar +// Copyright © 2010—2016 Sam Hocevar // © 2014—2015 Benjamin “Touky” Huet // // Lol Engine is free software. It comes without any warranty, to @@ -51,6 +51,14 @@ struct Tile //----------------------------------------------------------------------------- static array m_scene_displays; +static inline void gpu_marker(char const *message) +{ +#if USE_GLEW + if (GLEW_GREMEDY_string_marker) + glStringMarkerGREMEDY(0, message); +#endif +} + /* * Public SceneDisplay class */ @@ -607,12 +615,22 @@ void Scene::DisableDisplay() /* Render everything that the scene contains */ void Scene::render(float seconds) { + bool do_pp = true; + + gpu_marker("Start Render"); + /* First render into the offline buffer */ - data->m_backbuffer->Bind(); + if (do_pp) + data->m_backbuffer->Bind(); + { RenderContext rc; - rc.SetClearColor(vec4(0.f, 0.f, 0.f, 1.f)); - rc.SetClearDepth(1.f); + if (do_pp) + { + rc.SetClearColor(vec4(0.f, 0.f, 0.f, 1.f)); + rc.SetClearDepth(1.f); + } + Renderer::Get()->Clear(ClearMask::Color | ClearMask::Depth); // FIXME: get rid of the delta time argument @@ -620,16 +638,24 @@ void Scene::render(float seconds) render_tiles(); render_lines(seconds); } - data->m_backbuffer->Unbind(); - - /* Now blit the offline buffer */ - data->m_pp.m_shader->Bind(); - data->m_pp.m_shader->SetUniform(data->m_pp.m_texture, data->m_backbuffer->GetTextureUniform(), 0); - data->m_pp.m_vdecl->SetStream(data->m_pp.m_vbo, data->m_pp.m_coord); - data->m_pp.m_vdecl->Bind(); - data->m_pp.m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 6); - data->m_pp.m_vdecl->Unbind(); - data->m_pp.m_shader->Unbind(); + + if (do_pp) + { + data->m_backbuffer->Unbind(); + + gpu_marker("PostProcess"); + + /* Now blit the offline buffer */ + data->m_pp.m_shader->Bind(); + data->m_pp.m_shader->SetUniform(data->m_pp.m_texture, data->m_backbuffer->GetTextureUniform(), 0); + data->m_pp.m_vdecl->SetStream(data->m_pp.m_vbo, data->m_pp.m_coord); + data->m_pp.m_vdecl->Bind(); + data->m_pp.m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 6); + data->m_pp.m_vdecl->Unbind(); + data->m_pp.m_shader->Unbind(); + } + + gpu_marker("End Render"); } //-----------------------------------------------------------------------------