X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_gate.h;h=21cabe9d22150fdd79ff29666b2a3a32a8c019dc;hb=5ecf9cca8b5b9bf876d7e7c7fde03d5b187bb42b;hp=8434fb1e6c27a3ed45c6515478766dd319b07ad6;hpb=c2d67378dd5c82de50b8fbbbe222ec6be2da4eee;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_gate.h b/world_gate.h index 8434fb1..21cabe9 100644 --- a/world_gate.h +++ b/world_gate.h @@ -1,27 +1,34 @@ +/* + * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved + */ + #ifndef WORLD_GATE_H #define WORLD_GATE_H +#define GATE_RENDER_PERFORMANCE + #include "common.h" #include "model.h" #include "render.h" -#include "shaders/gate.h" -#include "shaders/gatelq.h" + +#ifndef GATE_RENDER_PERFORMANCE + #include "shaders/gate.h" +#else + #include "shaders/gatelq.h" +#endif + #include "world_water.h" + typedef struct teleport_gate teleport_gate; static struct { struct framebuffer fb; glmesh mdl; - - int high_qual; /* If in high performance mode, we don't use RT's, and - instead use stencil buffers. - There is therefore no heat warp effect. */ } grender = { - .high_qual = 0, .fb = { .format = GL_RGB, .div = 1 @@ -42,40 +49,24 @@ static void gate_transform_update( teleport_gate *gate ) m4x3_mul( gate->recv_to_world, to_local, gate->transport ); } -static int world_gates_init(void) +static void world_gates_init(void) { vg_info( "world_gates_init\n" ); + +#ifndef GATE_RENDER_PERFORMANCE shader_gate_register(); +#else shader_gatelq_register(); +#endif mdl_header *mgate = mdl_load( "models/rs_gate.mdl" ); - if( vg_acquire_thread_sync(1) ) + vg_acquire_thread_sync(); { - if( !fb_init( &grender.fb ) ) - { - free( mgate ); - vg_release_thread_sync(1); - return 0; - } - - if( !mdl_unpack_glmesh( mgate, &grender.mdl ) ) - { - free( mgate ); - fb_free( &grender.fb ); - vg_release_thread_sync(1); - return 0; - } - - vg_release_thread_sync(1); + fb_init( &grender.fb ); + mdl_unpack_glmesh( mgate, &grender.mdl ); } - else - { - free( mgate ); - return 0; - } - - return 1; + vg_release_thread_sync(); } static void world_gates_free(void*_) @@ -146,22 +137,19 @@ static int render_gate( teleport_gate *gate, v3f viewpos, m4x3f camera ) m4x4_mul( projection, view, projection ); - if( grender.high_qual ) - { +#ifndef GATE_RENDER_PERFORMANCE fb_use( &grender.fb ); glClearColor( 0.11f, 0.35f, 0.37f, 1.0f ); glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT ); - } - else - { +#else shader_gatelq_use(); - shader_gatelq_uPv( vg_pv ); + shader_gatelq_uPv( vg.pv ); shader_gatelq_uMdl( gate_xform ); shader_gatelq_uCam( viewpos ); - shader_gatelq_uTime( vg_time*0.25f ); + shader_gatelq_uTime( vg.time*0.25f ); shader_gatelq_uInvRes( (v2f){ - 1.0f / (float)vg_window_x, - 1.0f / (float)vg_window_y }); + 1.0f / (float)vg.window_x, + 1.0f / (float)vg.window_y }); glEnable( GL_STENCIL_TEST ); glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE ); @@ -174,14 +162,14 @@ static int render_gate( teleport_gate *gate, v3f viewpos, m4x3f camera ) glClear( GL_DEPTH_BUFFER_BIT ); glStencilFunc( GL_EQUAL, 1, 0xFF ); glStencilMask( 0x00 ); - } +#endif render_world( projection, cam_new ); - if( grender.high_qual ) - { +#ifndef GATE_RENDER_PERFORMANCE + /* - * TODO: Need to find a way to draw a stencil buffer into the water + * NOTE: Need to find a way to draw a stencil buffer into the water * rendering */ @@ -214,9 +202,7 @@ static int render_gate( teleport_gate *gate, v3f viewpos, m4x3f camera ) mesh_draw( &grender.mdl ); glDisable(GL_BLEND); - } - else - { +#else glDisable( GL_STENCIL_TEST ); render_water_texture( cam_new ); @@ -228,7 +214,7 @@ static int render_gate( teleport_gate *gate, v3f viewpos, m4x3f camera ) glStencilMask( 0xFF ); glStencilFunc( GL_ALWAYS, 1, 0xFF ); glDisable( GL_STENCIL_TEST ); - } +#endif return 1; }