本文整理汇总了C++中CBaseTexture::BindToUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseTexture::BindToUnit方法的具体用法?C++ CBaseTexture::BindToUnit怎么用?C++ CBaseTexture::BindToUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseTexture
的用法示例。
在下文中一共展示了CBaseTexture::BindToUnit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Begin
void CGUITextureGL::Begin(UTILS::Color color)
{
CBaseTexture* texture = m_texture.m_textures[m_currentFrame];
texture->LoadToGPU();
if (m_diffuse.size())
m_diffuse.m_textures[0]->LoadToGPU();
texture->BindToUnit(0);
// Setup Colors
m_col[0] = (GLubyte)GET_R(color);
m_col[1] = (GLubyte)GET_G(color);
m_col[2] = (GLubyte)GET_B(color);
m_col[3] = (GLubyte)GET_A(color);
bool hasAlpha = m_texture.m_textures[m_currentFrame]->HasAlpha() || m_col[3] < 255;
if (m_diffuse.size())
{
if (m_col[0] == 255 && m_col[1] == 255 && m_col[2] == 255 && m_col[3] == 255 )
{
m_renderSystem->EnableShader(SM_MULTI);
}
else
{
m_renderSystem->EnableShader(SM_MULTI_BLENDCOLOR);
}
hasAlpha |= m_diffuse.m_textures[0]->HasAlpha();
m_diffuse.m_textures[0]->BindToUnit(1);
}
else
{
if (m_col[0] == 255 && m_col[1] == 255 && m_col[2] == 255 && m_col[3] == 255)
{
m_renderSystem->EnableShader(SM_TEXTURE_NOBLEND);
}
else
{
m_renderSystem->EnableShader(SM_TEXTURE);
}
}
if (hasAlpha)
{
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_ONE);
glEnable(GL_BLEND);
}
else
{
glDisable(GL_BLEND);
}
m_packedVertices.clear();
m_idx.clear();
}
示例2:
void CGUITextureD3D::Begin(color_t color)
{
CBaseTexture* texture = m_texture.m_textures[m_currentFrame];
LPDIRECT3DDEVICE9 p3DDevice = g_Windowing.Get3DDevice();
texture->LoadToGPU();
if (m_diffuse.size())
m_diffuse.m_textures[0]->LoadToGPU();
// Set state to render the image
texture->BindToUnit(0);
p3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
p3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
p3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
p3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
p3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
p3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
if (m_diffuse.size())
{
m_diffuse.m_textures[0]->BindToUnit(1);
p3DDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
p3DDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
p3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MODULATE );
p3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
p3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG2, D3DTA_CURRENT );
p3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
p3DDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE);
p3DDevice->SetTextureStageState( 2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
}
else
{
p3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
p3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
}
p3DDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );
p3DDevice->SetRenderState( D3DRS_ALPHAREF, 0 );
p3DDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL );
p3DDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
p3DDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
p3DDevice->SetRenderState( D3DRS_FOGTABLEMODE, D3DFOG_NONE );
p3DDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
p3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
p3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
p3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
p3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
p3DDevice->SetRenderState( D3DRS_LIGHTING, FALSE);
p3DDevice->SetFVF( D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2 );
m_col = color;
}
示例3:
void CGUITextureD3D::Begin(color_t color)
{
int unit = 0;
CBaseTexture* texture = m_texture.m_textures[m_currentFrame];
LPDIRECT3DDEVICE9 p3DDevice = g_Windowing.Get3DDevice();
texture->LoadToGPU();
if (m_diffuse.size())
m_diffuse.m_textures[0]->LoadToGPU();
// Set state to render the image
texture->BindToUnit(unit);
p3DDevice->SetTextureStageState( unit, D3DTSS_COLOROP , D3DTOP_MODULATE );
p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG1, D3DTA_TEXTURE );
p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAOP , D3DTOP_MODULATE );
p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
unit++;
if (m_diffuse.size())
{
m_diffuse.m_textures[0]->BindToUnit(1);
p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG1, D3DTA_TEXTURE );
p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG2, D3DTA_CURRENT );
p3DDevice->SetTextureStageState( unit, D3DTSS_COLOROP , D3DTOP_MODULATE );
p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAARG2, D3DTA_CURRENT );
p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAOP , D3DTOP_MODULATE );
unit++;
}
if(g_Windowing.UseLimitedColor())
{
m_col = D3DCOLOR_RGBA(GET_R(color) * (235 - 16) / 255
, GET_G(color) * (235 - 16) / 255
, GET_B(color) * (235 - 16) / 255
, GET_A(color));
p3DDevice->SetTextureStageState( unit, D3DTSS_COLOROP , D3DTOP_ADD );
p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG1, D3DTA_CURRENT) ;
p3DDevice->SetRenderState( D3DRS_TEXTUREFACTOR, D3DCOLOR_RGBA(16,16,16, 0) );
p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG2, D3DTA_TFACTOR );
unit++;
}
else
m_col = color;
p3DDevice->SetTextureStageState( unit, D3DTSS_COLOROP, D3DTOP_DISABLE);
p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
p3DDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );
p3DDevice->SetRenderState( D3DRS_ALPHAREF, 0 );
p3DDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL );
p3DDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
p3DDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
p3DDevice->SetRenderState( D3DRS_FOGTABLEMODE, D3DFOG_NONE );
p3DDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
p3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
p3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
p3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
p3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
p3DDevice->SetRenderState( D3DRS_LIGHTING, FALSE);
p3DDevice->SetFVF( D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2 );
}