framebuffer features vg4
authorhgn <hgodden00@gmail.com>
Mon, 27 Oct 2025 22:51:27 +0000 (22:51 +0000)
committerhgn <hgodden00@gmail.com>
Mon, 27 Oct 2025 22:51:27 +0000 (22:51 +0000)
source/engine/model.c
source/engine/model.h
source/engine/shader_props.h
source/engine/vg_framebuffer.c
source/engine/vg_framebuffer.h

index 50e6b83a06233cb3dc3684c2919b6dc20bd566a6..c02999c97c02a704df61a53d91dcf44f42dc6496 100644 (file)
@@ -167,9 +167,11 @@ static void vg_model_stream_materials( struct vg_model_stream_context *ctx, stru
          if( mat->shader == k_shader_standard || 
              mat->shader == k_shader_standard_cutout || 
              mat->shader == k_shader_foliage ||
-             mat->shader == k_shader_fxglow )
+             mat->shader == k_shader_fxglow ||
+             mat->shader == k_shader_pipe )
          {
             keyvalues_read_u32s( &kvs, root, "tex_diffuse", (u32[]){0}, &props->standard.tex_diffuse, 1 );
+            keyvalues_read_u32s( &kvs, root, "tex_normal", (u32[]){0}, &props->standard.tex_normal, 1 );
             keyvalues_read_u32s( &kvs, root, "render_flags", (u32[]){0}, &props->standard.render_flags, 1 );
          }
          else if( mat->shader == k_shader_standard_vertex_blend )
index 424e198ad15798cdbd7080d56fec2af089cee8e0..bea0d129acb7eb44e093ec578d088116f5b70ffe 100644 (file)
@@ -20,6 +20,7 @@ enum mdl_shader
    k_shader_walking                 = 9,
    k_shader_foliage                 = 10,
    k_shader_workshop                = 11,
+   k_shader_pipe                    = 12,
    k_shader_override                = 30000
 };
 
index d383c0db9751aa900a10b9920f87922c174826b6..7c90c7fefce7f3d9de5566c134794c32bf892603 100644 (file)
@@ -23,7 +23,7 @@ union shader_props
 {
    struct shader_props_standard
    {
-      u32 tex_diffuse;
+      u32 tex_diffuse, tex_normal;
       u32 render_flags;
    }
    standard;
index aa77caad2f0e39edb64f1371f531f8be53479a39..d416af3c598c48a283d6fccfc3374f612d74749b 100644 (file)
@@ -40,6 +40,16 @@ void framebuffer_get_res( struct framebuffer *fb, i32 *x, i32 *y )
    {
       *x = _engine.w / fb->resolution_div;
       *y = _engine.h / fb->resolution_div;
+
+      if( fb->fixed_ratio != 0.0f )
+      {
+         f32 engine_ratio = (f32)_engine.w / (f32)_engine.h;
+         if( engine_ratio > fb->fixed_ratio )
+            *x = (f32)(*y) * fb->fixed_ratio;
+         
+         if( engine_ratio < fb->fixed_ratio )
+            *y = (f32)(*x) / fb->fixed_ratio;
+      }
    }
    else
    {
@@ -283,11 +293,21 @@ void framebuffer_init( struct framebuffer *fb )
                attachment->purpose == k_framebuffer_attachment_type_texture_depth )
       {
          glGenTextures( 1, &attachment->tex.name );
-         attachment->tex.flags = VG_TEX_COMPLETE|VG_TEX_FRAMEBUFFER_ATTACHMENT|VG_TEX_LINEAR|VG_TEX_CLAMP|VG_TEX_NOMIP;
+         attachment->tex.flags = VG_TEX_COMPLETE|VG_TEX_FRAMEBUFFER_ATTACHMENT|VG_TEX_CLAMP|VG_TEX_NOMIP;
 
          framebuffer_allocate_texture( fb, attachment );
-         glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-         glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+         if( fb->nearest )
+         {
+            attachment->tex.flags |= VG_TEX_NEAREST;
+            glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+            glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+         }
+         else
+         {
+            attachment->tex.flags |= VG_TEX_LINEAR;
+            glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+            glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+         }
          glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
          glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
          glFramebufferTexture2D( GL_FRAMEBUFFER, attachment->attachment, GL_TEXTURE_2D, attachment->tex.name, 0 );
index 866a55693186fa98e6f45aff368cedb28e776c0e..a086efa15e91d0fb244acc859ac7af68af47c0ed 100644 (file)
@@ -9,7 +9,7 @@
 struct framebuffer
 {
    const c8 *display_name;
-   int       resolution_div, /* If 0:     Use fixed_w, fixed_h.
+   i32       resolution_div, /* If 0:     Use fixed_w, fixed_h.
                                 If non-0: Automatically size itself to 
                                           the window resolution divided by 
                                           this value */
@@ -18,6 +18,10 @@ struct framebuffer
 
              render_w, /* The currently rendering resolution */
              render_h;
+
+   f32       fixed_ratio;
+   b8        nearest;
+
    GLuint id;
    u32 attachment_count;