medfall

A super great game engine
Log | Files | Refs

commit 9aa29a6e5d221d0afd962a7d9a3fdd16b0cea2d8
parent 0422929f211ca7886b1ff12fbb92651ce233642c
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat, 13 Oct 2018 00:15:22 +0900

Add a fullscreen pass helper

Diffstat:
renderer.cc | 17+++++++++++++++++
renderer.h | 2++
2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/renderer.cc b/renderer.cc @@ -77,6 +77,7 @@ static u8 * uniforms_buffer; static size_t uniforms_offset; static Texture blue_noise; +static Mesh fullscreen_triangle; static RenderState previous_render_state; static FramebufferObject previous_fbo; @@ -99,11 +100,23 @@ void renderer_init() { ubo_offset_alignment = checked_cast< size_t >( alignment ); blue_noise = load_png_memory( blue_noise_png, blue_noise_png_len, TEXFMT_R_U8NORM, 1 ); + + v3 tri[] = { + v3( -1.0f, -1.0f, 0.0f ), + v3( 3.0f, -1.0f, 0.0f ), + v3( -1.0f, 3.0f, 0.0f ), + }; + MeshConfig config; + config.positions = renderer_new_vb( tri, sizeof( tri ) ); + config.num_vertices = 3; + config.primitive_type = PRIMITIVETYPE_TRIANGLES; + fullscreen_triangle = renderer_new_mesh( config ); } void renderer_term() { glDeleteBuffers( 1, &uniforms ); renderer_delete_texture( blue_noise ); + renderer_delete_mesh( fullscreen_triangle ); } void renderer_begin_frame() { @@ -1047,3 +1060,7 @@ void renderer_draw_instances( const Mesh & mesh, const RenderState & render_stat draw_calls_this_frame++; vertices_this_frame += mesh.num_vertices * num_instances; } + +void renderer_draw_fullscreen_triangle( const RenderState & render_state ) { + renderer_draw_mesh( fullscreen_triangle, render_state ); +} diff --git a/renderer.h b/renderer.h @@ -241,6 +241,8 @@ void renderer_draw_mesh( const Mesh & mesh, const RenderState & state ); void renderer_draw_instances( const Mesh & mesh, const RenderState & state, u32 num_instances, VB instace_data ); void renderer_delete_mesh( const Mesh & mesh ); +void renderer_draw_fullscreen_triangle( const RenderState & state ); + /* * renderer_new_*( array ) helpers */