本文整理汇总了C++中IDriver::activeVertexProgram方法的典型用法代码示例。如果您正苦于以下问题:C++ IDriver::activeVertexProgram方法的具体用法?C++ IDriver::activeVertexProgram怎么用?C++ IDriver::activeVertexProgram使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDriver
的用法示例。
在下文中一共展示了IDriver::activeVertexProgram方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderTestMesh
//*******************************************************************************
void CWaterEnvMap::renderTestMesh(IDriver &driver)
{
doInit();
CMaterial testMat;
testMat.setLighting(false);
testMat.texEnvOpRGB(0, CMaterial::Modulate);
testMat.texEnvArg0RGB(0, CMaterial::Texture, CMaterial::SrcColor);
testMat.texEnvArg0RGB(1, CMaterial::Diffuse, CMaterial::SrcColor);
testMat.texEnvOpAlpha(0, CMaterial::Replace);
testMat.texEnvArg0Alpha(0, CMaterial::Constant, CMaterial::SrcAlpha);
testMat.texConstantColor(0, CRGBA(255, 255, 255, 255));
testMat.setDoubleSided(true);
testMat.setZWrite(false);
testMat.setZFunc(CMaterial::always);
// tmp : test cubemap
driver.activeVertexProgram(&testMeshVP);
driver.activeVertexBuffer(_TestVB);
driver.activeIndexBuffer(_TestIB);
driver.setConstantMatrix(0, IDriver::ModelViewProjection, IDriver::Identity); // tmp
_MaterialPassThruZTest.setTexture(0, _EnvCubic);
driver.setConstantMatrix(0, IDriver::ModelViewProjection, IDriver::Identity);
driver.setConstant(4, 2.f, 1.f, 0.f, 0.f);
//driver.renderTriangles(testMat, 0, TEST_VB_NUM_TRIS);
driver.renderTriangles(_MaterialPassThruZTest, 0, TEST_VB_NUM_TRIS);
driver.activeVertexProgram(NULL);
}
示例2: update
//*******************************************************************************
void CWaterEnvMap::update(TGlobalAnimationTime time, IDriver &driver)
{
if (_LastRenderTime == time) return;
_LastRenderTime = time;
// First five updates are used to render the cubemap faces (bottom face is not rendered)
// Sixth update project the cubemap into a 2D texture
uint numTexToRender;
if (_UpdateTime > 0)
{
uint64 currRenderTick = (uint64) (time / (_UpdateTime / (NUM_FACES_TO_RENDER + 1)));
numTexToRender = (uint) (currRenderTick - _LastRenderTick);
_LastRenderTick = currRenderTick;
}
else
{
numTexToRender = NUM_FACES_TO_RENDER + 1;
}
if (!numTexToRender) return;
if (_NumRenderedFaces == 0)
{
_StartRenderTime = time;
}
uint lastCubeFacesToRender = std::min((uint) NUM_FACES_TO_RENDER, _NumRenderedFaces + numTexToRender); // we don't render negative Z (only top hemisphere is used)
for(uint k = _NumRenderedFaces; k < lastCubeFacesToRender; ++k)
{
driver.setRenderTarget(_EnvCubic, 0, 0, _EnvCubicSize, _EnvCubicSize, 0, (uint32) k);
render((CTextureCube::TFace) k, _StartRenderTime);
}
_NumRenderedFaces = lastCubeFacesToRender;
if (_NumRenderedFaces == NUM_FACES_TO_RENDER && (_NumRenderedFaces + numTexToRender) > NUM_FACES_TO_RENDER)
{
// render to 2D map
driver.setRenderTarget(_Env2D, 0, 0, _Env2DSize, _Env2DSize);
doInit();
//
driver.activeVertexProgram(NULL);
driver.activeVertexBuffer(_FlattenVB);
driver.activeIndexBuffer(_FlattenIB);
driver.setFrustum(-1.f, 1.f, -1.f, 1.f, 0.f, 1.f, false);
driver.setupViewMatrix(CMatrix::Identity);
CMatrix mat;
//mat.scale(0.8f);
driver.setupModelMatrix(mat);
_MaterialPassThru.setTexture(0, _EnvCubic);
_MaterialPassThru.texConstantColor(0, CRGBA(255, 255, 255, _Alpha));
driver.renderTriangles(_MaterialPassThru, 0, FVB_NUM_TRIS);
_NumRenderedFaces = 0; // start to render again
}
driver.setRenderTarget(NULL);
}
示例3: applyEffect
void CFXAA::applyEffect()
{
if (!m_PP)
return;
CDriverUser *dru = static_cast<CDriverUser *>(m_Driver);
IDriver *drv = dru->getDriver();
// backup
bool fogEnabled = m_Driver->fogEnabled();
m_Driver->enableFog(false);
NL3D::ITexture *renderTarget = drv->getRenderTarget();
nlassert(renderTarget);
nlassert(renderTarget->isBloomTexture());
uint width = renderTarget->getWidth();
uint height = renderTarget->getHeight();
bool mode2D = static_cast<CTextureBloom *>(renderTarget)->isMode2D();
nlassert(renderTarget->getUploadFormat() == ITexture::Auto);
float fwidth = (float)width;
float fheight = (float)height;
float pwidth = 1.0f / fwidth;
float pheight = 1.0f / fheight;
float hpwidth = pwidth * 0.5f;
float hpheight = pheight * 0.5f;
float n = 0.5f;
//if (width != m_Width || height != m_Height)
/*{
// Build VB
m_Width = width;
m_Height = height;
CVertexBufferReadWrite vba;
m_VB.lock(vba);
vba.setValueFloat3Ex(CVertexBuffer::Position, 0, 0.f, 0.f, 0.5f); // BL
vba.setValueFloat3Ex(CVertexBuffer::Position, 1, 1.f, 0.f, 0.5f); // BR
vba.setValueFloat3Ex(CVertexBuffer::Position, 2, 1.f, 1.f, 0.5f); // TR
vba.setValueFloat3Ex(CVertexBuffer::Position, 3, 0.f, 1.f, 0.5f); // TL
vba.setValueFloat2Ex(CVertexBuffer::TexCoord0, 0, 0.f, 0.f);
vba.setValueFloat2Ex(CVertexBuffer::TexCoord0, 1, 1.f, 0.f);
vba.setValueFloat2Ex(CVertexBuffer::TexCoord0, 2, 1.f, 1.f);
vba.setValueFloat2Ex(CVertexBuffer::TexCoord0, 3, 0.f, 1.f);
vba.setValueFloat4Ex(CVertexBuffer::TexCoord1, 0, 0.f - hpwidth, 0.f - hpheight, 0.f + hpwidth, 0.f + hpheight);
vba.setValueFloat4Ex(CVertexBuffer::TexCoord1, 1, 1.f - hpwidth, 0.f - hpheight, 1.f + hpwidth, 0.f + hpheight);
vba.setValueFloat4Ex(CVertexBuffer::TexCoord1, 2, 1.f - hpwidth, 1.f - hpheight, 1.f + hpwidth, 1.f + hpheight);
vba.setValueFloat4Ex(CVertexBuffer::TexCoord1, 3, 0.f - hpwidth, 1.f - hpheight, 0.f + hpwidth, 1.f + hpheight);
}*/
// create render target
CTextureUser *otherRenderTarget = m_Driver->getRenderTargetManager().getRenderTarget(width, height, mode2D);
// swap render target
CTextureUser texNull;
dru->setRenderTarget(texNull);
drv->swapTextureHandle(*renderTarget, *otherRenderTarget->getITexture());
drv->setRenderTarget(renderTarget);
m_Driver->setMatrixMode2D11();
// debug
// m_Driver->clearBuffers(CRGBA(128, 128, 128, 128));
// activate program
bool vpok = drv->activeVertexProgram(m_VP);
nlassert(vpok);
bool ppok = drv->activePixelProgram(m_PP);
nlassert(ppok);
/*drv->setUniform4f(IDriver::PixelProgram, 0, -n / fwidth, -n / fheight, n / fwidth, n / fheight); // fxaaConsoleRcpFrameOpt
drv->setUniform4f(IDriver::PixelProgram, 1, -2.0f / fwidth, -2.0f / fheight, 2.0f / fwidth, 2.0f / fheight); // fxaaConsoleRcpFrameOpt2*/
drv->setUniform2f(IDriver::PixelProgram, 0, 1.0f / fwidth, 1.0f / fheight); // fxaaQualityRcpFrame
drv->setUniform1f(IDriver::PixelProgram, 1, 0.75f); // fxaaQualitySubpix
drv->setUniform1f(IDriver::PixelProgram, 2, 0.166f); // fxaaQualityEdgeThreshold
drv->setUniform1f(IDriver::PixelProgram, 3, 0.0833f); // fxaaQualityEdgeThresholdMin
drv->setUniformMatrix(IDriver::VertexProgram, 0, IDriver::ModelViewProjection, IDriver::Identity);
// drv->setUniform4f(IDriver::VertexProgram, 9, -hpwidth, -hpheight, hpwidth, hpheight);
// render effect
m_Mat.getObjectPtr()->setTexture(0, otherRenderTarget->getITexture());
/*drv->activeVertexBuffer(m_VB);
drv->renderRawQuads(*m_Mat.getObjectPtr(), 0, 1);*/
m_Driver->drawQuad(m_QuadUV, m_Mat);
m_Mat.getObjectPtr()->setTexture(0, NULL);
// deactivate program
drv->activeVertexProgram(NULL);
drv->activePixelProgram(NULL);
// restore
m_Driver->enableFog(fogEnabled);
// recycle render target
m_Driver->getRenderTargetManager().recycleRenderTarget(otherRenderTarget);
}
示例4: getDriver
// ***************************************************************************
void CScene::endPartRender(bool keepTrav)
{
nlassert(_IsRendering);
_IsRendering = false;
if (!keepTrav)
{
// Delete model deleted during the rendering
uint i;
for (i=0; i<_ToDelete.size(); i++)
deleteModel (_ToDelete[i]);
_ToDelete.clear ();
// Special for SkeletonSpawnScript animation. create models spawned now
flushSSSModelRequests();
// Particle system handling (remove the resources of those which are too far, as their clusters may not have been parsed).
// Note that only a few of them are tested at each call
_ParticleSystemManager.refreshModels(ClipTrav.WorldFrustumPyramid, ClipTrav.CamPos);
// Waiting Instance handling
double deltaT = _DeltaSystemTimeBetweenRender;
clamp (deltaT, 0.01, 0.1);
updateWaitingInstances(deltaT);
}
// Reset profiling
_NextRenderProfile= false;
IDriver *drv = getDriver();
drv->activeVertexProgram(NULL);
drv->activePixelProgram(NULL);
drv->activeGeometryProgram(NULL);
// Ensure nothing animates on subsequent renders
_EllapsedTime = 0.f;
/*
uint64 total = PSStatsRegisterPSModelObserver +
PSStatsRemovePSModelObserver +
PSStatsUpdateOpacityInfos +
PSStatsUpdateLightingInfos +
PSStatsGetAABBox +
PSStatsReallocRsc +
PSStatsReleasePSPointer +
PSStatsRefreshRscDeletion +
PSStatsReleaseRsc +
PSStatsReleaseRscAndInvalidate +
PSStatsGetNumTriangles +
PSStatsCheckAgainstPyramid +
PSStatsTraverseAnimDetail +
PSStatsDoAnimate +
PSStatsTraverseRender +
PSStatsTraverseClip +
PSStatsCheckDestroyCondition +
PSStatsForceInstanciate +
PSStatsDoAnimatePart1 +
PSStatsDoAnimatePart2 +
PSStatsDoAnimatePart3 +
PSStatsTraverseAnimDetailPart1 +
PSStatsTraverseAnimDetailPart2 +
PSStatsTraverseAnimDetailPart3 +
PSStatsTraverseAnimDetailPart4 +
PSAnim1 +
PSAnim2+
PSAnim3+
PSAnim4+
PSAnim5+
PSAnim6+
PSAnim7+
PSAnim8+
PSAnim9+
PSAnim10+
PSAnim11;
if (((double) total / (double) NLMISC::CSystemInfo::getProcessorFrequency()) > 0.01)
{
nlinfo("***** PS STATS ****");
#define PS_STATS(var) \
nlinfo("time for " #var " = %.2f", (float) (1000 * ((double) var / (double) CSystemInfo::getProcessorFrequency())));
PS_STATS(PSStatsRegisterPSModelObserver)
PS_STATS(PSStatsRemovePSModelObserver)
PS_STATS(PSStatsUpdateOpacityInfos)
PS_STATS(PSStatsUpdateLightingInfos)
PS_STATS(PSStatsGetAABBox)
PS_STATS(PSStatsReallocRsc)
PS_STATS(PSStatsReleasePSPointer)
PS_STATS(PSStatsRefreshRscDeletion)
PS_STATS(PSStatsReleaseRsc)
PS_STATS(PSStatsReleaseRscAndInvalidate)
PS_STATS(PSStatsGetNumTriangles)
PS_STATS(PSStatsCheckAgainstPyramid)
PS_STATS(PSStatsTraverseAnimDetail)
PS_STATS(PSStatsDoAnimate)
PS_STATS(PSStatsTraverseRender)
PS_STATS(PSStatsTraverseClip)
PS_STATS(PSStatsClipSystemInstanciated);
//.........这里部分代码省略.........