本文整理汇总了C++中VertexShader::GetNumSamplers方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexShader::GetNumSamplers方法的具体用法?C++ VertexShader::GetNumSamplers怎么用?C++ VertexShader::GetNumSamplers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexShader
的用法示例。
在下文中一共展示了VertexShader::GetNumSamplers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: glCreateProgram
PdrMaterialPass::PdrMaterialPass (Renderer *renderer, const MaterialPass *pass)
{
mPass = pass;
VertexShader *vshader = pass->GetVertexShader();
PixelShader *pshader = pass->GetPixelShader();
renderer->Bind(vshader);
renderer->Bind(pshader);
PdrVertexShader *pdrVS = renderer->GetResource(pass->GetVertexShader());
PdrPixelShader *pdrPS = renderer->GetResource(pass->GetPixelShader());
mProgramObject = glCreateProgram();
assertion(mProgramObject != 0, "glCreateProgram failed.");
GLint vShader = pdrVS->GetShader();
GLint pShader = pdrPS->GetShader();
PX2_GL_CHECK(glAttachShader (mProgramObject, vShader));
PX2_GL_CHECK(glAttachShader (mProgramObject, pShader));
glBindAttribLocation(mProgramObject, ALP_POSITION, "modelPosition");
glBindAttribLocation(mProgramObject, ALP_NORMAL, "modelNormal");
glBindAttribLocation(mProgramObject, ALP_TEXCOORD0, "modelTCoord0");
// Link the program
glLinkProgram (mProgramObject);
// Check the link status
GLint linked;
glGetProgramiv(mProgramObject, GL_LINK_STATUS, &linked);
if (!linked)
{
GLint infoLen = 0;
glGetProgramiv(mProgramObject, GL_INFO_LOG_LENGTH, &infoLen);
if (infoLen > 1)
{
char* infoLog = (char*)malloc(sizeof(char) * infoLen);
glGetProgramInfoLog(mProgramObject, infoLen, NULL, infoLog);
assertion(false, "Error linking program:\n%s\n", infoLog);
free(infoLog);
}
glDeleteProgram(mProgramObject);
}
else
{
int vProfile = VertexShader::GetProfile();
const int vNumConstants = vshader->GetNumConstants();
for (int i=0; i<vNumConstants; ++i)
{
const std::string &name = vshader->GetConstantName(i);
int location = glGetUniformLocation(mProgramObject, name.c_str());
vshader->SetBaseRegister(vProfile, i, location);
}
const int numVTexs = vshader->GetNumSamplers();
for (int i=0; i<numVTexs; i++)
{
std::string sampleName = vshader->GetSamplerName(i);
int location = glGetUniformLocation(mProgramObject, sampleName.c_str());
}
int pProfile = PixelShader::GetProfile();
const int pNumConstants = pshader->GetNumConstants();
for (int i=0; i<pNumConstants; ++i)
{
const std::string &name = pshader->GetConstantName(i);
int location = glGetUniformLocation(mProgramObject, name.c_str());
pshader->SetBaseRegister(pProfile, i, location);
}
const int numPTexs = pshader->GetNumSamplers();
for (int i=0; i<numPTexs; i++)
{
std::string sampleName = pshader->GetSamplerName(i);
int location = glGetUniformLocation(mProgramObject, sampleName.c_str());
}
}
}