replace VG_STATIC -> static
[vg.git] / vg_shader.h
index 86b6ba6d928d100bf4844bf70f8f352c4c2cee2c..6537ec9c659064c42f4ca86a6c82627209cef962 100644 (file)
@@ -40,7 +40,7 @@ struct
 }
 static vg_shaders;
 
-VG_STATIC GLuint vg_shader_subshader( const char *src, GLint gliShaderType )
+static GLuint vg_shader_subshader( const char *src, GLint gliShaderType )
 {
        GLint shader = glCreateShader( gliShaderType );
 
@@ -69,7 +69,7 @@ VG_STATIC GLuint vg_shader_subshader( const char *src, GLint gliShaderType )
        return shader;
 }
 
-VG_STATIC int vg_shader_compile( struct vg_shader *shader )
+static int vg_shader_compile( struct vg_shader *shader )
 {
        GLuint program, vert, frag;
 
@@ -81,14 +81,11 @@ VG_STATIC int vg_shader_compile( struct vg_shader *shader )
     */
 
    int use_source_files = 0;
-   if( shader->compiled )
-   {
-      if( shader->vs.orig_file && shader->fs.orig_file )
-      {
+   if( shader->compiled ){
+      if( shader->vs.orig_file && shader->fs.orig_file ){
          use_source_files = 1;
       }
-      else 
-      {
+      else {
          vg_warn( "No source files for shader '%s'\n", shader->name );
          return 1;
       }
@@ -96,8 +93,7 @@ VG_STATIC int vg_shader_compile( struct vg_shader *shader )
 
        vg_info( "Compile shader '%s'\n", shader->name );
 
-   if( use_source_files )
-   {
+   if( use_source_files ){
       char error[260];
       char path[260];
 
@@ -109,14 +105,20 @@ VG_STATIC int vg_shader_compile( struct vg_shader *shader )
       strcat( path, shader->fs.orig_file );
       char *fragment_src = stb_include_file( path, "", "../../shaders", error );
    
-      if( !vertex_src || !fragment_src )
-      {
-         vg_error( "Could not find shader source files (%s)\n",
-                   shader->vs.orig_file );
-
-         free( vertex_src );
-         free( fragment_src );
-         return 0;
+      if( !vertex_src || !fragment_src ){
+         const char *errstr = "Could not find shader source files (%s)\n";
+         if( shader->compiled ){
+            vg_warn( errstr, shader->vs.orig_file );
+            free( vertex_src );
+            free( fragment_src );
+            return 1;
+         }
+         else{
+            vg_error( errstr, shader->vs.orig_file );
+            free( vertex_src );
+            free( fragment_src );
+            return 0;
+         }
       }
 
       vert = vg_shader_subshader( vertex_src,   GL_VERTEX_SHADER );
@@ -125,8 +127,7 @@ VG_STATIC int vg_shader_compile( struct vg_shader *shader )
       free( vertex_src );
       free( fragment_src );
    }
-   else
-   {
+   else{
       vert = vg_shader_subshader( shader->vs.static_src, GL_VERTEX_SHADER );
       frag = vg_shader_subshader( shader->fs.static_src, GL_FRAGMENT_SHADER );
    }
@@ -166,7 +167,7 @@ VG_STATIC int vg_shader_compile( struct vg_shader *shader )
        return 1;
 }
 
-VG_STATIC void vg_free_shader( struct vg_shader *shader )
+static void vg_free_shader( struct vg_shader *shader )
 {
    if( shader->compiled )
    {
@@ -175,12 +176,11 @@ VG_STATIC void vg_free_shader( struct vg_shader *shader )
    }
 }
 
-VG_STATIC void vg_shaders_compile(void)
+static void vg_shaders_compile(void)
 {
        vg_info( "Compiling shaders\n" );
 
-       for( int i=0; i<vg_shaders.count; i ++ )
-       {
+       for( int i=0; i<vg_shaders.count; i ++ ){
                vg_shader *shader = vg_shaders.shaders[i];
 
                if( !vg_shader_compile( shader ) )
@@ -188,7 +188,7 @@ VG_STATIC void vg_shaders_compile(void)
        }
 }
 
-VG_STATIC int vg_shaders_live_recompile(int argc, const char *argv[])
+static int vg_shaders_live_recompile(int argc, const char *argv[])
 {
    vg_info( "Recompiling shaders\n" );
    for( int i=0; i<vg_shaders.count; i ++ )
@@ -200,7 +200,7 @@ VG_STATIC int vg_shaders_live_recompile(int argc, const char *argv[])
    return 0;
 }
 
-VG_STATIC void vg_shader_register( struct vg_shader *shader )
+static void vg_shader_register( struct vg_shader *shader )
 {
    if( vg_shaders.count == vg_list_size(vg_shaders.shaders) )
       vg_fatal_error( "Too many shaders" );