本文整理汇总了C++中PolycodeShaderModule类的典型用法代码示例。如果您正苦于以下问题:C++ PolycodeShaderModule类的具体用法?C++ PolycodeShaderModule怎么用?C++ PolycodeShaderModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PolycodeShaderModule类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: atoi
Shader *MaterialManager::createShaderFromXMLNode(TiXmlNode *node) {
Shader *retShader = NULL;
if(node->ToElement()->Attribute("type")) {
String shaderType = node->ToElement()->Attribute("type");
// Logger::log("Attempting to create %s shader\n", shaderType.c_str());
for(int m=0; m < shaderModules.size(); m++) {
PolycodeShaderModule *shaderModule = shaderModules[m];
if(shaderModule->getShaderType() == shaderType) {
retShader = shaderModule->createShader(node);
}
}
}
int numAreaLights = 0;
int numSpotLights = 0;
if(node->ToElement()->Attribute("numAreaLights")) {
numAreaLights = atoi(node->ToElement()->Attribute("numAreaLights"));
}
if(node->ToElement()->Attribute("numSpotLights")) {
numSpotLights = atoi(node->ToElement()->Attribute("numSpotLights"));
}
if(retShader) {
retShader->numAreaLights = numAreaLights;
retShader->numSpotLights = numSpotLights;
}
return retShader;
}
示例2: setTexture
void OpenGLRenderer::applyMaterial(Material *material, ShaderBinding *localOptions,unsigned int shaderIndex) {
if(!material->getShader(shaderIndex) || !shadersEnabled) {
setTexture(NULL);
return;
}
FixedShaderBinding *fBinding;
switch(material->getShader(shaderIndex)->getType()) {
case Shader::FIXED_SHADER:
// FixedShader *fShader = (FixedShader*)material->getShader();
fBinding = (FixedShaderBinding*)material->getShaderBinding(shaderIndex);
setTexture(fBinding->getDiffuseTexture());
// setTexture(fShader->getDiffuseTexture());
break;
case Shader::MODULE_SHADER:
currentMaterial = material;
if(material->shaderModule == NULL) {
for(int m=0; m < shaderModules.size(); m++) {
PolycodeShaderModule *shaderModule = shaderModules[m];
if(shaderModule->hasShader(material->getShader(shaderIndex))) {
material->shaderModule = (void*)shaderModule;
}
}
} else {
PolycodeShaderModule *shaderModule = (PolycodeShaderModule*)material->shaderModule;
shaderModule->applyShaderMaterial(this, material, localOptions, shaderIndex);
currentShaderModule = shaderModule;
}
break;
}
setBlendingMode(material->blendingMode);
}
示例3: reloadPrograms
void MaterialManager::reloadPrograms() {
for(int m=0; m < shaderModules.size(); m++) {
PolycodeShaderModule *shaderModule = shaderModules[m];
shaderModule->reloadPrograms();
}
vector<Resource *> shaders = CoreServices::getInstance()->getResourceManager()->getResources(Resource::RESOURCE_SHADER);
for(int s = 0; s < shaders.size(); s++) {
Shader *shader = (Shader *)shaders[s];
shader->reload();
}
}
示例4: entry
ShaderProgram *MaterialManager::createProgramFromFile(String programPath) {
OSFileEntry entry(programPath, OSFileEntry::TYPE_FILE);
for(int m=0; m < shaderModules.size(); m++) {
PolycodeShaderModule *shaderModule = shaderModules[m];
if(shaderModule->acceptsExtension(entry.extension)) {
ShaderProgram *newProgram = shaderModule->createProgramFromFile(entry.extension, entry.fullPath);
return newProgram;
}
}
return NULL;
}
示例5: setTexture
void OpenGLRenderer::applyMaterial(Material *material, ShaderBinding *localOptions,unsigned int shaderIndex) {
if(!material->getShader(shaderIndex) || !shadersEnabled) {
setTexture(NULL);
return;
}
GLfloat data4[] = {material->diffuseColor.r, material->diffuseColor.g, material->diffuseColor.b, material->diffuseColor.a};
glMaterialfv(GL_FRONT, GL_DIFFUSE, data4);
data4[0] = material->specularColor.r;
data4[1] = material->specularColor.g;
data4[2] = material->specularColor.b;
data4[3] = material->specularStrength;
glMaterialfv(GL_FRONT, GL_SPECULAR, data4);
glMaterialf(GL_FRONT, GL_SHININESS, material->specularValue);
data4[0] = ambientColor.r;
data4[1] = ambientColor.g;
data4[2] = ambientColor.b;
data4[3] = 1.0;
glMaterialfv(GL_FRONT, GL_AMBIENT, data4);
FixedShaderBinding *fBinding;
switch(material->getShader(shaderIndex)->getType()) {
case Shader::FIXED_SHADER:
// FixedShader *fShader = (FixedShader*)material->getShader();
fBinding = (FixedShaderBinding*)material->getShaderBinding(shaderIndex);
setTexture(fBinding->getDiffuseTexture());
// setTexture(fShader->getDiffuseTexture());
break;
case Shader::MODULE_SHADER:
currentMaterial = material;
if(material->shaderModule == NULL) {
for(int m=0; m < shaderModules.size(); m++) {
PolycodeShaderModule *shaderModule = shaderModules[m];
if(shaderModule->hasShader(material->getShader(shaderIndex))) {
material->shaderModule = (void*)shaderModule;
}
}
} else {
PolycodeShaderModule *shaderModule = (PolycodeShaderModule*)material->shaderModule;
shaderModule->applyShaderMaterial(this, material, localOptions, shaderIndex);
currentShaderModule = shaderModule;
}
break;
}
}
示例6: setTexture
void Renderer::applyMaterial(Material *material, ShaderBinding *localOptions,unsigned int shaderIndex, bool forceMaterial) {
if(overrideMaterial) {
if(!forceMaterial) {
material = overrideMaterial;
}
}
if(!material->getShader(shaderIndex) || !shadersEnabled) {
setTexture(NULL);
return;
}
FixedShaderBinding *fBinding;
Shader *shader = material->getShader(shaderIndex);
if(shader->numPointLights + shader->numSpotLights > 0) {
sortLights();
}
switch(material->getShader(shaderIndex)->getType()) {
case Shader::FIXED_SHADER:
fBinding = (FixedShaderBinding*)material->getShaderBinding(shaderIndex);
setTexture(fBinding->getDiffuseTexture());
break;
case Shader::MODULE_SHADER:
currentMaterial = material;
if(material->shaderModule == NULL) {
for(int m=0; m < shaderModules.size(); m++) {
PolycodeShaderModule *shaderModule = shaderModules[m];
if(shaderModule->hasShader(material->getShader(shaderIndex))) {
material->shaderModule = (void*)shaderModule;
}
}
} else {
PolycodeShaderModule *shaderModule = (PolycodeShaderModule*)material->shaderModule;
shaderModule->applyShaderMaterial(this, material, localOptions, shaderIndex);
currentShaderModule = shaderModule;
}
break;
}
setBlendingMode(material->blendingMode);
setWireframePolygonMode(material->wireframe);
}
示例7: atoi
Shader *MaterialManager::createShaderFromXMLNode(TiXmlNode *node) {
TiXmlElement *nodeElement = node->ToElement();
if (!nodeElement) return NULL; // Skip comment nodes
Shader *retShader = NULL;
if(nodeElement->Attribute("type")) {
String shaderType = nodeElement->Attribute("type");
// Logger::log("Attempting to create %s shader\n", shaderType.c_str());
for(int m=0; m < shaderModules.size(); m++) {
PolycodeShaderModule *shaderModule = shaderModules[m];
if(shaderModule->getShaderType() == shaderType) {
retShader = shaderModule->createShader(node);
}
}
}
if (!retShader)
return NULL;
int numAreaLights = 0;
int numSpotLights = 0;
if(nodeElement->Attribute("numAreaLights")) {
numAreaLights = atoi(nodeElement->Attribute("numAreaLights"));
}
if(nodeElement->Attribute("numSpotLights")) {
numSpotLights = atoi(nodeElement->Attribute("numSpotLights"));
}
retShader->screenShader = false;
if(nodeElement->Attribute("screen")) {
if(String(nodeElement->Attribute("screen")) == "true") {
retShader->screenShader = true;
}
}
if(retShader) {
retShader->numAreaLights = numAreaLights;
retShader->numSpotLights = numSpotLights;
}
return retShader;
}
示例8:
Shader *MaterialManager::createShader(String shaderType, String name, String vpName, String fpName, bool screenShader) {
Shader *retShader = NULL;
for(int m=0; m < shaderModules.size(); m++) {
PolycodeShaderModule *shaderModule = shaderModules[m];
if(shaderModule->getShaderType() == shaderType) {
retShader = shaderModule->createShader(name, vpName, fpName);
}
}
if(retShader) {
retShader->screenShader = screenShader;
retShader->numAreaLights = 0;
retShader->numSpotLights = 0;
}
return retShader;
}
示例9: parsePrograms
void ResourceManager::parsePrograms(const String& dirPath, bool recursive) {
vector<OSFileEntry> resourceDir;
resourceDir = OSBasics::parseFolder(dirPath, false);
for(int i=0; i < resourceDir.size(); i++) {
if(resourceDir[i].type == OSFileEntry::TYPE_FILE) {
for(int m=0; m < shaderModules.size(); m++) {
PolycodeShaderModule *shaderModule = shaderModules[m];
if(shaderModule->acceptsExtension(resourceDir[i].extension)) {
Resource *newProgram = shaderModule->createProgramFromFile(resourceDir[i].extension, resourceDir[i].fullPath);
if(newProgram) {
newProgram->setResourceName(resourceDir[i].name);
newProgram->setResourcePath(resourceDir[i].fullPath);
resources.push_back(newProgram);
}
}
}
} else {
if(recursive)
parsePrograms(dirPath+"/"+resourceDir[i].name, true);
}
}
}
示例10: reloadPrograms
void MaterialManager::reloadPrograms() {
for(int m=0; m < shaderModules.size(); m++) {
PolycodeShaderModule *shaderModule = shaderModules[m];
shaderModule->reloadPrograms();
}
}