From: hgn Date: Thu, 2 Jun 2022 15:28:50 +0000 (+0100) Subject: maths and bugs X-Git-Url: https://harrygodden.com/git/?p=vg.git;a=commitdiff_plain;h=f9b8c958c6221365d88a248e645aaebb6f7f1b90 maths and bugs --- diff --git a/src/vg/vg_lines.h b/src/vg/vg_lines.h index f57dd09..0263722 100644 --- a/src/vg/vg_lines.h +++ b/src/vg/vg_lines.h @@ -127,7 +127,6 @@ static void vg_lines_drawall( float* projection ) glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glBlendEquation( GL_FUNC_ADD ); - glDrawArrays( GL_LINES, 0, vg_lines.draw_idx ); glDisable( GL_BLEND ); diff --git a/src/vg/vg_m.h b/src/vg/vg_m.h index a61c6f0..9f93416 100644 --- a/src/vg/vg_m.h +++ b/src/vg/vg_m.h @@ -598,6 +598,13 @@ static inline void m4x3_to_3x3( m4x3f a, m3x3f b ) v3_copy( a[2], b[2] ); } +static inline void m4x3_invert_affine( m4x3f a, m4x3f b ) +{ + m3x3_transpose( a, b ); + m3x3_mulv( b, a[3], b[3] ); + v3_negate( b[3], b[3] ); +} + static inline void m4x3_copy( m4x3f a, m4x3f b ) { v3_copy( a[0], b[0] ); diff --git a/src/vg/vg_platform.h b/src/vg/vg_platform.h index 89315b6..7e70d81 100644 --- a/src/vg/vg_platform.h +++ b/src/vg/vg_platform.h @@ -1,3 +1,6 @@ +#ifndef VG_PLATFORM_H +#define VG_PLATFORM_H + /* Copyright (C) 2021-2022 Harry Godden (hgn) - All Rights Reserved */ typedef uint8_t u8; @@ -107,3 +110,5 @@ int vg_thread_run( void *pfunc, void *data ) } #endif } + +#endif diff --git a/src/vg/vg_shader.h b/src/vg/vg_shader.h index da61186..0f1303b 100644 --- a/src/vg/vg_shader.h +++ b/src/vg/vg_shader.h @@ -66,17 +66,26 @@ struct vg_shader static GLuint vg_shader_subshader( const char *src, GLint gliShaderType ) { GLint shader = glCreateShader( gliShaderType ); + + if( shader == GL_NONE ) + { + vg_error( "Could not 'glCreateShader()'\n" ); + return 0; + } + glShaderSource( shader, 2, (const char *[2]){ vg_shader_gl_ver, src }, NULL ); glCompileShader( shader ); - int success; - char infoLog[512]; - glGetShaderiv( shader, GL_COMPILE_STATUS, &success ); + GLint status; + glGetShaderiv( shader, GL_COMPILE_STATUS, &status ); - if( !success ) + if( status != GL_TRUE ) { - glGetShaderInfoLog( shader, 512, NULL, infoLog ); - vg_error( "Error info:\n%s\n", infoLog ); + GLchar info[1024]; + GLsizei len; + + glGetShaderInfoLog( shader, sizeof(info), &len, info ); + vg_error( "Error info:\n%s\n", info ); return 0; } diff --git a/src/vg/vg_ui.h b/src/vg/vg_ui.h index f7f8a1c..f36d363 100644 --- a/src/vg/vg_ui.h +++ b/src/vg/vg_ui.h @@ -1,5 +1,8 @@ /* Copyright (C) 2021-2022 Harry Godden (hgn) - All Rights Reserved */ +#ifndef VG_UI_H +#define VG_UI_H + SHADER_DEFINE( shader_ui, "layout (location=0) in vec2 a_co;" @@ -853,3 +856,5 @@ static void ui_push_image( ui_ctx *ctx, ui_rect rc, GLuint image ) #define gui_want_mouse() ui_want_mouse( &ui_global_ctx ) #define gui_push_image(...) ui_push_image( &ui_global_ctx, __VA_ARGS__ ) #define gui_reset_colours(...) ui_reset_colours( &ui_global_ctx ) + +#endif