Cleanup style

--HG--
branch : opengl3
hg/feature/opengl3
kaetemi 11 years ago
parent be050f3927
commit 99f37eb90c

@ -37,14 +37,14 @@ namespace NL3D
void reset();
/// Generate Vertex Shader based on the data provided in material, descriptor and vertexbuffer flags
void generateVS( std::string &vs );
void generateVS(std::string &vs);
/// Generate Pixel Shader based on the data provided in material, descriptor and vertexbuffer flags
void generatePS( std::string &ps );
void generatePS(std::string &ps);
void setMaterial( CMaterial *mat ){ material = mat; }
void setVBFormat( uint16 format ){ vbFormat = format; }
void setShaderDesc( CShaderDesc *d ){ desc = d; }
void setMaterial(CMaterial *mat) { material = mat; }
void setVBFormat(uint16 format) { vbFormat = format; }
void setShaderDesc(CShaderDesc *d) { desc = d; }
private:
/// Adds ambient color constant uniform declaration to the program
@ -72,7 +72,7 @@ namespace NL3D
/// Adds the alpha threshold uniform to the program
void addAlphaTreshold();
/// Adds the actual alpha test to the program ( discards fragment if below threshold )
/// Adds the actual alpha test to the program (discards fragment if below threshold)
void addAlphaTest();
//////////////////////////////////////////////////////////////
@ -105,10 +105,10 @@ namespace NL3D
void addLightInsFS();
/// Adds the directional light Vertex Shader function, num is the light number
void addDirectionalFunctionVS( int num );
void addDirectionalFunctionVS(int num);
/// Adds the point-light Vertex Shader function, num is the light number
void addPointLightFunctionVS( int num );
void addPointLightFunctionVS(int num);
/// Adds the appropriate light functions to the Vertex Shader
void addLightsFunctionVS();
@ -116,10 +116,10 @@ namespace NL3D
/// Adds the appropriate light functions to the Pixel Shader
void addLightsFunctionFS();
/// Adds the lights to the Vertex Shader ( calls the appropriate functions )
/// Adds the lights to the Vertex Shader (calls the appropriate functions)
void addLightsVS();
/// Adds the lights to the Fragment Shader ( calls the appropriate functions )
/// Adds the lights to the Fragment Shader (calls the appropriate functions)
void addLightsFS();
//////////////////////////////////////////////////////////////
@ -147,9 +147,9 @@ namespace NL3D
void generateTexEnv();
void generateTexEnvRGB( unsigned int stage );
void generateTexEnvAlpha( unsigned int stage );
void buildArg( unsigned int stage, unsigned int n, bool alpha, std::string &arg );
void generateTexEnvRGB(unsigned int stage);
void generateTexEnvAlpha(unsigned int stage);
void buildArg(unsigned int stage, unsigned int n, bool alpha, std::string &arg);
void generateLightMapPS();
void generateSpecularPS();

