commit e83c7117f6d7d2b7b14debbe3507257d3341bead parent 35e286f909100219a8400f6b79b41cf0fdb02bbe Author: Michael Savage <mikejsavage@gmail.com> Date: Wed Aug 31 21:28:45 -0700 Add immediate_aabb Diffstat:
immediate.cc | | | 24 | ++++++++++++++++++++++++ |
immediate.h | | | 11 | +++++++---- |
diff --git a/immediate.cc b/immediate.cc @@ -102,6 +102,30 @@ 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_render( const ImmediateContext * ctx, GLint at_position, GLint at_colour, diff --git a/immediate.h b/immediate.h @@ -27,14 +27,17 @@ void immediate_triangle( ImmediateContext * ctx, void immediate_triangle( ImmediateContext * ctx, ImmediateVertex v1, ImmediateVertex v2, ImmediateVertex v3 ); -void immediate_render( const ImmediateContext * ctx, - GLint at_position, GLint at_colour, - bool textured = false, GLint at_uv = 0, GLint un_texture = 0 ); - void immediate_sphere( ImmediateContext * ctx, glm::vec3 centre, float radius, glm::vec4 colour, u32 subdivisions = 16 ); +void immediate_aabb( ImmediateContext * ctx, + glm::vec3 mins, glm::vec3 maxs, glm::vec4 colour ); + +void immediate_render( const ImmediateContext * ctx, + GLint at_position, GLint at_colour, + bool textured = false, GLint at_uv = 0, GLint un_texture = 0 ); + void immediate_clear( ImmediateContext * ctx ); #endif // _IMMEDIATE_H_