return 0;
}
-static void async_world_render_init( void *payload, u32 size ){
+static void async_world_render_init( void *payload, u32 size )
+{
vg_info( "Allocate uniform buffers\n" );
- for( int i=0; i<k_world_max; i++ ){
+ for( int i=0; i<k_world_max; i++ )
+ {
world_instance *world = &world_static.instances[i];
world->ubo_bind_point = i;
glBindBufferBase( GL_UNIFORM_BUFFER, i, world->ubo_lighting );
VG_CHECK_GL_ERR();
}
-
- vg_info( "Allocate frame buffers\n" );
- for( int i=0; i<k_world_max; i++ ){
- world_instance *world = &world_static.instances[i];
- struct framebuffer *fb = &world->heightmap;
-
- fb->display_name = NULL;
- fb->link = NULL;
- fb->fixed_w = 1024;
- fb->fixed_h = 1024;
- fb->resolution_div = 0;
-
- fb->attachments[0].display_name = NULL;
- fb->attachments[0].purpose = k_framebuffer_attachment_type_texture;
- fb->attachments[0].internalformat = GL_RG16F;
- fb->attachments[0].format = GL_RG;
- fb->attachments[0].type = GL_FLOAT;
- fb->attachments[0].attachment = GL_COLOR_ATTACHMENT0;
-
- fb->attachments[1].purpose = k_framebuffer_attachment_type_none;
- fb->attachments[2].purpose = k_framebuffer_attachment_type_none;
- fb->attachments[3].purpose = k_framebuffer_attachment_type_none;
- fb->attachments[4].purpose = k_framebuffer_attachment_type_none;
-
- render_fb_allocate( fb );
- }
}
void world_render_init(void)
VG_TEX2D_NEAREST|VG_TEX2D_REPEAT,
&world_render.tex_terrain_noise );
+ vg_info( "Allocate frame buffers\n" );
+ for( int i=0; i<k_world_max; i++ )
+ {
+ world_instance *world = &world_static.instances[i];
+ world->heightmap = vg_framebuffer_allocate( vg_mem.rtmemory, 1, 0 );
+ world->heightmap->display_name = NULL;
+ world->heightmap->fixed_w = 1024;
+ world->heightmap->fixed_h = 1024;
+ world->heightmap->resolution_div = 0;
+ world->heightmap->attachments[0] = (vg_framebuffer_attachment)
+ {
+ NULL, k_framebuffer_attachment_type_texture,
+ .internalformat = GL_RG16F,
+ .format = GL_RG,
+ .type = GL_FLOAT,
+ .attachment = GL_COLOR_ATTACHMENT0
+ };
+ vg_framebuffer_create( world->heightmap );
+ }
+
vg_async_call( async_world_render_init, NULL, 0 );
}
GLuint shader, GLuint location,
int slot )
{
- render_fb_bind_texture( &world->heightmap, 0, slot );
+ vg_framebuffer_bind_texture( world->heightmap, 0, slot );
glUniform1i( location, slot );
}
}
/* render texts */
- font3d_bind( &gui.font, k_font_shader_world, 0, world, &skaterift.cam );
+ font3d_bind( &gui.font, k_font_shader_world, 0, world, &g_render.cam );
u32 count = 0;
shader_scene_font_uOpacity( scale );
shader_scene_font_uColourize( colour );
- font3d_simple_draw( 1, buf, &skaterift.cam, mmdl );
+ font3d_simple_draw( 1, buf, &g_render.cam, mmdl );
}
}
render_world_fxglow( world, world, cam, NULL, 1, 1, 0 );
}
- if( with_water ){
+ if( with_water )
+ {
render_water_texture( world, cam );
- render_fb_bind( gpipeline.fb_main, 1 );
+ vg_framebuffer_bind( g_render.fb_main, k_render_scale );
}
- if( stenciled ){
+ if( stenciled )
+ {
glStencilFunc( GL_EQUAL, 1, 0xFF );
glStencilMask( 0x00 );
glEnable( GL_CULL_FACE );
glEnable( GL_STENCIL_TEST );
}
- if( with_water ){
+ if( with_water )
+ {
render_water_surface( world, cam );
}
render_other_entities( world, cam );
ent_miniworld_render( world, cam );
- if( stenciled ){
+ if( stenciled )
+ {
glStencilMask( 0xFF );
glStencilFunc( GL_ALWAYS, 1, 0xFF );
glDisable( GL_STENCIL_TEST );
}
}
-void imgui_world_light_edit( world_instance *world )
+void imgui_world_light_edit( ui_context *ctx, world_instance *world )
{
ui_rect panel = { vg.window_x-400, 0, 400, vg.window_y };
- ui_fill( panel, ui_colour( k_ui_bg+1 ) );
- ui_outline( panel, 1, ui_colour( k_ui_bg+7 ), 0 );
+ ui_fill( ctx, panel, ui_colour( ctx, k_ui_bg+1 ) );
+ ui_outline( ctx, panel, 1, ui_colour( ctx, k_ui_bg+7 ), 0 );
ui_rect_pad( panel, (ui_px[2]){ 8, 8 } );
- vg_ui.wants_mouse = 1;
+ ui_capture_mouse(ctx, 1);
static i32 option_to_edit = 0;
- ui_enum( panel, "option", skybox_setting_options, 5, &option_to_edit );
- ui_colourpicker( panel, "colour",
+ ui_enum( ctx, panel, "option", skybox_setting_options, 5, &option_to_edit );
+ ui_colourpicker( ctx, panel, "colour",
skybox_prop_location( world, option_to_edit ) );
- if( ui_button( panel, "save tweaker file ('/tmp/tweaker.txt')\n" ) == 1 ){
+ if( ui_button( ctx, panel, "save tweaker file ('/tmp/tweaker.txt')\n" ) == 1 )
+ {
FILE *fp = fopen( "/tmp/tweaker.txt", "w" );
for( i32 i=0; i<5; i ++ ){