#ifndef RENDER_H
#define RENDER_H
+static f32 k_render_scale = 1.0f;
+static i32 k_blur_effect = 1;
+static f32 k_blur_strength = 0.3f;
+static f32 k_fov = 0.86f;
+static f32 k_cam_height = 0.8f;
+
typedef struct framebuffer framebuffer;
/*
* All standard buffers used in rendering
*/
-VG_STATIC struct pipeline{
+static struct pipeline{
glmesh fsquad;
framebuffer *fb_main,
*fb_water_beneath,
*fb_workshop_preview;
int ready;
-
- float view_render_scale,
- water_render_scale;
}
-gpipeline = { .view_render_scale = 1.0f };
+gpipeline;
struct framebuffer{
const char *display_name;
/*
* Get the current (automatically scaled or fixed) resolution of framebuffer
*/
-VG_STATIC void render_fb_get_current_res( struct framebuffer *fb,
+static void render_fb_get_current_res( struct framebuffer *fb,
int *x, int *y )
{
if( fb->resolution_div ){
}
}
-VG_STATIC void render_fb_inverse_ratio( framebuffer *fb, v2f inverse )
+static void render_fb_inverse_ratio( framebuffer *fb, v2f inverse )
{
if( fb ){
int x, y;
/*
* Bind framebuffer for drawing to
*/
-VG_STATIC void render_fb_bind( framebuffer *fb, int use_scaling )
+static void render_fb_bind( framebuffer *fb, int use_scaling )
{
int x, y;
render_fb_get_current_res( fb, &x, &y );
if( use_scaling ){
- x = gpipeline.view_render_scale*(float)x;
- y = gpipeline.view_render_scale*(float)y;
+ x = k_render_scale*(float)x;
+ y = k_render_scale*(float)y;
x = VG_MAX( 16, x );
y = VG_MAX( 16, y );
/*
* Bind framebuffer attachment's texture
*/
-VG_STATIC void render_fb_bind_texture( framebuffer *fb,
+static void render_fb_bind_texture( framebuffer *fb,
int attachment, int slot )
{
struct framebuffer_attachment *at = &fb->attachments[attachment];
/*
* Convert OpenGL attachment ID enum to string
*/
-VG_STATIC const char *render_fb_attachment_str( GLenum e )
+static const char *render_fb_attachment_str( GLenum e )
{
struct { GLenum e; const char *str; }
formats[] =
* Convert OpenGL texture format enums from TexImage2D table 1,2 &
* RenderBufferStorage Table 1, into strings
*/
-VG_STATIC const char *render_fb_format_str( GLenum format )
+static const char *render_fb_format_str( GLenum format )
{
struct { GLenum e; const char *str; }
formats[] =
/*
* Bind and allocate texture for framebuffer attachment
*/
-VG_STATIC void render_fb_allocate_texture( struct framebuffer *fb,
+static void render_fb_allocate_texture( struct framebuffer *fb,
struct framebuffer_attachment *a )
{
int rx, ry;
/*
* Full allocation of a framebuffer
*/
-VG_STATIC void render_fb_allocate( struct framebuffer *fb )
+static void render_fb_allocate( struct framebuffer *fb )
{
glGenFramebuffers( 1, &fb->fb );
glBindFramebuffer( GL_FRAMEBUFFER, fb->fb );
/*
* Resize/Update all framebuffers(we know about)
*/
-VG_STATIC void render_fb_resize(void)
+static void render_fb_resize(void)
{
- if( !gpipeline.ready )
- return;
+ if( !gpipeline.ready ) return;
for( int i=0; i<vg_list_size(framebuffers); i++ ){
struct framebuffer *fb = &framebuffers[i];
}
}
-VG_STATIC int render_framebuffer_control( int argc, char const *argv[] );
-VG_STATIC void render_framebuffer_poll( int argc, char const *argv[] );
+static int render_framebuffer_control( int argc, char const *argv[] );
+static void render_framebuffer_poll( int argc, char const *argv[] );
-VG_STATIC void async_render_init( void *payload, u32 size )
+static void async_render_init( void *payload, u32 size )
{
/*
* Complete Framebuffers
vg_console_reg_cmd( "fb", render_framebuffer_control,
render_framebuffer_poll );
- vg_console_reg_var( "render_scale", &gpipeline.view_render_scale,
- k_var_dtype_f32, VG_VAR_PERSISTENT );
-
glGenVertexArrays( 1, &gpipeline.fsquad.vao );
glGenBuffers( 1, &gpipeline.fsquad.vbo );
glBindVertexArray( gpipeline.fsquad.vao );
gpipeline.ready = 1;
}
-VG_STATIC void render_init(void)
+static void render_init(void)
{
+ vg_console_reg_var( "blur_strength", &k_blur_strength, k_var_dtype_f32, 0 );
+ vg_console_reg_var( "render_scale", &k_render_scale,
+ k_var_dtype_f32, VG_VAR_PERSISTENT );
+ vg_console_reg_var( "fov", &k_fov, k_var_dtype_f32, VG_VAR_PERSISTENT );
+ vg_console_reg_var( "cam_height", &k_cam_height,
+ k_var_dtype_f32, VG_VAR_PERSISTENT );
+ vg_console_reg_var( "blur_effect", &k_blur_effect,
+ k_var_dtype_i32, VG_VAR_PERSISTENT );
+
+
shader_blit_register();
shader_blitblur_register();
shader_blitcolour_register();
/*
* Utility
*/
-VG_STATIC void render_fsquad(void)
+static void render_fsquad(void)
{
glBindVertexArray( gpipeline.fsquad.vao );
glDrawArrays( GL_TRIANGLES, 0, 6 );
}
-VG_STATIC void render_fsquad1(void)
+static void render_fsquad1(void)
{
glBindVertexArray( gpipeline.fsquad.vao );
glDrawArrays( GL_TRIANGLES, 6, 6 );
}
-VG_STATIC void render_fsquad2(void)
+static void render_fsquad2(void)
{
glBindVertexArray( gpipeline.fsquad.vao );
glDrawArrays( GL_TRIANGLES, 66,6 );
/*
* Call this inside the UI function
*/
-VG_STATIC void render_view_framebuffer_ui(void)
+static void render_view_framebuffer_ui(void)
{
#if 0
int viewing_count = 0;
#endif
}
-VG_STATIC void render_framebuffer_show( struct framebuffer *fb,
+static void render_framebuffer_show( struct framebuffer *fb,
struct framebuffer_attachment *at,
int operation )
{
* arg1: framebuffer name <name>/"all"
* arg2: subname <name>/none
*/
-VG_STATIC int render_framebuffer_control( int argc, char const *argv[] )
+static int render_framebuffer_control( int argc, char const *argv[] )
{
if( argc < 2 ){
vg_error( "Usage: fb \"show/hide\" <name>/\"all\" <name>/none\n" );
return 0;
}
-VG_STATIC void render_framebuffer_poll( int argc, char const *argv[] )
+static void render_framebuffer_poll( int argc, char const *argv[] )
{
const char *term = argv[argc-1];