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