本文整理汇总了C++中pRenderContext函数的典型用法代码示例。如果您正苦于以下问题:C++ pRenderContext函数的具体用法?C++ pRenderContext怎么用?C++ pRenderContext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pRenderContext函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pRenderContext
bool C_CFPlayer::OnPostInternalDrawModel( ClientModelRenderInfo_t *pInfo )
{
CMatRenderContextPtr pRenderContext( materials );
pRenderContext->DepthRange(0.0f, 1.0f);
return BaseClass::OnPostInternalDrawModel(pInfo);
}
示例2: OverlayCameraRenderTarget
void OverlayCameraRenderTarget(const char *pszMaterialName, float flX, float flY, float w, float h)
{
float offsetS = (0.5f / 256.0f);
float offsetT = (0.5f / 256.0f);
IMaterial *pMaterial;
pMaterial = materials->FindMaterial(pszMaterialName, TEXTURE_GROUP_OTHER, true);
if (!IsErrorMaterial(pMaterial))
{
CMatRenderContextPtr pRenderContext(materials);
pRenderContext->Bind(pMaterial);
IMesh* pMesh = pRenderContext->GetDynamicMesh(true);
CMeshBuilder meshBuilder;
meshBuilder.Begin(pMesh, MATERIAL_QUADS, 1);
meshBuilder.Position3f(flX, flY, 0.0f);
meshBuilder.TexCoord2f(0, 0.0f + offsetS, 0.0f + offsetT);
meshBuilder.AdvanceVertex();
meshBuilder.Position3f(flX + w, flY, 0.0f);
meshBuilder.TexCoord2f(0, 1.0f + offsetS, 0.0f + offsetT);
meshBuilder.AdvanceVertex();
meshBuilder.Position3f(flX + w, flY + h, 0.0f);
meshBuilder.TexCoord2f(0, 1.0f + offsetS, 1.0f + offsetT);
meshBuilder.AdvanceVertex();
meshBuilder.Position3f(flX, flY + h, 0.0f);
meshBuilder.TexCoord2f(0, 0.0f + offsetS, 1.0f + offsetT);
meshBuilder.AdvanceVertex();
meshBuilder.End();
pMesh->Draw();
}
}
示例3: VPROF
void CGlowOverlay::DrawOverlays( bool bCacheFullSceneState )
{
VPROF("CGlowOverlay::DrawOverlays()");
CMatRenderContextPtr pRenderContext( materials );
bool bClippingEnabled = pRenderContext->EnableClipping( true );
unsigned short iNext;
for( unsigned short i=g_GlowOverlaySystem.m_GlowOverlays.Head(); i != g_GlowOverlaySystem.m_GlowOverlays.InvalidIndex(); i = iNext )
{
iNext = g_GlowOverlaySystem.m_GlowOverlays.Next( i );
CGlowOverlay *pOverlay = g_GlowOverlaySystem.m_GlowOverlays[i];
if( !pOverlay->m_bActivated )
continue;
if( pOverlay->Update() )
{
pRenderContext->EnableClipping( ((pOverlay->m_bInSky) ? (false):(bClippingEnabled)) ); //disable clipping in skybox, restore clipping to pre-existing state when not in skybox (it may be off as well)
pOverlay->Draw( bCacheFullSceneState );
}
else
{
delete pOverlay;
}
}
pRenderContext->EnableClipping( bClippingEnabled ); //restore clipping to original state
}
示例4: GetAbsOrigin
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_PropCombineBall::DrawMotionBlur( void )
{
float color[3];
Vector vecDir = GetAbsOrigin() - m_vecLastOrigin;
float speed = VectorNormalize( vecDir );
speed = clamp( speed, 0, 32 );
float stepSize = MIN( ( speed * 0.5f ), 4.0f );
Vector spawnPos = GetAbsOrigin();
Vector spawnStep = -vecDir * stepSize;
float base = RemapValClamped( speed, 4, 32, 0.0f, 1.0f );
CMatRenderContextPtr pRenderContext( materials );
pRenderContext->Bind( m_pBlurMaterial );
// Draw the motion blurred trail
for ( int i = 0; i < 8; i++ )
{
spawnPos += spawnStep;
color[0] = color[1] = color[2] = base * ( 1.0f - ( (float) i / 12.0f ) );
DrawHalo( m_pBlurMaterial, spawnPos, m_flRadius, color );
}
}
示例5: pRenderContext
int C_Hairball::DrawModel( int flags )
{
if ( !m_pMaterial )
return 0;
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
for ( int iHair=0; iHair < m_nHairs; iHair++ )
{
CSimplePhysics::CNode *pBase = &m_Nodes[iHair * m_nNodesPerHair];
CBeamSegDraw beamDraw;
beamDraw.Start( pRenderContext, m_nNodesPerHair-1, m_pMaterial );
for ( int i=0; i < m_nNodesPerHair; i++ )
{
BeamSeg_t seg;
seg.m_vPos = pBase[i].m_vPredicted;
seg.m_vColor.Init( 0, 0, 0 );
seg.m_flTexCoord = 0;
static float flHairWidth = 1;
seg.m_flWidth = flHairWidth;
seg.m_flAlpha = 0;
beamDraw.NextSeg( &seg );
}
beamDraw.End();
}
return 1;
}
示例6: QAngle
//-----------------------------------------------------------------------------
// Purpose: Sets view parameters for level overview mode
// Input : *rect -
//-----------------------------------------------------------------------------
void CViewRender::SetUpOverView()
{
static int oldCRC = 0;
m_View.m_bOrtho = true;
float aspect = (float)m_View.width/(float)m_View.height;
int size_y = 1024.0f * cl_leveloverview.GetFloat(); // scale factor, 1024 = OVERVIEW_MAP_SIZE
int size_x = size_y * aspect; // standard screen aspect
m_View.origin.x -= size_x / 2;
m_View.origin.y += size_y / 2;
m_View.m_OrthoLeft = 0;
m_View.m_OrthoTop = -size_y;
m_View.m_OrthoRight = size_x;
m_View.m_OrthoBottom = 0;
m_View.angles = QAngle( 90, 90, 0 );
// simple movement detector, show position if moved
int newCRC = m_View.origin.x + m_View.origin.y + m_View.origin.z;
if ( newCRC != oldCRC )
{
Msg( "Overview: scale %.2f, pos_x %.0f, pos_y %.0f\n", cl_leveloverview.GetFloat(),
m_View.origin.x, m_View.origin.y );
oldCRC = newCRC;
}
CMatRenderContextPtr pRenderContext( materials );
pRenderContext->ClearColor4ub( 0, 255, 0, 255 );
// render->DrawTopView( true );
}
示例7: VPROF_BUDGET
void CReplayRenderer::LayoffFrame( int nFrame )
{
VPROF_BUDGET( "CReplayRenderer::LayoffFrame", VPROF_BUDGETGROUP_REPLAY );
// FIXME: This is somewhat of a hack to get layoff working again
// We're rendering into the full preview size, but stretching down to the actual size
Rect_t srcRect;
srcRect.x = 0;
srcRect.y = 0;
srcRect.width = m_RenderParams.m_Settings.m_nWidth;
srcRect.height = m_RenderParams.m_Settings.m_nHeight;
Rect_t dstRect;
dstRect.x = 0;
dstRect.y = 0;
dstRect.width = m_RenderParams.m_Settings.m_nWidth;
dstRect.height = m_RenderParams.m_Settings.m_nHeight;
#ifdef TRACE_REPLAY_STATE_MACHINE
Msg( "laying off movie frame %i\n", nFrame );
#endif
CMatRenderContextPtr pRenderContext( materials );
// pRenderContext->ReadPixelsAndStretch( &srcRect, &dstRect, (unsigned char*)m_pLayoffBuf,
// IMAGE_FORMAT_BGRA8888, dstRect.width * ImageLoader::SizeInBytes( IMAGE_FORMAT_BGRA8888 ) );
pRenderContext->ReadPixels( 0, 0, (int) m_RenderParams.m_Settings.m_nWidth, (int) m_RenderParams.m_Settings.m_nHeight, (unsigned char*)m_pLayoffBuf, IMAGE_FORMAT_BGRA8888 );
static ConVarRef mat_queue_mode( "mat_queue_mode" );
// Encode the frame
#ifdef REPLAY_RECORDING_ENABLE
if ( m_RenderParams.m_bExportRaw )
{
CUtlBuffer bufOut;
if ( TGAWriter::WriteToBuffer( (unsigned char *)m_pLayoffBuf, bufOut, m_RenderParams.m_Settings.m_nWidth,
m_RenderParams.m_Settings.m_nHeight, IMAGE_FORMAT_BGRA8888, IMAGE_FORMAT_RGB888 ) )
{
// Format filename and write the TGA
CFmtStr fmtFilename(
"%sFrame_%04i.tga",
m_fmtTgaRenderDirName.Access(),
m_iTgaFrame++
);
if ( !g_pFullFileSystem->WriteFile( fmtFilename.Access(), NULL, bufOut ) )
{
Warning( "Couldn't write bitmap data snapshot to file %s.\n", fmtFilename.Access() );
}
}
}
else if ( m_pMovieMaker )
{
// can't run in any other mode
Assert( mat_queue_mode.GetInt() == 0 );
VPROF_BUDGET( "CReplayRenderer::LayoffFrame - AppendVideoFrame", VPROF_BUDGETGROUP_REPLAY );
m_pMovieMaker->AppendVideoFrame( m_pLayoffBuf );
}
#endif
}
示例8: pRenderContext
//-----------------------------------------------------------------------------
// Sets a default env_cubemap for rendering materials w/ specularity
//-----------------------------------------------------------------------------
void CSceneViewerApp::InitDefaultEnvCubemap( )
{
// Deal with the default cubemap
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
ITexture *pCubemapTexture = g_pMaterialSystem->FindTexture( "editor/cubemap", NULL, true );
m_DefaultEnvCubemap.Init( pCubemapTexture );
pRenderContext->BindLocalCubemap( pCubemapTexture );
}
示例9: pRenderContext
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CDmeDrawSettings::DrawDag( CDmeDag *pDag )
{
if ( !pDag )
return;
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
m_IsAMaterialBound = false;
if ( !Shaded() )
{
BindWireframe();
}
else if ( GetGrayShade() )
{
BindGray();
}
pDag->Draw( this );
m_IsAMaterialBound = false;
if ( GetWireframeOnShaded() )
{
if ( Shaded() )
{
VMatrix m;
pRenderContext->GetMatrix( MATERIAL_PROJECTION, &m );
/* Extract the near and far clipping plane values from projection matrix
float c = m[ 2 ][ 2 ];
float d = m[ 2 ][ 3 ];
const float near = d / ( c - 1.0f );
const float far = d / ( c + 1.0f );
*/
const float zBias = 0.00025;
m[ 2 ][ 2 ] += zBias;
m[ 2 ][ 3 ] += zBias;
pRenderContext->MatrixMode( MATERIAL_PROJECTION );
pRenderContext->PushMatrix();
pRenderContext->LoadMatrix( m );
BindWireframeOnShaded();
PushDrawType();
SetDrawType( CDmeDrawSettings::DRAW_WIREFRAME );
pDag->Draw( this );
PopDrawType();
pRenderContext->MatrixMode( MATERIAL_PROJECTION );
pRenderContext->PopMatrix();
}
}
}
示例10: pRenderContext
void CColorCorrectionMgr::RemoveColorCorrection( ClientCCHandle_t h )
{
if ( h != INVALID_CLIENT_CCHANDLE )
{
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
ColorCorrectionHandle_t ccHandle = (ColorCorrectionHandle_t)h;
pRenderContext->RemoveLookup( ccHandle );
}
}
示例11: DrawSmokeFogOverlay
void DrawSmokeFogOverlay()
{
if(g_SmokeFogOverlayAlpha == 0 || !g_pSmokeFogMaterial || !materials)
return;
// Hard-coded for now..
g_SmokeFogOverlayColor.Init( 0.3, 0.3, 0.3 );
CMatRenderContextPtr pRenderContext( materials );
pRenderContext->MatrixMode( MATERIAL_PROJECTION );
pRenderContext->LoadIdentity();
pRenderContext->Ortho( 0, 0, 1, 1, -99999, 99999 );
pRenderContext->MatrixMode( MATERIAL_VIEW );
pRenderContext->LoadIdentity();
pRenderContext->MatrixMode( MATERIAL_MODEL );
pRenderContext->LoadIdentity();
IMesh* pMesh = pRenderContext->GetDynamicMesh( false, NULL, NULL, g_pSmokeFogMaterial );
CMeshBuilder meshBuilder;
static float dist = 10;
Vector vColor = g_SmokeFogOverlayColor;
vColor.x = MIN(MAX(vColor.x, 0), 1);
vColor.y = MIN(MAX(vColor.y, 0), 1);
vColor.z = MIN(MAX(vColor.z, 0), 1);
float alpha = MIN(MAX(g_SmokeFogOverlayAlpha, 0), 1);
meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 );
meshBuilder.Position3f( 0, 0, dist );
meshBuilder.Color4f( vColor.x, vColor.y, vColor.z, alpha );
meshBuilder.TexCoord2f( 0, 0.0f, 0.0f );
meshBuilder.AdvanceVertex();
meshBuilder.Position3f( 0, 1, dist );
meshBuilder.Color4f( vColor.x, vColor.y, vColor.z, alpha );
meshBuilder.TexCoord2f( 0, 0.0f, 0.0f );
meshBuilder.AdvanceVertex();
meshBuilder.Position3f( 1, 1, dist );
meshBuilder.Color4f( vColor.x, vColor.y, vColor.z, alpha );
meshBuilder.TexCoord2f( 0, 0.0f, 0.0f );
meshBuilder.AdvanceVertex();
meshBuilder.Position3f( 1, 0, dist );
meshBuilder.Color4f( vColor.x, vColor.y, vColor.z, alpha );
meshBuilder.TexCoord2f( 0, 0.0f, 0.0f );
meshBuilder.AdvanceVertex();
meshBuilder.End();
pMesh->Draw();
}
示例12: pRenderContext
void CTextureSystem::RebindDefaultCubeMap()
{
// rebind with the default cubemap
if ( m_pCubemapTexture )
{
CMatRenderContextPtr pRenderContext( MaterialSystemInterface() );
pRenderContext->BindLocalCubemap( m_pCubemapTexture );
}
}
示例13: pRenderContext
//-----------------------------------------------------------------------------
// Purpose: Draw our special effects
//-----------------------------------------------------------------------------
void C_WeaponStunStick::DrawFirstPersonEffects( void )
{
Vector vecOrigin;
QAngle vecAngles;
float color[3];
float scale;
CMatRenderContextPtr pRenderContext( materials );
IMaterial *pMaterial = materials->FindMaterial( STUNSTICK_GLOW_MATERIAL_NOZ, NULL, false );
// FIXME: Needs to work with new IMaterial system!
pRenderContext->Bind( pMaterial );
// Find where we are in the fade
float fadeAmount = RemapValClamped( gpGlobals->curtime, m_flFadeTime, m_flFadeTime + FADE_DURATION, 1.0f, 0.1f );
// Get bright when swung
if ( InSwing() )
{
color[0] = color[1] = color[2] = 0.4f;
scale = 22.0f;
}
else
{
color[0] = color[1] = color[2] = 0.4f * fadeAmount;
scale = 20.0f;
}
if ( color[0] > 0.0f )
{
// Draw an all encompassing glow around the entire head
UTIL_GetWeaponAttachment( this, m_BeamCenterAttachment, vecOrigin, vecAngles );
DrawHalo( pMaterial, vecOrigin, scale, color );
}
// Draw bright points at each attachment location
for ( int i = 0; i < (NUM_BEAM_ATTACHMENTS*2)+1; i++ )
{
if ( InSwing() )
{
color[0] = color[1] = color[2] = random->RandomFloat( 0.05f, 0.5f );
scale = random->RandomFloat( 4.0f, 5.0f );
}
else
{
color[0] = color[1] = color[2] = random->RandomFloat( 0.05f, 0.5f ) * fadeAmount;
scale = random->RandomFloat( 4.0f, 5.0f ) * fadeAmount;
}
if ( color[0] > 0.0f )
{
UTIL_GetWeaponAttachment( this, i, vecOrigin, vecAngles );
DrawHalo( pMaterial, vecOrigin, scale, color );
}
}
}
示例14: DrawHaloOriented
//-----------------------------------------------------------------------------
// Purpose:
// Input : pMaterial -
// source -
// color -
//-----------------------------------------------------------------------------
void DrawHaloOriented( const Vector& source, float scale, float const *color, float roll )
{
Vector point, screen;
CMatRenderContextPtr pRenderContext( materials );
IMesh* pMesh = pRenderContext->GetDynamicMesh();
CMeshBuilder meshBuilder;
meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 );
// Transform source into screen space
ScreenTransform( source, screen );
Vector right, up;
float sr, cr;
SinCos( roll, &sr, &cr );
for ( int i = 0; i < 3; i++ )
{
right[i] = CurrentViewRight()[i] * cr + CurrentViewUp()[i] * sr;
up[i] = CurrentViewRight()[i] * -sr + CurrentViewUp()[i] * cr;
}
meshBuilder.Color3fv (color);
meshBuilder.TexCoord2f (0, 0, 1);
VectorMA (source, -scale, up, point);
VectorMA (point, -scale, right, point);
meshBuilder.Position3fv (point.Base());
meshBuilder.AdvanceVertex();
meshBuilder.Color3fv (color);
meshBuilder.TexCoord2f (0, 0, 0);
VectorMA (source, scale, up, point);
VectorMA (point, -scale, right, point);
meshBuilder.Position3fv (point.Base());
meshBuilder.AdvanceVertex();
meshBuilder.Color3fv (color);
meshBuilder.TexCoord2f (0, 1, 0);
VectorMA (source, scale, up, point);
VectorMA (point, scale, right, point);
meshBuilder.Position3fv (point.Base());
meshBuilder.AdvanceVertex();
meshBuilder.Color3fv (color);
meshBuilder.TexCoord2f (0, 1, 1);
VectorMA (source, -scale, up, point);
VectorMA (point, scale, right, point);
meshBuilder.Position3fv (point.Base());
meshBuilder.AdvanceVertex();
meshBuilder.End();
pMesh->Draw();
}
示例15: 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();
}