medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 3eef4511ce3f6906aafb553c691339ab509e35a7
parent 067b69953ec3a1a8056ee1602893b498313a46a3
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Tue Nov 15 00:00:39 +0200

Drop glm from immediate renderer

Diffstat:
bsp.cc | 34+++++++++++++++++-----------------
hm.cc | 38+++++++++++++++++++-------------------
immediate.cc | 119+++++++++++++++++++++++++++++++++++++++----------------------------------------
immediate.h | 21++++++++++-----------
linear_algebra.h | 12++++++++++++
mod_btt.cc | 14+++++++-------
shadow_map.cc | 18+++++++++---------
7 files changed, 133 insertions(+), 123 deletions(-)
diff --git a/bsp.cc b/bsp.cc @@ -164,30 +164,30 @@ bool BSP::trace_seg_brush( const BSP_Brush & brush, const glm::vec3 start, const const float t = start_dist / denom; if( t >= tmin && t <= tmax ) { - glm::vec4 colour = glm::vec4( 0, 0, 1, 1 ); + v4 colour = v4( 0, 0, 1, 1 ); // TODO: if we are exiting the brush we want the nearest collision if( start_dist >= 0.0f ) { if( t >= tfar ) { tfar = t; hit = true; - colour = glm::vec4( 1, 1, 1, 1 ); + colour = v4( 1, 1, 1, 1 ); } } else if( t <= tnear ) { tnear = t; hit = true; - colour = glm::vec4( 0, 0, 0, 1 ); + colour = v4( 0, 0, 0, 1 ); } - immediate_sphere( &imm, start + t * dir, 8, colour, 8 ); + immediate_sphere( &imm, GLMV3( start + t * dir ), 8, colour, 8 ); } else - immediate_sphere( &imm, start + t * dir, 8, glm::vec4( 0.5, 0.5, 0.5, 1 ), 8 ); + immediate_sphere( &imm, GLMV3( start + t * dir ), 8, v4( 0.5, 0.5, 0.5, 1 ), 8 ); } - glm::vec4 colour = glm::vec4( 1, 0, 1, 1 ); - if( tnear >= tfar ) colour = glm::vec4( 1, 1, 0, 1 ); + v4 colour = v4( 1, 0, 1, 1 ); + if( tnear >= tfar ) colour = v4( 1, 1, 0, 1 ); - if( hit ) immediate_sphere( &imm, start + tfar * dir, 16, colour ); + if( hit ) immediate_sphere( &imm, GLMV3( start + tfar * dir ), 16, colour ); if( hit ) { if( !starts_inside ) { if( tfar <= tnear ) { @@ -261,7 +261,7 @@ void BSP::trace_seg_tree( const s32 node_idx, const glm::vec3 start, const glm:: // otherwise we straddle the plane check_both_sides = true; t = unchecked_t; - immediate_sphere( &imm, start + t * dir, 8, glm::vec4( 0, 1, 0, 1 ), 8 ); + immediate_sphere( &imm, GLMV3( start + t * dir ), 8, v4( 0, 1, 0, 1 ), 8 ); } } } @@ -379,7 +379,7 @@ extern "C" GAME_FRAME( game_frame ) { bspr_render( &game->bspr, GLMV3( game->pos ), render_state ); immediate_init( &imm, triangles, ARRAY_COUNT( triangles ) ); - immediate_sphere( &imm, glm::vec3( 0, 0, 0 ), 128, glm::vec4( 1, 1, 0, 1 ) ); + immediate_sphere( &imm, v3( 0, 0, 0 ), 128, v4( 1, 1, 0, 1 ) ); if( input->keys[ 't' ] ) { fix = true; @@ -392,7 +392,7 @@ extern "C" GAME_FRAME( game_frame ) { bool hit = game->bspr.bsp->trace_seg( fix_start, fix_end, is ); if( hit ) { - immediate_sphere( &imm, is.pos, 16, glm::vec4( 1, 0, 0, 1 ) ); + immediate_sphere( &imm, GLMV3( is.pos ), 16, v4( 1, 0, 0, 1 ) ); } } @@ -403,11 +403,11 @@ extern "C" GAME_FRAME( game_frame ) { glGenTextures( 1, &tex ); glBindTexture( GL_TEXTURE_2D, tex ); - const glm::vec4 checkerboard[] = { - glm::vec4( 0, 0, 0, 0.5 ), - glm::vec4( 1, 1, 1, 0.5 ), - glm::vec4( 1, 1, 1, 0.5 ), - glm::vec4( 0, 0, 0, 0.5 ), + const v4 checkerboard[] = { + v4( 0, 0, 0, 0.5 ), + v4( 1, 1, 1, 0.5 ), + v4( 1, 1, 1, 0.5 ), + v4( 0, 0, 0, 0.5 ), }; TextureConfig texture_config = { }; texture_config.width = 2; @@ -416,7 +416,7 @@ extern "C" GAME_FRAME( game_frame ) { Texture texture = renderer_new_texture( texture_config ); const float aspect = 640.0f / 480.0f; - const glm::vec4 white( 1, 1, 1, 1 ); + const v4 white( 1, 1, 1, 1 ); const int num_checks = 20; v3 positions[] = { diff --git a/hm.cc b/hm.cc @@ -139,29 +139,29 @@ extern "C" GAME_INIT( game_init ) { const float crosshair_thickness = 0.0025; const float crosshair_length = 0.01; - const glm::vec4 red( 1, 0, 0, 1 ); + const v4 red( 1, 0, 0, 1 ); immediate_triangle( &game->test_immediate, - glm::vec3( -crosshair_length, -crosshair_thickness, 0 ), - glm::vec3( -crosshair_length, crosshair_thickness, 0 ), - glm::vec3( crosshair_length, crosshair_thickness, 0 ), + v3( -crosshair_length, -crosshair_thickness, 0 ), + v3( -crosshair_length, crosshair_thickness, 0 ), + v3( crosshair_length, crosshair_thickness, 0 ), red ); immediate_triangle( &game->test_immediate, - glm::vec3( crosshair_length, crosshair_thickness, 0 ), - glm::vec3( crosshair_length, -crosshair_thickness, 0 ), - glm::vec3( -crosshair_length, -crosshair_thickness, 0 ), + v3( crosshair_length, crosshair_thickness, 0 ), + v3( crosshair_length, -crosshair_thickness, 0 ), + v3( -crosshair_length, -crosshair_thickness, 0 ), red ); immediate_triangle( &game->test_immediate, - glm::vec3( -crosshair_thickness / aspect, crosshair_length * aspect, 0 ), - glm::vec3( crosshair_thickness / aspect, crosshair_length * aspect, 0 ), - glm::vec3( crosshair_thickness / aspect, -crosshair_length * aspect, 0 ), + v3( -crosshair_thickness / aspect, crosshair_length * aspect, 0 ), + v3( crosshair_thickness / aspect, crosshair_length * aspect, 0 ), + v3( crosshair_thickness / aspect, -crosshair_length * aspect, 0 ), red ); immediate_triangle( &game->test_immediate, - glm::vec3( crosshair_thickness / aspect, -crosshair_length * aspect, 0 ), - glm::vec3( -crosshair_thickness / aspect, -crosshair_length * aspect, 0 ), - glm::vec3( -crosshair_thickness / aspect, crosshair_length * aspect, 0 ), + v3( crosshair_thickness / aspect, -crosshair_length * aspect, 0 ), + v3( -crosshair_thickness / aspect, -crosshair_length * aspect, 0 ), + v3( -crosshair_thickness / aspect, crosshair_length * aspect, 0 ), red ); @@ -214,8 +214,8 @@ static void draw_string( const GameState * game, const char * str, const GLint at_pos, const GLint at_colour, const GLint at_uv, const GLint un_atlas ) { - const float scale = 1.0f / 32.0f / 5.0f; - const glm::vec4 white( 1, 1, 1, 1 ); + const float scale = 1.0f / 32.0f / 15.0f; + const v4 white( 1, 1, 1, 1 ); ImmediateContext imm; ImmediateTriangle triangles[ 256 ]; @@ -227,10 +227,10 @@ static void draw_string( const GameState * game, stbtt_aligned_quad q; stbtt_GetBakedQuad( game->test_chars, 512, 256, *str - ' ', &x, &y, &q, 1 ); - const ImmediateVertex v1A = { glm::vec3( q.x0 * scale, -q.y0 * scale, 0 ), white, glm::vec2( q.s0, q.t0 ) }; - const ImmediateVertex v2A = { glm::vec3( q.x1 * scale, -q.y0 * scale, 0 ), white, glm::vec2( q.s1, q.t0 ) }; - const ImmediateVertex v3A = { glm::vec3( q.x0 * scale, -q.y1 * scale, 0 ), white, glm::vec2( q.s0, q.t1 ) }; - const ImmediateVertex v4A = { glm::vec3( q.x1 * scale, -q.y1 * scale, 0 ), white, glm::vec2( q.s1, q.t1 ) }; + const ImmediateVertex v1A = { v3( q.x0 * scale, -q.y0 * scale, 0 ), white, v2( q.s0, q.t0 ) }; + const ImmediateVertex v2A = { v3( q.x1 * scale, -q.y0 * scale, 0 ), white, v2( q.s1, q.t0 ) }; + const ImmediateVertex v3A = { v3( q.x0 * scale, -q.y1 * scale, 0 ), white, v2( q.s0, q.t1 ) }; + const ImmediateVertex v4A = { v3( q.x1 * scale, -q.y1 * scale, 0 ), white, v2( q.s1, q.t1 ) }; immediate_triangle( &imm, v1A, v2A, v3A ); immediate_triangle( &imm, v3A, v2A, v4A ); diff --git a/immediate.cc b/immediate.cc @@ -1,9 +1,9 @@ #include <math.h> #include "glad.h" -#include <glm/glm.hpp> #include "intrinsics.h" +#include "linear_algebra.h" #include "immediate.h" void immediate_init( ImmediateContext * ctx, ImmediateTriangle * memory, size_t max_triangles ) { @@ -12,18 +12,14 @@ void immediate_init( ImmediateContext * ctx, ImmediateTriangle * memory, size_t ctx->max_triangles = max_triangles; } -void immediate_triangle( - ImmediateContext * ctx, - glm::vec3 v1, glm::vec3 v2, glm::vec3 v3, - glm::vec4 colour -) { +void immediate_triangle( ImmediateContext * ctx, v3 p1, v3 p2, v3 p3, v4 colour ) { assert( ctx->num_triangles < ctx->max_triangles - 1 ); - glm::vec2 uv; + v2 uv( 0, 0 ); ImmediateTriangle triangle = { { - { v1, colour, uv }, - { v2, colour, uv }, - { v3, colour, uv }, + { p1, colour, uv }, + { p2, colour, uv }, + { p3, colour, uv }, } }; ctx->triangles[ ctx->num_triangles++ ] = triangle; @@ -41,8 +37,8 @@ void immediate_triangle( } void immediate_sphere( - ImmediateContext * ctx, glm::vec3 centre, float radius, - glm::vec4 colour, u32 subdivisions + ImmediateContext * ctx, v3 centre, float radius, + v4 colour, u32 subdivisions ) { const float azimuth_max = 2.0f * M_PI; const float pitch_max = M_PI; @@ -64,25 +60,25 @@ void immediate_sphere( float cp1 = dcp; for( u32 p = 0; p < subdivisions; p++ ) { - glm::vec3 top_left = centre + glm::vec3( + v3 top_left = centre + v3( radius * ca0 * sp0, radius * sa0 * sp0, radius * cp0 ); - glm::vec3 top_right = centre + glm::vec3( + v3 top_right = centre + v3( radius * ca1 * sp0, radius * sa1 * sp0, radius * cp0 ); - glm::vec3 bottom_left = centre + glm::vec3( + v3 bottom_left = centre + v3( radius * ca0 * sp1, radius * sa0 * sp1, radius * cp1 ); - glm::vec3 bottom_right = centre + glm::vec3( + v3 bottom_right = centre + v3( radius * ca1 * sp1, radius * sa1 * sp1, radius * cp1 @@ -104,32 +100,32 @@ void immediate_sphere( } } -void immediate_aabb( ImmediateContext * ctx, glm::vec3 mins, glm::vec3 maxs, glm::vec4 colour ) { - const glm::vec3 v0( mins.x, mins.y, mins.z ); - const glm::vec3 v1( maxs.x, mins.y, mins.z ); - const glm::vec3 v2( mins.x, maxs.y, mins.z ); - const glm::vec3 v3( maxs.x, maxs.y, mins.z ); - const glm::vec3 v4( mins.x, mins.y, maxs.z ); - const glm::vec3 v5( maxs.x, mins.y, maxs.z ); - const glm::vec3 v6( mins.x, maxs.y, maxs.z ); - const glm::vec3 v7( maxs.x, maxs.y, maxs.z ); - - immediate_triangle( ctx, v0, v1, v2, colour ); // bottom - immediate_triangle( ctx, v1, v3, v2, colour ); - immediate_triangle( ctx, v4, v6, v5, colour ); // top - immediate_triangle( ctx, v6, v7, v5, colour ); - immediate_triangle( ctx, v2, v6, v0, colour ); // left - immediate_triangle( ctx, v6, v4, v0, colour ); - immediate_triangle( ctx, v1, v5, v3, colour ); // right - immediate_triangle( ctx, v5, v7, v3, colour ); - immediate_triangle( ctx, v0, v4, v1, colour ); // front - immediate_triangle( ctx, v4, v5, v1, colour ); - immediate_triangle( ctx, v3, v7, v2, colour ); // back - immediate_triangle( ctx, v7, v6, v2, colour ); +void immediate_aabb( ImmediateContext * ctx, v3 mins, v3 maxs, v4 colour ) { + const v3 p0( mins.x, mins.y, mins.z ); + const v3 p1( maxs.x, mins.y, mins.z ); + const v3 p2( mins.x, maxs.y, mins.z ); + const v3 p3( maxs.x, maxs.y, mins.z ); + const v3 p4( mins.x, mins.y, maxs.z ); + const v3 p5( maxs.x, mins.y, maxs.z ); + const v3 p6( mins.x, maxs.y, maxs.z ); + const v3 p7( maxs.x, maxs.y, maxs.z ); + + immediate_triangle( ctx, p0, p1, p2, colour ); // bottom + immediate_triangle( ctx, p1, p3, p2, colour ); + immediate_triangle( ctx, p4, p6, p5, colour ); // top + immediate_triangle( ctx, p6, p7, p5, colour ); + immediate_triangle( ctx, p2, p6, p0, colour ); // left + immediate_triangle( ctx, p6, p4, p0, colour ); + immediate_triangle( ctx, p1, p5, p3, colour ); // right + immediate_triangle( ctx, p5, p7, p3, colour ); + immediate_triangle( ctx, p0, p4, p1, colour ); // front + immediate_triangle( ctx, p4, p5, p1, colour ); + immediate_triangle( ctx, p3, p7, p2, colour ); // back + immediate_triangle( ctx, p7, p6, p2, colour ); } -static glm::mat3 about_with_sin_cos( glm::vec3 axis, float s, float c ) { - return glm::mat3( +static m3 about_with_sin_cos( v3 axis, float s, float c ) { + return m3( axis.x * axis.x + ( 1.0 - axis.x * axis.x ) * c, axis.x * axis.y * ( 1.0 - c ) - axis.z * s, axis.x * axis.z * ( 1.0 - c ) + axis.y * s, @@ -142,39 +138,42 @@ static glm::mat3 about_with_sin_cos( glm::vec3 axis, float s, float c ) { ); } -static glm::mat3 rotation_between( glm::vec3 from, glm::vec3 to ) { - if( from == to ) return glm::mat3(); - if( from == -to ) return -glm::mat3(); +static m3 rotation_between( v3 from, v3 to ) { + if( from == to ) return m3_identity(); + if( from == -to ) return -m3_identity(); - glm::vec3 axis = glm::normalize( glm::cross( from, to ) ); - float cos_theta = glm::dot( from, to ); + v3 axis = normalize( cross( from, to ) ); + float cos_theta = dot( from, to ); // TODO: why is this -????? float sin_theta = -sqrtf( 1.0f - cos_theta * cos_theta ); return about_with_sin_cos( axis, sin_theta, cos_theta ); } -void immediate_arrow( ImmediateContext * ctx, glm::vec3 origin, glm::vec3 direction, float length, glm::vec4 colour ) { - glm::vec3 v[] = { +void immediate_arrow( + ImmediateContext * ctx, + v3 origin, v3 direction, float length, v4 colour +) { + v3 v[] = { // base of stick - glm::vec3( -0.05, -0.05, 0 ), - glm::vec3( 0.05, -0.05, 0 ), - glm::vec3( -0.05, 0.05, 0 ), - glm::vec3( 0.05, 0.05, 0 ), + v3( -0.05, -0.05, 0 ), + v3( 0.05, -0.05, 0 ), + v3( -0.05, 0.05, 0 ), + v3( 0.05, 0.05, 0 ), // top of stick - glm::vec3( -0.05, -0.05, 0.6 ), - glm::vec3( 0.05, -0.05, 0.6 ), - glm::vec3( -0.05, 0.05, 0.6 ), - glm::vec3( 0.05, 0.05, 0.6 ), + v3( -0.05, -0.05, 0.6 ), + v3( 0.05, -0.05, 0.6 ), + v3( -0.05, 0.05, 0.6 ), + v3( 0.05, 0.05, 0.6 ), // point - glm::vec3( 0, 0, 1 ), - glm::vec3( 0, 0, 0.6 ), + v3( 0, 0, 1 ), + v3( 0, 0, 0.6 ), }; const size_t CONE_SUBDIVISIONS = 8; - glm::vec3 cone[ CONE_SUBDIVISIONS ]; + v3 cone[ CONE_SUBDIVISIONS ]; // TODO: do the fast sin/cos thing // TODO: make a helper function to do it that fills in an array of floats @@ -182,10 +181,10 @@ void immediate_arrow( ImmediateContext * ctx, glm::vec3 origin, glm::vec3 direct float s = sinf( float( i ) / float( array_count( cone ) ) * 2.0f * M_PI ); float c = cosf( float( i ) / float( array_count( cone ) ) * 2.0f * M_PI ); - cone[ i ] = glm::vec3( 0.2f * c, 0.2f * s, 0.6 ); + cone[ i ] = v3( 0.2f * c, 0.2f * s, 0.6 ); } - glm::mat3 rot = rotation_between( glm::vec3( 0, 0, 1 ), glm::normalize( direction ) ); + m3 rot = rotation_between( v3( 0, 0, 1 ), normalize( direction ) ); for( size_t i = 0; i < array_count( v ); i++ ) { v[ i ] = ( rot * v[ i ] ) * length + origin; diff --git a/immediate.h b/immediate.h @@ -1,12 +1,13 @@ #ifndef _IMMEDIATE_H_ #define _IMMEDIATE_H_ -#include <glm/glm.hpp> +#include "glad.h" +#include "linear_algebra.h" struct ImmediateVertex { - glm::vec3 pos; - glm::vec4 colour; - glm::vec2 uv; + v3 pos; + v4 colour; + v2 uv; }; struct ImmediateTriangle { @@ -22,20 +23,18 @@ struct ImmediateContext { void immediate_init( ImmediateContext * ctx, ImmediateTriangle * memory, size_t max_triangles ); -void immediate_triangle( ImmediateContext * ctx, - glm::vec3 v1, glm::vec3 v2, glm::vec3 v3, glm::vec4 colour ); +void immediate_triangle( ImmediateContext * ctx, v3 p1, v3 p2, v3 p3, v4 colour ); void immediate_triangle( ImmediateContext * ctx, ImmediateVertex v1, ImmediateVertex v2, ImmediateVertex v3 ); void immediate_sphere( ImmediateContext * ctx, - glm::vec3 centre, float radius, glm::vec4 colour, - u32 subdivisions = 16 ); + v3 centre, float radius, v4 colour, u32 subdivisions = 16 ); void immediate_aabb( ImmediateContext * ctx, - glm::vec3 mins, glm::vec3 maxs, glm::vec4 colour ); + v3 mins, v3 maxs, v4 colour ); -void immediate_arrow( ImmediateContext * ctx, glm::vec3 origin, - glm::vec3 direction, float length, glm::vec4 colour ); +void immediate_arrow( ImmediateContext * ctx, v3 origin, v3 direction, + float length, v4 colour ); void immediate_render( const ImmediateContext * ctx, GLint at_position, GLint at_colour, diff --git a/linear_algebra.h b/linear_algebra.h @@ -326,6 +326,10 @@ forceinline v3 operator-( v3 v ) { return v3( -v.x, -v.y, -v.z ); } +forceinline bool operator==( v3 lhs, v3 rhs ) { + return lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z; +} + forceinline float dot( v3 u, v3 v ) { return u.x * v.x + u.y * v.y + u.z * v.z; } @@ -444,6 +448,10 @@ forceinline v3 operator*( const m3 & m, v3 v ) { ); } +forceinline m3 operator-( const m3 & m ) { + return m3( -m.row0, -m.row1, -m.row2 ); +} + /* * v4 */ @@ -661,6 +669,10 @@ forceinline m4 operator*( const m4 & lhs, const m4 & rhs ) { ); } +forceinline m4 operator-( const m4 & m ) { + return m4( -m.row0, -m.row1, -m.row2, -m.row3 ); +} + /* * quat */ diff --git a/mod_btt.cc b/mod_btt.cc @@ -212,9 +212,9 @@ struct FSData { static void draw_qt( ImmediateContext * imm, AABBu32 aabb, const array< HeightmapQuadTreeNode > nodes, size_t node_idx ) { if( aabb.maxs.x - aabb.mins.x >= 32 ) { - glm::vec3 mins( aabb.mins.x, aabb.mins.y, aabb.mins.z ); - glm::vec3 maxs( aabb.maxs.x, aabb.maxs.y, aabb.maxs.z ); - immediate_aabb( imm, mins, maxs, glm::vec4( 0, 0, 1, 1 ) ); + v3 mins( aabb.mins.x, aabb.mins.y, aabb.mins.z ); + v3 maxs( aabb.maxs.x, aabb.maxs.y, aabb.maxs.z ); + immediate_aabb( imm, mins, maxs, v4( 0, 0, 1, 1 ) ); } else return; @@ -269,9 +269,9 @@ extern "C" GAME_FRAME( game_frame ) { immediate_init( &imm, triangles, array_count( triangles ) ); for( size_t i = 0; i < game->hm.width; i++ ) { - glm::vec3 origin = glm::vec3( i, 1, game->hm.point( i, 1 ).z ); - glm::vec3 direction = glm::normalize( glm::vec3( -1, 0, horizons[ 1 * game->hm.width + i ] ) ); - glm::vec4 white( 1, 1, 1, 1 ); + v3 origin = v3( i, 1, game->hm.point( i, 1 ).z ); + v3 direction = normalize( v3( -1, 0, horizons[ 1 * game->hm.width + i ] ) ); + v4 white( 1, 1, 1, 1 ); immediate_arrow( &imm, origin, direction, 2, white ); } glUseProgram( game->test_outline_shader ); @@ -281,7 +281,7 @@ extern "C" GAME_FRAME( game_frame ) { if( ray_vs_quadtree( &qt, GLMV3( game->pos ), GLMV3( angles_to_vector( game->angles ) ), &t ) ) { glm::vec3 impact = game->pos + angles_to_vector( game->angles ) * t; printf( "impact (%f) %f %f %f\n", t, impact.x, impact.y, impact.z ); - immediate_sphere( &imm, impact, 4, glm::vec4( 1, 0, 0, 1 ) ); + immediate_sphere( &imm, GLMV3( impact ), 4, v4( 1, 0, 0, 1 ) ); } else printf( "nope\n" ); immediate_render( &imm, game->test_outline_at_position, game->test_outline_at_colour ); diff --git a/shadow_map.cc b/shadow_map.cc @@ -79,15 +79,15 @@ static const char * depth_frag_src = GLSL( static void draw_scene( GLint at_position, GLint at_colour ) { immediate_init( &imm, triangles, array_count( triangles ) ); - immediate_sphere( &imm, glm::vec3( 0, 0, 5 ), 3, glm::vec4( 1, 0, 0, 1 ) ); - immediate_sphere( &imm, glm::vec3( -3, 7, 5 ), 2, glm::vec4( 0, 1, 0, 1 ) ); - - glm::vec3 tl( -15, 15, 0 ); - glm::vec3 tr( 15, 15, 0 ); - glm::vec3 bl( -15, -15, 0 ); - glm::vec3 br( 15, -15, 0 ); - immediate_triangle( &imm, tl, tr, bl, glm::vec4( 0.5, 0.5, 0.5, 1.0 ) ); - immediate_triangle( &imm, bl, tr, br, glm::vec4( 0.5, 0.5, 0.5, 1.0 ) ); + immediate_sphere( &imm, v3( 0, 0, 5 ), 3, v4( 1, 0, 0, 1 ) ); + immediate_sphere( &imm, v3( -3, 7, 5 ), 2, v4( 0, 1, 0, 1 ) ); + + v3 tl( -15, 15, 0 ); + v3 tr( 15, 15, 0 ); + v3 bl( -15, -15, 0 ); + v3 br( 15, -15, 0 ); + immediate_triangle( &imm, tl, tr, bl, v4( 0.5, 0.5, 0.5, 1.0 ) ); + immediate_triangle( &imm, bl, tr, br, v4( 0.5, 0.5, 0.5, 1.0 ) ); immediate_render( &imm, at_position, at_colour ); }