/*
* All standard buffers used in rendering
*/
-VG_STATIC struct pipeline
-{
+VG_STATIC struct pipeline{
glmesh fsquad;
framebuffer *fb_main,
}
gpipeline = { .view_render_scale = 1.0f };
-struct framebuffer
-{
+struct framebuffer{
const char *display_name;
int resolution_div, /* definition */
fixed_w,
render_w, /* runtime */
render_h;
- struct framebuffer_attachment
- {
+ struct framebuffer_attachment{
const char *display_name;
- enum framebuffer_attachment_type
- {
+ enum framebuffer_attachment_type{
k_framebuffer_attachment_type_none,
k_framebuffer_attachment_type_colour,
k_framebuffer_attachment_type_renderbuffer
}
purpose;
- enum framebuffer_quality_profile
- {
+ enum framebuffer_quality_profile{
k_framebuffer_quality_all,
k_framebuffer_quality_high_only
}
{
struct framebuffer_attachment *at = &fb->attachments[attachment];
- if( at->purpose != k_framebuffer_attachment_type_colour )
- {
+ if( at->purpose != k_framebuffer_attachment_type_colour ){
vg_fatal_exit_loop( "illegal operation: bind non-colour framebuffer"
" attachment to texture slot" );
}
int rx, ry;
render_fb_get_current_res( fb, &rx, &ry );
- if( a->purpose == k_framebuffer_attachment_type_renderbuffer )
- {
+ if( a->purpose == k_framebuffer_attachment_type_renderbuffer ){
glBindRenderbuffer( GL_RENDERBUFFER, a->id );
glRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, rx, ry );
}
- else if( a->purpose == k_framebuffer_attachment_type_colour )
- {
+ else if( a->purpose == k_framebuffer_attachment_type_colour ){
glBindTexture( GL_TEXTURE_2D, a->id );
glTexImage2D( GL_TEXTURE_2D, 0, a->internalformat, rx, ry,
0, a->format, a->type, NULL );
GLenum colour_attachments[4];
u32 colour_count = 0;
- for( int j=0; j<vg_list_size(fb->attachments); j++ )
- {
+ for( int j=0; j<vg_list_size(fb->attachments); j++ ){
struct framebuffer_attachment *attachment = &fb->attachments[j];
if( attachment->purpose == k_framebuffer_attachment_type_none )
render_fb_attachment_str( attachment->attachment ),
render_fb_format_str( attachment->internalformat ) );
- if( attachment->purpose == k_framebuffer_attachment_type_renderbuffer )
- {
+ if( attachment->purpose == k_framebuffer_attachment_type_renderbuffer ){
glGenRenderbuffers( 1, &attachment->id );
render_fb_allocate_texture( fb, attachment );
glFramebufferRenderbuffer( GL_FRAMEBUFFER,
GL_DEPTH_STENCIL_ATTACHMENT,
GL_RENDERBUFFER, attachment->id );
}
- else if( attachment->purpose == k_framebuffer_attachment_type_colour )
- {
+ else if( attachment->purpose == k_framebuffer_attachment_type_colour ){
glGenTextures( 1, &attachment->id );
render_fb_allocate_texture( fb, attachment );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
*/
GLenum result = glCheckFramebufferStatus( GL_FRAMEBUFFER );
- if( result == GL_FRAMEBUFFER_COMPLETE )
- {
+ if( result == GL_FRAMEBUFFER_COMPLETE ){
/*
* Attatch to gpipeline
*/
vg_success( " status: complete\n" );
vg_info( "}\n" );
}
- else
- {
+ else{
if( result == GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT )
vg_error( " status: Incomplete attachment" );
else if( result == GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT )
if( !gpipeline.ready )
return;
- for( int i=0; i<vg_list_size(framebuffers); i++ )
- {
+ for( int i=0; i<vg_list_size(framebuffers); i++ ){
struct framebuffer *fb = &framebuffers[i];
- for( int j=0; j<vg_list_size(fb->attachments); j++ )
- {
+ for( int j=0; j<vg_list_size(fb->attachments); j++ ){
struct framebuffer_attachment *attachment = &fb->attachments[j];
render_fb_allocate_texture( fb, attachment );
}
{
vg_info( "[render] Allocate quad\n" );
- float quad[] =
- {
+ float quad[] = {
0.00f,0.00f, 1.00f,1.00f, 0.00f,1.00f,
0.00f,0.00f, 1.00f,0.00f, 1.00f,1.00f,
0.60f,0.60f, 0.90f,0.60f, 0.90f,0.90f,
};
- vg_function_push( (struct vg_cmd)
- {
- .name = "fb",
- .function = render_framebuffer_control,
- .poll_suggest = render_framebuffer_poll
- });
+ vg_console_reg_cmd( "fb", render_framebuffer_control,
+ render_framebuffer_poll );
glGenVertexArrays( 1, &gpipeline.fsquad.vao );
glGenBuffers( 1, &gpipeline.fsquad.vbo );
/*
* Complete Framebuffers
*/
- for( int i=0; i<vg_list_size(framebuffers); i++ )
- {
+ for( int i=0; i<vg_list_size(framebuffers); i++ ){
struct framebuffer *fb = &framebuffers[i];
render_fb_allocate( fb );
}
*/
VG_STATIC int render_framebuffer_control( int argc, char const *argv[] )
{
- if( argc < 2 )
- {
+ if( argc < 2 ){
vg_error( "Usage: fb \"show/hide\" <name>/\"all\" <name>/none\n" );
return 0;
}
operation = 1;
else if( !strcmp( argv[0], "hide" ) )
operation = 0;
- else
- {
+ else{
vg_error( "Unknown framebuffer operation: '%s'\n", argv[0] );
return 0;
}
if( !strcmp( argv[1], "all" ) )
modify_all = 1;
- for( int i=0; i<vg_list_size(framebuffers); i++ )
- {
+ for( int i=0; i<vg_list_size(framebuffers); i++ ){
struct framebuffer *fb = &framebuffers[i];
- for( int j=0; j<vg_list_size(fb->attachments); j++ )
- {
+ for( int j=0; j<vg_list_size(fb->attachments); j++ ){
struct framebuffer_attachment *at = &fb->attachments[j];
if( at->purpose == k_framebuffer_attachment_type_none )
continue;
- if( modify_all )
- {
+ if( modify_all ){
render_framebuffer_show( fb, at, operation );
}
- else
- {
- if( !strcmp( fb->display_name, argv[1] ) )
- {
+ else{
+ if( !strcmp( fb->display_name, argv[1] ) ){
if( argc == 2 )
render_framebuffer_show( fb, at, operation );
else if( !strcmp( at->display_name, argv[2] ) )
{
const char *term = argv[argc-1];
- if( argc == 1 )
- {
+ if( argc == 1 ){
console_suggest_score_text( "show", term, 0 );
console_suggest_score_text( "hide", term, 0 );
}
- else if( argc == 2 )
- {
+ else if( argc == 2 ){
console_suggest_score_text( "all", term, 0 );
- for( int i=0; i<vg_list_size(framebuffers); i++ )
- {
+ for( int i=0; i<vg_list_size(framebuffers); i++ ){
struct framebuffer *fb = &framebuffers[i];
console_suggest_score_text( fb->display_name, term, 0 );
}
}
- else if( argc == 3 )
- {
+ else if( argc == 3 ){
int modify_all = 0;
if( !strcmp( argv[1], "all" ) )
modify_all = 1;
- for( int i=0; i<vg_list_size(framebuffers); i++ )
- {
+ for( int i=0; i<vg_list_size(framebuffers); i++ ){
struct framebuffer *fb = &framebuffers[i];
- for( int j=0; j<vg_list_size(fb->attachments); j++ )
- {
+ for( int j=0; j<vg_list_size(fb->attachments); j++ ){
struct framebuffer_attachment *at = &fb->attachments[j];
if( at->purpose == k_framebuffer_attachment_type_none )
continue;
- if( modify_all )
- {
+ if( modify_all ){
console_suggest_score_text( at->display_name, term, 0 );
}
- else if( !strcmp( fb->display_name, argv[1] ) )
- {
+ else if( !strcmp( fb->display_name, argv[1] ) ){
console_suggest_score_text( at->display_name, term, 0 );
}
}