@ -256,7 +256,7 @@ CDriverGL3::CDriverGL3()
// Compute the Flag which say if one texture has been changed in CMaterial.
_MaterialAllTextureTouchedFlag= 0;
for(i=0; i < IDRV_MAT_MAXTEXTURES; i++)
for (i=0; i < IDRV_MAT_MAXTEXTURES; i++)
{
_MaterialAllTextureTouchedFlag|= IDRV_TOUCHED_TEX[i];
#ifdef GL_NONE
@ -266,7 +266,7 @@ CDriverGL3::CDriverGL3()
#endif
}
for( i = 0; i < IDRV_MAT_MAXTEXTURES; i++ )
for (i = 0; i < IDRV_MAT_MAXTEXTURES; i++)
_UserTexMat[ i ].identity();
_UserTexMatEnabled = 0;
@ -318,8 +318,8 @@ CDriverGL3::CDriverGL3()
usrShaderManager = new CUsrShaderManager();
CUsrShaderLoader loader;
loader.setManager( usrShaderManager );
loader.loadShaders( "./shaders" );
loader.setManager(usrShaderManager);
loader.loadShaders("./shaders");
}
// ***************************************************************************
@ -333,11 +333,11 @@ CDriverGL3::~CDriverGL3()
currentProgram.pp = NULL;
currentProgram.gp = NULL;
if( currentProgram.dynmatVP != NULL )
if (currentProgram.dynmatVP != NULL)
delete currentProgram.dynmatVP;
currentProgram.dynmatVP = NULL;
if( currentProgram.dynmatPP != NULL )
if (currentProgram.dynmatPP != NULL)
delete currentProgram.dynmatPP;
currentProgram.dynmatPP = NULL;
@ -362,7 +362,7 @@ bool CDriverGL3::setupDisplay()
registerGlExtensions (_Extensions);
vector<string> lines;
explode(_Extensions.toString(), string("\n"), lines);
for(uint i = 0; i < lines.size(); i++)
for (uint i = 0; i < lines.size(); i++)
nlinfo("3D: %s", lines[i].c_str());
#if defined(NL_OS_WINDOWS)
@ -374,13 +374,13 @@ bool CDriverGL3::setupDisplay()
// Check required extensions!!
// ARBMultiTexture is a OpenGL 1.2 required extension.
if(!_Extensions.ARBMultiTexture)
if (!_Extensions.ARBMultiTexture)
{
nlwarning("Missing Required GL extension: GL_ARB_multitexture. Update your driver");
throw EBadDisplay("Missing Required GL extension: GL_ARB_multitexture. Update your driver");
}
if(!_Extensions.EXTTextureEnvCombine)
if (!_Extensions.EXTTextureEnvCombine)
{
nlwarning("Missing Important GL extension: GL_EXT_texture_env_combine => All envcombine are setup to GL_MODULATE!!!");
}
@ -394,7 +394,7 @@ bool CDriverGL3::setupDisplay()
// All User Light are disabled by Default
uint i;
for(i=0;i<MaxLight;i++)
for (i=0;i<MaxLight;i++)
_UserLightEnable[i]= false;
// init _DriverGLStates
@ -423,7 +423,7 @@ bool CDriverGL3::setupDisplay()
_PZBCameraPos= CVector::Null;
// Be always in EXTSeparateSpecularColor.
if(_Extensions.EXTSeparateSpecularColor)
if (_Extensions.EXTSeparateSpecularColor)
{
}
@ -447,7 +447,7 @@ bool CDriverGL3::setupDisplay()
// Activate the default texture environnments for all stages.
//===========================================================
for(uint stage=0;stage<inlGetNumTextStages(); stage++)
for (uint stage=0;stage<inlGetNumTextStages(); stage++)
{
// init no texture.
_CurrentTexture[stage]= NULL;
@ -496,10 +496,10 @@ bool CDriverGL3::setupDisplay()
// Reset the vbl interval
setSwapVBLInterval(_Interval);
if( !initPipeline() )
if (!initPipeline())
{
nlinfo( "Failed to create Pipeline Object" );
nlassert( false );
nlinfo("Failed to create Pipeline Object");
nlassert(false);
}
return true;
@ -535,9 +535,9 @@ bool CDriverGL3::isTextureRectangle(ITexture * tex) const
// ***************************************************************************
bool CDriverGL3::activeFrameBufferObject(ITexture * tex)
{
if(supportFrameBufferObject()/* && supportPackedDepthStencil()*/)
if (supportFrameBufferObject()/* && supportPackedDepthStencil()*/)
{
if(tex)
if (tex)
{
CTextureDrvInfosGL3* gltext = (CTextureDrvInfosGL3*)(ITextureDrvInfos*)(tex->TextureDrvShare->DrvTexture);
return gltext->activeFrameBufferObject(tex);
@ -608,7 +608,7 @@ bool CDriverGL3::clearStencilBuffer(float stencilval)
// --------------------------------------------------
void CDriverGL3::setColorMask (bool bRed, bool bGreen, bool bBlue, bool bAlpha)
{
H_AUTO_OGL(CDriverGL3_setColorMask )
H_AUTO_OGL(CDriverGL3_setColorMask)
glColorMask (bRed, bGreen, bBlue, bAlpha);
}
@ -640,7 +640,7 @@ bool CDriverGL3::swapBuffers()
#elif defined(NL_OS_MAC)
// TODO: maybe do this somewhere else?
if(_DestroyWindow)
if (_DestroyWindow)
{
[_autoreleasePool release];
_autoreleasePool = [[NSAutoreleasePool alloc] init];
@ -657,8 +657,8 @@ bool CDriverGL3::swapBuffers()
// Activate the default texture environnments for all stages.
//===========================================================
// This is not a requirement, but it ensure a more stable state each frame.
// (well, maybe the good reason is "it hides much more the bugs" :o) ).
for(uint stage=0;stage<inlGetNumTextStages(); stage++)
// (well, maybe the good reason is "it hides much more the bugs" :o)).
for (uint stage=0;stage<inlGetNumTextStages(); stage++)
{
// init no texture.
_CurrentTexture[stage]= NULL;
@ -689,7 +689,7 @@ bool CDriverGL3::swapBuffers()
_TextureUsed.clear();
// Reset Profile VBHardLock
if(_VBHardProfiling)
if (_VBHardProfiling)
{
_CurVBHardLockCount= 0;
_NumVBHardProfileFrame++;
@ -749,7 +749,7 @@ bool CDriverGL3::release()
// --------------------------------------------------
void CDriverGL3::setupViewport (const class CViewport& viewport)
{
H_AUTO_OGL(CDriverGL3_setupViewport )
H_AUTO_OGL(CDriverGL3_setupViewport)
if (_win == EmptyWindow) return;
@ -772,9 +772,9 @@ void CDriverGL3::setupViewport (const class CViewport& viewport)
{
float factorX = 1;
float factorY = 1;
if(clientWidth)
if (clientWidth)
factorX = (float)_TextureTarget->getWidth() / (float)clientWidth;
if(clientHeight)
if (clientHeight)
factorY = (float)_TextureTarget->getHeight() / (float)clientHeight;
x *= factorX;
y *= factorY;
@ -804,7 +804,7 @@ void CDriverGL3::getViewport(CViewport &viewport)
// --------------------------------------------------
void CDriverGL3::setupScissor (const class CScissor& scissor)
{
H_AUTO_OGL(CDriverGL3_setupScissor )
H_AUTO_OGL(CDriverGL3_setupScissor)
if (_win == EmptyWindow) return;
@ -826,9 +826,9 @@ void CDriverGL3::setupScissor (const class CScissor& scissor)
{
float factorX = 1;
float factorY = 1;
if(clientWidth)
if (clientWidth)
factorX = (float) _TextureTarget->getWidth() / (float)clientWidth;
if(clientHeight)
if (clientHeight)
factorY = (float) _TextureTarget->getHeight() / (float)clientHeight;
x *= factorX;
y *= factorY;
@ -837,7 +837,7 @@ void CDriverGL3::setupScissor (const class CScissor& scissor)
}
// enable or disable Scissor, but AFTER textureTarget adjust
if(x==0.f && y==0.f && width>=1.f && height>=1.f)
if (x==0.f && y==0.f && width>=1.f && height>=1.f)
{
glDisable(GL_SCISSOR_TEST);
}
@ -849,9 +849,9 @@ void CDriverGL3::setupScissor (const class CScissor& scissor)
sint iy0=(sint)floor((float)clientHeight* y + 0.5f);
clamp (iy0, 0, (sint)clientHeight);
sint ix1=(sint)floor((float)clientWidth * (x+width) + 0.5f );
sint ix1=(sint)floor((float)clientWidth * (x+width) + 0.5f);
clamp (ix1, 0, (sint)clientWidth);
sint iy1=(sint)floor((float)clientHeight* (y+height) + 0.5f );
sint iy1=(sint)floor((float)clientHeight* (y+height) + 0.5f);
clamp (iy1, 0, (sint)clientHeight);
sint iwidth= ix1 - ix0;
@ -866,7 +866,7 @@ void CDriverGL3::setupScissor (const class CScissor& scissor)
uint8 CDriverGL3::getBitPerPixel ()
{
H_AUTO_OGL(CDriverGL3_getBitPerPixel )
H_AUTO_OGL(CDriverGL3_getBitPerPixel)
return _CurrentMode.Depth;
}
@ -906,10 +906,10 @@ bool CDriverGL3::clipRect(NLMISC::CRect &rect)
void CDriverGL3::getBufferPart (CBitmap &bitmap, NLMISC::CRect &rect)
{
H_AUTO_OGL(CDriverGL3_getBufferPart )
H_AUTO_OGL(CDriverGL3_getBufferPart)
bitmap.reset();
if(clipRect(rect))
if (clipRect(rect))
{
bitmap.resize(rect.Width, rect.Height, CBitmap::RGBA);
glReadPixels (rect.X, rect.Y, rect.Width, rect.Height, GL_RGBA, GL_UNSIGNED_BYTE, bitmap.getPixels ().getPtr());
@ -918,10 +918,10 @@ void CDriverGL3::getBufferPart (CBitmap &bitmap, NLMISC::CRect &rect)
void CDriverGL3::getZBufferPart (std::vector<float> &zbuffer, NLMISC::CRect &rect)
{
H_AUTO_OGL(CDriverGL3_getZBufferPart )
H_AUTO_OGL(CDriverGL3_getZBufferPart)
zbuffer.clear();
if(clipRect(rect))
if (clipRect(rect))
{
zbuffer.resize(rect.Width*rect.Height);
@ -933,7 +933,7 @@ void CDriverGL3::getZBufferPart (std::vector<float> &zbuffer, NLMISC::CRect &re
void CDriverGL3::getZBuffer (std::vector<float> &zbuffer)
{
H_AUTO_OGL(CDriverGL3_getZBuffer )
H_AUTO_OGL(CDriverGL3_getZBuffer)
CRect rect(0,0);
getWindowSize(rect.Width, rect.Height);
getZBufferPart(zbuffer, rect);
@ -941,7 +941,7 @@ void CDriverGL3::getZBuffer (std::vector<float> &zbuffer)
void CDriverGL3::getBuffer (CBitmap &bitmap)
{
H_AUTO_OGL(CDriverGL3_getBuffer )
H_AUTO_OGL(CDriverGL3_getBuffer)
CRect rect(0,0);
getWindowSize(rect.Width, rect.Height);
getBufferPart(bitmap, rect);
@ -950,14 +950,14 @@ void CDriverGL3::getBuffer (CBitmap &bitmap)
bool CDriverGL3::fillBuffer (CBitmap &bitmap)
{
H_AUTO_OGL(CDriverGL3_fillBuffer )
H_AUTO_OGL(CDriverGL3_fillBuffer)
CRect rect(0,0);
getWindowSize(rect.Width, rect.Height);
if( rect.Width!=bitmap.getWidth() || rect.Height!=bitmap.getHeight() || bitmap.getPixelFormat()!=CBitmap::RGBA )
if (rect.Width!=bitmap.getWidth() || rect.Height!=bitmap.getHeight() || bitmap.getPixelFormat()!=CBitmap::RGBA)
return false;
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glDrawPixels (rect.Width, rect.Height, GL_RGBA, GL_UNSIGNED_BYTE, &(bitmap.getPixels()[0]) );
glDrawPixels (rect.Width, rect.Height, GL_RGBA, GL_UNSIGNED_BYTE, &(bitmap.getPixels()[0]));
return true;
}
@ -987,13 +987,13 @@ void CDriverGL3::copyFrameBufferToTexture(ITexture *tex,
// setup texture mode, after activeTextureARB()
CDriverGLStates3::TTextureMode textureMode= CDriverGLStates3::Texture2D;
if(gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV)
if (gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV)
textureMode = CDriverGLStates3::TextureRect;
_DriverGLStates.setTextureMode(textureMode);
if (tex->isTextureCube())
{
if(_Extensions.ARBTextureCubeMap)
if (_Extensions.ARBTextureCubeMap)
{
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID);
glCopyTexSubImage2D(NLCubeFaceToGLCubeFace[cubeFace], level, offsetx, offsety, x, y, width, height);
@ -1015,7 +1015,7 @@ void CDriverGL3::copyFrameBufferToTexture(ITexture *tex,
// ***************************************************************************
void CDriverGL3::setPolygonMode (TPolygonMode mode)
{
H_AUTO_OGL(CDriverGL3_setPolygonMode )
H_AUTO_OGL(CDriverGL3_setPolygonMode)
IDriver::setPolygonMode (mode);
// Set the polygon mode
@ -1126,7 +1126,7 @@ uint32 CDriverGL3::profileSetupedModelMatrix() const
// ***************************************************************************
void CDriverGL3::enableUsedTextureMemorySum (bool enable)
{
H_AUTO_OGL(CDriverGL3_enableUsedTextureMemorySum )
H_AUTO_OGL(CDriverGL3_enableUsedTextureMemorySum)
if (enable)
nlinfo ("3D: PERFORMANCE INFO: enableUsedTextureMemorySum has been set to true in CDriverGL");
@ -1169,7 +1169,7 @@ void CDriverGL3::setMatrix2DForTextureOffsetAddrMode(const uint stage, const flo
if (!supportTextureShaders()) return;
//nlassert(supportTextureShaders());
nlassert(stage < inlGetNumTextStages() );
nlassert(stage < inlGetNumTextStages());
_DriverGLStates.activeTextureARB(stage);
//glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, mat);
@ -1223,7 +1223,7 @@ void CDriverGL3::setBlendConstantColor(NLMISC::CRGBA col)
_CurrentBlendConstantColor= col;
// update GL
if(!_Extensions.EXTBlendColor)
if (!_Extensions.EXTBlendColor)
return;
static const float OO255= 1.0f/255;
@ -1307,7 +1307,7 @@ void CDriverGL3::setSwapVBLInterval(uint interval)
bool res = true;
#if defined(NL_OS_WINDOWS)
if(_Extensions.WGLEXTSwapControl)
if (_Extensions.WGLEXTSwapControl)
{
res = nwglSwapIntervalEXT(_Interval) == TRUE;
}
@ -1343,7 +1343,7 @@ uint CDriverGL3::getSwapVBLInterval()
H_AUTO_OGL(CDriverGL3_getSwapVBLInterval)
#if defined(NL_OS_WINDOWS)
if(_Extensions.WGLEXTSwapControl)
if (_Extensions.WGLEXTSwapControl)
{
return nwglGetSwapIntervalEXT();
}
@ -1371,7 +1371,7 @@ void CDriverGL3::enablePolygonSmoothing(bool smooth)
{
H_AUTO_OGL(CDriverGL3_enablePolygonSmoothing);
if(smooth)
if (smooth)
glEnable(GL_POLYGON_SMOOTH);
else
glDisable(GL_POLYGON_SMOOTH);
@ -1390,7 +1390,7 @@ bool CDriverGL3::isPolygonSmoothingEnabled() const
// ***************************************************************************
void CDriverGL3::startProfileVBHardLock()
{
if(_VBHardProfiling)
if (_VBHardProfiling)
return;
// start
@ -1404,20 +1404,20 @@ void CDriverGL3::startProfileVBHardLock()
// ***************************************************************************
void CDriverGL3::endProfileVBHardLock(vector<std::string> &result)
{
if(!_VBHardProfiling)
if (!_VBHardProfiling)
return;
// Fill infos.
result.clear();
result.resize(_VBHardProfiles.size() + 1);
float total= 0;
for(uint i=0;i<_VBHardProfiles.size();i++)
for (uint i=0;i<_VBHardProfiles.size();i++)
{
const uint tmpSize= 256;
char tmp[tmpSize];
CVBHardProfile &vbProf= _VBHardProfiles[i];
const char *vbName;
if(vbProf.VBHard && !vbProf.VBHard->getName().empty())
if (vbProf.VBHard && !vbProf.VBHard->getName().empty())
{
vbName= vbProf.VBHard->getName().c_str();
}
@ -1427,7 +1427,7 @@ void CDriverGL3::endProfileVBHardLock(vector<std::string> &result)
}
// Display in ms.
float timeLock= (float)CTime::ticksToSecond(vbProf.AccumTime)*1000 / max(_NumVBHardProfileFrame,1U);
smprintf(tmp, tmpSize, "%16s%c: %2.3f ms", vbName, vbProf.Change?'*':' ', timeLock );
smprintf(tmp, tmpSize, "%16s%c: %2.3f ms", vbName, vbProf.Change?'*':' ', timeLock);
total+= timeLock;
result[i]= tmp;
@ -1443,7 +1443,7 @@ void CDriverGL3::endProfileVBHardLock(vector<std::string> &result)
void CDriverGL3::appendVBHardLockProfile(NLMISC::TTicks time, CVertexBuffer *vb)
{
// must allocate a new place?
if(_CurVBHardLockCount>=_VBHardProfiles.size())
if (_CurVBHardLockCount>=_VBHardProfiles.size())
{
_VBHardProfiles.resize(_VBHardProfiles.size()+1);
// set the original VBHard
@ -1453,7 +1453,7 @@ void CDriverGL3::appendVBHardLockProfile(NLMISC::TTicks time, CVertexBuffer *vb)
// Accumulate.
_VBHardProfiles[_CurVBHardLockCount].AccumTime+= time;
// if change of VBHard for this chrono place
if(_VBHardProfiles[_CurVBHardLockCount].VBHard != vb)
if (_VBHardProfiles[_CurVBHardLockCount].VBHard != vb)
{
// flag, and set new
_VBHardProfiles[_CurVBHardLockCount].VBHard= vb;
@ -1488,32 +1488,32 @@ void CDriverGL3::profileVBHardAllocation(std::vector<std::string> &result)
result.clear();
result.reserve(1000);
result.push_back(toString("Memory Allocated: %4d Ko in AGP / %4d Ko in VRAM",
getAvailableVertexAGPMemory()/1000, getAvailableVertexVRAMMemory()/1000 ));
getAvailableVertexAGPMemory()/1000, getAvailableVertexVRAMMemory()/1000));
result.push_back(toString("Num VBHard: %d", _VertexBufferHardSet.Set.size()));
uint totalMemUsed= 0;
set<IVertexBufferHardGL*>::iterator it;
for(it= _VertexBufferHardSet.Set.begin(); it!=_VertexBufferHardSet.Set.end(); it++)
for (it= _VertexBufferHardSet.Set.begin(); it!=_VertexBufferHardSet.Set.end(); it++)
{
IVertexBufferHardGL *vbHard= *it;
if(vbHard)
if (vbHard)
{
uint vSize= vbHard->VB->getVertexSize();
uint numVerts= vbHard->VB->getNumVertices();
totalMemUsed+= vSize*numVerts;
}
}
result.push_back(toString("Mem Used: %4d Ko", totalMemUsed/1000) );
result.push_back(toString("Mem Used: %4d Ko", totalMemUsed/1000));
for(it= _VertexBufferHardSet.Set.begin(); it!=_VertexBufferHardSet.Set.end(); it++)
for (it= _VertexBufferHardSet.Set.begin(); it!=_VertexBufferHardSet.Set.end(); it++)
{
IVertexBufferHardGL *vbHard= *it;
if(vbHard)
if (vbHard)
{
uint vSize= vbHard->VB->getVertexSize();
uint numVerts= vbHard->VB->getNumVertices();
result.push_back(toString(" %16s: %4d ko (format: %d / numVerts: %d)",
vbHard->VB->getName().c_str(), vSize*numVerts/1000, vSize, numVerts ));
vbHard->VB->getName().c_str(), vSize*numVerts/1000, vSize, numVerts));
}
}
}
@ -1618,7 +1618,7 @@ void CDriverGL3::checkTextureOn() const
// tmp for debug
CDriverGLStates3 &dgs = const_cast<CDriverGLStates3 &>(_DriverGLStates);
uint currTexStage = dgs.getActiveTextureARB();
for(uint k = 0; k < this->getNbTextureStages(); ++k)
for (uint k = 0; k < this->getNbTextureStages(); ++k)
{
dgs.activeTextureARB(k);
GLboolean flag2D;
@ -1928,12 +1928,12 @@ void CDriverGL3::reloadUserShaders()
{
usrShaderManager->clear();
NL3D::CUsrShaderLoader loader;
loader.setManager( usrShaderManager );
loader.loadShaders( "./shaders" );
loader.setManager(usrShaderManager);
loader.loadShaders("./shaders");
}
CVertexProgramDrvInfosGL3::CVertexProgramDrvInfosGL3( CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it ) :
IProgramDrvInfos( drv, it )
CVertexProgramDrvInfosGL3::CVertexProgramDrvInfosGL3(CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it) :
IProgramDrvInfos(drv, it)
{
programId = 0;
}
@ -1943,17 +1943,17 @@ CVertexProgramDrvInfosGL3::~CVertexProgramDrvInfosGL3()
programId = 0;
}
uint CVertexProgramDrvInfosGL3::getUniformIndex( const char *name ) const
uint CVertexProgramDrvInfosGL3::getUniformIndex(const char *name) const
{
int idx = nglGetUniformLocation( programId, name );
if( idx == -1 )
int idx = nglGetUniformLocation(programId, name);
if (idx == -1)
return ~0;
else
return idx;
}
CPixelProgramDrvInfosGL3::CPixelProgramDrvInfosGL3( CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it ) :
IProgramDrvInfos( drv, it )
CPixelProgramDrvInfosGL3::CPixelProgramDrvInfosGL3(CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it) :
IProgramDrvInfos(drv, it)
{
programId = 0;
}
@ -1963,10 +1963,10 @@ CPixelProgramDrvInfosGL3::~CPixelProgramDrvInfosGL3()
programId = 0;
}
uint CPixelProgramDrvInfosGL3::getUniformIndex( const char *name ) const
uint CPixelProgramDrvInfosGL3::getUniformIndex(const char *name) const
{
int idx = nglGetUniformLocation( programId, name );
if( idx == -1 )
int idx = nglGetUniformLocation(programId, name);
if (idx == -1)
return ~0;
else
return idx;

@ -314,10 +314,10 @@ public:
virtual bool init (uint windowIcon = 0, emptyProc exitFunc = 0);
virtual void disableHardwareVertexProgram(){}
virtual void disableHardwarePixelProgram(){}
virtual void disableHardwareVertexArrayAGP(){}
virtual void disableHardwareTextureShader(){}
virtual void disableHardwareVertexProgram() {}
virtual void disableHardwarePixelProgram() {}
virtual void disableHardwareVertexArrayAGP() {}
virtual void disableHardwareTextureShader() {}
virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay);
virtual bool setMode(const GfxMode& mode);
@ -346,8 +346,8 @@ public:
virtual bool copyTextToClipboard(const ucstring &text);
virtual bool pasteTextFromClipboard(ucstring &text);
uint32 getAvailableVertexAGPMemory (){ return uint32( -1 ); };
uint32 getAvailableVertexVRAMMemory (){ return uint32( -1 ); };
uint32 getAvailableVertexAGPMemory () { return uint32(-1); };
uint32 getAvailableVertexVRAMMemory () { return uint32(-1); };
virtual emptyProc getWindowProc();
@ -400,7 +400,7 @@ public:
bool setupProgram(CMaterial& mat);
bool setupDynMatProgram(CMaterial& mat, uint pass);
void setupUniforms();
void setupUniforms( TProgram program );
void setupUniforms(TProgram program);
virtual void startSpecularBatch();
virtual void endSpecularBatch();
@ -422,7 +422,7 @@ public:
{
_ForceNormalize= normalize;
// if ForceNormalize, must enable GLNormalize now.
if(normalize)
if (normalize)
enableGlNormalize(true);
}
@ -452,7 +452,7 @@ public:
virtual bool activeIndexBuffer(CIndexBuffer& IB);
virtual void mapTextureStageToUV(uint stage, uint uv){}
virtual void mapTextureStageToUV(uint stage, uint uv) {}
virtual bool renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines);
virtual bool renderTriangles(CMaterial& Mat, uint32 firstIndex, uint32 ntris);
@ -595,7 +595,7 @@ public:
virtual void enableLight (uint8 num, bool enable=true);
virtual bool isLightEnabled (uint8 num );
virtual bool isLightEnabled (uint8 num);
virtual void setPerPixelLightingLight(CRGBA diffuse, CRGBA specular, float shininess);
@ -1074,7 +1074,7 @@ private:
// @}
// Sets up a rendering pass from the dynamic material
bool setupDynMatPass( uint pass );
bool setupDynMatPass(uint pass);
/// LastVB for UV setup.
CVertexBufferInfo _LastVB;
@ -1168,10 +1168,10 @@ private:
/// Test/activate normalisation of normal.
void enableGlNormalize(bool normalize)
{
if(_CurrentGlNormalize!=normalize)
if (_CurrentGlNormalize!=normalize)
{
_CurrentGlNormalize= normalize;
if(normalize)
if (normalize)
glEnable(GL_NORMALIZE);
else
glDisable(GL_NORMALIZE);
@ -1265,14 +1265,14 @@ private:
bool supportGeometryProgram(CGeometryProgram::TProfile profile) const{ return false; }
bool compileGeometryProgram(CGeometryProgram *program){ return false; }
bool compileGeometryProgram(CGeometryProgram *program) { return false; }
bool activeGeometryProgram(CGeometryProgram *program){ return false; }
bool activeGeometryProgram(CGeometryProgram *program) { return false; }
uint32 getProgramId( TProgram program ) const;
IProgram* getProgram( TProgram program ) const;
uint32 getProgramId(TProgram program) const;
IProgram* getProgram(TProgram program) const;
int getUniformLocation( TProgram program, const char *name );
int getUniformLocation(TProgram program, const char *name);
void setUniform1f(TProgram program, uint index, float f0);
void setUniform2f(TProgram program, uint index, float f0, float f1);
void setUniform3f(TProgram program, uint index, float f0, float f1, float f2);
@ -1288,9 +1288,9 @@ private:
void setUniform3f(TProgram program, uint index, const NLMISC::CVector& v);
void setUniform4f(TProgram program, uint index, const NLMISC::CVector& v, float f3);
void setUniform4f(TProgram program, uint index, const NLMISC::CRGBAF& rgba);
void setUniform3x3f(TProgram program, uint index, const float *src );
void setUniform3x3f(TProgram program, uint index, const float *src);
void setUniform4x4f(TProgram program, uint index, const NLMISC::CMatrix& m);
void setUniform4x4f(TProgram program, uint index, const float *src );
void setUniform4x4f(TProgram program, uint index, const float *src);
void setUniform4fv(TProgram program, uint index, size_t num, const float *src);
void setUniform4iv(TProgram program, uint index, size_t num, const sint32 *src);
void setUniform4uiv(TProgram program, uint index, size_t num, const uint32 *src);
@ -1298,9 +1298,9 @@ private:
void setUniformMatrix(TProgram program, uint index, TMatrix matrix, TTransform transform);
void setUniformFog(TProgram program, uint index);
bool isUniformProgramState(){ return false; }
bool isUniformProgramState() { return false; }
void enableVertexProgramDoubleSidedColor(bool doubleSided){}
void enableVertexProgramDoubleSidedColor(bool doubleSided) {}
bool supportVertexProgramDoubleSidedColor() const{ return true; };
virtual bool supportMADOperator() const ;
@ -1430,11 +1430,11 @@ public:
class CVertexProgramDrvInfosGL3 : public IProgramDrvInfos
{
public:
CVertexProgramDrvInfosGL3( CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it );
CVertexProgramDrvInfosGL3(CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it);
~CVertexProgramDrvInfosGL3();
uint getUniformIndex( const char *name ) const;
uint getUniformIndex(const char *name) const;
uint getProgramId() const{ return programId; }
void setProgramId( uint id ){ programId = id; }
void setProgramId(uint id) { programId = id; }
private:
uint programId;
@ -1443,11 +1443,11 @@ private:
class CPixelProgramDrvInfosGL3 : public IProgramDrvInfos
{
public:
CPixelProgramDrvInfosGL3( CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it );
CPixelProgramDrvInfosGL3(CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it);
~CPixelProgramDrvInfosGL3();
uint getUniformIndex( const char *name ) const;
uint getUniformIndex(const char *name) const;
uint getProgramId() const{ return programId; }
void setProgramId( uint id ){ programId = id; }
void setProgramId(uint id) { programId = id; }
private:
uint programId;

@ -457,13 +457,13 @@ namespace NLDRIVERGL3 {
#endif
#define CHECK_EXT(ext_str) \
if(strstr(glext, ext_str)==NULL) { nlwarning("3D: OpengGL extension '%s' was not found", ext_str); return false; } else { nldebug("3D: OpengGL Extension '%s' found", ext_str); }
if (strstr(glext, ext_str)==NULL) { nlwarning("3D: OpengGL extension '%s' was not found", ext_str); return false; } else { nldebug("3D: OpengGL Extension '%s' found", ext_str); }
// Debug: don't return false if the procaddr returns 0
// It means that it can crash if nel calls this extension but at least we have a warning to know why the extension is available but not the procaddr
#define CHECK_ADDRESS(type, ext) \
n##ext=(type)nglGetProcAddress(#ext); \
if(!n##ext) { nlwarning("3D: GetProcAddress(\"%s\") returns NULL", #ext); return false; } else { /*nldebug("3D: GetProcAddress(\"%s\") succeed", #ext);*/ }
if (!n##ext) { nlwarning("3D: GetProcAddress(\"%s\") returns NULL", #ext); return false; } else { /*nldebug("3D: GetProcAddress(\"%s\") succeed", #ext);*/ }
// ***************************************************************************
// Extensions registrations, and Windows function Registration.
@ -833,127 +833,127 @@ static bool setupPackedDepthStencil(const char *glext)
return true;
}
static bool setupGLSL( const char *glext )
static bool setupGLSL(const char *glext)
{
CHECK_EXT( "GL_ARB_shader_objects" );
CHECK_ADDRESS( PFNGLATTACHSHADERPROC, glAttachShader );
CHECK_ADDRESS( PFNGLCOMPILESHADERPROC, glCompileShader );
CHECK_ADDRESS( PFNGLCREATEPROGRAMPROC, glCreateProgram );
CHECK_ADDRESS( PFNGLCREATESHADERPROC, glCreateShader );
CHECK_ADDRESS( PFNGLDELETEPROGRAMPROC, glDeleteProgram );
CHECK_ADDRESS( PFNGLDELETESHADERPROC, glDeleteShader );
CHECK_ADDRESS( PFNGLDETACHSHADERPROC, glDetachShader );
CHECK_ADDRESS( PFNGLDISABLEVERTEXATTRIBARRAYPROC, glDisableVertexAttribArray );
CHECK_ADDRESS( PFNGLENABLEVERTEXATTRIBARRAYPROC, glEnableVertexAttribArray );
CHECK_ADDRESS( PFNGLGETATTACHEDSHADERSPROC, glGetAttachedShaders );
CHECK_ADDRESS( PFNGLGETPROGRAMIVPROC, glGetProgramiv );
CHECK_ADDRESS( PFNGLGETPROGRAMINFOLOGPROC, glGetProgramInfoLog );
CHECK_ADDRESS( PFNGLGETSHADERIVPROC, glGetShaderiv );
CHECK_ADDRESS( PFNGLGETSHADERINFOLOGPROC, glGetShaderInfoLog );
CHECK_ADDRESS( PFNGLGETUNIFORMLOCATIONPROC, glGetUniformLocation );
CHECK_ADDRESS( PFNGLISPROGRAMPROC, glIsProgram );
CHECK_ADDRESS( PFNGLISSHADERPROC, glIsShader );
CHECK_ADDRESS( PFNGLLINKPROGRAMPROC, glLinkProgram );
CHECK_ADDRESS( PFNGLSHADERSOURCEPROC, glShaderSource );
CHECK_ADDRESS( PFNGLUSEPROGRAMPROC, glUseProgram );
CHECK_ADDRESS( PFNGLVALIDATEPROGRAMPROC, glValidateProgram );
CHECK_ADDRESS( PFNGLUNIFORM1FPROC, glUniform1f );
CHECK_ADDRESS( PFNGLUNIFORM2FPROC, glUniform2f );
CHECK_ADDRESS( PFNGLUNIFORM3FPROC, glUniform3f );
CHECK_ADDRESS( PFNGLUNIFORM4FPROC, glUniform4f );
CHECK_ADDRESS( PFNGLUNIFORM1IPROC, glUniform1i );
CHECK_ADDRESS( PFNGLUNIFORM2IPROC, glUniform2i );
CHECK_ADDRESS( PFNGLUNIFORM3IPROC, glUniform3i );
CHECK_ADDRESS( PFNGLUNIFORM4IPROC, glUniform4i );
CHECK_ADDRESS( PFNGLUNIFORM1FVPROC, glUniform1fv );
CHECK_ADDRESS( PFNGLUNIFORM2FVPROC, glUniform2fv );
CHECK_ADDRESS( PFNGLUNIFORM3FVPROC, glUniform3fv );
CHECK_ADDRESS( PFNGLUNIFORM4FVPROC, glUniform4fv );
CHECK_ADDRESS( PFNGLUNIFORM1IVPROC, glUniform1iv );
CHECK_ADDRESS( PFNGLUNIFORM2IVPROC, glUniform2iv );
CHECK_ADDRESS( PFNGLUNIFORM3IVPROC, glUniform3iv );
CHECK_ADDRESS( PFNGLUNIFORM4IVPROC, glUniform4iv );
CHECK_ADDRESS( PFNGLUNIFORMMATRIX2FVPROC, glUniformMatrix2fv );
CHECK_ADDRESS( PFNGLUNIFORMMATRIX3FVPROC, glUniformMatrix3fv );
CHECK_ADDRESS( PFNGLUNIFORMMATRIX4FVPROC, glUniformMatrix4fv );
CHECK_ADDRESS( PFNGLVERTEXATTRIBPOINTERPROC, glVertexAttribPointer );
CHECK_ADDRESS( PFNGLUNIFORM1UIPROC, glUniform1ui );
CHECK_ADDRESS( PFNGLUNIFORM2UIPROC, glUniform2ui );
CHECK_ADDRESS( PFNGLUNIFORM3UIPROC, glUniform3ui );
CHECK_ADDRESS( PFNGLUNIFORM4UIPROC, glUniform4ui );
CHECK_ADDRESS( PFNGLUNIFORM1UIVPROC, glUniform1uiv );
CHECK_ADDRESS( PFNGLUNIFORM2UIVPROC, glUniform2uiv );
CHECK_ADDRESS( PFNGLUNIFORM3UIVPROC, glUniform3uiv );
CHECK_ADDRESS( PFNGLUNIFORM4UIVPROC, glUniform4uiv );
CHECK_EXT("GL_ARB_shader_objects");
CHECK_ADDRESS(PFNGLATTACHSHADERPROC, glAttachShader);
CHECK_ADDRESS(PFNGLCOMPILESHADERPROC, glCompileShader);
CHECK_ADDRESS(PFNGLCREATEPROGRAMPROC, glCreateProgram);
CHECK_ADDRESS(PFNGLCREATESHADERPROC, glCreateShader);
CHECK_ADDRESS(PFNGLDELETEPROGRAMPROC, glDeleteProgram);
CHECK_ADDRESS(PFNGLDELETESHADERPROC, glDeleteShader);
CHECK_ADDRESS(PFNGLDETACHSHADERPROC, glDetachShader);
CHECK_ADDRESS(PFNGLDISABLEVERTEXATTRIBARRAYPROC, glDisableVertexAttribArray);
CHECK_ADDRESS(PFNGLENABLEVERTEXATTRIBARRAYPROC, glEnableVertexAttribArray);
CHECK_ADDRESS(PFNGLGETATTACHEDSHADERSPROC, glGetAttachedShaders);
CHECK_ADDRESS(PFNGLGETPROGRAMIVPROC, glGetProgramiv);
CHECK_ADDRESS(PFNGLGETPROGRAMINFOLOGPROC, glGetProgramInfoLog);
CHECK_ADDRESS(PFNGLGETSHADERIVPROC, glGetShaderiv);
CHECK_ADDRESS(PFNGLGETSHADERINFOLOGPROC, glGetShaderInfoLog);
CHECK_ADDRESS(PFNGLGETUNIFORMLOCATIONPROC, glGetUniformLocation);
CHECK_ADDRESS(PFNGLISPROGRAMPROC, glIsProgram);
CHECK_ADDRESS(PFNGLISSHADERPROC, glIsShader);
CHECK_ADDRESS(PFNGLLINKPROGRAMPROC, glLinkProgram);
CHECK_ADDRESS(PFNGLSHADERSOURCEPROC, glShaderSource);
CHECK_ADDRESS(PFNGLUSEPROGRAMPROC, glUseProgram);
CHECK_ADDRESS(PFNGLVALIDATEPROGRAMPROC, glValidateProgram);
CHECK_ADDRESS(PFNGLUNIFORM1FPROC, glUniform1f);
CHECK_ADDRESS(PFNGLUNIFORM2FPROC, glUniform2f);
CHECK_ADDRESS(PFNGLUNIFORM3FPROC, glUniform3f);
CHECK_ADDRESS(PFNGLUNIFORM4FPROC, glUniform4f);
CHECK_ADDRESS(PFNGLUNIFORM1IPROC, glUniform1i);
CHECK_ADDRESS(PFNGLUNIFORM2IPROC, glUniform2i);
CHECK_ADDRESS(PFNGLUNIFORM3IPROC, glUniform3i);
CHECK_ADDRESS(PFNGLUNIFORM4IPROC, glUniform4i);
CHECK_ADDRESS(PFNGLUNIFORM1FVPROC, glUniform1fv);
CHECK_ADDRESS(PFNGLUNIFORM2FVPROC, glUniform2fv);
CHECK_ADDRESS(PFNGLUNIFORM3FVPROC, glUniform3fv);
CHECK_ADDRESS(PFNGLUNIFORM4FVPROC, glUniform4fv);
CHECK_ADDRESS(PFNGLUNIFORM1IVPROC, glUniform1iv);
CHECK_ADDRESS(PFNGLUNIFORM2IVPROC, glUniform2iv);
CHECK_ADDRESS(PFNGLUNIFORM3IVPROC, glUniform3iv);
CHECK_ADDRESS(PFNGLUNIFORM4IVPROC, glUniform4iv);
CHECK_ADDRESS(PFNGLUNIFORMMATRIX2FVPROC, glUniformMatrix2fv);
CHECK_ADDRESS(PFNGLUNIFORMMATRIX3FVPROC, glUniformMatrix3fv);
CHECK_ADDRESS(PFNGLUNIFORMMATRIX4FVPROC, glUniformMatrix4fv);
CHECK_ADDRESS(PFNGLVERTEXATTRIBPOINTERPROC, glVertexAttribPointer);
CHECK_ADDRESS(PFNGLUNIFORM1UIPROC, glUniform1ui);
CHECK_ADDRESS(PFNGLUNIFORM2UIPROC, glUniform2ui);
CHECK_ADDRESS(PFNGLUNIFORM3UIPROC, glUniform3ui);
CHECK_ADDRESS(PFNGLUNIFORM4UIPROC, glUniform4ui);
CHECK_ADDRESS(PFNGLUNIFORM1UIVPROC, glUniform1uiv);
CHECK_ADDRESS(PFNGLUNIFORM2UIVPROC, glUniform2uiv);
CHECK_ADDRESS(PFNGLUNIFORM3UIVPROC, glUniform3uiv);
CHECK_ADDRESS(PFNGLUNIFORM4UIVPROC, glUniform4uiv);
return true;
}
static bool setupSeparateShaderObjects( const char *glext )
static bool setupSeparateShaderObjects(const char *glext)
{
CHECK_EXT( "GL_ARB_separate_shader_objects" );
CHECK_ADDRESS( PFNGLUSEPROGRAMSTAGESPROC, glUseProgramStages );
CHECK_ADDRESS( PFNGLACTIVESHADERPROGRAMPROC, glActiveShaderProgram );
CHECK_ADDRESS( PFNGLCREATESHADERPROGRAMVPROC, glCreateShaderProgramv );
CHECK_ADDRESS( PFNGLBINDPROGRAMPIPELINEPROC, glBindProgramPipeline );
CHECK_ADDRESS( PFNGLDELETEPROGRAMPIPELINESPROC, glDeleteProgramPipelines );
CHECK_ADDRESS( PFNGLGENPROGRAMPIPELINESPROC, glGenProgramPipelines );
CHECK_ADDRESS( PFNGLISPROGRAMPIPELINEPROC, glIsProgramPipeline );
CHECK_ADDRESS( PFNGLGETPROGRAMPIPELINEIVPROC, glGetProgramPipelineiv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM1IPROC, glProgramUniform1i );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM1IVPROC, glProgramUniform1iv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM1FPROC, glProgramUniform1f );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM1FVPROC, glProgramUniform1fv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM1DPROC, glProgramUniform1d );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM1DVPROC, glProgramUniform1dv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM1UIPROC, glProgramUniform1ui );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM1UIVPROC, glProgramUniform1uiv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM2IPROC, glProgramUniform2i );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM2IVPROC, glProgramUniform2iv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM2FPROC, glProgramUniform2f );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM2FVPROC, glProgramUniform2fv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM2DPROC, glProgramUniform2d );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM2DVPROC, glProgramUniform2dv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM2UIPROC, glProgramUniform2ui );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM2UIVPROC, glProgramUniform2uiv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM3IPROC, glProgramUniform3i );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM3IVPROC, glProgramUniform3iv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM3FPROC, glProgramUniform3f );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM3FVPROC, glProgramUniform3fv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM3DPROC, glProgramUniform3d );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM3DVPROC, glProgramUniform3dv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM3UIPROC, glProgramUniform3ui );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM3UIVPROC, glProgramUniform3uiv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM4IPROC, glProgramUniform4i );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM4IVPROC, glProgramUniform4iv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM4FPROC, glProgramUniform4f );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM4FVPROC, glProgramUniform4fv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM4DPROC, glProgramUniform4d );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM4DVPROC, glProgramUniform4dv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM4UIPROC, glProgramUniform4ui );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORM4UIVPROC, glProgramUniform4uiv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX2FVPROC, glProgramUniformMatrix2fv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX3FVPROC, glProgramUniformMatrix3fv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX4FVPROC, glProgramUniformMatrix4fv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX2DVPROC, glProgramUniformMatrix2dv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX3DVPROC, glProgramUniformMatrix3dv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX4DVPROC, glProgramUniformMatrix4dv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC, glProgramUniformMatrix2x3fv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC, glProgramUniformMatrix3x2fv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC, glProgramUniformMatrix2x4fv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC, glProgramUniformMatrix4x2fv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC, glProgramUniformMatrix3x4fv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC, glProgramUniformMatrix4x3fv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC, glProgramUniformMatrix2x3dv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC, glProgramUniformMatrix3x2dv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC, glProgramUniformMatrix2x4dv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC, glProgramUniformMatrix4x2dv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC, glProgramUniformMatrix3x4dv );
CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC, glProgramUniformMatrix4x3dv );
CHECK_ADDRESS( PFNGLVALIDATEPROGRAMPIPELINEPROC, glValidateProgramPipeline );
CHECK_ADDRESS( PFNGLGETPROGRAMPIPELINEINFOLOGPROC, glGetProgramPipelineInfoLog );
CHECK_EXT("GL_ARB_separate_shader_objects");
CHECK_ADDRESS(PFNGLUSEPROGRAMSTAGESPROC, glUseProgramStages);
CHECK_ADDRESS(PFNGLACTIVESHADERPROGRAMPROC, glActiveShaderProgram);
CHECK_ADDRESS(PFNGLCREATESHADERPROGRAMVPROC, glCreateShaderProgramv);
CHECK_ADDRESS(PFNGLBINDPROGRAMPIPELINEPROC, glBindProgramPipeline);
CHECK_ADDRESS(PFNGLDELETEPROGRAMPIPELINESPROC, glDeleteProgramPipelines);
CHECK_ADDRESS(PFNGLGENPROGRAMPIPELINESPROC, glGenProgramPipelines);
CHECK_ADDRESS(PFNGLISPROGRAMPIPELINEPROC, glIsProgramPipeline);
CHECK_ADDRESS(PFNGLGETPROGRAMPIPELINEIVPROC, glGetProgramPipelineiv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1IPROC, glProgramUniform1i);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1IVPROC, glProgramUniform1iv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1FPROC, glProgramUniform1f);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1FVPROC, glProgramUniform1fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1DPROC, glProgramUniform1d);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1DVPROC, glProgramUniform1dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1UIPROC, glProgramUniform1ui);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1UIVPROC, glProgramUniform1uiv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2IPROC, glProgramUniform2i);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2IVPROC, glProgramUniform2iv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2FPROC, glProgramUniform2f);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2FVPROC, glProgramUniform2fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2DPROC, glProgramUniform2d);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2DVPROC, glProgramUniform2dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2UIPROC, glProgramUniform2ui);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2UIVPROC, glProgramUniform2uiv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3IPROC, glProgramUniform3i);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3IVPROC, glProgramUniform3iv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3FPROC, glProgramUniform3f);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3FVPROC, glProgramUniform3fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3DPROC, glProgramUniform3d);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3DVPROC, glProgramUniform3dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3UIPROC, glProgramUniform3ui);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3UIVPROC, glProgramUniform3uiv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4IPROC, glProgramUniform4i);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4IVPROC, glProgramUniform4iv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4FPROC, glProgramUniform4f);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4FVPROC, glProgramUniform4fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4DPROC, glProgramUniform4d);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4DVPROC, glProgramUniform4dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4UIPROC, glProgramUniform4ui);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4UIVPROC, glProgramUniform4uiv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2FVPROC, glProgramUniformMatrix2fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3FVPROC, glProgramUniformMatrix3fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4FVPROC, glProgramUniformMatrix4fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2DVPROC, glProgramUniformMatrix2dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3DVPROC, glProgramUniformMatrix3dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4DVPROC, glProgramUniformMatrix4dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC, glProgramUniformMatrix2x3fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC, glProgramUniformMatrix3x2fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC, glProgramUniformMatrix2x4fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC, glProgramUniformMatrix4x2fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC, glProgramUniformMatrix3x4fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC, glProgramUniformMatrix4x3fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC, glProgramUniformMatrix2x3dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC, glProgramUniformMatrix3x2dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC, glProgramUniformMatrix2x4dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC, glProgramUniformMatrix4x2dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC, glProgramUniformMatrix3x4dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC, glProgramUniformMatrix4x3dv);
CHECK_ADDRESS(PFNGLVALIDATEPROGRAMPIPELINEPROC, glValidateProgramPipeline);
CHECK_ADDRESS(PFNGLGETPROGRAMPIPELINEINFOLOGPROC, glGetProgramPipelineInfoLog);
return true;
}
@ -968,11 +968,11 @@ void registerGlExtensions(CGlExtensions &ext)
sint a=0, b=0;
sscanf(nglVersion, "%d.%d", &a, &b);
if( ( a < 3 ) || ( ( a == 3 ) && ( b < 3 ) ) )
if ((a < 3) || ((a == 3) && (b < 3)))
{
nlinfo( "OpenGL version is less than 3.3!" );
nlinfo( "Version string: %s",nglVersion );
nlassert( false );
nlinfo("OpenGL version is less than 3.3!");
nlinfo("Version string: %s",nglVersion);
nlassert(false);
}
// Extensions.
@ -985,18 +985,18 @@ void registerGlExtensions(CGlExtensions &ext)
{
vector<string> exts;
explode(string(glext), string(" "), exts);
for(uint i = 0; i < exts.size(); i++)
for (uint i = 0; i < exts.size(); i++)
{
if(i%5==0) DebugLog->displayRaw("3D: ");
if (i%5==0) DebugLog->displayRaw("3D: ");
DebugLog->displayRaw(string(exts[i]+" ").c_str());
if(i%5==4) DebugLog->displayRaw("\n");
if (i%5==4) DebugLog->displayRaw("\n");
}
DebugLog->displayRaw("\n");
}
// Check ARBMultiTexture
ext.ARBMultiTexture= setupARBMultiTexture(glext);
if(ext.ARBMultiTexture)
if (ext.ARBMultiTexture)
{
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &ntext);
// We could have more than IDRV_MAT_MAXTEXTURES but the interface only
@ -1077,16 +1077,16 @@ void registerGlExtensions(CGlExtensions &ext)
setupARBVertexBufferObject(glext);
if( !setupGLSL( glext ) )
if (!setupGLSL(glext))
{
nlinfo( "Failed to set up GLSL related calls!" );
nlassert( false );
nlinfo("Failed to set up GLSL related calls!");
nlassert(false);
}
if( !setupSeparateShaderObjects( glext ) )
if (!setupSeparateShaderObjects(glext))
{
nlinfo( "Failed to set up separate shader object calls!" );
nlassert( false );
nlinfo("Failed to set up separate shader object calls!");
nlassert(false);
}
}
@ -1168,11 +1168,11 @@ bool registerWGlExtensions(CGlExtensions &ext, HDC hDC)
{
vector<string> exts;
explode(string(glext), string(" "), exts);
for(uint i = 0; i < exts.size(); i++)
for (uint i = 0; i < exts.size(); i++)
{
if(i%5==0) DebugLog->displayRaw("3D: ");
if (i%5==0) DebugLog->displayRaw("3D: ");
DebugLog->displayRaw(string(exts[i]+" ").c_str());
if(i%5==4) DebugLog->displayRaw("\n");
if (i%5==4) DebugLog->displayRaw("\n");
}
DebugLog->displayRaw("\n");
}
@ -1209,11 +1209,11 @@ bool registerGlXExtensions(CGlExtensions &ext, Display *dpy, sint screen)
{
vector<string> exts;
explode(string(glext), string(" "), exts);
for(uint i = 0; i < exts.size(); i++)
for (uint i = 0; i < exts.size(); i++)
{
if(i%5==0) DebugLog->displayRaw("3D: ");
if (i%5==0) DebugLog->displayRaw("3D: ");
DebugLog->displayRaw(string(exts[i]+" ").c_str());
if(i%5==4) DebugLog->displayRaw("\n");
if (i%5==4) DebugLog->displayRaw("\n");
}
DebugLog->displayRaw("\n");
}

