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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
#ifndef _GROPENGLSHADER_H
#define _GROPENGLSHADER_H
#include "globalincs/pstypes.h"
#include "graphics/gropengl.h"
#include <string>
#define MAX_SHADER_UNIFORMS 20
#define SDR_ATTRIB_RADIUS 0
#define SDR_ATTRIB_SUBMODEL 1
#define MAX_SDR_ATTRIBUTES 5
#define MAX_SDR_UNIFORM_BLOCKS 5
struct geometry_sdr_params
{
int input_type;
int output_type;
int vertices_out;
};
struct opengl_shader_type_t {
shader_type type_id;
char *vert;
char *frag;
char *geo;
geometry_sdr_params geo_sdr_info;
int num_uniforms;
char* uniforms[MAX_SHADER_UNIFORMS];
int num_attributes;
char* attributes[MAX_SDR_ATTRIBUTES];
const char* description;
};
struct opengl_shader_variant_t {
shader_type type_id;
bool use_geometry_sdr;
int flag;
SCP_string flag_text;
int num_uniforms;
char* uniforms[MAX_SHADER_UNIFORMS];
int num_attributes;
char* attributes[MAX_SDR_ATTRIBUTES];
const char* description;
};
struct opengl_shader_file_t {
char *vert;
char *frag;
char *geo;
int flags;
int num_uniforms;
char* uniforms[MAX_SHADER_UNIFORMS];
int num_attributes;
char* attributes[MAX_SDR_ATTRIBUTES];
const char* description;
};
struct opengl_shader_uniform_reference_t {
unsigned int flag;
int num_uniforms;
char* uniforms[MAX_SHADER_UNIFORMS];
int num_attributes;
char* attributes[MAX_SDR_ATTRIBUTES];
int num_uniform_blocks;
char* uniform_blocks[MAX_SDR_UNIFORM_BLOCKS];
const char* name;
};
typedef struct opengl_shader_uniform_t {
SCP_string text_id;
GLint location;
opengl_shader_uniform_t() : location(-1) {}
} opengl_shader_uniform_t;
typedef struct opengl_shader_t {
GLhandleARB program_id;
shader_type shader;
unsigned int flags;
int flags2;
SCP_vector<opengl_shader_uniform_t> uniforms;
SCP_vector<opengl_shader_uniform_t> uniform_blocks;
SCP_vector<opengl_shader_uniform_t> attributes; // using the uniform data structure to keep track of vert attribs
opengl_shader_t() :
program_id(0), flags(0), flags2(0)
{
}
} opengl_shader_t;
extern SCP_vector<opengl_shader_t> GL_shader;
extern opengl_shader_t *Current_shader;
extern geometry_sdr_params *Current_geo_sdr_params;
int gr_opengl_maybe_create_shader(shader_type shader_t, unsigned int flags);
void opengl_delete_shader(int sdr_handle);
void opengl_shader_set_current(opengl_shader_t *shader_obj = NULL);
void opengl_shader_set_current(int handle);
void opengl_shader_init();
void opengl_shader_shutdown();
int opengl_compile_shader(shader_type sdr, uint flags);
GLhandleARB opengl_shader_create(const char *vs, const char *fs, const char *gs);
void opengl_shader_init_attribute(const char *attribute_text);
GLint opengl_shader_get_attribute(const char *attribute_text);
void opengl_shader_init_uniform(const char *uniform_text);
GLint opengl_shader_get_uniform(const char *uniform_text);
void opengl_shader_init_uniform_block(const char *uniform_text);
GLint opengl_shader_get_uniform_block(const char *uniform_text);
void gr_opengl_shader_set_animated_effect(int effect, float timer);
int opengl_shader_get_animated_effect();
float opengl_shader_get_animated_timer();
void opengl_shader_compile_deferred_light_shader();
void opengl_shader_compile_deferred_light_clear_shader();
#define ANIMATED_SHADER_LOADOUTSELECT_FS1 0
#define ANIMATED_SHADER_LOADOUTSELECT_FS2 1
#define ANIMATED_SHADER_CLOAK 2
#endif // _GROPENGLSHADER_H
|