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
;
23 static f32 k_cam_height
= 0.8f
;
25 typedef struct framebuffer framebuffer
;
28 * All standard buffers used in rendering
30 static struct pipeline
{
42 const char *display_name
;
43 int resolution_div
, /* definition */
47 render_w
, /* runtime */
50 struct framebuffer_attachment
{
51 const char *display_name
;
53 enum framebuffer_attachment_type
{
54 k_framebuffer_attachment_type_none
,
55 k_framebuffer_attachment_type_texture
,
56 k_framebuffer_attachment_type_renderbuffer
,
57 k_framebuffer_attachment_type_texture_depth
61 enum framebuffer_quality_profile
{
62 k_framebuffer_quality_all
,
63 k_framebuffer_quality_high_only
67 GLenum internalformat
,
85 * The primary draw target
88 .link
= &gpipeline
.fb_main
,
93 "colour", k_framebuffer_attachment_type_texture
,
95 .internalformat
= GL_RGB
,
97 .type
= GL_UNSIGNED_BYTE
,
98 .attachment
= GL_COLOR_ATTACHMENT0
101 "motion", k_framebuffer_attachment_type_texture
,
103 .quality
= k_framebuffer_quality_high_only
,
104 .internalformat
= GL_RG16F
,
107 .attachment
= GL_COLOR_ATTACHMENT1
111 "depth_stencil", k_framebuffer_attachment_type_renderbuffer
,
113 .internalformat
= GL_DEPTH24_STENCIL8
,
115 "depth_stencil", k_framebuffer_attachment_type_texture_depth
,
116 .internalformat
= GL_DEPTH24_STENCIL8
,
117 .format
= GL_DEPTH_STENCIL
,
118 .type
= GL_UNSIGNED_INT_24_8
,
120 .attachment
= GL_DEPTH_STENCIL_ATTACHMENT
126 * Second rendered view from the perspective of the water reflection
129 .link
= &gpipeline
.fb_water_reflection
,
134 "colour", k_framebuffer_attachment_type_texture
,
135 .internalformat
= GL_RGB
,
137 .type
= GL_UNSIGNED_BYTE
,
138 .attachment
= GL_COLOR_ATTACHMENT0
141 "depth_stencil", k_framebuffer_attachment_type_renderbuffer
,
143 .internalformat
= GL_DEPTH24_STENCIL8
,
144 .attachment
= GL_DEPTH_STENCIL_ATTACHMENT
150 * Thid rendered view from the perspective of the camera, but just
151 * captures stuff thats under the water
154 .link
= &gpipeline
.fb_water_beneath
,
159 "colour", k_framebuffer_attachment_type_texture
,
160 .internalformat
= GL_RED
,
162 .type
= GL_UNSIGNED_BYTE
,
163 .attachment
= GL_COLOR_ATTACHMENT0
166 "depth_stencil", k_framebuffer_attachment_type_renderbuffer
,
168 .internalformat
= GL_DEPTH24_STENCIL8
,
169 .attachment
= GL_DEPTH_STENCIL_ATTACHMENT
175 .link
= &gpipeline
.fb_workshop_preview
,
177 .fixed_w
= WORKSHOP_PREVIEW_WIDTH
, .fixed_h
= WORKSHOP_PREVIEW_HEIGHT
,
181 "colour", k_framebuffer_attachment_type_texture
,
182 .internalformat
= GL_RGB
,
184 .type
= GL_UNSIGNED_BYTE
,
185 .attachment
= GL_COLOR_ATTACHMENT0
188 "depth_stencil", k_framebuffer_attachment_type_renderbuffer
,
189 .internalformat
= GL_DEPTH24_STENCIL8
,
190 .attachment
= GL_DEPTH_STENCIL_ATTACHMENT
197 * Get the current (automatically scaled or fixed) resolution of framebuffer
199 static void render_fb_get_current_res( struct framebuffer
*fb
,
202 if( fb
->resolution_div
){
203 *x
= vg
.window_x
/ fb
->resolution_div
;
204 *y
= vg
.window_y
/ fb
->resolution_div
;
212 static void render_fb_inverse_ratio( framebuffer
*fb
, v2f inverse
)
216 render_fb_get_current_res( fb
, &x
, &y
);
218 v2f render
= { fb
->render_w
, fb
->render_h
},
221 v2_div( render
, original
, inverse
);
224 v2_div( (v2f
){1.0f
,1.0f
}, (v2f
){ vg
.window_x
, vg
.window_y
}, inverse
);
229 * Bind framebuffer for drawing to
231 static void render_fb_bind( framebuffer
*fb
, int use_scaling
)
234 render_fb_get_current_res( fb
, &x
, &y
);
237 x
= k_render_scale
*(float)x
;
238 y
= k_render_scale
*(float)y
;
247 glBindFramebuffer( GL_FRAMEBUFFER
, fb
->fb
);
248 glViewport( 0, 0, x
, y
);
252 * Bind framebuffer attachment's texture
254 static void render_fb_bind_texture( framebuffer
*fb
,
255 int attachment
, int slot
)
257 struct framebuffer_attachment
*at
= &fb
->attachments
[attachment
];
259 if( (at
->purpose
!= k_framebuffer_attachment_type_texture
) &&
260 (at
->purpose
!= k_framebuffer_attachment_type_texture_depth
) )
262 vg_fatal_error( "illegal operation: bind non-texture framebuffer"
263 " attachment to texture slot" );
266 glActiveTexture( GL_TEXTURE0
+ slot
);
267 glBindTexture( GL_TEXTURE_2D
, fb
->attachments
[attachment
].id
);
275 #define FB_FORMAT_STR( E ) { E, #E },
278 * Convert OpenGL attachment ID enum to string
280 static const char *render_fb_attachment_str( GLenum e
)
282 struct { GLenum e
; const char *str
; }
285 FB_FORMAT_STR(GL_COLOR_ATTACHMENT0
)
286 FB_FORMAT_STR(GL_COLOR_ATTACHMENT1
)
287 FB_FORMAT_STR(GL_COLOR_ATTACHMENT2
)
288 FB_FORMAT_STR(GL_COLOR_ATTACHMENT3
)
289 FB_FORMAT_STR(GL_COLOR_ATTACHMENT4
)
290 FB_FORMAT_STR(GL_DEPTH_STENCIL_ATTACHMENT
)
293 for( int i
=0; i
<vg_list_size(formats
); i
++ )
294 if( formats
[i
].e
== e
)
295 return formats
[i
].str
;
301 * Convert OpenGL texture format enums from TexImage2D table 1,2 &
302 * RenderBufferStorage Table 1, into strings
304 static const char *render_fb_format_str( GLenum format
)
306 struct { GLenum e
; const char *str
; }
310 FB_FORMAT_STR(GL_DEPTH_COMPONENT
)
311 FB_FORMAT_STR(GL_DEPTH_STENCIL
)
312 FB_FORMAT_STR(GL_RED
)
314 FB_FORMAT_STR(GL_RGB
)
315 FB_FORMAT_STR(GL_RGBA
)
317 /* Render buffer formats */
318 FB_FORMAT_STR(GL_DEPTH_COMPONENT16
)
319 FB_FORMAT_STR(GL_DEPTH_COMPONENT24
)
320 FB_FORMAT_STR(GL_DEPTH_COMPONENT32F
)
321 FB_FORMAT_STR(GL_DEPTH24_STENCIL8
)
322 FB_FORMAT_STR(GL_DEPTH32F_STENCIL8
)
323 FB_FORMAT_STR(GL_STENCIL_INDEX8
)
327 FB_FORMAT_STR(GL_R8_SNORM
)
328 FB_FORMAT_STR(GL_R16
)
329 FB_FORMAT_STR(GL_R16_SNORM
)
330 FB_FORMAT_STR(GL_RG8
)
331 FB_FORMAT_STR(GL_RG8_SNORM
)
332 FB_FORMAT_STR(GL_RG16
)
333 FB_FORMAT_STR(GL_RG16_SNORM
)
334 FB_FORMAT_STR(GL_R3_G3_B2
)
335 FB_FORMAT_STR(GL_RGB4
)
336 FB_FORMAT_STR(GL_RGB5
)
337 FB_FORMAT_STR(GL_RGB8
)
338 FB_FORMAT_STR(GL_RGB8_SNORM
)
339 FB_FORMAT_STR(GL_RGB10
)
340 FB_FORMAT_STR(GL_RGB12
)
341 FB_FORMAT_STR(GL_RGB16_SNORM
)
342 FB_FORMAT_STR(GL_RGBA2
)
343 FB_FORMAT_STR(GL_RGBA4
)
344 FB_FORMAT_STR(GL_RGB5_A1
)
345 FB_FORMAT_STR(GL_RGBA8
)
346 FB_FORMAT_STR(GL_RGBA8_SNORM
)
347 FB_FORMAT_STR(GL_RGB10_A2
)
348 FB_FORMAT_STR(GL_RGB10_A2UI
)
349 FB_FORMAT_STR(GL_RGBA12
)
350 FB_FORMAT_STR(GL_RGBA16
)
351 FB_FORMAT_STR(GL_SRGB8
)
352 FB_FORMAT_STR(GL_SRGB8_ALPHA8
)
353 FB_FORMAT_STR(GL_R16F
)
354 FB_FORMAT_STR(GL_RG16F
)
355 FB_FORMAT_STR(GL_RGB16F
)
356 FB_FORMAT_STR(GL_RGBA16F
)
357 FB_FORMAT_STR(GL_R32F
)
358 FB_FORMAT_STR(GL_RG32F
)
359 FB_FORMAT_STR(GL_RGB32F
)
360 FB_FORMAT_STR(GL_RGBA32F
)
361 FB_FORMAT_STR(GL_R11F_G11F_B10F
)
362 FB_FORMAT_STR(GL_RGB9_E5
)
363 FB_FORMAT_STR(GL_R8I
)
364 FB_FORMAT_STR(GL_R8UI
)
365 FB_FORMAT_STR(GL_R16I
)
366 FB_FORMAT_STR(GL_R16UI
)
367 FB_FORMAT_STR(GL_R32I
)
368 FB_FORMAT_STR(GL_R32UI
)
369 FB_FORMAT_STR(GL_RG8I
)
370 FB_FORMAT_STR(GL_RG8UI
)
371 FB_FORMAT_STR(GL_RG16I
)
372 FB_FORMAT_STR(GL_RG16UI
)
373 FB_FORMAT_STR(GL_RG32I
)
374 FB_FORMAT_STR(GL_RG32UI
)
375 FB_FORMAT_STR(GL_RGB8I
)
376 FB_FORMAT_STR(GL_RGB8UI
)
377 FB_FORMAT_STR(GL_RGB16I
)
378 FB_FORMAT_STR(GL_RGB16UI
)
379 FB_FORMAT_STR(GL_RGB32I
)
380 FB_FORMAT_STR(GL_RGB32UI
)
381 FB_FORMAT_STR(GL_RGBA8I
)
382 FB_FORMAT_STR(GL_RGBA8UI
)
383 FB_FORMAT_STR(GL_RGBA16I
)
384 FB_FORMAT_STR(GL_RGBA16UI
)
385 FB_FORMAT_STR(GL_RGBA32I
)
386 FB_FORMAT_STR(GL_RGBA32UI
)
389 for( int i
=0; i
<vg_list_size(formats
); i
++ )
390 if( formats
[i
].e
== format
)
391 return formats
[i
].str
;
397 * Bind and allocate texture for framebuffer attachment
399 static void render_fb_allocate_texture( struct framebuffer
*fb
,
400 struct framebuffer_attachment
*a
)
403 render_fb_get_current_res( fb
, &rx
, &ry
);
405 if( a
->purpose
== k_framebuffer_attachment_type_renderbuffer
){
406 glBindRenderbuffer( GL_RENDERBUFFER
, a
->id
);
407 glRenderbufferStorage( GL_RENDERBUFFER
, a
->internalformat
, rx
, ry
);
409 else if( a
->purpose
== k_framebuffer_attachment_type_texture
||
410 a
->purpose
== k_framebuffer_attachment_type_texture_depth
)
412 glBindTexture( GL_TEXTURE_2D
, a
->id
);
413 glTexImage2D( GL_TEXTURE_2D
, 0, a
->internalformat
, rx
, ry
,
414 0, a
->format
, a
->type
, NULL
);
419 * Full allocation of a framebuffer
421 static void render_fb_allocate( struct framebuffer
*fb
)
423 glGenFramebuffers( 1, &fb
->fb
);
424 glBindFramebuffer( GL_FRAMEBUFFER
, fb
->fb
);
427 render_fb_get_current_res( fb
, &rx
, &ry
);
429 vg_info( "allocate_framebuffer( %s, %dx%d )\n", fb
->display_name
, rx
, ry
);
432 GLenum colour_attachments
[4];
433 u32 colour_count
= 0;
435 for( int j
=0; j
<vg_list_size(fb
->attachments
); j
++ ){
436 struct framebuffer_attachment
*attachment
= &fb
->attachments
[j
];
438 if( attachment
->purpose
== k_framebuffer_attachment_type_none
)
441 vg_info( " %s: %s\n",
442 render_fb_attachment_str( attachment
->attachment
),
443 render_fb_format_str( attachment
->internalformat
) );
445 if( attachment
->purpose
== k_framebuffer_attachment_type_renderbuffer
){
446 glGenRenderbuffers( 1, &attachment
->id
);
447 render_fb_allocate_texture( fb
, attachment
);
448 glFramebufferRenderbuffer( GL_FRAMEBUFFER
,
449 GL_DEPTH_STENCIL_ATTACHMENT
,
450 GL_RENDERBUFFER
, attachment
->id
);
452 else if( attachment
->purpose
== k_framebuffer_attachment_type_texture
||
453 attachment
->purpose
== k_framebuffer_attachment_type_texture_depth
)
455 glGenTextures( 1, &attachment
->id
);
456 render_fb_allocate_texture( fb
, attachment
);
457 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
458 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_LINEAR
);
459 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_WRAP_S
, GL_CLAMP_TO_EDGE
);
460 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_WRAP_T
, GL_CLAMP_TO_EDGE
);
462 glFramebufferTexture2D( GL_FRAMEBUFFER
, attachment
->attachment
,
463 GL_TEXTURE_2D
, attachment
->id
, 0 );
465 if( attachment
->purpose
== k_framebuffer_attachment_type_texture
)
466 colour_attachments
[ colour_count
++ ] = attachment
->attachment
;
470 glDrawBuffers( colour_count
, colour_attachments
);
475 GLenum result
= glCheckFramebufferStatus( GL_FRAMEBUFFER
);
477 if( result
== GL_FRAMEBUFFER_COMPLETE
){
479 * Attatch to gpipeline
484 vg_success( " status: complete\n" );
488 if( result
== GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
)
489 vg_error( " status: Incomplete attachment" );
490 else if( result
== GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
)
491 vg_error( " status: Missing attachment" );
492 else if( result
== GL_FRAMEBUFFER_UNSUPPORTED
)
493 vg_error( " status: Unsupported framebuffer format" );
495 vg_error( " status: Generic Error" );
498 vg_fatal_error( "Incomplete framebuffer (see logs)" );
503 * Resize/Update all framebuffers(we know about)
505 static void render_fb_resize(void)
507 if( !gpipeline
.ready
) return;
509 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
510 struct framebuffer
*fb
= &framebuffers
[i
];
511 for( int j
=0; j
<vg_list_size(fb
->attachments
); j
++ ){
512 struct framebuffer_attachment
*attachment
= &fb
->attachments
[j
];
513 render_fb_allocate_texture( fb
, attachment
);
518 static int render_framebuffer_control( int argc
, char const *argv
[] );
519 static void render_framebuffer_poll( int argc
, char const *argv
[] );
521 static void async_render_init( void *payload
, u32 size
)
524 * Complete Framebuffers
526 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
527 struct framebuffer
*fb
= &framebuffers
[i
];
528 render_fb_allocate( fb
);
531 f32 rh
= 0x1p
-4f
, ih
= 0.3f
;
534 0.00f
,0.00f
, 1.00f
,1.00f
, 0.00f
,1.00f
, /* fsquad */
535 0.00f
,0.00f
, 1.00f
,0.00f
, 1.00f
,1.00f
,
537 0.00f
,0.00f
, 1.00f
,rh
, 0.00f
,rh
, /* fsquad1 */
538 0.00f
,0.00f
, 1.00f
,0.00f
, 1.00f
,rh
,
542 0.00f
,0.00f
, 0.30f
,0.30f
, 0.00f
,0.30f
,
543 0.00f
,0.00f
, 0.30f
,0.00f
, 0.30f
,0.30f
,
544 0.30f
,0.00f
, 0.60f
,0.30f
, 0.30f
,0.30f
,
545 0.30f
,0.00f
, 0.60f
,0.00f
, 0.60f
,0.30f
,
546 0.60f
,0.00f
, 0.90f
,0.30f
, 0.60f
,0.30f
,
547 0.60f
,0.00f
, 0.90f
,0.00f
, 0.90f
,0.30f
,
549 0.00f
,0.30f
, 0.30f
,0.60f
, 0.00f
,0.60f
,
550 0.00f
,0.30f
, 0.30f
,0.30f
, 0.30f
,0.60f
,
551 0.30f
,0.30f
, 0.60f
,0.60f
, 0.30f
,0.60f
,
552 0.30f
,0.30f
, 0.60f
,0.30f
, 0.60f
,0.60f
,
553 0.60f
,0.30f
, 0.90f
,0.60f
, 0.60f
,0.60f
,
554 0.60f
,0.30f
, 0.90f
,0.30f
, 0.90f
,0.60f
,
556 0.00f
,0.60f
, 0.30f
,0.90f
, 0.00f
,0.90f
,
557 0.00f
,0.60f
, 0.30f
,0.60f
, 0.30f
,0.90f
,
558 0.30f
,0.60f
, 0.60f
,0.90f
, 0.30f
,0.90f
,
559 0.30f
,0.60f
, 0.60f
,0.60f
, 0.60f
,0.90f
,
560 0.60f
,0.60f
, 0.90f
,0.90f
, 0.60f
,0.90f
,
561 0.60f
,0.60f
, 0.90f
,0.60f
, 0.90f
,0.90f
,
563 0.00f
,ih
, 1.00f
,ih
+rh
, 0.00f
,ih
+rh
, /* fsquad2 */
564 0.00f
,ih
, 1.00f
,ih
, 1.00f
,ih
+rh
,
567 vg_console_reg_cmd( "fb", render_framebuffer_control
,
568 render_framebuffer_poll
);
569 glGenVertexArrays( 1, &gpipeline
.fsquad
.vao
);
570 glGenBuffers( 1, &gpipeline
.fsquad
.vbo
);
571 glBindVertexArray( gpipeline
.fsquad
.vao
);
572 glBindBuffer( GL_ARRAY_BUFFER
, gpipeline
.fsquad
.vbo
);
573 glBufferData( GL_ARRAY_BUFFER
, sizeof(quad
), quad
, GL_STATIC_DRAW
);
574 glBindVertexArray( gpipeline
.fsquad
.vao
);
575 glVertexAttribPointer( 0, 2, GL_FLOAT
, GL_FALSE
,
576 sizeof(float)*2, (void*)0 );
577 glEnableVertexAttribArray( 0 );
581 glBindFramebuffer( GL_FRAMEBUFFER
, 0 );
585 static void render_init(void)
587 vg_console_reg_var( "blur_strength", &k_blur_strength
, k_var_dtype_f32
, 0 );
588 vg_console_reg_var( "render_scale", &k_render_scale
,
589 k_var_dtype_f32
, VG_VAR_PERSISTENT
);
590 vg_console_reg_var( "fov", &k_fov
, k_var_dtype_f32
, VG_VAR_PERSISTENT
);
591 vg_console_reg_var( "cam_height", &k_cam_height
,
592 k_var_dtype_f32
, VG_VAR_PERSISTENT
);
593 vg_console_reg_var( "blur_effect", &k_blur_effect
,
594 k_var_dtype_i32
, VG_VAR_PERSISTENT
);
597 shader_blit_register();
598 shader_blitblur_register();
599 shader_blitcolour_register();
601 vg_async_call( async_render_init
, NULL
, 0 );
607 static void render_fsquad(void)
609 glBindVertexArray( gpipeline
.fsquad
.vao
);
610 glDrawArrays( GL_TRIANGLES
, 0, 6 );
613 static void render_fsquad1(void)
615 glBindVertexArray( gpipeline
.fsquad
.vao
);
616 glDrawArrays( GL_TRIANGLES
, 6, 6 );
619 static void render_fsquad2(void)
621 glBindVertexArray( gpipeline
.fsquad
.vao
);
622 glDrawArrays( GL_TRIANGLES
, 66,6 );
626 * Call this inside the UI function
628 static void render_view_framebuffer_ui(void)
631 int viewing_count
= 0;
633 glBindVertexArray( gpipeline
.fsquad
.vao
);
635 shader_blit_uTexMain( 0 );
637 v2f identity
= { 1.0f
, 1.0f
};
638 shader_blit_uInverseRatio( identity
);
640 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
641 struct framebuffer
*fb
= &framebuffers
[i
];
643 for( int j
=0; j
<vg_list_size(fb
->attachments
); j
++ ){
644 struct framebuffer_attachment
*at
= &fb
->attachments
[j
];
646 if( !at
->debug_view
)
650 window
= { vg
.window_x
, vg
.window_y
};
652 corner
[0] = viewing_count
% 3;
653 corner
[1] = 1 + (viewing_count
/ 3);
654 v2_mul( corner
, window
, corner
);
655 v2_muls( corner
, 0.3f
, corner
);
656 corner
[1] = vg
.window_y
- corner
[1];
658 ui_text( (ui_rect
){ corner
[0], corner
[1], 0.0f
, 0.0f
},
659 fb
->display_name
, 2, k_text_align_left
);
660 ui_text( (ui_rect
){ corner
[0], corner
[1] + 32, 0.0f
, 0.0f
, },
661 at
->display_name
, 1, k_text_align_left
);
663 if( at
->purpose
== k_framebuffer_attachment_type_renderbuffer
){
665 v2_muladds( corner
, window
, 0.15f
, center
);
667 ui_text( (ui_rect
){ center
[0], center
[1], 0.0f
, 0.0f
},
668 "<hardware texture>", 1, k_text_align_center
);
671 render_fb_bind_texture( fb
, j
, 0 );
673 int start
= (viewing_count
+2) * 6,
675 glDrawArrays( GL_TRIANGLES
, start
, count
);
684 static void render_framebuffer_show( struct framebuffer
*fb
,
685 struct framebuffer_attachment
*at
,
688 at
->debug_view
= operation
;
689 vg_info( "%s %s:%s\n", (operation
?"shown": "hidden"),
690 fb
->display_name
, at
->display_name
);
694 * arg0: command "show"/"hide"
695 * arg1: framebuffer name <name>/"all"
696 * arg2: subname <name>/none
698 static int render_framebuffer_control( int argc
, char const *argv
[] )
701 vg_error( "Usage: fb \"show/hide\" <name>/\"all\" <name>/none\n" );
708 if( !strcmp( argv
[0], "show" ) )
710 else if( !strcmp( argv
[0], "hide" ) )
713 vg_error( "Unknown framebuffer operation: '%s'\n", argv
[0] );
717 if( !strcmp( argv
[1], "all" ) )
720 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
721 struct framebuffer
*fb
= &framebuffers
[i
];
723 for( int j
=0; j
<vg_list_size(fb
->attachments
); j
++ ){
724 struct framebuffer_attachment
*at
= &fb
->attachments
[j
];
726 if( at
->purpose
== k_framebuffer_attachment_type_none
)
730 render_framebuffer_show( fb
, at
, operation
);
733 if( !strcmp( fb
->display_name
, argv
[1] ) ){
735 render_framebuffer_show( fb
, at
, operation
);
736 else if( !strcmp( at
->display_name
, argv
[2] ) )
737 render_framebuffer_show( fb
, at
, operation
);
746 static void render_framebuffer_poll( int argc
, char const *argv
[] )
748 const char *term
= argv
[argc
-1];
751 console_suggest_score_text( "show", term
, 0 );
752 console_suggest_score_text( "hide", term
, 0 );
754 else if( argc
== 2 ){
755 console_suggest_score_text( "all", term
, 0 );
757 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
758 struct framebuffer
*fb
= &framebuffers
[i
];
759 console_suggest_score_text( fb
->display_name
, term
, 0 );
762 else if( argc
== 3 ){
765 if( !strcmp( argv
[1], "all" ) )
768 for( int i
=0; i
<vg_list_size(framebuffers
); i
++ ){
769 struct framebuffer
*fb
= &framebuffers
[i
];
771 for( int j
=0; j
<vg_list_size(fb
->attachments
); j
++ ){
772 struct framebuffer_attachment
*at
= &fb
->attachments
[j
];
774 if( at
->purpose
== k_framebuffer_attachment_type_none
)
778 console_suggest_score_text( at
->display_name
, term
, 0 );
780 else if( !strcmp( fb
->display_name
, argv
[1] ) ){
781 console_suggest_score_text( at
->display_name
, term
, 0 );
788 #endif /* RENDER_H */