void ShaderProgram::setUniform(const std::string& name, float value) { if(s_currentProgram && s_currentProgram->_initialized) { #ifdef _3DS GPU_SetFloatUniform(GPU_VERTEX_SHADER, s_currentProgram->getUniformLocation(name), (u32*)&value, 1); #else glUniform1f(s_currentProgram->getUniformLocation(name), value); #endif // _3DS } }
void ShaderProgram::setUniform(const std::string& name, const Vec3& v3) { if(s_currentProgram && s_currentProgram->_initialized) { #ifdef _3DS GPU_SetFloatUniform(GPU_VERTEX_SHADER, s_currentProgram->getUniformLocation(name), (u32*)&v3, 3); #else glUniform3f(s_currentProgram->getUniformLocation(name), v3.x, v3.y, v3.z); #endif // _3DS } }
void ShaderProgram::setUniform(const std::string& name, float x, float y, float z, float w) { if(s_currentProgram && s_currentProgram->_initialized) { #ifdef _3DS float values[] = { x, y, z, w }; GPU_SetFloatUniform(GPU_VERTEX_SHADER, s_currentProgram->getUniformLocation(name), (u32*)values, 4); #else glUniform4f(s_currentProgram->getUniformLocation(name), x, y, z, w); #endif // _3DS } }
void gpuSetUniform(u32 shader, ShaderType type, const char* name, const void* data, u32 elements) { if(name == NULL || data == NULL) { return; } ShaderData* shdr = (ShaderData*) shader; if(shdr == NULL || shdr->dvlb == NULL) { return; } shaderInstance_s* instance = type == VERTEX_SHADER ? shdr->program.vertexShader : shdr->program.geometryShader; if(instance != NULL) { Result res = shaderInstanceGetUniformLocation(instance, name); if(res >= 0) { GPU_SetFloatUniform((GPU_SHADER_TYPE) type, (u32) res, (u32 *) data, elements); } } }
void ShaderProgram::setUniform(const std::string& name, const Transform& t) { if(s_currentProgram && s_currentProgram->_initialized) { float mu[16]; for(int i = 0; i < 4; ++i) { for(int j = 0; j < 4; ++j) { mu[i*4 + j] = t.getValue(3 - j, i); } } #ifdef _3DS GPU_SetFloatUniform(GPU_VERTEX_SHADER, s_currentProgram->getUniformLocation(name), (u32*)mu, 4); #else glUniformMatrix4fv(s_currentProgram->getUniformLocation(name), 1, GL_TRUE, (float*)&t); #endif // _3DS } }
void matrix_gpu_set_uniform(const float *m, u32 startreg) { GPU_SetFloatUniform(GPU_VERTEX_SHADER, startreg, (u32 *)m, 4); }
void glUniform4fv(GLint location, GLsizei count, const GLfloat *value) { #ifdef _3DS GPU_SetFloatUniform(GPU_VERTEX_SHADER, location, (u32*)value, count); #endif }