Cleanup style

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

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

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

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

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

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

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

@ -118,7 +118,7 @@ void CDriverGL3::setTextureEnvFunction(uint stage, CMaterial& mat)
{ {
H_AUTO_OGL(CDriverGL3_setTextureEnvFunction) H_AUTO_OGL(CDriverGL3_setTextureEnvFunction)
ITexture *text= mat.getTexture(uint8(stage)); ITexture *text= mat.getTexture(uint8(stage));
if(text) if (text)
{ {
CMaterial::CTexEnv &env= mat._TexEnvs[stage]; CMaterial::CTexEnv &env= mat._TexEnvs[stage];
@ -133,7 +133,7 @@ void CDriverGL3::setTextureEnvFunction(uint stage, CMaterial& mat)
{ {
// set mode and enable. // set mode and enable.
CMaterial::TTexCoordGenMode mode= mat.getTexCoordGenMode(stage); CMaterial::TTexCoordGenMode mode= mat.getTexCoordGenMode(stage);
if(mode==CMaterial::TexCoordGenReflect) if (mode==CMaterial::TexCoordGenReflect)
{ {
// Cubic or normal ? // Cubic or normal ?
if (text->isTextureCube ()) if (text->isTextureCube ())
@ -141,11 +141,11 @@ void CDriverGL3::setTextureEnvFunction(uint stage, CMaterial& mat)
else else
_DriverGLStates.setTexGenMode (stage, GL_SPHERE_MAP); _DriverGLStates.setTexGenMode (stage, GL_SPHERE_MAP);
} }
else if(mode==CMaterial::TexCoordGenObjectSpace) else if (mode==CMaterial::TexCoordGenObjectSpace)
{ {
_DriverGLStates.setTexGenMode (stage, GL_OBJECT_LINEAR); _DriverGLStates.setTexGenMode (stage, GL_OBJECT_LINEAR);
} }
else if(mode==CMaterial::TexCoordGenEyeSpace) else if (mode==CMaterial::TexCoordGenEyeSpace)
{ {
_DriverGLStates.setTexGenMode (stage, GL_EYE_LINEAR); _DriverGLStates.setTexGenMode (stage, GL_EYE_LINEAR);
} }
@ -165,7 +165,7 @@ void CDriverGL3::setupUserTextureMatrix(uint numStages, CMaterial& mat)
if ( if (
(_UserTexMatEnabled != 0 && (mat.getFlags() & IDRV_MAT_USER_TEX_MAT_ALL) == 0) (_UserTexMatEnabled != 0 && (mat.getFlags() & IDRV_MAT_USER_TEX_MAT_ALL) == 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 // 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; 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 if (newMask & shiftMask) // user matrix for this stage
{ {
_UserTexMat[ k ] = mat.getUserTexMat( k ); _UserTexMat[ k ] = mat.getUserTexMat(k);
_UserTexMatEnabled |= shiftMask; _UserTexMatEnabled |= shiftMask;
} }
else else
@ -182,7 +182,7 @@ void CDriverGL3::setupUserTextureMatrix(uint numStages, CMaterial& mat)
/// check if matrix disabled /// check if matrix disabled
if ( if (
(newMask & shiftMask) != (_UserTexMatEnabled & shiftMask) (newMask & shiftMask) != (_UserTexMatEnabled & shiftMask)
) )
{ {
_UserTexMat[ k ].identity(); _UserTexMat[ k ].identity();
_UserTexMatEnabled &= ~shiftMask; _UserTexMatEnabled &= ~shiftMask;
@ -232,7 +232,7 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
{ {
H_AUTO_OGL(CDriverGL3_setupMaterial) H_AUTO_OGL(CDriverGL3_setupMaterial)
if( mat.getDynMat() != NULL ) if (mat.getDynMat() != NULL)
{ {
_CurrentMaterial = &mat; _CurrentMaterial = &mat;
return true; return true;
@ -263,26 +263,26 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
// 1. Setup modified fields of material. // 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 /* 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. 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). 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 any flag is set (but a flag of texture)
if( touched & (~_MaterialAllTextureTouchedFlag) ) if (touched & (~_MaterialAllTextureTouchedFlag))
{ {
// Convert Material to driver shader. // Convert Material to driver shader.
if (touched & IDRV_TOUCHED_BLENDFUNC) if (touched & IDRV_TOUCHED_BLENDFUNC)
{ {
convBlend( mat.getSrcBlend(),glenum ); convBlend(mat.getSrcBlend(),glenum);
pShader->SrcBlend=glenum; pShader->SrcBlend=glenum;
convBlend( mat.getDstBlend(),glenum ); convBlend(mat.getDstBlend(),glenum);
pShader->DstBlend=glenum; pShader->DstBlend=glenum;
} }
if (touched & IDRV_TOUCHED_ZFUNC) if (touched & IDRV_TOUCHED_ZFUNC)
{ {
convZFunction( mat.getZFunc(),glenum); convZFunction(mat.getZFunc(),glenum);
pShader->ZComp= glenum; pShader->ZComp= glenum;
} }
if (touched & IDRV_TOUCHED_LIGHTING) if (touched & IDRV_TOUCHED_LIGHTING)
@ -318,14 +318,14 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
CMaterial::TShader matShader = pShader->SupportedShader; CMaterial::TShader matShader = pShader->SupportedShader;
// if the shader has changed since last time // if the shader has changed since last time
if(matShader != _CurrentMaterialSupportedShader) if (matShader != _CurrentMaterialSupportedShader)
{ {
// if old was lightmap, restore standard lighting // if old was lightmap, restore standard lighting
if(_CurrentMaterialSupportedShader==CMaterial::LightMap) if (_CurrentMaterialSupportedShader==CMaterial::LightMap)
setupLightMapDynamicLighting(false); setupLightMapDynamicLighting(false);
// if new is lightmap, setup dynamic lighting // if new is lightmap, setup dynamic lighting
if(matShader==CMaterial::LightMap) if (matShader==CMaterial::LightMap)
setupLightMapDynamicLighting(true); setupLightMapDynamicLighting(true);
} }
@ -339,7 +339,7 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
// because setupTexture() may disable all stage. // because setupTexture() may disable all stage.
if (matShader != CMaterial::Water) if (matShader != CMaterial::Water)
{ {
for(stage=0 ; stage<inlGetNumTextStages() ; stage++) for (stage=0 ; stage<inlGetNumTextStages() ; stage++)
{ {
ITexture *text= mat.getTexture(uint8(stage)); ITexture *text= mat.getTexture(uint8(stage));
if (text != NULL && !setupTexture(*text)) if (text != NULL && !setupTexture(*text))
@ -347,9 +347,9 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
} }
} }
// Here, for Lightmap materials, setup the lightmaps. // 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; ITexture *text = mat._LightMaps[stage].Texture;
if (text != NULL && !setupTexture(*text)) 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. // 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. // 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. // 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::PerPixelLighting
/* && matShader != CMaterial::Caustics */ /* && matShader != CMaterial::Caustics */
&& matShader != CMaterial::Cloud && matShader != CMaterial::Cloud
&& matShader != CMaterial::Water && matShader != CMaterial::Water
&& matShader != CMaterial::Specular && matShader != CMaterial::Specular
) )
{ {
for(stage=0 ; stage<inlGetNumTextStages() ; stage++) for (stage=0 ; stage<inlGetNumTextStages() ; stage++)
{ {
ITexture *text= mat.getTexture(uint8(stage)); ITexture *text= mat.getTexture(uint8(stage));
@ -393,21 +393,21 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
//================= //=================
bool blend = (mat.getFlags()&IDRV_MAT_BLEND)!=0; bool blend = (mat.getFlags()&IDRV_MAT_BLEND)!=0;
_DriverGLStates.enableBlend(blend); _DriverGLStates.enableBlend(blend);
if(blend) if (blend)
_DriverGLStates.blendFunc(pShader->SrcBlend, pShader->DstBlend); _DriverGLStates.blendFunc(pShader->SrcBlend, pShader->DstBlend);
// Double Sided Part. // Double Sided Part.
//=================== //===================
// NB: inverse state: DoubleSided <=> !CullFace. // NB: inverse state: DoubleSided <=> !CullFace.
uint32 twoSided= mat.getFlags()&IDRV_MAT_DOUBLE_SIDED; uint32 twoSided= mat.getFlags()&IDRV_MAT_DOUBLE_SIDED;
_DriverGLStates.enableCullFace( twoSided==0 ); _DriverGLStates.enableCullFace(twoSided==0);
// Alpha Test Part. // Alpha Test Part.
//================= //=================
uint32 alphaTest= mat.getFlags()&IDRV_MAT_ALPHA_TEST; uint32 alphaTest= mat.getFlags()&IDRV_MAT_ALPHA_TEST;
_DriverGLStates.enableAlphaTest(alphaTest); _DriverGLStates.enableAlphaTest(alphaTest);
if(alphaTest) if (alphaTest)
{ {
// setup alphaTest threshold. // setup alphaTest threshold.
_DriverGLStates.alphaFunc(mat.getAlphaTestThreshold()); _DriverGLStates.alphaFunc(mat.getAlphaTestThreshold());
@ -433,10 +433,10 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
// Light Part. // Light Part.
_DriverGLStates.enableLighting(mat.getFlags()&IDRV_MAT_LIGHTING); _DriverGLStates.enableLighting(mat.getFlags()&IDRV_MAT_LIGHTING);
if( ( mat.getFlags() & IDRV_MAT_LIGHTING ) == 0 ) if ((mat.getFlags() & IDRV_MAT_LIGHTING) == 0)
disableAllLights(); disableAllLights();
if(mat.getFlags()&IDRV_MAT_LIGHTING) if (mat.getFlags()&IDRV_MAT_LIGHTING)
{ {
_DriverGLStates.setEmissive(pShader->PackedEmissive, pShader->Emissive); _DriverGLStates.setEmissive(pShader->PackedEmissive, pShader->Emissive);
_DriverGLStates.setAmbient(pShader->PackedAmbient, pShader->Ambient); _DriverGLStates.setAmbient(pShader->PackedAmbient, pShader->Ambient);
@ -484,7 +484,7 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
// 5. Set up the program // 5. Set up the program
// ===================== // =====================
bool programOK = setupProgram( mat ); bool programOK = setupProgram(mat);
return programOK; return programOK;
} }
@ -493,7 +493,7 @@ sint CDriverGL3::beginMultiPass()
{ {
H_AUTO_OGL(CDriverGL3_beginMultiPass) H_AUTO_OGL(CDriverGL3_beginMultiPass)
if( _CurrentMaterial->getDynMat() != NULL ) if (_CurrentMaterial->getDynMat() != NULL)
return _CurrentMaterial->getDynMat()->getPassCount(); return _CurrentMaterial->getDynMat()->getPassCount();
// Depending on material type and hardware, return number of pass required to draw this material. // 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) H_AUTO_OGL(CDriverGL3_setupPass)
if( _CurrentMaterial->getDynMat() != NULL ) if (_CurrentMaterial->getDynMat() != NULL)
return setupDynMatPass( pass ); return setupDynMatPass(pass);
switch(_CurrentMaterialSupportedShader) switch(_CurrentMaterialSupportedShader)
{ {
@ -563,7 +563,7 @@ void CDriverGL3::endMultiPass()
{ {
H_AUTO_OGL(CDriverGL3_endMultiPass) H_AUTO_OGL(CDriverGL3_endMultiPass)
if( _CurrentMaterial->getDynMat() != NULL ) if (_CurrentMaterial->getDynMat() != NULL)
return; return;
switch(_CurrentMaterialSupportedShader) 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; return false;
if( ( _CurrentMaterial->getFlags() & IDRV_MAT_DOUBLE_SIDED ) != 0 ) if ((_CurrentMaterial->getFlags() & IDRV_MAT_DOUBLE_SIDED) != 0)
_DriverGLStates.enableCullFace( false ); _DriverGLStates.enableCullFace(false);
else else
_DriverGLStates.enableCullFace( true ); _DriverGLStates.enableCullFace(true);
CDynMaterial *m = _CurrentMaterial->getDynMat(); CDynMaterial *m = _CurrentMaterial->getDynMat();
SRenderPass *currentPass = m->getPass( pass ); SRenderPass *currentPass = m->getPass(pass);
IProgram *p; IProgram *p;
@ -618,56 +618,56 @@ bool CDriverGL3::setupDynMatPass( uint pass )
type[ 0 ] = IDriver::VertexProgram; type[ 0 ] = IDriver::VertexProgram;
type[ 1 ] = IDriver::PixelProgram; type[ 1 ] = IDriver::PixelProgram;
for( uint32 j = 0; j < 2; j++ ) for (uint32 j = 0; j < 2; j++)
{ {
p = programs[ 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 ); const SDynMaterialProp *prop = currentPass->getProperty(i);
int loc = getUniformLocation( type[ j ], prop->prop.c_str() ); int loc = getUniformLocation(type[ j ], prop->prop.c_str());
if( loc == -1 ) if (loc == -1)
continue; continue;
switch( prop->type ) switch(prop->type)
{ {
case SDynMaterialProp::Float: case SDynMaterialProp::Float:
setUniform1f( type[ j ], loc, prop->value.toFloat() ); setUniform1f(type[ j ], loc, prop->value.toFloat());
break; break;
case SDynMaterialProp::Int: case SDynMaterialProp::Int:
setUniform1i( type[ j ], loc, prop->value.toInt() ); setUniform1i(type[ j ], loc, prop->value.toInt());
break; break;
case SDynMaterialProp::Uint: case SDynMaterialProp::Uint:
setUniform1ui( type[ j ], loc, prop->value.toUInt() ); setUniform1ui(type[ j ], loc, prop->value.toUInt());
break; break;
case SDynMaterialProp::Color: case SDynMaterialProp::Color:
{ {
float v[ 4 ]; 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; 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; break;
case SDynMaterialProp::Vector4: case SDynMaterialProp::Vector4:
{ {
float v[ 4 ]; float v[ 4 ];
prop->value.getVector4( v ); prop->value.getVector4(v);
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; break;
case SDynMaterialProp::Matrix4: case SDynMaterialProp::Matrix4:
{ {
float m[ 16 ]; float m[ 16 ];
prop->value.getMatrix4( m ); prop->value.getMatrix4(m);
setUniform4x4f( type[ j ], loc, m ); setUniform4x4f(type[ j ], loc, m);
break; break;
} }
@ -679,17 +679,17 @@ bool CDriverGL3::setupDynMatPass( uint pass )
////////////////////////////////// Set up some standard uniforms ////////////////////////////////// ////////////////////////////////// Set up some standard uniforms //////////////////////////////////
int loc = -1; int loc = -1;
loc = getUniformLocation( type[ j ], "mvpMatrix" ); loc = getUniformLocation(type[ j ], "mvpMatrix");
if( loc != -1 ) if (loc != -1)
{ {
CMatrix mat = _GLProjMat * _ModelViewMatrix; CMatrix mat = _GLProjMat * _ModelViewMatrix;
setUniform4x4f( type[ j ], loc, mat ); setUniform4x4f(type[ j ], loc, mat);
} }
loc = getUniformLocation( type[ j ], "mvMatrix" ); loc = getUniformLocation(type[ j ], "mvMatrix");
if( loc != -1 ) if (loc != -1)
{ {
setUniform4x4f( type[ j ], loc, _ModelViewMatrix ); setUniform4x4f(type[ j ], loc, _ModelViewMatrix);
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
@ -703,34 +703,34 @@ void CDriverGL3::setupNormalPass()
{ {
const CMaterial &mat = *_CurrentMaterial; const CMaterial &mat = *_CurrentMaterial;
for( int i = 0; i < IDRV_MAT_MAXTEXTURES; i++ ) for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++)
{ {
// Set constant // Set constant
int cl = currentProgram.pp->getUniformIndex( CProgramIndex::TName( CProgramIndex::Constant0 + i ) ); int cl = currentProgram.pp->getUniformIndex(CProgramIndex::TName(CProgramIndex::Constant0 + i));
if( cl != -1 ) if (cl != -1)
{ {
GLfloat glCol[ 4 ]; GLfloat glCol[ 4 ];
convColor( mat._TexEnvs[ i ].ConstantColor, glCol ); convColor(mat._TexEnvs[ i ].ConstantColor, glCol);
setUniform4f( IDriver::PixelProgram, cl, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ] ); setUniform4f(IDriver::PixelProgram, cl, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ]);
} }
// Set texture // Set texture
ITexture *t = mat.getTexture( i ); ITexture *t = mat.getTexture(i);
if( t == NULL ) if (t == NULL)
continue; continue;
int index = currentProgram.pp->getUniformIndex( CProgramIndex::TName( CProgramIndex::Sampler0 + i ) ); int index = currentProgram.pp->getUniformIndex(CProgramIndex::TName(CProgramIndex::Sampler0 + i));
if( index == -1 ) if (index == -1)
continue; continue;
setUniform1i( IDriver::PixelProgram, index, i ); setUniform1i(IDriver::PixelProgram, index, i);
} }
} }
// *************************************************************************** // ***************************************************************************
void CDriverGL3::computeLightMapInfos (const CMaterial &mat) 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(); static const uint32 RGBMaskPacked = CRGBA(255,255,255,0).getPacked();
// For optimisation consideration, suppose there is not too much lightmap. // For optimisation consideration, suppose there is not too much lightmap.
@ -761,7 +761,7 @@ void CDriverGL3::computeLightMapInfos (const CMaterial &mat)
// *************************************************************************** // ***************************************************************************
sint CDriverGL3::beginLightMapMultiPass () sint CDriverGL3::beginLightMapMultiPass ()
{ {
H_AUTO_OGL(CDriverGL3_beginLightMapMultiPass ) H_AUTO_OGL(CDriverGL3_beginLightMapMultiPass)
const CMaterial &mat= *_CurrentMaterial; const CMaterial &mat= *_CurrentMaterial;
// compute how many lightmap and pass we must process. // 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 // 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 // normal way is that setupLightMapDynamicLighting() is called in setupMaterial() if shader different from prec
if(_LightMapDynamicLightDirty) if (_LightMapDynamicLightDirty)
setupLightMapDynamicLighting(true); setupLightMapDynamicLighting(true);
// reset Ambient and specular lighting // 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}; static GLfloat glcolGrey[4]= {0.5f,0.5f,0.5f,1.f};
// No lightmap or all blacks??, just setup "black texture" for stage 0. // No lightmap or all blacks??, just setup "black texture" for stage 0.
if(_NLightMaps==0) if (_NLightMaps==0)
{ {
ITexture *text= mat.getTexture(0); ITexture *text= mat.getTexture(0);
activateTexture(0,text); activateTexture(0,text);
@ -819,7 +819,7 @@ void CDriverGL3::setupLightMapPass(uint pass)
_DriverGLStates.setTexGenMode(0, 0); _DriverGLStates.setTexGenMode(0, 0);
// And disable other stages. // And disable other stages.
for(uint stage = 1; stage < inlGetNumTextStages(); stage++) for (uint stage = 1; stage < inlGetNumTextStages(); stage++)
{ {
// disable texturing. // disable texturing.
activateTexture(stage, NULL); activateTexture(stage, NULL);
@ -845,7 +845,7 @@ void CDriverGL3::setupLightMapPass(uint pass)
uint32 g=0; uint32 g=0;
uint32 b=0; uint32 b=0;
// sum only the ambient of lightmaps that will be drawn this pass // 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]; uint wla= _LightMapLUT[lmapId+sa];
// must mul them by their respective mapFactor too // must mul them by their respective mapFactor too
@ -867,10 +867,10 @@ void CDriverGL3::setupLightMapPass(uint pass)
} }
// setup all stages. // setup all stages.
for(uint stage= 0; stage<inlGetNumTextStages(); stage++) for (uint stage= 0; stage<inlGetNumTextStages(); stage++)
{ {
// if must setup a lightmap stage. // if must setup a lightmap stage.
if(stage<nstages-1) if (stage<nstages-1)
{ {
// setup lightMap. // setup lightMap.
uint whichLightMap= _LightMapLUT[lmapId]; uint whichLightMap= _LightMapLUT[lmapId];
@ -889,29 +889,29 @@ void CDriverGL3::setupLightMapPass(uint pass)
// If texture not NULL, Change texture env fonction. // If texture not NULL, Change texture env fonction.
//================================================== //==================================================
if(text) if (text)
{ {
static CMaterial::CTexEnv stdEnv; static CMaterial::CTexEnv stdEnv;
{ {
// Here, we are sure that texEnvCombine4 or texEnvCombine3 is OK. // Here, we are sure that texEnvCombine4 or texEnvCombine3 is OK.
// nlassert( _Extensions.ATITextureEnvCombine3); // nlassert(_Extensions.ATITextureEnvCombine3);
// setup constant color with Lightmap factor. // setup constant color with Lightmap factor.
stdEnv.ConstantColor=lmapFactor; stdEnv.ConstantColor=lmapFactor;
int cl = currentProgram.pp->getUniformIndex( CProgramIndex::TName( CProgramIndex::Constant0 + stage ) ); int cl = currentProgram.pp->getUniformIndex(CProgramIndex::TName(CProgramIndex::Constant0 + stage));
if( cl != -1 ) if (cl != -1)
{ {
GLfloat glCol[ 4 ]; GLfloat glCol[ 4 ];
convColor( lmapFactor, glCol ); convColor(lmapFactor, glCol);
setUniform4f( IDriver::PixelProgram, cl, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ] ); setUniform4f(IDriver::PixelProgram, cl, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ]);
} }
int tl = currentProgram.pp->getUniformIndex( CProgramIndex::TName( CProgramIndex::Sampler0 + stage ) ); int tl = currentProgram.pp->getUniformIndex(CProgramIndex::TName(CProgramIndex::Sampler0 + stage));
if( tl != -1 ) if (tl != -1)
{ {
setUniform1i( IDriver::PixelProgram, tl, stage ); setUniform1i(IDriver::PixelProgram, tl, stage);
} }
activateTexEnvColor(stage, stdEnv); activateTexEnvColor(stage, stdEnv);
@ -921,7 +921,7 @@ void CDriverGL3::setupLightMapPass(uint pass)
_DriverGLStates.setTexGenMode(stage, 0); _DriverGLStates.setTexGenMode(stage, 0);
// setup TexEnvCombine4 (ignore alpha part). // setup TexEnvCombine4 (ignore alpha part).
if(_CurrentTexEnvSpecial[stage] != TexEnvSpecialLightMap) if (_CurrentTexEnvSpecial[stage] != TexEnvSpecialLightMap)
{ {
// TexEnv is special. // TexEnv is special.
_CurrentTexEnvSpecial[stage] = TexEnvSpecialLightMap; _CurrentTexEnvSpecial[stage] = TexEnvSpecialLightMap;
@ -932,11 +932,11 @@ void CDriverGL3::setupLightMapPass(uint pass)
// Next lightmap. // Next lightmap.
lmapId++; lmapId++;
} }
else if(stage<nstages) else if (stage<nstages)
{ {
// optim: do this only for first pass, and last pass only if stage!=nLMapPerPass // optim: do this only for first pass, and last pass only if stage!=nLMapPerPass
// (meaning not the same stage as preceding passes). // (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. // activate the texture at last stage.
ITexture *text= mat.getTexture(0); ITexture *text= mat.getTexture(0);
@ -949,10 +949,10 @@ void CDriverGL3::setupLightMapPass(uint pass)
_DriverGLStates.activeTextureARB(stage); _DriverGLStates.activeTextureARB(stage);
_DriverGLStates.setTexGenMode(stage, 0); _DriverGLStates.setTexGenMode(stage, 0);
int tl = currentProgram.pp->getUniformIndex( CProgramIndex::TName( CProgramIndex::Sampler0 + stage ) ); int tl = currentProgram.pp->getUniformIndex(CProgramIndex::TName(CProgramIndex::Sampler0 + stage));
if( tl != -1 ) 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 // Blend is different if the material is blended or not
if( !mat.getBlend() ) if (!mat.getBlend())
{ {
// Not blended, std case. // Not blended, std case.
if(pass==0) if (pass==0)
{ {
// no transparency for first pass. // no transparency for first pass.
_DriverGLStates.enableBlend(false); _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). // setup an Additive transparency (only for pass 1, will be kept for successives pass).
_DriverGLStates.enableBlend(true); _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)= finalResult= T*l1 * A + fint = T*l1 * A + T*l0 * A + B * (1-A)=
T* (l0+l1) * A + B * (1-A) T* (l0+l1) * A + B * (1-A)
*/ */
if(pass==0) if (pass==0)
{ {
// no transparency for first pass. // no transparency for first pass.
_DriverGLStates.enableBlend(true); _DriverGLStates.enableBlend(true);
_DriverGLStates.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); _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). // setup an Additive transparency (only for pass 1, will be kept for successives pass).
_DriverGLStates.enableBlend(true); _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) // 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 the lightmap is in x2 mode, then must divide effect of the dynamic light too
if (mat._LightMapsMulx2) if (mat._LightMapsMulx2)
@ -1027,7 +1027,7 @@ void CDriverGL3::setupLightMapPass(uint pass)
_DriverGLStates.setDiffuse(packedColorWhite, glcolWhite); _DriverGLStates.setDiffuse(packedColorWhite, glcolWhite);
} }
// no need to reset for pass after 1, since same than prec pass (black)! // 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); _DriverGLStates.setDiffuse(packedColorBlack, glcolBlack);
} }
@ -1061,7 +1061,7 @@ void CDriverGL3::setupSpecularBegin()
H_AUTO_OGL(CDriverGL3_setupSpecularBegin) H_AUTO_OGL(CDriverGL3_setupSpecularBegin)
// ---- Reset any textures with id>=2 // ---- Reset any textures with id>=2
uint stage = 2; uint stage = 2;
for(; stage < inlGetNumTextStages(); stage++) for (; stage < inlGetNumTextStages(); stage++)
{ {
// disable texturing // disable texturing
activateTexture(stage, NULL); activateTexture(stage, NULL);
@ -1109,7 +1109,7 @@ sint CDriverGL3::beginSpecularMultiPass()
// activate the 2 textures here // activate the 2 textures here
uint stage; uint stage;
uint numStages= std::min((uint)2, inlGetNumTextStages()); 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)); ITexture *text= mat.getTexture(uint8(stage));
@ -1118,14 +1118,14 @@ sint CDriverGL3::beginSpecularMultiPass()
} }
// End specular , only if not Batching mode. // End specular , only if not Batching mode.
if(!_SpecularBatchOn) if (!_SpecularBatchOn)
setupSpecularBegin(); setupSpecularBegin();
// Manage the rare case when the SpecularMap is not provided (fault of graphist). // 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; return 1;
if(!_Extensions.ARBTextureCubeMap) if (!_Extensions.ARBTextureCubeMap)
return 1; return 1;
return 1; return 1;
@ -1138,29 +1138,29 @@ void CDriverGL3::setupSpecularPass(uint pass)
const CMaterial &mat= *_CurrentMaterial; const CMaterial &mat= *_CurrentMaterial;
// Manage the rare case when the SpecularMap is not provided (error of a graphist). // 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 // Just display the texture
// NB: setupMaterial() code has correclty setuped textures. // NB: setupMaterial() code has correclty setuped textures.
return; return;
} }
int sl0 = currentProgram.pp->getUniformIndex( CProgramIndex::Sampler0 ); int sl0 = currentProgram.pp->getUniformIndex(CProgramIndex::Sampler0);
if( sl0 != -1 ) if (sl0 != -1)
{ {
setUniform1i( IDriver::PixelProgram, sl0, 0 ); setUniform1i(IDriver::PixelProgram, sl0, 0);
} }
int sl1 = currentProgram.pp->getUniformIndex( CProgramIndex::Sampler1 ); int sl1 = currentProgram.pp->getUniformIndex(CProgramIndex::Sampler1);
if( sl1 != -1 ) if (sl1 != -1)
{ {
setUniform1i( IDriver::PixelProgram, sl1, 1 ); setUniform1i(IDriver::PixelProgram, sl1, 1);
} }
int tml = currentProgram.vp->getUniformIndex( CProgramIndex::TexMatrix0 ); int tml = currentProgram.vp->getUniformIndex(CProgramIndex::TexMatrix0);
if( tml != -1 ) 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 // Set Stage 1
// Special: not the same special env if there is or not texture in stage 0. // Special: not the same special env if there is or not texture in stage 0.
CTexEnvSpecial newEnvStage1; CTexEnvSpecial newEnvStage1;
if( mat.getTexture(0) == NULL ) if (mat.getTexture(0) == NULL)
newEnvStage1= TexEnvSpecialSpecularStage1NoText; newEnvStage1= TexEnvSpecialSpecularStage1NoText;
else else
newEnvStage1= TexEnvSpecialSpecularStage1; newEnvStage1= TexEnvSpecialSpecularStage1;
// Test if same env as prec. // Test if same env as prec.
if(_CurrentTexEnvSpecial[1] != newEnvStage1) if (_CurrentTexEnvSpecial[1] != newEnvStage1)
{ {
// TexEnv is special. // TexEnv is special.
_CurrentTexEnvSpecial[1] = newEnvStage1; _CurrentTexEnvSpecial[1] = newEnvStage1;
@ -1190,7 +1190,7 @@ void CDriverGL3::endSpecularMultiPass()
{ {
H_AUTO_OGL(CDriverGL3_endSpecularMultiPass) H_AUTO_OGL(CDriverGL3_endSpecularMultiPass)
// End specular , only if not Batching mode. // End specular , only if not Batching mode.
if(!_SpecularBatchOn) if (!_SpecularBatchOn)
setupSpecularEnd(); setupSpecularEnd();
} }
@ -1504,7 +1504,7 @@ void CDriverGL3::endCausticsMultiPass(const CMaterial &mat)
// *************************************************************************** // ***************************************************************************
sint CDriverGL3::beginCloudMultiPass () sint CDriverGL3::beginCloudMultiPass ()
{ {
H_AUTO_OGL(CDriverGL3_beginCloudMultiPass ) H_AUTO_OGL(CDriverGL3_beginCloudMultiPass)
nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud); nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud);
return 1; return 1;
} }
@ -1512,7 +1512,7 @@ sint CDriverGL3::beginCloudMultiPass ()
// *************************************************************************** // ***************************************************************************
void CDriverGL3::setupCloudPass (uint /* pass */) void CDriverGL3::setupCloudPass (uint /* pass */)
{ {
H_AUTO_OGL(CDriverGL3_setupCloudPass ) H_AUTO_OGL(CDriverGL3_setupCloudPass)
nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud); nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud);
const CMaterial &mat= *_CurrentMaterial; 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); H_AUTO_OGL(CDriverGL3_setFrustum);
if( perspective ) if (perspective)
_GLProjMat.frustum( left, right, bottom, top, znear, zfar ); _GLProjMat.frustum(left, right, bottom, top, znear, zfar);
else 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) H_AUTO_OGL(CDriverGL3_renderLines)
// setup material // setup material
if ( !setupMaterial(mat) || _LastIB._Values == NULL ) if (!setupMaterial(mat) || _LastIB._Values == NULL)
return false; return false;
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
@ -43,14 +43,14 @@ bool CDriverGL3::renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines)
uint nPass; uint nPass;
nPass= beginMultiPass(); nPass= beginMultiPass();
// draw all passes. // draw all passes.
for(uint pass=0;pass<nPass; pass++) for (uint pass=0;pass<nPass; pass++)
{ {
// setup the pass. // setup the pass.
if( !setupPass(pass) ) if (!setupPass(pass))
return false; return false;
// draw the primitives. // draw the primitives.
if(nlines) if (nlines)
{ {
if (_LastIB._Format == CIndexBuffer::Indices16) if (_LastIB._Format == CIndexBuffer::Indices16)
{ {
@ -82,7 +82,7 @@ bool CDriverGL3::renderTriangles(CMaterial& mat, uint32 firstIndex, uint32 ntris
H_AUTO_OGL(CDriverGL3_renderTriangles); H_AUTO_OGL(CDriverGL3_renderTriangles);
// setup material // setup material
if ( !setupMaterial(mat) || _LastIB._Values == NULL ) if (!setupMaterial(mat) || _LastIB._Values == NULL)
return false; return false;
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
@ -95,14 +95,14 @@ bool CDriverGL3::renderTriangles(CMaterial& mat, uint32 firstIndex, uint32 ntris
nPass= beginMultiPass(); nPass= beginMultiPass();
// draw all passes. // draw all passes.
for(uint pass=0;pass<nPass; pass++) for (uint pass=0;pass<nPass; pass++)
{ {
// setup the pass. // setup the pass.
if( !setupPass(pass) ) if (!setupPass(pass))
return false; return false;
// draw the primitives. // draw the primitives.
if(ntris) if (ntris)
{ {
if (_LastIB._Format == CIndexBuffer::Indices16) if (_LastIB._Format == CIndexBuffer::Indices16)
{ {
@ -170,7 +170,7 @@ bool CDriverGL3::renderRawPoints(CMaterial& mat, uint32 startIndex, uint32 numPo
H_AUTO_OGL(CDriverGL3_renderRawPoints) H_AUTO_OGL(CDriverGL3_renderRawPoints)
// setup material // setup material
if ( !setupMaterial(mat) ) if (!setupMaterial(mat))
return false; return false;
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
@ -180,14 +180,14 @@ bool CDriverGL3::renderRawPoints(CMaterial& mat, uint32 startIndex, uint32 numPo
uint nPass; uint nPass;
nPass= beginMultiPass(); nPass= beginMultiPass();
// draw all passes. // draw all passes.
for(uint pass=0;pass<nPass; pass++) for (uint pass=0;pass<nPass; pass++)
{ {
// setup the pass. // setup the pass.
if( !setupPass(pass) ) if (!setupPass(pass))
return false; return false;
// draw the primitives. // draw the primitives.
if(numPoints) if (numPoints)
glDrawArrays(GL_POINTS, startIndex, numPoints); glDrawArrays(GL_POINTS, startIndex, numPoints);
} }
// end multipass. // end multipass.
@ -210,7 +210,7 @@ bool CDriverGL3::renderRawLines(CMaterial& mat, uint32 startIndex, uint32 numLin
H_AUTO_OGL(CDriverGL3_renderRawLines) H_AUTO_OGL(CDriverGL3_renderRawLines)
// setup material // setup material
if ( !setupMaterial(mat) ) if (!setupMaterial(mat))
return false; return false;
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
@ -220,14 +220,14 @@ bool CDriverGL3::renderRawLines(CMaterial& mat, uint32 startIndex, uint32 numLin
uint nPass; uint nPass;
nPass= beginMultiPass(); nPass= beginMultiPass();
// draw all passes. // draw all passes.
for(uint pass=0;pass<nPass; pass++) for (uint pass=0;pass<nPass; pass++)
{ {
// setup the pass. // setup the pass.
if( !setupPass(pass) ) if (!setupPass(pass))
return false; return false;
// draw the primitives. // draw the primitives.
if(numLines) if (numLines)
glDrawArrays(GL_LINES, startIndex << 1, numLines << 1); glDrawArrays(GL_LINES, startIndex << 1, numLines << 1);
} }
// end multipass. // end multipass.
@ -250,7 +250,7 @@ bool CDriverGL3::renderRawTriangles(CMaterial& mat, uint32 startIndex, uint32 nu
H_AUTO_OGL(CDriverGL3_renderRawTriangles) H_AUTO_OGL(CDriverGL3_renderRawTriangles)
// setup material // setup material
if ( !setupMaterial(mat) ) if (!setupMaterial(mat))
return false; return false;
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
@ -260,14 +260,14 @@ bool CDriverGL3::renderRawTriangles(CMaterial& mat, uint32 startIndex, uint32 nu
uint nPass; uint nPass;
nPass= beginMultiPass(); nPass= beginMultiPass();
// draw all passes. // draw all passes.
for(uint pass=0;pass<nPass; pass++) for (uint pass=0;pass<nPass; pass++)
{ {
// setup the pass. // setup the pass.
if( !setupPass(pass) ) if (!setupPass(pass))
return false; return false;
// draw the primitives. // draw the primitives.
if(numTris) if (numTris)
{ {
glDrawArrays(GL_TRIANGLES, startIndex*3, numTris*3); glDrawArrays(GL_TRIANGLES, startIndex*3, numTris*3);
} }
@ -293,7 +293,7 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua
if (!numQuads) return true; if (!numQuads) return true;
// setup material // setup material
if ( !setupMaterial(mat) ) if (!setupMaterial(mat))
return false; return false;
if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true;
@ -304,7 +304,7 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua
if (!init) if (!init)
{ {
// setup the base index buffer // 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 // first tri
defaultIndices[k * 6] = (GLshort) (k * 4); defaultIndices[k * 6] = (GLshort) (k * 4);
@ -325,10 +325,10 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua
uint nPass; uint nPass;
nPass= beginMultiPass(); nPass= beginMultiPass();
// draw all passes. // draw all passes.
for(uint pass=0;pass<nPass; pass++) for (uint pass=0;pass<nPass; pass++)
{ {
// setup the pass. // setup the pass.
if( !setupPass(pass) ) if (!setupPass(pass))
return false; return false;
uint32 currIndex = startIndex; uint32 currIndex = startIndex;
@ -367,7 +367,7 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua
*curr++ = vertexIndex + 3; *curr++ = vertexIndex + 3;
vertexIndex += 4; vertexIndex += 4;
} }
while(curr != end); while (curr != end);
glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_SHORT, indices); glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_SHORT, indices);
} }
else else
@ -387,7 +387,7 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua
*curr++ = vertexIndex + 3; *curr++ = vertexIndex + 3;
vertexIndex += 4; vertexIndex += 4;
} }
while(curr != end); while (curr != end);
glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_INT, indices); glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_INT, indices);
} }
numLeftQuads -= numQuadsToDraw; numLeftQuads -= numQuadsToDraw;

@ -28,26 +28,26 @@ namespace NL3D
clearCache(); 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 shaders[ i ].getShaders();
} }
return SShaderPair(); return SShaderPair();
} }
void CShaderCache::cacheShader( CShaderDesc &desc ) void CShaderCache::cacheShader(CShaderDesc &desc)
{ {
shaders.push_back( desc ); shaders.push_back(desc);
} }
void CShaderCache::clearCache() void CShaderCache::clearCache()
{ {
std::vector< CShaderDesc >::iterator itr = shaders.begin(); std::vector< CShaderDesc >::iterator itr = shaders.begin();
while( itr != shaders.end() ) while (itr != shaders.end())
{ {
SShaderPair sp; SShaderPair sp;
sp = itr->getShaders(); sp = itr->getShaders();

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

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

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

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

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

@ -111,7 +111,7 @@ IVertexBufferHardGL *CVertexArrayRange::createVBHardGL(uint size, CVertexBuffer
void CVertexArrayRange::enable() void CVertexArrayRange::enable()
{ {
H_AUTO_OGL(CVertexArrayRangeARB_enable) H_AUTO_OGL(CVertexArrayRangeARB_enable)
if(_Driver->_CurrentVertexArrayRange != this) if (_Driver->_CurrentVertexArrayRange != this)
{ {
_Driver->_CurrentVertexArrayRange= this; _Driver->_CurrentVertexArrayRange= this;
} }
@ -121,7 +121,7 @@ void CVertexArrayRange::enable()
void CVertexArrayRange::disable() void CVertexArrayRange::disable()
{ {
H_AUTO_OGL(CVertexArrayRangeARB_disbale) H_AUTO_OGL(CVertexArrayRangeARB_disbale)
if(_Driver->_CurrentVertexBufferHard != NULL) if (_Driver->_CurrentVertexBufferHard != NULL)
{ {
_Driver->_CurrentVertexBufferHard= NULL; _Driver->_CurrentVertexBufferHard= NULL;
} }
@ -136,7 +136,7 @@ void CVertexArrayRange::updateLostBuffers()
nlassert(_Driver); nlassert(_Driver);
if (_Driver->isWndActive()) 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); nlassert((*it)->_VertexObjectId);
GLuint id = (GLuint) (*it)->_VertexObjectId; GLuint id = (GLuint) (*it)->_VertexObjectId;
@ -261,7 +261,7 @@ void *CVertexBufferHard::lock()
// continue to standard mapping code below .. // continue to standard mapping code below ..
} }
TTicks beforeLock = 0; TTicks beforeLock = 0;
if(_Driver->_VBHardProfiling) if (_Driver->_VBHardProfiling)
{ {
beforeLock= CTime::getPerformanceTime(); beforeLock= CTime::getPerformanceTime();
} }
@ -283,7 +283,7 @@ void *CVertexBufferHard::lock()
#endif #endif
_Driver->_DriverGLStates.forceBindARBVertexBuffer(0); _Driver->_DriverGLStates.forceBindARBVertexBuffer(0);
// Lock Profile? // Lock Profile?
if(_Driver->_VBHardProfiling) if (_Driver->_VBHardProfiling)
{ {
TTicks afterLock; TTicks afterLock;
afterLock= CTime::getPerformanceTime(); afterLock= CTime::getPerformanceTime();
@ -301,7 +301,7 @@ void CVertexBufferHard::unlock()
if (_Invalid) return; if (_Invalid) return;
if (!_VertexObjectId) return; if (!_VertexObjectId) return;
TTicks beforeLock = 0; TTicks beforeLock = 0;
if(_Driver->_VBHardProfiling) if (_Driver->_VBHardProfiling)
{ {
beforeLock= CTime::getPerformanceTime(); beforeLock= CTime::getPerformanceTime();
} }
@ -318,7 +318,7 @@ void CVertexBufferHard::unlock()
_Unmapping = false; _Unmapping = false;
#endif #endif
// Lock Profile? // Lock Profile?
if(_Driver->_VBHardProfiling) if (_Driver->_VBHardProfiling)
{ {
TTicks afterLock; TTicks afterLock;
afterLock= CTime::getPerformanceTime(); afterLock= CTime::getPerformanceTime();
@ -354,7 +354,7 @@ void CVertexBufferHard::unlock(uint /* startVert */,uint /* endVert */)
void CVertexBufferHard::enable() void CVertexBufferHard::enable()
{ {
H_AUTO_OGL(CVertexBufferHardARB_enable) H_AUTO_OGL(CVertexBufferHardARB_enable)
if(_Driver->_CurrentVertexBufferHard != this) if (_Driver->_CurrentVertexBufferHard != this)
{ {
/* nlassert(_VertexArrayRange); /* nlassert(_VertexArrayRange);
_VertexArrayRange->enable(); */ _VertexArrayRange->enable(); */
@ -366,7 +366,7 @@ void CVertexBufferHard::enable()
void CVertexBufferHard::disable() void CVertexBufferHard::disable()
{ {
H_AUTO_OGL(CVertexBufferHardARB_disable) H_AUTO_OGL(CVertexBufferHardARB_disable)
if(_Driver->_CurrentVertexBufferHard != NULL) if (_Driver->_CurrentVertexBufferHard != NULL)
{ {
/* nlassert(_VertexArrayRange); /* nlassert(_VertexArrayRange);
_VertexArrayRange->disable(); */ _VertexArrayRange->disable(); */
@ -418,7 +418,7 @@ void CVertexBufferHard::invalidate()
{ {
nlwarning("*****************************************************"); nlwarning("*****************************************************");
nlwarning("Mapped buffers :"); 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; CVertexBufferHard &vbarb = **it;
nlwarning("Buffer id = %u, size = %u, address = %p", vbarb._VertexObjectId, vbarb.VB->getVertexSize() * vbarb.VB->getNumVertices(), vbarb.getPointer()); 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) if (!driver)
return false; return false;
if(message == WM_SIZE) if (message == WM_SIZE)
{ {
if (driver->_CurrentMode.Windowed) 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); driver->_CurrentMode.Height = (uint16)(rect.bottom-rect.top);
} }
} }
else if(message == WM_MOVE) else if (message == WM_MOVE)
{ {
if (driver->_CurrentMode.Windowed) 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) // disable menu (default ALT-F4 behavior is disabled)
if (message == WM_CLOSE) if (message == WM_CLOSE)
{ {
if(pDriver && pDriver->ExitFunc) if (pDriver && pDriver->ExitFunc)
{ {
pDriver->ExitFunc(); pDriver->ExitFunc();
} }
@ -174,7 +174,7 @@ bool GlWndProc(CDriverGL3 *driver, const void* e)
{ {
H_AUTO_OGL(GlWndProc) H_AUTO_OGL(GlWndProc)
if(!driver) if (!driver)
return false; return false;
NSEvent* event = [NSEvent eventWithEventRef:e]; NSEvent* event = [NSEvent eventWithEventRef:e];
@ -214,7 +214,7 @@ bool GlWndProc(CDriverGL3 *driver, XEvent &e)
{ {
case DestroyNotify: case DestroyNotify:
if(driver && driver->ExitFunc) if (driver && driver->ExitFunc)
{ {
driver->ExitFunc(); driver->ExitFunc();
} }
@ -316,7 +316,7 @@ bool CDriverGL3::init (uint windowIcon, emptyProc exitFunc)
wc.hbrBackground = WHITE_BRUSH; wc.hbrBackground = WHITE_BRUSH;
wc.lpszClassName = L"NLClass"; wc.lpszClassName = L"NLClass";
wc.lpszMenuName = NULL; wc.lpszMenuName = NULL;
if ( !RegisterClassW(&wc) ) if (!RegisterClassW(&wc))
{ {
return false; return false;
} }
@ -402,11 +402,11 @@ bool CDriverGL3::init (uint windowIcon, emptyProc exitFunc)
sint nextensions = 0; sint nextensions = 0;
char **extensions = XListExtensions(_dpy, &nextensions); 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()); 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"); DebugLog->displayRaw("\n");
@ -524,7 +524,7 @@ void CDriverGL3::setWindowIcon(const std::vector<NLMISC::CBitmap> &bitmaps)
uint bigHeight = GetSystemMetrics(SM_CYICON); uint bigHeight = GetSystemMetrics(SM_CYICON);
// find icons with the exact size // 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) if (smallIndex == -1 && bitmaps[i].getWidth() == smallWidth && bitmaps[i].getHeight() == smallHeight)
smallIndex = i; smallIndex = i;
@ -534,7 +534,7 @@ void CDriverGL3::setWindowIcon(const std::vector<NLMISC::CBitmap> &bitmaps)
} }
// find icons with taller size (we will resize them) // 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) if (smallIndex == -1 && bitmaps[i].getWidth() >= smallWidth && bitmaps[i].getHeight() >= smallHeight)
smallIndex = i; smallIndex = i;
@ -571,7 +571,7 @@ void CDriverGL3::setWindowIcon(const std::vector<NLMISC::CBitmap> &bitmaps)
if (!bitmaps.empty()) if (!bitmaps.empty())
{ {
// process each bitmap // process each bitmap
for(uint i = 0; i < bitmaps.size(); ++i) for (uint i = 0; i < bitmaps.size(); ++i)
{ {
convertBitmapToIcon(bitmaps[i], icon_data); convertBitmapToIcon(bitmaps[i], icon_data);
} }
@ -626,7 +626,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
RECT rc; RECT rc;
SetRect (&rc, 0, 0, width, height); SetRect (&rc, 0, 0, width, height);
AdjustWindowRectEx (&rc, GetWindowStyle (_win), GetMenu (_win) != NULL, GetWindowExStyle (_win)); 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 // Get the
HDC tempHDC = GetDC(tmpHWND); HDC tempHDC = GetDC(tmpHWND);
@ -642,7 +642,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
_pfd.cColorBits = _CurrentMode.Depth; _pfd.cColorBits = _CurrentMode.Depth;
// Choose best suited Depth Buffer. // Choose best suited Depth Buffer.
if(_CurrentMode.Depth<=16) if (_CurrentMode.Depth<=16)
{ {
_pfd.cDepthBits = 16; _pfd.cDepthBits = 16;
} }
@ -659,7 +659,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
DestroyWindow (tmpHWND); DestroyWindow (tmpHWND);
return false; return false;
} }
if ( !SetPixelFormat(tempHDC,pf,&_pfd) ) if (!SetPixelFormat(tempHDC,pf,&_pfd))
{ {
nlwarning ("CDriverGL3::setDisplay: SetPixelFormat failed"); nlwarning ("CDriverGL3::setDisplay: SetPixelFormat failed");
DestroyWindow (tmpHWND); 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 // Attribute arrays must be "0" terminated - for simplicity, first
// just zero-out the array then fill from left to right. // 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; iattributes[a] = 0;
fattributes[a] = 0; fattributes[a] = 0;
@ -754,10 +754,10 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
// requirements. // requirements.
int pformat[20]; int pformat[20];
unsigned int nformats; unsigned int nformats;
if ( !nwglChoosePixelFormatARB ( hdc, iattributes, fattributes, if (!nwglChoosePixelFormatARB (hdc, iattributes, fattributes,
20, pformat, &nformats ) ) 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); wglDeleteContext (tempGLRC);
DestroyWindow (tmpHWND); DestroyWindow (tmpHWND);
return false; 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: */ returned in the list in step #2 and call the function: */
int iattributes2[1] = {0}; int iattributes2[1] = {0};
// int iattributes2[] = {WGL_PBUFFER_LARGEST_ARB, 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) if (_PBuffer == NULL)
{ {
DWORD error = GetLastError (); 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. */ /* 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 (); DWORD error = GetLastError ();
nlwarning ("CDriverGL3::setDisplay: wglQueryPbufferARB failed: 0x%x", error); 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; return false;
} }
if ( !nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height ) ) if (!nwglQueryPbufferARB(_PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height))
{ {
DWORD error = GetLastError (); DWORD error = GetLastError ();
nlwarning ("CDriverGL3::setDisplay: wglQueryPbufferARB failed: 0x%x", error); 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, /* The next step is to create a device context for the newly created pbuffer. To do this,
call to the function: */ call to the function: */
_hDC = nwglGetPbufferDCARB( _PBuffer ); _hDC = nwglGetPbufferDCARB(_PBuffer);
if (_hDC == NULL) if (_hDC == NULL)
{ {
DWORD error = GetLastError (); DWORD error = GetLastError ();
nlwarning ("CDriverGL3::setDisplay: wglGetPbufferDCARB failed: 0x%x", error); nlwarning ("CDriverGL3::setDisplay: wglGetPbufferDCARB failed: 0x%x", error);
nwglDestroyPbufferARB( _PBuffer ); nwglDestroyPbufferARB(_PBuffer);
wglDeleteContext (tempGLRC); 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 /* 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 */ 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) if (_hRC == NULL)
{ {
DWORD error = GetLastError (); DWORD error = GetLastError ();
nlwarning ("CDriverGL3::setDisplay: wglCreateContext failed: 0x%x", error); nlwarning ("CDriverGL3::setDisplay: wglCreateContext failed: 0x%x", error);
nwglReleasePbufferDCARB( _PBuffer, _hDC ); nwglReleasePbufferDCARB(_PBuffer, _hDC);
nwglDestroyPbufferARB( _PBuffer ); nwglDestroyPbufferARB(_PBuffer);
wglDeleteContext (tempGLRC); wglDeleteContext (tempGLRC);
DestroyWindow (tmpHWND); DestroyWindow (tmpHWND);
_PBuffer = NULL; _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); nlwarning ("CDriverGL3::setDisplay: wglMakeCurrent failed: 0x%x", error);
wglDeleteContext (_hRC); wglDeleteContext (_hRC);
nwglReleasePbufferDCARB( _PBuffer, _hDC ); nwglReleasePbufferDCARB(_PBuffer, _hDC);
nwglDestroyPbufferARB( _PBuffer ); nwglDestroyPbufferARB(_PBuffer);
DestroyWindow (tmpHWND); DestroyWindow (tmpHWND);
_PBuffer = NULL; _PBuffer = NULL;
@ -951,7 +951,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
* (http://dev.ryzom.com/issues/1013) * (http://dev.ryzom.com/issues/1013)
*/ */
NSView* view = (NSView*)wnd; 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]; [view setBoundsOrigin:view.frame.origin];
} }
} }
@ -974,7 +974,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
NSOpenGLPixelFormat* format = NSOpenGLPixelFormat* format =
[[NSOpenGLPixelFormat alloc] initWithAttributes:att]; [[NSOpenGLPixelFormat alloc] initWithAttributes:att];
if(!format) if (!format)
nlerror("cannot create NSOpenGLPixelFormat"); nlerror("cannot create NSOpenGLPixelFormat");
// intially set height/width, further updates through CocoaOpenGLView // 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) initWithFrame:NSMakeRect(0, 0, mode.Width, mode.Height)
pixelFormat:format]; pixelFormat:format];
if(!_glView) if (!_glView)
nlerror("cannot create view"); nlerror("cannot create view");
// tell the view about the driver so the view is able to update "window" size // 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 // create a opengl context for the view
_ctx = [_glView openGLContext]; _ctx = [_glView openGLContext];
if(!_ctx) if (!_ctx)
nlerror("cannot create context"); nlerror("cannot create context");
// free the pixel format object // 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); XVisualInfo *visual_info = glXChooseVisual (_dpy, DefaultScreen(_dpy), sAttribList24bpp);
if (visual_info == NULL) if (visual_info == NULL)
visual_info = glXChooseVisual(_dpy, DefaultScreen(_dpy), sAttribList16bpp); visual_info = glXChooseVisual(_dpy, DefaultScreen(_dpy), sAttribList16bpp);
if(visual_info == NULL) if (visual_info == NULL)
{ {
nlerror("glXChooseVisual() failed"); nlerror("glXChooseVisual() failed");
} }
@ -1297,13 +1297,13 @@ bool CDriverGL3::setScreenMode(const GfxMode &mode)
devMode.dmPelsWidth = mode.Width; devMode.dmPelsWidth = mode.Width;
devMode.dmPelsHeight = mode.Height; devMode.dmPelsHeight = mode.Height;
if(mode.Depth > 0) if (mode.Depth > 0)
{ {
devMode.dmBitsPerPel = mode.Depth; devMode.dmBitsPerPel = mode.Depth;
devMode.dmFields |= DM_BITSPERPEL; devMode.dmFields |= DM_BITSPERPEL;
} }
if(mode.Frequency > 0) if (mode.Frequency > 0)
{ {
devMode.dmDisplayFrequency = mode.Frequency; devMode.dmDisplayFrequency = mode.Frequency;
devMode.dmFields |= DM_DISPLAYFREQUENCY; devMode.dmFields |= DM_DISPLAYFREQUENCY;
@ -1447,7 +1447,7 @@ bool CDriverGL3::createWindow(const GfxMode &mode)
initWithContentRect:NSMakeRect(0, 0, mode.Width, mode.Height) initWithContentRect:NSMakeRect(0, 0, mode.Width, mode.Height)
styleMask:styleMask backing:NSBackingStoreBuffered defer:NO]; styleMask:styleMask backing:NSBackingStoreBuffered defer:NO];
if(!cocoa_window) if (!cocoa_window)
{ {
nlerror("cannot create cocoa window"); nlerror("cannot create cocoa window");
return false; return false;
@ -1490,7 +1490,7 @@ bool CDriverGL3::createWindow(const GfxMode &mode)
[cocoa_window setContentView: (NSView*)window]; [cocoa_window setContentView: (NSView*)window];
if(window == EmptyWindow) if (window == EmptyWindow)
{ {
nldebug("cannot create cocoa view for cocoa window"); nldebug("cannot create cocoa view for cocoa window");
return false; return false;
@ -1716,14 +1716,14 @@ bool CDriverGL3::setWindowStyle(EWindowStyle windowStyle)
#elif defined(NL_OS_MAC) #elif defined(NL_OS_MAC)
// leave fullscreen mode, enter windowed mode // 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 // disable manual setting of back buffer size, cocoa handles this
// automatically as soon as the view gets resized // automatically as soon as the view gets resized
CGLError error = CGLDisable((CGLContextObj)[_ctx CGLContextObj], CGLError error = CGLDisable((CGLContextObj)[_ctx CGLContextObj],
kCGLCESurfaceBackingSize); kCGLCESurfaceBackingSize);
if(error != kCGLNoError) if (error != kCGLNoError)
nlerror("cannot disable kCGLCESurfaceBackingSize (%s)", nlerror("cannot disable kCGLCESurfaceBackingSize (%s)",
CGLErrorString(error)); CGLErrorString(error));
@ -1738,13 +1738,13 @@ bool CDriverGL3::setWindowStyle(EWindowStyle windowStyle)
} }
// enter fullscreen, leave windowed mode // 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 // enable manual back buffer size for mode setting in fullscreen
CGLError error = CGLEnable((CGLContextObj)[_ctx CGLContextObj], CGLError error = CGLEnable((CGLContextObj)[_ctx CGLContextObj],
kCGLCESurfaceBackingSize); kCGLCESurfaceBackingSize);
if(error != kCGLNoError) if (error != kCGLNoError)
nlerror("cannot enable kCGLCESurfaceBackingSize (%s)", nlerror("cannot enable kCGLCESurfaceBackingSize (%s)",
CGLErrorString(error)); CGLErrorString(error));
@ -1859,11 +1859,11 @@ static int bppFromDisplayMode(CGDisplayModeRef mode)
{ {
CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding(mode); CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding(mode);
if(CFStringCompare(pixelEncoding, CFSTR(IO32BitDirectPixels), if (CFStringCompare(pixelEncoding, CFSTR(IO32BitDirectPixels),
kCFCompareCaseInsensitive) == kCFCompareEqualTo) kCFCompareCaseInsensitive) == kCFCompareEqualTo)
return 32; return 32;
else if(CFStringCompare(pixelEncoding, CFSTR(IO16BitDirectPixels), else if (CFStringCompare(pixelEncoding, CFSTR(IO16BitDirectPixels),
kCFCompareCaseInsensitive) == kCFCompareEqualTo) kCFCompareCaseInsensitive) == kCFCompareEqualTo)
return 16; return 16;
@ -1900,7 +1900,7 @@ bool CDriverGL3::getModes(std::vector<GfxMode> &modes)
while (EnumDisplaySettings (NULL, modeIndex, &devMode)) while (EnumDisplaySettings (NULL, modeIndex, &devMode))
{ {
// Keep only 16 and 32 bits // Keep only 16 and 32 bits
if ((devMode.dmBitsPerPel == 16 ) || (devMode.dmBitsPerPel == 32)) if ((devMode.dmBitsPerPel == 16) || (devMode.dmBitsPerPel == 32))
{ {
// Add this mode // Add this mode
GfxMode mode; GfxMode mode;
@ -1922,7 +1922,7 @@ bool CDriverGL3::getModes(std::vector<GfxMode> &modes)
CGDisplayCount numDisplays; CGDisplayCount numDisplays;
CGDisplayErr err = CGGetActiveDisplayList(kMaxDisplays, display, &numDisplays); CGDisplayErr err = CGGetActiveDisplayList(kMaxDisplays, display, &numDisplays);
if(err != CGDisplayNoErr) if (err != CGDisplayNoErr)
{ {
nlwarning("Cannot get displays (%d)", err); nlwarning("Cannot get displays (%d)", err);
return false; return false;
@ -2100,7 +2100,7 @@ bool CDriverGL3::getCurrentScreenMode(GfxMode &mode)
mode.Depth = NSBitsPerPixelFromDepth([screen depth]); mode.Depth = NSBitsPerPixelFromDepth([screen depth]);
// in fullscreen mode // in fullscreen mode
if([containerView() isInFullScreenMode]) if ([containerView() isInFullScreenMode])
{ {
// return the size of the back buffer (like having switched monitor mode) // return the size of the back buffer (like having switched monitor mode)
mode.Windowed = false; mode.Windowed = false;
@ -2352,7 +2352,7 @@ bool CDriverGL3::createContext()
_pfd.iPixelType = PFD_TYPE_RGBA; _pfd.iPixelType = PFD_TYPE_RGBA;
_pfd.cColorBits = _CurrentMode.Depth; _pfd.cColorBits = _CurrentMode.Depth;
// Choose best suited Depth Buffer. // Choose best suited Depth Buffer.
if(_CurrentMode.Depth <= 16) if (_CurrentMode.Depth <= 16)
{ {
_pfd.cDepthBits = 16; _pfd.cDepthBits = 16;
} }
@ -2369,7 +2369,7 @@ bool CDriverGL3::createContext()
return false; return false;
} }
if ( !SetPixelFormat(_hDC,pf,&_pfd) ) if (!SetPixelFormat(_hDC,pf,&_pfd))
{ {
return false; return false;
} }
@ -2398,7 +2398,7 @@ bool CDriverGL3::activate()
#elif defined(NL_OS_MAC) #elif defined(NL_OS_MAC)
if([NSOpenGLContext currentContext] != _ctx) if ([NSOpenGLContext currentContext] != _ctx)
[_ctx makeCurrentContext]; [_ctx makeCurrentContext];
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
@ -2466,15 +2466,15 @@ void CDriverGL3::getWindowSize(uint32 &width, uint32 &height)
if (_PBuffer) if (_PBuffer)
{ {
nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width ); nwglQueryPbufferARB(_PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width);
nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height ); nwglQueryPbufferARB(_PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height);
} }
#endif #endif
} }
else else
{ {
#ifdef NL_OS_MAC #ifdef NL_OS_MAC
if([containerView() isInFullScreenMode]) if ([containerView() isInFullScreenMode])
{ {
width = _backBufferWidth; width = _backBufferWidth;
height = _backBufferHeight; height = _backBufferHeight;
@ -2517,7 +2517,7 @@ void CDriverGL3::setWindowSize(uint32 width, uint32 height)
#elif defined(NL_OS_MAC) #elif defined(NL_OS_MAC)
// for fullscreen mode, adjust the back buffer size to desired resolution // for fullscreen mode, adjust the back buffer size to desired resolution
if([containerView() isInFullScreenMode]) if ([containerView() isInFullScreenMode])
{ {
// disable and re-enable fullscreen // disable and re-enable fullscreen
// fixes #1062 (http://dev.ryzom.com/issues/1062) // fixes #1062 (http://dev.ryzom.com/issues/1062)
@ -2530,7 +2530,7 @@ void CDriverGL3::setWindowSize(uint32 width, uint32 height)
(CGLContextObj)[_ctx CGLContextObj], (CGLContextObj)[_ctx CGLContextObj],
kCGLCPSurfaceBackingSize, dim); kCGLCPSurfaceBackingSize, dim);
if(error != kCGLNoError) if (error != kCGLNoError)
nlerror("cannot set kCGLCPSurfaceBackingSize parameter (%s)", nlerror("cannot set kCGLCPSurfaceBackingSize parameter (%s)",
CGLErrorString(error)); CGLErrorString(error));
@ -2540,7 +2540,7 @@ void CDriverGL3::setWindowSize(uint32 width, uint32 height)
else else
{ {
// only change the window size if the driver created the window itself // only change the window size if the driver created the window itself
if(_DestroyWindow) if (_DestroyWindow)
{ {
// get the windows current frame // get the windows current frame
NSRect rect = [[containerView() window] frame]; NSRect rect = [[containerView() window] frame];
@ -2635,7 +2635,7 @@ bool CDriverGL3::isActive()
// *************************************************************************** // ***************************************************************************
bool CDriverGL3::setMonitorColorProperties (const CMonitorColorProperties &properties) bool CDriverGL3::setMonitorColorProperties (const CMonitorColorProperties &properties)
{ {
H_AUTO_OGL(CDriverGL3_setMonitorColorProperties ) H_AUTO_OGL(CDriverGL3_setMonitorColorProperties)
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
@ -2648,19 +2648,19 @@ bool CDriverGL3::setMonitorColorProperties (const CMonitorColorProperties &prope
// For each composant // For each composant
uint c; uint c;
for( c=0; c<3; c++ ) for (c=0; c<3; c++)
{ {
uint i; uint i;
for( i=0; i<256; i++ ) for (i=0; i<256; i++)
{ {
// Floating value // Floating value
float value = (float)i / 256; float value = (float)i / 256;
// Contrast // 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 // 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 // Luminosity
value = value + properties.Luminosity[c] / 2.f; value = value + properties.Luminosity[c] / 2.f;
@ -2864,7 +2864,7 @@ bool CDriverGL3::convertBitmapToIcon(const NLMISC::CBitmap &bitmap, std::vector<
// convert RGBA to ARGB // convert RGBA to ARGB
CObjectVector<uint8> pixels = bitmap.getPixels(); 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; icon[pos++] = pixels[j] << 16 | pixels[j+1] << 8 | pixels[j+2] | pixels[j+3] << 24;
return true; return true;

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

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

Loading…
Cancel
Save