本文整理汇总了C++中renderstate::StateBlock::setCullFace方法的典型用法代码示例。如果您正苦于以下问题:C++ StateBlock::setCullFace方法的具体用法?C++ StateBlock::setCullFace怎么用?C++ StateBlock::setCullFace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类renderstate::StateBlock
的用法示例。
在下文中一共展示了StateBlock::setCullFace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lua_RenderStateStateBlock_setCullFace
int lua_RenderStateStateBlock_setCullFace(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_TBOOLEAN)
{
// Get parameter 1 off the stack.
bool param1 = ScriptUtil::luaCheckBool(state, 2);
RenderState::StateBlock* instance = getInstance(state);
instance->setCullFace(param1);
return 0;
}
lua_pushstring(state, "lua_RenderStateStateBlock_setCullFace - 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: Alertf
Material *gamehsp::makeMaterialTex2D( char *fname, int matopt )
{
bool mipmap;
mipmap = (matopt & GPOBJ_MATOPT_NOMIPMAP ) == 0;
Texture* texture = Texture::create(fname);
if ( texture == NULL ) {
Alertf("Texture not found.(%s)",fname);
return NULL;
}
_tex_width = texture->getWidth();
_tex_height = texture->getHeight();
// Search for the first sampler uniform in the effect.
Uniform* samplerUniform = NULL;
for (unsigned int i = 0, count = _spriteEffect->getUniformCount(); i < count; ++i)
{
Uniform* uniform = _spriteEffect->getUniform(i);
if (uniform && uniform->getType() == GL_SAMPLER_2D)
{
samplerUniform = uniform;
break;
}
}
if (!samplerUniform)
{
GP_ERROR("No uniform of type GL_SAMPLER_2D found in sprite effect.");
return NULL;
}
RenderState::StateBlock *state;
// Wrap the effect in a material
Material* mesh_material = Material::create(_spriteEffect); // +ref effect
// Bind the texture to the material as a sampler
Texture::Sampler* sampler = Texture::Sampler::create(texture); // +ref texture
mesh_material->getParameter(samplerUniform->getName())->setValue(sampler);
/*
Material* mesh_material = Material::create( SPRITE_VSH, SPRITE_FSH, NULL );
if ( mesh_material == NULL ) {
GP_ERROR("2D initalize failed.");
return NULL;
}
mesh_material->getParameter("u_diffuseTexture")->setValue( fname, mipmap );
*/
mesh_material->getParameter("u_projectionMatrix")->setValue(_projectionMatrix2D);
state = mesh_material->getStateBlock();
state->setCullFace(false);
state->setDepthTest(false);
state->setDepthWrite(false);
state->setBlend(true);
state->setBlendSrc(RenderState::BLEND_SRC_ALPHA);
state->setBlendDst(RenderState::BLEND_ONE_MINUS_SRC_ALPHA);
SAFE_RELEASE( texture );
return mesh_material;
}
示例3: setMaterialDefaultBinding
void gamehsp::setMaterialDefaultBinding( Material* material, int icolor, int matopt )
{
// These parameters are normally set in a .material file but this example sets them programmatically.
// Bind the uniform "u_worldViewProjectionMatrix" to use the WORLD_VIEW_PROJECTION_MATRIX from the scene's active camera and the node that the model belongs to.
// material->getParameter("u_worldViewProjectionMatrix")->setValue( _camera->getWorldViewProjectionMatrix() );
// material->getParameter("u_inverseTransposeWorldViewMatrix")->setValue( _camera->getInverseTransposeWorldViewMatrix() );
// material->getParameter("u_cameraPosition")->setValue( _camera->getTranslation() );
// material->getParameter("u_worldViewProjectionMatrix")->bindValue( _camera, &Node::getWorldViewProjectionMatrix );
// material->getParameter("u_inverseTransposeWorldViewMatrix")->bindValue( _camera, &Node::getInverseTransposeWorldViewMatrix );
// material->getParameter("u_cameraPosition")->bindValue( _camera, &Node::getTranslation );
if ( hasParameter( material, "u_cameraPosition" ) )
material->setParameterAutoBinding("u_cameraPosition", "CAMERA_WORLD_POSITION");
if ( hasParameter( material, "u_worldViewProjectionMatrix" ) )
material->setParameterAutoBinding("u_worldViewProjectionMatrix", "WORLD_VIEW_PROJECTION_MATRIX");
if ( hasParameter( material, "u_inverseTransposeWorldViewMatrix" ) )
material->setParameterAutoBinding("u_inverseTransposeWorldViewMatrix", "INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX");
Vector4 color;
Node *light_node;
if ( _curlight < 0 ) {
// カレントライトなし(シーンを参照)
if ( hasParameter( material, "u_ambientColor" ) )
material->setParameterAutoBinding("u_ambientColor", "SCENE_AMBIENT_COLOR");
if ( hasParameter( material, "u_lightDirection" ) )
material->setParameterAutoBinding("u_lightDirection", "SCENE_LIGHT_DIRECTION");
if ( hasParameter( material, "u_lightColor" ) )
material->setParameterAutoBinding("u_lightColor", "SCENE_LIGHT_COLOR");
} else {
// カレントライトを反映させる
gpobj *lgt;
lgt = getObj( _curlight );
light_node = lgt->_node;
// ライトの方向設定
if ( hasParameter( material, "u_lightDirection" ) )
material->getParameter("u_lightDirection")->bindValue(light_node, &Node::getForwardVectorView);
// ライトの色設定
// (リアルタイムに変更を反映させる場合は再設定が必要。現在は未対応)
Vector3 *vambient;
vambient = (Vector3 *)&lgt->_vec[GPOBJ_USERVEC_WORK];
if ( hasParameter( material, "u_lightColor" ) )
material->getParameter("u_lightColor")->setValue(light_node->getLight()->getColor());
if ( hasParameter( material, "u_ambientColor" ) )
material->getParameter("u_ambientColor")->setValue( vambient );
}
//material->setParameterAutoBinding("u_ambientColor", "SCENE_AMBIENT_COLOR");
//material->setParameterAutoBinding("u_lightDirection", "SCENE_LIGHT_DIRECTION");
//material->setParameterAutoBinding("u_lightColor", "SCENE_LIGHT_COLOR");
colorVector3( icolor, color );
if ( hasParameter( material, "u_diffuseColor" ) )
material->getParameter("u_diffuseColor")->setValue(color);
gameplay::MaterialParameter *prm_modalpha;
if ( hasParameter( material, "u_modulateAlpha" ) )
prm_modalpha = material->getParameter("u_modulateAlpha");
if ( prm_modalpha ) { prm_modalpha->setValue( 1.0f ); }
RenderState::StateBlock *state;
state = material->getStateBlock();
state->setCullFace( (( matopt & GPOBJ_MATOPT_NOCULL )==0) );
state->setDepthTest( (( matopt & GPOBJ_MATOPT_NOZTEST )==0) );
state->setDepthWrite( (( matopt & GPOBJ_MATOPT_NOZWRITE )==0) );
state->setBlend(true);
if ( matopt & GPOBJ_MATOPT_BLENDADD ) {
state->setBlendSrc(RenderState::BLEND_SRC_ALPHA);
state->setBlendDst(RenderState::BLEND_ONE);
} else {
state->setBlendSrc(RenderState::BLEND_SRC_ALPHA);
state->setBlendDst(RenderState::BLEND_ONE_MINUS_SRC_ALPHA);
}
}