2 * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
10 #include "shaders/blit.h"
11 #include "shaders/blitblur.h"
12 #include "shaders/blitcolour.h"
15 #include "shaders/standard.h"
16 #include "shaders/vblend.h"
19 #define WORKSHOP_PREVIEW_WIDTH 504
20 #define WORKSHOP_PREVIEW_HEIGHT 336
22 VG_STATIC
void render_water_texture( world_instance
*world
, camera
*cam
,
24 VG_STATIC
void render_water_surface( world_instance
*world
, camera
*cam
);
25 VG_STATIC
void render_world( world_instance
*world
, camera
*cam
,
27 VG_STATIC
void render_world_depth( world_instance
*world
, camera
*cam
);
32 typedef struct framebuffer framebuffer
;
35 * All standard buffers used in rendering
37 VG_STATIC
struct pipeline
{
46 float view_render_scale
,
49 gpipeline
= { .view_render_scale
= 1.0f
};
52 const char *display_name
;
53 int resolution_div
, /* definition */
57 render_w
, /* runtime */
60 struct framebuffer_attachment
{
61 const char *display_name
;
63 enum framebuffer_attachment_type
{
64 k_framebuffer_attachment_type_none
,
65 k_framebuffer_attachment_type_texture
,
66 k_framebuffer_attachment_type_renderbuffer
,
67 k_framebuffer_attachment_type_texture_depth
71 enum framebuffer_quality_profile
{
72 k_framebuffer_quality_all
,
73 k_framebuffer_quality_high_only
77 GLenum internalformat
,
95 * The primary draw target
98 .link
= &gpipeline
.fb_main
,
103 "colour", k_framebuffer_attachment_type_texture
,
105 .internalformat
= GL_RGB
,
107 .type
= GL_UNSIGNED_BYTE
,
108 .attachment
= GL_COLOR_ATTACHMENT0
111 "motion", k_framebuffer_attachment_type_texture
,
113 .quality
= k_framebuffer_quality_high_only
,
114 .internalformat
= GL_RG16F
,
117 .attachment
= GL_COLOR_ATTACHMENT1
121 "depth_stencil", k_framebuffer_attachment_type_renderbuffer
,
123 .internalformat
= GL_DEPTH24_STENCIL8
,
125 "depth_stencil", k_framebuffer_attachment_type_texture_depth
,
126 .internalformat
= GL_DEPTH24_STENCIL8
,
127 .format
= GL_DEPTH_STENCIL
,
128 .type
= GL_UNSIGNED_INT_24_8
,
130 .attachment
= GL_DEPTH_STENCIL_ATTACHMENT
136 * Second rendered view from the perspective of the water reflection
139 .link
= &gpipeline
.fb_water_reflection
,
144 "colour", k_framebuffer_attachment_type_texture
,
145 .internalformat
= GL_RGB
,
147 .type
= GL_UNSIGNED_BYTE
,
148 .attachment
= GL_COLOR_ATTACHMENT0
151 "depth_stencil", k_framebuffer_attachment_type_renderbuffer
,
153 .internalformat
= GL_DEPTH24_STENCIL8
,
154 .attachment
= GL_DEPTH_STENCIL_ATTACHMENT
160 * Thid rendered view from the perspective of the camera, but just
161 * captures stuff thats under the water
164 .link
= &gpipeline
.fb_water_beneath
,
169 "colour", k_framebuffer_attachment_type_texture
,
170 .internalformat
= GL_RED
,
172 .type
= GL_UNSIGNED_BYTE
,
173 .attachment
= GL_COLOR_ATTACHMENT0
176 "depth_stencil", k_framebuffer_attachment_type_renderbuffer
,
178 .internalformat
= GL_DEPTH24_STENCIL8
,
179 .attachment
= GL_DEPTH_STENCIL_ATTACHMENT
185 .link
= &gpipeline
.fb_workshop_preview
,
187 .fixed_w
= WORKSHOP_PREVIEW_WIDTH
, .fixed_h
= WORKSHOP_PREVIEW_HEIGHT
,
191 "colour", k_framebuffer_attachment_type_texture
,
192 .internalformat
= GL_RGB
,
194 .type
= GL_UNSIGNED_BYTE
,
195 .attachment
= GL_COLOR_ATTACHMENT0
198 "depth_stencil", k_framebuffer_attachment_type_renderbuffer
,
199 .internalformat
= GL_DEPTH24_STENCIL8
,
200 .attachment
= GL_DEPTH_STENCIL_ATTACHMENT
207 * Get the current (automatically scaled or fixed) resolution of framebuffer
209 VG_STATIC
void render_fb_get_current_res( struct framebuffer
*fb
,
212 if( fb
->resolution_div
){
213 *x
= vg
.window_x
/ fb
->resolution_div
;
214 *y
= vg
.window_y
/ fb
->resolution_div
;
222 VG_STATIC
void render_fb_inverse_ratio( framebuffer
*fb
, v2f inverse
)
226 render_fb_get_current_res( fb
, &x
, &y
);
228 v2f render
= { fb
->render_w
, fb
->render_h
},
231 v2_div( render
, original
, inverse
);
234 v2_div( (v2f
){1.0f
,1.0f
}, (v2f
){ vg
.window_x
, vg
.window_y
}, inverse
);
239 * Bind framebuffer for drawing to
241 VG_STATIC
void render_fb_bind( framebuffer
*fb
, int use_scaling
)
244 render_fb_get_current_res( fb
, &x
, &y
);
247 x
= gpipeline
.view_render_scale
*(float)x
;
248 y
= gpipeline
.view_render_scale
*(float)y
;
257 glBindFramebuffer( GL_FRAMEBUFFER
, fb
->fb
);
258 glViewport( 0, 0, x
, y
);
262 * Bind framebuffer attachment's texture
264 VG_STATIC
void render_fb_bind_texture( framebuffer
*fb
,
265 int attachment
, int slot
)
267 struct framebuffer_attachment
*at
= &fb
->attachments
[attachment
];
269 if( (at
->purpose
!= k_framebuffer_attachment_type_texture
) &&
270 (at
->purpose
!= k_framebuffer_attachment_type_texture_depth
) )
272 vg_fatal_error( "illegal operation: bind non-texture framebuffer"
273 " attachment to texture slot" );
276 glActiveTexture( GL_TEXTURE0
+ slot
);
277 glBindTexture( GL_TEXTURE_2D
, fb
->attachments
[attachment
].id
);
285 #define FB_FORMAT_STR( E ) { E, #E },
288 * Convert OpenGL attachment ID enum to string
290 VG_STATIC
const char *render_fb_attachment_str( GLenum e
)
292 struct { GLenum e
; const char *str
; }
295 FB_FORMAT_STR(GL_COLOR_ATTACHMENT0
)
296 FB_FORMAT_STR(GL_COLOR_ATTACHMENT1
)
297 FB_FORMAT_STR(GL_COLOR_ATTACHMENT2
)
298 FB_FORMAT_STR(GL_COLOR_ATTACHMENT3
)
299 FB_FORMAT_STR(GL_COLOR_ATTACHMENT4
)
300 FB_FORMAT_STR(GL_DEPTH_STENCIL_ATTACHMENT
)
303 for( int i
=0; i
<vg_list_size(formats
); i
++ )
304 if( formats
[i
].e
== e
)
305 return formats
[i
].str
;
311 * Convert OpenGL texture format enums from TexImage2D table 1,2 &
312 * RenderBufferStorage Table 1, into strings
314 VG_STATIC
const char *render_fb_format_str( GLenum format
)
316 struct { GLenum e
; const char *str
; }
320 FB_FORMAT_STR(GL_DEPTH_COMPONENT
)
321 FB_FORMAT_STR(GL_DEPTH_STENCIL
)
322 FB_FORMAT_STR(GL_RED
)
324 FB_FORMAT_STR(GL_RGB
)
325 FB_FORMAT_STR(GL_RGBA
)
327 /* Render buffer formats */
328 FB_FORMAT_STR(GL_DEPTH_COMPONENT16
)
329 FB_FORMAT_STR(GL_DEPTH_COMPONENT24
)
330 FB_FORMAT_STR(GL_DEPTH_COMPONENT32F
)
331 FB_FORMAT_STR(GL_DEPTH24_STENCIL8
)
332 FB_FORMAT_STR(GL_DEPTH32F_STENCIL8
)
333 FB_FORMAT_STR(GL_STENCIL_INDEX8
)
337 FB_FORMAT_STR(GL_R8_SNORM
)
338 FB_FORMAT_STR(GL_R16
)
339 FB_FORMAT_STR(GL_R16_SNORM
)
340 FB_FORMAT_STR(GL_RG8
)
341 FB_FORMAT_STR(GL_RG8_SNORM
)
342 FB_FORMAT_STR(GL_RG16
)
343 FB_FORMAT_STR(GL_RG16_SNORM
)
344 FB_FORMAT_STR(GL_R3_G3_B2
)
345 FB_FORMAT_STR(GL_RGB4
)
346 FB_FORMAT_STR(GL_RGB5
)
347 FB_FORMAT_STR(GL_RGB8
)
348 FB_FORMAT_STR(GL_RGB8_SNORM
)
349 FB_FORMAT_STR(GL_RGB10
)
350 FB_FORMAT_STR(GL_RGB12
)
351 FB_FORMAT_STR(GL_RGB16_SNORM
)
352 FB_FORMAT_STR(GL_RGBA2
)
353 FB_FORMAT_STR(GL_RGBA4
)
354 FB_FORMAT_STR(GL_RGB5_A1
)
355 FB_FORMAT_STR(GL_RGBA8
)
356 FB_FORMAT_STR(GL_RGBA8_SNORM
)
357 FB_FORMAT_STR(GL_RGB10_A2
)
358 FB_FORMAT_STR(GL_RGB10_A2UI
)
359 FB_FORMAT_STR(GL_RGBA12
)
360 FB_FORMAT_STR(GL_RGBA16
)
361 FB_FORMAT_STR(GL_SRGB8
)
362 FB_FORMAT_STR(GL_SRGB8_ALPHA8
)
363 FB_FORMAT_STR(GL_R16F
)
364 FB_FORMAT_STR(GL_RG16F
)
365 FB_FORMAT_STR(GL_RGB16F
)
366 FB_FORMAT_STR(GL_RGBA16F
)
367 FB_FORMAT_STR(GL_R32F
)
368 FB_FORMAT_STR(GL_RG32F
)
369 FB_FORMAT_STR(GL_RGB32F
)
370 FB_FORMAT_STR(GL_RGBA32F
)
371 FB_FORMAT_STR(GL_R11F_G11F_B10F
)
372 FB_FORMAT_STR(GL_RGB9_E5
)
373 FB_FORMAT_STR(GL_R8I
)
374 FB_FORMAT_STR(GL_R8UI
)
375 FB_FORMAT_STR(GL_R16I
)
376 FB_FORMAT_STR(GL_R16UI
)
377 FB_FORMAT_STR(GL_R32I
)
378 FB_FORMAT_STR(GL_R32UI
)
379 FB_FORMAT_STR(GL_RG8I
)
380 FB_FORMAT_STR(GL_RG8UI
)
381 FB_FORMAT_STR(GL_RG16I
)
382 FB_FORMAT_STR(GL_RG16UI
)
383 FB_FORMAT_STR(GL_RG32I
)
384 FB_FORMAT_STR(GL_RG32UI
)
385 FB_FORMAT_STR(GL_RGB8I
)
386 FB_FORMAT_STR(GL_RGB8UI
)
387 FB_FORMAT_STR(GL_RGB16I
)
388 FB_FORMAT_STR(GL_RGB16UI
)
389 FB_FORMAT_STR(GL_RGB32I
)
390 FB_FORMAT_STR(GL_RGB32UI
)
391 FB_FORMAT_STR(GL_RGBA8I
)
392 FB_FORMAT_STR(GL_RGBA8UI
)
393 FB_FORMAT_STR(GL_RGBA16I
)
394 FB_FORMAT_STR(GL_RGBA16UI
)
395 FB_FORMAT_STR(GL_RGBA32I
)
396 FB_FORMAT_STR(GL_RGBA32UI
)
399 for( int i
=0; i
<vg_list_size(formats
); i
++ )
400 if( formats
[i
].e
== format
)
401 return formats
[i
].str
;
407 * Bind and allocate texture for framebuffer attachment
409 VG_STATIC
void render_fb_allocate_texture( struct framebuffer
*fb
,
410 struct framebuffer_attachment
*a
)
413 render_fb_get_current_res( fb
, &rx
, &ry
);
415 if( a
->purpose
== k_framebuffer_attachment_type_renderbuffer
){
416 glBindRenderbuffer( GL_RENDERBUFFER
, a
->id
);
417 glRenderbufferStorage( GL_RENDERBUFFER
, a
->internalformat
, rx
, ry
);
419 else if( a
->purpose
== k_framebuffer_attachment_type_texture
||
420 a
->purpose
== k_framebuffer_attachment_type_texture_depth
)
422 glBindTexture( GL_TEXTURE_2D
, a
->id
);
423 glTexImage2D( GL_TEXTURE_2D
, 0, a
->internalformat
, rx
, ry
,
424 0, a
->format
, a
->type
, NULL
);
429 * Full allocation of a framebuffer
431 VG_STATIC
void render_fb_allocate( struct framebuffer
*fb
)
433 glGenFramebuffers( 1, &fb
->fb
);
434 glBindFramebuffer( GL_FRAMEBUFFER
, fb
->fb
);
437 render_fb_get_current_res( fb
, &rx
, &ry
);
439 vg_info( "allocate_framebuffer( %s, %dx%d )\n", fb
->display_name
, rx
, ry
);
442 GLenum colour_attachments
[4];
443 u32 colour_count
= 0;
445 for( int j
=0; j
<vg_list_size(fb
->attachments
); j
++ ){
446 struct framebuffer_attachment
*attachment
= &fb
->attachments
[j
];
448 if( attachment
->purpose
== k_framebuffer_attachment_type_none
)
451 vg_info( " %s: %s\n",
452 render_fb_attachment_str( attachment
->attachment
),
453 render_fb_format_str( attachment
->internalformat
) );
455 if( attachment
->purpose
== k_framebuffer_attachment_type_renderbuffer
){
456 glGenRenderbuffers( 1, &attachment
->id
);
457 render_fb_allocate_texture( fb
, attachment
);
458 glFramebufferRenderbuffer( GL_FRAMEBUFFER
,
459 GL_DEPTH_STENCIL_ATTACHMENT
,
460 GL_RENDERBUFFER
, attachment
->id
);
462 else if( attachment
->purpose
== k_framebuffer_attachment_type_texture
||
463 attachment
->purpose
== k_framebuffer_attachment_type_texture_depth
)
465 glGenTextures( 1, &attachment
->id
);
466 render_fb_allocate_texture( fb
, attachment
);
467 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
468 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_LINEAR
);
469 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_WRAP_S
, GL_CLAMP_TO_EDGE
);
470 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_WRAP_T
, GL_CLAMP_TO_EDGE
);
472 glFramebufferTexture2D( GL_FRAMEBUFFER
, attachment
->attachment
,
473 GL_TEXTURE_2D
, attachment
->id
, 0 );
475 if( attachment
->purpose
== k_framebuffer_attachment_type_texture
)
476 colour_attachments
[ colour_count
++ ] = attachment
->attachment
;
480 glDrawBuffers( colour_count
, colour_attachments
);
485 GLenum result
= glCheckFramebufferStatus( GL_FRAMEBUFFER
);
487 if( result
== GL_FRAMEBUFFER_COMPLETE
){
489 * Attatch to gpipeline
494 vg_success( " status: complete\n" );
498 if( result
== GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
)
499 vg_error( " status: Incomplete attachment" );
500 else if( result
== GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
)
501 vg_error( " status: Missing attachment" );
502 else if( result
== GL_FRAMEBUFFER_UNSUPPORTED
)
503 vg_error( " status: Unsupported framebuffer format" );
505 vg_error( " status: Generic Error" );
508 vg_fatal_error( "Incomplete framebuffer (see logs)" );
513 * Resize/Update all framebuffers(we know about)
515 VG_STATIC
void render_fb_resize(void)
517 if( !gpipeline
.ready
)
520 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
521 struct framebuffer
*fb
= &framebuffers
[i
];
522 for( int j
=0; j
<vg_list_size(fb
->attachments
); j
++ ){
523 struct framebuffer_attachment
*attachment
= &fb
->attachments
[j
];
524 render_fb_allocate_texture( fb
, attachment
);
529 VG_STATIC
int render_framebuffer_control( int argc
, char const *argv
[] );
530 VG_STATIC
void render_framebuffer_poll( int argc
, char const *argv
[] );
532 VG_STATIC
void async_render_init( void *payload
, u32 size
)
535 * Complete Framebuffers
537 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
538 struct framebuffer
*fb
= &framebuffers
[i
];
539 render_fb_allocate( fb
);
543 0.00f
,0.00f
, 1.00f
,1.00f
, 0.00f
,1.00f
, /* fsquad */
544 0.00f
,0.00f
, 1.00f
,0.00f
, 1.00f
,1.00f
,
546 0.00f
,0.00f
, 1.00f
,0x1p
-4f
,0.00f
,0x1p
-4f
, /* fsquad1 */
547 0.00f
,0.00f
, 1.00f
,0.00f
, 1.00f
,0x1p
-4f
,
551 0.00f
,0.00f
, 0.30f
,0.30f
, 0.00f
,0.30f
,
552 0.00f
,0.00f
, 0.30f
,0.00f
, 0.30f
,0.30f
,
553 0.30f
,0.00f
, 0.60f
,0.30f
, 0.30f
,0.30f
,
554 0.30f
,0.00f
, 0.60f
,0.00f
, 0.60f
,0.30f
,
555 0.60f
,0.00f
, 0.90f
,0.30f
, 0.60f
,0.30f
,
556 0.60f
,0.00f
, 0.90f
,0.00f
, 0.90f
,0.30f
,
558 0.00f
,0.30f
, 0.30f
,0.60f
, 0.00f
,0.60f
,
559 0.00f
,0.30f
, 0.30f
,0.30f
, 0.30f
,0.60f
,
560 0.30f
,0.30f
, 0.60f
,0.60f
, 0.30f
,0.60f
,
561 0.30f
,0.30f
, 0.60f
,0.30f
, 0.60f
,0.60f
,
562 0.60f
,0.30f
, 0.90f
,0.60f
, 0.60f
,0.60f
,
563 0.60f
,0.30f
, 0.90f
,0.30f
, 0.90f
,0.60f
,
565 0.00f
,0.60f
, 0.30f
,0.90f
, 0.00f
,0.90f
,
566 0.00f
,0.60f
, 0.30f
,0.60f
, 0.30f
,0.90f
,
567 0.30f
,0.60f
, 0.60f
,0.90f
, 0.30f
,0.90f
,
568 0.30f
,0.60f
, 0.60f
,0.60f
, 0.60f
,0.90f
,
569 0.60f
,0.60f
, 0.90f
,0.90f
, 0.60f
,0.90f
,
570 0.60f
,0.60f
, 0.90f
,0.60f
, 0.90f
,0.90f
,
573 vg_console_reg_cmd( "fb", render_framebuffer_control
,
574 render_framebuffer_poll
);
575 vg_console_reg_var( "render_scale", &gpipeline
.view_render_scale
,
576 k_var_dtype_f32
, VG_VAR_PERSISTENT
);
578 glGenVertexArrays( 1, &gpipeline
.fsquad
.vao
);
579 glGenBuffers( 1, &gpipeline
.fsquad
.vbo
);
580 glBindVertexArray( gpipeline
.fsquad
.vao
);
581 glBindBuffer( GL_ARRAY_BUFFER
, gpipeline
.fsquad
.vbo
);
582 glBufferData( GL_ARRAY_BUFFER
, sizeof(quad
), quad
, GL_STATIC_DRAW
);
583 glBindVertexArray( gpipeline
.fsquad
.vao
);
584 glVertexAttribPointer( 0, 2, GL_FLOAT
, GL_FALSE
,
585 sizeof(float)*2, (void*)0 );
586 glEnableVertexAttribArray( 0 );
590 glBindFramebuffer( GL_FRAMEBUFFER
, 0 );
594 VG_STATIC
void render_init(void)
596 shader_blit_register();
597 shader_blitblur_register();
598 shader_blitcolour_register();
600 vg_async_call( async_render_init
, NULL
, 0 );
606 VG_STATIC
void render_fsquad(void)
608 glBindVertexArray( gpipeline
.fsquad
.vao
);
609 glDrawArrays( GL_TRIANGLES
, 0, 6 );
612 VG_STATIC
void render_fsquad1(void)
614 glBindVertexArray( gpipeline
.fsquad
.vao
);
615 glDrawArrays( GL_TRIANGLES
, 6, 6 );
619 * Call this inside the UI function
621 VG_STATIC
void render_view_framebuffer_ui(void)
624 int viewing_count
= 0;
626 glBindVertexArray( gpipeline
.fsquad
.vao
);
628 shader_blit_uTexMain( 0 );
630 v2f identity
= { 1.0f
, 1.0f
};
631 shader_blit_uInverseRatio( identity
);
633 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
634 struct framebuffer
*fb
= &framebuffers
[i
];
636 for( int j
=0; j
<vg_list_size(fb
->attachments
); j
++ ){
637 struct framebuffer_attachment
*at
= &fb
->attachments
[j
];
639 if( !at
->debug_view
)
643 window
= { vg
.window_x
, vg
.window_y
};
645 corner
[0] = viewing_count
% 3;
646 corner
[1] = 1 + (viewing_count
/ 3);
647 v2_mul( corner
, window
, corner
);
648 v2_muls( corner
, 0.3f
, corner
);
649 corner
[1] = vg
.window_y
- corner
[1];
651 ui_text( (ui_rect
){ corner
[0], corner
[1], 0.0f
, 0.0f
},
652 fb
->display_name
, 2, k_text_align_left
);
653 ui_text( (ui_rect
){ corner
[0], corner
[1] + 32, 0.0f
, 0.0f
, },
654 at
->display_name
, 1, k_text_align_left
);
656 if( at
->purpose
== k_framebuffer_attachment_type_renderbuffer
){
658 v2_muladds( corner
, window
, 0.15f
, center
);
660 ui_text( (ui_rect
){ center
[0], center
[1], 0.0f
, 0.0f
},
661 "<hardware texture>", 1, k_text_align_center
);
664 render_fb_bind_texture( fb
, j
, 0 );
666 int start
= (viewing_count
+2) * 6,
668 glDrawArrays( GL_TRIANGLES
, start
, count
);
677 VG_STATIC
void render_framebuffer_show( struct framebuffer
*fb
,
678 struct framebuffer_attachment
*at
,
681 at
->debug_view
= operation
;
682 vg_info( "%s %s:%s\n", (operation
?"shown": "hidden"),
683 fb
->display_name
, at
->display_name
);
687 * arg0: command "show"/"hide"
688 * arg1: framebuffer name <name>/"all"
689 * arg2: subname <name>/none
691 VG_STATIC
int render_framebuffer_control( int argc
, char const *argv
[] )
694 vg_error( "Usage: fb \"show/hide\" <name>/\"all\" <name>/none\n" );
701 if( !strcmp( argv
[0], "show" ) )
703 else if( !strcmp( argv
[0], "hide" ) )
706 vg_error( "Unknown framebuffer operation: '%s'\n", argv
[0] );
710 if( !strcmp( argv
[1], "all" ) )
713 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
714 struct framebuffer
*fb
= &framebuffers
[i
];
716 for( int j
=0; j
<vg_list_size(fb
->attachments
); j
++ ){
717 struct framebuffer_attachment
*at
= &fb
->attachments
[j
];
719 if( at
->purpose
== k_framebuffer_attachment_type_none
)
723 render_framebuffer_show( fb
, at
, operation
);
726 if( !strcmp( fb
->display_name
, argv
[1] ) ){
728 render_framebuffer_show( fb
, at
, operation
);
729 else if( !strcmp( at
->display_name
, argv
[2] ) )
730 render_framebuffer_show( fb
, at
, operation
);
739 VG_STATIC
void render_framebuffer_poll( int argc
, char const *argv
[] )
741 const char *term
= argv
[argc
-1];
744 console_suggest_score_text( "show", term
, 0 );
745 console_suggest_score_text( "hide", term
, 0 );
747 else if( argc
== 2 ){
748 console_suggest_score_text( "all", term
, 0 );
750 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
751 struct framebuffer
*fb
= &framebuffers
[i
];
752 console_suggest_score_text( fb
->display_name
, term
, 0 );
755 else if( argc
== 3 ){
758 if( !strcmp( argv
[1], "all" ) )
761 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
762 struct framebuffer
*fb
= &framebuffers
[i
];
764 for( int j
=0; j
<vg_list_size(fb
->attachments
); j
++ ){
765 struct framebuffer_attachment
*at
= &fb
->attachments
[j
];
767 if( at
->purpose
== k_framebuffer_attachment_type_none
)
771 console_suggest_score_text( at
->display_name
, term
, 0 );
773 else if( !strcmp( fb
->display_name
, argv
[1] ) ){
774 console_suggest_score_text( at
->display_name
, term
, 0 );
781 #endif /* RENDER_H */