本文整理汇总了C++中Pass类的典型用法代码示例。如果您正苦于以下问题:C++ Pass类的具体用法?C++ Pass怎么用?C++ Pass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lua_Pass_getParameterByIndex
static int lua_Pass_getParameterByIndex(lua_State* state)
{
// Get the number of parameters.
int paramCount = lua_gettop(state);
// Attempt to match the parameters to a valid binding.
switch (paramCount)
{
case 2:
{
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
lua_type(state, 2) == LUA_TNUMBER)
{
// Get parameter 1 off the stack.
unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
Pass* instance = getInstance(state);
void* returnPtr = ((void*)instance->getParameterByIndex(param1));
if (returnPtr)
{
gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
object->instance = returnPtr;
object->owns = false;
luaL_getmetatable(state, "MaterialParameter");
lua_setmetatable(state, -2);
}
else
{
lua_pushnil(state);
}
return 1;
}
lua_pushstring(state, "lua_Pass_getParameterByIndex - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
default:
{
lua_pushstring(state, "Invalid number of parameters (expected 2).");
lua_error(state);
break;
}
}
return 0;
}
示例2: hasParameter
bool hasParameter( Material* material, const char* name )
{
unsigned int mc = material->getTechniqueCount();
for (unsigned int i = 0; i < mc; ++i)
{
Technique *tech = material->getTechniqueByIndex( i );
unsigned int pc = tech->getPassCount();
for (unsigned int j = 0; j < pc; ++j)
{
Pass *pass = tech->getPassByIndex(j);
Effect *effect = pass->getEffect();
if (effect->getUniform( name ) != NULL)
return true;
}
}
return false;
}
示例3: UpdMiniTer
// HUD utils
//---------------------------------------------------------------------------------------------------------------
void CHud::UpdMiniTer()
{
MaterialPtr mm = MaterialManager::getSingleton().getByName("circle_minimap");
Pass* pass = mm->getTechnique(0)->getPass(0);
if (!pass) return;
try
{ GpuProgramParametersSharedPtr par = pass->getFragmentProgramParameters();
bool ter = app->scn->sc->ter;
if (par->_findNamedConstantDefinition("showTerrain",false))
par->setNamedConstant("showTerrain", pSet->mini_terrain && ter ? 1.f : 0.f);
if (par->_findNamedConstantDefinition("showBorder",false))
par->setNamedConstant("showBorder", pSet->mini_border && ter ? 1.f : 0.f);
if (par->_findNamedConstantDefinition("square",false))
par->setNamedConstant("square", pSet->mini_zoomed && ter ? 0.f : 1.f);
}
catch(...){ }
}
示例4: lua_Pass_getVertexAttributeBinding
int lua_Pass_getVertexAttributeBinding(lua_State* state)
{
// Get the number of parameters.
int paramCount = lua_gettop(state);
// Attempt to match the parameters to a valid binding.
switch (paramCount)
{
case 1:
{
if ((lua_type(state, 1) == LUA_TUSERDATA))
{
Pass* instance = getInstance(state);
void* returnPtr = (void*)instance->getVertexAttributeBinding();
if (returnPtr)
{
ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
object->instance = returnPtr;
object->owns = false;
luaL_getmetatable(state, "VertexAttributeBinding");
lua_setmetatable(state, -2);
}
else
{
lua_pushnil(state);
}
return 1;
}
else
{
lua_pushstring(state, "lua_Pass_getVertexAttributeBinding - Failed to match the given parameters to a valid function signature.");
lua_error(state);
}
break;
}
default:
{
lua_pushstring(state, "Invalid number of parameters (expected 1).");
lua_error(state);
break;
}
}
return 0;
}
示例5: Material
Material* MaterialCache2D::CreateMaterial(Texture2D* texture, BlendMode blendMode)
{
Material* material = new Material(context_);
if (texture)
material->SetName(texture->GetName() + "_" + blendModeNames[blendMode]);
else
material->SetName(blendModeNames[blendMode]);
Technique* tech = new Technique(context_);
Pass* pass = tech->CreatePass(PASS_ALPHA);
pass->SetBlendMode(blendMode);
pass->SetVertexShader("Basic");
pass->SetVertexShaderDefines("DIFFMAP VERTEXCOLOR");
pass->SetPixelShader("Basic");
pass->SetPixelShaderDefines("DIFFMAP VERTEXCOLOR");
pass->SetDepthWrite(false);
material->SetTechnique(0, tech);
material->SetCullMode(CULL_NONE);
material->SetTexture(TU_DIFFUSE, texture);
return material;
}
示例6: pixelSize
void DepthOfFieldListener::notifyMaterialSetup(uint32 pass_id, MaterialPtr &mat)
{
if (pass_id == 1)
{
float blurScale =.5f;
Vector4 pixelSize(1.0f / (mViewportWidth * blurScale), 1.0f / (mViewportHeight * blurScale), 0.0f, 0.0f);
mat->load();
Pass *pass = mat->getBestTechnique()->getPass(0);
GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
if (params->_findNamedConstantDefinition("pixelSize"))
params->setNamedConstant("pixelSize", pixelSize);
}
else if (pass_id == 2)
{
float blurScale =.5f;
Vector4 pixelSize(1.0f / mViewportWidth, 1.0f / mViewportHeight,1.0f / (mViewportWidth * blurScale), 1.0f / (mViewportHeight * blurScale) );
Pass *pass = mat->getBestTechnique()->getPass(0);
GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
if (params->_findNamedConstantDefinition("pixelSize"))
params->setNamedConstant("pixelSize", pixelSize);
// this is the camera you're using
#ifndef SR_EDITOR
Camera *cam = mApp->mSplitMgr->mCameras.front();
#else
Camera *cam = mApp->mCamera;
#endif
if (params->_findNamedConstantDefinition("far"))
params->setNamedConstant("far", cam->getFarClipDistance());
if (params->_findNamedConstantDefinition("dofparams"))
{
Vector4 dofParams(0.0f,mApp->pSet->dof_focus,mApp->pSet->dof_far,1.0);
params->setNamedConstant("dofparams", dofParams);
}
}
}
示例7: if
//------------------------------------------------------------------------------//
void ShaderTranslator::translate(ScriptNodePtr& pScriptNode, const String& group)
{
ShaderType st;
if (pScriptNode->name == "vertex_shader")
{
st = ST_VERTEX_SHADER;
}
else if (pScriptNode->name == "pixel_shader")
{
st = ST_PIXEL_SHADER;
}
StringKeyValueMap::iterator it = pScriptNode->keyValueMap.find("name");
if(it == pScriptNode->keyValueMap.end())
{
TITAN_EXCEPT_ITEMLOST(
"The vertex shader must have name attribute"
);
return;
}
String shaderName = it->second;
ShaderPtr pShader = ShaderMgr::getSingleton().create(shaderName, group, st);
pScriptNode->keyValueMap.erase(it);
//set shader attributes
pShader->setParams(pScriptNode->keyValueMap);
ShaderParamsPtr pParams = pShader->getShaderParams();
ScriptNodePtrList::iterator sit = pScriptNode->children.begin(), sitEnd = pScriptNode->children.end();
while (sit != sitEnd)
{
translateShaderParam(*sit, pParams);
++sit;
}
Pass* parent = any_cast<Pass*>(pScriptNode->parent->createObj);
if(st == ST_VERTEX_SHADER)
{
parent->setVertexShader(shaderName);
}
else if(st == ST_PIXEL_SHADER)
{
parent->setPixelShader(shaderName);
}
}
示例8: GP_ASSERT
void MeshBatch::updateVertexAttributeBinding()
{
GP_ASSERT(_material);
// Update our vertex attribute bindings.
for (unsigned int i = 0, techniqueCount = _material->getTechniqueCount(); i < techniqueCount; ++i)
{
Technique* t = _material->getTechniqueByIndex(i);
GP_ASSERT(t);
for (unsigned int j = 0, passCount = t->getPassCount(); j < passCount; ++j)
{
Pass* p = t->getPassByIndex(j);
GP_ASSERT(p);
VertexAttributeBinding* b = VertexAttributeBinding::create(_vertexFormat, _vertices, p->getEffect());
p->setVertexAttributeBinding(b);
SAFE_RELEASE(b);
}
}
}
示例9: setupContent
void PlayPen_testManualBlend::setupContent()
{
// create material
MaterialPtr mat = MaterialManager::getSingleton().create("TestMat",
TRANSIENT_RESOURCE_GROUP);
Pass * p = mat->getTechnique(0)->getPass(0);
p->setLightingEnabled(false);
p->createTextureUnitState("Dirt.jpg");
TextureUnitState* t = p->createTextureUnitState("ogrelogo.png");
t->setColourOperationEx(LBX_BLEND_MANUAL, LBS_TEXTURE, LBS_CURRENT,
ColourValue::White, ColourValue::White, 0.75);
Entity *planeEnt = mSceneMgr->createEntity("Plane", SceneManager::PT_PLANE);
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(planeEnt);
planeEnt->setMaterialName("TestMat");
mCamera->setPosition(0,0,600);
mCamera->lookAt(Vector3::ZERO);
}
示例10: while
//-------------------------------------------------------------------------------------------------------
// utility
//-------------------------------------------------------------------------------------------------------
void CarModel::UpdateLightMap()
{
MaterialPtr mtr;
for (int i=0; i < NumMaterials; ++i)
{
mtr = MaterialManager::getSingleton().getByName(sMtr[i]);
if (!mtr.isNull())
{ Material::TechniqueIterator techIt = mtr->getTechniqueIterator();
while (techIt.hasMoreElements())
{ Technique* tech = techIt.getNext();
Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements())
{ Pass* pass = passIt.getNext();
if (pass->hasFragmentProgram())
{
GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
params->setIgnoreMissingParams(true); // don't throw exception if material doesnt use lightmap
params->setNamedConstant("enableTerrainLightMap", bLightMapEnabled ? 1.f : 0.f);
} } } } }
}
示例11: doUnbindPassOpacityMap
inline void doUnbindPassOpacityMap( PassRenderNode & node
, Pass & pass )
{
auto unit = pass.getTextureUnit( TextureChannel::eOpacity );
if ( unit )
{
unit->getSampler()->unbind( 0u );
unit->getTexture()->unbind( 0u );
}
}
示例12: getPassSubstitution
/// Add a CodeGen pass at this point in the pipeline after checking for target
/// and command line overrides.
///
/// addPass cannot return a pointer to the pass instance because is internal the
/// PassManager and the instance we create here may already be freed.
AnalysisID TargetPassConfig::addPass(AnalysisID PassID, bool verifyAfter,
bool printAfter) {
IdentifyingPassPtr TargetID = getPassSubstitution(PassID);
IdentifyingPassPtr FinalPtr = overridePass(PassID, TargetID);
if (!FinalPtr.isValid())
return nullptr;
Pass *P;
if (FinalPtr.isInstance())
P = FinalPtr.getInstance();
else {
P = Pass::createPass(FinalPtr.getID());
if (!P)
llvm_unreachable("Pass ID not registered");
}
AnalysisID FinalID = P->getPassID();
addPass(P, verifyAfter, printAfter); // Ends the lifetime of P.
return FinalID;
}
示例13: lua_Pass_setVertexAttributeBinding
int lua_Pass_setVertexAttributeBinding(lua_State* state)
{
// Get the number of parameters.
int paramCount = lua_gettop(state);
// Attempt to match the parameters to a valid binding.
switch (paramCount)
{
case 2:
{
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
(lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
{
// Get parameter 1 off the stack.
bool param1Valid;
ScriptUtil::LuaArray<VertexAttributeBinding> param1 = ScriptUtil::getObjectPointer<VertexAttributeBinding>(2, "VertexAttributeBinding", false, ¶m1Valid);
if (!param1Valid)
{
lua_pushstring(state, "Failed to convert parameter 1 to type 'VertexAttributeBinding'.");
lua_error(state);
}
Pass* instance = getInstance(state);
instance->setVertexAttributeBinding(param1);
return 0;
}
lua_pushstring(state, "lua_Pass_setVertexAttributeBinding - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
default:
{
lua_pushstring(state, "Invalid number of parameters (expected 2).");
lua_error(state);
break;
}
}
return 0;
}
示例14: Drawable
Renderer2D::Renderer2D(Context* context) :
Drawable(context, DRAWABLE_GEOMETRY),
material_(new Material(context)),
indexBuffer_(new IndexBuffer(context_)),
viewMask_(DEFAULT_VIEWMASK)
{
material_->SetName("Urho2D");
Technique* tech = new Technique(context_);
Pass* pass = tech->CreatePass("alpha");
pass->SetVertexShader("Urho2D");
pass->SetPixelShader("Urho2D");
pass->SetDepthWrite(false);
cachedTechniques_[BLEND_REPLACE] = tech;
material_->SetTechnique(0, tech);
material_->SetCullMode(CULL_NONE);
frame_.frameNumber_ = 0;
SubscribeToEvent(E_BEGINVIEWUPDATE, URHO3D_HANDLER(Renderer2D, HandleBeginViewUpdate));
}
示例15: doBindPassOpacityMap
inline void doBindPassOpacityMap( PassRenderNode & node
, Pass & pass )
{
auto unit = pass.getTextureUnit( TextureChannel::eOpacity );
if ( unit )
{
node.m_textures.find( unit->getIndex() )->second.get().setValue( 0 );
unit->getTexture()->bind( 0u );
unit->getSampler()->bind( 0u );
}
}