change shader properties to be vg_msg based
[carveJwlIkooP6JGAAIwe30JlM.git] / menu.c
diff --git a/menu.c b/menu.c
index b98f5d40e27ec991431890a7082d00f534b3d54e..7cfd738047aa028782710e3d3e601fbfbc2568c9 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -648,7 +648,7 @@ void menu_render(void)
    ent_menuitem *text_list[ 8 ];
    u32 text_count = 0;
 
-   u32 current_tex = 0xffffffff;
+   u32 current_mat = 0xffffffff;
 
    for( u32 i=0; i<mdl_arrcount(&menu.items); i++ ){
       ent_menuitem *item = mdl_arritm( &menu.items, i );
@@ -721,17 +721,31 @@ void menu_render(void)
 
       shader_model_menu_uMdl( mmdl );
 
-      for( u32 j=0; j<item->submesh_count; j++ ){
+      for( u32 j=0; j<item->submesh_count; j++ )
+      {
          u32 index = item->submesh_start + j;
          mdl_submesh *sm = mdl_arritm( &menu.model.submeshs, index );
-         
-         mdl_material *mat = mdl_arritm( &menu.model.materials, 
-                                         sm->material_id-1 );
 
-         if( mat->tex_diffuse != current_tex ){
+         if( sm->material_id != current_mat )
+         {
+            mdl_material *mat = mdl_arritm( &menu.model.materials, 
+                                            sm->material_id-1 );
             glActiveTexture( GL_TEXTURE1 );
-            glBindTexture( GL_TEXTURE_2D, menu.textures[ mat->tex_diffuse ] );
-            current_tex = mat->tex_diffuse;
+
+            if( mat->shader == k_shader_standard ) 
+            {
+               struct shader_props_standard *props = mat->props.compiled;
+
+               /* FIXME: why does menu have its own texture array?? */
+               glBindTexture( GL_TEXTURE_2D, 
+                              menu.textures[ props->tex_diffuse ] );
+            }
+            else
+            {
+               glBindTexture( GL_TEXTURE_2D, vg.tex_missing );
+            }
+
+            current_mat = sm->material_id;
          }
 
          mdl_draw_submesh( sm );