18 #include "../image.hpp"
34 , refcount_(new unsigned(1))
37 if (!vertex_object_) {
38 throw shader_error(
"Failed to compile vertex shader");
42 if (!fragment_object_) {
43 throw shader_error(
"Failed to compile fragment shader");
47 if (!program_object_) {
48 throw shader_error(
"Failed to link shader program");
59 set_color_mod(0, 0, 0, 0);
64 shader_program::shader_program()
74 , refcount_(new unsigned(1))
77 shader_program::~shader_program()
88 shader_program::shader_program(
const shader_program &prog)
89 : program_object_(prog.program_object_)
90 , vertex_object_(prog.vertex_object_)
91 , fragment_object_(prog.fragment_object_)
93 , attr_color_mod_(prog.attr_color_mod_)
94 , attr_submerge_(prog.attr_submerge_)
95 , attr_effects_(prog.attr_effects_)
96 , uni_overlay_(prog.uni_overlay_)
97 , overlay_image_(prog.overlay_image_)
98 , refcount_(prog.refcount_)
103 const shader_program &shader_program::operator =(
const shader_program &prog)
106 this->~shader_program();
107 return *(
new(
this) shader_program(prog));
113 void shader_program::activate()
116 "vert_texture_pos",
"vert_draw_color",
121 set_overlay(image::get_texture(
"misc/blank.png"));
124 void shader_program::deactivate()
131 void shader_program::set_color_mod(
int r,
int g,
int b,
int a)
133 static float color_mod[4];
134 color_mod[0] = float(r) / 255;
135 color_mod[1] = float(g) / 255;
136 color_mod[2] = float(b) / 255;
137 color_mod[3] = float(a) / 255;
142 void shader_program::set_submerge(
float val)
147 void shader_program::set_effects(
int effects)
152 void shader_program::set_overlay(
const timage &
img)
154 overlay_image_ =
img;
GPU_ShaderBlock GPU_LoadShaderBlock(Uint32 program_object, const char *position_name, const char *texcoord_name, const char *color_name, const char *modelViewMatrix_name)
static l_noret error(LoadState *S, const char *why)
Uint32 GPU_LinkShaders(Uint32 shader_object1, Uint32 shader_object2)
const char * GPU_GetShaderMessage(void)
GLuint const GLfloat * val
Uint32 GPU_LoadShader(GPU_ShaderEnum shader_type, const char *filename)
GLdouble GLdouble GLdouble b
void GPU_SetShaderImage(GPU_Image *image, int location, int image_unit)
void GPU_SetAttributefv(int location, int num_elements, float *value)
void GPU_ActivateShaderProgram(Uint32 program_object, GPU_ShaderBlock *block)
GLboolean GLboolean GLboolean GLboolean a
void GPU_FreeShaderProgram(Uint32 program_object)
void GPU_SetAttributef(int location, float value)
void GPU_DeactivateShaderProgram(void)
int GPU_GetUniformLocation(Uint32 program_object, const char *uniform_name)
GLdouble GLdouble GLdouble r
void GPU_FreeShader(Uint32 shader_object)
int GPU_GetAttributeLocation(Uint32 program_object, const char *attrib_name)
Uint32 GPU_GetCurrentShaderProgram(void)
GLsizei const GLcharARB ** string
void GPU_SetAttributei(int location, int value)