本文整理汇总了C++中AddShader函数的典型用法代码示例。如果您正苦于以下问题:C++ AddShader函数的具体用法?C++ AddShader怎么用?C++ AddShader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AddShader函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
bool NullTechnique::Init()
{
if (!Technique::Init()) {
return false;
}
if (!AddShader(GL_VERTEX_SHADER, "../shaders/null_technique_vertex.glsl")) {
return false;
}
if (!AddShader(GL_FRAGMENT_SHADER, "../shaders/null_technique_fragment.glsl")) {
return false;
}
if (!Finalize()) {
return false;
}
m_WVPLocation = GetUniformLocation("gWVP");
if (m_WVPLocation == INVALID_UNIFORM_LOCATION) {
return false;
}
return true;
}
示例2: AddShader
//-------------------------------------------------------------------------------------------------
WorldShader::WorldShader( const char *name ) {
AddShader( "glsl\\worldshader.v.glsl", GL_VERTEX_SHADER );
AddShader( "glsl\\worldshader.f.glsl", GL_FRAGMENT_SHADER );
Link();
AddUniform( u_pattern_sampler, "sampler_patterns" );
AddUniform( u_noise_sampler, "sampler_noise" );
AddUniform( u_global_translation, "global_translation" );
AddUniform( u_camera, "camera" );
AddUniform( u_skylight_color, "skylight_color" );
AddUniform( u_skylight_intensity, "skylight_intensity" );
AddUniform( u_fog_distance, "fog_distance" );
AddUniform( u_fog_length, "fog_length" );
AddAttribute( a_instance_translation, "instance_translation", 1 );
AddAttribute( a_instance_form, "instance_form", 1 );
AddAttribute( a_instance_texture, "instance_texture", 1 );
AddAttribute( a_instance_color, "instance_color", 1, 4 );
//AddAttribute( attribInstanceColor2, "instance_color_2", 1 );
//AddAttribute( attribInstanceColor3, "instance_color_3", 1 );
//AddAttribute( attribInstanceColor4, "instance_color_4", 1 );
AddUniform( u_texture_sampler, "sampler_texture" );
AddUniform( u_texture_translation, "texture_translation" );
AddUniform( u_opacity, "opacity" );
AddUniform( u_fog_color, "fog_color" );
AddUniform( u_light_brightness, "light_brightness" );
AddUniform( u_light_colors, "light_colors" );
AddUniform( u_light_positions, "light_positions" );
Register( name );
}
示例3: Init
bool BlurTech::Init()
{
if (!Technique::Init()) {
return false;
}
if (!AddShader(GL_VERTEX_SHADER, "../tutorial46/shaders/blur.vs")) {
return false;
}
if (!AddShader(GL_FRAGMENT_SHADER, "../tutorial46/shaders/blur.fs")) {
return false;
}
if (!Finalize()) {
return false;
}
m_inputTextureUnitLocation = GetUniformLocation("gColorMap");
if (m_inputTextureUnitLocation == INVALID_UNIFORM_LOCATION) {
return false;
}
Enable();
glUniform1i(m_inputTextureUnitLocation, INPUT_TEXTURE_UNIT_INDEX);
return true;
}
示例4: Init
bool LightingTechnique::Init()
{
if (!Technique::Init()) {
return false;
}
if (!AddShader(GL_VERTEX_SHADER, "lighting.vs")) {
return false;
}
if (!AddShader(GL_FRAGMENT_SHADER, "lighting.fs")) {
return false;
}
if (!Finalize()) {
return false;
}
m_WVPLocation = GetUniformLocation("gWVP");
m_samplerLocation = GetUniformLocation("gSampler");
m_dirLightColorLocation = GetUniformLocation("gDirectionalLight.Color");
m_dirLightAmbientIntensityLocation = GetUniformLocation("gDirectionalLight.AmbientIntensity");
if (m_dirLightAmbientIntensityLocation == 0xFFFFFFFF ||
m_WVPLocation == 0xFFFFFFFF ||
m_samplerLocation == 0xFFFFFFFF ||
m_dirLightColorLocation == 0xFFFFFFFF)
{
return false;
}
return true;
}
示例5: Create
static inline const program_t& Create(const std::string& mat_name , const std::string& preprocessorDefinitions = std::string())
{
const uint16_t version = GLSL_VERSION;
const std::string comp_str = GLSL_VERSION>=150 ?" compatibility":"";
const std::string mat_name_cut = GetMaterialName(mat_name);
if(GetPrograms().find(mat_name_cut)==GetPrograms().end())
{
program_t p;
p.program = new osg::Program;
p.program->setName(mat_name_cut);
static osg::Shader* ssv = AddShader(shaders::VS, "shadow", version, comp_str, string());
static osg::Shader* ssf = AddShader(shaders::FS, "shadow", version, comp_str, string());
p.program->addShader( ssv );
p.program->addShader( ssf );
p.program->addShader( AddShader(shaders::VS, mat_name_cut, version, comp_str, preprocessorDefinitions));
p.program->addShader( AddShader(shaders::FS, mat_name_cut, version, comp_str, preprocessorDefinitions));
p.program->addBindAttribLocation( "tangent" , 6 );
p.program->addBindAttribLocation( "binormal", 7 );
GetPrograms()[mat_name_cut]=p;
}
return GetPrograms()[mat_name_cut];
}
示例6: Shader
bool Res::Init() {
Shader* shader = nullptr;
Texture* texture = nullptr;
// block shader
shader = new Shader();
if (!shader->Init("res/block.vert", "res/block.frag")) return false;
AddShader("block", shader);
// simpler color shader
shader = new Shader();
if (!shader->Init("res/color.vert", "res/color.frag")) return false;
AddShader("color", shader);
std::vector<byte> buffer, image;
LodePNG::loadFile(buffer, "res/blocks.png");
LodePNG::Decoder decoder;
decoder.decode(image, buffer);
int dim = decoder.getWidth();
texture = Texture::Create3DTexture(dim, dim, decoder.getHeight() / dim, image.data());
AddTexture("blocks", texture);
return true;
}
示例7: CompileShaders
static void CompileShaders()
{
GLuint ShaderProgram = glCreateProgram();
AddShader(ShaderProgram, GL_VERTEX_SHADER, pVS);
AddShader(ShaderProgram, GL_FRAGMENT_SHADER, pFS);
glLinkProgram(ShaderProgram);
GLint Success;
glGetProgramiv(ShaderProgram, GL_LINK_STATUS, &Success);
if (!Success)
{
GLchar InfoLog[1024] = {0};
glGetProgramInfoLog(ShaderProgram, 1024, NULL, InfoLog);
fprintf(stderr, "Error : Link Error '%s'\n", InfoLog);
exit(0);
}
gWorldLocation = glGetUniformLocation(ShaderProgram, "gWorld");
assert(gWorldLocation != 0xFFFFFFFF);
glValidateProgram(ShaderProgram);
glGetProgramiv(ShaderProgram, GL_VALIDATE_STATUS, &Success);
if (!Success)
{
GLchar InfoLog[1024] = {0};
glGetProgramInfoLog(ShaderProgram, 1024, NULL, InfoLog);
fprintf(stderr, "Error : Invalid shader program '%s'\n", InfoLog);
exit(1);
}
glUseProgram(ShaderProgram);
}
示例8: Init
bool ShadowMapTechnique::Init()
{
if (!Technique::Init()) {
return false;
}
if (!AddShader(GL_VERTEX_SHADER, "shadow_map.vs")) {
return false;
}
if (!AddShader(GL_FRAGMENT_SHADER, "shadow_map.fs")) {
return false;
}
if (!Finalize()) {
return false;
}
m_WVPLocation = GetUniformLocation("gWVP");
m_textureLocation = GetUniformLocation("gShadowMap");
if (m_WVPLocation == INVALID_UNIFORM_LOCATION ||
m_textureLocation == INVALID_UNIFORM_LOCATION) {
return false;
}
return true;
}
示例9: IObject
Shader::Shader(const std::string& vertexPath, const std::string& fragmentPath) : IObject("shader")
{
AddShader(ShaderType::Vertex, vertexPath);
AddShader(ShaderType::Fragment, fragmentPath);
Reload(true);
}
示例10: Init
bool LineShader::Init()
{
if (!Shader::Init()) {
return false;
}
if (!AddShader(GL_VERTEX_SHADER, "Resources/shader/Line.vs")) {
return false;
}
if (!AddShader(GL_FRAGMENT_SHADER, "Resources/shader/Line.fs")) {
return false;
}
if (!Finalize()) {
return false;
}
m_MVPLocation = GetUniformLocation("MVP");
if (m_MVPLocation == INVALID_UNIFORM_LOCATION) {
return false;
}
m_LineColorLocation = GetUniformLocation("LineColor");
if (m_LineColorLocation == INVALID_UNIFORM_LOCATION) {
return false;
}
return true;
}
示例11: CompileShader
void CompileShader()
{
shaderProgram = glCreateProgram();
string vs, fs;
if (!ReadFile(VSFile, vs))
exit(1);
if (!ReadFile(FSFile, fs))
exit(1);
AddShader(shaderProgram, vs.c_str(), GL_VERTEX_SHADER);
AddShader(shaderProgram, fs.c_str(), GL_FRAGMENT_SHADER);
GLint success;
GLchar errorLog[1024];
glLinkProgram(shaderProgram);
glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success);
if (success == 0)
{
glGetProgramInfoLog(shaderProgram, 1024, NULL, errorLog);
fprintf(stderr, "Link error : %s\n", errorLog);
exit(1);
}
glValidateProgram(shaderProgram);
glGetProgramiv(shaderProgram, GL_VALIDATE_STATUS, &success);
if (success == 0)
{
glGetProgramInfoLog(shaderProgram, 1024, NULL, errorLog);
fprintf(stderr, "Validate error : %s\n", errorLog);
exit(1);
}
}
示例12: Init
bool MotionBlurTechnique::Init()
{
if (!Technique::Init()) {
return false;
}
if (!AddShader(GL_VERTEX_SHADER, "shaders/motion_blur.vs")) {
return false;
}
if (!AddShader(GL_FRAGMENT_SHADER, "shaders/motion_blur.fs")) {
return false;
}
if (!Finalize()) {
return false;
}
m_colorTextureLocation = GetUniformLocation("gColorTexture");
m_motionTextureLocation = GetUniformLocation("gMotionTexture");
if (m_motionTextureLocation == INVALID_UNIFORM_LOCATION ||
m_colorTextureLocation == INVALID_UNIFORM_LOCATION) {
return false;
}
return true;
}
示例13: Init
bool DSDirLightPassTech::Init()
{
if (!Technique::Init())
{
return false;
}
if (!AddShader(GL_VERTEX_SHADER, "shaders/light_pass.vs"))
{
return false;
}
if (!AddShader(GL_FRAGMENT_SHADER, "shaders/dir_light_pass.fs"))
{
return false;
}
if (!Finalize()) {
return false;
}
m_dirLightLocation.Color = GetUniformLocation("gDirectionalLight.Base.Color");
m_dirLightLocation.AmbientIntensity = GetUniformLocation("gDirectionalLight.Base.AmbientIntensity");
m_dirLightLocation.Direction = GetUniformLocation("gDirectionalLight.Direction");
m_dirLightLocation.DiffuseIntensity = GetUniformLocation("gDirectionalLight.Base.DiffuseIntensity");
if (m_dirLightLocation.AmbientIntensity == INVALID_UNIFORM_LOCATION ||
m_dirLightLocation.Color == INVALID_UNIFORM_LOCATION ||
m_dirLightLocation.DiffuseIntensity == INVALID_UNIFORM_LOCATION ||
m_dirLightLocation.Direction == INVALID_UNIFORM_LOCATION) {
return false;
}
return DSLightPassTech::Init();
}
示例14: Init
bool GeomPassTech::Init()
{
if (!Technique::Init()) {
return false;
}
if (!AddShader(GL_VERTEX_SHADER, "engine/shaders/geometry_pass.vs")) {
return false;
}
if (!AddShader(GL_FRAGMENT_SHADER, "engine/shaders/geometry_pass.fs")) {
return false;
}
if (!Finalize()) {
return false;
}
m_WVPLocation = GetUniformLocation("gWVP");
if (m_WVPLocation == INVALID_UNIFORM_LOCATION) {
return false;
}
return true;
}
示例15: Init
bool PickingTechnique::Init()
{
if (!Technique::Init()) {
return false;
}
if (!AddShader(GL_VERTEX_SHADER, pVS)) {
return false;
}
if (!AddShader(GL_FRAGMENT_SHADER, pFS)) {
return false;
}
if (!Finalize()) {
return false;
}
m_WVPLocation = GetUniformLocation("gWVP");
m_objectIndexLocation = GetUniformLocation("gObjectIndex");
m_drawIndexLocation = GetUniformLocation("gDrawIndex");
if (m_WVPLocation == INVALID_UNIFORM_LOCATION ||
m_objectIndexLocation == INVALID_UNIFORM_LOCATION ||
m_drawIndexLocation == INVALID_UNIFORM_LOCATION) {
return false;
}
return true;
}