forked from snesrev/zelda3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glsl_shader.h
99 lines (86 loc) · 2.08 KB
/
glsl_shader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef ZELDA3_GLSL_SHADER_H_
#define ZELDA3_GLSL_SHADER_H_
#include "types.h"
enum {
kGlslMaxPasses = 20,
kGlslMaxTextures = 10,
};
enum GLSLScaleType {
GLSL_NONE,
GLSL_SOURCE,
GLSL_VIEWPORT,
GLSL_ABSOLUTE
};
typedef struct GlslTextureUniform {
int Texture;
int InputSize;
int TextureSize;
int TexCoord;
} GlslTextureUniform;
typedef struct GlslUniforms {
GlslTextureUniform Top;
int OutputSize;
int FrameCount, FrameDirection;
int LUTTexCoord;
int VertexCoord;
GlslTextureUniform Orig;
GlslTextureUniform Prev[7];
GlslTextureUniform Pass[kGlslMaxPasses];
GlslTextureUniform PassPrev[kGlslMaxPasses];
int Texture[kGlslMaxTextures];
} GlslUniforms;
typedef struct GlslPass {
char *filename;
uint8 scale_type_x, scale_type_y;
bool float_framebuffer;
bool srgb_framebuffer;
bool mipmap_input;
float scale_x, scale_y;
uint wrap_mode;
uint frame_count_mod;
uint frame_count;
uint gl_program, gl_fbo;
uint filter;
uint gl_texture;
uint16 width, height;
GlslUniforms unif;
} GlslPass;
typedef struct GlTextureWithSize {
uint gl_texture;
uint16 width, height;
} GlTextureWithSize;
typedef struct GlslTexture {
struct GlslTexture *next;
char *id;
char *filename;
uint filter;
uint gl_texture;
uint wrap_mode;
bool mipmap;
int width;
int height;
} GlslTexture;
typedef struct GlslParam {
struct GlslParam *next;
char *id;
bool has_value;
float value;
float min;
float max;
uint uniform[kGlslMaxPasses];
} GlslParam;
typedef struct GlslShader {
int n_pass;
GlslPass *pass;
GlslParam *first_param;
GlslTexture *first_texture;
uint *gl_vao;
uint gl_vbo;
uint frame_count;
int max_prev_frame;
GlTextureWithSize prev_frame[8];
} GlslShader;
GlslShader *GlslShader_CreateFromFile(const char *filename);
void GlslShader_Destroy(GlslShader *gs);
void GlslShader_Render(GlslShader *gs, GlTextureWithSize *tex, int viewport_x, int viewport_y, int viewport_width, int viewport_height);
#endif // ZELDA3_GLSL_SHADER_H_