clean up overlay init code
[carveJwlIkooP6JGAAIwe30JlM.git] / render.h
1 /*
2 * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
3 */
4 #pragma once
5 #include "common.h"
6 #include "model.h"
7 #include "camera.h"
8 #include "shader_props.h"
9
10 #include "shaders/blit.h"
11 #include "shaders/blitblur.h"
12 #include "shaders/blitcolour.h"
13 #include "shaders/blit_transition.h"
14
15 #define WORKSHOP_PREVIEW_WIDTH 504
16 #define WORKSHOP_PREVIEW_HEIGHT 336
17
18 static f32 k_render_scale = 1.0f;
19 static i32 k_blur_effect = 1;
20 static f32 k_blur_strength = 0.3f;
21 static f32 k_fov = 0.86f;
22 static f32 k_cam_height = 0.8f;
23
24 typedef struct framebuffer framebuffer;
25
26 /*
27 * All standard buffers used in rendering
28 */
29 static struct pipeline{
30 glmesh fsquad;
31
32 framebuffer *fb_main,
33 *fb_water_reflection,
34 *fb_water_beneath,
35 *fb_workshop_preview,
36 *fb_network_status;
37 int ready;
38 }
39 gpipeline;
40
41 struct framebuffer{
42 const char *display_name;
43 int resolution_div, /* definition */
44 fixed_w,
45 fixed_h,
46
47 render_w, /* runtime */
48 render_h;
49
50 struct framebuffer_attachment{
51 const char *display_name;
52
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
58 }
59 purpose;
60
61 enum framebuffer_quality_profile{
62 k_framebuffer_quality_all,
63 k_framebuffer_quality_high_only
64 }
65 quality;
66
67 GLenum internalformat,
68 format,
69 type,
70 attachment;
71
72 GLuint id;
73
74 /* Runtime */
75 int debug_view;
76 }
77 attachments[5];
78 GLuint fb;
79 framebuffer **link;
80 }
81 extern framebuffers[];
82
83 void render_init(void);
84 void render_fsquad(void);
85 void render_fsquad1(void);
86 void render_fsquad2(void);
87 void render_view_framebuffer_ui(void);
88 void render_fb_bind_texture( framebuffer *fb, int attachment, int slot );
89 void render_fb_inverse_ratio( framebuffer *fb, v2f inverse );
90 void render_fb_get_current_res( struct framebuffer *fb, int *x, int *y );
91 void render_fb_bind( framebuffer *fb, int use_scaling );
92 void render_fb_bind_texture( framebuffer *fb, int attachment, int slot );
93 void render_fb_allocate( struct framebuffer *fb );
94 void render_fb_resize(void);