本文整理汇总了C++中VertexShader::apply方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexShader::apply方法的具体用法?C++ VertexShader::apply怎么用?C++ VertexShader::apply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexShader
的用法示例。
在下文中一共展示了VertexShader::apply方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderProjection
void renderProjection(Storm3D_Scene &scene, Storm3D_Spotlight *spot)
{
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
if(!decals.empty())
{
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
D3DXMATRIX tm;
int materialIndex = 0;
int startIndex = 0;
int endIndex = 0;
if(spot->getType() == IStorm3D_Spotlight::Point)
pointVertexShader.apply();
else if(spot->getType() == IStorm3D_Spotlight::Directional)
dirVertexShader.apply();
else if(spot->getType() == IStorm3D_Spotlight::Flat)
flatVertexShader.apply();
vertices.apply(0);
int prevBindOffs = 0;
Storm3D_ShaderManager::GetSingleton()->SetWorldTransform(tm);
Storm3D_ShaderManager::GetSingleton()->SetTransparencyFactor(0.75f);
for(;;)
{
materialIndex = decals[startIndex]->materialIndex;
materials[materialIndex].applyProjection(spot->getColorMultiplier());
int decalAmount = decals.size();
for(int i = startIndex + 1; i < decalAmount; ++i)
{
if(decals[i]->materialIndex != materialIndex)
break;
endIndex = i;
}
int renderAmount = endIndex - startIndex + 1;
if (prevBindOffs != startIndex * 4) {
vertices.apply(0, (startIndex * 4) * VERTEX_SIZE);
prevBindOffs = startIndex * 4;
}
indices.render(renderAmount * 2, renderAmount * 4);
startIndex = ++endIndex;
scene.AddPolyCounter(renderAmount * 2);
if(startIndex >= decalAmount)
break;
}
Storm3D_ShaderManager::GetSingleton()->SetTransparencyFactor(1.f);
glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_BLEND);
}
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
}
示例2: render
void render(Storm3D_Scene &scene)
{
findDecals(scene);
createIndexBuffers();
createVertexBuffers();
// Render
if(!decals.empty())
{
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
D3DXMATRIX tm;
pixelShader.apply();
vertexShader.apply();
vertices.apply(0);
// ugly HACK!
int prevBindOffs = 0;
Storm3D_ShaderManager::GetSingleton()->SetWorldTransform(tm);
float outfactor[4] = { outFactor.r, outFactor.g, outFactor.b, 1.0f };
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 8, outfactor);
float infactor[4] = { inFactor.r, inFactor.g, inFactor.b, 1.0f };
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 9, infactor);
int materialIndex = 0;
int startIndex = 0;
int endIndex = 0;
for(;;)
{
materialIndex = decals[startIndex]->materialIndex;
materials[materialIndex].apply();
int decalAmount = decals.size();
for(int i = startIndex + 1; i < decalAmount; ++i)
{
if(decals[i]->materialIndex != materialIndex)
break;
endIndex = i;
}
int renderAmount = endIndex - startIndex + 1;
if (prevBindOffs != startIndex * 4) {
vertices.apply(0, (startIndex * 4) * VERTEX_SIZE);
prevBindOffs = startIndex * 4;
}
indices.render(renderAmount * 2, renderAmount * 4);
startIndex = ++endIndex;
scene.AddPolyCounter(renderAmount * 2);
if(startIndex >= decalAmount)
break;
}
glDisable(GL_BLEND);
}
}