本文整理汇总了C++中ITexture::GetActualHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ ITexture::GetActualHeight方法的具体用法?C++ ITexture::GetActualHeight怎么用?C++ ITexture::GetActualHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITexture
的用法示例。
在下文中一共展示了ITexture::GetActualHeight方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OverlayShowTexture
//-----------------------------------------------------------------------------
// Debugging aid to display a texture
//-----------------------------------------------------------------------------
static void OverlayShowTexture( const char* textureName, float scale )
{
bool foundVar;
IMaterial *pMaterial;
IMaterialVar *BaseTextureVar;
ITexture *pTex;
float x, y, w, h;
// ___error is created in code in CMaterialSystem::CreateDebugMaterials()
pMaterial = materials->FindMaterial( "___error", TEXTURE_GROUP_OTHER, true );
BaseTextureVar = pMaterial->FindVar( "$basetexture", &foundVar, false );
if (!foundVar)
return;
CMatRenderContextPtr pRenderContext( materials );
if ( textureName && textureName[0] )
{
pTex = materials->FindTexture( textureName, TEXTURE_GROUP_OTHER, false );
BaseTextureVar->SetTextureValue( pTex );
w = pTex->GetActualWidth() * scale;
h = pTex->GetActualHeight() * scale;
}
else
{
w = h = 64.0f * scale;
}
// Center relative to current viewport
int nViewportX, nViewportY, nViewportWidth, nViewportHeight;
pRenderContext->GetViewport( nViewportX, nViewportY, nViewportWidth, nViewportHeight );
x = ( nViewportWidth - w ) * 0.5f;
y = ( nViewportHeight - h ) * 0.5f;
pRenderContext->Bind( pMaterial );
IMesh* pMesh = pRenderContext->GetDynamicMesh( true );
CMeshBuilder meshBuilder;
meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 );
meshBuilder.Position3f( x, y, 0.0f );
meshBuilder.TexCoord2f( 0, 0.0f, 0.0f );
meshBuilder.AdvanceVertex();
meshBuilder.Position3f( x+w, y, 0.0f );
meshBuilder.TexCoord2f( 0, 1.0f, 0.0f );
meshBuilder.AdvanceVertex();
meshBuilder.Position3f( x+w, y+h, 0.0f );
meshBuilder.TexCoord2f( 0, 1.0f, 1.0f );
meshBuilder.AdvanceVertex();
meshBuilder.Position3f( x, y+h, 0.0f );
meshBuilder.TexCoord2f( 0, 0.0f, 1.0f );
meshBuilder.AdvanceVertex();
meshBuilder.End();
pMesh->Draw();
}
示例2: OverlayShowTexture
//-----------------------------------------------------------------------------
// Debugging aid to display a texture
//-----------------------------------------------------------------------------
static void OverlayShowTexture( const char* textureName, float scale )
{
bool foundVar;
IMaterial *pMaterial;
IMaterialVar *BaseTextureVar;
ITexture *pTex;
float x, y, w, h;
// screen safe
x = 32;
y = 32;
pMaterial = materials->FindMaterial( "___debug", TEXTURE_GROUP_OTHER, true );
BaseTextureVar = pMaterial->FindVar( "$basetexture", &foundVar, false );
if (!foundVar)
return;
CMatRenderContextPtr pRenderContext( materials );
if ( textureName && textureName[0] )
{
pTex = materials->FindTexture( textureName, TEXTURE_GROUP_OTHER, false );
BaseTextureVar->SetTextureValue( pTex );
w = pTex->GetActualWidth() * scale;
h = pTex->GetActualHeight() * scale;
}
else
{
w = h = 64.0f * scale;
}
pRenderContext->Bind( pMaterial );
IMesh* pMesh = pRenderContext->GetDynamicMesh( true );
CMeshBuilder meshBuilder;
meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 );
meshBuilder.Position3f( x, y, 0.0f );
meshBuilder.TexCoord2f( 0, 0.0f, 0.0f );
meshBuilder.AdvanceVertex();
meshBuilder.Position3f( x+w, y, 0.0f );
meshBuilder.TexCoord2f( 0, 1.0f, 0.0f );
meshBuilder.AdvanceVertex();
meshBuilder.Position3f( x+w, y+h, 0.0f );
meshBuilder.TexCoord2f( 0, 1.0f, 1.0f );
meshBuilder.AdvanceVertex();
meshBuilder.Position3f( x, y+h, 0.0f );
meshBuilder.TexCoord2f( 0, 0.0f, 1.0f );
meshBuilder.AdvanceVertex();
meshBuilder.End();
pMesh->Draw();
}
示例3: Render
//------------------------------------------------------------------------------
// CExampleEffect render
//------------------------------------------------------------------------------
void CExampleEffect::Render( int x, int y, int w, int h )
{
if ( !IsEnabled() )
return;
// Render Effect
Rect_t actualRect;
UpdateScreenEffectTexture( 0, x, y, w, h, false, &actualRect );
ITexture *pTexture = GetFullFrameFrameBufferTexture( 0 );
CMatRenderContextPtr pRenderContext( materials );
pRenderContext->DrawScreenSpaceRectangle( m_Material, x, y, w, h,
actualRect.x, actualRect.y, actualRect.x+actualRect.width-1, actualRect.y+actualRect.height-1,
pTexture->GetActualWidth(), pTexture->GetActualHeight() );
}
示例4: draw_pp_shader
void draw_pp_shader( const CViewSetup &view, IMaterial *pMaterial)
{
int x = view.x;
int y = view.y;
int w = view.width;
int h = view.height;
Rect_t actualRect;
UpdateScreenEffectTexture( 0, x, y, w, h, false, &actualRect);
int u1 = actualRect.x;
int v1 = actualRect.y;
int u2 = actualRect.x+actualRect.width-1;
int v2 = actualRect.y+actualRect.height-1;
ITexture *pTexture = GetFullFrameFrameBufferTexture( 0 );
int aw = pTexture->GetActualWidth();
int ah = pTexture->GetActualHeight();
CMatRenderContextPtr pRenderContext( materials );
pRenderContext->DrawScreenSpaceRectangle( pMaterial, x, y, w, h, u1, v1, u2, v2, aw, ah );
pRenderContext.SafeRelease();
}
示例5: ApplyEntityGlowEffects
//.........这里部分代码省略.........
// Render the glow colors to _rt_FullFrameFB
//=============================================
{
PIXEvent pixEvent( pRenderContext, "RenderGlowModels" );
RenderGlowModels( pSetup, nSplitScreenSlot, pRenderContext );
}
//===================================
// Setup state for downsample/bloom
//===================================
pRenderContext->PushRenderTargetAndViewport();
// Get viewport
int nSrcWidth = pSetup->width;
int nSrcHeight = pSetup->height;
int nViewportX, nViewportY, nViewportWidth, nViewportHeight;
pRenderContext->GetViewport( nViewportX, nViewportY, nViewportWidth, nViewportHeight );
// Get material and texture pointers
IMaterial *pMatDownsample = materials->FindMaterial( "dev/glow_downsample", TEXTURE_GROUP_OTHER, true);
IMaterial *pMatBlurX = materials->FindMaterial( "dev/glow_blur_x", TEXTURE_GROUP_OTHER, true );
IMaterial *pMatBlurY = materials->FindMaterial( "dev/glow_blur_y", TEXTURE_GROUP_OTHER, true );
ITexture *pRtFullFrame = materials->FindTexture( FULL_FRAME_TEXTURE, TEXTURE_GROUP_RENDER_TARGET );
ITexture *pRtQuarterSize0 = materials->FindTexture( "_rt_SmallFB0", TEXTURE_GROUP_RENDER_TARGET );
ITexture *pRtQuarterSize1 = materials->FindTexture( "_rt_SmallFB1", TEXTURE_GROUP_RENDER_TARGET );
//============================================
// Downsample _rt_FullFrameFB to _rt_SmallFB0
//============================================
// First clear the full target to black if we're not going to touch every pixel
if ( ( pRtQuarterSize0->GetActualWidth() != ( pSetup->width / 4 ) ) || ( pRtQuarterSize0->GetActualHeight() != ( pSetup->height / 4 ) ) )
{
SetRenderTargetAndViewPort( pRtQuarterSize0, pRtQuarterSize0->GetActualWidth(), pRtQuarterSize0->GetActualHeight() );
pRenderContext->ClearColor3ub( 0, 0, 0 );
pRenderContext->ClearBuffers( true, false, false );
}
// Set the viewport
SetRenderTargetAndViewPort( pRtQuarterSize0, pSetup->width / 4, pSetup->height / 4 );
IMaterialVar *pbloomexpvar = pMatDownsample->FindVar( "$bloomexp", null );
if ( pbloomexpvar != NULL )
{
pbloomexpvar->SetFloatValue( 2.5f );
}
IMaterialVar *pbloomsaturationvar = pMatDownsample->FindVar( "$bloomsaturation", null );
if ( pbloomsaturationvar != NULL )
{
pbloomsaturationvar->SetFloatValue( 1.0f );
}
// note the -2's below. Thats because we are downsampling on each axis and the shader
// accesses pixels on both sides of the source coord
int nFullFbWidth = nSrcWidth;
int nFullFbHeight = nSrcHeight;
pRenderContext->DrawScreenSpaceRectangle( pMatDownsample, 0, 0, nSrcWidth/4, nSrcHeight/4,
0, 0, nFullFbWidth - 4, nFullFbHeight - 4,
pRtFullFrame->GetActualWidth(), pRtFullFrame->GetActualHeight() );
//============================//
// Guassian blur x rt0 to rt1 //
示例6: Render
void CGodRaysEffect::Render( int x, int y, int w, int h )
{
CMatRenderContextPtr pRenderContext( materials );
// Save off the current render target and put the occlusion
// mask on the top of the rt stack.
pRenderContext->PushRenderTargetAndViewport( m_OcclusionMask );
// Create the god rays rendering view.
CViewRender* pViewRender = CViewRender::GetMainView();
CRefPtr<CGodRaysView> pGodRaysView = new CGodRaysView( pViewRender );
// Set the sun instance.
pGodRaysView->m_pSun = m_pSun;
// Draw the occlusion mask.
pViewRender->AddViewToScene( pGodRaysView );
// Restore original render targets.
pRenderContext->PopRenderTargetAndViewport();
// Now, downsample the occlusion mask. Start by setting the quarter
// sized render target as the texture to render to.
pRenderContext->PushRenderTargetAndViewport( m_SmallRT0 );
// Get the dimensions of the god rays texture.
ITexture* pMaskTexture = m_OcclusionMask;
const int nSrcWidth = pMaskTexture->GetActualWidth();
const int nSrcHeight = pMaskTexture->GetActualHeight();
const int nQtrWidth = nSrcWidth / 4;
const int nQtrHeight = nSrcHeight / 4;
// Blit the data from the occlusion mask texture to the quarter sized one
// and use the downsample shader to do it with.
pRenderContext->DrawScreenSpaceRectangle(
m_DownsampleMaterial,
0, 0,
nQtrWidth, nQtrHeight,
0, 0,
nSrcWidth - 2, nSrcHeight - 2,
nSrcWidth, nSrcHeight );
// Restore the original render target.
pRenderContext->PopRenderTargetAndViewport();
Vector vLightPos;
GetLightPosition( vLightPos );
if( SetMaterialParms( vLightPos ) )
{
// Apply godrays on _rt_SmallFB0 -> _rt_SmallFB1.
pRenderContext->PushRenderTargetAndViewport( m_SmallRT1 );
pRenderContext->DrawScreenSpaceRectangle(
m_GodRaysMaterial,
0, 0,
nQtrWidth, nQtrHeight,
0, 0,
nQtrWidth - 2, nQtrHeight - 2,
nQtrWidth, nQtrHeight );
pRenderContext->PopRenderTargetAndViewport();
// Now blur _rt_SmallFB1 -> _rt_SmallFB0.
pRenderContext->PushRenderTargetAndViewport( m_SmallRT0 );
pRenderContext->DrawScreenSpaceRectangle(
m_BlurYMaterial,
0, 0,
nQtrWidth, nQtrHeight,
0, 0,
nQtrWidth - 2, nQtrHeight - 2,
nQtrWidth, nQtrHeight );
pRenderContext->PopRenderTargetAndViewport();
// Now blur _rt_SmallFB0 -> _rt_SmallFB1.
pRenderContext->PushRenderTargetAndViewport( m_SmallRT1 );
pRenderContext->DrawScreenSpaceRectangle(
m_BlurXMaterial,
0, 0,
nQtrWidth, nQtrHeight,
0, 0,
nQtrWidth - 2, nQtrHeight - 2,
nQtrWidth, nQtrHeight );
// Restore old render target and viewport.
pRenderContext->PopRenderTargetAndViewport();
// This forces the framebuffer to update with the latest scene.
UpdateScreenEffectTexture( 0, x, y, w, h, true );
// Now combine the godrays results with the main frame buffer.
pRenderContext->DrawScreenSpaceQuad( m_GodRaysCombineMaterial );
}
// Release the render context.
pRenderContext->Release();
}