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"
14 #define WORKSHOP_PREVIEW_WIDTH 504
15 #define WORKSHOP_PREVIEW_HEIGHT 336
19 static f32 k_render_scale
= 1.0f
;
20 static i32 k_blur_effect
= 1;
21 static f32 k_blur_strength
= 0.3f
;
22 static f32 k_fov
= 0.86f
;
24 typedef struct framebuffer framebuffer
;
27 * All standard buffers used in rendering
29 VG_STATIC
struct pipeline
{
41 const char *display_name
;
42 int resolution_div
, /* definition */
46 render_w
, /* runtime */
49 struct framebuffer_attachment
{
50 const char *display_name
;
52 enum framebuffer_attachment_type
{
53 k_framebuffer_attachment_type_none
,
54 k_framebuffer_attachment_type_texture
,
55 k_framebuffer_attachment_type_renderbuffer
,
56 k_framebuffer_attachment_type_texture_depth
60 enum framebuffer_quality_profile
{
61 k_framebuffer_quality_all
,
62 k_framebuffer_quality_high_only
66 GLenum internalformat
,
84 * The primary draw target
87 .link
= &gpipeline
.fb_main
,
92 "colour", k_framebuffer_attachment_type_texture
,
94 .internalformat
= GL_RGB
,
96 .type
= GL_UNSIGNED_BYTE
,
97 .attachment
= GL_COLOR_ATTACHMENT0
100 "motion", k_framebuffer_attachment_type_texture
,
102 .quality
= k_framebuffer_quality_high_only
,
103 .internalformat
= GL_RG16F
,
106 .attachment
= GL_COLOR_ATTACHMENT1
110 "depth_stencil", k_framebuffer_attachment_type_renderbuffer
,
112 .internalformat
= GL_DEPTH24_STENCIL8
,
114 "depth_stencil", k_framebuffer_attachment_type_texture_depth
,
115 .internalformat
= GL_DEPTH24_STENCIL8
,
116 .format
= GL_DEPTH_STENCIL
,
117 .type
= GL_UNSIGNED_INT_24_8
,
119 .attachment
= GL_DEPTH_STENCIL_ATTACHMENT
125 * Second rendered view from the perspective of the water reflection
128 .link
= &gpipeline
.fb_water_reflection
,
133 "colour", k_framebuffer_attachment_type_texture
,
134 .internalformat
= GL_RGB
,
136 .type
= GL_UNSIGNED_BYTE
,
137 .attachment
= GL_COLOR_ATTACHMENT0
140 "depth_stencil", k_framebuffer_attachment_type_renderbuffer
,
142 .internalformat
= GL_DEPTH24_STENCIL8
,
143 .attachment
= GL_DEPTH_STENCIL_ATTACHMENT
149 * Thid rendered view from the perspective of the camera, but just
150 * captures stuff thats under the water
153 .link
= &gpipeline
.fb_water_beneath
,
158 "colour", k_framebuffer_attachment_type_texture
,
159 .internalformat
= GL_RED
,
161 .type
= GL_UNSIGNED_BYTE
,
162 .attachment
= GL_COLOR_ATTACHMENT0
165 "depth_stencil", k_framebuffer_attachment_type_renderbuffer
,
167 .internalformat
= GL_DEPTH24_STENCIL8
,
168 .attachment
= GL_DEPTH_STENCIL_ATTACHMENT
174 .link
= &gpipeline
.fb_workshop_preview
,
176 .fixed_w
= WORKSHOP_PREVIEW_WIDTH
, .fixed_h
= WORKSHOP_PREVIEW_HEIGHT
,
180 "colour", k_framebuffer_attachment_type_texture
,
181 .internalformat
= GL_RGB
,
183 .type
= GL_UNSIGNED_BYTE
,
184 .attachment
= GL_COLOR_ATTACHMENT0
187 "depth_stencil", k_framebuffer_attachment_type_renderbuffer
,
188 .internalformat
= GL_DEPTH24_STENCIL8
,
189 .attachment
= GL_DEPTH_STENCIL_ATTACHMENT
196 * Get the current (automatically scaled or fixed) resolution of framebuffer
198 VG_STATIC
void render_fb_get_current_res( struct framebuffer
*fb
,
201 if( fb
->resolution_div
){
202 *x
= vg
.window_x
/ fb
->resolution_div
;
203 *y
= vg
.window_y
/ fb
->resolution_div
;
211 VG_STATIC
void render_fb_inverse_ratio( framebuffer
*fb
, v2f inverse
)
215 render_fb_get_current_res( fb
, &x
, &y
);
217 v2f render
= { fb
->render_w
, fb
->render_h
},
220 v2_div( render
, original
, inverse
);
223 v2_div( (v2f
){1.0f
,1.0f
}, (v2f
){ vg
.window_x
, vg
.window_y
}, inverse
);
228 * Bind framebuffer for drawing to
230 VG_STATIC
void render_fb_bind( framebuffer
*fb
, int use_scaling
)
233 render_fb_get_current_res( fb
, &x
, &y
);
236 x
= k_render_scale
*(float)x
;
237 y
= k_render_scale
*(float)y
;
246 glBindFramebuffer( GL_FRAMEBUFFER
, fb
->fb
);
247 glViewport( 0, 0, x
, y
);
251 * Bind framebuffer attachment's texture
253 VG_STATIC
void render_fb_bind_texture( framebuffer
*fb
,
254 int attachment
, int slot
)
256 struct framebuffer_attachment
*at
= &fb
->attachments
[attachment
];
258 if( (at
->purpose
!= k_framebuffer_attachment_type_texture
) &&
259 (at
->purpose
!= k_framebuffer_attachment_type_texture_depth
) )
261 vg_fatal_error( "illegal operation: bind non-texture framebuffer"
262 " attachment to texture slot" );
265 glActiveTexture( GL_TEXTURE0
+ slot
);
266 glBindTexture( GL_TEXTURE_2D
, fb
->attachments
[attachment
].id
);
274 #define FB_FORMAT_STR( E ) { E, #E },
277 * Convert OpenGL attachment ID enum to string
279 VG_STATIC
const char *render_fb_attachment_str( GLenum e
)
281 struct { GLenum e
; const char *str
; }
284 FB_FORMAT_STR(GL_COLOR_ATTACHMENT0
)
285 FB_FORMAT_STR(GL_COLOR_ATTACHMENT1
)
286 FB_FORMAT_STR(GL_COLOR_ATTACHMENT2
)
287 FB_FORMAT_STR(GL_COLOR_ATTACHMENT3
)
288 FB_FORMAT_STR(GL_COLOR_ATTACHMENT4
)
289 FB_FORMAT_STR(GL_DEPTH_STENCIL_ATTACHMENT
)
292 for( int i
=0; i
<vg_list_size(formats
); i
++ )
293 if( formats
[i
].e
== e
)
294 return formats
[i
].str
;
300 * Convert OpenGL texture format enums from TexImage2D table 1,2 &
301 * RenderBufferStorage Table 1, into strings
303 VG_STATIC
const char *render_fb_format_str( GLenum format
)
305 struct { GLenum e
; const char *str
; }
309 FB_FORMAT_STR(GL_DEPTH_COMPONENT
)
310 FB_FORMAT_STR(GL_DEPTH_STENCIL
)
311 FB_FORMAT_STR(GL_RED
)
313 FB_FORMAT_STR(GL_RGB
)
314 FB_FORMAT_STR(GL_RGBA
)
316 /* Render buffer formats */
317 FB_FORMAT_STR(GL_DEPTH_COMPONENT16
)
318 FB_FORMAT_STR(GL_DEPTH_COMPONENT24
)
319 FB_FORMAT_STR(GL_DEPTH_COMPONENT32F
)
320 FB_FORMAT_STR(GL_DEPTH24_STENCIL8
)
321 FB_FORMAT_STR(GL_DEPTH32F_STENCIL8
)
322 FB_FORMAT_STR(GL_STENCIL_INDEX8
)
326 FB_FORMAT_STR(GL_R8_SNORM
)
327 FB_FORMAT_STR(GL_R16
)
328 FB_FORMAT_STR(GL_R16_SNORM
)
329 FB_FORMAT_STR(GL_RG8
)
330 FB_FORMAT_STR(GL_RG8_SNORM
)
331 FB_FORMAT_STR(GL_RG16
)
332 FB_FORMAT_STR(GL_RG16_SNORM
)
333 FB_FORMAT_STR(GL_R3_G3_B2
)
334 FB_FORMAT_STR(GL_RGB4
)
335 FB_FORMAT_STR(GL_RGB5
)
336 FB_FORMAT_STR(GL_RGB8
)
337 FB_FORMAT_STR(GL_RGB8_SNORM
)
338 FB_FORMAT_STR(GL_RGB10
)
339 FB_FORMAT_STR(GL_RGB12
)
340 FB_FORMAT_STR(GL_RGB16_SNORM
)
341 FB_FORMAT_STR(GL_RGBA2
)
342 FB_FORMAT_STR(GL_RGBA4
)
343 FB_FORMAT_STR(GL_RGB5_A1
)
344 FB_FORMAT_STR(GL_RGBA8
)
345 FB_FORMAT_STR(GL_RGBA8_SNORM
)
346 FB_FORMAT_STR(GL_RGB10_A2
)
347 FB_FORMAT_STR(GL_RGB10_A2UI
)
348 FB_FORMAT_STR(GL_RGBA12
)
349 FB_FORMAT_STR(GL_RGBA16
)
350 FB_FORMAT_STR(GL_SRGB8
)
351 FB_FORMAT_STR(GL_SRGB8_ALPHA8
)
352 FB_FORMAT_STR(GL_R16F
)
353 FB_FORMAT_STR(GL_RG16F
)
354 FB_FORMAT_STR(GL_RGB16F
)
355 FB_FORMAT_STR(GL_RGBA16F
)
356 FB_FORMAT_STR(GL_R32F
)
357 FB_FORMAT_STR(GL_RG32F
)
358 FB_FORMAT_STR(GL_RGB32F
)
359 FB_FORMAT_STR(GL_RGBA32F
)
360 FB_FORMAT_STR(GL_R11F_G11F_B10F
)
361 FB_FORMAT_STR(GL_RGB9_E5
)
362 FB_FORMAT_STR(GL_R8I
)
363 FB_FORMAT_STR(GL_R8UI
)
364 FB_FORMAT_STR(GL_R16I
)
365 FB_FORMAT_STR(GL_R16UI
)
366 FB_FORMAT_STR(GL_R32I
)
367 FB_FORMAT_STR(GL_R32UI
)
368 FB_FORMAT_STR(GL_RG8I
)
369 FB_FORMAT_STR(GL_RG8UI
)
370 FB_FORMAT_STR(GL_RG16I
)
371 FB_FORMAT_STR(GL_RG16UI
)
372 FB_FORMAT_STR(GL_RG32I
)
373 FB_FORMAT_STR(GL_RG32UI
)
374 FB_FORMAT_STR(GL_RGB8I
)
375 FB_FORMAT_STR(GL_RGB8UI
)
376 FB_FORMAT_STR(GL_RGB16I
)
377 FB_FORMAT_STR(GL_RGB16UI
)
378 FB_FORMAT_STR(GL_RGB32I
)
379 FB_FORMAT_STR(GL_RGB32UI
)
380 FB_FORMAT_STR(GL_RGBA8I
)
381 FB_FORMAT_STR(GL_RGBA8UI
)
382 FB_FORMAT_STR(GL_RGBA16I
)
383 FB_FORMAT_STR(GL_RGBA16UI
)
384 FB_FORMAT_STR(GL_RGBA32I
)
385 FB_FORMAT_STR(GL_RGBA32UI
)
388 for( int i
=0; i
<vg_list_size(formats
); i
++ )
389 if( formats
[i
].e
== format
)
390 return formats
[i
].str
;
396 * Bind and allocate texture for framebuffer attachment
398 VG_STATIC
void render_fb_allocate_texture( struct framebuffer
*fb
,
399 struct framebuffer_attachment
*a
)
402 render_fb_get_current_res( fb
, &rx
, &ry
);
404 if( a
->purpose
== k_framebuffer_attachment_type_renderbuffer
){
405 glBindRenderbuffer( GL_RENDERBUFFER
, a
->id
);
406 glRenderbufferStorage( GL_RENDERBUFFER
, a
->internalformat
, rx
, ry
);
408 else if( a
->purpose
== k_framebuffer_attachment_type_texture
||
409 a
->purpose
== k_framebuffer_attachment_type_texture_depth
)
411 glBindTexture( GL_TEXTURE_2D
, a
->id
);
412 glTexImage2D( GL_TEXTURE_2D
, 0, a
->internalformat
, rx
, ry
,
413 0, a
->format
, a
->type
, NULL
);
418 * Full allocation of a framebuffer
420 VG_STATIC
void render_fb_allocate( struct framebuffer
*fb
)
422 glGenFramebuffers( 1, &fb
->fb
);
423 glBindFramebuffer( GL_FRAMEBUFFER
, fb
->fb
);
426 render_fb_get_current_res( fb
, &rx
, &ry
);
428 vg_info( "allocate_framebuffer( %s, %dx%d )\n", fb
->display_name
, rx
, ry
);
431 GLenum colour_attachments
[4];
432 u32 colour_count
= 0;
434 for( int j
=0; j
<vg_list_size(fb
->attachments
); j
++ ){
435 struct framebuffer_attachment
*attachment
= &fb
->attachments
[j
];
437 if( attachment
->purpose
== k_framebuffer_attachment_type_none
)
440 vg_info( " %s: %s\n",
441 render_fb_attachment_str( attachment
->attachment
),
442 render_fb_format_str( attachment
->internalformat
) );
444 if( attachment
->purpose
== k_framebuffer_attachment_type_renderbuffer
){
445 glGenRenderbuffers( 1, &attachment
->id
);
446 render_fb_allocate_texture( fb
, attachment
);
447 glFramebufferRenderbuffer( GL_FRAMEBUFFER
,
448 GL_DEPTH_STENCIL_ATTACHMENT
,
449 GL_RENDERBUFFER
, attachment
->id
);
451 else if( attachment
->purpose
== k_framebuffer_attachment_type_texture
||
452 attachment
->purpose
== k_framebuffer_attachment_type_texture_depth
)
454 glGenTextures( 1, &attachment
->id
);
455 render_fb_allocate_texture( fb
, attachment
);
456 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
457 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_LINEAR
);
458 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_WRAP_S
, GL_CLAMP_TO_EDGE
);
459 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_WRAP_T
, GL_CLAMP_TO_EDGE
);
461 glFramebufferTexture2D( GL_FRAMEBUFFER
, attachment
->attachment
,
462 GL_TEXTURE_2D
, attachment
->id
, 0 );
464 if( attachment
->purpose
== k_framebuffer_attachment_type_texture
)
465 colour_attachments
[ colour_count
++ ] = attachment
->attachment
;
469 glDrawBuffers( colour_count
, colour_attachments
);
474 GLenum result
= glCheckFramebufferStatus( GL_FRAMEBUFFER
);
476 if( result
== GL_FRAMEBUFFER_COMPLETE
){
478 * Attatch to gpipeline
483 vg_success( " status: complete\n" );
487 if( result
== GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
)
488 vg_error( " status: Incomplete attachment" );
489 else if( result
== GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
)
490 vg_error( " status: Missing attachment" );
491 else if( result
== GL_FRAMEBUFFER_UNSUPPORTED
)
492 vg_error( " status: Unsupported framebuffer format" );
494 vg_error( " status: Generic Error" );
497 vg_fatal_error( "Incomplete framebuffer (see logs)" );
502 * Resize/Update all framebuffers(we know about)
504 VG_STATIC
void render_fb_resize(void)
506 if( !gpipeline
.ready
) return;
508 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
509 struct framebuffer
*fb
= &framebuffers
[i
];
510 for( int j
=0; j
<vg_list_size(fb
->attachments
); j
++ ){
511 struct framebuffer_attachment
*attachment
= &fb
->attachments
[j
];
512 render_fb_allocate_texture( fb
, attachment
);
517 VG_STATIC
int render_framebuffer_control( int argc
, char const *argv
[] );
518 VG_STATIC
void render_framebuffer_poll( int argc
, char const *argv
[] );
520 VG_STATIC
void async_render_init( void *payload
, u32 size
)
523 * Complete Framebuffers
525 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
526 struct framebuffer
*fb
= &framebuffers
[i
];
527 render_fb_allocate( fb
);
530 f32 rh
= 0x1p
-4f
, ih
= 0.3f
;
533 0.00f
,0.00f
, 1.00f
,1.00f
, 0.00f
,1.00f
, /* fsquad */
534 0.00f
,0.00f
, 1.00f
,0.00f
, 1.00f
,1.00f
,
536 0.00f
,0.00f
, 1.00f
,rh
, 0.00f
,rh
, /* fsquad1 */
537 0.00f
,0.00f
, 1.00f
,0.00f
, 1.00f
,rh
,
541 0.00f
,0.00f
, 0.30f
,0.30f
, 0.00f
,0.30f
,
542 0.00f
,0.00f
, 0.30f
,0.00f
, 0.30f
,0.30f
,
543 0.30f
,0.00f
, 0.60f
,0.30f
, 0.30f
,0.30f
,
544 0.30f
,0.00f
, 0.60f
,0.00f
, 0.60f
,0.30f
,
545 0.60f
,0.00f
, 0.90f
,0.30f
, 0.60f
,0.30f
,
546 0.60f
,0.00f
, 0.90f
,0.00f
, 0.90f
,0.30f
,
548 0.00f
,0.30f
, 0.30f
,0.60f
, 0.00f
,0.60f
,
549 0.00f
,0.30f
, 0.30f
,0.30f
, 0.30f
,0.60f
,
550 0.30f
,0.30f
, 0.60f
,0.60f
, 0.30f
,0.60f
,
551 0.30f
,0.30f
, 0.60f
,0.30f
, 0.60f
,0.60f
,
552 0.60f
,0.30f
, 0.90f
,0.60f
, 0.60f
,0.60f
,
553 0.60f
,0.30f
, 0.90f
,0.30f
, 0.90f
,0.60f
,
555 0.00f
,0.60f
, 0.30f
,0.90f
, 0.00f
,0.90f
,
556 0.00f
,0.60f
, 0.30f
,0.60f
, 0.30f
,0.90f
,
557 0.30f
,0.60f
, 0.60f
,0.90f
, 0.30f
,0.90f
,
558 0.30f
,0.60f
, 0.60f
,0.60f
, 0.60f
,0.90f
,
559 0.60f
,0.60f
, 0.90f
,0.90f
, 0.60f
,0.90f
,
560 0.60f
,0.60f
, 0.90f
,0.60f
, 0.90f
,0.90f
,
562 0.00f
,ih
, 1.00f
,ih
+rh
, 0.00f
,ih
+rh
, /* fsquad2 */
563 0.00f
,ih
, 1.00f
,ih
, 1.00f
,ih
+rh
,
566 vg_console_reg_cmd( "fb", render_framebuffer_control
,
567 render_framebuffer_poll
);
568 glGenVertexArrays( 1, &gpipeline
.fsquad
.vao
);
569 glGenBuffers( 1, &gpipeline
.fsquad
.vbo
);
570 glBindVertexArray( gpipeline
.fsquad
.vao
);
571 glBindBuffer( GL_ARRAY_BUFFER
, gpipeline
.fsquad
.vbo
);
572 glBufferData( GL_ARRAY_BUFFER
, sizeof(quad
), quad
, GL_STATIC_DRAW
);
573 glBindVertexArray( gpipeline
.fsquad
.vao
);
574 glVertexAttribPointer( 0, 2, GL_FLOAT
, GL_FALSE
,
575 sizeof(float)*2, (void*)0 );
576 glEnableVertexAttribArray( 0 );
580 glBindFramebuffer( GL_FRAMEBUFFER
, 0 );
584 VG_STATIC
void render_init(void)
586 vg_console_reg_var( "blur_strength", &k_blur_strength
, k_var_dtype_f32
, 0 );
587 vg_console_reg_var( "render_scale", &k_render_scale
,
588 k_var_dtype_f32
, VG_VAR_PERSISTENT
);
589 vg_console_reg_var( "fov", &k_fov
, k_var_dtype_f32
, VG_VAR_PERSISTENT
);
590 vg_console_reg_var( "blur_effect", &k_blur_effect
,
591 k_var_dtype_i32
, VG_VAR_PERSISTENT
);
594 shader_blit_register();
595 shader_blitblur_register();
596 shader_blitcolour_register();
598 vg_async_call( async_render_init
, NULL
, 0 );
604 VG_STATIC
void render_fsquad(void)
606 glBindVertexArray( gpipeline
.fsquad
.vao
);
607 glDrawArrays( GL_TRIANGLES
, 0, 6 );
610 VG_STATIC
void render_fsquad1(void)
612 glBindVertexArray( gpipeline
.fsquad
.vao
);
613 glDrawArrays( GL_TRIANGLES
, 6, 6 );
616 VG_STATIC
void render_fsquad2(void)
618 glBindVertexArray( gpipeline
.fsquad
.vao
);
619 glDrawArrays( GL_TRIANGLES
, 66,6 );
623 * Call this inside the UI function
625 VG_STATIC
void render_view_framebuffer_ui(void)
628 int viewing_count
= 0;
630 glBindVertexArray( gpipeline
.fsquad
.vao
);
632 shader_blit_uTexMain( 0 );
634 v2f identity
= { 1.0f
, 1.0f
};
635 shader_blit_uInverseRatio( identity
);
637 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
638 struct framebuffer
*fb
= &framebuffers
[i
];
640 for( int j
=0; j
<vg_list_size(fb
->attachments
); j
++ ){
641 struct framebuffer_attachment
*at
= &fb
->attachments
[j
];
643 if( !at
->debug_view
)
647 window
= { vg
.window_x
, vg
.window_y
};
649 corner
[0] = viewing_count
% 3;
650 corner
[1] = 1 + (viewing_count
/ 3);
651 v2_mul( corner
, window
, corner
);
652 v2_muls( corner
, 0.3f
, corner
);
653 corner
[1] = vg
.window_y
- corner
[1];
655 ui_text( (ui_rect
){ corner
[0], corner
[1], 0.0f
, 0.0f
},
656 fb
->display_name
, 2, k_text_align_left
);
657 ui_text( (ui_rect
){ corner
[0], corner
[1] + 32, 0.0f
, 0.0f
, },
658 at
->display_name
, 1, k_text_align_left
);
660 if( at
->purpose
== k_framebuffer_attachment_type_renderbuffer
){
662 v2_muladds( corner
, window
, 0.15f
, center
);
664 ui_text( (ui_rect
){ center
[0], center
[1], 0.0f
, 0.0f
},
665 "<hardware texture>", 1, k_text_align_center
);
668 render_fb_bind_texture( fb
, j
, 0 );
670 int start
= (viewing_count
+2) * 6,
672 glDrawArrays( GL_TRIANGLES
, start
, count
);
681 VG_STATIC
void render_framebuffer_show( struct framebuffer
*fb
,
682 struct framebuffer_attachment
*at
,
685 at
->debug_view
= operation
;
686 vg_info( "%s %s:%s\n", (operation
?"shown": "hidden"),
687 fb
->display_name
, at
->display_name
);
691 * arg0: command "show"/"hide"
692 * arg1: framebuffer name <name>/"all"
693 * arg2: subname <name>/none
695 VG_STATIC
int render_framebuffer_control( int argc
, char const *argv
[] )
698 vg_error( "Usage: fb \"show/hide\" <name>/\"all\" <name>/none\n" );
705 if( !strcmp( argv
[0], "show" ) )
707 else if( !strcmp( argv
[0], "hide" ) )
710 vg_error( "Unknown framebuffer operation: '%s'\n", argv
[0] );
714 if( !strcmp( argv
[1], "all" ) )
717 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
718 struct framebuffer
*fb
= &framebuffers
[i
];
720 for( int j
=0; j
<vg_list_size(fb
->attachments
); j
++ ){
721 struct framebuffer_attachment
*at
= &fb
->attachments
[j
];
723 if( at
->purpose
== k_framebuffer_attachment_type_none
)
727 render_framebuffer_show( fb
, at
, operation
);
730 if( !strcmp( fb
->display_name
, argv
[1] ) ){
732 render_framebuffer_show( fb
, at
, operation
);
733 else if( !strcmp( at
->display_name
, argv
[2] ) )
734 render_framebuffer_show( fb
, at
, operation
);
743 VG_STATIC
void render_framebuffer_poll( int argc
, char const *argv
[] )
745 const char *term
= argv
[argc
-1];
748 console_suggest_score_text( "show", term
, 0 );
749 console_suggest_score_text( "hide", term
, 0 );
751 else if( argc
== 2 ){
752 console_suggest_score_text( "all", term
, 0 );
754 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
755 struct framebuffer
*fb
= &framebuffers
[i
];
756 console_suggest_score_text( fb
->display_name
, term
, 0 );
759 else if( argc
== 3 ){
762 if( !strcmp( argv
[1], "all" ) )
765 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
766 struct framebuffer
*fb
= &framebuffers
[i
];
768 for( int j
=0; j
<vg_list_size(fb
->attachments
); j
++ ){
769 struct framebuffer_attachment
*at
= &fb
->attachments
[j
];
771 if( at
->purpose
== k_framebuffer_attachment_type_none
)
775 console_suggest_score_text( at
->display_name
, term
, 0 );
777 else if( !strcmp( fb
->display_name
, argv
[1] ) ){
778 console_suggest_score_text( at
->display_name
, term
, 0 );
785 #endif /* RENDER_H */