@ -159,7 +159,7 @@ void CDriverGL3::addCursor(const std::string &name, const NLMISC::CBitmap &curso
minX = x;
for (uint y = 0; y < height; ++y)
{
if(pixels[x + y * width].A != 0)
if (pixels[x + y * width].A != 0)
{
stop = true;
break;
@ -175,7 +175,7 @@ void CDriverGL3::addCursor(const std::string &name, const NLMISC::CBitmap &curso
maxX = (uint) x;
for (uint y = 0; y < height; ++y)
{
if(pixels[x + y * width].A != 0)
if (pixels[x + y * width].A != 0)
{
stop = true;
break;
@ -191,7 +191,7 @@ void CDriverGL3::addCursor(const std::string &name, const NLMISC::CBitmap &curso
minY = y;
for (uint x = 0; x < width; ++x)
{
if(pixels[x + y * width].A != 0)
if (pixels[x + y * width].A != 0)
{
stop = true;
break;
@ -207,7 +207,7 @@ void CDriverGL3::addCursor(const std::string &name, const NLMISC::CBitmap &curso
maxY = (uint) y;
for (uint x = 0; x < width; ++x)
{
if(pixels[x + y * width].A != 0)
if (pixels[x + y * width].A != 0)
{
stop = true;
break;
@ -342,7 +342,7 @@ void CDriverGL3::setCursor(const std::string &name, NLMISC::CRGBA col, uint8 rot
curs.Rot != rot ||
curs.ColorDepth != _ColorDepth ||
forceRebuild
)
)
{
curs.reset();
curs.Cursor = buildCursor(curs.Src, col, rot, hotSpotX, hotSpotY);
@ -466,18 +466,18 @@ void CDriverGL3::showCursor(bool b)
CGDisplayErr error = kCGErrorSuccess;
static bool visible = true;
if(b && !visible)
if (b && !visible)
{
error = CGDisplayShowCursor(kCGDirectMainDisplay);
visible = true;
}
else if(!b && visible)
else if (!b && visible)
{
error = CGDisplayHideCursor(kCGDirectMainDisplay);
visible = false;
}
if(error != kCGErrorSuccess)
if (error != kCGErrorSuccess)
nlerror("cannot show / hide cursor");
#elif defined (NL_OS_UNIX)
@ -527,7 +527,7 @@ void CDriverGL3::setMousePos(float x, float y)
// get the rect (position, size) of the window
NSRect windowRect;
if([containerView() isInFullScreenMode])
if ([containerView() isInFullScreenMode])
windowRect = [[[containerView() window] screen] frame];
else
windowRect = [[containerView() window] frame];
@ -542,7 +542,7 @@ void CDriverGL3::setMousePos(float x, float y)
firstScreenRect.size.height - windowRect.origin.y -
viewRect.size.height + ((1.0 - y) * viewRect.size.height)));
if(error != kCGErrorSuccess)
if (error != kCGErrorSuccess)
nlerror("cannot set mouse position");
#elif defined (NL_OS_UNIX)
@ -582,7 +582,7 @@ void CDriverGL3::setCapture (bool b)
#elif defined (NL_OS_UNIX)
if(b /* && isSystemCursorInClientArea() && !isSystemCursorCaptured()*/) // capture the cursor.
if (b /* && isSystemCursorInClientArea() && !isSystemCursorCaptured()*/) // capture the cursor.
{
// capture the cursor
XGrabPointer(_dpy, _win, True, 0, GrabModeAsync, GrabModeAsync, _win, None, CurrentTime);

@ -28,7 +28,7 @@ namespace NLDRIVERGL3 {
// ***************************************************************************
uint CDriverGL3::getMaxLight () const
{
H_AUTO_OGL(CDriverGL3_getMaxLight )
H_AUTO_OGL(CDriverGL3_getMaxLight)
// return min(maxLight supported by openGL, MaxLight=8).
return _MaxDriverLight;
}
@ -37,9 +37,9 @@ uint CDriverGL3::getMaxLight () const
// ***************************************************************************
void CDriverGL3::setLight (uint8 num, const CLight& light)
{
H_AUTO_OGL(CDriverGL3_setLight )
H_AUTO_OGL(CDriverGL3_setLight)
// bkup real light, for lightmap dynamic lighting purpose
if(num==0)
if (num==0)
{
_UserLight0= light;
// because the GL setup change, must dirt lightmap rendering
@ -106,7 +106,7 @@ void CDriverGL3::setLightInternal(uint8 num, const CLight& light)
// ***************************************************************************
void CDriverGL3::enableLight (uint8 num, bool enable)
{
H_AUTO_OGL(CDriverGL3_enableLight )
H_AUTO_OGL(CDriverGL3_enableLight)
// enable the light in GL
enableLightInternal(num, enable);
@ -117,7 +117,7 @@ void CDriverGL3::enableLight (uint8 num, bool enable)
bool CDriverGL3::isLightEnabled (uint8 num)
{
if(num<_MaxDriverLight)
if (num<_MaxDriverLight)
return _UserLightEnable[num];
return false;
@ -144,7 +144,7 @@ void CDriverGL3::enableLightInternal(uint8 num, bool enable)
void CDriverGL3::setAmbientColor (CRGBA color)
{
H_AUTO_OGL(CDriverGL3_setAmbientColor )
H_AUTO_OGL(CDriverGL3_setAmbientColor)
}
@ -152,7 +152,7 @@ void CDriverGL3::setAmbientColor (CRGBA color)
// ***************************************************************************
void CDriverGL3::setLightMapDynamicLight (bool enable, const CLight& light)
{
H_AUTO_OGL(CDriverGL3_setLightMapDynamicLight )
H_AUTO_OGL(CDriverGL3_setLightMapDynamicLight)
// just store, for future setup in lightmap material rendering
_LightMapDynamicLightEnabled= enable;
_LightMapDynamicLight= light;
@ -165,14 +165,14 @@ void CDriverGL3::setupLightMapDynamicLighting(bool enable)
{
H_AUTO_OGL(CDriverGL3_setupLightMapDynamicLighting)
// start lightmap dynamic lighting
if(enable)
if (enable)
{
// disable all lights but the 0th.
for(uint i=1;i<_MaxDriverLight;i++)
for (uint i=1;i<_MaxDriverLight;i++)
enableLightInternal(i, false);
// if the dynamic light is really enabled
if(_LightMapDynamicLightEnabled)
if (_LightMapDynamicLightEnabled)
{
// then setup and enable
setLightInternal(0, _LightMapDynamicLight);
@ -194,14 +194,14 @@ void CDriverGL3::setupLightMapDynamicLighting(bool enable)
setLightInternal(0, _UserLight0);
// restore all standard light enable states
for(uint i=0;i<_MaxDriverLight;i++)
for (uint i=0;i<_MaxDriverLight;i++)
enableLightInternal(i, _UserLightEnable[i]);
}
}
void CDriverGL3::disableAllLights()
{
for( int i = 0; i < MaxLight; i++ )
for (int i = 0; i < MaxLight; i++)
{
_UserLightEnable[ i ] = false;
}

@ -118,7 +118,7 @@ void CDriverGL3::setTextureEnvFunction(uint stage, CMaterial& mat)
{
H_AUTO_OGL(CDriverGL3_setTextureEnvFunction)
ITexture *text= mat.getTexture(uint8(stage));
if(text)
if (text)
{
CMaterial::CTexEnv &env= mat._TexEnvs[stage];
@ -133,7 +133,7 @@ void CDriverGL3::setTextureEnvFunction(uint stage, CMaterial& mat)
{
// set mode and enable.
CMaterial::TTexCoordGenMode mode= mat.getTexCoordGenMode(stage);
if(mode==CMaterial::TexCoordGenReflect)
if (mode==CMaterial::TexCoordGenReflect)
{
// Cubic or normal ?
if (text->isTextureCube ())
@ -141,11 +141,11 @@ void CDriverGL3::setTextureEnvFunction(uint stage, CMaterial& mat)
else
_DriverGLStates.setTexGenMode (stage, GL_SPHERE_MAP);
}
else if(mode==CMaterial::TexCoordGenObjectSpace)
else if (mode==CMaterial::TexCoordGenObjectSpace)
{
_DriverGLStates.setTexGenMode (stage, GL_OBJECT_LINEAR);
}
else if(mode==CMaterial::TexCoordGenEyeSpace)
else if (mode==CMaterial::TexCoordGenEyeSpace)
{
_DriverGLStates.setTexGenMode (stage, GL_EYE_LINEAR);
}
@ -165,7 +165,7 @@ void CDriverGL3::setupUserTextureMatrix(uint numStages, CMaterial& mat)
if (
(_UserTexMatEnabled != 0 && (mat.getFlags() & IDRV_MAT_USER_TEX_MAT_ALL) == 0)
|| (mat.getFlags() & IDRV_MAT_USER_TEX_MAT_ALL) != 0
)
)
{
// for each stage, setup the texture matrix if needed
uint newMask = (mat.getFlags() & IDRV_MAT_USER_TEX_MAT_ALL) >> IDRV_MAT_USER_TEX_FIRST_BIT;
@ -174,7 +174,7 @@ void CDriverGL3::setupUserTextureMatrix(uint numStages, CMaterial& mat)
{
if (newMask & shiftMask) // user matrix for this stage
{
_UserTexMat[ k ] = mat.getUserTexMat( k );
_UserTexMat[ k ] = mat.getUserTexMat(k);
_UserTexMatEnabled |= shiftMask;
}
else
@ -182,7 +182,7 @@ void CDriverGL3::setupUserTextureMatrix(uint numStages, CMaterial& mat)
/// check if matrix disabled
if (
(newMask & shiftMask) != (_UserTexMatEnabled & shiftMask)
)
)
{
_UserTexMat[ k ].identity();
_UserTexMatEnabled &= ~shiftMask;
@ -232,7 +232,7 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
{
H_AUTO_OGL(CDriverGL3_setupMaterial)
if( mat.getDynMat() != NULL )
if (mat.getDynMat() != NULL)
{
_CurrentMaterial = &mat;
return true;
@ -263,26 +263,26 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
// 1. Setup modified fields of material.
//=====================================
if( touched )
if (touched)
{
/* Exception: if only Textures are modified in the material, no need to "Bind OpenGL States", or even to test
for change, because textures are activated alone, see below.
No problem with delete/new problem (see below), because in this case, IDRV_TOUCHED_ALL is set (see above).
*/
// If any flag is set (but a flag of texture)
if( touched & (~_MaterialAllTextureTouchedFlag) )
if (touched & (~_MaterialAllTextureTouchedFlag))
{
// Convert Material to driver shader.
if (touched & IDRV_TOUCHED_BLENDFUNC)
{
convBlend( mat.getSrcBlend(),glenum );
convBlend(mat.getSrcBlend(),glenum);
pShader->SrcBlend=glenum;
convBlend( mat.getDstBlend(),glenum );
convBlend(mat.getDstBlend(),glenum);
pShader->DstBlend=glenum;
}
if (touched & IDRV_TOUCHED_ZFUNC)
{
convZFunction( mat.getZFunc(),glenum);
convZFunction(mat.getZFunc(),glenum);
pShader->ZComp= glenum;
}
if (touched & IDRV_TOUCHED_LIGHTING)
@ -318,14 +318,14 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
CMaterial::TShader matShader = pShader->SupportedShader;
// if the shader has changed since last time
if(matShader != _CurrentMaterialSupportedShader)
if (matShader != _CurrentMaterialSupportedShader)
{
// if old was lightmap, restore standard lighting
if(_CurrentMaterialSupportedShader==CMaterial::LightMap)
if (_CurrentMaterialSupportedShader==CMaterial::LightMap)
setupLightMapDynamicLighting(false);
// if new is lightmap, setup dynamic lighting
if(matShader==CMaterial::LightMap)
if (matShader==CMaterial::LightMap)
setupLightMapDynamicLighting(true);
}
@ -339,7 +339,7 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
// because setupTexture() may disable all stage.
if (matShader != CMaterial::Water)
{
for(stage=0 ; stage<inlGetNumTextStages() ; stage++)
for (stage=0 ; stage<inlGetNumTextStages() ; stage++)
{
ITexture *text= mat.getTexture(uint8(stage));
if (text != NULL && !setupTexture(*text))
@ -347,9 +347,9 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
}
}
// Here, for Lightmap materials, setup the lightmaps.
if(matShader == CMaterial::LightMap)
if (matShader == CMaterial::LightMap)
{
for(stage = 0; stage < mat._LightMaps.size(); stage++)
for (stage = 0; stage < mat._LightMaps.size(); stage++)
{
ITexture *text = mat._LightMaps[stage].Texture;
if (text != NULL && !setupTexture(*text))
@ -367,15 +367,15 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
// Do not do it for Lightmap and per pixel lighting , because done in multipass in a very special fashion.
// This avoid the useless multiple change of texture states per lightmapped object.
// Don't do it also for Specular because the EnvFunction and the TexGen may be special.
if(matShader != CMaterial::LightMap
if (matShader != CMaterial::LightMap
&& matShader != CMaterial::PerPixelLighting
/* && matShader != CMaterial::Caustics */
&& matShader != CMaterial::Cloud
&& matShader != CMaterial::Water
&& matShader != CMaterial::Specular
)
)
{
for(stage=0 ; stage<inlGetNumTextStages() ; stage++)
for (stage=0 ; stage<inlGetNumTextStages() ; stage++)
{
ITexture *text= mat.getTexture(uint8(stage));
@ -393,21 +393,21 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
//=================
bool blend = (mat.getFlags()&IDRV_MAT_BLEND)!=0;
_DriverGLStates.enableBlend(blend);
if(blend)
if (blend)
_DriverGLStates.blendFunc(pShader->SrcBlend, pShader->DstBlend);
// Double Sided Part.
//===================
// NB: inverse state: DoubleSided <=> !CullFace.
uint32 twoSided= mat.getFlags()&IDRV_MAT_DOUBLE_SIDED;
_DriverGLStates.enableCullFace( twoSided==0 );
_DriverGLStates.enableCullFace(twoSided==0);
// Alpha Test Part.
//=================
uint32 alphaTest= mat.getFlags()&IDRV_MAT_ALPHA_TEST;
_DriverGLStates.enableAlphaTest(alphaTest);
if(alphaTest)
if (alphaTest)
{
// setup alphaTest threshold.
_DriverGLStates.alphaFunc(mat.getAlphaTestThreshold());
@ -433,10 +433,10 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
// Light Part.
_DriverGLStates.enableLighting(mat.getFlags()&IDRV_MAT_LIGHTING);
if( ( mat.getFlags() & IDRV_MAT_LIGHTING ) == 0 )
if ((mat.getFlags() & IDRV_MAT_LIGHTING) == 0)
disableAllLights();
if(mat.getFlags()&IDRV_MAT_LIGHTING)
if (mat.getFlags()&IDRV_MAT_LIGHTING)
{
_DriverGLStates.setEmissive(pShader->PackedEmissive, pShader->Emissive);
_DriverGLStates.setAmbient(pShader->PackedAmbient, pShader->Ambient);
@ -484,7 +484,7 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
// 5. Set up the program
// =====================
bool programOK = setupProgram( mat );
bool programOK = setupProgram(mat);
return programOK;
}
@ -493,7 +493,7 @@ sint CDriverGL3::beginMultiPass()
{
H_AUTO_OGL(CDriverGL3_beginMultiPass)
if( _CurrentMaterial->getDynMat() != NULL )
if (_CurrentMaterial->getDynMat() != NULL)
return _CurrentMaterial->getDynMat()->getPassCount();
// Depending on material type and hardware, return number of pass required to draw this material.
@ -524,8 +524,8 @@ bool CDriverGL3::setupPass(uint pass)
{
H_AUTO_OGL(CDriverGL3_setupPass)
if( _CurrentMaterial->getDynMat() != NULL )
return setupDynMatPass( pass );
if (_CurrentMaterial->getDynMat() != NULL)
return setupDynMatPass(pass);
switch(_CurrentMaterialSupportedShader)
{
@ -563,7 +563,7 @@ void CDriverGL3::endMultiPass()
{
H_AUTO_OGL(CDriverGL3_endMultiPass)
if( _CurrentMaterial->getDynMat() != NULL )
if (_CurrentMaterial->getDynMat() != NULL)
return;
switch(_CurrentMaterialSupportedShader)
@ -594,19 +594,19 @@ void CDriverGL3::endMultiPass()
}
}
bool CDriverGL3::setupDynMatPass( uint pass )
bool CDriverGL3::setupDynMatPass(uint pass)
{
if( !setupDynMatProgram( *_CurrentMaterial, pass ) )
if (!setupDynMatProgram(*_CurrentMaterial, pass))
return false;
if( ( _CurrentMaterial->getFlags() & IDRV_MAT_DOUBLE_SIDED ) != 0 )
_DriverGLStates.enableCullFace( false );
if ((_CurrentMaterial->getFlags() & IDRV_MAT_DOUBLE_SIDED) != 0)
_DriverGLStates.enableCullFace(false);
else
_DriverGLStates.enableCullFace( true );
_DriverGLStates.enableCullFace(true);
CDynMaterial *m = _CurrentMaterial->getDynMat();
SRenderPass *currentPass = m->getPass( pass );
SRenderPass *currentPass = m->getPass(pass);
IProgram *p;
@ -618,56 +618,56 @@ bool CDriverGL3::setupDynMatPass( uint pass )
type[ 0 ] = IDriver::VertexProgram;
type[ 1 ] = IDriver::PixelProgram;
for( uint32 j = 0; j < 2; j++ )
for (uint32 j = 0; j < 2; j++)
{
p = programs[ j ];
for( uint32 i = 0; i < currentPass->count(); i++ )
for (uint32 i = 0; i < currentPass->count(); i++)
{
const SDynMaterialProp *prop = currentPass->getProperty( i );
int loc = getUniformLocation( type[ j ], prop->prop.c_str() );
if( loc == -1 )
const SDynMaterialProp *prop = currentPass->getProperty(i);
int loc = getUniformLocation(type[ j ], prop->prop.c_str());
if (loc == -1)
continue;
switch( prop->type )
switch(prop->type)
{
case SDynMaterialProp::Float:
setUniform1f( type[ j ], loc, prop->value.toFloat() );
setUniform1f(type[ j ], loc, prop->value.toFloat());
break;
case SDynMaterialProp::Int:
setUniform1i( type[ j ], loc, prop->value.toInt() );
setUniform1i(type[ j ], loc, prop->value.toInt());
break;
case SDynMaterialProp::Uint:
setUniform1ui( type[ j ], loc, prop->value.toUInt() );
setUniform1ui(type[ j ], loc, prop->value.toUInt());
break;
case SDynMaterialProp::Color:
{
float v[ 4 ];
prop->value.getVector4( v );
prop->value.getVector4(v);
for( int k = 0; k < 4; k++ )
for (int k = 0; k < 4; k++)
v[ k ] = v[ k ] / 255.0f;
setUniform4f( type[ j ], loc, v[ 0 ], v[ 1 ], v[ 2 ], v[ 3 ] );
setUniform4f(type[ j ], loc, v[ 0 ], v[ 1 ], v[ 2 ], v[ 3 ]);
}
break;
case SDynMaterialProp::Vector4:
{
float v[ 4 ];
prop->value.getVector4( v );
setUniform4f( type[ j ], loc, v[ 0 ], v[ 1 ], v[ 2 ], v[ 3 ] );
prop->value.getVector4(v);
setUniform4f(type[ j ], loc, v[ 0 ], v[ 1 ], v[ 2 ], v[ 3 ]);
}
break;
case SDynMaterialProp::Matrix4:
{
float m[ 16 ];
prop->value.getMatrix4( m );
setUniform4x4f( type[ j ], loc, m );
prop->value.getMatrix4(m);
setUniform4x4f(type[ j ], loc, m);
break;
}
@ -679,17 +679,17 @@ bool CDriverGL3::setupDynMatPass( uint pass )
////////////////////////////////// Set up some standard uniforms //////////////////////////////////
int loc = -1;
loc = getUniformLocation( type[ j ], "mvpMatrix" );
if( loc != -1 )
loc = getUniformLocation(type[ j ], "mvpMatrix");
if (loc != -1)
{
CMatrix mat = _GLProjMat * _ModelViewMatrix;
setUniform4x4f( type[ j ], loc, mat );
setUniform4x4f(type[ j ], loc, mat);
}
loc = getUniformLocation( type[ j ], "mvMatrix" );
if( loc != -1 )
loc = getUniformLocation(type[ j ], "mvMatrix");
if (loc != -1)
{
setUniform4x4f( type[ j ], loc, _ModelViewMatrix );
setUniform4x4f(type[ j ], loc, _ModelViewMatrix);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@ -703,34 +703,34 @@ void CDriverGL3::setupNormalPass()
{
const CMaterial &mat = *_CurrentMaterial;
for( int i = 0; i < IDRV_MAT_MAXTEXTURES; i++ )
for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++)
{
// Set constant
int cl = currentProgram.pp->getUniformIndex( CProgramIndex::TName( CProgramIndex::Constant0 + i ) );
if( cl != -1 )
int cl = currentProgram.pp->getUniformIndex(CProgramIndex::TName(CProgramIndex::Constant0 + i));
if (cl != -1)
{
GLfloat glCol[ 4 ];
convColor( mat._TexEnvs[ i ].ConstantColor, glCol );
setUniform4f( IDriver::PixelProgram, cl, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ] );
convColor(mat._TexEnvs[ i ].ConstantColor, glCol);
setUniform4f(IDriver::PixelProgram, cl, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ]);
}
// Set texture
ITexture *t = mat.getTexture( i );
if( t == NULL )
ITexture *t = mat.getTexture(i);
if (t == NULL)
continue;
int index = currentProgram.pp->getUniformIndex( CProgramIndex::TName( CProgramIndex::Sampler0 + i ) );
if( index == -1 )
int index = currentProgram.pp->getUniformIndex(CProgramIndex::TName(CProgramIndex::Sampler0 + i));
if (index == -1)
continue;
setUniform1i( IDriver::PixelProgram, index, i );
setUniform1i(IDriver::PixelProgram, index, i);
}
}
// ***************************************************************************
void CDriverGL3::computeLightMapInfos (const CMaterial &mat)
{
H_AUTO_OGL(CDriverGL3_computeLightMapInfos )
H_AUTO_OGL(CDriverGL3_computeLightMapInfos)
static const uint32 RGBMaskPacked = CRGBA(255,255,255,0).getPacked();
// For optimisation consideration, suppose there is not too much lightmap.
@ -761,7 +761,7 @@ void CDriverGL3::computeLightMapInfos (const CMaterial &mat)
// ***************************************************************************
sint CDriverGL3::beginLightMapMultiPass ()
{
H_AUTO_OGL(CDriverGL3_beginLightMapMultiPass )
H_AUTO_OGL(CDriverGL3_beginLightMapMultiPass)
const CMaterial &mat= *_CurrentMaterial;
// compute how many lightmap and pass we must process.
@ -772,7 +772,7 @@ sint CDriverGL3::beginLightMapMultiPass ()
// if the dynamic lightmap light has changed since the last render (should not happen), resetup
// normal way is that setupLightMapDynamicLighting() is called in setupMaterial() if shader different from prec
if(_LightMapDynamicLightDirty)
if (_LightMapDynamicLightDirty)
setupLightMapDynamicLighting(true);
// reset Ambient and specular lighting
@ -801,7 +801,7 @@ void CDriverGL3::setupLightMapPass(uint pass)
static GLfloat glcolGrey[4]= {0.5f,0.5f,0.5f,1.f};
// No lightmap or all blacks??, just setup "black texture" for stage 0.
if(_NLightMaps==0)
if (_NLightMaps==0)
{
ITexture *text= mat.getTexture(0);
activateTexture(0,text);
@ -819,7 +819,7 @@ void CDriverGL3::setupLightMapPass(uint pass)
_DriverGLStates.setTexGenMode(0, 0);
// And disable other stages.
for(uint stage = 1; stage < inlGetNumTextStages(); stage++)
for (uint stage = 1; stage < inlGetNumTextStages(); stage++)
{
// disable texturing.
activateTexture(stage, NULL);
@ -845,7 +845,7 @@ void CDriverGL3::setupLightMapPass(uint pass)
uint32 g=0;
uint32 b=0;
// sum only the ambient of lightmaps that will be drawn this pass
for(uint sa=0;sa<nstages-1;sa++)
for (uint sa=0;sa<nstages-1;sa++)
{
uint wla= _LightMapLUT[lmapId+sa];
// must mul them by their respective mapFactor too
@ -867,10 +867,10 @@ void CDriverGL3::setupLightMapPass(uint pass)
}
// setup all stages.
for(uint stage= 0; stage<inlGetNumTextStages(); stage++)
for (uint stage= 0; stage<inlGetNumTextStages(); stage++)
{
// if must setup a lightmap stage.
if(stage<nstages-1)
if (stage<nstages-1)
{
// setup lightMap.
uint whichLightMap= _LightMapLUT[lmapId];
@ -889,29 +889,29 @@ void CDriverGL3::setupLightMapPass(uint pass)
// If texture not NULL, Change texture env fonction.
//==================================================
if(text)
if (text)
{
static CMaterial::CTexEnv stdEnv;
{
// Here, we are sure that texEnvCombine4 or texEnvCombine3 is OK.
// nlassert( _Extensions.ATITextureEnvCombine3);
// nlassert(_Extensions.ATITextureEnvCombine3);
// setup constant color with Lightmap factor.
stdEnv.ConstantColor=lmapFactor;
int cl = currentProgram.pp->getUniformIndex( CProgramIndex::TName( CProgramIndex::Constant0 + stage ) );
if( cl != -1 )
int cl = currentProgram.pp->getUniformIndex(CProgramIndex::TName(CProgramIndex::Constant0 + stage));
if (cl != -1)
{
GLfloat glCol[ 4 ];
convColor( lmapFactor, glCol );
setUniform4f( IDriver::PixelProgram, cl, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ] );
convColor(lmapFactor, glCol);
setUniform4f(IDriver::PixelProgram, cl, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ]);
}
int tl = currentProgram.pp->getUniformIndex( CProgramIndex::TName( CProgramIndex::Sampler0 + stage ) );
if( tl != -1 )
int tl = currentProgram.pp->getUniformIndex(CProgramIndex::TName(CProgramIndex::Sampler0 + stage));
if (tl != -1)
{
setUniform1i( IDriver::PixelProgram, tl, stage );
setUniform1i(IDriver::PixelProgram, tl, stage);
}
activateTexEnvColor(stage, stdEnv);
@ -921,7 +921,7 @@ void CDriverGL3::setupLightMapPass(uint pass)
_DriverGLStates.setTexGenMode(stage, 0);
// setup TexEnvCombine4 (ignore alpha part).
if(_CurrentTexEnvSpecial[stage] != TexEnvSpecialLightMap)
if (_CurrentTexEnvSpecial[stage] != TexEnvSpecialLightMap)
{
// TexEnv is special.
_CurrentTexEnvSpecial[stage] = TexEnvSpecialLightMap;
@ -932,11 +932,11 @@ void CDriverGL3::setupLightMapPass(uint pass)
// Next lightmap.
lmapId++;
}
else if(stage<nstages)
else if (stage<nstages)
{
// optim: do this only for first pass, and last pass only if stage!=nLMapPerPass
// (meaning not the same stage as preceding passes).
if(pass==0 || (pass==_NLightMapPass-1 && stage!=_NLightMapPerPass))
if (pass==0 || (pass==_NLightMapPass-1 && stage!=_NLightMapPerPass))
{
// activate the texture at last stage.
ITexture *text= mat.getTexture(0);
@ -949,10 +949,10 @@ void CDriverGL3::setupLightMapPass(uint pass)
_DriverGLStates.activeTextureARB(stage);
_DriverGLStates.setTexGenMode(stage, 0);
int tl = currentProgram.pp->getUniformIndex( CProgramIndex::TName( CProgramIndex::Sampler0 + stage ) );
if( tl != -1 )
int tl = currentProgram.pp->getUniformIndex(CProgramIndex::TName(CProgramIndex::Sampler0 + stage));
if (tl != -1)
{
setUniform1i( IDriver::PixelProgram, tl, stage );
setUniform1i(IDriver::PixelProgram, tl, stage);
}
}
@ -972,15 +972,15 @@ void CDriverGL3::setupLightMapPass(uint pass)
*/
// Blend is different if the material is blended or not
if( !mat.getBlend() )
if (!mat.getBlend())
{
// Not blended, std case.
if(pass==0)
if (pass==0)
{
// no transparency for first pass.
_DriverGLStates.enableBlend(false);
}
else if(pass==1)
else if (pass==1)
{
// setup an Additive transparency (only for pass 1, will be kept for successives pass).
_DriverGLStates.enableBlend(true);
@ -1003,13 +1003,13 @@ void CDriverGL3::setupLightMapPass(uint pass)
finalResult= T*l1 * A + fint = T*l1 * A + T*l0 * A + B * (1-A)=
T* (l0+l1) * A + B * (1-A)
*/
if(pass==0)
if (pass==0)
{
// no transparency for first pass.
_DriverGLStates.enableBlend(true);
_DriverGLStates.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
else if(pass==1)
else if (pass==1)
{
// setup an Additive transparency (only for pass 1, will be kept for successives pass).
_DriverGLStates.enableBlend(true);
@ -1018,7 +1018,7 @@ void CDriverGL3::setupLightMapPass(uint pass)
}
// Dynamic lighting: The influence of the dynamic light must be added only in the first pass (only one time)
if(pass==0)
if (pass==0)
{
// If the lightmap is in x2 mode, then must divide effect of the dynamic light too
if (mat._LightMapsMulx2)
@ -1027,7 +1027,7 @@ void CDriverGL3::setupLightMapPass(uint pass)
_DriverGLStates.setDiffuse(packedColorWhite, glcolWhite);
}
// no need to reset for pass after 1, since same than prec pass (black)!
else if(pass==1)
else if (pass==1)
_DriverGLStates.setDiffuse(packedColorBlack, glcolBlack);
}
@ -1061,7 +1061,7 @@ void CDriverGL3::setupSpecularBegin()
H_AUTO_OGL(CDriverGL3_setupSpecularBegin)
// ---- Reset any textures with id>=2
uint stage = 2;
for(; stage < inlGetNumTextStages(); stage++)
for (; stage < inlGetNumTextStages(); stage++)
{
// disable texturing
activateTexture(stage, NULL);
@ -1109,7 +1109,7 @@ sint CDriverGL3::beginSpecularMultiPass()
// activate the 2 textures here
uint stage;
uint numStages= std::min((uint)2, inlGetNumTextStages());
for(stage=0 ; stage<numStages; stage++)
for (stage=0 ; stage<numStages; stage++)
{
ITexture *text= mat.getTexture(uint8(stage));
@ -1118,14 +1118,14 @@ sint CDriverGL3::beginSpecularMultiPass()
}
// End specular , only if not Batching mode.
if(!_SpecularBatchOn)
if (!_SpecularBatchOn)
setupSpecularBegin();
// Manage the rare case when the SpecularMap is not provided (fault of graphist).
if(mat.getTexture(1)==NULL)
if (mat.getTexture(1)==NULL)
return 1;
if(!_Extensions.ARBTextureCubeMap)
if (!_Extensions.ARBTextureCubeMap)
return 1;
return 1;
@ -1138,29 +1138,29 @@ void CDriverGL3::setupSpecularPass(uint pass)
const CMaterial &mat= *_CurrentMaterial;
// Manage the rare case when the SpecularMap is not provided (error of a graphist).
if(mat.getTexture(1)==NULL)
if (mat.getTexture(1)==NULL)
{
// Just display the texture
// NB: setupMaterial() code has correclty setuped textures.
return;
}
int sl0 = currentProgram.pp->getUniformIndex( CProgramIndex::Sampler0 );
if( sl0 != -1 )
int sl0 = currentProgram.pp->getUniformIndex(CProgramIndex::Sampler0);
if (sl0 != -1)
{
setUniform1i( IDriver::PixelProgram, sl0, 0 );
setUniform1i(IDriver::PixelProgram, sl0, 0);
}
int sl1 = currentProgram.pp->getUniformIndex( CProgramIndex::Sampler1 );
if( sl1 != -1 )
int sl1 = currentProgram.pp->getUniformIndex(CProgramIndex::Sampler1);
if (sl1 != -1)
{
setUniform1i( IDriver::PixelProgram, sl1, 1 );
setUniform1i(IDriver::PixelProgram, sl1, 1);
}
int tml = currentProgram.vp->getUniformIndex( CProgramIndex::TexMatrix0 );
if( tml != -1 )
int tml = currentProgram.vp->getUniformIndex(CProgramIndex::TexMatrix0);
if (tml != -1)
{
setUniform4x4f( IDriver::VertexProgram, tml, _UserTexMat[ 1 ] );
setUniform4x4f(IDriver::VertexProgram, tml, _UserTexMat[ 1 ]);
}
{
@ -1169,12 +1169,12 @@ void CDriverGL3::setupSpecularPass(uint pass)
// Set Stage 1
// Special: not the same special env if there is or not texture in stage 0.
CTexEnvSpecial newEnvStage1;
if( mat.getTexture(0) == NULL )
if (mat.getTexture(0) == NULL)
newEnvStage1= TexEnvSpecialSpecularStage1NoText;
else
newEnvStage1= TexEnvSpecialSpecularStage1;
// Test if same env as prec.
if(_CurrentTexEnvSpecial[1] != newEnvStage1)
if (_CurrentTexEnvSpecial[1] != newEnvStage1)
{
// TexEnv is special.
_CurrentTexEnvSpecial[1] = newEnvStage1;
@ -1190,7 +1190,7 @@ void CDriverGL3::endSpecularMultiPass()
{
H_AUTO_OGL(CDriverGL3_endSpecularMultiPass)
// End specular , only if not Batching mode.
if(!_SpecularBatchOn)
if (!_SpecularBatchOn)
setupSpecularEnd();
}
@ -1504,7 +1504,7 @@ void CDriverGL3::endCausticsMultiPass(const CMaterial &mat)
// ***************************************************************************
sint CDriverGL3::beginCloudMultiPass ()
{
H_AUTO_OGL(CDriverGL3_beginCloudMultiPass )
H_AUTO_OGL(CDriverGL3_beginCloudMultiPass)
nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud);
return 1;
}
@ -1512,7 +1512,7 @@ sint CDriverGL3::beginCloudMultiPass ()
// ***************************************************************************
void CDriverGL3::setupCloudPass (uint /* pass */)
{
H_AUTO_OGL(CDriverGL3_setupCloudPass )
H_AUTO_OGL(CDriverGL3_setupCloudPass)
nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud);
const CMaterial &mat= *_CurrentMaterial;

@ -28,12 +28,12 @@ void CDriverGL3::setFrustum(float left, float right, float bottom, float top, fl
{
H_AUTO_OGL(CDriverGL3_setFrustum);
if( perspective )
_GLProjMat.frustum( left, right, bottom, top, znear, zfar );
if (perspective)
_GLProjMat.frustum(left, right, bottom, top, znear, zfar);
else
_GLProjMat.ortho( left, right, bottom, top, znear, zfar );
_GLProjMat.ortho(left, right, bottom, top, znear, zfar);
_OODeltaZ = 1 / ( zfar - znear );
_OODeltaZ = 1 / (zfar - znear);
}

File diff suppressed because it is too large Load Diff

@ -33,7 +33,7 @@ bool CDriverGL3::renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines)
H_AUTO_OGL(CDriverGL3_renderLines)
// setup material
if ( !setupMaterial(mat) || _LastIB._Values == NULL )
if (!setupMaterial(mat) || _LastIB._Values == NULL)
return false;
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
@ -43,14 +43,14 @@ bool CDriverGL3::renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines)
uint nPass;
nPass= beginMultiPass();
// draw all passes.
for(uint pass=0;pass<nPass; pass++)
for (uint pass=0;pass<nPass; pass++)
{
// setup the pass.
if( !setupPass(pass) )
if (!setupPass(pass))
return false;
// draw the primitives.
if(nlines)
if (nlines)
{
if (_LastIB._Format == CIndexBuffer::Indices16)
{
@ -82,7 +82,7 @@ bool CDriverGL3::renderTriangles(CMaterial& mat, uint32 firstIndex, uint32 ntris
H_AUTO_OGL(CDriverGL3_renderTriangles);
// setup material
if ( !setupMaterial(mat) || _LastIB._Values == NULL )
if (!setupMaterial(mat) || _LastIB._Values == NULL)
return false;
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
@ -95,14 +95,14 @@ bool CDriverGL3::renderTriangles(CMaterial& mat, uint32 firstIndex, uint32 ntris
nPass= beginMultiPass();
// draw all passes.
for(uint pass=0;pass<nPass; pass++)
for (uint pass=0;pass<nPass; pass++)
{
// setup the pass.
if( !setupPass(pass) )
if (!setupPass(pass))
return false;
// draw the primitives.
if(ntris)
if (ntris)
{
if (_LastIB._Format == CIndexBuffer::Indices16)
{
@ -170,7 +170,7 @@ bool CDriverGL3::renderRawPoints(CMaterial& mat, uint32 startIndex, uint32 numPo
H_AUTO_OGL(CDriverGL3_renderRawPoints)
// setup material
if ( !setupMaterial(mat) )
if (!setupMaterial(mat))
return false;
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
@ -180,14 +180,14 @@ bool CDriverGL3::renderRawPoints(CMaterial& mat, uint32 startIndex, uint32 numPo
uint nPass;
nPass= beginMultiPass();
// draw all passes.
for(uint pass=0;pass<nPass; pass++)
for (uint pass=0;pass<nPass; pass++)
{
// setup the pass.
if( !setupPass(pass) )
if (!setupPass(pass))
return false;
// draw the primitives.
if(numPoints)
if (numPoints)
glDrawArrays(GL_POINTS, startIndex, numPoints);
}
// end multipass.
@ -210,7 +210,7 @@ bool CDriverGL3::renderRawLines(CMaterial& mat, uint32 startIndex, uint32 numLin
H_AUTO_OGL(CDriverGL3_renderRawLines)
// setup material
if ( !setupMaterial(mat) )
if (!setupMaterial(mat))
return false;
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
@ -220,14 +220,14 @@ bool CDriverGL3::renderRawLines(CMaterial& mat, uint32 startIndex, uint32 numLin
uint nPass;
nPass= beginMultiPass();
// draw all passes.
for(uint pass=0;pass<nPass; pass++)
for (uint pass=0;pass<nPass; pass++)
{
// setup the pass.
if( !setupPass(pass) )
if (!setupPass(pass))
return false;
// draw the primitives.
if(numLines)
if (numLines)
glDrawArrays(GL_LINES, startIndex << 1, numLines << 1);
}
// end multipass.
@ -250,7 +250,7 @@ bool CDriverGL3::renderRawTriangles(CMaterial& mat, uint32 startIndex, uint32 nu
H_AUTO_OGL(CDriverGL3_renderRawTriangles)
// setup material
if ( !setupMaterial(mat) )
if (!setupMaterial(mat))
return false;
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
@ -260,14 +260,14 @@ bool CDriverGL3::renderRawTriangles(CMaterial& mat, uint32 startIndex, uint32 nu
uint nPass;
nPass= beginMultiPass();
// draw all passes.
for(uint pass=0;pass<nPass; pass++)
for (uint pass=0;pass<nPass; pass++)
{
// setup the pass.
if( !setupPass(pass) )
if (!setupPass(pass))
return false;
// draw the primitives.
if(numTris)
if (numTris)
{
glDrawArrays(GL_TRIANGLES, startIndex*3, numTris*3);
}
@ -293,7 +293,7 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua
if (!numQuads) return true;
// setup material
if ( !setupMaterial(mat) )
if (!setupMaterial(mat))
return false;
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
@ -304,7 +304,7 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua
if (!init)
{
// setup the base index buffer
for(uint k = 0; k < QUAD_BATCH_SIZE; ++k)
for (uint k = 0; k < QUAD_BATCH_SIZE; ++k)
{
// first tri
defaultIndices[k * 6] = (GLshort) (k * 4);
@ -325,10 +325,10 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua
uint nPass;
nPass= beginMultiPass();
// draw all passes.
for(uint pass=0;pass<nPass; pass++)
for (uint pass=0;pass<nPass; pass++)
{
// setup the pass.
if( !setupPass(pass) )
if (!setupPass(pass))
return false;
uint32 currIndex = startIndex;
@ -367,7 +367,7 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua
*curr++ = vertexIndex + 3;
vertexIndex += 4;
}
while(curr != end);
while (curr != end);
glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_SHORT, indices);
}
else
@ -387,7 +387,7 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua
*curr++ = vertexIndex + 3;
vertexIndex += 4;
}
while(curr != end);
while (curr != end);
glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_INT, indices);
}
numLeftQuads -= numQuadsToDraw;

@ -28,26 +28,26 @@ namespace NL3D
clearCache();
}
SShaderPair CShaderCache::findShader( const CShaderDesc &desc ) const
SShaderPair CShaderCache::findShader(const CShaderDesc &desc) const
{
for( int i = 0; i < shaders.size(); i++ )
for (int i = 0; i < shaders.size(); i++)
{
if( shaders[ i ] == desc )
if (shaders[ i ] == desc)
return shaders[ i ].getShaders();
}
return SShaderPair();
}
void CShaderCache::cacheShader( CShaderDesc &desc )
void CShaderCache::cacheShader(CShaderDesc &desc)
{
shaders.push_back( desc );
shaders.push_back(desc);
}
void CShaderCache::clearCache()
{
std::vector< CShaderDesc >::iterator itr = shaders.begin();
while( itr != shaders.end() )
while (itr != shaders.end())
{
SShaderPair sp;
sp = itr->getShaders();

@ -31,10 +31,10 @@ namespace NL3D
~CShaderCache();
/// Checks if there's a shader cached that was generated from the specified descriptor
SShaderPair findShader( const CShaderDesc &desc ) const;
SShaderPair findShader(const CShaderDesc &desc) const;
/// Caches a shader with the specified descriptor as key
void cacheShader( CShaderDesc &desc );
void cacheShader(CShaderDesc &desc);
/// Clears the caches, removes the cached shaders
void clearCache();

@ -42,7 +42,7 @@ namespace NL3D
}
bool empty() const{
if( ( vp == NULL ) && ( pp == NULL ) )
if ((vp == NULL) && (pp == NULL))
return true;
else
return false;
@ -85,14 +85,14 @@ namespace NL3D
Spot
};
CShaderDesc(){
for( int i = 0; i < SHADER_MAX_TEXTURES; i++ )
CShaderDesc() {
for (int i = 0; i < SHADER_MAX_TEXTURES; i++)
texEnvMode[ i ] = 0;
for( int i = 0; i < SHADER_MAX_LIGHTS; i++ )
for (int i = 0; i < SHADER_MAX_LIGHTS; i++)
lightMode[ i ] = Nolight;
for( int i = 0; i < SHADER_MAX_TEXTURES; i++ )
for (int i = 0; i < SHADER_MAX_TEXTURES; i++)
useTextureStage[ i ] = false;
useFirstTextureCoordSet = false;
noTextures = true;
@ -106,100 +106,100 @@ namespace NL3D
pointLight = false;
}
~CShaderDesc(){
~CShaderDesc() {
}
bool operator==( const CShaderDesc &o ) const
bool operator==(const CShaderDesc &o) const
{
if( noTextures != o.noTextures )
if (noTextures != o.noTextures)
return false;
if( shaderType != o.shaderType )
if (shaderType != o.shaderType)
return false;
if( vbFlags != o.vbFlags )
if (vbFlags != o.vbFlags)
return false;
if( nlightmaps != o.nlightmaps )
if (nlightmaps != o.nlightmaps)
return false;
if( features != o.features )
if (features != o.features)
return false;
if( ( features & AlphaTest ) != 0 )
if ((features & AlphaTest) != 0)
{
if( alphaTestTreshold > o.alphaTestTreshold + 0.0001f )
if (alphaTestTreshold > o.alphaTestTreshold + 0.0001f)
return false;
if( alphaTestTreshold < o.alphaTestTreshold - 0.0001f )
if (alphaTestTreshold < o.alphaTestTreshold - 0.0001f)
return false;
}
if( fogEnabled() )
if (fogEnabled())
{
if( fogMode != o.fogMode )
if (fogMode != o.fogMode)
return false;
}
if( shaderType == Normal )
if (shaderType == Normal)
{
if( useFirstTextureCoordSet != o.useFirstTextureCoordSet )
if (useFirstTextureCoordSet != o.useFirstTextureCoordSet)
return false;
for( int i = 0; i < SHADER_MAX_TEXTURES; i++ )
if( texEnvMode[ i ] != o.texEnvMode[ i ] )
for (int i = 0; i < SHADER_MAX_TEXTURES; i++)
if (texEnvMode[ i ] != o.texEnvMode[ i ])
return false;
for( int i = 0; i < SHADER_MAX_TEXTURES; i++ )
if( useTextureStage[ i ] != o.useTextureStage[ i ] )
for (int i = 0; i < SHADER_MAX_TEXTURES; i++)
if (useTextureStage[ i ] != o.useTextureStage[ i ])
return false;
}
if( lightingEnabled() )
if (lightingEnabled())
{
for( int i = 0; i < SHADER_MAX_LIGHTS; i++ )
if( lightMode[ i ] != o.lightMode[ i ] )
for (int i = 0; i < SHADER_MAX_LIGHTS; i++)
if (lightMode[ i ] != o.lightMode[ i ])
return false;
}
return true;
}
void setTexEnvMode( uint32 index, uint32 mode ){ texEnvMode[ index ] = mode; }
void setTexEnvMode(uint32 index, uint32 mode) { texEnvMode[ index ] = mode; }
void setUseFirstTexCoords( bool b ){ useFirstTextureCoordSet = b; }
void setUseFirstTexCoords(bool b) { useFirstTextureCoordSet = b; }
bool getUseFirstTexCoords() const{ return useFirstTextureCoordSet; }
void setUseTexStage( uint8 stage, bool b ){ useTextureStage[ stage ] = b; }
bool getUseTexStage( uint8 stage ) const{ return useTextureStage[ stage ]; }
void setUseTexStage(uint8 stage, bool b) { useTextureStage[ stage ] = b; }
bool getUseTexStage(uint8 stage) const{ return useTextureStage[ stage ]; }
void setNoTextures( bool b ){ noTextures = b; }
void setNoTextures(bool b) { noTextures = b; }
bool useTextures() const{ return !noTextures; }
void setVBFlags( uint32 flags ){ vbFlags = flags; }
bool hasVBFlags( uint32 flags ) const{
if( ( vbFlags & flags ) != 0 )
void setVBFlags(uint32 flags) { vbFlags = flags; }
bool hasVBFlags(uint32 flags) const{
if ((vbFlags & flags) != 0)
return true;
else
return false;
}
void setShaderType( uint32 type ){ shaderType = type; }
void setNLightMaps( uint32 n ){ nlightmaps = n; }
void setShaderType(uint32 type) { shaderType = type; }
void setNLightMaps(uint32 n) { nlightmaps = n; }
void setAlphaTest( bool b )
void setAlphaTest(bool b)
{
if( b )
if (b)
features |= AlphaTest;
else
features &= ~AlphaTest;
}
void setAlphaTestThreshold( float t ){ alphaTestTreshold = t; }
void setAlphaTestThreshold(float t) { alphaTestTreshold = t; }
void setFog( bool b )
void setFog(bool b)
{
if( b )
if (b)
features |= Fog;
else
features &= ~Fog;
@ -207,19 +207,19 @@ namespace NL3D
bool fogEnabled() const
{
if( ( features & Fog ) != 0 )
if ((features & Fog) != 0)
return true;
else
return false;
}
void setFogMode( TFogMode mode ){ fogMode = mode; }
void setFogMode(TFogMode mode) { fogMode = mode; }
uint32 getFogMode() const{ return fogMode; }
void setLighting( bool b )
void setLighting(bool b)
{
if( b )
if (b)
features |= Lighting;
else
features &= ~Lighting;
@ -227,24 +227,24 @@ namespace NL3D
bool lightingEnabled() const
{
if( ( features & Lighting ) != 0 )
if ((features & Lighting) != 0)
return true;
else
return false;
}
void setLight( int idx, TLightMode mode )
void setLight(int idx, TLightMode mode)
{
lightMode[ idx ] = mode;
if( mode == Point )
if (mode == Point)
pointLight = true;
}
TLightMode getLight( int idx ) const{ return lightMode[ idx ]; }
TLightMode getLight(int idx) const{ return lightMode[ idx ]; }
bool hasPointLight() const{ return pointLight; }
void setShaders( SShaderPair sp ){ shaderPair = sp; }
void setShaders(SShaderPair sp) { shaderPair = sp; }
SShaderPair getShaders() const{ return shaderPair; }
private:

@ -58,11 +58,11 @@ void CDriverGLStates3::init(bool supportTextureCubeMap, bool supportTextureRec
_ColorArrayEnabled= false;
_SecondaryColorArrayEnabled= false;
uint i;
for(i=0; i<sizeof(_TexCoordArrayEnabled)/sizeof(_TexCoordArrayEnabled[0]); i++)
for (i=0; i<sizeof(_TexCoordArrayEnabled)/sizeof(_TexCoordArrayEnabled[0]); i++)
{
_TexCoordArrayEnabled[i]= false;
}
for(i=0; i<CVertexBuffer::NumValue; i++)
for (i=0; i<CVertexBuffer::NumValue; i++)
{
_VertexAttribArrayEnabled[i]= false;
}
@ -70,7 +70,7 @@ void CDriverGLStates3::init(bool supportTextureCubeMap, bool supportTextureRec
_DepthRangeFar = 1.f;
_ZBias = 0.f;
// by default all lights are disabled (not reseted in forceDefaults)
for(i=0; i<MaxLight; i++)
for (i=0; i<MaxLight; i++)
{
_CurLight[i]= false;
}
@ -140,13 +140,13 @@ void CDriverGLStates3::forceDefaults(uint nbStages)
// TexModes
uint stage;
for(stage=0;stage<nbStages; stage++)
for (stage=0;stage<nbStages; stage++)
{
// disable texturing.
nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
glDisable(GL_TEXTURE_2D);
if(_TextureCubeMapSupported)
if (_TextureCubeMapSupported)
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
_TextureMode[stage]= TextureDisabled;
@ -154,7 +154,7 @@ void CDriverGLStates3::forceDefaults(uint nbStages)
// Tex gen init
_TexGenMode[stage] = 0;
if(_TextureRectangleSupported)
if (_TextureRectangleSupported)
glDisable(GL_TEXTURE_RECTANGLE_NV);
glDisable(GL_TEXTURE_GEN_S);
@ -189,13 +189,13 @@ void CDriverGLStates3::enableBlend(uint enable)
// If different from current setup, update.
bool enabled= (enable!=0);
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( enabled != _CurBlend )
if (enabled != _CurBlend)
#endif
{
// new state.
_CurBlend= enabled;
// Setup GLState.
if(_CurBlend)
if (_CurBlend)
glEnable(GL_BLEND);
else
glDisable(GL_BLEND);
@ -209,13 +209,13 @@ void CDriverGLStates3::enableCullFace(uint enable)
// If different from current setup, update.
bool enabled= (enable!=0);
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( enabled != _CurCullFace )
if (enabled != _CurCullFace)
#endif
{
// new state.
_CurCullFace= enabled;
// Setup GLState.
if(_CurCullFace)
if (_CurCullFace)
glEnable(GL_CULL_FACE);
else
glDisable(GL_CULL_FACE);
@ -229,14 +229,14 @@ void CDriverGLStates3::enableAlphaTest(uint enable)
// If different from current setup, update.
bool enabled= (enable!=0);
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( enabled != _CurAlphaTest )
if (enabled != _CurAlphaTest)
#endif
{
// new state.
_CurAlphaTest= enabled;
// Setup GLState.
if(_CurAlphaTest)
if (_CurAlphaTest)
{
glEnable(GL_ALPHA_TEST);
}
@ -256,7 +256,7 @@ void CDriverGLStates3::enableLighting(uint enable)
// If different from current setup, update.
bool enabled= (enable!=0);
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( enabled != _CurLighting )
if (enabled != _CurLighting)
#endif
{
// new state.
@ -268,13 +268,13 @@ void CDriverGLStates3::enableLighting(uint enable)
void CDriverGLStates3::enableLight(uint num, uint enable)
{
H_AUTO_OGL(CDriverGLStates3_enableLight)
if(num>=_MaxDriverLight)
if (num>=_MaxDriverLight)
return;
// If different from current setup, update.
bool enabled= (enable!=0);
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( enabled != _CurLight[num] )
if (enabled != _CurLight[num])
#endif
{
// new state.
@ -286,7 +286,7 @@ void CDriverGLStates3::enableLight(uint num, uint enable)
bool CDriverGLStates3::isLightEnabled(uint num) const
{
H_AUTO_OGL(CDriverGLStates3_isLightEnabled)
if(num>=_MaxDriverLight)
if (num>=_MaxDriverLight)
return false;
else
return _CurLight[num];
@ -300,13 +300,13 @@ void CDriverGLStates3::enableZWrite(uint enable)
// If different from current setup, update.
bool enabled= (enable!=0);
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( enabled != _CurZWrite )
if (enabled != _CurZWrite)
#endif
{
// new state.
_CurZWrite= enabled;
// Setup GLState.
if(_CurZWrite)
if (_CurZWrite)
glDepthMask(GL_TRUE);
else
glDepthMask(GL_FALSE);
@ -321,13 +321,13 @@ void CDriverGLStates3::enableStencilTest(bool enable)
// If different from current setup, update.
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( enable != _CurStencilTest )
if (enable != _CurStencilTest)
#endif
{
// new state.
_CurStencilTest= enable;
// Setup GLState.
if(_CurStencilTest)
if (_CurStencilTest)
glEnable(GL_STENCIL_TEST);
else
glDisable(GL_STENCIL_TEST);
@ -341,14 +341,14 @@ void CDriverGLStates3::enableMultisample(bool enable)
// If different from current setup, update.
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( enable != _CurMultisample )
if (enable != _CurMultisample)
#endif
{
// new state.
_CurMultisample= enable;
// Setup GLState.
if(_CurMultisample)
if (_CurMultisample)
glEnable(GL_MULTISAMPLE_ARB);
else
glDisable(GL_MULTISAMPLE_ARB);
@ -361,7 +361,7 @@ void CDriverGLStates3::blendFunc(GLenum src, GLenum dst)
H_AUTO_OGL(CDriverGLStates3_blendFunc)
// If different from current setup, update.
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( src!= _CurBlendSrc || dst!=_CurBlendDst )
if (src!= _CurBlendSrc || dst!=_CurBlendDst)
#endif
{
// new state.
@ -378,7 +378,7 @@ void CDriverGLStates3::depthFunc(GLenum zcomp)
H_AUTO_OGL(CDriverGLStates3_depthFunc)
// If different from current setup, update.
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( zcomp != _CurDepthFunc )
if (zcomp != _CurDepthFunc)
#endif
{
// new state.
@ -394,7 +394,7 @@ void CDriverGLStates3::alphaFunc(float threshold)
{
H_AUTO_OGL(CDriverGLStates3_alphaFunc)
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if(threshold != _CurAlphaTestThreshold)
if (threshold != _CurAlphaTestThreshold)
#endif
{
// new state
@ -408,7 +408,7 @@ void CDriverGLStates3::stencilFunc(GLenum func, GLint ref, GLuint mask)
{
H_AUTO_OGL(CDriverGLStates3_stencilFunc)
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if((func!=_CurStencilFunc) || (ref!=_CurStencilRef) || (mask!=_CurStencilMask))
if ((func!=_CurStencilFunc) || (ref!=_CurStencilRef) || (mask!=_CurStencilMask))
#endif
{
// new state
@ -427,7 +427,7 @@ void CDriverGLStates3::stencilOp(GLenum fail, GLenum zfail, GLenum zpass)
{
H_AUTO_OGL(CDriverGLStates3_stencilOp)
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if((fail!=_CurStencilOpFail) || (zfail!=_CurStencilOpZFail) || (zpass!=_CurStencilOpZPass))
if ((fail!=_CurStencilOpFail) || (zfail!=_CurStencilOpZFail) || (zpass!=_CurStencilOpZPass))
#endif
{
// new state
@ -445,7 +445,7 @@ void CDriverGLStates3::stencilMask(GLuint mask)
{
H_AUTO_OGL(CDriverGLStates3_stencilMask)
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if(mask!=_CurStencilWriteMask)
if (mask!=_CurStencilWriteMask)
#endif
{
// new state
@ -462,7 +462,7 @@ void CDriverGLStates3::setEmissive(uint32 packedColor, const GLfloat color[4])
{
H_AUTO_OGL(CDriverGLStates3_setEmissive)
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( packedColor!=_CurEmissive )
if (packedColor!=_CurEmissive)
#endif
{
_CurEmissive= packedColor;
@ -474,7 +474,7 @@ void CDriverGLStates3::setAmbient(uint32 packedColor, const GLfloat color[4])
{
H_AUTO_OGL(CDriverGLStates3_setAmbient)
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( packedColor!=_CurAmbient )
if (packedColor!=_CurAmbient)
#endif
{
_CurAmbient= packedColor;
@ -486,7 +486,7 @@ void CDriverGLStates3::setDiffuse(uint32 packedColor, const GLfloat color[4])
{
H_AUTO_OGL(CDriverGLStates3_setDiffuse)
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( packedColor!=_CurDiffuse )
if (packedColor!=_CurDiffuse)
#endif
{
_CurDiffuse= packedColor;
@ -498,7 +498,7 @@ void CDriverGLStates3::setSpecular(uint32 packedColor, const GLfloat color[4])
{
H_AUTO_OGL(CDriverGLStates3_setSpecular)
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( packedColor!=_CurSpecular )
if (packedColor!=_CurSpecular)
#endif
{
_CurSpecular= packedColor;
@ -510,7 +510,7 @@ void CDriverGLStates3::setShininess(float shin)
{
H_AUTO_OGL(CDriverGLStates3_setShininess)
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( shin != _CurShininess )
if (shin != _CurShininess)
#endif
{
_CurShininess= shin;
@ -534,7 +534,7 @@ void CDriverGLStates3::setVertexColorLighted(bool enable)
{
H_AUTO_OGL(CDriverGLStates3_setVertexColorLighted)
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( enable != _VertexColorLighted)
if (enable != _VertexColorLighted)
#endif
{
_VertexColorLighted= enable;
@ -609,7 +609,7 @@ void CDriverGLStates3::setTextureMode(TTextureMode texMode)
{
H_AUTO_OGL(CDriverGLStates3_setTextureMode)
TTextureMode oldTexMode = _TextureMode[_CurrentActiveTextureARB];
if(oldTexMode != texMode)
if (oldTexMode != texMode)
{
// new mode.
@ -623,7 +623,7 @@ void CDriverGLStates3::activeTextureARB(uint stage)
{
H_AUTO_OGL(CDriverGLStates3_activeTextureARB);
if( _CurrentActiveTextureARB != stage )
if (_CurrentActiveTextureARB != stage)
{
nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
@ -647,10 +647,10 @@ void CDriverGLStates3::enableVertexAttribArrayARB(uint glIndex,bool enable)
H_AUTO_OGL(CDriverGLStates3_enableVertexAttribArrayARB);
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if(_VertexAttribArrayEnabled[glIndex] != enable)
if (_VertexAttribArrayEnabled[glIndex] != enable)
#endif
{
if( enable )
if (enable)
nglEnableVertexAttribArray(glIndex);
else
nglDisableVertexAttribArray(glIndex);
@ -667,7 +667,7 @@ void CDriverGLStates3::enableFog(uint enable)
// If different from current setup, update.
bool enabled= (enable!=0);
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if( enabled != _CurFog )
if (enabled != _CurFog)
#endif
{
// new state.

@ -85,13 +85,13 @@ CTextureDrvInfosGL3::~CTextureDrvInfosGL3()
// release in TextureUsed.
_Driver->_TextureUsed.erase (this);
if(InitFBO)
if (InitFBO)
{
nglDeleteFramebuffersEXT(1, &FBOId);
if(AttachDepthStencil)
if (AttachDepthStencil)
{
nglDeleteRenderbuffersEXT(1, &DepthFBOId);
if(!UsePackedDepthStencil)
if (!UsePackedDepthStencil)
nglDeleteRenderbuffersEXT(1, &StencilFBOId);
}
}
@ -100,19 +100,19 @@ CTextureDrvInfosGL3::~CTextureDrvInfosGL3()
// ***************************************************************************
bool CTextureDrvInfosGL3::initFrameBufferObject(ITexture * tex)
{
if(!InitFBO)
if (!InitFBO)
{
if(tex->isBloomTexture())
if (tex->isBloomTexture())
{
AttachDepthStencil = !((CTextureBloom*)tex)->isMode2D();
}
// generate IDs
nglGenFramebuffersEXT(1, &FBOId);
if(AttachDepthStencil)
if (AttachDepthStencil)
{
nglGenRenderbuffersEXT(1, &DepthFBOId);
if(UsePackedDepthStencil)
if (UsePackedDepthStencil)
StencilFBOId = DepthFBOId;
else
nglGenRenderbuffersEXT(1, &StencilFBOId);
@ -130,9 +130,9 @@ bool CTextureDrvInfosGL3::initFrameBufferObject(ITexture * tex)
// opengl.org extension registry). Until a safe approach to add
// them is found, there will be no attached stencil for the time
// being, aside of using packed depth+stencil buffers.
if(AttachDepthStencil)
if (AttachDepthStencil)
{
if(UsePackedDepthStencil)
if (UsePackedDepthStencil)
{
//nldebug("3D: using packed depth stencil");
nglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, StencilFBOId);
@ -264,7 +264,7 @@ bool CTextureDrvInfosGL3::initFrameBufferObject(ITexture * tex)
{
nglDeleteRenderbuffersEXT(1, &DepthFBOId);
if(!UsePackedDepthStencil)
if (!UsePackedDepthStencil)
nglDeleteRenderbuffersEXT(1, &StencilFBOId);
}
}
@ -277,9 +277,9 @@ bool CTextureDrvInfosGL3::initFrameBufferObject(ITexture * tex)
// ***************************************************************************
bool CTextureDrvInfosGL3::activeFrameBufferObject(ITexture * tex)
{
if(tex)
if (tex)
{
if(initFrameBufferObject(tex))
if (initFrameBufferObject(tex))
{
glBindTexture(TextureMode, 0);
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBOId);
@ -313,12 +313,12 @@ GLint CDriverGL3::getGlTextureFormat(ITexture& tex, bool &compressed)
ITexture::TUploadFormat texfmt= tex.getUploadFormat();
// If auto, retrieve the pixel format of the bitmap.
if(texfmt== ITexture::Auto)
if (texfmt== ITexture::Auto)
{
switch(tex.getPixelFormat())
{
case CBitmap::RGBA:
if(_ForceDXTCCompression && tex.allowDegradation() )
if (_ForceDXTCCompression && tex.allowDegradation())
texfmt= ITexture::DXTC5;
else
texfmt= ITexture::RGBA8888;
@ -336,7 +336,7 @@ GLint CDriverGL3::getGlTextureFormat(ITexture& tex, bool &compressed)
}
// Get gl tex format, try S3TC compressed ones.
if(_Extensions.EXTTextureCompressionS3TC)
if (_Extensions.EXTTextureCompressionS3TC)
{
compressed= true;
// Try Compressed ones.
@ -402,7 +402,7 @@ static GLint getGlSrcTextureFormat(ITexture &tex, GLint glfmt)
}
}
if( glfmt == GL_RG8 )
if (glfmt == GL_RG8)
return GL_RG;
// Else, not a Src format for upload, or RGBA.
@ -410,11 +410,11 @@ static GLint getGlSrcTextureFormat(ITexture &tex, GLint glfmt)
}
// ***************************************************************************
static GLenum getGlSrcTextureComponentType( ITexture &tex, GLint texSrcFormat)
static GLenum getGlSrcTextureComponentType(ITexture &tex, GLint texSrcFormat)
{
H_AUTO_OGL(getGlSrcTextureComponentType);
if( tex.getPixelFormat() == CBitmap::DsDt )
if (tex.getPixelFormat() == CBitmap::DsDt)
return GL_BYTE;
return GL_UNSIGNED_BYTE;
@ -495,7 +495,7 @@ uint CDriverGL3::computeMipMapMemoryUsage(uint w, uint h, GLint glfmt) const
static inline GLenum translateWrapToGl(ITexture::TWrapMode mode, const CGlExtensions &extensions)
{
H_AUTO_OGL(translateWrapToGl)
if(mode== ITexture::Repeat)
if (mode== ITexture::Repeat)
return GL_REPEAT;
return GL_CLAMP_TO_EDGE;
@ -529,7 +529,7 @@ static inline GLenum translateMinFilterToGl(CTextureDrvInfosGL3 *glText)
return GL_NEAREST;
#else // NEL_FORCE_NEAREST
if(glText->MipMap)
if (glText->MipMap)
{
switch(glText->MinFilter)
{
@ -569,22 +569,22 @@ static inline bool sameDXTCFormat(ITexture &tex, GLint glfmt)
H_AUTO_OGL(sameDXTCFormat);
#ifdef GL_COMPRESSED_RGB_S3TC_DXT1_EXT
if(glfmt==GL_COMPRESSED_RGB_S3TC_DXT1_EXT && tex.PixelFormat==CBitmap::DXTC1)
if (glfmt==GL_COMPRESSED_RGB_S3TC_DXT1_EXT && tex.PixelFormat==CBitmap::DXTC1)
return true;
#endif
#ifdef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
if(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT && tex.PixelFormat==CBitmap::DXTC1Alpha)
if (glfmt==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT && tex.PixelFormat==CBitmap::DXTC1Alpha)
return true;
#endif
#ifdef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
if(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT3_EXT && tex.PixelFormat==CBitmap::DXTC3)
if (glfmt==GL_COMPRESSED_RGBA_S3TC_DXT3_EXT && tex.PixelFormat==CBitmap::DXTC3)
return true;
#endif
#ifdef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
if(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT5_EXT && tex.PixelFormat==CBitmap::DXTC5)
if (glfmt==GL_COMPRESSED_RGBA_S3TC_DXT5_EXT && tex.PixelFormat==CBitmap::DXTC5)
return true;
#endif
@ -597,22 +597,22 @@ static inline bool isDXTCFormat(GLint glfmt)
H_AUTO_OGL(isDXTCFormat);
#ifdef GL_COMPRESSED_RGB_S3TC_DXT1_EXT
if(glfmt==GL_COMPRESSED_RGB_S3TC_DXT1_EXT)
if (glfmt==GL_COMPRESSED_RGB_S3TC_DXT1_EXT)
return true;
#endif
#ifdef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
if(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)
if (glfmt==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)
return true;
#endif
#ifdef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
if(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT3_EXT)
if (glfmt==GL_COMPRESSED_RGBA_S3TC_DXT3_EXT)
return true;
#endif
#ifdef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
if(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)
if (glfmt==GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)
return true;
#endif
@ -637,7 +637,7 @@ void CDriverGL3::bindTextureWithMode(ITexture &tex)
gltext= getTextureGl(tex);
// system of "backup the previous binded texture" seems to not work with some drivers....
_DriverGLStates.activeTextureARB(0);
if(tex.isTextureCube())
if (tex.isTextureCube())
{
if (_Extensions.ARBTextureCubeMap)
{
@ -650,7 +650,7 @@ void CDriverGL3::bindTextureWithMode(ITexture &tex)
{
CDriverGLStates3::TTextureMode textureMode= CDriverGLStates3::Texture2D;
if(gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV)
if (gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV)
textureMode = CDriverGLStates3::TextureRect;
_DriverGLStates.setTextureMode(textureMode);
@ -673,7 +673,7 @@ void CDriverGL3::setupTextureBasicParameters(ITexture &tex)
gltext->WrapT= tex.getWrapT();
gltext->MagFilter= tex.getMagFilter();
gltext->MinFilter= tex.getMinFilter();
if(tex.isTextureCube())
if (tex.isTextureCube())
{
if (_Extensions.ARBTextureCubeMap)
{
@ -708,13 +708,13 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
//nldebug("3D: CDriverGL3::setupTextureEx(%016p, %d, %d, %d)", &tex, bUpload, bAllUploaded, bMustRecreateSharedTexture);
bAllUploaded = false;
if(tex.isTextureCube() && (!_Extensions.ARBTextureCubeMap))
if (tex.isTextureCube() && (!_Extensions.ARBTextureCubeMap))
return true;
// 0. Create/Retrieve the driver texture.
//=======================================
bool mustCreate = false;
if ( !tex.TextureDrvShare )
if (!tex.TextureDrvShare)
{
//nldebug("3D: creating CTextureDrvShare()");
// insert into driver list. (so it is deleted when driver is deleted).
@ -727,7 +727,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
}
// Does the texture has been touched ?
if ( (!tex.touched()) && (!mustCreate) )
if ((!tex.touched()) && (!mustCreate))
{
// if wrap mode or filter mode is touched, update it here
if (tex.filterOrWrapModeTouched())
@ -758,14 +758,14 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
But this is grave only if a new texture is created, with the same pointer (bad luck).
Since an newly allocated texture always pass here before use, we are sure to avoid any problems.
*/
for(uint stage = 0; stage < inlGetNumTextStages(); stage++)
for (uint stage = 0; stage < inlGetNumTextStages(); stage++)
{
activateTexture(stage, NULL);
}
// A. Share mgt.
//==============
if(tex.supportSharing())
if (tex.supportSharing())
{
// Try to get the shared texture.
@ -782,7 +782,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
itTex= rTexDrvInfos.find(name);
// texture not found?
if( itTex==rTexDrvInfos.end() )
if (itTex==rTexDrvInfos.end())
{
// insert into driver map. (so it is deleted when driver is deleted).
itTex= (rTexDrvInfos.insert(make_pair(name, (ITextureDrvInfos*)NULL))).first;
@ -796,7 +796,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
{
tex.TextureDrvShare->DrvTexture= itTex->second;
if(bMustRecreateSharedTexture)
if (bMustRecreateSharedTexture)
// reload this shared texture (user request)
mustLoadAll= true;
else
@ -811,7 +811,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
else
{
// If texture not already created.
if(!tex.TextureDrvShare->DrvTexture)
if (!tex.TextureDrvShare->DrvTexture)
{
// Must create it. Create auto a GL id (in constructor).
// Do not insert into the map. This un-shared texture will be deleted at deletion of the texture.
@ -821,15 +821,15 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
// need to load ALL this texture.
mustLoadAll= true;
}
else if(tex.isAllInvalidated())
else if (tex.isAllInvalidated())
mustLoadAll= true;
else if(tex.touched())
else if (tex.touched())
mustLoadPart= true;
}
// B. Setup texture.
//==================
if(mustLoadAll || mustLoadPart)
if (mustLoadAll || mustLoadPart)
{
// system of "backup the previous binded texture" seems to not work with some drivers....
bindTextureWithMode(tex);
@ -848,30 +848,30 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
gltext->TextureMemory= 0;
if(tex.isTextureCube())
if (tex.isTextureCube())
{
CTextureCube *pTC = NLMISC::safe_cast<CTextureCube *>(&tex);
// Regenerate all the texture.
tex.generate();
for(uint nText = 0; nText < 6; ++nText)
if(pTC->getTexture((CTextureCube::TFace)nText) != NULL)
for (uint nText = 0; nText < 6; ++nText)
if (pTC->getTexture((CTextureCube::TFace)nText) != NULL)
{
ITexture *pTInTC = pTC->getTexture((CTextureCube::TFace)nText);
// In open GL, we have to flip the faces of the cube map
if( ((CTextureCube::TFace)nText) == CTextureCube::positive_x )
if (((CTextureCube::TFace)nText) == CTextureCube::positive_x)
pTInTC->flipH();
if( ((CTextureCube::TFace)nText) == CTextureCube::negative_x )
if (((CTextureCube::TFace)nText) == CTextureCube::negative_x)
pTInTC->flipH();
if( ((CTextureCube::TFace)nText) == CTextureCube::positive_y )
if (((CTextureCube::TFace)nText) == CTextureCube::positive_y)
pTInTC->flipH();
if( ((CTextureCube::TFace)nText) == CTextureCube::negative_y )
if (((CTextureCube::TFace)nText) == CTextureCube::negative_y)
pTInTC->flipH();
if( ((CTextureCube::TFace)nText) == CTextureCube::positive_z )
if (((CTextureCube::TFace)nText) == CTextureCube::positive_z)
pTInTC->flipV();
if( ((CTextureCube::TFace)nText) == CTextureCube::negative_z )
if (((CTextureCube::TFace)nText) == CTextureCube::negative_z)
pTInTC->flipV();
// Get the correct texture format from texture...
@ -880,9 +880,9 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
GLenum glSrcType= getGlSrcTextureComponentType(*pTInTC,glSrcFmt);
sint nMipMaps;
if(glSrcFmt==GL_RGBA && pTInTC->getPixelFormat()!=CBitmap::RGBA )
if (glSrcFmt==GL_RGBA && pTInTC->getPixelFormat()!=CBitmap::RGBA)
pTInTC->convertToType(CBitmap::RGBA);
if(tex.mipMapOn())
if (tex.mipMapOn())
{
pTInTC->buildMipMaps();
nMipMaps= pTInTC->getMipMapCount();
@ -894,7 +894,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
gltext->MipMap= nMipMaps>1;
// Fill mipmaps.
for(sint i=0;i<nMipMaps;i++)
for (sint i=0;i<nMipMaps;i++)
{
void *ptr= pTInTC->getPixels(i).getPtr();
uint w= pTInTC->getWidth(i);
@ -922,7 +922,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
// Regenerate all the texture.
tex.generate();
if(tex.getSize()>0)
if (tex.getSize()>0)
{
// Get the correct texture format from texture...
GLint glfmt= getGlTextureFormat(tex, gltext->Compressed);
@ -931,11 +931,11 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
// DXTC: if same format, and same mipmapOn/Off, use glTexCompressedImage*.
// We cannot build the mipmaps if they are not here.
if(_Extensions.EXTTextureCompressionS3TC && sameDXTCFormat(tex, glfmt))
if (_Extensions.EXTTextureCompressionS3TC && sameDXTCFormat(tex, glfmt))
{
sint nMipMaps = 1;
if(tex.mipMapOn())
if (tex.mipMapOn())
nMipMaps= tex.getMipMapCount();
// MipMap upload?
@ -944,13 +944,13 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
// Degradation in Size allowed only if DXTC texture are provided with mipmaps.
// Because use them to resize !!!
uint decalMipMapResize= 0;
if(_ForceTextureResizePower>0 && tex.allowDegradation() && nMipMaps>1)
if (_ForceTextureResizePower>0 && tex.allowDegradation() && nMipMaps>1)
{
decalMipMapResize= min(_ForceTextureResizePower, (uint)(nMipMaps-1));
}
// Fill mipmaps.
for(sint i=decalMipMapResize;i<nMipMaps;i++)
for (sint i=decalMipMapResize;i<nMipMaps;i++)
{
void *ptr= tex.getPixels(i).getPtr();
sint size= tex.getPixels(i).size();
@ -978,14 +978,14 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
else
{
sint nMipMaps;
if(glSrcFmt==GL_RGBA && tex.getPixelFormat()!=CBitmap::RGBA )
if (glSrcFmt==GL_RGBA && tex.getPixelFormat()!=CBitmap::RGBA)
{
bUpload = true; // Force all upload
tex.convertToType(CBitmap::RGBA);
}
// Degradation in Size.
if(_ForceTextureResizePower>0 && tex.allowDegradation())
if (_ForceTextureResizePower>0 && tex.allowDegradation())
{
uint w= tex.getWidth(0) >> _ForceTextureResizePower;
uint h= tex.getHeight(0) >> _ForceTextureResizePower;
@ -994,7 +994,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
tex.resample(w, h);
}
if(tex.mipMapOn())
if (tex.mipMapOn())
{
tex.buildMipMaps();
nMipMaps= tex.getMipMapCount();
@ -1006,7 +1006,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
gltext->MipMap= nMipMaps>1;
// Fill mipmaps.
for(sint i=0;i<nMipMaps;i++)
for (sint i=0;i<nMipMaps;i++)
{
void *ptr= tex.getPixels(i).getPtr();
uint w= tex.getWidth(i);
@ -1044,7 +1044,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
// Regenerate wanted part of the texture.
tex.generate();
if(tex.getSize()>0)
if (tex.getSize()>0)
{
// Get the correct texture format from texture...
//===============================================
@ -1054,15 +1054,15 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
GLenum glSrcType= getGlSrcTextureComponentType(tex,glSrcFmt);
sint nMipMaps;
if(glSrcFmt==GL_RGBA && tex.getPixelFormat()!=CBitmap::RGBA )
if (glSrcFmt==GL_RGBA && tex.getPixelFormat()!=CBitmap::RGBA)
tex.convertToType(CBitmap::RGBA);
if(tex.mipMapOn())
if (tex.mipMapOn())
{
bool hadMipMap= tex.getMipMapCount()>1;
tex.buildMipMaps();
nMipMaps= tex.getMipMapCount();
// If the texture had no mipmap before, release them.
if(!hadMipMap)
if (!hadMipMap)
{
tex.releaseMipMaps();
}
@ -1073,7 +1073,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
// For all rect, update the texture/mipmap.
//===============================================
list<NLMISC::CRect>::iterator itRect;
for(itRect=tex._ListInvalidRect.begin(); itRect!=tex._ListInvalidRect.end(); itRect++)
for (itRect=tex._ListInvalidRect.begin(); itRect!=tex._ListInvalidRect.end(); itRect++)
{
CRect &rect= *itRect;
sint x0= rect.X;
@ -1082,7 +1082,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
sint y1= rect.Y+rect.Height;
// Fill mipmaps.
for(sint i=0;i<nMipMaps;i++)
for (sint i=0;i<nMipMaps;i++)
{
void *ptr= tex.getPixels(i).getPtr();
sint w= tex.getWidth(i);
@ -1118,7 +1118,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
}
// Release, if wanted.
if(tex.getReleasable())
if (tex.getReleasable())
tex.release();
// Basic parameters.
@ -1169,7 +1169,7 @@ bool CDriverGL3::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap)
_DriverGLStates.activeTextureARB (0);
CDriverGLStates3::TTextureMode textureMode= CDriverGLStates3::Texture2D;
if(gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV)
if (gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV)
textureMode = CDriverGLStates3::TextureRect;
_DriverGLStates.setTextureMode (textureMode);
@ -1229,7 +1229,7 @@ bool CDriverGL3::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap)
{
nglCompressedTexSubImage2DARB (
GL_TEXTURE_2D, nNumMipMap-decalMipMapResize,
x0, y0, (x1-x0), (y1-y0), glfmt, imageSize, ptr );
x0, y0, (x1-x0), (y1-y0), glfmt, imageSize, ptr);
}
else
{
@ -1287,7 +1287,7 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex)
if (this->_CurrentTexture[stage]!=tex)
{
_DriverGLStates.activeTextureARB(stage);
if(tex && tex->TextureDrvShare)
if (tex && tex->TextureDrvShare)
{
// get the drv info. should be not NULL.
CTextureDrvInfosGL3* gltext;
@ -1301,18 +1301,18 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex)
_TextureUsed.insert (gltext);
}
if(tex->isTextureCube())
if (tex->isTextureCube())
{
// setup texture mode, after activeTextureARB()
_DriverGLStates.setTextureMode(CDriverGLStates3::TextureCubeMap);
if(_Extensions.ARBTextureCubeMap)
if (_Extensions.ARBTextureCubeMap)
{
// Activate texturing...
//======================
// If the shared texture is the same than before, no op.
if(_CurrentTextureInfoGL[stage] != gltext)
if (_CurrentTextureInfoGL[stage] != gltext)
{
// Cache setup.
_CurrentTextureInfoGL[stage]= gltext;
@ -1322,12 +1322,12 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex)
// Change parameters of texture, if necessary.
//============================================
if(gltext->MagFilter!= tex->getMagFilter())
if (gltext->MagFilter!= tex->getMagFilter())
{
gltext->MagFilter= tex->getMagFilter();
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext));
}
if(gltext->MinFilter!= tex->getMinFilter())
if (gltext->MinFilter!= tex->getMinFilter())
{
gltext->MinFilter= tex->getMinFilter();
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext));
@ -1339,7 +1339,7 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex)
{
// setup texture mode, after activeTextureARB()
CDriverGLStates3::TTextureMode textureMode= CDriverGLStates3::Texture2D;
if(gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV)
if (gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV)
textureMode = CDriverGLStates3::TextureRect;
_DriverGLStates.setTextureMode(/*CDriverGLStates3::Texture2D*/textureMode);
@ -1347,7 +1347,7 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex)
//======================
// If the shared texture is the same than before, no op.
if(_CurrentTextureInfoGL[stage] != gltext)
if (_CurrentTextureInfoGL[stage] != gltext)
{
// Cache setup.
_CurrentTextureInfoGL[stage]= gltext;
@ -1358,22 +1358,22 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex)
// Change parameters of texture, if necessary.
//============================================
if(gltext->WrapS!= tex->getWrapS())
if (gltext->WrapS!= tex->getWrapS())
{
gltext->WrapS= tex->getWrapS();
glTexParameteri(gltext->TextureMode,GL_TEXTURE_WRAP_S, translateWrapToGl(gltext->WrapS, _Extensions));
}
if(gltext->WrapT!= tex->getWrapT())
if (gltext->WrapT!= tex->getWrapT())
{
gltext->WrapT= tex->getWrapT();
glTexParameteri(gltext->TextureMode,GL_TEXTURE_WRAP_T, translateWrapToGl(gltext->WrapT, _Extensions));
}
if(gltext->MagFilter!= tex->getMagFilter())
if (gltext->MagFilter!= tex->getMagFilter())
{
gltext->MagFilter= tex->getMagFilter();
glTexParameteri(gltext->TextureMode,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext));
}
if(gltext->MinFilter!= tex->getMinFilter())
if (gltext->MinFilter!= tex->getMinFilter())
{
gltext->MinFilter= tex->getMinFilter();
glTexParameteri(gltext->TextureMode,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext));
@ -1440,7 +1440,7 @@ void CDriverGL3::activateTexEnvMode(uint stage, const CMaterial::CTexEnv &env)
H_AUTO_OGL(CDriverGL3_activateTexEnvMode)
// If a special Texture environnement is setuped, or if not the same normal texture environnement,
// must setup a new normal Texture environnement.
if(_CurrentTexEnvSpecial[stage] != TexEnvSpecialDisabled || _CurrentTexEnv[stage].EnvPacked!= env.EnvPacked)
if (_CurrentTexEnvSpecial[stage] != TexEnvSpecialDisabled || _CurrentTexEnv[stage].EnvPacked!= env.EnvPacked)
{
forceActivateTexEnvMode(stage, env);
}
@ -1451,7 +1451,7 @@ void CDriverGL3::activateTexEnvMode(uint stage, const CMaterial::CTexEnv &env)
void CDriverGL3::activateTexEnvColor(uint stage, const CMaterial::CTexEnv &env)
{
H_AUTO_OGL(CDriverGL3_activateTexEnvColor)
if(_CurrentTexEnv[stage].ConstantColor!= env.ConstantColor)
if (_CurrentTexEnv[stage].ConstantColor!= env.ConstantColor)
{
forceActivateTexEnvColor(stage, env);
}
@ -1504,7 +1504,7 @@ void CDriverGL3::swapTextureHandle(ITexture &tex0, ITexture &tex1)
setupTexture(tex1);
// avoid any problem, disable all textures
for(uint stage = 0; stage < inlGetNumTextStages(); stage++)
for (uint stage = 0; stage < inlGetNumTextStages(); stage++)
{
activateTexture(stage, NULL);
}
@ -1539,12 +1539,12 @@ uint CDriverGL3::getTextureHandle(const ITexture &tex)
{
H_AUTO_OGL(CDriverGL3_getTextureHandle)
// If DrvShare not setuped
if(!tex.TextureDrvShare)
if (!tex.TextureDrvShare)
return 0;
// If DrvInfo not setuped
const CTextureDrvInfosGL3 *t0= (const CTextureDrvInfosGL3*)(const ITextureDrvInfos*)(tex.TextureDrvShare->DrvTexture);
if(!t0)
if (!t0)
return 0;
return t0->ID;
@ -1562,7 +1562,7 @@ uint CDriverGL3::getTextureHandle(const ITexture &tex)
bool CDriverGL3::setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 width, uint32 height, uint32 mipmapLevel, uint32 cubeFace)
{
H_AUTO_OGL(CDriverGL3_setRenderTarget )
H_AUTO_OGL(CDriverGL3_setRenderTarget)
// make backup of offscreen buffer to old texture if not using FBOs
if (!_RenderTargetFBO && _TextureTarget && _TextureTargetUpload && (_TextureTarget != tex || _TextureTargetCubeFace != cubeFace))
@ -1578,7 +1578,7 @@ bool CDriverGL3::setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 widt
// Check the texture is a render target
nlassertex (tex->getRenderTarget(), ("The texture must be a render target. Call ITexture::setRenderTarget(true)."));
if(tex->isBloomTexture() && supportBloomEffect())
if (tex->isBloomTexture() && supportBloomEffect())
{
uint32 w, h;
getWindowSize(w, h);

@ -103,15 +103,15 @@ bool CDriverGL3::setupVertexBuffer(CVertexBuffer& VB)
// 2. If necessary, do modifications.
//==================================
const bool touched = (VB.getTouchFlags() & (CVertexBuffer::TouchedReserve|CVertexBuffer::TouchedVertexFormat)) != 0;
if( touched || (VB.DrvInfos == NULL))
if (touched || (VB.DrvInfos == NULL))
{
// delete first
if(VB.DrvInfos)
if (VB.DrvInfos)
delete VB.DrvInfos;
VB.DrvInfos = NULL;
// create only if some vertices
if(VB.getNumVertices())
if (VB.getNumVertices())
{
// 1. Retrieve/Create driver shader.
//==================================
@ -125,7 +125,7 @@ bool CDriverGL3::setupVertexBuffer(CVertexBuffer& VB)
CVertexBuffer::TPreferredMemory preferred = VB.getPreferredMemory ();
if ((preferred == CVertexBuffer::RAMVolatile) ||
(preferred == CVertexBuffer::AGPVolatile) ||
(preferred == CVertexBuffer::RAMPreferred ) )
(preferred == CVertexBuffer::RAMPreferred))
preferred = CVertexBuffer::AGPPreferred;
const uint size = VB.capacity()*VB.getVertexSize();
@ -173,7 +173,7 @@ bool CDriverGL3::activeVertexBuffer(CVertexBuffer& VB)
if (info->_VBHard == NULL)
{
// Disable the current vertexBufferHard if setuped.
if(_CurrentVertexBufferHard)
if (_CurrentVertexBufferHard)
_CurrentVertexBufferHard->disable();
}
else
@ -252,7 +252,7 @@ IVertexBufferHardGL *CDriverGL3::createVertexBufferHard(uint size, uint numVerti
}
// If this one at least created (an extension support it).
if( !vertexArrayRange )
if (!vertexArrayRange)
return NULL;
else
{
@ -261,7 +261,7 @@ IVertexBufferHardGL *CDriverGL3::createVertexBufferHard(uint size, uint numVerti
// let the VAR create the vbhard.
vbHard= vertexArrayRange->createVBHardGL(size, vb);
// if fails
if(!vbHard)
if (!vbHard)
{
return NULL;
}
@ -404,7 +404,7 @@ void CDriverGL3::setupGlArrays(CVertexBufferInfo &vb)
{
mustNormalize = ARBVertexProgramMustNormalizeAttrib[value];
}
nglVertexAttribPointer( glIndex, NumCoordinatesType[type], GLType[ type ], mustNormalize, vb.VertexSize, vb.ValuePtr[value] );
nglVertexAttribPointer(glIndex, NumCoordinatesType[type], GLType[ type ], mustNormalize, vb.VertexSize, vb.ValuePtr[value]);
}
else
{
@ -461,7 +461,7 @@ void CVertexBufferInfo::setupVertexBuffer(CVertexBuffer &vb)
void CDriverGL3::resetVertexArrayRange()
{
H_AUTO_OGL(CDriverGL3_resetVertexArrayRange)
if(_CurrentVertexBufferHard)
if (_CurrentVertexBufferHard)
{
// Must ensure it has ended any drawing
_CurrentVertexBufferHard->lock();
@ -480,7 +480,7 @@ bool CDriverGL3::initVertexBufferHard(uint agpMem, uint vramMem)
H_AUTO_OGL(CDriverGL3_initVertexBufferHard)
// must be supported
if(!_AGPVertexArrayRange || !_VRAMVertexArrayRange)
if (!_AGPVertexArrayRange || !_VRAMVertexArrayRange)
return false;
// First, reset any VBHard created.

@ -111,7 +111,7 @@ IVertexBufferHardGL *CVertexArrayRange::createVBHardGL(uint size, CVertexBuffer
void CVertexArrayRange::enable()
{
H_AUTO_OGL(CVertexArrayRangeARB_enable)
if(_Driver->_CurrentVertexArrayRange != this)
if (_Driver->_CurrentVertexArrayRange != this)
{
_Driver->_CurrentVertexArrayRange= this;
}
@ -121,7 +121,7 @@ void CVertexArrayRange::enable()
void CVertexArrayRange::disable()
{
H_AUTO_OGL(CVertexArrayRangeARB_disbale)
if(_Driver->_CurrentVertexBufferHard != NULL)
if (_Driver->_CurrentVertexBufferHard != NULL)
{
_Driver->_CurrentVertexBufferHard= NULL;
}
@ -136,7 +136,7 @@ void CVertexArrayRange::updateLostBuffers()
nlassert(_Driver);
if (_Driver->isWndActive())
{
for(std::list<CVertexBufferHard *>::iterator it = _LostVBList.begin(); it != _LostVBList.end(); ++it)
for (std::list<CVertexBufferHard *>::iterator it = _LostVBList.begin(); it != _LostVBList.end(); ++it)
{
nlassert((*it)->_VertexObjectId);
GLuint id = (GLuint) (*it)->_VertexObjectId;
@ -261,7 +261,7 @@ void *CVertexBufferHard::lock()
// continue to standard mapping code below ..
}
TTicks beforeLock = 0;
if(_Driver->_VBHardProfiling)
if (_Driver->_VBHardProfiling)
{
beforeLock= CTime::getPerformanceTime();
}
@ -283,7 +283,7 @@ void *CVertexBufferHard::lock()
#endif
_Driver->_DriverGLStates.forceBindARBVertexBuffer(0);
// Lock Profile?
if(_Driver->_VBHardProfiling)
if (_Driver->_VBHardProfiling)
{
TTicks afterLock;
afterLock= CTime::getPerformanceTime();
@ -301,7 +301,7 @@ void CVertexBufferHard::unlock()
if (_Invalid) return;
if (!_VertexObjectId) return;
TTicks beforeLock = 0;
if(_Driver->_VBHardProfiling)
if (_Driver->_VBHardProfiling)
{
beforeLock= CTime::getPerformanceTime();
}
@ -318,7 +318,7 @@ void CVertexBufferHard::unlock()
_Unmapping = false;
#endif
// Lock Profile?
if(_Driver->_VBHardProfiling)
if (_Driver->_VBHardProfiling)
{
TTicks afterLock;
afterLock= CTime::getPerformanceTime();
@ -354,7 +354,7 @@ void CVertexBufferHard::unlock(uint /* startVert */,uint /* endVert */)
void CVertexBufferHard::enable()
{
H_AUTO_OGL(CVertexBufferHardARB_enable)
if(_Driver->_CurrentVertexBufferHard != this)
if (_Driver->_CurrentVertexBufferHard != this)
{
/* nlassert(_VertexArrayRange);
_VertexArrayRange->enable(); */
@ -366,7 +366,7 @@ void CVertexBufferHard::enable()
void CVertexBufferHard::disable()
{
H_AUTO_OGL(CVertexBufferHardARB_disable)
if(_Driver->_CurrentVertexBufferHard != NULL)
if (_Driver->_CurrentVertexBufferHard != NULL)
{
/* nlassert(_VertexArrayRange);
_VertexArrayRange->disable(); */
@ -418,7 +418,7 @@ void CVertexBufferHard::invalidate()
{
nlwarning("*****************************************************");
nlwarning("Mapped buffers :");
for(std::list<CVertexBufferHard *>::iterator it = _MappedVBList.begin(); it != _MappedVBList.end(); ++it)
for (std::list<CVertexBufferHard *>::iterator it = _MappedVBList.begin(); it != _MappedVBList.end(); ++it)
{
CVertexBufferHard &vbarb = **it;
nlwarning("Buffer id = %u, size = %u, address = %p", vbarb._VertexObjectId, vbarb.VB->getVertexSize() * vbarb.VB->getNumVertices(), vbarb.getPointer());

@ -61,7 +61,7 @@ bool GlWndProc(CDriverGL3 *driver, HWND hWnd, UINT message, WPARAM wParam, LPARA
if (!driver)
return false;
if(message == WM_SIZE)
if (message == WM_SIZE)
{
if (driver->_CurrentMode.Windowed)
{
@ -73,7 +73,7 @@ bool GlWndProc(CDriverGL3 *driver, HWND hWnd, UINT message, WPARAM wParam, LPARA
driver->_CurrentMode.Height = (uint16)(rect.bottom-rect.top);
}
}
else if(message == WM_MOVE)
else if (message == WM_MOVE)
{
if (driver->_CurrentMode.Windowed)
{
@ -151,7 +151,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
// disable menu (default ALT-F4 behavior is disabled)
if (message == WM_CLOSE)
{
if(pDriver && pDriver->ExitFunc)
if (pDriver && pDriver->ExitFunc)
{
pDriver->ExitFunc();
}
@ -174,7 +174,7 @@ bool GlWndProc(CDriverGL3 *driver, const void* e)
{
H_AUTO_OGL(GlWndProc)
if(!driver)
if (!driver)
return false;
NSEvent* event = [NSEvent eventWithEventRef:e];
@ -214,7 +214,7 @@ bool GlWndProc(CDriverGL3 *driver, XEvent &e)
{
case DestroyNotify:
if(driver && driver->ExitFunc)
if (driver && driver->ExitFunc)
{
driver->ExitFunc();
}
@ -316,7 +316,7 @@ bool CDriverGL3::init (uint windowIcon, emptyProc exitFunc)
wc.hbrBackground = WHITE_BRUSH;
wc.lpszClassName = L"NLClass";
wc.lpszMenuName = NULL;
if ( !RegisterClassW(&wc) )
if (!RegisterClassW(&wc))
{
return false;
}
@ -402,11 +402,11 @@ bool CDriverGL3::init (uint windowIcon, emptyProc exitFunc)
sint nextensions = 0;
char **extensions = XListExtensions(_dpy, &nextensions);
for(sint i = 0; i < nextensions; ++i)
for (sint i = 0; i < nextensions; ++i)
{
if(i%5==0) DebugLog->displayRaw("3D: ");
if (i%5==0) DebugLog->displayRaw("3D: ");
DebugLog->displayRaw(NLMISC::toString("%s ", extensions[i]).c_str());
if(i%5==4) DebugLog->displayRaw("\n");
if (i%5==4) DebugLog->displayRaw("\n");
}
DebugLog->displayRaw("\n");
@ -524,7 +524,7 @@ void CDriverGL3::setWindowIcon(const std::vector<NLMISC::CBitmap> &bitmaps)
uint bigHeight = GetSystemMetrics(SM_CYICON);
// find icons with the exact size
for(uint i = 0; i < bitmaps.size(); ++i)
for (uint i = 0; i < bitmaps.size(); ++i)
{
if (smallIndex == -1 && bitmaps[i].getWidth() == smallWidth && bitmaps[i].getHeight() == smallHeight)
smallIndex = i;
@ -534,7 +534,7 @@ void CDriverGL3::setWindowIcon(const std::vector<NLMISC::CBitmap> &bitmaps)
}
// find icons with taller size (we will resize them)
for(uint i = 0; i < bitmaps.size(); ++i)
for (uint i = 0; i < bitmaps.size(); ++i)
{
if (smallIndex == -1 && bitmaps[i].getWidth() >= smallWidth && bitmaps[i].getHeight() >= smallHeight)
smallIndex = i;
@ -571,7 +571,7 @@ void CDriverGL3::setWindowIcon(const std::vector<NLMISC::CBitmap> &bitmaps)
if (!bitmaps.empty())
{
// process each bitmap
for(uint i = 0; i < bitmaps.size(); ++i)
for (uint i = 0; i < bitmaps.size(); ++i)
{
convertBitmapToIcon(bitmaps[i], icon_data);
}
@ -626,7 +626,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
RECT rc;
SetRect (&rc, 0, 0, width, height);
AdjustWindowRectEx (&rc, GetWindowStyle (_win), GetMenu (_win) != NULL, GetWindowExStyle (_win));
SetWindowPos (_win, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
SetWindowPos (_win, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
// Get the
HDC tempHDC = GetDC(tmpHWND);
@ -642,7 +642,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
_pfd.cColorBits = _CurrentMode.Depth;
// Choose best suited Depth Buffer.
if(_CurrentMode.Depth<=16)
if (_CurrentMode.Depth<=16)
{
_pfd.cDepthBits = 16;
}
@ -659,7 +659,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
DestroyWindow (tmpHWND);
return false;
}
if ( !SetPixelFormat(tempHDC,pf,&_pfd) )
if (!SetPixelFormat(tempHDC,pf,&_pfd))
{
nlwarning ("CDriverGL3::setDisplay: SetPixelFormat failed");
DestroyWindow (tmpHWND);
@ -719,7 +719,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
// Attribute arrays must be "0" terminated - for simplicity, first
// just zero-out the array then fill from left to right.
for ( int a = 0; a < 2*20; a++ )
for (int a = 0; a < 2*20; a++)
{
iattributes[a] = 0;
fattributes[a] = 0;
@ -754,10 +754,10 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
// requirements.
int pformat[20];
unsigned int nformats;
if ( !nwglChoosePixelFormatARB ( hdc, iattributes, fattributes,
20, pformat, &nformats ) )
if (!nwglChoosePixelFormatARB (hdc, iattributes, fattributes,
20, pformat, &nformats))
{
nlwarning ( "pbuffer creation error: Couldn't find a suitable pixel format." );
nlwarning ("pbuffer creation error: Couldn't find a suitable pixel format.");
wglDeleteContext (tempGLRC);
DestroyWindow (tmpHWND);
return false;
@ -768,7 +768,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
returned in the list in step #2 and call the function: */
int iattributes2[1] = {0};
// int iattributes2[] = {WGL_PBUFFER_LARGEST_ARB, 1, 0};
_PBuffer = nwglCreatePbufferARB( hdc, pformat[0], width, height, iattributes2 );
_PBuffer = nwglCreatePbufferARB(hdc, pformat[0], width, height, iattributes2);
if (_PBuffer == NULL)
{
DWORD error = GetLastError ();
@ -784,7 +784,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
}
/* After creating a pbuffer, you may use this functions to determine the dimensions of the pbuffer actually created. */
if ( !nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width ) )
if (!nwglQueryPbufferARB(_PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width))
{
DWORD error = GetLastError ();
nlwarning ("CDriverGL3::setDisplay: wglQueryPbufferARB failed: 0x%x", error);
@ -797,7 +797,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
return false;
}
if ( !nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height ) )
if (!nwglQueryPbufferARB(_PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height))
{
DWORD error = GetLastError ();
nlwarning ("CDriverGL3::setDisplay: wglQueryPbufferARB failed: 0x%x", error);
@ -815,12 +815,12 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
/* The next step is to create a device context for the newly created pbuffer. To do this,
call to the function: */
_hDC = nwglGetPbufferDCARB( _PBuffer );
_hDC = nwglGetPbufferDCARB(_PBuffer);
if (_hDC == NULL)
{
DWORD error = GetLastError ();
nlwarning ("CDriverGL3::setDisplay: wglGetPbufferDCARB failed: 0x%x", error);
nwglDestroyPbufferARB( _PBuffer );
nwglDestroyPbufferARB(_PBuffer);
wglDeleteContext (tempGLRC);
@ -834,13 +834,13 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
/* The final step of pbuffer creation is to create an OpenGL rendering context and
associate it with the handle for the pbuffer's device context created in step #4. This is done as follows */
_hRC = wglCreateContext( _hDC );
_hRC = wglCreateContext(_hDC);
if (_hRC == NULL)
{
DWORD error = GetLastError ();
nlwarning ("CDriverGL3::setDisplay: wglCreateContext failed: 0x%x", error);
nwglReleasePbufferDCARB( _PBuffer, _hDC );
nwglDestroyPbufferARB( _PBuffer );
nwglReleasePbufferDCARB(_PBuffer, _hDC);
nwglDestroyPbufferARB(_PBuffer);
wglDeleteContext (tempGLRC);
DestroyWindow (tmpHWND);
_PBuffer = NULL;
@ -873,8 +873,8 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
nlwarning ("CDriverGL3::setDisplay: wglMakeCurrent failed: 0x%x", error);
wglDeleteContext (_hRC);
nwglReleasePbufferDCARB( _PBuffer, _hDC );
nwglDestroyPbufferARB( _PBuffer );
nwglReleasePbufferDCARB(_PBuffer, _hDC);
nwglDestroyPbufferARB(_PBuffer);
DestroyWindow (tmpHWND);
_PBuffer = NULL;
@ -951,7 +951,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
* (http://dev.ryzom.com/issues/1013)
*/
NSView* view = (NSView*)wnd;
if(view.frame.origin.x != 0 || view.frame.origin.y != 0) {
if (view.frame.origin.x != 0 || view.frame.origin.y != 0) {
[view setBoundsOrigin:view.frame.origin];
}
}
@ -974,7 +974,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
NSOpenGLPixelFormat* format =
[[NSOpenGLPixelFormat alloc] initWithAttributes:att];
if(!format)
if (!format)
nlerror("cannot create NSOpenGLPixelFormat");
// intially set height/width, further updates through CocoaOpenGLView
@ -986,7 +986,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
initWithFrame:NSMakeRect(0, 0, mode.Width, mode.Height)
pixelFormat:format];
if(!_glView)
if (!_glView)
nlerror("cannot create view");
// tell the view about the driver so the view is able to update "window" size
@ -1004,7 +1004,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
// create a opengl context for the view
_ctx = [_glView openGLContext];
if(!_ctx)
if (!_ctx)
nlerror("cannot create context");
// free the pixel format object
@ -1051,7 +1051,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
XVisualInfo *visual_info = glXChooseVisual (_dpy, DefaultScreen(_dpy), sAttribList24bpp);
if (visual_info == NULL)
visual_info = glXChooseVisual(_dpy, DefaultScreen(_dpy), sAttribList16bpp);
if(visual_info == NULL)
if (visual_info == NULL)
{
nlerror("glXChooseVisual() failed");
}
@ -1297,13 +1297,13 @@ bool CDriverGL3::setScreenMode(const GfxMode &mode)
devMode.dmPelsWidth = mode.Width;
devMode.dmPelsHeight = mode.Height;
if(mode.Depth > 0)
if (mode.Depth > 0)
{
devMode.dmBitsPerPel = mode.Depth;
devMode.dmFields |= DM_BITSPERPEL;
}
if(mode.Frequency > 0)
if (mode.Frequency > 0)
{
devMode.dmDisplayFrequency = mode.Frequency;
devMode.dmFields |= DM_DISPLAYFREQUENCY;
@ -1447,7 +1447,7 @@ bool CDriverGL3::createWindow(const GfxMode &mode)
initWithContentRect:NSMakeRect(0, 0, mode.Width, mode.Height)
styleMask:styleMask backing:NSBackingStoreBuffered defer:NO];
if(!cocoa_window)
if (!cocoa_window)
{
nlerror("cannot create cocoa window");
return false;
@ -1490,7 +1490,7 @@ bool CDriverGL3::createWindow(const GfxMode &mode)
[cocoa_window setContentView: (NSView*)window];
if(window == EmptyWindow)
if (window == EmptyWindow)
{
nldebug("cannot create cocoa view for cocoa window");
return false;
@ -1716,14 +1716,14 @@ bool CDriverGL3::setWindowStyle(EWindowStyle windowStyle)
#elif defined(NL_OS_MAC)
// leave fullscreen mode, enter windowed mode
if(windowStyle == EWSWindowed && [containerView() isInFullScreenMode])
if (windowStyle == EWSWindowed && [containerView() isInFullScreenMode])
{
// disable manual setting of back buffer size, cocoa handles this
// automatically as soon as the view gets resized
CGLError error = CGLDisable((CGLContextObj)[_ctx CGLContextObj],
kCGLCESurfaceBackingSize);
if(error != kCGLNoError)
if (error != kCGLNoError)
nlerror("cannot disable kCGLCESurfaceBackingSize (%s)",
CGLErrorString(error));
@ -1738,13 +1738,13 @@ bool CDriverGL3::setWindowStyle(EWindowStyle windowStyle)
}
// enter fullscreen, leave windowed mode
else if(windowStyle == EWSFullscreen && ![containerView() isInFullScreenMode])
else if (windowStyle == EWSFullscreen && ![containerView() isInFullScreenMode])
{
// enable manual back buffer size for mode setting in fullscreen
CGLError error = CGLEnable((CGLContextObj)[_ctx CGLContextObj],
kCGLCESurfaceBackingSize);
if(error != kCGLNoError)
if (error != kCGLNoError)
nlerror("cannot enable kCGLCESurfaceBackingSize (%s)",
CGLErrorString(error));
@ -1859,11 +1859,11 @@ static int bppFromDisplayMode(CGDisplayModeRef mode)
{
CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding(mode);
if(CFStringCompare(pixelEncoding, CFSTR(IO32BitDirectPixels),
if (CFStringCompare(pixelEncoding, CFSTR(IO32BitDirectPixels),
kCFCompareCaseInsensitive) == kCFCompareEqualTo)
return 32;
else if(CFStringCompare(pixelEncoding, CFSTR(IO16BitDirectPixels),
else if (CFStringCompare(pixelEncoding, CFSTR(IO16BitDirectPixels),
kCFCompareCaseInsensitive) == kCFCompareEqualTo)
return 16;
@ -1900,7 +1900,7 @@ bool CDriverGL3::getModes(std::vector<GfxMode> &modes)
while (EnumDisplaySettings (NULL, modeIndex, &devMode))
{
// Keep only 16 and 32 bits
if ((devMode.dmBitsPerPel == 16 ) || (devMode.dmBitsPerPel == 32))
if ((devMode.dmBitsPerPel == 16) || (devMode.dmBitsPerPel == 32))
{
// Add this mode
GfxMode mode;
@ -1922,7 +1922,7 @@ bool CDriverGL3::getModes(std::vector<GfxMode> &modes)
CGDisplayCount numDisplays;
CGDisplayErr err = CGGetActiveDisplayList(kMaxDisplays, display, &numDisplays);
if(err != CGDisplayNoErr)
if (err != CGDisplayNoErr)
{
nlwarning("Cannot get displays (%d)", err);
return false;
@ -2100,7 +2100,7 @@ bool CDriverGL3::getCurrentScreenMode(GfxMode &mode)
mode.Depth = NSBitsPerPixelFromDepth([screen depth]);
// in fullscreen mode
if([containerView() isInFullScreenMode])
if ([containerView() isInFullScreenMode])
{
// return the size of the back buffer (like having switched monitor mode)
mode.Windowed = false;
@ -2352,7 +2352,7 @@ bool CDriverGL3::createContext()
_pfd.iPixelType = PFD_TYPE_RGBA;
_pfd.cColorBits = _CurrentMode.Depth;
// Choose best suited Depth Buffer.
if(_CurrentMode.Depth <= 16)
if (_CurrentMode.Depth <= 16)
{
_pfd.cDepthBits = 16;
}
@ -2369,7 +2369,7 @@ bool CDriverGL3::createContext()
return false;
}
if ( !SetPixelFormat(_hDC,pf,&_pfd) )
if (!SetPixelFormat(_hDC,pf,&_pfd))
{
return false;
}
@ -2398,7 +2398,7 @@ bool CDriverGL3::activate()
#elif defined(NL_OS_MAC)
if([NSOpenGLContext currentContext] != _ctx)
if ([NSOpenGLContext currentContext] != _ctx)
[_ctx makeCurrentContext];
#elif defined (NL_OS_UNIX)
@ -2466,15 +2466,15 @@ void CDriverGL3::getWindowSize(uint32 &width, uint32 &height)
if (_PBuffer)
{
nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width );
nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height );
nwglQueryPbufferARB(_PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width);
nwglQueryPbufferARB(_PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height);
}
#endif
}
else
{
#ifdef NL_OS_MAC
if([containerView() isInFullScreenMode])
if ([containerView() isInFullScreenMode])
{
width = _backBufferWidth;
height = _backBufferHeight;
@ -2517,7 +2517,7 @@ void CDriverGL3::setWindowSize(uint32 width, uint32 height)
#elif defined(NL_OS_MAC)
// for fullscreen mode, adjust the back buffer size to desired resolution
if([containerView() isInFullScreenMode])
if ([containerView() isInFullScreenMode])
{
// disable and re-enable fullscreen
// fixes #1062 (http://dev.ryzom.com/issues/1062)
@ -2530,7 +2530,7 @@ void CDriverGL3::setWindowSize(uint32 width, uint32 height)
(CGLContextObj)[_ctx CGLContextObj],
kCGLCPSurfaceBackingSize, dim);
if(error != kCGLNoError)
if (error != kCGLNoError)
nlerror("cannot set kCGLCPSurfaceBackingSize parameter (%s)",
CGLErrorString(error));
@ -2540,7 +2540,7 @@ void CDriverGL3::setWindowSize(uint32 width, uint32 height)
else
{
// only change the window size if the driver created the window itself
if(_DestroyWindow)
if (_DestroyWindow)
{
// get the windows current frame
NSRect rect = [[containerView() window] frame];
@ -2635,7 +2635,7 @@ bool CDriverGL3::isActive()
// ***************************************************************************
bool CDriverGL3::setMonitorColorProperties (const CMonitorColorProperties &properties)
{
H_AUTO_OGL(CDriverGL3_setMonitorColorProperties )
H_AUTO_OGL(CDriverGL3_setMonitorColorProperties)
#ifdef NL_OS_WINDOWS
@ -2648,19 +2648,19 @@ bool CDriverGL3::setMonitorColorProperties (const CMonitorColorProperties &prope
// For each composant
uint c;
for( c=0; c<3; c++ )
for (c=0; c<3; c++)
{
uint i;
for( i=0; i<256; i++ )
for (i=0; i<256; i++)
{
// Floating value
float value = (float)i / 256;
// Contrast
value = (float) max (0.0f, (value-0.5f) * (float) pow (3.f, properties.Contrast[c]) + 0.5f );
value = (float) max (0.0f, (value-0.5f) * (float) pow (3.f, properties.Contrast[c]) + 0.5f);
// Gamma
value = (float) pow (value, (properties.Gamma[c]>0) ? 1 - 3 * properties.Gamma[c] / 4 : 1 - properties.Gamma[c] );
value = (float) pow (value, (properties.Gamma[c]>0) ? 1 - 3 * properties.Gamma[c] / 4 : 1 - properties.Gamma[c]);
// Luminosity
value = value + properties.Luminosity[c] / 2.f;
@ -2864,7 +2864,7 @@ bool CDriverGL3::convertBitmapToIcon(const NLMISC::CBitmap &bitmap, std::vector<
// convert RGBA to ARGB
CObjectVector<uint8> pixels = bitmap.getPixels();
for(uint j = 0; j < pixels.size(); j+=4)
for (uint j = 0; j < pixels.size(); j+=4)
icon[pos++] = pixels[j] << 16 | pixels[j+1] << 8 | pixels[j+2] | pixels[j+3] << 24;
return true;

@ -161,7 +161,7 @@ void CUnixEventEmitter::emulateMouseRawMode(bool enable)
{
_emulateRawMode = enable;
if(_emulateRawMode)
if (_emulateRawMode)
{
XWindowAttributes xwa;
XGetWindowAttributes(_dpy, _win, &xwa);
@ -172,7 +172,7 @@ void CUnixEventEmitter::emulateMouseRawMode(bool enable)
// was pulled back to 0.5 / 0.5, so a wrong movement delta would be
// reported otherwise
XEvent event;
while(XCheckIfEvent(_dpy, &event, &isMouseMoveEvent, NULL)) { };
while (XCheckIfEvent(_dpy, &event, &isMouseMoveEvent, NULL)) { };
}
}
@ -512,10 +512,10 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server)
TMouseButton button=getMouseButton (event.xbutton.state);
// if raw mode should be emulated
if(_emulateRawMode)
if (_emulateRawMode)
{
// when we just wrapped back the pointer to 0.5 / 0.5, ignore event
if(event.xbutton.x == xwa.width / 2 && event.xbutton.y == xwa.height / 2)
if (event.xbutton.x == xwa.width / 2 && event.xbutton.y == xwa.height / 2)
break;
// post a CGDMouseMove with the movement delta to the event server
@ -573,7 +573,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server)
if (keyCode)
{
TKey key = getKeyFromKeySym(k);
if(key == KeyNOKEY)
if (key == KeyNOKEY)
key = getKeyFromKeycode(keyCode);
// search for key in map
@ -591,7 +591,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server)
}
Text[c] = '\0';
if(c>0)
if (c>0)
{
#ifdef X_HAVE_UTF8_STRING
ucstring ucstr;
@ -626,7 +626,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server)
int c = XLookupString(&event.xkey, NULL, 0, &k, NULL);
TKey key = getKeyFromKeySym(k);
if(key == KeyNOKEY)
if (key == KeyNOKEY)
key = getKeyFromKeycode(event.xkey.keycode);
server->postEvent (new CEventKeyUp (key, getKeyButton(event.xbutton.state), this));
@ -719,7 +719,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server)
for (uint i=0; i < nitems; i++)
{
// nlwarning(" - Type=%s (%u)", XGetAtomName(_dpy, supportedTargets[i]), (uint)supportedTargets[i]);
if (supportedTargets[i] == XA_UTF8_STRING )
if (supportedTargets[i] == XA_UTF8_STRING)
{
if (bestTargetElect < 2)
{
@ -727,7 +727,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server)
bestTargetElect = 2;
}
}
else if (supportedTargets[i] == XA_STRING )
else if (supportedTargets[i] == XA_STRING)
{
if (bestTargetElect < 1)
{

@ -52,7 +52,7 @@ public:
/**
* sends all events to server
* (should call CEventServer method postEvent() )
* (should call CEventServer method postEvent())
*/
virtual void submitEvents(CEventServer & server, bool allWindows);

Loading…
Cancel
Save