# include "vg/vg_shader.h"
# include "src.generated/vg.shaders.h"
# include "vg/vg_tex.h"
+# endif
+
+# if defined( VG_ENGINE ) || defined( VG_IMGUI )
# include "vg/vg_font.h"
# include "vg/vg_ui/imgui.h"
+# endif
+
+# if defined( VG_ENGINE )
# include "vg/vg_ui/imgui_impl_opengl.h"
# include "vg/vg_ui/filebrowser.h"
# include "vg/vg_ui/console.h"
vg_strcat( &conf->defines, "\\\n" );
vg_strcat( &conf->include, "-I. -I./vg -I./vg/dep " );
- vg_strcat( &conf->library, "-L. -L/usr/lib/x86_64-linux-gnu " );
+ vg_strcat( &conf->library, "-L. -L/usr/lib" );
vg_strcat( &conf->link, "-lm " );
/* compile all the components
u64 current = 0;
/* read in chunks */
- for( u32 i=0; 1; i++ )
+ while(1)
{
vg_stack_extend_last( stack, +VG_FILE_IO_CHUNK_SIZE );
u64 l = fread( buffer + current, 1, VG_FILE_IO_CHUNK_SIZE, f );
while( child_offset )
{
vg_kv *kv = vg_stack_pointer( kvs->stack, child_offset );
- u32 key_length;
- const c8 *child_key = vg_kv_key( kvs, child_offset, &key_length );
if( ((kv->key_info ^ hash) & 0xFFFFF) == 0 )
{
u32 key_length;
*/
#define KNRM "\x1B[0m"
-#define KBLK "\x1B[30m"
+//#define KBLK "\x1B[30m"
+#define KBLK "\x1B[0m"
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define KYEL "\x1B[33m"
else return str->len;
}
+void vg_strclip( vg_str *str, i32 i )
+{
+ str->buffer[i] = '\0';
+ str->i = i;
+}
+
/*
* Reset string. If len is 0 (dynamically allocated), buffer must be either
* NULL or be acquired from malloc or realloc
return good;
}
+c8 vg_str_character( vg_str *str, i32 index )
+{
+ return str->buffer[ index ];
+}
+
/*
* Returns pointer to last instance of character
*/
-c8 *vg_strch( vg_str *str, c8 c )
-{
- c8 *ptr = NULL;
- for( i32 i=0; i<str->i; i++ ){
+i32 vg_strch( vg_str *str, i32 start, c8 c )
+{
+ i32 last_index = -1;
+ for( i32 i=start; i<str->i; i++ )
if( str->buffer[i] == c )
- ptr = str->buffer+i;
- }
-
- return ptr;
+ last_index = i;
+ return last_index;
}
u32 vg_strcpy( const c8 *src, c8 *dst )
return 0;
}
+#if defined( VG_UTF8 )
static u32 utf8_byte0_byte_count( u8 c80 )
{
for( u32 k=2; k<4; k++ )
buf[j] = 0x00;
return j;
}
-
-
-
-
-
+#endif
const c8 *vg_strp_info_str[] =
{
*/
void vg_strnull( vg_str *str, c8 *buffer, i32 len );
void vg_strfree( vg_str *str );
+void vg_strclip( vg_str *str, i32 i );
/*
* Append null terminated string to vg_str
* Returns 1 if string did not overflow while building
*/
int vg_strgood( vg_str *str );
+c8 vg_str_character( vg_str *str, i32 index );
/*
* Returns pointer to last instance of c8acter
*/
-c8 *vg_strch( vg_str *str, c8 c );
+i32 vg_strch( vg_str *str, i32 start, c8 c );
enum strncpy_behaviour
{
return ui_fill_rect( ctx, rect, colour, (ui_px[4]){ 4,4,4,4 } );
}
-void ui_outline( ui_context *ctx,
- ui_rect rect, ui_px thickness, u32 colour, u32 mask )
+void ui_outline( ui_context *ctx, ui_rect rect, ui_px thickness, u32 colour, u32 mask )
{
/* this if far from ideal but stops us from crashing */
if( (ctx->cur_vert + 8 > ctx->max_verts) ||
vertices[7].co[1] = vertices[3].co[1]+thickness;
u16 start = ctx->cur_vert;
- u32 mesh[] = { 0,5,4, 0,1,5, 1,6,5, 1,2,6, 2,7,6, 2,3,7, 3,4,7, 3,0,4 };
+ u32 mesh[] = { 0,5,4,0,1,5, 1,6,5,1,2,6, 2,7,6,2,3,7, 3,4,7,3,0,4 };
if( !mask )
mask = UI_TOP|UI_LEFT|UI_BOTTOM|UI_RIGHT;
ui_fill( ctx, inner, ui_colour( ctx, k_ui_bg+6 ) );
}
-void ui_image( ui_context *ctx, ui_rect rect, vg_tex *tex, bool flip )
+void ui_image( ui_context *ctx, ui_rect rect, void *image_resource, bool flip )
{
ui_flush( ctx, k_ui_shader_colour, NULL );
if( flip )
ui_fill_rect( ctx, rect, 0xffffffff, (ui_px[4]){ 0,0,256,256 } );
else
ui_fill_rect( ctx, rect, 0xffffffff, (ui_px[4]){ 0,256,256,0 } );
- ui_flush( ctx, k_ui_shader_image, tex );
+ ui_flush( ctx, k_ui_shader_image, image_resource );
}
void ui_defocus_all( ui_context *ctx )
*
* input coordinates go in co[0], co[1], and the result index is in co[2]
*/
-static void _ui_textbox_calc_index_from_grid( ui_context *ctx,
- int co[3], int wrap_length )
+static void _ui_textbox_calc_index_from_grid( ui_context *ctx, int co[3], int wrap_length )
{
int i[3] = {0,0,0};
/* allow instant transitions from textbox->textbox */
if( (ctx->focused_control_type != k_ui_control_none) &&
- (ctx->focused_control_type != k_ui_control_textbox) ){
+ (ctx->focused_control_type != k_ui_control_textbox) )
+ {
clickup = 0;
clickdown = 0;
click = 0;
}
ui_outline( ctx, rect, -2, ctx->scheme[ k_ui_orange ], 0 );
-
ui_rect cursor;
int c0 = ctx->textbox.cursor_pos,
cursor[2] = (float)(chars)*(float)ctx->font->sx;
}
- if( (ctx->click_fade_opacity<=0.0f) &&
- ui_clip( rect, cursor, cursor ) )
+ if( (ctx->click_fade_opacity<=0.0f) && ui_clip( rect, cursor, cursor ) )
{
ui_fill( ctx, cursor, col_cursor );
}
f32 hue;
};
-struct ui_batch_shader_data_image
-{
- void *resource;
-};
-
struct ui_batch_shader_data_image_gradient
{
- vg_tex *tex;
+ void *image_resource;
bool log;
f32 scale;
};
void ui_label( ui_context *ctx, ui_rect rect, const char *text, ui_px size, ui_px gap, ui_rect r );
void ui_info( ui_context *ctx, ui_rect inout_panel, const char *text );
void ui_spacer( ui_context *ctx, ui_rect inout_panel );
-void ui_image( ui_context *ctx, ui_rect rect, vg_tex *tex, bool flip );
+void ui_image( ui_context *ctx, ui_rect rect, void *image_resource, bool flip );
enum ui_button_state ui_button_base( ui_context *ctx, ui_rect rect );
glBindTexture( GL_TEXTURE_2D, vg_ui.tex_glyphs );
shader_vgui_uTexGlyphs( 0 );
- vg_tex_bind( GL_TEXTURE_2D, vg_ui.tex_bg, 1 );
+ vg_tex_bind( GL_TEXTURE_2D, (vg_tex *)vg_ui.tex_bg, 1 );
shader_vgui_uTexBG( 1 );
shader_vgui_uSpread( vg_ui.frosting );
shader_vgui_uBGInverseRatio( vg_ui.bg_inverse_ratio );
shader_vgui_image_uPv( vg_ui.pv );
shader_vgui_image_uTexImage( 0 );
shader_vgui_image_uColour( vg_ui.colour );
- vg_tex_bind( GL_TEXTURE_2D, shader_data, 0 );
+ vg_tex_bind( GL_TEXTURE_2D, (vg_tex *)shader_data, 0 );
}
else if( shader == k_ui_shader_grad )
{
struct ui_batch_shader_data_image_gradient *inf = shader_data;
shader_vgui_image_grad_uLog( inf->log );
shader_vgui_image_grad_uScale( inf->scale );
- vg_tex_bind( GL_TEXTURE_2D, inf->tex, 0 );
+ vg_tex_bind( GL_TEXTURE_2D, (vg_tex *)inf->tex, 0 );
}
else if( shader == k_ui_shader_hsv )
{