本文整理汇总了C++中CShader::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ CShader::getName方法的具体用法?C++ CShader::getName怎么用?C++ CShader::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CShader
的用法示例。
在下文中一共展示了CShader::getName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QERApp_LoadShadersFromDir
int WINAPI QERApp_LoadShadersFromDir (const char* path)
{
int count = 0;
// scan g_Shaders, and call QERApp_Shader_ForName for each in the given path
// this will load the texture if needed and will set it in use..
int nSize = g_Shaders.GetSize();
for (int i = 0; i < nSize; i++)
{
CShader *pShader = reinterpret_cast<CShader*>(g_Shaders.ElementAt(i));
if (strstr(pShader->getShaderFileName(), path) || strstr(pShader->getName(), path))
{
count++;
// request the shader, this will load the texture if needed and set "inuse"
//++timo FIXME: should we put an Activate member on CShader?
// this QERApp_Shader_ForName call is a kind of hack
IShader *pFoo = QERApp_Shader_ForName(pShader->getName());
#ifdef _DEBUG
// check we activated the right shader
// NOTE: if there was something else loaded, the size of g_Shaders may have changed and strange behaviours are to be expected
if (pFoo != pShader)
Sys_Printf("WARNING: unexpected pFoo != pShader in QERApp_LoadShadersFromDir\n");
#endif
}
}
return count;
}
示例2: QERApp_LoadShaderFile
void WINAPI QERApp_LoadShaderFile (const char* filename)
{
char* pBuff = NULL;
int nSize = LoadFile(filename, reinterpret_cast<void**>(&pBuff));
if (nSize == -1)
nSize = PakLoadAnyFile(filename, reinterpret_cast<void**>(&pBuff));
if (nSize > 0)
{
Sys_Printf("Parsing shaderfile %s\n", filename);
StartTokenParsing(pBuff);
while (GetToken(true))
{
// first token should be the path + name.. (from base)
CShader *pShader = new CShader();
// we want the relative filename only, it's easier for later lookup .. see QERApp_ReloadShaderFile
char cTmp[1024];
QE_ConvertDOSToUnixName( cTmp, filename );
pShader->setShaderFileName( filename + strlen(ValueForKey(g_qeglobals.d_project_entity, "basepath")) + 1);
if (pShader->Parse())
{
// do we already have this shader?
//++timo NOTE: this may a bit slow, we may need to use a map instead of a dumb list
if (g_Shaders.Shader_ForName( pShader->getName() ) != NULL)
{
Sys_Printf( "WARNING: shader %s is already in memory, definition in %s ignored.\n", pShader->getName(), filename );
delete pShader;
}
else
{
pShader->IncRef();
g_Shaders.Add( (LPVOID)pShader );
int n = g_PrefsDlg.m_nShader;
if ((g_PrefsDlg.m_nShader == CPrefsDlg::SHADER_ALL) || (g_PrefsDlg.m_nShader == CPrefsDlg::SHADER_COMMON && strstr(pShader->getName(), "common" )))
// load the qtexture and display in tex wnd
pShader->Activate();
}
}
else
{
Sys_Printf("Error parsing shader %s\n", pShader->getName());
delete pShader;
}
}
free (pBuff);
}
else
{
Sys_Printf("Unabled to read shaderfile %s\n", filename);
}
}
示例3: QERApp_LoadShaderFile
void WINAPI QERApp_LoadShaderFile (const char *filename)
{
char *pBuff;
int nSize = vfsLoadFile (filename, reinterpret_cast < void **>(&pBuff), 0);
if (nSize > 0)
{
Sys_Printf ("Parsing shaderfile %s\n", filename);
g_ScripLibTable.m_pfnStartTokenParsing (pBuff);
while (g_ScripLibTable.m_pfnGetToken (true))
{
// first token should be the path + name.. (from base)
CShader *pShader = new CShader ();
// we want the relative filename only, it's easier for later lookup .. see QERApp_ReloadShaderFile
char cTmp[1024];
g_FuncTable.m_pfnQE_ConvertDOSToUnixName (cTmp, filename);
// given the vfs, we should not store the full path
//pShader->setShaderFileName( filename + strlen(ValueForKey(g_qeglobals.d_project_entity, "basepath")));
pShader->setShaderFileName (filename);
if (pShader->Parse ())
{
// do we already have this shader?
//++timo NOTE: this may a bit slow, we may need to use a map instead of a dumb list
if (g_Shaders.Shader_ForName (pShader->getName ()) != NULL)
{
#ifdef _DEBUG
Sys_Printf ("WARNING: shader %s is already in memory, definition in %s ignored.\n",
pShader->getName (), filename);
#endif
delete pShader;
}
else
{
pShader->IncRef ();
g_Shaders.Add ((void *) pShader);
}
}
else
{
Sys_Printf ("Error parsing shader %s\n", pShader->getName ());
delete pShader;
}
}
vfsFreeFile (pBuff);
}
else
{
Sys_Printf ("Unable to read shaderfile %s\n", filename);
}
}
示例4: Shader_ForName
// NOTE: case sensitivity
// although we store shader names with case information, Radiant does case insensitive searches
// (we assume there's no case conflict with the names)
CShader* CShaderArray::Shader_ForName( const char * name) const
{
int i;
for ( i = 0; i < CPtrArray::GetSize(); i++ )
{
CShader *pShader = static_cast<CShader*>(CPtrArray::GetAt(i));
if (_stricmp(pShader->getName(), name) == 0)
return pShader;
}
return NULL;
}
示例5:
IShader *WINAPI QERApp_CreateShader_ForTextureName( const char *name ){
CShader *pShader;
pShader = new CShader;
// CreateDefault expects a texture / shader name relative to the "textures" directory
// (cause shader names are reletive to "textures/")
pShader->CreateDefault( name );
// hook it into the shader list
g_Shaders.Add( (void *) pShader );
pShader->IncRef();
// if it can't find the texture, SHADER_NOT_FOUND will be used
// Hydra: display an error message, so the user can quickly find a list of missing
// textures by looking at the console.
if ( !pShader->Activate() ) {
Sys_Printf( "WARNING: Activate shader failed for %s\n",pShader->getName() );
}
pShader->SetDisplayed( true );
return pShader;
}
示例6: SortShaders
void CShaderArray::SortShaders()
{
CPtrArray aux;
int i,icount;
int j,jcount;
CShader *pSort;
const char *sSort;
// dumb sort .. would it ever grow big enough so we would have to do something clever? noooo
icount = CPtrArray::GetSize();
for( i = 0; i < icount ; i++ )
{
pSort = static_cast<CShader *>(GetAt(i));
sSort = pSort->getName();
jcount = aux.GetSize();
for( j = 0; j < jcount ; j++ )
{
if (strcmp(sSort, static_cast<CShader *>(aux.GetAt(j))->getName()) < 0)
break;
}
aux.InsertAt(j, pSort);
}
CPtrArray::RemoveAll();
CPtrArray::InsertAt(0, &aux);
}
示例7: qDebug
//-----------------------------------------------------------------------------------------
TestTransformation::TestTransformation()
: m_bPressed(false)
, m_bTouch(false)
, m_StartPan(-1, -1)
, m_LastPan(-1, -1)
{
// On cr�e une camera
CCamera* pCamera = m_pSceneManager->createCamera();
m_vNewEyePosition = QVector3D(8., 8., 4.);
pCamera->setEyePosition(m_vNewEyePosition);
pCamera->setCenter(QVector3D(0., 0., 0.));
qDebug() << "Create View";
m_pView = createWidget3D(pCamera);
m_pView->setAttribute(Qt::WA_AcceptTouchEvents);
qDebug() << "End create View";
// On cr�e un noeud afin d'y placer une lumi�re
CSceneNode* pRootNode = getSceneManager()->getRootNode();
// On cr�e une lumi�re diffuse bleue
CLight* pLight = getSceneManager()->createLight();
pLight->setDiffuseColor(1.0, 1.0, 1.0);
pLight->setAmbientColor(1.0, 1.0, 1.0);
pLight->setDirection(QVector3D(-1, 0, 0));
pLight->setSpecularColor(1.0f, 1.0f, 1.0f);
// On l'associe au noeud
pRootNode->addItem(pLight);
// SkyBox
CSkyBox* pSkyBoxMesh = CMeshManager::getInstance().createCustomMesh<CSkyBox>("CSkyBox", "SkyBoxMesh");
CMeshInstance* pSkyBox = getSceneManager()->createMeshInstance(pSkyBoxMesh, "SkyBox");
pSkyBox->setSelectable(false);
CSceneNode* pSkyBoxNode = pRootNode->createChild("SkyBoxNode");
pSkyBoxNode->scale(400.);
pSkyBoxNode->addItem(pSkyBox);
CMaterial* pSkyBoxMat = CMaterialManager::getInstance().createMaterial("SkyBoxMaterial");
pSkyBox->setMaterialName(pSkyBoxMat->getName());
QStringList fileNames;
fileNames << "://Resources/xpos.png" << "://Resources/xneg.png" << "://Resources/ypos.png"
<< "://Resources/yneg.png" << "://Resources/zpos.png" << "://Resources/zneg.png";
ATexture* pSkyBoxTexture = CTextureManager::getInstance().createTextureCube("SkyBoxTexCube", fileNames);
pSkyBoxMat->addTexture(pSkyBoxTexture, eDiffuse);
#ifdef EMBEDDED_TARGET
CShader* pShader = CShaderManager::getInstance().createShader(
"SkyBoxShader",
"://Resources/skyboxES.vertex.glsl",
"",
"://Resources/skyboxES.fragment.glsl");
#else
CShader* pShader = CShaderManager::getInstance().createShader(
"SkyBoxShader",
"://Resources/skybox.vertex.glsl",
"",
"://Resources/skybox.fragment.glsl");
#endif
pSkyBoxMat->getRenderPass(0)->setShaderName(pShader->getName());
pSkyBoxMat->getRenderPass(0)->renderStates().setFaceCulling(CFaceCulling(false));
// Particules
CBillboard* pBillboard = getSceneManager()->createBillboard();
QVector<QVector3D> pos;
for (int i = 0; i < 1000; ++i)
pos << QVector3D(
Math::randDouble(-200., +200.),
Math::randDouble(-200., +200.),
Math::randDouble(-200., +200.));
pBillboard->addPositions(pos);
CMaterial* pBillboardMat = CMaterialManager::getInstance().createMaterial("BillboardMaterial");
pBillboardMat->getRenderPass(0)->renderStates().setFaceCulling(CFaceCulling(false));
CBlending blending;
blending.setEnabled(true);
blending.setBlendEquation(eAdd, eAdd);
blending.setBlendSeparateFunction(Source::eSourceAlpha, Destination::eOneMinusSourceAlpha, Source::eOne, Destination::eZero);
pBillboardMat->getRenderPass(0)->renderStates().setBlending(blending);
ATexture* pBillboardTexture = CTextureManager::getInstance().createTexture2D("BillBoardTex", "://Resources/particle.png");
pBillboardMat->addTexture(pBillboardTexture, eDiffuse);
CShader* pBillboardShader = CShaderManager::getInstance().createShader("BillboardShader",
"://Resources/billboard.vertex.glsl",
"://Resources/billboard.geometry.glsl",
"://Resources/billboard.fragment.glsl");
pBillboardMat->getRenderPass(0)->setShaderName(pBillboardShader->getName());
pBillboard->setMaterialName(pBillboardMat->getName());
pBillboardShader->setUniformValue("halfSize", 1.);
//.........这里部分代码省略.........