From 99f37eb90cd7f9b731459b0597fb27de42d22f75 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 29 Mar 2014 19:15:06 +0100 Subject: [PATCH] Cleanup style --HG-- branch : opengl3 --- .../opengl3/driver_glsl_shader_generator.cpp | 572 ++++++++--------- .../opengl3/driver_glsl_shader_generator.h | 26 +- .../src/3d/driver/opengl3/driver_opengl.cpp | 154 ++--- .../nel/src/3d/driver/opengl3/driver_opengl.h | 56 +- .../opengl3/driver_opengl_extension.cpp | 274 ++++----- .../driver/opengl3/driver_opengl_inputs.cpp | 22 +- .../3d/driver/opengl3/driver_opengl_light.cpp | 24 +- .../driver/opengl3/driver_opengl_material.cpp | 240 ++++---- .../driver/opengl3/driver_opengl_matrix.cpp | 8 +- .../driver/opengl3/driver_opengl_program.cpp | 578 +++++++++--------- .../opengl3/driver_opengl_rendering.cpp | 52 +- .../opengl3/driver_opengl_shader_cache.cpp | 12 +- .../opengl3/driver_opengl_shader_cache.h | 4 +- .../opengl3/driver_opengl_shader_desc.h | 100 +-- .../driver/opengl3/driver_opengl_states.cpp | 78 +-- .../driver/opengl3/driver_opengl_texture.cpp | 182 +++--- .../driver/opengl3/driver_opengl_vertex.cpp | 20 +- .../driver_opengl_vertex_buffer_hard.cpp | 20 +- .../driver/opengl3/driver_opengl_window.cpp | 124 ++-- .../3d/driver/opengl3/unix_event_emitter.cpp | 18 +- .../3d/driver/opengl3/unix_event_emitter.h | 2 +- 21 files changed, 1283 insertions(+), 1283 deletions(-) diff --git a/code/nel/src/3d/driver/opengl3/driver_glsl_shader_generator.cpp b/code/nel/src/3d/driver/opengl3/driver_glsl_shader_generator.cpp index 0f4ab01ed..e79da7b0c 100644 --- a/code/nel/src/3d/driver/opengl3/driver_glsl_shader_generator.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_glsl_shader_generator.cpp @@ -21,9 +21,9 @@ namespace { - inline bool hasFlag( uint32 data, uint32 flag ) + inline bool hasFlag(uint32 data, uint32 flag) { - if( ( data & flag ) != 0 ) + if ((data & flag) != 0) return true; else return false; @@ -137,13 +137,13 @@ namespace NL3D material = NULL; vbFormat = 0; desc = NULL; - ss.str( "" ); + ss.str(""); ss.clear(); } - void CGLSLShaderGenerator::generateVS( std::string &vs ) + void CGLSLShaderGenerator::generateVS(std::string &vs) { - ss.str( "" ); + ss.str(""); ss.clear(); ss << "// " << shaderNames[ material->getShader() ] << " Vertex Shader" << std::endl; ss << std::endl; @@ -158,13 +158,13 @@ namespace NL3D ss << "uniform mat4 modelViewProjection;" << std::endl; ss << std::endl; - for( int i = Position; i < NumOffsets; i++ ) + for (int i = Position; i < NumOffsets; i++) { - if( hasFlag( vbFormat, vertexFlags[ i ] ) ) + if (hasFlag(vbFormat, vertexFlags[ i ])) { - ss << "layout ( location = "; + ss << "layout (location = "; ss << i; - ss << " ) "; + ss << ") "; ss << "in vec4 "; ss << "v" << attribNames[ i ]; ss << ";"; @@ -173,9 +173,9 @@ namespace NL3D } ss << std::endl; - for( int i = Weight; i < NumOffsets; i++ ) + for (int i = Weight; i < NumOffsets; i++) { - if( hasFlag( vbFormat, vertexFlags[ i ] ) ) + if (hasFlag(vbFormat, vertexFlags[ i ])) { ss << "smooth out vec4 "; ss << attribNames[ i ] << ";" << std::endl; @@ -183,14 +183,14 @@ namespace NL3D } ss << std::endl; - if( !desc->useTextures() ) + if (!desc->useTextures()) { addAmbient(); addDiffuse(); addSpecular(); } - switch( material->getShader() ) + switch(material->getShader()) { case CMaterial::Normal: case CMaterial::UserColor: @@ -213,12 +213,12 @@ namespace NL3D break; } - vs.assign( ss.str() ); + vs.assign(ss.str()); } - void CGLSLShaderGenerator::generatePS( std::string &ps ) + void CGLSLShaderGenerator::generatePS(std::string &ps) { - ss.str( "" ); + ss.str(""); ss.clear(); ss << "// " << shaderNames[ material->getShader() ] << " Pixel Shader" << std::endl; @@ -229,9 +229,9 @@ namespace NL3D ss << "out vec4 fragColor;" << std::endl; - for( int i = Weight; i < NumOffsets; i++ ) + for (int i = Weight; i < NumOffsets; i++) { - if( hasFlag( vbFormat, vertexFlags[ i ] ) ) + if (hasFlag(vbFormat, vertexFlags[ i ])) { ss << "smooth in vec4 "; ss << attribNames[ i ] << ";" << std::endl; @@ -239,7 +239,7 @@ namespace NL3D } ss << std::endl; - switch( material->getShader() ) + switch(material->getShader()) { case CMaterial::Normal: case CMaterial::UserColor: @@ -268,7 +268,7 @@ namespace NL3D break; } - ps.assign( ss.str() ); + ps.assign(ss.str()); } void CGLSLShaderGenerator::addAmbient() @@ -316,20 +316,20 @@ namespace NL3D void CGLSLShaderGenerator::addAlphaTest() { - if( material->getAlphaTest() ) - ss << "if( fragColor.a <= ( alphaTreshold - 0.0001 ) ) discard;" << std::endl; + if (material->getAlphaTest()) + ss << "if (fragColor.a <= (alphaTreshold - 0.0001)) discard;" << std::endl; } void CGLSLShaderGenerator::addFogUniform() { - if( !desc->fogEnabled() ) + if (!desc->fogEnabled()) return; ss << "uniform float fogStart;" << std::endl; ss << "uniform float fogEnd;" << std::endl; ss << "uniform vec4 fogColor;" << std::endl; - if( desc->getFogMode() == CShaderDesc::Linear ) + if (desc->getFogMode() == CShaderDesc::Linear) return; ss << "uniform float fogDensity;" << std::endl; @@ -337,19 +337,19 @@ namespace NL3D void CGLSLShaderGenerator::addFogFunction() { - if( !desc->fogEnabled() ) + if (!desc->fogEnabled()) return; - switch( desc->getFogMode() ) + switch(desc->getFogMode()) { case CShaderDesc::Linear: - ss << "vec4 applyFog( vec4 col )" << std::endl; + ss << "vec4 applyFog(vec4 col)" << std::endl; ss << "{" << std::endl; ss << "float z = ecPos.z / ecPos.w;" << std::endl; - ss << "z = abs( z );" << std::endl; - ss << "float fogFactor = ( fogEnd - z ) / ( fogEnd - fogStart );" << std::endl; - ss << "fogFactor = clamp( fogFactor, 0.0, 1.0 );" << std::endl; - ss << "vec4 fColor = mix( fogColor, col, fogFactor );" << std::endl; + ss << "z = abs(z);" << std::endl; + ss << "float fogFactor = (fogEnd - z) / (fogEnd - fogStart);" << std::endl; + ss << "fogFactor = clamp(fogFactor, 0.0, 1.0);" << std::endl; + ss << "vec4 fColor = mix(fogColor, col, fogFactor);" << std::endl; ss << "return fColor;" << std::endl; ss << "}" << std::endl; ss << std::endl; @@ -359,7 +359,7 @@ namespace NL3D void CGLSLShaderGenerator::addFog() { - ss << "fragColor = applyFog( fragColor );" << std::endl; + ss << "fragColor = applyFog(fragColor);" << std::endl; } @@ -367,9 +367,9 @@ namespace NL3D void CGLSLShaderGenerator::addLightUniformsVS() { - for( int i = 0; i < SHADER_MAX_LIGHTS; i++ ) + for (int i = 0; i < SHADER_MAX_LIGHTS; i++) { - switch( desc->getLight( i ) ) + switch(desc->getLight(i)) { case CShaderDesc::Nolight: continue; @@ -399,9 +399,9 @@ namespace NL3D void CGLSLShaderGenerator::addLightUniformsFS() { - for( int i = 0; i < SHADER_MAX_LIGHTS; i++ ) + for (int i = 0; i < SHADER_MAX_LIGHTS; i++) { - switch( desc->getLight( i ) ) + switch(desc->getLight(i)) { case CShaderDesc::Nolight: continue; @@ -424,45 +424,45 @@ namespace NL3D ss << "smooth in vec4 lightColor;" << std::endl; } - void CGLSLShaderGenerator::addDirectionalFunctionVS( int num ) + void CGLSLShaderGenerator::addDirectionalFunctionVS(int num) { - ss << "float getIntensity" << num << "( vec3 normal3, vec3 lightDir )" << std::endl; + ss << "float getIntensity" << num << "(vec3 normal3, vec3 lightDir)" << std::endl; ss << "{" << std::endl; - ss << "float angle = dot( lightDir, normal3 );" << std::endl; - ss << "angle = max( 0.0, angle );" << std::endl; + ss << "float angle = dot(lightDir, normal3);" << std::endl; + ss << "angle = max(0.0, angle);" << std::endl; ss << "return angle;" << std::endl; ss << "}" << std::endl; ss << std::endl; - ss << "float getSpecIntensity" << num << "( vec3 normal3, vec3 lightDir )" << std::endl; + ss << "float getSpecIntensity" << num << "(vec3 normal3, vec3 lightDir)" << std::endl; ss << "{" << std::endl; - ss << "vec3 halfVector = normalize( lightDir + normal3 );" << std::endl; - ss << "float angle = dot( normal3, halfVector );" << std::endl; - ss << "angle = max( 0.0, angle );" << std::endl; - ss << "float si = pow( angle, light" << num << "Shininess );" << std::endl; + ss << "vec3 halfVector = normalize(lightDir + normal3);" << std::endl; + ss << "float angle = dot(normal3, halfVector);" << std::endl; + ss << "angle = max(0.0, angle);" << std::endl; + ss << "float si = pow(angle, light" << num << "Shininess);" << std::endl; ss << "return si;" << std::endl; ss << "}" << std::endl; ss << std::endl; ss << "vec4 getLight" << num << "Color()" << std::endl; ss << "{" << std::endl; - ss << "vec4 lightDir4 = viewMatrix * vec4( light" << num << "DirOrPos, 1.0 );" << std::endl; + ss << "vec4 lightDir4 = viewMatrix * vec4(light" << num << "DirOrPos, 1.0);" << std::endl; ss << "vec3 lightDir = lightDir4.xyz / lightDir4.w;" << std::endl; - ss << "lightDir = normalize( lightDir );" << std::endl; + ss << "lightDir = normalize(lightDir);" << std::endl; ss << "vec3 normal3 = vnormal.xyz / vnormal.w;" << std::endl; ss << "normal3 = normalMatrix * normal3;" << std::endl; - ss << "normal3 = normalize( normal3 );" << std::endl; + ss << "normal3 = normalize(normal3);" << std::endl; - if( desc->useTextures() || ( material->getShader() == CMaterial::LightMap ) ) + if (desc->useTextures() || (material->getShader() == CMaterial::LightMap)) { - ss << "vec4 lc = getIntensity" << num << "( normal3, lightDir ) * light" << num << "ColDiff + "; - ss << "getSpecIntensity" << num << "( normal3, lightDir ) * light" << num << "ColSpec + "; + ss << "vec4 lc = getIntensity" << num << "(normal3, lightDir) * light" << num << "ColDiff + "; + ss << "getSpecIntensity" << num << "(normal3, lightDir) * light" << num << "ColSpec + "; ss << "light" << num << "ColAmb;" << std::endl; } else { - ss << "vec4 lc = getIntensity" << num << "( normal3, lightDir ) * light" << num << "ColDiff * diffuseColor + "; - ss << "getSpecIntensity" << num << "( normal3, lightDir ) * light" << num << "ColSpec * specularColor + "; + ss << "vec4 lc = getIntensity" << num << "(normal3, lightDir) * light" << num << "ColDiff * diffuseColor + "; + ss << "getSpecIntensity" << num << "(normal3, lightDir) * light" << num << "ColSpec * specularColor + "; ss << "light" << num << "ColAmb * ambientColor;" << std::endl; } @@ -471,22 +471,22 @@ namespace NL3D ss << std::endl; } - void CGLSLShaderGenerator::addPointLightFunctionVS( int num ) + void CGLSLShaderGenerator::addPointLightFunctionVS(int num) { - ss << "float getIntensity" << num << "( vec3 normal3, vec3 direction3 )" << std::endl; + ss << "float getIntensity" << num << "(vec3 normal3, vec3 direction3)" << std::endl; ss << "{" << std::endl; - ss << "float angle = dot( direction3, normal3 );" << std::endl; - ss << "angle = max( 0.0, angle );" << std::endl; + ss << "float angle = dot(direction3, normal3);" << std::endl; + ss << "angle = max(0.0, angle);" << std::endl; ss << "return angle;" << std::endl; ss << "}" << std::endl; ss << std::endl; - ss << "float getSpecIntensity" << num << "( vec3 normal3, vec3 direction3 )" << std::endl; + ss << "float getSpecIntensity" << num << "(vec3 normal3, vec3 direction3)" << std::endl; ss << "{" << std::endl; - ss << "vec3 halfVector = normalize( direction3 + normal3 );" << std::endl; - ss << "float angle = dot( normal3, halfVector );" << std::endl; - ss << "angle = max( 0.0, angle );" << std::endl; - ss << "float si = pow( angle, light" << num << "Shininess );" << std::endl; + ss << "vec3 halfVector = normalize(direction3 + normal3);" << std::endl; + ss << "float angle = dot(normal3, halfVector);" << std::endl; + ss << "angle = max(0.0, angle);" << std::endl; + ss << "float si = pow(angle, light" << num << "Shininess);" << std::endl; ss << "return si;" << std::endl; ss << "}" << std::endl; ss << std::endl; @@ -494,11 +494,11 @@ namespace NL3D ss << "vec4 getLight" << num << "Color()" << std::endl; ss << "{" << std::endl; ss << "vec3 ecPos3 = ecPos4.xyz / ecPos4.w;" << std::endl; - ss << "vec4 lightPos4 = viewMatrix * vec4( light" << num << "DirOrPos, 1.0 );" << std::endl; + ss << "vec4 lightPos4 = viewMatrix * vec4(light" << num << "DirOrPos, 1.0);" << std::endl; ss << "vec3 lightPos = lightPos4.xyz / lightPos4.w;" << std::endl; ss << "vec3 lightDirection = lightPos - ecPos3;" << std::endl; - ss << "float lightDistance = length( lightDirection );" << std::endl; - ss << "lightDirection = normalize( lightDirection );" << std::endl; + ss << "float lightDistance = length(lightDirection);" << std::endl; + ss << "lightDirection = normalize(lightDirection);" << std::endl; ss << "float attenuation = light" << num << "ConstAttn + "; ss << "light" << num << "LinAttn * lightDistance +"; @@ -506,18 +506,18 @@ namespace NL3D ss << "vec3 normal3 = vnormal.xyz / vnormal.w;" << std::endl; ss << "normal3 = normalMatrix * normal3;" << std::endl; - ss << "normal3 = normalize( normal3 );" << std::endl; + ss << "normal3 = normalize(normal3);" << std::endl; - if( desc->useTextures() || ( material->getShader() == CMaterial::LightMap ) ) + if (desc->useTextures() || (material->getShader() == CMaterial::LightMap)) { - ss << "vec4 lc = getIntensity" << num << "( normal3, lightDirection ) * light" << num << "ColDiff + "; - ss << "getSpecIntensity" << num << "( normal3, lightDirection ) * light" << num << "ColSpec + "; + ss << "vec4 lc = getIntensity" << num << "(normal3, lightDirection) * light" << num << "ColDiff + "; + ss << "getSpecIntensity" << num << "(normal3, lightDirection) * light" << num << "ColSpec + "; ss << "light" << num << "ColAmb;" << std::endl; } else { - ss << "vec4 lc = getIntensity" << num << "( normal3, lightDirection ) * light" << num << "ColDiff * diffuseColor+ "; - ss << "getSpecIntensity" << num << "( normal3, lightDirection ) * light" << num << "ColSpec * specularColor + "; + ss << "vec4 lc = getIntensity" << num << "(normal3, lightDirection) * light" << num << "ColDiff * diffuseColor+ "; + ss << "getSpecIntensity" << num << "(normal3, lightDirection) * light" << num << "ColSpec * specularColor + "; ss << "light" << num << "ColAmb * ambientColor;" << std::endl; } @@ -529,20 +529,20 @@ namespace NL3D void CGLSLShaderGenerator::addLightsFunctionVS() { - for( int i = 0; i < SHADER_MAX_LIGHTS; i++ ) + for (int i = 0; i < SHADER_MAX_LIGHTS; i++) { - switch( desc->getLight( i ) ) + switch(desc->getLight(i)) { case CShaderDesc::Nolight: continue; break; case CShaderDesc::Directional: - addDirectionalFunctionVS( i ); + addDirectionalFunctionVS(i); break; case CShaderDesc::Point: - addPointLightFunctionVS( i ); + addPointLightFunctionVS(i); break; } @@ -552,7 +552,7 @@ namespace NL3D void CGLSLShaderGenerator::addLightsFunctionFS() { - ss << "vec4 applyLights( vec4 col )" << std::endl; + ss << "vec4 applyLights(vec4 col)" << std::endl; ss << "{" << std::endl; ss << "return col * lightColor;" << std::endl; ss << "}" << std::endl; @@ -560,11 +560,11 @@ namespace NL3D void CGLSLShaderGenerator::addLightsVS() { - ss << "lightColor = vec4( 0.0, 0.0, 0.0, 1.0 );" << std::endl; + ss << "lightColor = vec4(0.0, 0.0, 0.0, 1.0);" << std::endl; - for( int i = 0; i < SHADER_MAX_LIGHTS; i++ ) + for (int i = 0; i < SHADER_MAX_LIGHTS; i++) { - if( desc->getLight( i ) == CShaderDesc::Nolight ) + if (desc->getLight(i) == CShaderDesc::Nolight) continue; ss << "lightColor = lightColor + getLight" << i << "Color();" << std::endl; @@ -573,32 +573,32 @@ namespace NL3D void CGLSLShaderGenerator::addLightsFS() { - ss << "fragColor = applyLights( fragColor );" << std::endl; + ss << "fragColor = applyLights(fragColor);" << std::endl; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CGLSLShaderGenerator::generateNormalVS() { - if( desc->fogEnabled() || desc->hasPointLight() ) + if (desc->fogEnabled() || desc->hasPointLight()) { ss << "uniform mat4 modelView;" << std::endl; } - if( desc->lightingEnabled() ) + if (desc->lightingEnabled()) { addViewMatrix(); } - if( desc->fogEnabled() || desc->hasPointLight() ) + if (desc->fogEnabled() || desc->hasPointLight()) { ss << "vec4 ecPos4;" << std::endl; } - if( desc->fogEnabled() ) + if (desc->fogEnabled()) ss << "smooth out vec4 ecPos;" << std::endl; ss << std::endl; - if( desc->lightingEnabled() ) + if (desc->lightingEnabled()) { addNormalMatrix(); addLightUniformsVS(); @@ -609,23 +609,23 @@ namespace NL3D ss << std::endl; } - ss << "void main( void )" << std::endl; + ss << "void main(void)" << std::endl; ss << "{" << std::endl; ss << "gl_Position = modelViewProjection * " << "v" << attribNames[ 0 ] << ";" << std::endl; - if( desc->fogEnabled() || desc->hasPointLight() ) + if (desc->fogEnabled() || desc->hasPointLight()) ss << "ecPos4 = modelView * v" << attribNames[ 0 ] << ";" << std::endl; - if( desc->fogEnabled() ) + if (desc->fogEnabled()) ss << "ecPos = ecPos4;" << std::endl; - if( desc->lightingEnabled() ) + if (desc->lightingEnabled()) addLightsVS(); - for( int i = Weight; i < NumOffsets; i++ ) + for (int i = Weight; i < NumOffsets; i++) { - if( hasFlag( vbFormat, vertexFlags[ i ] ) ) + if (hasFlag(vbFormat, vertexFlags[ i ])) { ss << attribNames[ i ]; ss << " = "; @@ -643,16 +643,16 @@ namespace NL3D ss << "uniform mat4 texMatrix0;" << std::endl; ss << "smooth out vec3 cubeTexCoords;" << std::endl; - if( desc->fogEnabled() || desc->hasPointLight() ) + if (desc->fogEnabled() || desc->hasPointLight()) { ss << "vec4 ecPos4;" << std::endl; } - if( desc->fogEnabled() ) + if (desc->fogEnabled()) ss << "smooth out vec4 ecPos;" << std::endl; ss << std::endl; - if( desc->lightingEnabled() ) + if (desc->lightingEnabled()) { addViewMatrix(); addNormalMatrix(); @@ -664,37 +664,37 @@ namespace NL3D ss << std::endl; } - ss << "vec3 ReflectionMap( const in vec3 eyePos, const in vec3 normal )" << std::endl; + ss << "vec3 ReflectionMap(const in vec3 eyePos, const in vec3 normal)" << std::endl; ss << "{" << std::endl; - ss << "vec3 u = normalize( eyePos );" << std::endl; - ss << "return reflect( u, normal );" << std::endl; + ss << "vec3 u = normalize(eyePos);" << std::endl; + ss << "return reflect(u, normal);" << std::endl; ss << "}" << std::endl; ss << std::endl; - ss << "void main( void )" << std::endl; + ss << "void main(void)" << std::endl; ss << "{" << std::endl; ss << "vec4 eyePosition = modelView * v" << attribNames[ 0 ] << ";" << std::endl; - if( desc->hasPointLight() ) + if (desc->hasPointLight()) ss << "ecPos4 = eyePosition;" << std::endl; - if( desc->fogEnabled() ) + if (desc->fogEnabled()) ss << "ecPos = eyePosition;" << std::endl; ss << "vec3 ep = eyePosition.xyz / eyePosition.w;" << std::endl; ss << "vec3 n = vnormal.xyz;" << std::endl; - ss << "cubeTexCoords = ReflectionMap( ep, n );" << std::endl; - ss << "vec4 t = vec4( cubeTexCoords, 1.0 );" << std::endl; + ss << "cubeTexCoords = ReflectionMap(ep, n);" << std::endl; + ss << "vec4 t = vec4(cubeTexCoords, 1.0);" << std::endl; ss << "t = t * texMatrix0;" << std::endl; ss << "cubeTexCoords = t.xyz;" << std::endl; ss << "gl_Position = modelViewProjection * v" << attribNames[ 0 ] << ";" << std::endl; - if( desc->lightingEnabled() ) + if (desc->lightingEnabled()) addLightsVS(); - for( int i = Weight; i < NumOffsets; i++ ) + for (int i = Weight; i < NumOffsets; i++) { - if( hasFlag( vbFormat, vertexFlags[ i ] ) ) + if (hasFlag(vbFormat, vertexFlags[ i ])) { ss << attribNames[ i ]; ss << " = "; @@ -709,7 +709,7 @@ namespace NL3D { ss << "uniform vec4 lightPosition;" << std::endl; - if( material->getShader() == CMaterial::PerPixelLighting ) + if (material->getShader() == CMaterial::PerPixelLighting) { ss << "uniform vec4 viewerPos;" << std::endl; ss << "uniform mat4 invModelMat;" << std::endl; @@ -719,16 +719,16 @@ namespace NL3D ss << "smooth out vec3 cubeTexCoords0;" << std::endl; - if( material->getShader() == CMaterial::PerPixelLighting ) + if (material->getShader() == CMaterial::PerPixelLighting) ss << "smooth out vec3 cubeTexCoords2;" << std::endl; - ss << "void main( void )" << std::endl; + ss << "void main(void)" << std::endl; ss << "{" << std::endl; ss << "gl_Position = modelViewProjection * v" << attribNames[ 0 ] << ";" << std::endl; - for( int i = Weight; i < NumOffsets; i++ ) + for (int i = Weight; i < NumOffsets; i++) { - if( hasFlag( vbFormat, vertexFlags[ i ] ) ) + if (hasFlag(vbFormat, vertexFlags[ i ])) { ss << attribNames[ i ]; ss << " = "; @@ -736,29 +736,29 @@ namespace NL3D } } - ss << "vec4 n = normalize( vnormal ); //normalized normal" << std::endl; + ss << "vec4 n = normalize(vnormal); //normalized normal" << std::endl; ss << "vec4 T; // second basis, Tangent" << std::endl; ss << "T = texCoord1;" << std::endl; - ss << "T = T - n * dot( N, T ); // Gramm-Schmidt process" << std::endl; - ss << "T = normalize( T );" << std::endl; + ss << "T = T - n * dot(N, T); // Gramm-Schmidt process" << std::endl; + ss << "T = normalize(T);" << std::endl; ss << "vec4 B;" << std::endl; - ss << "B.xyz = cross( n.xyz, T.xyz ); // B = N x T" << std::endl; + ss << "B.xyz = cross(n.xyz, T.xyz); // B = N x T" << std::endl; ss << "vec4 L = lightPos - vposition; //Inverse light vector" << std::endl; - ss << "L = normalize( L );" << std::endl; + ss << "L = normalize(L);" << std::endl; ss << "L * [ T B N ]" << std::endl; - ss << "cubeTexCoords0.x = dot( T.xyz, L.xyz );" << std::endl; - ss << "cubeTexCoords0.y = dot( B.xyz, L.xyz );" << std::endl; - ss << "cubeTexCoords0.z = dot( n.xyz, L.xyz );" << std::endl; + ss << "cubeTexCoords0.x = dot(T.xyz, L.xyz);" << std::endl; + ss << "cubeTexCoords0.y = dot(B.xyz, L.xyz);" << std::endl; + ss << "cubeTexCoords0.z = dot(n.xyz, L.xyz);" << std::endl; - if( material->getShader() == CMaterial::PerPixelLighting ) + if (material->getShader() == CMaterial::PerPixelLighting) { ss << "vec4 V = invModelMat * viewerPos - vposition;" << std::endl; - ss << "V = normalize( V );" << std::endl; + ss << "V = normalize(V);" << std::endl; ss << "vec4 H = L + V; // half-angle" << std::endl; - ss << "vec4 H = normalize( H );" << std::endl; - ss << "cubeTexCoords2.x = dot( T, H );" << std::endl; - ss << "cubeTexCoords2.y = dot( B, H );" << std::endl; - ss << "cubeTexCoords2.w = dot( n, H );" << std::endl; + ss << "vec4 H = normalize(H);" << std::endl; + ss << "cubeTexCoords2.x = dot(T, H);" << std::endl; + ss << "cubeTexCoords2.y = dot(B, H);" << std::endl; + ss << "cubeTexCoords2.w = dot(n, H);" << std::endl; } ss << "}" << std::endl; @@ -767,7 +767,7 @@ namespace NL3D void CGLSLShaderGenerator::generateWaterVS() { bool diffuse = false; - if( material->getTexture( 3 ) ) + if (material->getTexture(3)) diffuse = true; ss << "smooth out vec4 texCoord0;" << std::endl; @@ -776,12 +776,12 @@ namespace NL3D ss << "flat out vec4 bump0ScaleBias;" << std::endl; ss << "flat out vec4 bump1ScaleBias;" << std::endl; - if( diffuse ) + if (diffuse) ss << "smooth out vec4 texCoord3;" << std::endl; ss << std::endl; - if( diffuse ) + if (diffuse) { ss << "uniform vec4 diffuseMapVector0;" << std::endl; ss << "uniform vec4 diffuseMapVector1;" << std::endl; @@ -796,7 +796,7 @@ namespace NL3D //ss << "uniform mat4 modelView;" << std::endl; ss << std::endl; - ss << "void main( void )" << std::endl; + ss << "void main(void)" << std::endl; ss << "{" << std::endl; ss << "vec4 eye = vposition;" << std::endl; // FIXME ss << "vec4 position = vposition;" << std::endl; // FIXME @@ -806,18 +806,18 @@ namespace NL3D // no fog yet //ss << "vec4 v = modelView[ 3 ];" << std::endl; - //fog.x = dot( position, v ); + //fog.x = dot(position, v); ss << "texCoord0 = position * bumpMap0Scale + bumpMap0Offset;" << std::endl; ss << "texCoord1 = position * bumpMap1Scale + bumpMap1Offset;" << std::endl; - ss << "vec4 eyeDirection = normalize( eye - position );" << std::endl; + ss << "vec4 eyeDirection = normalize(eye - position);" << std::endl; - ss << "texCoord2 = -1 * eyeDirection * vec4( 0.5, 0.05, 0.0, 1.0 ) + vec4( 0.5, 0.05, 0.0, 1.0 );" << std::endl; + ss << "texCoord2 = -1 * eyeDirection * vec4(0.5, 0.05, 0.0, 1.0) + vec4(0.5, 0.05, 0.0, 1.0);" << std::endl; - if( diffuse ) + if (diffuse) { - ss << "texCoord3.x = dot( position, diffuseMapVector0 );" << std::endl; - ss << "texCoord3.y = dot( position, diffuseMapVector1 );" << std::endl; + ss << "texCoord3.x = dot(position, diffuseMapVector0);" << std::endl; + ss << "texCoord3.y = dot(position, diffuseMapVector1);" << std::endl; } ss << "}" << std::endl; @@ -826,9 +826,9 @@ namespace NL3D void CGLSLShaderGenerator::generateNormalPS() { uint sampler = 0; - for( int i = 0; i < SHADER_MAX_TEXTURES; i++ ) + for (int i = 0; i < SHADER_MAX_TEXTURES; i++) { - if( desc->getUseTexStage( i ) ) + if (desc->getUseTexStage(i)) ss << "uniform sampler2D sampler" << sampler << ";" << std::endl; sampler++; } @@ -838,12 +838,12 @@ namespace NL3D addAlphaTreshold(); addFogUniform(); - if( desc->fogEnabled() ) + if (desc->fogEnabled()) ss << "smooth in vec4 ecPos;" << std::endl; ss << std::endl; - if( desc->lightingEnabled() ) + if (desc->lightingEnabled()) { addLightUniformsFS(); addLightInsFS(); @@ -853,24 +853,24 @@ namespace NL3D ss << std::endl; } - if( desc->fogEnabled() ) + if (desc->fogEnabled()) addFogFunction(); - ss << "void main( void )" << std::endl; + ss << "void main(void)" << std::endl; ss << "{" << std::endl; bool textures = false; sampler = 0; - for( int i = 0; i < SHADER_MAX_TEXTURES; i++ ) + for (int i = 0; i < SHADER_MAX_TEXTURES; i++) { - if( desc->getUseTexStage( i ) ) + if (desc->getUseTexStage(i)) { - ss << "vec4 texel" << sampler << " = texture( sampler" << sampler << ","; + ss << "vec4 texel" << sampler << " = texture(sampler" << sampler << ","; - if( !desc->getUseFirstTexCoords() ) - ss << attribNames[ TexCoord0 + i ] << ".st );"; + if (!desc->getUseFirstTexCoords()) + ss << attribNames[ TexCoord0 + i ] << ".st);"; else - ss << attribNames[ TexCoord0 ] << ".st );"; + ss << attribNames[ TexCoord0 ] << ".st);"; ss << std::endl; @@ -880,31 +880,31 @@ namespace NL3D } bool vertexColor = false; - if( hasFlag( vbFormat, vertexFlags[ PrimaryColor ] ) ) + if (hasFlag(vbFormat, vertexFlags[ PrimaryColor ])) vertexColor = true; - if( textures && !vertexColor ) - ss << "vec4 texel = vec4( 1.0, 1.0, 1.0, 1.0 );" << std::endl; + if (textures && !vertexColor) + ss << "vec4 texel = vec4(1.0, 1.0, 1.0, 1.0);" << std::endl; else - if( vertexColor ) + if (vertexColor) ss << "vec4 texel = color;" << std::endl; else - ss << "vec4 texel = vec4( 0.5, 0.5, 0.5, 1.0 );" << std::endl; + ss << "vec4 texel = vec4(0.5, 0.5, 0.5, 1.0);" << std::endl; generateTexEnv(); // This is just an idea I had, but it seems to be working. // Unfortunately it's not documented anywhere I looked in the GL spec, but if I don't have this modulation here, // the Ryzom UI looks horrific. - if( vertexColor ) + if (vertexColor) ss << "texel = color * texel;" << std::endl; ss << "fragColor = texel;" << std::endl; - if( desc->lightingEnabled() ) + if (desc->lightingEnabled()) addLightsFS(); - if( desc->fogEnabled() ) + if (desc->fogEnabled()) addFog(); addAlphaTest(); @@ -915,36 +915,36 @@ namespace NL3D void CGLSLShaderGenerator::generateTexEnv() { uint32 stage = 0; - for( int i = 0; i < SHADER_MAX_TEXTURES; i++ ) + for (int i = 0; i < SHADER_MAX_TEXTURES; i++) { - if( desc->getUseTexStage( i ) ) + if (desc->getUseTexStage(i)) { - generateTexEnvRGB( stage ); - generateTexEnvAlpha( stage ); + generateTexEnvRGB(stage); + generateTexEnvAlpha(stage); } stage++; } } - void CGLSLShaderGenerator::generateTexEnvRGB( unsigned int stage ) + void CGLSLShaderGenerator::generateTexEnvRGB(unsigned int stage) { std::string arg0; std::string arg1; std::string arg2; - switch( material->_TexEnvs[ stage ].Env.OpRGB ) + switch(material->_TexEnvs[ stage ].Env.OpRGB) { case CMaterial::Replace: { - buildArg( stage, 0, false, arg0 ); + buildArg(stage, 0, false, arg0); ss << "texel.rgb = " << arg0 << ";" << std::endl; } break; case CMaterial::Modulate: { - buildArg( stage, 0, false, arg0 ); - buildArg( stage, 1, false, arg1 ); + buildArg(stage, 0, false, arg0); + buildArg(stage, 1, false, arg1); ss << "texel.rgb = " << arg0 << " * " << arg1 << ";" << std::endl; //ss << "texel.rgb = " << arg0 << ";" << std::endl; //ss << "texel.rgb = texel.rgb * " << arg1 << ";" << std::endl; @@ -952,26 +952,26 @@ namespace NL3D break; case CMaterial::Add: - buildArg( stage, 0, false, arg0 ); - buildArg( stage, 1, false, arg1 ); + buildArg(stage, 0, false, arg0); + buildArg(stage, 1, false, arg1); ss << "texel.rgb = " << arg0 << " + " << arg1 << ";" << std::endl; //ss << "texel.rgb = " << arg0 << ";" << std::endl; //ss << "texel.rgb = texel.rgb + " << arg1 << ";" << std::endl; break; case CMaterial::AddSigned: - buildArg( stage, 0, false, arg0 ); - buildArg( stage, 1, false, arg1 ); - ss << "texel.rgb = " << arg0 << " + " << arg1 << " - vec3( 0.5, 0.5, 0.5 );" << std::endl; + buildArg(stage, 0, false, arg0); + buildArg(stage, 1, false, arg1); + ss << "texel.rgb = " << arg0 << " + " << arg1 << " - vec3(0.5, 0.5, 0.5);" << std::endl; //ss << "texel.rgb = " << arg0 << ";" << std::endl; //ss << "texel.rgb = texel.rgb + " << arg1 << ";" << std::endl; - //ss << "texel.rgb = texel.rgb - vec3( 0.5, 0.5, 0.5 );" << std::endl; + //ss << "texel.rgb = texel.rgb - vec3(0.5, 0.5, 0.5);" << std::endl; break; case CMaterial::Mad: - buildArg( stage, 0, false, arg0 ); - buildArg( stage, 1, false, arg1 ); - buildArg( stage, 2, false, arg2 ); + buildArg(stage, 0, false, arg0); + buildArg(stage, 1, false, arg1); + buildArg(stage, 2, false, arg2); ss << "texel.rgb = " << arg0 << " * " << arg1 << " + " << arg2 << ";" << std::endl; //ss << "texel.rgb = " << arg0 << ";" << std::endl; //ss << "texel.rgb = texel.rgb * " << arg1 << ";" << std::endl; @@ -980,75 +980,75 @@ namespace NL3D case CMaterial::InterpolateTexture: { - buildArg( stage, 0, false, arg0 ); - buildArg( stage, 1, false, arg1 ); + buildArg(stage, 0, false, arg0); + buildArg(stage, 1, false, arg1); std::string As = texelNames[ stage ]; - As.append( ".a" ); + As.append(".a"); ss << "texel.rgb = " << arg0 << " * " << As << ";" << std::endl; - ss << "texel.rgb = texel.rgb + " << arg1 << " * " << "( 1.0 - " << As << " );" << std::endl; + ss << "texel.rgb = texel.rgb + " << arg1 << " * " << "(1.0 - " << As << ");" << std::endl; } break; case CMaterial::InterpolatePrevious: { - buildArg( stage, 0, false, arg0 ); - buildArg( stage, 1, false, arg1 ); + buildArg(stage, 0, false, arg0); + buildArg(stage, 1, false, arg1); std::string As = "texel.a"; ss << "texel.rgb = " << arg0 << " * " << As << ";" << std::endl; - ss << "texel.rgb = texel.rgb + " << arg1 << " * " << "( 1.0 - " << As << " );" << std::endl; + ss << "texel.rgb = texel.rgb + " << arg1 << " * " << "(1.0 - " << As << ");" << std::endl; } break; case CMaterial::InterpolateDiffuse: { - buildArg( stage, 0, false, arg0 ); - buildArg( stage, 1, false, arg1 ); + buildArg(stage, 0, false, arg0); + buildArg(stage, 1, false, arg1); std::string As = "diffuseColor.a"; ss << "texel.rgb = " << arg0 << " * " << As << ";" << std::endl; - ss << "texel.rgb = texel.rgb + " << arg1 << " * " << "( 1.0 - " << As << " );" << std::endl; + ss << "texel.rgb = texel.rgb + " << arg1 << " * " << "(1.0 - " << As << ");" << std::endl; } break; case CMaterial::InterpolateConstant: { - buildArg( stage, 0, false, arg0 ); - buildArg( stage, 1, false, arg1 ); + buildArg(stage, 0, false, arg0); + buildArg(stage, 1, false, arg1); std::string As = constantNames[ stage ]; - As.append( ".a" ); + As.append(".a"); ss << "texel.rgb = " << arg0 << " * " << As << ";" << std::endl; - ss << "texel.rgb = texel.rgb + " << arg1 << " * " << "( 1.0 - " << As << " );" << std::endl; + ss << "texel.rgb = texel.rgb + " << arg1 << " * " << "(1.0 - " << As << ");" << std::endl; } break; } } - void CGLSLShaderGenerator::generateTexEnvAlpha( unsigned int stage ) + void CGLSLShaderGenerator::generateTexEnvAlpha(unsigned int stage) { std::string arg0; std::string arg1; std::string arg2; - switch( material->_TexEnvs[ stage ].Env.OpRGB ) + switch(material->_TexEnvs[ stage ].Env.OpRGB) { case CMaterial::Replace: { - buildArg( stage, 0, true, arg0 ); + buildArg(stage, 0, true, arg0); ss << "texel.a = " << arg0 << ";" << std::endl; } break; case CMaterial::Modulate: { - buildArg( stage, 0, true, arg0 ); - buildArg( stage, 1, true, arg1 ); + buildArg(stage, 0, true, arg0); + buildArg(stage, 1, true, arg1); ss << "texel.a = " << arg0 << " * " << arg1 << ";" << std::endl; //ss << "texel.a = " << arg0 << ";" << std::endl; //ss << "texel.a = texel.a * " << arg1 << ";" << std::endl; @@ -1056,26 +1056,26 @@ namespace NL3D break; case CMaterial::Add: - buildArg( stage, 0, true, arg0 ); - buildArg( stage, 1, true, arg1 ); + buildArg(stage, 0, true, arg0); + buildArg(stage, 1, true, arg1); ss << "texel.a = " << arg0 << " + " << arg1 << ";" << std::endl; //ss << "texel.a = " << arg0 << ";" << std::endl; //ss << "texel.a = texel.a + " << arg1 << ";" << std::endl; break; case CMaterial::AddSigned: - buildArg( stage, 0, true, arg0 ); - buildArg( stage, 1, true, arg1 ); - ss << "texel.a = " << arg0 << " * " << arg1 << " - vec3( 0.5, 0.5, 0.5 );" << std::endl; + buildArg(stage, 0, true, arg0); + buildArg(stage, 1, true, arg1); + ss << "texel.a = " << arg0 << " * " << arg1 << " - vec3(0.5, 0.5, 0.5);" << std::endl; //ss << "texel.rgb = " << arg0 << ";" << std::endl; //ss << "texel.rgb = texel.rgb + " << arg1 << ";" << std::endl; - //ss << "texel.rgb = texel.rgb - vec3( 0.5, 0.5, 0.5 );" << std::endl; + //ss << "texel.rgb = texel.rgb - vec3(0.5, 0.5, 0.5);" << std::endl; break; case CMaterial::Mad: - buildArg( stage, 0, true, arg0 ); - buildArg( stage, 1, true, arg1 ); - buildArg( stage, 2, true, arg2 ); + buildArg(stage, 0, true, arg0); + buildArg(stage, 1, true, arg1); + buildArg(stage, 2, true, arg2); ss << "texel.a = " << arg0 << ";" << std::endl; ss << "texel.a = texel.a * " << arg1 << ";" << std::endl; ss << "texel.a = texel.a + " << arg2 << ";" << std::endl; @@ -1083,89 +1083,89 @@ namespace NL3D case CMaterial::InterpolateTexture: { - buildArg( stage, 0, true, arg0 ); - buildArg( stage, 1, true, arg1 ); + buildArg(stage, 0, true, arg0); + buildArg(stage, 1, true, arg1); std::string As = texelNames[ stage ]; - As.append( ".a" ); + As.append(".a"); ss << "texel.a = " << arg0 << " * " << As << ";" << std::endl; - ss << "texel.a = texel.a + " << arg1 << " * " << "( 1.0 - " << As << " );" << std::endl; + ss << "texel.a = texel.a + " << arg1 << " * " << "(1.0 - " << As << ");" << std::endl; } break; case CMaterial::InterpolatePrevious: { - buildArg( stage, 0, true, arg0 ); - buildArg( stage, 1, true, arg1 ); + buildArg(stage, 0, true, arg0); + buildArg(stage, 1, true, arg1); std::string As = "texel.a"; ss << "texel.a = " << arg0 << " * " << As << ";" << std::endl; - ss << "texel.a = texel.a + " << arg1 << " * " << "( 1.0 - " << As << " );" << std::endl; + ss << "texel.a = texel.a + " << arg1 << " * " << "(1.0 - " << As << ");" << std::endl; } break; case CMaterial::InterpolateDiffuse: { - buildArg( stage, 0, true, arg0 ); - buildArg( stage, 1, true, arg1 ); + buildArg(stage, 0, true, arg0); + buildArg(stage, 1, true, arg1); std::string As = "diffuseColor.a"; ss << "texel.a = " << arg0 << " * " << As << ";" << std::endl; - ss << "texel.a = texel.a + " << arg1 << " * " << "( 1.0 - " << As << " );" << std::endl; + ss << "texel.a = texel.a + " << arg1 << " * " << "(1.0 - " << As << ");" << std::endl; } break; case CMaterial::InterpolateConstant: { - buildArg( stage, 0, true, arg0 ); - buildArg( stage, 1, true, arg1 ); + buildArg(stage, 0, true, arg0); + buildArg(stage, 1, true, arg1); std::string As = constantNames[ stage ]; - As.append( ".a" ); + As.append(".a"); ss << "texel.a = " << arg0 << " * " << As << ";" << std::endl; - ss << "texel.a = texel.a + " << arg1 << " * " << "( 1.0 - " << As << " );" << std::endl; + ss << "texel.a = texel.a + " << arg1 << " * " << "(1.0 - " << As << ");" << std::endl; } break; } } - void CGLSLShaderGenerator::buildArg( unsigned int stage, unsigned int n, bool alpha, std::string &arg ) + void CGLSLShaderGenerator::buildArg(unsigned int stage, unsigned int n, bool alpha, std::string &arg) { uint32 src; uint32 op; - if( !alpha ) + if (!alpha) { - src = material->_TexEnvs[ n ].getColorArg( n ); - op = material->_TexEnvs[ n ].getColorOperand( n ); + src = material->_TexEnvs[ n ].getColorArg(n); + op = material->_TexEnvs[ n ].getColorOperand(n); } else { - src = material->_TexEnvs[ n ].getAlphaArg( n ); - op = material->_TexEnvs[ n ].getAlphaOperand( n ); + src = material->_TexEnvs[ n ].getAlphaArg(n); + op = material->_TexEnvs[ n ].getAlphaOperand(n); } std::stringstream ds; - switch( src ) + switch(src) { case CMaterial::Texture: { - switch( op ) + switch(op) { case CMaterial::SrcColor: ds << texelNames[ stage ] << ".rgb"; break; case CMaterial::InvSrcColor: - ds << "( vec3( 1.0, 1.0, 1.0 ) - "; - ds << texelNames[ stage ] << ".rgb )"; + ds << "(vec3(1.0, 1.0, 1.0) - "; + ds << texelNames[ stage ] << ".rgb)"; break; case CMaterial::SrcAlpha: @@ -1173,8 +1173,8 @@ namespace NL3D break; case CMaterial::InvSrcAlpha: - ds << "( 1.0 - "; - ds << texelNames[ stage ] << ".a )"; + ds << "(1.0 - "; + ds << texelNames[ stage ] << ".a)"; break; } } @@ -1182,14 +1182,14 @@ namespace NL3D case CMaterial::Previous: - switch( op ) + switch(op) { case CMaterial::SrcColor: ds << "texel.rgb"; break; case CMaterial::InvSrcColor: - ds << "( vec3( 1.0, 1.0, 1.0 ) - texel.rgb )"; + ds << "(vec3(1.0, 1.0, 1.0) - texel.rgb)"; break; case CMaterial::SrcAlpha: @@ -1197,21 +1197,21 @@ namespace NL3D break; case CMaterial::InvSrcAlpha: - ds << "( 1.0 - texel.a )"; + ds << "(1.0 - texel.a)"; break; } break; case CMaterial::Diffuse: - switch( op ) + switch(op) { case CMaterial::SrcColor: ds << "materialColor.rgb"; break; case CMaterial::InvSrcColor: - ds << "( vec3( 1.0, 1.0, 1.0 ) - materialColor.rgb )"; + ds << "(vec3(1.0, 1.0, 1.0) - materialColor.rgb)"; break; case CMaterial::SrcAlpha: @@ -1219,21 +1219,21 @@ namespace NL3D break; case CMaterial::InvSrcAlpha: - ds << "( 1.0 - materialColor.a )"; + ds << "(1.0 - materialColor.a)"; break; } break; case CMaterial::Constant: - switch( op ) + switch(op) { case CMaterial::SrcColor: ds << constantNames[ stage ] << ".rgb"; break; case CMaterial::InvSrcColor: - ds << "( vec3( 1.0, 1.0, 1.0 ) - " << constantNames[ stage ] << ".rgb )"; + ds << "(vec3(1.0, 1.0, 1.0) - " << constantNames[ stage ] << ".rgb)"; break; case CMaterial::SrcAlpha: @@ -1241,13 +1241,13 @@ namespace NL3D break; case CMaterial::InvSrcAlpha: - ds << "( 1.0 - " << constantNames[ stage ] << ".a )"; + ds << "(1.0 - " << constantNames[ stage ] << ".a)"; break; } break; } - arg.assign( ds.str() ); + arg.assign(ds.str()); } @@ -1257,15 +1257,15 @@ namespace NL3D ls++; // lightmaps + color texture int ntextures = 0; - for( int i = TexCoord0; i < TexCoord4; i++ ) + for (int i = TexCoord0; i < TexCoord4; i++) { - if( hasFlag( vbFormat, vertexFlags[ i ] ) ) + if (hasFlag(vbFormat, vertexFlags[ i ])) ntextures++; } - ntextures = std::max( ntextures, ls ); + ntextures = std::max(ntextures, ls); - for( int i = 0; i < ntextures; i++ ) + for (int i = 0; i < ntextures; i++) ss << "uniform sampler2D sampler" << i << ";" << std::endl; addConstants(); @@ -1276,12 +1276,12 @@ namespace NL3D addFogUniform(); - if( desc->fogEnabled() ) + if (desc->fogEnabled()) ss << "smooth in vec4 ecPos;" << std::endl; ss << std::endl; - if( desc->lightingEnabled() ) + if (desc->lightingEnabled()) { addLightUniformsFS(); addLightInsFS(); @@ -1291,29 +1291,29 @@ namespace NL3D ss << std::endl; } - if( desc->fogEnabled() ) + if (desc->fogEnabled()) addFogFunction(); - ss << "void main( void )" << std::endl; + ss << "void main(void)" << std::endl; ss << "{" << std::endl; // Lightmap UV coords are at position 1 - for( int i = 0; i < ntextures - 1; i++ ) + for (int i = 0; i < ntextures - 1; i++) { ss << "vec4 texel" << i; - ss << " = texture( sampler" << i; - ss << ", " << attribNames[ TexCoord1 ] << ".st );" << std::endl; + ss << " = texture(sampler" << i; + ss << ", " << attribNames[ TexCoord1 ] << ".st);" << std::endl; } // Color map UV coords are at position 0 - ss << "vec4 texel" << ntextures - 1 << " = texture( sampler" << ntextures - 1 << ", " << attribNames[ TexCoord0 ] << ".st );" << std::endl; + ss << "vec4 texel" << ntextures - 1 << " = texture(sampler" << ntextures - 1 << ", " << attribNames[ TexCoord0 ] << ".st);" << std::endl; //ss << "vec4 texel = diffuseColor;" << std::endl; - //ss << "vec4 texel = vec4( 1.0, 1.0, 1.0, 1.0 );" << std::endl; - ss << "vec4 texel = vec4( 0.0, 0.0, 0.0, 1.0 );" << std::endl; + //ss << "vec4 texel = vec4(1.0, 1.0, 1.0, 1.0);" << std::endl; + ss << "vec4 texel = vec4(0.0, 0.0, 0.0, 1.0);" << std::endl; // Lightmaps - for( int i = 0; i < ntextures - 1; i++ ) + for (int i = 0; i < ntextures - 1; i++) { ss << "texel.rgb = " << texelNames[ i ] << ".rgb * " << constantNames[ i ] << ".rgb + texel.rgb;" << std::endl; ss << "texel.a = " << texelNames[ i ] << ".a * texel.a + texel.a;" << std::endl; @@ -1323,7 +1323,7 @@ namespace NL3D ss << "texel.rgb = " << texelNames[ ntextures - 1 ] << ".rgb * texel.rgb;" << std::endl; ss << "texel.a = " << texelNames[ ntextures - 1] << ".a;" << std::endl; - if( material->_LightMapsMulx2 ) + if (material->_LightMapsMulx2) { ss << "texel.rgb = texel.rgb * 2.0;" << std::endl; ss << "texel.a = texel.a * 2.0;" << std::endl; @@ -1331,10 +1331,10 @@ namespace NL3D ss << "fragColor = texel;" << std::endl; - if( desc->lightingEnabled() ) + if (desc->lightingEnabled()) addLightsFS(); - if( desc->fogEnabled() ) + if (desc->fogEnabled()) addFog(); addAlphaTest(); @@ -1352,7 +1352,7 @@ namespace NL3D addAlphaTreshold(); addFogUniform(); - if( desc->lightingEnabled() ) + if (desc->lightingEnabled()) { addLightUniformsFS(); addLightInsFS(); @@ -1362,18 +1362,18 @@ namespace NL3D ss << std::endl; } - if( desc->fogEnabled() ) + if (desc->fogEnabled()) ss << "smooth in vec4 ecPos;" << std::endl; ss << std::endl; - if( desc->fogEnabled() ) + if (desc->fogEnabled()) addFogFunction(); - ss << "void main( void )" << std::endl; + ss << "void main(void)" << std::endl; ss << "{" << std::endl; - ss << "vec4 texel0 = texture( sampler0, texCoord0.st );" << std::endl; - ss << "vec4 texel1 = texture( sampler1, cubeTexCoords );" << std::endl; + ss << "vec4 texel0 = texture(sampler0, texCoord0.st);" << std::endl; + ss << "vec4 texel1 = texture(sampler1, cubeTexCoords);" << std::endl; ss << "vec4 texel;" << std::endl; ss << "texel.rgb = texel0.rgb * diffuseColor.rgb;" << std::endl; ss << "texel.a = texel0.a;" << std::endl; @@ -1381,10 +1381,10 @@ namespace NL3D ss << "texel.a = texel1.a;" << std::endl; ss << "fragColor = texel;" << std::endl; - if( desc->lightingEnabled() ) + if (desc->lightingEnabled()) addLightsFS(); - if( desc->fogEnabled() ) + if (desc->fogEnabled()) addFog(); addAlphaTest(); @@ -1395,14 +1395,14 @@ namespace NL3D void CGLSLShaderGenerator::generatePPLPS() { ss << "smooth in vec3 cubeTexCoords0;" << std::endl; - if( material->getShader() == CMaterial::PerPixelLighting ) + if (material->getShader() == CMaterial::PerPixelLighting) ss << "smooth in vec3 cubeTexCoords2;" << std::endl; ss << std::endl; ss << "uniform samplerCube cubeSampler0;" << std::endl; ss << "uniform sampler2D sampler1;" << std::endl; - if( material->getShader() == CMaterial::PerPixelLighting ) + if (material->getShader() == CMaterial::PerPixelLighting) ss << "uniform samplerCube cubeSampler2;" << std::endl; addDiffuse(); @@ -1413,18 +1413,18 @@ namespace NL3D ss << std::endl; - ss << "void main( void )" << std::endl; + ss << "void main(void)" << std::endl; ss << "{" << std::endl; - ss << "vec4 texel0 = texture( cubeSampler0, cubeTexCoords0 );" << std::endl; - ss << "vec4 texel1 = texture( sampler1, texCoord1.st );" << std::endl; + ss << "vec4 texel0 = texture(cubeSampler0, cubeTexCoords0);" << std::endl; + ss << "vec4 texel1 = texture(sampler1, texCoord1.st);" << std::endl; - if( material->getShader() == CMaterial::PerPixelLighting ) - ss << "vec4 texel2 = texture( cubeSampler2, cubeTexCoords2 );" << std::endl; + if (material->getShader() == CMaterial::PerPixelLighting) + ss << "vec4 texel2 = texture(cubeSampler2, cubeTexCoords2);" << std::endl; ss << "vec4 texel;" << std::endl; - if( material->getShader() == CMaterial::PerPixelLighting ) + if (material->getShader() == CMaterial::PerPixelLighting) { ss << "texel.rgb = texel0.rgb * constant0.rgb + constant0.rgb;" << std::endl; ss << "texel.rgb = texel1.rgb * texel.rgb;" << std::endl; @@ -1449,14 +1449,14 @@ namespace NL3D void CGLSLShaderGenerator::generateWaterPS() { bool diffuse = false; - if( material->getTexture( 3 ) != NULL ) + if (material->getTexture(3) != NULL) diffuse = true; ss << "smooth in vec4 texCoord0;" << std::endl; ss << "smooth in vec4 texCoord1;" << std::endl; ss << "smooth in vec4 texCoord2;" << std::endl; - if( diffuse ) + if (diffuse) ss << "smooth in vec4 texCoord3;" << std::endl; ss << "flat in vec4 bump0ScaleBias;" << std::endl; @@ -1468,34 +1468,34 @@ namespace NL3D ss << "uniform sampler2D sampler1;" << std::endl; ss << "uniform sampler2D sampler2;" << std::endl; - if( diffuse ) + if (diffuse) ss << "uniform sampler2D sampler3;" << std::endl; addAlphaTreshold(); ss << std::endl; - ss << "void main( void )" << std::endl; + ss << "void main(void)" << std::endl; ss << "{" << std::endl; - ss << "vec4 texel0 = texture( sampler0, texCoord0.st );" << std::endl; + ss << "vec4 texel0 = texture(sampler0, texCoord0.st);" << std::endl; ss << "texel0 = texel0 * bump0ScaleBias.xxxx + bump0ScaleBias.yyzz;" << std::endl; ss << "texel0 = texel0 + texCoord1;" << std::endl; - ss << "vec4 texel1 = texture( sampler1, texel0.st );" << std::endl; + ss << "vec4 texel1 = texture(sampler1, texel0.st);" << std::endl; ss << "texel1 = texel1 * bump1ScaleBias.xxxx + bump1ScaleBias.yyzz;" << std::endl; ss << "texel1 = texel1 + texCoord2;" << std::endl; - ss << "vec4 texel2 = texture( sampler2, texel1.st );" << std::endl; + ss << "vec4 texel2 = texture(sampler2, texel1.st);" << std::endl; - if( diffuse ) + if (diffuse) { - ss << "vec4 texel3 = texture( sampler3, texCoord3.st );" << std::endl; + ss << "vec4 texel3 = texture(sampler3, texCoord3.st);" << std::endl; ss << "texel3 = texel3 * texel2;" << std::endl; } // No fog yet, so for later - //vec4 tmpFog = clamp( fogValue.x * fogFactor.x + fogFactor.y ); - //vec4 fragColor = mix( texel3, fogColor, tmpFog.x ); + //vec4 tmpFog = clamp(fogValue.x * fogFactor.x + fogFactor.y); + //vec4 fragColor = mix(texel3, fogColor, tmpFog.x); - if( diffuse ) + if (diffuse) ss << "fragColor = texel3;" << std::endl; else ss << "fragColor = texel2;" << std::endl; @@ -1515,11 +1515,11 @@ namespace NL3D addAlphaTreshold(); ss << std::endl; - ss << "void main( void )" << std::endl; + ss << "void main(void)" << std::endl; ss << "{" << std::endl; - ss << "vec4 tex0 = texture( sampler0, texCoord0.st );" << std::endl; - ss << "vec4 tex1 = texture( sampler1, texCoord1.st );" << std::endl; - ss << "vec4 tex = mix( tex0, tex1, diffuse.a );" << std::endl; + ss << "vec4 tex0 = texture(sampler0, texCoord0.st);" << std::endl; + ss << "vec4 tex1 = texture(sampler1, texCoord1.st);" << std::endl; + ss << "vec4 tex = mix(tex0, tex1, diffuse.a);" << std::endl; ss << "tex.a = 0;" << std::endl; ss << "fragColor = tex;" << std::endl; addAlphaTest(); diff --git a/code/nel/src/3d/driver/opengl3/driver_glsl_shader_generator.h b/code/nel/src/3d/driver/opengl3/driver_glsl_shader_generator.h index decdba35a..7eba87f50 100644 --- a/code/nel/src/3d/driver/opengl3/driver_glsl_shader_generator.h +++ b/code/nel/src/3d/driver/opengl3/driver_glsl_shader_generator.h @@ -37,14 +37,14 @@ namespace NL3D void reset(); /// Generate Vertex Shader based on the data provided in material, descriptor and vertexbuffer flags - void generateVS( std::string &vs ); + void generateVS(std::string &vs); /// Generate Pixel Shader based on the data provided in material, descriptor and vertexbuffer flags - void generatePS( std::string &ps ); + void generatePS(std::string &ps); - void setMaterial( CMaterial *mat ){ material = mat; } - void setVBFormat( uint16 format ){ vbFormat = format; } - void setShaderDesc( CShaderDesc *d ){ desc = d; } + void setMaterial(CMaterial *mat) { material = mat; } + void setVBFormat(uint16 format) { vbFormat = format; } + void setShaderDesc(CShaderDesc *d) { desc = d; } private: /// Adds ambient color constant uniform declaration to the program @@ -72,7 +72,7 @@ namespace NL3D /// Adds the alpha threshold uniform to the program void addAlphaTreshold(); - /// Adds the actual alpha test to the program ( discards fragment if below threshold ) + /// Adds the actual alpha test to the program (discards fragment if below threshold) void addAlphaTest(); ////////////////////////////////////////////////////////////// @@ -105,10 +105,10 @@ namespace NL3D void addLightInsFS(); /// Adds the directional light Vertex Shader function, num is the light number - void addDirectionalFunctionVS( int num ); + void addDirectionalFunctionVS(int num); /// Adds the point-light Vertex Shader function, num is the light number - void addPointLightFunctionVS( int num ); + void addPointLightFunctionVS(int num); /// Adds the appropriate light functions to the Vertex Shader void addLightsFunctionVS(); @@ -116,10 +116,10 @@ namespace NL3D /// Adds the appropriate light functions to the Pixel Shader void addLightsFunctionFS(); - /// Adds the lights to the Vertex Shader ( calls the appropriate functions ) + /// Adds the lights to the Vertex Shader (calls the appropriate functions) void addLightsVS(); - /// Adds the lights to the Fragment Shader ( calls the appropriate functions ) + /// Adds the lights to the Fragment Shader (calls the appropriate functions) void addLightsFS(); ////////////////////////////////////////////////////////////// @@ -147,9 +147,9 @@ namespace NL3D void generateTexEnv(); - void generateTexEnvRGB( unsigned int stage ); - void generateTexEnvAlpha( unsigned int stage ); - void buildArg( unsigned int stage, unsigned int n, bool alpha, std::string &arg ); + void generateTexEnvRGB(unsigned int stage); + void generateTexEnvAlpha(unsigned int stage); + void buildArg(unsigned int stage, unsigned int n, bool alpha, std::string &arg); void generateLightMapPS(); void generateSpecularPS(); diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl.cpp index 289a1bff6..f1b6cca41 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl.cpp @@ -256,7 +256,7 @@ CDriverGL3::CDriverGL3() // Compute the Flag which say if one texture has been changed in CMaterial. _MaterialAllTextureTouchedFlag= 0; - for(i=0; i < IDRV_MAT_MAXTEXTURES; i++) + for (i=0; i < IDRV_MAT_MAXTEXTURES; i++) { _MaterialAllTextureTouchedFlag|= IDRV_TOUCHED_TEX[i]; #ifdef GL_NONE @@ -266,7 +266,7 @@ CDriverGL3::CDriverGL3() #endif } - for( i = 0; i < IDRV_MAT_MAXTEXTURES; i++ ) + for (i = 0; i < IDRV_MAT_MAXTEXTURES; i++) _UserTexMat[ i ].identity(); _UserTexMatEnabled = 0; @@ -318,8 +318,8 @@ CDriverGL3::CDriverGL3() usrShaderManager = new CUsrShaderManager(); CUsrShaderLoader loader; - loader.setManager( usrShaderManager ); - loader.loadShaders( "./shaders" ); + loader.setManager(usrShaderManager); + loader.loadShaders("./shaders"); } // *************************************************************************** @@ -333,11 +333,11 @@ CDriverGL3::~CDriverGL3() currentProgram.pp = NULL; currentProgram.gp = NULL; - if( currentProgram.dynmatVP != NULL ) + if (currentProgram.dynmatVP != NULL) delete currentProgram.dynmatVP; currentProgram.dynmatVP = NULL; - if( currentProgram.dynmatPP != NULL ) + if (currentProgram.dynmatPP != NULL) delete currentProgram.dynmatPP; currentProgram.dynmatPP = NULL; @@ -362,7 +362,7 @@ bool CDriverGL3::setupDisplay() registerGlExtensions (_Extensions); vector lines; explode(_Extensions.toString(), string("\n"), lines); - for(uint i = 0; i < lines.size(); i++) + for (uint i = 0; i < lines.size(); i++) nlinfo("3D: %s", lines[i].c_str()); #if defined(NL_OS_WINDOWS) @@ -374,13 +374,13 @@ bool CDriverGL3::setupDisplay() // Check required extensions!! // ARBMultiTexture is a OpenGL 1.2 required extension. - if(!_Extensions.ARBMultiTexture) + if (!_Extensions.ARBMultiTexture) { nlwarning("Missing Required GL extension: GL_ARB_multitexture. Update your driver"); throw EBadDisplay("Missing Required GL extension: GL_ARB_multitexture. Update your driver"); } - if(!_Extensions.EXTTextureEnvCombine) + if (!_Extensions.EXTTextureEnvCombine) { nlwarning("Missing Important GL extension: GL_EXT_texture_env_combine => All envcombine are setup to GL_MODULATE!!!"); } @@ -394,7 +394,7 @@ bool CDriverGL3::setupDisplay() // All User Light are disabled by Default uint i; - for(i=0;iTextureDrvShare->DrvTexture); return gltext->activeFrameBufferObject(tex); @@ -608,7 +608,7 @@ bool CDriverGL3::clearStencilBuffer(float stencilval) // -------------------------------------------------- void CDriverGL3::setColorMask (bool bRed, bool bGreen, bool bBlue, bool bAlpha) { - H_AUTO_OGL(CDriverGL3_setColorMask ) + H_AUTO_OGL(CDriverGL3_setColorMask) glColorMask (bRed, bGreen, bBlue, bAlpha); } @@ -640,7 +640,7 @@ bool CDriverGL3::swapBuffers() #elif defined(NL_OS_MAC) // TODO: maybe do this somewhere else? - if(_DestroyWindow) + if (_DestroyWindow) { [_autoreleasePool release]; _autoreleasePool = [[NSAutoreleasePool alloc] init]; @@ -657,8 +657,8 @@ bool CDriverGL3::swapBuffers() // Activate the default texture environnments for all stages. //=========================================================== // This is not a requirement, but it ensure a more stable state each frame. - // (well, maybe the good reason is "it hides much more the bugs" :o) ). - for(uint stage=0;stagegetWidth() / (float)clientWidth; - if(clientHeight) + if (clientHeight) factorY = (float)_TextureTarget->getHeight() / (float)clientHeight; x *= factorX; y *= factorY; @@ -804,7 +804,7 @@ void CDriverGL3::getViewport(CViewport &viewport) // -------------------------------------------------- void CDriverGL3::setupScissor (const class CScissor& scissor) { - H_AUTO_OGL(CDriverGL3_setupScissor ) + H_AUTO_OGL(CDriverGL3_setupScissor) if (_win == EmptyWindow) return; @@ -826,9 +826,9 @@ void CDriverGL3::setupScissor (const class CScissor& scissor) { float factorX = 1; float factorY = 1; - if(clientWidth) + if (clientWidth) factorX = (float) _TextureTarget->getWidth() / (float)clientWidth; - if(clientHeight) + if (clientHeight) factorY = (float) _TextureTarget->getHeight() / (float)clientHeight; x *= factorX; y *= factorY; @@ -837,7 +837,7 @@ void CDriverGL3::setupScissor (const class CScissor& scissor) } // enable or disable Scissor, but AFTER textureTarget adjust - if(x==0.f && y==0.f && width>=1.f && height>=1.f) + if (x==0.f && y==0.f && width>=1.f && height>=1.f) { glDisable(GL_SCISSOR_TEST); } @@ -849,9 +849,9 @@ void CDriverGL3::setupScissor (const class CScissor& scissor) sint iy0=(sint)floor((float)clientHeight* y + 0.5f); clamp (iy0, 0, (sint)clientHeight); - sint ix1=(sint)floor((float)clientWidth * (x+width) + 0.5f ); + sint ix1=(sint)floor((float)clientWidth * (x+width) + 0.5f); clamp (ix1, 0, (sint)clientWidth); - sint iy1=(sint)floor((float)clientHeight* (y+height) + 0.5f ); + sint iy1=(sint)floor((float)clientHeight* (y+height) + 0.5f); clamp (iy1, 0, (sint)clientHeight); sint iwidth= ix1 - ix0; @@ -866,7 +866,7 @@ void CDriverGL3::setupScissor (const class CScissor& scissor) uint8 CDriverGL3::getBitPerPixel () { - H_AUTO_OGL(CDriverGL3_getBitPerPixel ) + H_AUTO_OGL(CDriverGL3_getBitPerPixel) return _CurrentMode.Depth; } @@ -906,10 +906,10 @@ bool CDriverGL3::clipRect(NLMISC::CRect &rect) void CDriverGL3::getBufferPart (CBitmap &bitmap, NLMISC::CRect &rect) { - H_AUTO_OGL(CDriverGL3_getBufferPart ) + H_AUTO_OGL(CDriverGL3_getBufferPart) bitmap.reset(); - if(clipRect(rect)) + if (clipRect(rect)) { bitmap.resize(rect.Width, rect.Height, CBitmap::RGBA); glReadPixels (rect.X, rect.Y, rect.Width, rect.Height, GL_RGBA, GL_UNSIGNED_BYTE, bitmap.getPixels ().getPtr()); @@ -918,10 +918,10 @@ void CDriverGL3::getBufferPart (CBitmap &bitmap, NLMISC::CRect &rect) void CDriverGL3::getZBufferPart (std::vector &zbuffer, NLMISC::CRect &rect) { - H_AUTO_OGL(CDriverGL3_getZBufferPart ) + H_AUTO_OGL(CDriverGL3_getZBufferPart) zbuffer.clear(); - if(clipRect(rect)) + if (clipRect(rect)) { zbuffer.resize(rect.Width*rect.Height); @@ -933,7 +933,7 @@ void CDriverGL3::getZBufferPart (std::vector &zbuffer, NLMISC::CRect &re void CDriverGL3::getZBuffer (std::vector &zbuffer) { - H_AUTO_OGL(CDriverGL3_getZBuffer ) + H_AUTO_OGL(CDriverGL3_getZBuffer) CRect rect(0,0); getWindowSize(rect.Width, rect.Height); getZBufferPart(zbuffer, rect); @@ -941,7 +941,7 @@ void CDriverGL3::getZBuffer (std::vector &zbuffer) void CDriverGL3::getBuffer (CBitmap &bitmap) { - H_AUTO_OGL(CDriverGL3_getBuffer ) + H_AUTO_OGL(CDriverGL3_getBuffer) CRect rect(0,0); getWindowSize(rect.Width, rect.Height); getBufferPart(bitmap, rect); @@ -950,14 +950,14 @@ void CDriverGL3::getBuffer (CBitmap &bitmap) bool CDriverGL3::fillBuffer (CBitmap &bitmap) { - H_AUTO_OGL(CDriverGL3_fillBuffer ) + H_AUTO_OGL(CDriverGL3_fillBuffer) CRect rect(0,0); getWindowSize(rect.Width, rect.Height); - if( rect.Width!=bitmap.getWidth() || rect.Height!=bitmap.getHeight() || bitmap.getPixelFormat()!=CBitmap::RGBA ) + if (rect.Width!=bitmap.getWidth() || rect.Height!=bitmap.getHeight() || bitmap.getPixelFormat()!=CBitmap::RGBA) return false; glPixelStorei(GL_UNPACK_ALIGNMENT,1); - glDrawPixels (rect.Width, rect.Height, GL_RGBA, GL_UNSIGNED_BYTE, &(bitmap.getPixels()[0]) ); + glDrawPixels (rect.Width, rect.Height, GL_RGBA, GL_UNSIGNED_BYTE, &(bitmap.getPixels()[0])); return true; } @@ -987,13 +987,13 @@ void CDriverGL3::copyFrameBufferToTexture(ITexture *tex, // setup texture mode, after activeTextureARB() CDriverGLStates3::TTextureMode textureMode= CDriverGLStates3::Texture2D; - if(gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV) + if (gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV) textureMode = CDriverGLStates3::TextureRect; _DriverGLStates.setTextureMode(textureMode); if (tex->isTextureCube()) { - if(_Extensions.ARBTextureCubeMap) + if (_Extensions.ARBTextureCubeMap) { glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID); glCopyTexSubImage2D(NLCubeFaceToGLCubeFace[cubeFace], level, offsetx, offsety, x, y, width, height); @@ -1015,7 +1015,7 @@ void CDriverGL3::copyFrameBufferToTexture(ITexture *tex, // *************************************************************************** void CDriverGL3::setPolygonMode (TPolygonMode mode) { - H_AUTO_OGL(CDriverGL3_setPolygonMode ) + H_AUTO_OGL(CDriverGL3_setPolygonMode) IDriver::setPolygonMode (mode); // Set the polygon mode @@ -1126,7 +1126,7 @@ uint32 CDriverGL3::profileSetupedModelMatrix() const // *************************************************************************** void CDriverGL3::enableUsedTextureMemorySum (bool enable) { - H_AUTO_OGL(CDriverGL3_enableUsedTextureMemorySum ) + H_AUTO_OGL(CDriverGL3_enableUsedTextureMemorySum) if (enable) nlinfo ("3D: PERFORMANCE INFO: enableUsedTextureMemorySum has been set to true in CDriverGL"); @@ -1169,7 +1169,7 @@ void CDriverGL3::setMatrix2DForTextureOffsetAddrMode(const uint stage, const flo if (!supportTextureShaders()) return; //nlassert(supportTextureShaders()); - nlassert(stage < inlGetNumTextStages() ); + nlassert(stage < inlGetNumTextStages()); _DriverGLStates.activeTextureARB(stage); //glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, mat); @@ -1223,7 +1223,7 @@ void CDriverGL3::setBlendConstantColor(NLMISC::CRGBA col) _CurrentBlendConstantColor= col; // update GL - if(!_Extensions.EXTBlendColor) + if (!_Extensions.EXTBlendColor) return; static const float OO255= 1.0f/255; @@ -1307,7 +1307,7 @@ void CDriverGL3::setSwapVBLInterval(uint interval) bool res = true; #if defined(NL_OS_WINDOWS) - if(_Extensions.WGLEXTSwapControl) + if (_Extensions.WGLEXTSwapControl) { res = nwglSwapIntervalEXT(_Interval) == TRUE; } @@ -1343,7 +1343,7 @@ uint CDriverGL3::getSwapVBLInterval() H_AUTO_OGL(CDriverGL3_getSwapVBLInterval) #if defined(NL_OS_WINDOWS) - if(_Extensions.WGLEXTSwapControl) + if (_Extensions.WGLEXTSwapControl) { return nwglGetSwapIntervalEXT(); } @@ -1371,7 +1371,7 @@ void CDriverGL3::enablePolygonSmoothing(bool smooth) { H_AUTO_OGL(CDriverGL3_enablePolygonSmoothing); - if(smooth) + if (smooth) glEnable(GL_POLYGON_SMOOTH); else glDisable(GL_POLYGON_SMOOTH); @@ -1390,7 +1390,7 @@ bool CDriverGL3::isPolygonSmoothingEnabled() const // *************************************************************************** void CDriverGL3::startProfileVBHardLock() { - if(_VBHardProfiling) + if (_VBHardProfiling) return; // start @@ -1404,20 +1404,20 @@ void CDriverGL3::startProfileVBHardLock() // *************************************************************************** void CDriverGL3::endProfileVBHardLock(vector &result) { - if(!_VBHardProfiling) + if (!_VBHardProfiling) return; // Fill infos. result.clear(); result.resize(_VBHardProfiles.size() + 1); float total= 0; - for(uint i=0;i<_VBHardProfiles.size();i++) + for (uint i=0;i<_VBHardProfiles.size();i++) { const uint tmpSize= 256; char tmp[tmpSize]; CVBHardProfile &vbProf= _VBHardProfiles[i]; const char *vbName; - if(vbProf.VBHard && !vbProf.VBHard->getName().empty()) + if (vbProf.VBHard && !vbProf.VBHard->getName().empty()) { vbName= vbProf.VBHard->getName().c_str(); } @@ -1427,7 +1427,7 @@ void CDriverGL3::endProfileVBHardLock(vector &result) } // Display in ms. float timeLock= (float)CTime::ticksToSecond(vbProf.AccumTime)*1000 / max(_NumVBHardProfileFrame,1U); - smprintf(tmp, tmpSize, "%16s%c: %2.3f ms", vbName, vbProf.Change?'*':' ', timeLock ); + smprintf(tmp, tmpSize, "%16s%c: %2.3f ms", vbName, vbProf.Change?'*':' ', timeLock); total+= timeLock; result[i]= tmp; @@ -1443,7 +1443,7 @@ void CDriverGL3::endProfileVBHardLock(vector &result) void CDriverGL3::appendVBHardLockProfile(NLMISC::TTicks time, CVertexBuffer *vb) { // must allocate a new place? - if(_CurVBHardLockCount>=_VBHardProfiles.size()) + if (_CurVBHardLockCount>=_VBHardProfiles.size()) { _VBHardProfiles.resize(_VBHardProfiles.size()+1); // set the original VBHard @@ -1453,7 +1453,7 @@ void CDriverGL3::appendVBHardLockProfile(NLMISC::TTicks time, CVertexBuffer *vb) // Accumulate. _VBHardProfiles[_CurVBHardLockCount].AccumTime+= time; // if change of VBHard for this chrono place - if(_VBHardProfiles[_CurVBHardLockCount].VBHard != vb) + if (_VBHardProfiles[_CurVBHardLockCount].VBHard != vb) { // flag, and set new _VBHardProfiles[_CurVBHardLockCount].VBHard= vb; @@ -1488,32 +1488,32 @@ void CDriverGL3::profileVBHardAllocation(std::vector &result) result.clear(); result.reserve(1000); result.push_back(toString("Memory Allocated: %4d Ko in AGP / %4d Ko in VRAM", - getAvailableVertexAGPMemory()/1000, getAvailableVertexVRAMMemory()/1000 )); + getAvailableVertexAGPMemory()/1000, getAvailableVertexVRAMMemory()/1000)); result.push_back(toString("Num VBHard: %d", _VertexBufferHardSet.Set.size())); uint totalMemUsed= 0; set::iterator it; - for(it= _VertexBufferHardSet.Set.begin(); it!=_VertexBufferHardSet.Set.end(); it++) + for (it= _VertexBufferHardSet.Set.begin(); it!=_VertexBufferHardSet.Set.end(); it++) { IVertexBufferHardGL *vbHard= *it; - if(vbHard) + if (vbHard) { uint vSize= vbHard->VB->getVertexSize(); uint numVerts= vbHard->VB->getNumVertices(); totalMemUsed+= vSize*numVerts; } } - result.push_back(toString("Mem Used: %4d Ko", totalMemUsed/1000) ); + result.push_back(toString("Mem Used: %4d Ko", totalMemUsed/1000)); - for(it= _VertexBufferHardSet.Set.begin(); it!=_VertexBufferHardSet.Set.end(); it++) + for (it= _VertexBufferHardSet.Set.begin(); it!=_VertexBufferHardSet.Set.end(); it++) { IVertexBufferHardGL *vbHard= *it; - if(vbHard) + if (vbHard) { uint vSize= vbHard->VB->getVertexSize(); uint numVerts= vbHard->VB->getNumVertices(); result.push_back(toString(" %16s: %4d ko (format: %d / numVerts: %d)", - vbHard->VB->getName().c_str(), vSize*numVerts/1000, vSize, numVerts )); + vbHard->VB->getName().c_str(), vSize*numVerts/1000, vSize, numVerts)); } } } @@ -1618,7 +1618,7 @@ void CDriverGL3::checkTextureOn() const // tmp for debug CDriverGLStates3 &dgs = const_cast(_DriverGLStates); uint currTexStage = dgs.getActiveTextureARB(); - for(uint k = 0; k < this->getNbTextureStages(); ++k) + for (uint k = 0; k < this->getNbTextureStages(); ++k) { dgs.activeTextureARB(k); GLboolean flag2D; @@ -1928,12 +1928,12 @@ void CDriverGL3::reloadUserShaders() { usrShaderManager->clear(); NL3D::CUsrShaderLoader loader; - loader.setManager( usrShaderManager ); - loader.loadShaders( "./shaders" ); + loader.setManager(usrShaderManager); + loader.loadShaders("./shaders"); } -CVertexProgramDrvInfosGL3::CVertexProgramDrvInfosGL3( CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it ) : -IProgramDrvInfos( drv, it ) +CVertexProgramDrvInfosGL3::CVertexProgramDrvInfosGL3(CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it) : +IProgramDrvInfos(drv, it) { programId = 0; } @@ -1943,17 +1943,17 @@ CVertexProgramDrvInfosGL3::~CVertexProgramDrvInfosGL3() programId = 0; } -uint CVertexProgramDrvInfosGL3::getUniformIndex( const char *name ) const +uint CVertexProgramDrvInfosGL3::getUniformIndex(const char *name) const { - int idx = nglGetUniformLocation( programId, name ); - if( idx == -1 ) + int idx = nglGetUniformLocation(programId, name); + if (idx == -1) return ~0; else return idx; } -CPixelProgramDrvInfosGL3::CPixelProgramDrvInfosGL3( CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it ) : -IProgramDrvInfos( drv, it ) +CPixelProgramDrvInfosGL3::CPixelProgramDrvInfosGL3(CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it) : +IProgramDrvInfos(drv, it) { programId = 0; } @@ -1963,10 +1963,10 @@ CPixelProgramDrvInfosGL3::~CPixelProgramDrvInfosGL3() programId = 0; } -uint CPixelProgramDrvInfosGL3::getUniformIndex( const char *name ) const +uint CPixelProgramDrvInfosGL3::getUniformIndex(const char *name) const { - int idx = nglGetUniformLocation( programId, name ); - if( idx == -1 ) + int idx = nglGetUniformLocation(programId, name); + if (idx == -1) return ~0; else return idx; diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl.h b/code/nel/src/3d/driver/opengl3/driver_opengl.h index 253f3c629..604649ae8 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl3/driver_opengl.h @@ -314,10 +314,10 @@ public: virtual bool init (uint windowIcon = 0, emptyProc exitFunc = 0); - virtual void disableHardwareVertexProgram(){} - virtual void disableHardwarePixelProgram(){} - virtual void disableHardwareVertexArrayAGP(){} - virtual void disableHardwareTextureShader(){} + virtual void disableHardwareVertexProgram() {} + virtual void disableHardwarePixelProgram() {} + virtual void disableHardwareVertexArrayAGP() {} + virtual void disableHardwareTextureShader() {} virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay); virtual bool setMode(const GfxMode& mode); @@ -346,8 +346,8 @@ public: virtual bool copyTextToClipboard(const ucstring &text); virtual bool pasteTextFromClipboard(ucstring &text); - uint32 getAvailableVertexAGPMemory (){ return uint32( -1 ); }; - uint32 getAvailableVertexVRAMMemory (){ return uint32( -1 ); }; + uint32 getAvailableVertexAGPMemory () { return uint32(-1); }; + uint32 getAvailableVertexVRAMMemory () { return uint32(-1); }; virtual emptyProc getWindowProc(); @@ -400,7 +400,7 @@ public: bool setupProgram(CMaterial& mat); bool setupDynMatProgram(CMaterial& mat, uint pass); void setupUniforms(); - void setupUniforms( TProgram program ); + void setupUniforms(TProgram program); virtual void startSpecularBatch(); virtual void endSpecularBatch(); @@ -422,7 +422,7 @@ public: { _ForceNormalize= normalize; // if ForceNormalize, must enable GLNormalize now. - if(normalize) + if (normalize) enableGlNormalize(true); } @@ -452,7 +452,7 @@ public: virtual bool activeIndexBuffer(CIndexBuffer& IB); - virtual void mapTextureStageToUV(uint stage, uint uv){} + virtual void mapTextureStageToUV(uint stage, uint uv) {} virtual bool renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines); virtual bool renderTriangles(CMaterial& Mat, uint32 firstIndex, uint32 ntris); @@ -595,7 +595,7 @@ public: virtual void enableLight (uint8 num, bool enable=true); - virtual bool isLightEnabled (uint8 num ); + virtual bool isLightEnabled (uint8 num); virtual void setPerPixelLightingLight(CRGBA diffuse, CRGBA specular, float shininess); @@ -1074,7 +1074,7 @@ private: // @} // Sets up a rendering pass from the dynamic material - bool setupDynMatPass( uint pass ); + bool setupDynMatPass(uint pass); /// LastVB for UV setup. CVertexBufferInfo _LastVB; @@ -1168,10 +1168,10 @@ private: /// Test/activate normalisation of normal. void enableGlNormalize(bool normalize) { - if(_CurrentGlNormalize!=normalize) + if (_CurrentGlNormalize!=normalize) { _CurrentGlNormalize= normalize; - if(normalize) + if (normalize) glEnable(GL_NORMALIZE); else glDisable(GL_NORMALIZE); @@ -1265,14 +1265,14 @@ private: bool supportGeometryProgram(CGeometryProgram::TProfile profile) const{ return false; } - bool compileGeometryProgram(CGeometryProgram *program){ return false; } + bool compileGeometryProgram(CGeometryProgram *program) { return false; } - bool activeGeometryProgram(CGeometryProgram *program){ return false; } + bool activeGeometryProgram(CGeometryProgram *program) { return false; } - uint32 getProgramId( TProgram program ) const; - IProgram* getProgram( TProgram program ) const; + uint32 getProgramId(TProgram program) const; + IProgram* getProgram(TProgram program) const; - int getUniformLocation( TProgram program, const char *name ); + int getUniformLocation(TProgram program, const char *name); void setUniform1f(TProgram program, uint index, float f0); void setUniform2f(TProgram program, uint index, float f0, float f1); void setUniform3f(TProgram program, uint index, float f0, float f1, float f2); @@ -1288,9 +1288,9 @@ private: void setUniform3f(TProgram program, uint index, const NLMISC::CVector& v); void setUniform4f(TProgram program, uint index, const NLMISC::CVector& v, float f3); void setUniform4f(TProgram program, uint index, const NLMISC::CRGBAF& rgba); - void setUniform3x3f(TProgram program, uint index, const float *src ); + void setUniform3x3f(TProgram program, uint index, const float *src); void setUniform4x4f(TProgram program, uint index, const NLMISC::CMatrix& m); - void setUniform4x4f(TProgram program, uint index, const float *src ); + void setUniform4x4f(TProgram program, uint index, const float *src); void setUniform4fv(TProgram program, uint index, size_t num, const float *src); void setUniform4iv(TProgram program, uint index, size_t num, const sint32 *src); void setUniform4uiv(TProgram program, uint index, size_t num, const uint32 *src); @@ -1298,9 +1298,9 @@ private: void setUniformMatrix(TProgram program, uint index, TMatrix matrix, TTransform transform); void setUniformFog(TProgram program, uint index); - bool isUniformProgramState(){ return false; } + bool isUniformProgramState() { return false; } - void enableVertexProgramDoubleSidedColor(bool doubleSided){} + void enableVertexProgramDoubleSidedColor(bool doubleSided) {} bool supportVertexProgramDoubleSidedColor() const{ return true; }; virtual bool supportMADOperator() const ; @@ -1430,11 +1430,11 @@ public: class CVertexProgramDrvInfosGL3 : public IProgramDrvInfos { public: - CVertexProgramDrvInfosGL3( CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it ); + CVertexProgramDrvInfosGL3(CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it); ~CVertexProgramDrvInfosGL3(); - uint getUniformIndex( const char *name ) const; + uint getUniformIndex(const char *name) const; uint getProgramId() const{ return programId; } - void setProgramId( uint id ){ programId = id; } + void setProgramId(uint id) { programId = id; } private: uint programId; @@ -1443,11 +1443,11 @@ private: class CPixelProgramDrvInfosGL3 : public IProgramDrvInfos { public: - CPixelProgramDrvInfosGL3( CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it ); + CPixelProgramDrvInfosGL3(CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it); ~CPixelProgramDrvInfosGL3(); - uint getUniformIndex( const char *name ) const; + uint getUniformIndex(const char *name) const; uint getProgramId() const{ return programId; } - void setProgramId( uint id ){ programId = id; } + void setProgramId(uint id) { programId = id; } private: uint programId; diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_extension.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_extension.cpp index c355c4d3e..745ceeeb6 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_extension.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_extension.cpp @@ -457,13 +457,13 @@ namespace NLDRIVERGL3 { #endif #define CHECK_EXT(ext_str) \ - if(strstr(glext, ext_str)==NULL) { nlwarning("3D: OpengGL extension '%s' was not found", ext_str); return false; } else { nldebug("3D: OpengGL Extension '%s' found", ext_str); } + if (strstr(glext, ext_str)==NULL) { nlwarning("3D: OpengGL extension '%s' was not found", ext_str); return false; } else { nldebug("3D: OpengGL Extension '%s' found", ext_str); } // Debug: don't return false if the procaddr returns 0 // It means that it can crash if nel calls this extension but at least we have a warning to know why the extension is available but not the procaddr #define CHECK_ADDRESS(type, ext) \ n##ext=(type)nglGetProcAddress(#ext); \ - if(!n##ext) { nlwarning("3D: GetProcAddress(\"%s\") returns NULL", #ext); return false; } else { /*nldebug("3D: GetProcAddress(\"%s\") succeed", #ext);*/ } + if (!n##ext) { nlwarning("3D: GetProcAddress(\"%s\") returns NULL", #ext); return false; } else { /*nldebug("3D: GetProcAddress(\"%s\") succeed", #ext);*/ } // *************************************************************************** // Extensions registrations, and Windows function Registration. @@ -833,127 +833,127 @@ static bool setupPackedDepthStencil(const char *glext) return true; } -static bool setupGLSL( const char *glext ) +static bool setupGLSL(const char *glext) { - CHECK_EXT( "GL_ARB_shader_objects" ); - - CHECK_ADDRESS( PFNGLATTACHSHADERPROC, glAttachShader ); - CHECK_ADDRESS( PFNGLCOMPILESHADERPROC, glCompileShader ); - CHECK_ADDRESS( PFNGLCREATEPROGRAMPROC, glCreateProgram ); - CHECK_ADDRESS( PFNGLCREATESHADERPROC, glCreateShader ); - CHECK_ADDRESS( PFNGLDELETEPROGRAMPROC, glDeleteProgram ); - CHECK_ADDRESS( PFNGLDELETESHADERPROC, glDeleteShader ); - CHECK_ADDRESS( PFNGLDETACHSHADERPROC, glDetachShader ); - CHECK_ADDRESS( PFNGLDISABLEVERTEXATTRIBARRAYPROC, glDisableVertexAttribArray ); - CHECK_ADDRESS( PFNGLENABLEVERTEXATTRIBARRAYPROC, glEnableVertexAttribArray ); - CHECK_ADDRESS( PFNGLGETATTACHEDSHADERSPROC, glGetAttachedShaders ); - CHECK_ADDRESS( PFNGLGETPROGRAMIVPROC, glGetProgramiv ); - CHECK_ADDRESS( PFNGLGETPROGRAMINFOLOGPROC, glGetProgramInfoLog ); - CHECK_ADDRESS( PFNGLGETSHADERIVPROC, glGetShaderiv ); - CHECK_ADDRESS( PFNGLGETSHADERINFOLOGPROC, glGetShaderInfoLog ); - CHECK_ADDRESS( PFNGLGETUNIFORMLOCATIONPROC, glGetUniformLocation ); - CHECK_ADDRESS( PFNGLISPROGRAMPROC, glIsProgram ); - CHECK_ADDRESS( PFNGLISSHADERPROC, glIsShader ); - CHECK_ADDRESS( PFNGLLINKPROGRAMPROC, glLinkProgram ); - CHECK_ADDRESS( PFNGLSHADERSOURCEPROC, glShaderSource ); - CHECK_ADDRESS( PFNGLUSEPROGRAMPROC, glUseProgram ); - CHECK_ADDRESS( PFNGLVALIDATEPROGRAMPROC, glValidateProgram ); - CHECK_ADDRESS( PFNGLUNIFORM1FPROC, glUniform1f ); - CHECK_ADDRESS( PFNGLUNIFORM2FPROC, glUniform2f ); - CHECK_ADDRESS( PFNGLUNIFORM3FPROC, glUniform3f ); - CHECK_ADDRESS( PFNGLUNIFORM4FPROC, glUniform4f ); - CHECK_ADDRESS( PFNGLUNIFORM1IPROC, glUniform1i ); - CHECK_ADDRESS( PFNGLUNIFORM2IPROC, glUniform2i ); - CHECK_ADDRESS( PFNGLUNIFORM3IPROC, glUniform3i ); - CHECK_ADDRESS( PFNGLUNIFORM4IPROC, glUniform4i ); - CHECK_ADDRESS( PFNGLUNIFORM1FVPROC, glUniform1fv ); - CHECK_ADDRESS( PFNGLUNIFORM2FVPROC, glUniform2fv ); - CHECK_ADDRESS( PFNGLUNIFORM3FVPROC, glUniform3fv ); - CHECK_ADDRESS( PFNGLUNIFORM4FVPROC, glUniform4fv ); - CHECK_ADDRESS( PFNGLUNIFORM1IVPROC, glUniform1iv ); - CHECK_ADDRESS( PFNGLUNIFORM2IVPROC, glUniform2iv ); - CHECK_ADDRESS( PFNGLUNIFORM3IVPROC, glUniform3iv ); - CHECK_ADDRESS( PFNGLUNIFORM4IVPROC, glUniform4iv ); - CHECK_ADDRESS( PFNGLUNIFORMMATRIX2FVPROC, glUniformMatrix2fv ); - CHECK_ADDRESS( PFNGLUNIFORMMATRIX3FVPROC, glUniformMatrix3fv ); - CHECK_ADDRESS( PFNGLUNIFORMMATRIX4FVPROC, glUniformMatrix4fv ); - CHECK_ADDRESS( PFNGLVERTEXATTRIBPOINTERPROC, glVertexAttribPointer ); - CHECK_ADDRESS( PFNGLUNIFORM1UIPROC, glUniform1ui ); - CHECK_ADDRESS( PFNGLUNIFORM2UIPROC, glUniform2ui ); - CHECK_ADDRESS( PFNGLUNIFORM3UIPROC, glUniform3ui ); - CHECK_ADDRESS( PFNGLUNIFORM4UIPROC, glUniform4ui ); - CHECK_ADDRESS( PFNGLUNIFORM1UIVPROC, glUniform1uiv ); - CHECK_ADDRESS( PFNGLUNIFORM2UIVPROC, glUniform2uiv ); - CHECK_ADDRESS( PFNGLUNIFORM3UIVPROC, glUniform3uiv ); - CHECK_ADDRESS( PFNGLUNIFORM4UIVPROC, glUniform4uiv ); + CHECK_EXT("GL_ARB_shader_objects"); + + CHECK_ADDRESS(PFNGLATTACHSHADERPROC, glAttachShader); + CHECK_ADDRESS(PFNGLCOMPILESHADERPROC, glCompileShader); + CHECK_ADDRESS(PFNGLCREATEPROGRAMPROC, glCreateProgram); + CHECK_ADDRESS(PFNGLCREATESHADERPROC, glCreateShader); + CHECK_ADDRESS(PFNGLDELETEPROGRAMPROC, glDeleteProgram); + CHECK_ADDRESS(PFNGLDELETESHADERPROC, glDeleteShader); + CHECK_ADDRESS(PFNGLDETACHSHADERPROC, glDetachShader); + CHECK_ADDRESS(PFNGLDISABLEVERTEXATTRIBARRAYPROC, glDisableVertexAttribArray); + CHECK_ADDRESS(PFNGLENABLEVERTEXATTRIBARRAYPROC, glEnableVertexAttribArray); + CHECK_ADDRESS(PFNGLGETATTACHEDSHADERSPROC, glGetAttachedShaders); + CHECK_ADDRESS(PFNGLGETPROGRAMIVPROC, glGetProgramiv); + CHECK_ADDRESS(PFNGLGETPROGRAMINFOLOGPROC, glGetProgramInfoLog); + CHECK_ADDRESS(PFNGLGETSHADERIVPROC, glGetShaderiv); + CHECK_ADDRESS(PFNGLGETSHADERINFOLOGPROC, glGetShaderInfoLog); + CHECK_ADDRESS(PFNGLGETUNIFORMLOCATIONPROC, glGetUniformLocation); + CHECK_ADDRESS(PFNGLISPROGRAMPROC, glIsProgram); + CHECK_ADDRESS(PFNGLISSHADERPROC, glIsShader); + CHECK_ADDRESS(PFNGLLINKPROGRAMPROC, glLinkProgram); + CHECK_ADDRESS(PFNGLSHADERSOURCEPROC, glShaderSource); + CHECK_ADDRESS(PFNGLUSEPROGRAMPROC, glUseProgram); + CHECK_ADDRESS(PFNGLVALIDATEPROGRAMPROC, glValidateProgram); + CHECK_ADDRESS(PFNGLUNIFORM1FPROC, glUniform1f); + CHECK_ADDRESS(PFNGLUNIFORM2FPROC, glUniform2f); + CHECK_ADDRESS(PFNGLUNIFORM3FPROC, glUniform3f); + CHECK_ADDRESS(PFNGLUNIFORM4FPROC, glUniform4f); + CHECK_ADDRESS(PFNGLUNIFORM1IPROC, glUniform1i); + CHECK_ADDRESS(PFNGLUNIFORM2IPROC, glUniform2i); + CHECK_ADDRESS(PFNGLUNIFORM3IPROC, glUniform3i); + CHECK_ADDRESS(PFNGLUNIFORM4IPROC, glUniform4i); + CHECK_ADDRESS(PFNGLUNIFORM1FVPROC, glUniform1fv); + CHECK_ADDRESS(PFNGLUNIFORM2FVPROC, glUniform2fv); + CHECK_ADDRESS(PFNGLUNIFORM3FVPROC, glUniform3fv); + CHECK_ADDRESS(PFNGLUNIFORM4FVPROC, glUniform4fv); + CHECK_ADDRESS(PFNGLUNIFORM1IVPROC, glUniform1iv); + CHECK_ADDRESS(PFNGLUNIFORM2IVPROC, glUniform2iv); + CHECK_ADDRESS(PFNGLUNIFORM3IVPROC, glUniform3iv); + CHECK_ADDRESS(PFNGLUNIFORM4IVPROC, glUniform4iv); + CHECK_ADDRESS(PFNGLUNIFORMMATRIX2FVPROC, glUniformMatrix2fv); + CHECK_ADDRESS(PFNGLUNIFORMMATRIX3FVPROC, glUniformMatrix3fv); + CHECK_ADDRESS(PFNGLUNIFORMMATRIX4FVPROC, glUniformMatrix4fv); + CHECK_ADDRESS(PFNGLVERTEXATTRIBPOINTERPROC, glVertexAttribPointer); + CHECK_ADDRESS(PFNGLUNIFORM1UIPROC, glUniform1ui); + CHECK_ADDRESS(PFNGLUNIFORM2UIPROC, glUniform2ui); + CHECK_ADDRESS(PFNGLUNIFORM3UIPROC, glUniform3ui); + CHECK_ADDRESS(PFNGLUNIFORM4UIPROC, glUniform4ui); + CHECK_ADDRESS(PFNGLUNIFORM1UIVPROC, glUniform1uiv); + CHECK_ADDRESS(PFNGLUNIFORM2UIVPROC, glUniform2uiv); + CHECK_ADDRESS(PFNGLUNIFORM3UIVPROC, glUniform3uiv); + CHECK_ADDRESS(PFNGLUNIFORM4UIVPROC, glUniform4uiv); return true; } -static bool setupSeparateShaderObjects( const char *glext ) +static bool setupSeparateShaderObjects(const char *glext) { - CHECK_EXT( "GL_ARB_separate_shader_objects" ); - - CHECK_ADDRESS( PFNGLUSEPROGRAMSTAGESPROC, glUseProgramStages ); - CHECK_ADDRESS( PFNGLACTIVESHADERPROGRAMPROC, glActiveShaderProgram ); - CHECK_ADDRESS( PFNGLCREATESHADERPROGRAMVPROC, glCreateShaderProgramv ); - CHECK_ADDRESS( PFNGLBINDPROGRAMPIPELINEPROC, glBindProgramPipeline ); - CHECK_ADDRESS( PFNGLDELETEPROGRAMPIPELINESPROC, glDeleteProgramPipelines ); - CHECK_ADDRESS( PFNGLGENPROGRAMPIPELINESPROC, glGenProgramPipelines ); - CHECK_ADDRESS( PFNGLISPROGRAMPIPELINEPROC, glIsProgramPipeline ); - CHECK_ADDRESS( PFNGLGETPROGRAMPIPELINEIVPROC, glGetProgramPipelineiv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM1IPROC, glProgramUniform1i ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM1IVPROC, glProgramUniform1iv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM1FPROC, glProgramUniform1f ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM1FVPROC, glProgramUniform1fv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM1DPROC, glProgramUniform1d ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM1DVPROC, glProgramUniform1dv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM1UIPROC, glProgramUniform1ui ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM1UIVPROC, glProgramUniform1uiv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM2IPROC, glProgramUniform2i ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM2IVPROC, glProgramUniform2iv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM2FPROC, glProgramUniform2f ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM2FVPROC, glProgramUniform2fv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM2DPROC, glProgramUniform2d ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM2DVPROC, glProgramUniform2dv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM2UIPROC, glProgramUniform2ui ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM2UIVPROC, glProgramUniform2uiv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM3IPROC, glProgramUniform3i ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM3IVPROC, glProgramUniform3iv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM3FPROC, glProgramUniform3f ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM3FVPROC, glProgramUniform3fv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM3DPROC, glProgramUniform3d ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM3DVPROC, glProgramUniform3dv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM3UIPROC, glProgramUniform3ui ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM3UIVPROC, glProgramUniform3uiv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM4IPROC, glProgramUniform4i ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM4IVPROC, glProgramUniform4iv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM4FPROC, glProgramUniform4f ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM4FVPROC, glProgramUniform4fv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM4DPROC, glProgramUniform4d ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM4DVPROC, glProgramUniform4dv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM4UIPROC, glProgramUniform4ui ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORM4UIVPROC, glProgramUniform4uiv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX2FVPROC, glProgramUniformMatrix2fv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX3FVPROC, glProgramUniformMatrix3fv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX4FVPROC, glProgramUniformMatrix4fv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX2DVPROC, glProgramUniformMatrix2dv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX3DVPROC, glProgramUniformMatrix3dv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX4DVPROC, glProgramUniformMatrix4dv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC, glProgramUniformMatrix2x3fv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC, glProgramUniformMatrix3x2fv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC, glProgramUniformMatrix2x4fv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC, glProgramUniformMatrix4x2fv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC, glProgramUniformMatrix3x4fv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC, glProgramUniformMatrix4x3fv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC, glProgramUniformMatrix2x3dv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC, glProgramUniformMatrix3x2dv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC, glProgramUniformMatrix2x4dv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC, glProgramUniformMatrix4x2dv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC, glProgramUniformMatrix3x4dv ); - CHECK_ADDRESS( PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC, glProgramUniformMatrix4x3dv ); - CHECK_ADDRESS( PFNGLVALIDATEPROGRAMPIPELINEPROC, glValidateProgramPipeline ); - CHECK_ADDRESS( PFNGLGETPROGRAMPIPELINEINFOLOGPROC, glGetProgramPipelineInfoLog ); + CHECK_EXT("GL_ARB_separate_shader_objects"); + + CHECK_ADDRESS(PFNGLUSEPROGRAMSTAGESPROC, glUseProgramStages); + CHECK_ADDRESS(PFNGLACTIVESHADERPROGRAMPROC, glActiveShaderProgram); + CHECK_ADDRESS(PFNGLCREATESHADERPROGRAMVPROC, glCreateShaderProgramv); + CHECK_ADDRESS(PFNGLBINDPROGRAMPIPELINEPROC, glBindProgramPipeline); + CHECK_ADDRESS(PFNGLDELETEPROGRAMPIPELINESPROC, glDeleteProgramPipelines); + CHECK_ADDRESS(PFNGLGENPROGRAMPIPELINESPROC, glGenProgramPipelines); + CHECK_ADDRESS(PFNGLISPROGRAMPIPELINEPROC, glIsProgramPipeline); + CHECK_ADDRESS(PFNGLGETPROGRAMPIPELINEIVPROC, glGetProgramPipelineiv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1IPROC, glProgramUniform1i); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1IVPROC, glProgramUniform1iv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1FPROC, glProgramUniform1f); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1FVPROC, glProgramUniform1fv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1DPROC, glProgramUniform1d); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1DVPROC, glProgramUniform1dv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1UIPROC, glProgramUniform1ui); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1UIVPROC, glProgramUniform1uiv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2IPROC, glProgramUniform2i); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2IVPROC, glProgramUniform2iv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2FPROC, glProgramUniform2f); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2FVPROC, glProgramUniform2fv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2DPROC, glProgramUniform2d); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2DVPROC, glProgramUniform2dv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2UIPROC, glProgramUniform2ui); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2UIVPROC, glProgramUniform2uiv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3IPROC, glProgramUniform3i); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3IVPROC, glProgramUniform3iv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3FPROC, glProgramUniform3f); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3FVPROC, glProgramUniform3fv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3DPROC, glProgramUniform3d); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3DVPROC, glProgramUniform3dv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3UIPROC, glProgramUniform3ui); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3UIVPROC, glProgramUniform3uiv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4IPROC, glProgramUniform4i); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4IVPROC, glProgramUniform4iv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4FPROC, glProgramUniform4f); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4FVPROC, glProgramUniform4fv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4DPROC, glProgramUniform4d); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4DVPROC, glProgramUniform4dv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4UIPROC, glProgramUniform4ui); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4UIVPROC, glProgramUniform4uiv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2FVPROC, glProgramUniformMatrix2fv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3FVPROC, glProgramUniformMatrix3fv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4FVPROC, glProgramUniformMatrix4fv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2DVPROC, glProgramUniformMatrix2dv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3DVPROC, glProgramUniformMatrix3dv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4DVPROC, glProgramUniformMatrix4dv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC, glProgramUniformMatrix2x3fv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC, glProgramUniformMatrix3x2fv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC, glProgramUniformMatrix2x4fv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC, glProgramUniformMatrix4x2fv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC, glProgramUniformMatrix3x4fv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC, glProgramUniformMatrix4x3fv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC, glProgramUniformMatrix2x3dv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC, glProgramUniformMatrix3x2dv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC, glProgramUniformMatrix2x4dv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC, glProgramUniformMatrix4x2dv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC, glProgramUniformMatrix3x4dv); + CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC, glProgramUniformMatrix4x3dv); + CHECK_ADDRESS(PFNGLVALIDATEPROGRAMPIPELINEPROC, glValidateProgramPipeline); + CHECK_ADDRESS(PFNGLGETPROGRAMPIPELINEINFOLOGPROC, glGetProgramPipelineInfoLog); return true; } @@ -968,11 +968,11 @@ void registerGlExtensions(CGlExtensions &ext) sint a=0, b=0; sscanf(nglVersion, "%d.%d", &a, &b); - if( ( a < 3 ) || ( ( a == 3 ) && ( b < 3 ) ) ) + if ((a < 3) || ((a == 3) && (b < 3))) { - nlinfo( "OpenGL version is less than 3.3!" ); - nlinfo( "Version string: %s",nglVersion ); - nlassert( false ); + nlinfo("OpenGL version is less than 3.3!"); + nlinfo("Version string: %s",nglVersion); + nlassert(false); } // Extensions. @@ -985,18 +985,18 @@ void registerGlExtensions(CGlExtensions &ext) { vector exts; explode(string(glext), string(" "), exts); - for(uint i = 0; i < exts.size(); i++) + for (uint i = 0; i < exts.size(); i++) { - if(i%5==0) DebugLog->displayRaw("3D: "); + if (i%5==0) DebugLog->displayRaw("3D: "); DebugLog->displayRaw(string(exts[i]+" ").c_str()); - if(i%5==4) DebugLog->displayRaw("\n"); + if (i%5==4) DebugLog->displayRaw("\n"); } DebugLog->displayRaw("\n"); } // Check ARBMultiTexture ext.ARBMultiTexture= setupARBMultiTexture(glext); - if(ext.ARBMultiTexture) + if (ext.ARBMultiTexture) { glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &ntext); // We could have more than IDRV_MAT_MAXTEXTURES but the interface only @@ -1077,16 +1077,16 @@ void registerGlExtensions(CGlExtensions &ext) setupARBVertexBufferObject(glext); - if( !setupGLSL( glext ) ) + if (!setupGLSL(glext)) { - nlinfo( "Failed to set up GLSL related calls!" ); - nlassert( false ); + nlinfo("Failed to set up GLSL related calls!"); + nlassert(false); } - if( !setupSeparateShaderObjects( glext ) ) + if (!setupSeparateShaderObjects(glext)) { - nlinfo( "Failed to set up separate shader object calls!" ); - nlassert( false ); + nlinfo("Failed to set up separate shader object calls!"); + nlassert(false); } } @@ -1168,11 +1168,11 @@ bool registerWGlExtensions(CGlExtensions &ext, HDC hDC) { vector exts; explode(string(glext), string(" "), exts); - for(uint i = 0; i < exts.size(); i++) + for (uint i = 0; i < exts.size(); i++) { - if(i%5==0) DebugLog->displayRaw("3D: "); + if (i%5==0) DebugLog->displayRaw("3D: "); DebugLog->displayRaw(string(exts[i]+" ").c_str()); - if(i%5==4) DebugLog->displayRaw("\n"); + if (i%5==4) DebugLog->displayRaw("\n"); } DebugLog->displayRaw("\n"); } @@ -1209,11 +1209,11 @@ bool registerGlXExtensions(CGlExtensions &ext, Display *dpy, sint screen) { vector exts; explode(string(glext), string(" "), exts); - for(uint i = 0; i < exts.size(); i++) + for (uint i = 0; i < exts.size(); i++) { - if(i%5==0) DebugLog->displayRaw("3D: "); + if (i%5==0) DebugLog->displayRaw("3D: "); DebugLog->displayRaw(string(exts[i]+" ").c_str()); - if(i%5==4) DebugLog->displayRaw("\n"); + if (i%5==4) DebugLog->displayRaw("\n"); } DebugLog->displayRaw("\n"); } diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_inputs.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_inputs.cpp index b867bf534..b9f3093d9 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_inputs.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_inputs.cpp @@ -159,7 +159,7 @@ void CDriverGL3::addCursor(const std::string &name, const NLMISC::CBitmap &curso minX = x; for (uint y = 0; y < height; ++y) { - if(pixels[x + y * width].A != 0) + if (pixels[x + y * width].A != 0) { stop = true; break; @@ -175,7 +175,7 @@ void CDriverGL3::addCursor(const std::string &name, const NLMISC::CBitmap &curso maxX = (uint) x; for (uint y = 0; y < height; ++y) { - if(pixels[x + y * width].A != 0) + if (pixels[x + y * width].A != 0) { stop = true; break; @@ -191,7 +191,7 @@ void CDriverGL3::addCursor(const std::string &name, const NLMISC::CBitmap &curso minY = y; for (uint x = 0; x < width; ++x) { - if(pixels[x + y * width].A != 0) + if (pixels[x + y * width].A != 0) { stop = true; break; @@ -207,7 +207,7 @@ void CDriverGL3::addCursor(const std::string &name, const NLMISC::CBitmap &curso maxY = (uint) y; for (uint x = 0; x < width; ++x) { - if(pixels[x + y * width].A != 0) + if (pixels[x + y * width].A != 0) { stop = true; break; @@ -342,7 +342,7 @@ void CDriverGL3::setCursor(const std::string &name, NLMISC::CRGBA col, uint8 rot curs.Rot != rot || curs.ColorDepth != _ColorDepth || forceRebuild - ) + ) { curs.reset(); curs.Cursor = buildCursor(curs.Src, col, rot, hotSpotX, hotSpotY); @@ -466,18 +466,18 @@ void CDriverGL3::showCursor(bool b) CGDisplayErr error = kCGErrorSuccess; static bool visible = true; - if(b && !visible) + if (b && !visible) { error = CGDisplayShowCursor(kCGDirectMainDisplay); visible = true; } - else if(!b && visible) + else if (!b && visible) { error = CGDisplayHideCursor(kCGDirectMainDisplay); visible = false; } - if(error != kCGErrorSuccess) + if (error != kCGErrorSuccess) nlerror("cannot show / hide cursor"); #elif defined (NL_OS_UNIX) @@ -527,7 +527,7 @@ void CDriverGL3::setMousePos(float x, float y) // get the rect (position, size) of the window NSRect windowRect; - if([containerView() isInFullScreenMode]) + if ([containerView() isInFullScreenMode]) windowRect = [[[containerView() window] screen] frame]; else windowRect = [[containerView() window] frame]; @@ -542,7 +542,7 @@ void CDriverGL3::setMousePos(float x, float y) firstScreenRect.size.height - windowRect.origin.y - viewRect.size.height + ((1.0 - y) * viewRect.size.height))); - if(error != kCGErrorSuccess) + if (error != kCGErrorSuccess) nlerror("cannot set mouse position"); #elif defined (NL_OS_UNIX) @@ -582,7 +582,7 @@ void CDriverGL3::setCapture (bool b) #elif defined (NL_OS_UNIX) - if(b /* && isSystemCursorInClientArea() && !isSystemCursorCaptured()*/) // capture the cursor. + if (b /* && isSystemCursorInClientArea() && !isSystemCursorCaptured()*/) // capture the cursor. { // capture the cursor XGrabPointer(_dpy, _win, True, 0, GrabModeAsync, GrabModeAsync, _win, None, CurrentTime); diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_light.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_light.cpp index 256bf50e8..0fa51904e 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_light.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_light.cpp @@ -28,7 +28,7 @@ namespace NLDRIVERGL3 { // *************************************************************************** uint CDriverGL3::getMaxLight () const { - H_AUTO_OGL(CDriverGL3_getMaxLight ) + H_AUTO_OGL(CDriverGL3_getMaxLight) // return min(maxLight supported by openGL, MaxLight=8). return _MaxDriverLight; } @@ -37,9 +37,9 @@ uint CDriverGL3::getMaxLight () const // *************************************************************************** void CDriverGL3::setLight (uint8 num, const CLight& light) { - H_AUTO_OGL(CDriverGL3_setLight ) + H_AUTO_OGL(CDriverGL3_setLight) // bkup real light, for lightmap dynamic lighting purpose - if(num==0) + if (num==0) { _UserLight0= light; // because the GL setup change, must dirt lightmap rendering @@ -106,7 +106,7 @@ void CDriverGL3::setLightInternal(uint8 num, const CLight& light) // *************************************************************************** void CDriverGL3::enableLight (uint8 num, bool enable) { - H_AUTO_OGL(CDriverGL3_enableLight ) + H_AUTO_OGL(CDriverGL3_enableLight) // enable the light in GL enableLightInternal(num, enable); @@ -117,7 +117,7 @@ void CDriverGL3::enableLight (uint8 num, bool enable) bool CDriverGL3::isLightEnabled (uint8 num) { - if(num<_MaxDriverLight) + if (num<_MaxDriverLight) return _UserLightEnable[num]; return false; @@ -144,7 +144,7 @@ void CDriverGL3::enableLightInternal(uint8 num, bool enable) void CDriverGL3::setAmbientColor (CRGBA color) { - H_AUTO_OGL(CDriverGL3_setAmbientColor ) + H_AUTO_OGL(CDriverGL3_setAmbientColor) } @@ -152,7 +152,7 @@ void CDriverGL3::setAmbientColor (CRGBA color) // *************************************************************************** void CDriverGL3::setLightMapDynamicLight (bool enable, const CLight& light) { - H_AUTO_OGL(CDriverGL3_setLightMapDynamicLight ) + H_AUTO_OGL(CDriverGL3_setLightMapDynamicLight) // just store, for future setup in lightmap material rendering _LightMapDynamicLightEnabled= enable; _LightMapDynamicLight= light; @@ -165,14 +165,14 @@ void CDriverGL3::setupLightMapDynamicLighting(bool enable) { H_AUTO_OGL(CDriverGL3_setupLightMapDynamicLighting) // start lightmap dynamic lighting - if(enable) + if (enable) { // disable all lights but the 0th. - for(uint i=1;i<_MaxDriverLight;i++) + for (uint i=1;i<_MaxDriverLight;i++) enableLightInternal(i, false); // if the dynamic light is really enabled - if(_LightMapDynamicLightEnabled) + if (_LightMapDynamicLightEnabled) { // then setup and enable setLightInternal(0, _LightMapDynamicLight); @@ -194,14 +194,14 @@ void CDriverGL3::setupLightMapDynamicLighting(bool enable) setLightInternal(0, _UserLight0); // restore all standard light enable states - for(uint i=0;i<_MaxDriverLight;i++) + for (uint i=0;i<_MaxDriverLight;i++) enableLightInternal(i, _UserLightEnable[i]); } } void CDriverGL3::disableAllLights() { - for( int i = 0; i < MaxLight; i++ ) + for (int i = 0; i < MaxLight; i++) { _UserLightEnable[ i ] = false; } diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_material.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_material.cpp index 0f9e0a135..9a08b041b 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_material.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_material.cpp @@ -118,7 +118,7 @@ void CDriverGL3::setTextureEnvFunction(uint stage, CMaterial& mat) { H_AUTO_OGL(CDriverGL3_setTextureEnvFunction) ITexture *text= mat.getTexture(uint8(stage)); - if(text) + if (text) { CMaterial::CTexEnv &env= mat._TexEnvs[stage]; @@ -133,7 +133,7 @@ void CDriverGL3::setTextureEnvFunction(uint stage, CMaterial& mat) { // set mode and enable. CMaterial::TTexCoordGenMode mode= mat.getTexCoordGenMode(stage); - if(mode==CMaterial::TexCoordGenReflect) + if (mode==CMaterial::TexCoordGenReflect) { // Cubic or normal ? if (text->isTextureCube ()) @@ -141,11 +141,11 @@ void CDriverGL3::setTextureEnvFunction(uint stage, CMaterial& mat) else _DriverGLStates.setTexGenMode (stage, GL_SPHERE_MAP); } - else if(mode==CMaterial::TexCoordGenObjectSpace) + else if (mode==CMaterial::TexCoordGenObjectSpace) { _DriverGLStates.setTexGenMode (stage, GL_OBJECT_LINEAR); } - else if(mode==CMaterial::TexCoordGenEyeSpace) + else if (mode==CMaterial::TexCoordGenEyeSpace) { _DriverGLStates.setTexGenMode (stage, GL_EYE_LINEAR); } @@ -165,7 +165,7 @@ void CDriverGL3::setupUserTextureMatrix(uint numStages, CMaterial& mat) if ( (_UserTexMatEnabled != 0 && (mat.getFlags() & IDRV_MAT_USER_TEX_MAT_ALL) == 0) || (mat.getFlags() & IDRV_MAT_USER_TEX_MAT_ALL) != 0 - ) + ) { // for each stage, setup the texture matrix if needed uint newMask = (mat.getFlags() & IDRV_MAT_USER_TEX_MAT_ALL) >> IDRV_MAT_USER_TEX_FIRST_BIT; @@ -174,7 +174,7 @@ void CDriverGL3::setupUserTextureMatrix(uint numStages, CMaterial& mat) { if (newMask & shiftMask) // user matrix for this stage { - _UserTexMat[ k ] = mat.getUserTexMat( k ); + _UserTexMat[ k ] = mat.getUserTexMat(k); _UserTexMatEnabled |= shiftMask; } else @@ -182,7 +182,7 @@ void CDriverGL3::setupUserTextureMatrix(uint numStages, CMaterial& mat) /// check if matrix disabled if ( (newMask & shiftMask) != (_UserTexMatEnabled & shiftMask) - ) + ) { _UserTexMat[ k ].identity(); _UserTexMatEnabled &= ~shiftMask; @@ -232,7 +232,7 @@ bool CDriverGL3::setupMaterial(CMaterial& mat) { H_AUTO_OGL(CDriverGL3_setupMaterial) - if( mat.getDynMat() != NULL ) + if (mat.getDynMat() != NULL) { _CurrentMaterial = &mat; return true; @@ -263,26 +263,26 @@ bool CDriverGL3::setupMaterial(CMaterial& mat) // 1. Setup modified fields of material. //===================================== - if( touched ) + if (touched) { /* Exception: if only Textures are modified in the material, no need to "Bind OpenGL States", or even to test for change, because textures are activated alone, see below. No problem with delete/new problem (see below), because in this case, IDRV_TOUCHED_ALL is set (see above). */ // If any flag is set (but a flag of texture) - if( touched & (~_MaterialAllTextureTouchedFlag) ) + if (touched & (~_MaterialAllTextureTouchedFlag)) { // Convert Material to driver shader. if (touched & IDRV_TOUCHED_BLENDFUNC) { - convBlend( mat.getSrcBlend(),glenum ); + convBlend(mat.getSrcBlend(),glenum); pShader->SrcBlend=glenum; - convBlend( mat.getDstBlend(),glenum ); + convBlend(mat.getDstBlend(),glenum); pShader->DstBlend=glenum; } if (touched & IDRV_TOUCHED_ZFUNC) { - convZFunction( mat.getZFunc(),glenum); + convZFunction(mat.getZFunc(),glenum); pShader->ZComp= glenum; } if (touched & IDRV_TOUCHED_LIGHTING) @@ -318,14 +318,14 @@ bool CDriverGL3::setupMaterial(CMaterial& mat) CMaterial::TShader matShader = pShader->SupportedShader; // if the shader has changed since last time - if(matShader != _CurrentMaterialSupportedShader) + if (matShader != _CurrentMaterialSupportedShader) { // if old was lightmap, restore standard lighting - if(_CurrentMaterialSupportedShader==CMaterial::LightMap) + if (_CurrentMaterialSupportedShader==CMaterial::LightMap) setupLightMapDynamicLighting(false); // if new is lightmap, setup dynamic lighting - if(matShader==CMaterial::LightMap) + if (matShader==CMaterial::LightMap) setupLightMapDynamicLighting(true); } @@ -339,7 +339,7 @@ bool CDriverGL3::setupMaterial(CMaterial& mat) // because setupTexture() may disable all stage. if (matShader != CMaterial::Water) { - for(stage=0 ; stageSrcBlend, pShader->DstBlend); // Double Sided Part. //=================== // NB: inverse state: DoubleSided <=> !CullFace. uint32 twoSided= mat.getFlags()&IDRV_MAT_DOUBLE_SIDED; - _DriverGLStates.enableCullFace( twoSided==0 ); + _DriverGLStates.enableCullFace(twoSided==0); // Alpha Test Part. //================= uint32 alphaTest= mat.getFlags()&IDRV_MAT_ALPHA_TEST; _DriverGLStates.enableAlphaTest(alphaTest); - if(alphaTest) + if (alphaTest) { // setup alphaTest threshold. _DriverGLStates.alphaFunc(mat.getAlphaTestThreshold()); @@ -433,10 +433,10 @@ bool CDriverGL3::setupMaterial(CMaterial& mat) // Light Part. _DriverGLStates.enableLighting(mat.getFlags()&IDRV_MAT_LIGHTING); - if( ( mat.getFlags() & IDRV_MAT_LIGHTING ) == 0 ) + if ((mat.getFlags() & IDRV_MAT_LIGHTING) == 0) disableAllLights(); - if(mat.getFlags()&IDRV_MAT_LIGHTING) + if (mat.getFlags()&IDRV_MAT_LIGHTING) { _DriverGLStates.setEmissive(pShader->PackedEmissive, pShader->Emissive); _DriverGLStates.setAmbient(pShader->PackedAmbient, pShader->Ambient); @@ -484,7 +484,7 @@ bool CDriverGL3::setupMaterial(CMaterial& mat) // 5. Set up the program // ===================== - bool programOK = setupProgram( mat ); + bool programOK = setupProgram(mat); return programOK; } @@ -493,7 +493,7 @@ sint CDriverGL3::beginMultiPass() { H_AUTO_OGL(CDriverGL3_beginMultiPass) - if( _CurrentMaterial->getDynMat() != NULL ) + if (_CurrentMaterial->getDynMat() != NULL) return _CurrentMaterial->getDynMat()->getPassCount(); // Depending on material type and hardware, return number of pass required to draw this material. @@ -524,8 +524,8 @@ bool CDriverGL3::setupPass(uint pass) { H_AUTO_OGL(CDriverGL3_setupPass) - if( _CurrentMaterial->getDynMat() != NULL ) - return setupDynMatPass( pass ); + if (_CurrentMaterial->getDynMat() != NULL) + return setupDynMatPass(pass); switch(_CurrentMaterialSupportedShader) { @@ -563,7 +563,7 @@ void CDriverGL3::endMultiPass() { H_AUTO_OGL(CDriverGL3_endMultiPass) - if( _CurrentMaterial->getDynMat() != NULL ) + if (_CurrentMaterial->getDynMat() != NULL) return; switch(_CurrentMaterialSupportedShader) @@ -594,19 +594,19 @@ void CDriverGL3::endMultiPass() } } -bool CDriverGL3::setupDynMatPass( uint pass ) +bool CDriverGL3::setupDynMatPass(uint pass) { - if( !setupDynMatProgram( *_CurrentMaterial, pass ) ) + if (!setupDynMatProgram(*_CurrentMaterial, pass)) return false; - if( ( _CurrentMaterial->getFlags() & IDRV_MAT_DOUBLE_SIDED ) != 0 ) - _DriverGLStates.enableCullFace( false ); + if ((_CurrentMaterial->getFlags() & IDRV_MAT_DOUBLE_SIDED) != 0) + _DriverGLStates.enableCullFace(false); else - _DriverGLStates.enableCullFace( true ); + _DriverGLStates.enableCullFace(true); CDynMaterial *m = _CurrentMaterial->getDynMat(); - SRenderPass *currentPass = m->getPass( pass ); + SRenderPass *currentPass = m->getPass(pass); IProgram *p; @@ -618,56 +618,56 @@ bool CDriverGL3::setupDynMatPass( uint pass ) type[ 0 ] = IDriver::VertexProgram; type[ 1 ] = IDriver::PixelProgram; - for( uint32 j = 0; j < 2; j++ ) + for (uint32 j = 0; j < 2; j++) { p = programs[ j ]; - for( uint32 i = 0; i < currentPass->count(); i++ ) + for (uint32 i = 0; i < currentPass->count(); i++) { - const SDynMaterialProp *prop = currentPass->getProperty( i ); - int loc = getUniformLocation( type[ j ], prop->prop.c_str() ); - if( loc == -1 ) + const SDynMaterialProp *prop = currentPass->getProperty(i); + int loc = getUniformLocation(type[ j ], prop->prop.c_str()); + if (loc == -1) continue; - switch( prop->type ) + switch(prop->type) { case SDynMaterialProp::Float: - setUniform1f( type[ j ], loc, prop->value.toFloat() ); + setUniform1f(type[ j ], loc, prop->value.toFloat()); break; case SDynMaterialProp::Int: - setUniform1i( type[ j ], loc, prop->value.toInt() ); + setUniform1i(type[ j ], loc, prop->value.toInt()); break; case SDynMaterialProp::Uint: - setUniform1ui( type[ j ], loc, prop->value.toUInt() ); + setUniform1ui(type[ j ], loc, prop->value.toUInt()); break; case SDynMaterialProp::Color: { float v[ 4 ]; - prop->value.getVector4( v ); + prop->value.getVector4(v); - for( int k = 0; k < 4; k++ ) + for (int k = 0; k < 4; k++) v[ k ] = v[ k ] / 255.0f; - setUniform4f( type[ j ], loc, v[ 0 ], v[ 1 ], v[ 2 ], v[ 3 ] ); + setUniform4f(type[ j ], loc, v[ 0 ], v[ 1 ], v[ 2 ], v[ 3 ]); } break; case SDynMaterialProp::Vector4: { float v[ 4 ]; - prop->value.getVector4( v ); - setUniform4f( type[ j ], loc, v[ 0 ], v[ 1 ], v[ 2 ], v[ 3 ] ); + prop->value.getVector4(v); + setUniform4f(type[ j ], loc, v[ 0 ], v[ 1 ], v[ 2 ], v[ 3 ]); } break; case SDynMaterialProp::Matrix4: { float m[ 16 ]; - prop->value.getMatrix4( m ); - setUniform4x4f( type[ j ], loc, m ); + prop->value.getMatrix4(m); + setUniform4x4f(type[ j ], loc, m); break; } @@ -679,17 +679,17 @@ bool CDriverGL3::setupDynMatPass( uint pass ) ////////////////////////////////// Set up some standard uniforms ////////////////////////////////// int loc = -1; - loc = getUniformLocation( type[ j ], "mvpMatrix" ); - if( loc != -1 ) + loc = getUniformLocation(type[ j ], "mvpMatrix"); + if (loc != -1) { CMatrix mat = _GLProjMat * _ModelViewMatrix; - setUniform4x4f( type[ j ], loc, mat ); + setUniform4x4f(type[ j ], loc, mat); } - loc = getUniformLocation( type[ j ], "mvMatrix" ); - if( loc != -1 ) + loc = getUniformLocation(type[ j ], "mvMatrix"); + if (loc != -1) { - setUniform4x4f( type[ j ], loc, _ModelViewMatrix ); + setUniform4x4f(type[ j ], loc, _ModelViewMatrix); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -703,34 +703,34 @@ void CDriverGL3::setupNormalPass() { const CMaterial &mat = *_CurrentMaterial; - for( int i = 0; i < IDRV_MAT_MAXTEXTURES; i++ ) + for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++) { // Set constant - int cl = currentProgram.pp->getUniformIndex( CProgramIndex::TName( CProgramIndex::Constant0 + i ) ); - if( cl != -1 ) + int cl = currentProgram.pp->getUniformIndex(CProgramIndex::TName(CProgramIndex::Constant0 + i)); + if (cl != -1) { GLfloat glCol[ 4 ]; - convColor( mat._TexEnvs[ i ].ConstantColor, glCol ); - setUniform4f( IDriver::PixelProgram, cl, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ] ); + convColor(mat._TexEnvs[ i ].ConstantColor, glCol); + setUniform4f(IDriver::PixelProgram, cl, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ]); } // Set texture - ITexture *t = mat.getTexture( i ); - if( t == NULL ) + ITexture *t = mat.getTexture(i); + if (t == NULL) continue; - int index = currentProgram.pp->getUniformIndex( CProgramIndex::TName( CProgramIndex::Sampler0 + i ) ); - if( index == -1 ) + int index = currentProgram.pp->getUniformIndex(CProgramIndex::TName(CProgramIndex::Sampler0 + i)); + if (index == -1) continue; - setUniform1i( IDriver::PixelProgram, index, i ); + setUniform1i(IDriver::PixelProgram, index, i); } } // *************************************************************************** void CDriverGL3::computeLightMapInfos (const CMaterial &mat) { - H_AUTO_OGL(CDriverGL3_computeLightMapInfos ) + H_AUTO_OGL(CDriverGL3_computeLightMapInfos) static const uint32 RGBMaskPacked = CRGBA(255,255,255,0).getPacked(); // For optimisation consideration, suppose there is not too much lightmap. @@ -761,7 +761,7 @@ void CDriverGL3::computeLightMapInfos (const CMaterial &mat) // *************************************************************************** sint CDriverGL3::beginLightMapMultiPass () { - H_AUTO_OGL(CDriverGL3_beginLightMapMultiPass ) + H_AUTO_OGL(CDriverGL3_beginLightMapMultiPass) const CMaterial &mat= *_CurrentMaterial; // compute how many lightmap and pass we must process. @@ -772,7 +772,7 @@ sint CDriverGL3::beginLightMapMultiPass () // if the dynamic lightmap light has changed since the last render (should not happen), resetup // normal way is that setupLightMapDynamicLighting() is called in setupMaterial() if shader different from prec - if(_LightMapDynamicLightDirty) + if (_LightMapDynamicLightDirty) setupLightMapDynamicLighting(true); // reset Ambient and specular lighting @@ -801,7 +801,7 @@ void CDriverGL3::setupLightMapPass(uint pass) static GLfloat glcolGrey[4]= {0.5f,0.5f,0.5f,1.f}; // No lightmap or all blacks??, just setup "black texture" for stage 0. - if(_NLightMaps==0) + if (_NLightMaps==0) { ITexture *text= mat.getTexture(0); activateTexture(0,text); @@ -819,7 +819,7 @@ void CDriverGL3::setupLightMapPass(uint pass) _DriverGLStates.setTexGenMode(0, 0); // And disable other stages. - for(uint stage = 1; stage < inlGetNumTextStages(); stage++) + for (uint stage = 1; stage < inlGetNumTextStages(); stage++) { // disable texturing. activateTexture(stage, NULL); @@ -845,7 +845,7 @@ void CDriverGL3::setupLightMapPass(uint pass) uint32 g=0; uint32 b=0; // sum only the ambient of lightmaps that will be drawn this pass - for(uint sa=0;sagetUniformIndex( CProgramIndex::TName( CProgramIndex::Constant0 + stage ) ); - if( cl != -1 ) + int cl = currentProgram.pp->getUniformIndex(CProgramIndex::TName(CProgramIndex::Constant0 + stage)); + if (cl != -1) { GLfloat glCol[ 4 ]; - convColor( lmapFactor, glCol ); - setUniform4f( IDriver::PixelProgram, cl, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ] ); + convColor(lmapFactor, glCol); + setUniform4f(IDriver::PixelProgram, cl, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ]); } - int tl = currentProgram.pp->getUniformIndex( CProgramIndex::TName( CProgramIndex::Sampler0 + stage ) ); - if( tl != -1 ) + int tl = currentProgram.pp->getUniformIndex(CProgramIndex::TName(CProgramIndex::Sampler0 + stage)); + if (tl != -1) { - setUniform1i( IDriver::PixelProgram, tl, stage ); + setUniform1i(IDriver::PixelProgram, tl, stage); } activateTexEnvColor(stage, stdEnv); @@ -921,7 +921,7 @@ void CDriverGL3::setupLightMapPass(uint pass) _DriverGLStates.setTexGenMode(stage, 0); // setup TexEnvCombine4 (ignore alpha part). - if(_CurrentTexEnvSpecial[stage] != TexEnvSpecialLightMap) + if (_CurrentTexEnvSpecial[stage] != TexEnvSpecialLightMap) { // TexEnv is special. _CurrentTexEnvSpecial[stage] = TexEnvSpecialLightMap; @@ -932,11 +932,11 @@ void CDriverGL3::setupLightMapPass(uint pass) // Next lightmap. lmapId++; } - else if(stagegetUniformIndex( CProgramIndex::TName( CProgramIndex::Sampler0 + stage ) ); - if( tl != -1 ) + int tl = currentProgram.pp->getUniformIndex(CProgramIndex::TName(CProgramIndex::Sampler0 + stage)); + if (tl != -1) { - setUniform1i( IDriver::PixelProgram, tl, stage ); + setUniform1i(IDriver::PixelProgram, tl, stage); } } @@ -972,15 +972,15 @@ void CDriverGL3::setupLightMapPass(uint pass) */ // Blend is different if the material is blended or not - if( !mat.getBlend() ) + if (!mat.getBlend()) { // Not blended, std case. - if(pass==0) + if (pass==0) { // no transparency for first pass. _DriverGLStates.enableBlend(false); } - else if(pass==1) + else if (pass==1) { // setup an Additive transparency (only for pass 1, will be kept for successives pass). _DriverGLStates.enableBlend(true); @@ -1003,13 +1003,13 @@ void CDriverGL3::setupLightMapPass(uint pass) finalResult= T*l1 * A + fint = T*l1 * A + T*l0 * A + B * (1-A)= T* (l0+l1) * A + B * (1-A) */ - if(pass==0) + if (pass==0) { // no transparency for first pass. _DriverGLStates.enableBlend(true); _DriverGLStates.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } - else if(pass==1) + else if (pass==1) { // setup an Additive transparency (only for pass 1, will be kept for successives pass). _DriverGLStates.enableBlend(true); @@ -1018,7 +1018,7 @@ void CDriverGL3::setupLightMapPass(uint pass) } // Dynamic lighting: The influence of the dynamic light must be added only in the first pass (only one time) - if(pass==0) + if (pass==0) { // If the lightmap is in x2 mode, then must divide effect of the dynamic light too if (mat._LightMapsMulx2) @@ -1027,7 +1027,7 @@ void CDriverGL3::setupLightMapPass(uint pass) _DriverGLStates.setDiffuse(packedColorWhite, glcolWhite); } // no need to reset for pass after 1, since same than prec pass (black)! - else if(pass==1) + else if (pass==1) _DriverGLStates.setDiffuse(packedColorBlack, glcolBlack); } @@ -1061,7 +1061,7 @@ void CDriverGL3::setupSpecularBegin() H_AUTO_OGL(CDriverGL3_setupSpecularBegin) // ---- Reset any textures with id>=2 uint stage = 2; - for(; stage < inlGetNumTextStages(); stage++) + for (; stage < inlGetNumTextStages(); stage++) { // disable texturing activateTexture(stage, NULL); @@ -1109,7 +1109,7 @@ sint CDriverGL3::beginSpecularMultiPass() // activate the 2 textures here uint stage; uint numStages= std::min((uint)2, inlGetNumTextStages()); - for(stage=0 ; stagegetUniformIndex( CProgramIndex::Sampler0 ); - if( sl0 != -1 ) + int sl0 = currentProgram.pp->getUniformIndex(CProgramIndex::Sampler0); + if (sl0 != -1) { - setUniform1i( IDriver::PixelProgram, sl0, 0 ); + setUniform1i(IDriver::PixelProgram, sl0, 0); } - int sl1 = currentProgram.pp->getUniformIndex( CProgramIndex::Sampler1 ); - if( sl1 != -1 ) + int sl1 = currentProgram.pp->getUniformIndex(CProgramIndex::Sampler1); + if (sl1 != -1) { - setUniform1i( IDriver::PixelProgram, sl1, 1 ); + setUniform1i(IDriver::PixelProgram, sl1, 1); } - int tml = currentProgram.vp->getUniformIndex( CProgramIndex::TexMatrix0 ); - if( tml != -1 ) + int tml = currentProgram.vp->getUniformIndex(CProgramIndex::TexMatrix0); + if (tml != -1) { - setUniform4x4f( IDriver::VertexProgram, tml, _UserTexMat[ 1 ] ); + setUniform4x4f(IDriver::VertexProgram, tml, _UserTexMat[ 1 ]); } { @@ -1169,12 +1169,12 @@ void CDriverGL3::setupSpecularPass(uint pass) // Set Stage 1 // Special: not the same special env if there is or not texture in stage 0. CTexEnvSpecial newEnvStage1; - if( mat.getTexture(0) == NULL ) + if (mat.getTexture(0) == NULL) newEnvStage1= TexEnvSpecialSpecularStage1NoText; else newEnvStage1= TexEnvSpecialSpecularStage1; // Test if same env as prec. - if(_CurrentTexEnvSpecial[1] != newEnvStage1) + if (_CurrentTexEnvSpecial[1] != newEnvStage1) { // TexEnv is special. _CurrentTexEnvSpecial[1] = newEnvStage1; @@ -1190,7 +1190,7 @@ void CDriverGL3::endSpecularMultiPass() { H_AUTO_OGL(CDriverGL3_endSpecularMultiPass) // End specular , only if not Batching mode. - if(!_SpecularBatchOn) + if (!_SpecularBatchOn) setupSpecularEnd(); } @@ -1504,7 +1504,7 @@ void CDriverGL3::endCausticsMultiPass(const CMaterial &mat) // *************************************************************************** sint CDriverGL3::beginCloudMultiPass () { - H_AUTO_OGL(CDriverGL3_beginCloudMultiPass ) + H_AUTO_OGL(CDriverGL3_beginCloudMultiPass) nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud); return 1; } @@ -1512,7 +1512,7 @@ sint CDriverGL3::beginCloudMultiPass () // *************************************************************************** void CDriverGL3::setupCloudPass (uint /* pass */) { - H_AUTO_OGL(CDriverGL3_setupCloudPass ) + H_AUTO_OGL(CDriverGL3_setupCloudPass) nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud); const CMaterial &mat= *_CurrentMaterial; diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_matrix.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_matrix.cpp index bdadd1426..edc519149 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_matrix.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_matrix.cpp @@ -28,12 +28,12 @@ void CDriverGL3::setFrustum(float left, float right, float bottom, float top, fl { H_AUTO_OGL(CDriverGL3_setFrustum); - if( perspective ) - _GLProjMat.frustum( left, right, bottom, top, znear, zfar ); + if (perspective) + _GLProjMat.frustum(left, right, bottom, top, znear, zfar); else - _GLProjMat.ortho( left, right, bottom, top, znear, zfar ); + _GLProjMat.ortho(left, right, bottom, top, znear, zfar); - _OODeltaZ = 1 / ( zfar - znear ); + _OODeltaZ = 1 / (zfar - znear); } diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_program.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_program.cpp index 879a2ef21..2005a7122 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_program.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_program.cpp @@ -78,86 +78,86 @@ namespace NL3D { bool CDriverGL3::supportVertexProgram(CVertexProgram::TProfile profile) const { - if( profile == IProgram::glsl330v ) + if (profile == IProgram::glsl330v) return true; else return false; } - bool CDriverGL3::compileVertexProgram( CVertexProgram *program ) + bool CDriverGL3::compileVertexProgram(CVertexProgram *program) { - if( program->m_DrvInfo != NULL ) + if (program->m_DrvInfo != NULL) return false; IProgram::CSource *src = NULL; - for( int i = 0; i < program->getSourceNb(); i++ ) + for (int i = 0; i < program->getSourceNb(); i++) { - src = program->getSource( i ); - if( src->Profile == IProgram::glsl330v ) + src = program->getSource(i); + if (src->Profile == IProgram::glsl330v) break; src = NULL; } - if( src == NULL ) + if (src == NULL) return false; const char *s = src->SourcePtr; glGetError(); - unsigned int id = nglCreateShaderProgramv( GL_VERTEX_SHADER, 1, &s ); + unsigned int id = nglCreateShaderProgramv(GL_VERTEX_SHADER, 1, &s); - if( id == 0 ) + if (id == 0) return false; GLint ok; - nglGetProgramiv( id, GL_LINK_STATUS, &ok ); - if( ok == 0 ) + nglGetProgramiv(id, GL_LINK_STATUS, &ok); + if (ok == 0) { char errorLog[ 1024 ]; - nglGetProgramInfoLog( id, 1024, NULL, errorLog ); - nlwarning( "GL3: %s", errorLog ); + nglGetProgramInfoLog(id, 1024, NULL, errorLog); + nlwarning("GL3: %s", errorLog); std::vector lines; NLMISC::explode(std::string(src->SourcePtr), std::string("\n"), lines); for (std::vector::size_type i = 0; i < lines.size(); ++i) { - nldebug( "GL3: %i: %s", i, lines[i].c_str()); + nldebug("GL3: %i: %s", i, lines[i].c_str()); } return false; } GLenum error = glGetError(); - if( error != GL_NO_ERROR ) + if (error != GL_NO_ERROR) return false; - ItGPUPrgDrvInfoPtrList it = _GPUPrgDrvInfos.insert( _GPUPrgDrvInfos.end(),(NL3D::IProgramDrvInfos*)NULL ); - CVertexProgramDrvInfosGL3 *drvInfo = new CVertexProgramDrvInfosGL3( this, it ); + ItGPUPrgDrvInfoPtrList it = _GPUPrgDrvInfos.insert(_GPUPrgDrvInfos.end(),(NL3D::IProgramDrvInfos*)NULL); + CVertexProgramDrvInfosGL3 *drvInfo = new CVertexProgramDrvInfosGL3(this, it); *it = drvInfo; program->m_DrvInfo = drvInfo; - drvInfo->setProgramId( id ); + drvInfo->setProgramId(id); - program->buildInfo( src ); + program->buildInfo(src); return true; } - bool CDriverGL3::activeVertexProgram( CVertexProgram *program ) + bool CDriverGL3::activeVertexProgram(CVertexProgram *program) { - if( program == NULL ) + if (program == NULL) return true; IProgramDrvInfos *di = program->m_DrvInfo; - CVertexProgramDrvInfosGL3 *drvInfo = dynamic_cast< CVertexProgramDrvInfosGL3* >( di ); - if( drvInfo == NULL ) + CVertexProgramDrvInfosGL3 *drvInfo = dynamic_cast< CVertexProgramDrvInfosGL3* >(di); + if (drvInfo == NULL) return false; glGetError(); - nglUseProgramStages( ppoId, GL_VERTEX_SHADER_BIT, drvInfo->getProgramId() ); + nglUseProgramStages(ppoId, GL_VERTEX_SHADER_BIT, drvInfo->getProgramId()); GLenum error = glGetError(); - if( error != GL_NO_ERROR ) + if (error != GL_NO_ERROR) { return false; @@ -168,89 +168,89 @@ namespace NL3D return true; } - bool CDriverGL3::supportPixelProgram( IProgram::TProfile profile ) const + bool CDriverGL3::supportPixelProgram(IProgram::TProfile profile) const { - if( profile == IProgram::glsl330f ) + if (profile == IProgram::glsl330f) return true; else return false; } - bool CDriverGL3::compilePixelProgram( CPixelProgram *program ) + bool CDriverGL3::compilePixelProgram(CPixelProgram *program) { - if( program->m_DrvInfo != NULL ) + if (program->m_DrvInfo != NULL) return false; IProgram::CSource *src = NULL; - for( int i = 0; i < program->getSourceNb(); i++ ) + for (int i = 0; i < program->getSourceNb(); i++) { - src = program->getSource( i ); - if( src->Profile == IProgram::glsl330f ) + src = program->getSource(i); + if (src->Profile == IProgram::glsl330f) break; src = NULL; } - if( src == NULL ) + if (src == NULL) return false; const char *s = src->SourcePtr; glGetError(); - unsigned int id = nglCreateShaderProgramv( GL_FRAGMENT_SHADER, 1, &s ); - if( id == 0 ) + unsigned int id = nglCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, &s); + if (id == 0) return false; GLint ok; - nglGetProgramiv( id, GL_LINK_STATUS, &ok ); - if( ok == 0 ) + nglGetProgramiv(id, GL_LINK_STATUS, &ok); + if (ok == 0) { char errorLog[ 1024 ]; - nglGetProgramInfoLog( id, 1024, NULL, errorLog ); - nlwarning( "GL3: %s", errorLog ); + nglGetProgramInfoLog(id, 1024, NULL, errorLog); + nlwarning("GL3: %s", errorLog); std::vector lines; NLMISC::explode(std::string(src->SourcePtr), std::string("\n"), lines); for (std::vector::size_type i = 0; i < lines.size(); ++i) { - nldebug( "GL3: %i: %s", i, lines[i].c_str()); + nldebug("GL3: %i: %s", i, lines[i].c_str()); } return false; } GLenum error = glGetError(); - if( error != GL_NO_ERROR ) + if (error != GL_NO_ERROR) return false; - ItGPUPrgDrvInfoPtrList it = _GPUPrgDrvInfos.insert( _GPUPrgDrvInfos.end(), ( NL3D::IProgramDrvInfos* )NULL ); - CPixelProgramDrvInfosGL3 *drvInfo = new CPixelProgramDrvInfosGL3( this, it ); + ItGPUPrgDrvInfoPtrList it = _GPUPrgDrvInfos.insert(_GPUPrgDrvInfos.end(), (NL3D::IProgramDrvInfos*)NULL); + CPixelProgramDrvInfosGL3 *drvInfo = new CPixelProgramDrvInfosGL3(this, it); *it = drvInfo; - drvInfo->setProgramId( id ); + drvInfo->setProgramId(id); program->m_DrvInfo = drvInfo; - program->buildInfo( src ); + program->buildInfo(src); return true; } - bool CDriverGL3::activePixelProgram( CPixelProgram *program ) + bool CDriverGL3::activePixelProgram(CPixelProgram *program) { - if( program == NULL ) + if (program == NULL) return true; - if( program->m_DrvInfo == NULL ) + if (program->m_DrvInfo == NULL) return false; IProgramDrvInfos *di = program->m_DrvInfo; - CPixelProgramDrvInfosGL3 *drvInfo = dynamic_cast< CPixelProgramDrvInfosGL3* >( di ); - if( drvInfo == NULL ) + CPixelProgramDrvInfosGL3 *drvInfo = dynamic_cast< CPixelProgramDrvInfosGL3* >(di); + if (drvInfo == NULL) return false; glGetError(); - nglUseProgramStages( ppoId, GL_FRAGMENT_SHADER_BIT, drvInfo->getProgramId() ); + nglUseProgramStages(ppoId, GL_FRAGMENT_SHADER_BIT, drvInfo->getProgramId()); GLenum error = glGetError(); - if( error != GL_NO_ERROR ) + if (error != GL_NO_ERROR) { return false; } @@ -261,30 +261,30 @@ namespace NL3D } - uint32 CDriverGL3::getProgramId( TProgram program ) const + uint32 CDriverGL3::getProgramId(TProgram program) const { uint32 id = 0; - switch( program ) + switch(program) { case IDriver::VertexProgram: { - if( currentProgram.vp != NULL ) + if (currentProgram.vp != NULL) { IProgramDrvInfos *di = currentProgram.vp->m_DrvInfo; - CVertexProgramDrvInfosGL3 *drvInfo = dynamic_cast< CVertexProgramDrvInfosGL3* >( di ); - if( drvInfo != NULL ) + CVertexProgramDrvInfosGL3 *drvInfo = dynamic_cast< CVertexProgramDrvInfosGL3* >(di); + if (drvInfo != NULL) id = drvInfo->getProgramId(); } } break; case IDriver::PixelProgram: - if( currentProgram.pp != NULL ) + if (currentProgram.pp != NULL) { IProgramDrvInfos *di = currentProgram.pp->m_DrvInfo; - CPixelProgramDrvInfosGL3 *drvInfo = dynamic_cast< CPixelProgramDrvInfosGL3* >( di ); - if( drvInfo != NULL ) + CPixelProgramDrvInfosGL3 *drvInfo = dynamic_cast< CPixelProgramDrvInfosGL3* >(di); + if (drvInfo != NULL) id = drvInfo->getProgramId(); } break; @@ -296,11 +296,11 @@ namespace NL3D return id; } - IProgram* CDriverGL3::getProgram( TProgram program ) const + IProgram* CDriverGL3::getProgram(TProgram program) const { IProgram *p = NULL; - switch( program ) + switch(program) { case IDriver::VertexProgram: p = currentProgram.vp; @@ -318,145 +318,145 @@ namespace NL3D return p; } - int CDriverGL3::getUniformLocation( TProgram program, const char *name ) + int CDriverGL3::getUniformLocation(TProgram program, const char *name) { - uint32 id = getProgramId( program ); - return nglGetUniformLocation( id, name ); + uint32 id = getProgramId(program); + return nglGetUniformLocation(id, name); } - void CDriverGL3::setUniform1f( TProgram program, uint index, float f0 ) + void CDriverGL3::setUniform1f(TProgram program, uint index, float f0) { - uint32 id = getProgramId( program ); - nglProgramUniform1f( id, index, f0 ); + uint32 id = getProgramId(program); + nglProgramUniform1f(id, index, f0); } - void CDriverGL3::setUniform2f( TProgram program, uint index, float f0, float f1 ) + void CDriverGL3::setUniform2f(TProgram program, uint index, float f0, float f1) { - uint32 id = getProgramId( program ); - nglProgramUniform2f( id, index, f0, f1 ); + uint32 id = getProgramId(program); + nglProgramUniform2f(id, index, f0, f1); } - void CDriverGL3::setUniform3f( TProgram program, uint index, float f0, float f1, float f2 ) + void CDriverGL3::setUniform3f(TProgram program, uint index, float f0, float f1, float f2) { - uint32 id = getProgramId( program ); - nglProgramUniform3f( id, index, f0, f1, f2 ); + uint32 id = getProgramId(program); + nglProgramUniform3f(id, index, f0, f1, f2); } - void CDriverGL3::setUniform4f( TProgram program, uint index, float f0, float f1, float f2, float f3 ) + void CDriverGL3::setUniform4f(TProgram program, uint index, float f0, float f1, float f2, float f3) { - uint32 id = getProgramId( program ); - nglProgramUniform4f( id, index, f0, f1, f2, f3 ); + uint32 id = getProgramId(program); + nglProgramUniform4f(id, index, f0, f1, f2, f3); } - void CDriverGL3::setUniform1i( TProgram program, uint index, sint32 i0 ) + void CDriverGL3::setUniform1i(TProgram program, uint index, sint32 i0) { - uint32 id = getProgramId( program ); - nglProgramUniform1i( id, index, i0 ); + uint32 id = getProgramId(program); + nglProgramUniform1i(id, index, i0); } - void CDriverGL3::setUniform2i( TProgram program, uint index, sint32 i0, sint32 i1 ) + void CDriverGL3::setUniform2i(TProgram program, uint index, sint32 i0, sint32 i1) { - uint32 id = getProgramId( program ); - nglProgramUniform2i( id, index, i0, i1 ); + uint32 id = getProgramId(program); + nglProgramUniform2i(id, index, i0, i1); } - void CDriverGL3::setUniform3i( TProgram program, uint index, sint32 i0, sint32 i1, sint32 i2 ) + void CDriverGL3::setUniform3i(TProgram program, uint index, sint32 i0, sint32 i1, sint32 i2) { - uint32 id = getProgramId( program ); - nglProgramUniform3i( id, index, i0, i1, i2 ); + uint32 id = getProgramId(program); + nglProgramUniform3i(id, index, i0, i1, i2); } - void CDriverGL3::setUniform4i( TProgram program, uint index, sint32 i0, sint32 i1, sint32 i2, sint32 i3 ) + void CDriverGL3::setUniform4i(TProgram program, uint index, sint32 i0, sint32 i1, sint32 i2, sint32 i3) { - uint32 id = getProgramId( program ); - nglProgramUniform4i( id, index, i0, i1, i2, i3 ); + uint32 id = getProgramId(program); + nglProgramUniform4i(id, index, i0, i1, i2, i3); } - void CDriverGL3::setUniform1ui( TProgram program, uint index, uint32 ui0 ) + void CDriverGL3::setUniform1ui(TProgram program, uint index, uint32 ui0) { - uint32 id = getProgramId( program ); - nglProgramUniform1ui( id, index, ui0 ); + uint32 id = getProgramId(program); + nglProgramUniform1ui(id, index, ui0); } - void CDriverGL3::setUniform2ui( TProgram program, uint index, uint32 ui0, uint32 ui1 ) + void CDriverGL3::setUniform2ui(TProgram program, uint index, uint32 ui0, uint32 ui1) { - uint32 id = getProgramId( program ); - nglProgramUniform2ui( id, index, ui0, ui1 ); + uint32 id = getProgramId(program); + nglProgramUniform2ui(id, index, ui0, ui1); } - void CDriverGL3::setUniform3ui( TProgram program, uint index, uint32 ui0, uint32 ui1, uint32 ui2 ) + void CDriverGL3::setUniform3ui(TProgram program, uint index, uint32 ui0, uint32 ui1, uint32 ui2) { - uint32 id = getProgramId( program ); - nglProgramUniform3ui( id, index, ui0, ui1, ui2 ); + uint32 id = getProgramId(program); + nglProgramUniform3ui(id, index, ui0, ui1, ui2); } - void CDriverGL3::setUniform4ui( TProgram program, uint index, uint32 ui0, uint32 ui1, uint32 ui2, uint32 ui3 ) + void CDriverGL3::setUniform4ui(TProgram program, uint index, uint32 ui0, uint32 ui1, uint32 ui2, uint32 ui3) { - uint32 id = getProgramId( program ); - nglProgramUniform4ui( id, index, ui0, ui1, ui2, ui3 ); + uint32 id = getProgramId(program); + nglProgramUniform4ui(id, index, ui0, ui1, ui2, ui3); } - void CDriverGL3::setUniform3f( TProgram program, uint index, const CVector &v ) + void CDriverGL3::setUniform3f(TProgram program, uint index, const CVector &v) { - uint32 id = getProgramId( program ); - nglProgramUniform3f( id, index, v.x, v.y, v.z ); + uint32 id = getProgramId(program); + nglProgramUniform3f(id, index, v.x, v.y, v.z); } - void CDriverGL3::setUniform4f( TProgram program, uint index, const CVector &v, float f3 ) + void CDriverGL3::setUniform4f(TProgram program, uint index, const CVector &v, float f3) { - uint32 id = getProgramId( program ); - nglProgramUniform4f( id, index, v.x, v.y, v.z, f3 ); + uint32 id = getProgramId(program); + nglProgramUniform4f(id, index, v.x, v.y, v.z, f3); } - void CDriverGL3::setUniform4f( TProgram program, uint index, const NLMISC::CRGBAF& rgba ) + void CDriverGL3::setUniform4f(TProgram program, uint index, const NLMISC::CRGBAF& rgba) { - uint32 id = getProgramId( program ); - nglProgramUniform4f( id, index, rgba.R, rgba.G, rgba.B, rgba.A ); + uint32 id = getProgramId(program); + nglProgramUniform4f(id, index, rgba.R, rgba.G, rgba.B, rgba.A); } - void CDriverGL3::setUniform3x3f( TProgram program, uint index, const float *src ) + void CDriverGL3::setUniform3x3f(TProgram program, uint index, const float *src) { - uint32 id = getProgramId( program ); - nglProgramUniformMatrix3fv( id, index, 1, false, src ); + uint32 id = getProgramId(program); + nglProgramUniformMatrix3fv(id, index, 1, false, src); } - void CDriverGL3::setUniform4x4f( TProgram program, uint index, const CMatrix &m ) + void CDriverGL3::setUniform4x4f(TProgram program, uint index, const CMatrix &m) { - uint32 id = getProgramId( program ); - nglProgramUniformMatrix4fv( id, index, 1, false, m.get() ); + uint32 id = getProgramId(program); + nglProgramUniformMatrix4fv(id, index, 1, false, m.get()); } - void CDriverGL3::setUniform4x4f( TProgram program, uint index, const float *src ) + void CDriverGL3::setUniform4x4f(TProgram program, uint index, const float *src) { - uint32 id = getProgramId( program ); - nglProgramUniformMatrix4fv( id, index, 1, false, src ); + uint32 id = getProgramId(program); + nglProgramUniformMatrix4fv(id, index, 1, false, src); } - void CDriverGL3::setUniform4fv( TProgram program, uint index, size_t num, const float *src ) + void CDriverGL3::setUniform4fv(TProgram program, uint index, size_t num, const float *src) { - uint32 id = getProgramId( program ); - nglProgramUniform4fv( id, index, num, src ); + uint32 id = getProgramId(program); + nglProgramUniform4fv(id, index, num, src); } - void CDriverGL3::setUniform4iv( TProgram program, uint index, size_t num, const sint32 *src ) + void CDriverGL3::setUniform4iv(TProgram program, uint index, size_t num, const sint32 *src) { - uint32 id = getProgramId( program ); - nglProgramUniform4iv( id, index, num, src ); + uint32 id = getProgramId(program); + nglProgramUniform4iv(id, index, num, src); } - void CDriverGL3::setUniform4uiv( TProgram program, uint index, size_t num, const uint32 *src ) + void CDriverGL3::setUniform4uiv(TProgram program, uint index, size_t num, const uint32 *src) { - uint32 id = getProgramId( program ); - nglProgramUniform4uiv( id, index, num, src ); + uint32 id = getProgramId(program); + nglProgramUniform4uiv(id, index, num, src); } - void CDriverGL3::setUniformMatrix( TProgram program, uint index, TMatrix matrix, TTransform transform ) + void CDriverGL3::setUniformMatrix(TProgram program, uint index, TMatrix matrix, TTransform transform) { - uint32 id = getProgramId( program ); + uint32 id = getProgramId(program); CMatrix mat; - switch( matrix ) + switch(matrix) { case IDriver::ModelView: mat = _ModelViewMatrix; @@ -469,7 +469,7 @@ namespace NL3D break; } - switch( transform ) + switch(transform) { case IDriver::Inverse: mat.invert(); @@ -484,108 +484,108 @@ namespace NL3D } - nglProgramUniformMatrix4fv( id, index, 1, false, mat.get() ); + nglProgramUniformMatrix4fv(id, index, 1, false, mat.get()); } - void CDriverGL3::setUniformFog( TProgram program, uint index ) + void CDriverGL3::setUniformFog(TProgram program, uint index) { - uint32 id = getProgramId( program ); + uint32 id = getProgramId(program); const float *v = _ModelViewMatrix.get(); - nglProgramUniform4f( id, index, -v[ 2 ], -v[ 6 ], -v[ 10 ], -v[ 4 ] ); + nglProgramUniform4f(id, index, -v[ 2 ], -v[ 6 ], -v[ 10 ], -v[ 4 ]); } - void CDriverGL3::generateShaderDesc( CShaderDesc &desc, CMaterial &mat ) + void CDriverGL3::generateShaderDesc(CShaderDesc &desc, CMaterial &mat) { - desc.setShaderType( mat.getShader() ); - desc.setVBFlags( _CurrentVertexBufferHard->VB->getVertexFormat() ); + desc.setShaderType(mat.getShader()); + desc.setVBFlags(_CurrentVertexBufferHard->VB->getVertexFormat()); - if( mat.getShader() == CMaterial::LightMap ) - desc.setNLightMaps( mat._LightMaps.size() ); + if (mat.getShader() == CMaterial::LightMap) + desc.setNLightMaps(mat._LightMaps.size()); //int i = 0; - if( mat.getShader() == CMaterial::Normal ) + if (mat.getShader() == CMaterial::Normal) { bool useTextures = false; - int maxTextures = std::min( int( SHADER_MAX_TEXTURES ), int( IDRV_MAT_MAXTEXTURES ) ); - for( int i = 0; i < maxTextures; i++ ) + int maxTextures = std::min(int(SHADER_MAX_TEXTURES), int(IDRV_MAT_MAXTEXTURES)); + for (int i = 0; i < maxTextures; i++) { - desc.setTexEnvMode( i, mat.getTexEnvMode( i ) ); + desc.setTexEnvMode(i, mat.getTexEnvMode(i)); } - for( int i = 0; i < maxTextures; i++ ) + for (int i = 0; i < maxTextures; i++) { - if( desc.hasVBFlags( vertexFlags[ TexCoord0 + i ] ) ) + if (desc.hasVBFlags(vertexFlags[ TexCoord0 + i ])) { - desc.setUseTexStage( i, true ); + desc.setUseTexStage(i, true); useTextures = true; } } - if( useTextures && !desc.getUseTexStage( 1 ) ) + if (useTextures && !desc.getUseTexStage(1)) { - for( int i = 1; i < maxTextures; i++ ) + for (int i = 1; i < maxTextures; i++) { - if( mat.getTexture( i ) != NULL ) + if (mat.getTexture(i) != NULL) { - desc.setUseTexStage( i, true ); - desc.setUseFirstTexCoords( true ); + desc.setUseTexStage(i, true); + desc.setUseFirstTexCoords(true); } } } else - if( !useTextures ) + if (!useTextures) { - desc.setNoTextures( true ); + desc.setNoTextures(true); } } - if( mat.getAlphaTest() ) + if (mat.getAlphaTest()) { - desc.setAlphaTest( true ); - desc.setAlphaTestThreshold( mat.getAlphaTestThreshold() ); + desc.setAlphaTest(true); + desc.setAlphaTestThreshold(mat.getAlphaTestThreshold()); } - if( fogEnabled() ) + if (fogEnabled()) { - desc.setFog( true ); - desc.setFogMode( CShaderDesc::Linear ); + desc.setFog(true); + desc.setFogMode(CShaderDesc::Linear); } - int maxLights = std::min( int( SHADER_MAX_LIGHTS ), int( MaxLight ) ); + int maxLights = std::min(int(SHADER_MAX_LIGHTS), int(MaxLight)); bool enableLights = false; - for( int i = 0; i < maxLights; i++ ) + for (int i = 0; i < maxLights; i++) { - if( !_UserLightEnable[ i ] ) + if (!_UserLightEnable[ i ]) continue; enableLights = true; - switch( _LightMode[ i ] ) + switch(_LightMode[ i ]) { case CLight::DirectionalLight: - desc.setLight( i, CShaderDesc::Directional ); + desc.setLight(i, CShaderDesc::Directional); break; case CLight::PointLight: - desc.setLight( i, CShaderDesc::Point ); + desc.setLight(i, CShaderDesc::Point); break; case CLight::SpotLight: - desc.setLight( i, CShaderDesc::Spot ); + desc.setLight(i, CShaderDesc::Spot); break; } } - desc.setLighting( enableLights ); + desc.setLighting(enableLights); } - bool CDriverGL3::setupProgram( CMaterial &mat ) + bool CDriverGL3::setupProgram(CMaterial &mat) { - if( mat.getDynMat() != NULL ) + if (mat.getDynMat() != NULL) return true; CVertexProgram *vp = NULL; @@ -594,23 +594,23 @@ namespace NL3D CShaderDesc desc; - generateShaderDesc( desc, mat ); + generateShaderDesc(desc, mat); // See if we've already generated and compiled this shader - sp = shaderCache.findShader( desc ); + sp = shaderCache.findShader(desc); // Yes we have! - if( !sp.empty() ) + if (!sp.empty()) { - if( currentProgram.vp == NULL ) + if (currentProgram.vp == NULL) { - if( !activeVertexProgram( sp.vp ) ) + if (!activeVertexProgram(sp.vp)) return false; } - if( currentProgram.pp == NULL ) + if (currentProgram.pp == NULL) { - if( !activePixelProgram( sp.pp ) ) + if (!activePixelProgram(sp.pp)) return false; } } @@ -622,31 +622,31 @@ namespace NL3D bool cacheShaders = true; shaderGenerator->reset(); - shaderGenerator->setMaterial( &mat ); - shaderGenerator->setVBFormat( _CurrentVertexBufferHard->VB->getVertexFormat() ); - shaderGenerator->setShaderDesc( &desc ); + shaderGenerator->setMaterial(&mat); + shaderGenerator->setVBFormat(_CurrentVertexBufferHard->VB->getVertexFormat()); + shaderGenerator->setShaderDesc(&desc); // If we don't already have a vertex program attached, we'll generate it now - if( currentProgram.vp == NULL ) + if (currentProgram.vp == NULL) { - shaderGenerator->generateVS( vs ); + shaderGenerator->generateVS(vs); vp = new CVertexProgram(); { IProgram::CSource *src = new IProgram::CSource(); src->Profile = IProgram::glsl330v; src->DisplayName = ""; - src->setSource( vs ); - vp->addSource( src ); + src->setSource(vs); + vp->addSource(src); } - if( !compileVertexProgram( vp ) ) + if (!compileVertexProgram(vp)) { delete vp; vp = NULL; return false; } - if( !activeVertexProgram( vp ) ) + if (!activeVertexProgram(vp)) { delete vp; vp = NULL; @@ -657,19 +657,19 @@ namespace NL3D cacheShaders = false; // If we don't already have a pixel program attached, we'll generate it now - if( currentProgram.pp == NULL ) + if (currentProgram.pp == NULL) { - shaderGenerator->generatePS( ps ); + shaderGenerator->generatePS(ps); pp = new CPixelProgram(); { IProgram::CSource *src = new IProgram::CSource(); src->Profile = IProgram::glsl330f; src->DisplayName = ""; - src->setSource( ps ); - pp->addSource( src ); + src->setSource(ps); + pp->addSource(src); } - if( !compilePixelProgram( pp ) ) + if (!compilePixelProgram(pp)) { delete vp; vp = NULL; @@ -678,7 +678,7 @@ namespace NL3D return false; } - if( !activePixelProgram( pp ) ) + if (!activePixelProgram(pp)) { delete vp; vp = NULL; @@ -692,12 +692,12 @@ namespace NL3D // If we already have a shader attached we won't cache this shaderpair, since we didn't generate it - if( cacheShaders ) + if (cacheShaders) { sp.vp = vp; sp.pp = pp; - desc.setShaders( sp ); - shaderCache.cacheShader( desc ); + desc.setShaders(sp); + shaderCache.cacheShader(desc); } } @@ -706,84 +706,84 @@ namespace NL3D return true; } - bool CDriverGL3::setupDynMatProgram( CMaterial& mat, uint pass ) + bool CDriverGL3::setupDynMatProgram(CMaterial& mat, uint pass) { - if( ( currentProgram.vp != NULL ) && ( currentProgram.pp != NULL ) ) + if ((currentProgram.vp != NULL) && (currentProgram.pp != NULL)) return true; CDynMaterial *m = mat.getDynMat(); - const SRenderPass *rp = m->getPass( pass ); + const SRenderPass *rp = m->getPass(pass); std::string shaderRef; - rp->getShaderRef( shaderRef ); + rp->getShaderRef(shaderRef); NL3D::CUsrShaderProgram prg; - if( !usrShaderManager->getShader( shaderRef, &prg ) ) + if (!usrShaderManager->getShader(shaderRef, &prg)) return false; std::string shaderSource; std::string log; std::string name; - if( currentProgram.vp == NULL ) + if (currentProgram.vp == NULL) { - prg.getVP( shaderSource ); - prg.getName( name ); + prg.getVP(shaderSource); + prg.getName(name); CVertexProgram *vp = new CVertexProgram(); { IProgram::CSource *src = new IProgram::CSource(); src->Profile = IProgram::glsl330v; src->DisplayName = name; - src->setSource( shaderSource.c_str() ); - vp->addSource( src ); + src->setSource(shaderSource.c_str()); + vp->addSource(src); } - if( !compileVertexProgram( vp ) ) + if (!compileVertexProgram(vp)) { delete vp; return false; } - if( !activeVertexProgram( vp ) ) + if (!activeVertexProgram(vp)) { delete vp; return false; } - if( currentProgram.dynmatVP != NULL ) + if (currentProgram.dynmatVP != NULL) delete currentProgram.dynmatVP; currentProgram.dynmatVP = vp; } - if( currentProgram.pp == NULL ) + if (currentProgram.pp == NULL) { CPixelProgram *pp = new CPixelProgram(); - prg.getFP( shaderSource ); + prg.getFP(shaderSource); { IProgram::CSource *src = new IProgram::CSource(); src->Profile = IProgram::glsl330f; src->DisplayName = name; - src->setSource( shaderSource.c_str() ); - pp->addSource( src ); + src->setSource(shaderSource.c_str()); + pp->addSource(src); } - if( !compilePixelProgram( pp ) ) + if (!compilePixelProgram(pp)) { delete pp; return false; } - if( !activePixelProgram( pp ) ) + if (!activePixelProgram(pp)) { delete pp; return false; } - if( currentProgram.dynmatPP != NULL ) + if (currentProgram.dynmatPP != NULL) delete currentProgram.dynmatPP; currentProgram.dynmatPP = pp; @@ -795,36 +795,36 @@ namespace NL3D void CDriverGL3::setupUniforms() { - setupUniforms( IDriver::VertexProgram); - setupUniforms( IDriver::PixelProgram ); + setupUniforms(IDriver::VertexProgram); + setupUniforms(IDriver::PixelProgram); } - void CDriverGL3::setupUniforms( TProgram program ) + void CDriverGL3::setupUniforms(TProgram program) { CMaterial &mat = *_CurrentMaterial; - IProgram *p = getProgram( program ); + IProgram *p = getProgram(program); - int mvpIndex = p->getUniformIndex( CProgramIndex::ModelViewProjection ); - if( mvpIndex != -1 ) + int mvpIndex = p->getUniformIndex(CProgramIndex::ModelViewProjection); + if (mvpIndex != -1) { CMatrix mvp = _GLProjMat * _ModelViewMatrix; - setUniform4x4f( program, mvpIndex, mvp ); + setUniform4x4f(program, mvpIndex, mvp); } - int vmIndex = p->getUniformIndex( CProgramIndex::ViewMatrix ); - if( vmIndex != -1 ) + int vmIndex = p->getUniformIndex(CProgramIndex::ViewMatrix); + if (vmIndex != -1) { - setUniform4x4f( program, vmIndex, _ViewMtx ); + setUniform4x4f(program, vmIndex, _ViewMtx); } - int mvIndex = p->getUniformIndex( CProgramIndex::ModelView ); - if( mvIndex != -1 ) + int mvIndex = p->getUniformIndex(CProgramIndex::ModelView); + if (mvIndex != -1) { - setUniform4x4f( program, mvIndex, _ModelViewMatrix ); + setUniform4x4f(program, mvIndex, _ModelViewMatrix); } - int nmIdx = p->getUniformIndex( CProgramIndex::NormalMatrix ); - if( nmIdx != -1 ) + int nmIdx = p->getUniformIndex(CProgramIndex::NormalMatrix); + if (nmIdx != -1) { // normal matrix is the inverse-transpose of the rotation part of the modelview matrix // Inverse-transpose of the rotation matrix, is itself @@ -840,23 +840,23 @@ namespace NL3D nm[ 7 ] = mv[ 9 ]; nm[ 8 ] = mv[ 10 ]; - setUniform3x3f( program, nmIdx, nm ); + setUniform3x3f(program, nmIdx, nm); } - int fogStartIdx = p->getUniformIndex( CProgramIndex::FogStart ); - if( fogStartIdx != -1 ) + int fogStartIdx = p->getUniformIndex(CProgramIndex::FogStart); + if (fogStartIdx != -1) { - setUniform1f( program, fogStartIdx, getFogStart() ); + setUniform1f(program, fogStartIdx, getFogStart()); } - int fogEndIdx = p->getUniformIndex( CProgramIndex::FogEnd ); - if( fogEndIdx != -1 ) + int fogEndIdx = p->getUniformIndex(CProgramIndex::FogEnd); + if (fogEndIdx != -1) { - setUniform1f( program, fogEndIdx, getFogEnd() ); + setUniform1f(program, fogEndIdx, getFogEnd()); } - int fogColorIdx = p->getUniformIndex( CProgramIndex::FogColor ); - if( fogColorIdx != -1 ) + int fogColorIdx = p->getUniformIndex(CProgramIndex::FogColor); + if (fogColorIdx != -1) { GLfloat glCol[ 4 ]; CRGBA col = getFogColor(); @@ -864,11 +864,11 @@ namespace NL3D glCol[ 1 ] = col.G / 255.0f; glCol[ 2 ] = col.B / 255.0f; glCol[ 3 ] = col.A / 255.0f; - setUniform4f( program, fogColorIdx, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ] ); + setUniform4f(program, fogColorIdx, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ]); } - int colorIndex = p->getUniformIndex( CProgramIndex::Color ); - if( colorIndex != -1 ) + int colorIndex = p->getUniformIndex(CProgramIndex::Color); + if (colorIndex != -1) { GLfloat glCol[ 4 ]; CRGBA col = mat.getColor(); @@ -877,11 +877,11 @@ namespace NL3D glCol[ 2 ] = col.B / 255.0f; glCol[ 3 ] = col.A / 255.0f; - setUniform4f( program, colorIndex, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ] ); + setUniform4f(program, colorIndex, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ]); } - int diffuseIndex = p->getUniformIndex( CProgramIndex::DiffuseColor ); - if( diffuseIndex != -1 ) + int diffuseIndex = p->getUniformIndex(CProgramIndex::DiffuseColor); + if (diffuseIndex != -1) { GLfloat glCol[ 4 ]; CRGBA col = mat.getDiffuse(); @@ -890,46 +890,46 @@ namespace NL3D glCol[ 2 ] = col.B / 255.0f; glCol[ 3 ] = col.A / 255.0f; - setUniform4f( program, diffuseIndex, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ] ); + setUniform4f(program, diffuseIndex, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ]); } - int maxLights = std::min( int( MaxLight ), int( SHADER_MAX_LIGHTS ) ); - for( int i = 0; i < maxLights; i++ ) + int maxLights = std::min(int(MaxLight), int(SHADER_MAX_LIGHTS)); + for (int i = 0; i < maxLights; i++) { - if( !_UserLightEnable[ i ] ) + if (!_UserLightEnable[ i ]) continue; ////////////////// Temporary insanity /////////////////////////////// - if( ( _LightMode[ i ] != CLight::DirectionalLight ) && ( _LightMode[ i ] != CLight::PointLight ) ) + if ((_LightMode[ i ] != CLight::DirectionalLight) && (_LightMode[ i ] != CLight::PointLight)) continue; ////////////////////////////////////////////////////////////////////// - if( _LightMode[ i ] == CLight::DirectionalLight ) + if (_LightMode[ i ] == CLight::DirectionalLight) { - int ld = p->getUniformIndex( CProgramIndex::TName( CProgramIndex::Light0DirOrPos + i ) ); - if( ld != -1 ) + int ld = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0DirOrPos + i)); + if (ld != -1) { CVector v = -1 * _UserLight[ i ].getDirection(); - setUniform3f( program, ld, v.x, v.y, v.z ); + setUniform3f(program, ld, v.x, v.y, v.z); } } else { - int lp = p->getUniformIndex( CProgramIndex::TName( CProgramIndex::Light0DirOrPos + i ) ); - if( lp != -1 ) + int lp = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0DirOrPos + i)); + if (lp != -1) { CVector v = _UserLight[ i ].getPosition(); float pos[ 3 ]; pos[ 0 ] = v.x - _PZBCameraPos.x; pos[ 1 ] = v.y - _PZBCameraPos.y; pos[ 2 ] = v.z - _PZBCameraPos.z; - setUniform3f( program, lp, pos[ 0 ], pos[ 1 ], pos[ 2 ] ); + setUniform3f(program, lp, pos[ 0 ], pos[ 1 ], pos[ 2 ]); } } - int ldc = p->getUniformIndex( CProgramIndex::TName( CProgramIndex::Light0ColDiff + i ) ); - if( ldc != -1 ) + int ldc = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0ColDiff + i)); + if (ldc != -1) { GLfloat glCol[ 4 ]; CRGBA col = _UserLight[ i ].getDiffuse(); @@ -937,11 +937,11 @@ namespace NL3D glCol[ 1 ] = col.G / 255.0f; glCol[ 2 ] = col.B / 255.0f; glCol[ 3 ] = col.A / 255.0f; - setUniform4f( program, ldc, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ] ); + setUniform4f(program, ldc, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ]); } - int lsc = p->getUniformIndex( CProgramIndex::TName( CProgramIndex::Light0ColSpec + i ) ); - if( lsc != -1 ) + int lsc = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0ColSpec + i)); + if (lsc != -1) { GLfloat glCol[ 4 ]; CRGBA col = _UserLight[ i ].getSpecular(); @@ -949,60 +949,60 @@ namespace NL3D glCol[ 1 ] = col.G / 255.0f; glCol[ 2 ] = col.B / 255.0f; glCol[ 3 ] = col.A / 255.0f; - setUniform4f( program, lsc, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ] ); + setUniform4f(program, lsc, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ]); } - int shl = p->getUniformIndex( CProgramIndex::TName( CProgramIndex::Light0Shininess + i ) ); - if( shl != -1 ) + int shl = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0Shininess + i)); + if (shl != -1) { - setUniform1f( program, shl, mat.getShininess() ); + setUniform1f(program, shl, mat.getShininess()); } - int lac = p->getUniformIndex( CProgramIndex::TName( CProgramIndex::Light0ColAmb + i ) ); - if( lac != -1 ) + int lac = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0ColAmb + i)); + if (lac != -1) { GLfloat glCol[ 4 ]; CRGBA col; - if( mat.getShader() == CMaterial::LightMap ) + if (mat.getShader() == CMaterial::LightMap) col = _UserLight[ i ].getAmbiant(); else - col.add( _UserLight[ i ].getAmbiant(), mat.getEmissive() ); + col.add(_UserLight[ i ].getAmbiant(), mat.getEmissive()); glCol[ 0 ] = col.R / 255.0f; glCol[ 1 ] = col.G / 255.0f; glCol[ 2 ] = col.B / 255.0f; glCol[ 3 ] = col.A / 255.0f; - setUniform4f( program, lac, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ] ); + setUniform4f(program, lac, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ]); } - int lca = p->getUniformIndex( CProgramIndex::TName( CProgramIndex::Light0ConstAttn + i ) ); - if( lca != -1 ) + int lca = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0ConstAttn + i)); + if (lca != -1) { - setUniform1f( program, lca, _UserLight[ i ].getConstantAttenuation() ); + setUniform1f(program, lca, _UserLight[ i ].getConstantAttenuation()); } - int lla = p->getUniformIndex( CProgramIndex::TName( CProgramIndex::Light0LinAttn + i ) ); - if( lla != -1 ) + int lla = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0LinAttn + i)); + if (lla != -1) { - setUniform1f( program, lla, _UserLight[ i ].getLinearAttenuation() ); + setUniform1f(program, lla, _UserLight[ i ].getLinearAttenuation()); } - int lqa = p->getUniformIndex( CProgramIndex::TName( CProgramIndex::Light0QuadAttn + i ) ); - if( lqa != -1 ) + int lqa = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0QuadAttn + i)); + if (lqa != -1) { - setUniform1f( program, lqa, _UserLight[ i ].getQuadraticAttenuation() ); + setUniform1f(program, lqa, _UserLight[ i ].getQuadraticAttenuation()); } } // Lightmaps have special constants - if( mat.getShader() != CMaterial::LightMap ) + if (mat.getShader() != CMaterial::LightMap) { - for( int i = 0; i < IDRV_MAT_MAXTEXTURES; i++ ) + for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++) { - int cl = p->getUniformIndex( CProgramIndex::TName( CProgramIndex::Constant0 + i ) ); - if( cl != -1 ) + int cl = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Constant0 + i)); + if (cl != -1) { CRGBA col = mat._TexEnvs[ i ].ConstantColor; GLfloat glCol[ 4 ]; @@ -1011,7 +1011,7 @@ namespace NL3D glCol[ 2 ] = col.B / 255.0f; glCol[ 3 ] = col.A / 255.0f; - setUniform4f( program, cl, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ] ); + setUniform4f(program, cl, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ]); } } @@ -1022,11 +1022,11 @@ namespace NL3D { ppoId = 0; - nglGenProgramPipelines( 1, &ppoId ); - if( ppoId == 0 ) + nglGenProgramPipelines(1, &ppoId); + if (ppoId == 0) return false; - nglBindProgramPipeline( ppoId ); + nglBindProgramPipeline(ppoId); return true; } diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_rendering.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_rendering.cpp index 915006afa..985444ea0 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_rendering.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_rendering.cpp @@ -33,7 +33,7 @@ bool CDriverGL3::renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines) H_AUTO_OGL(CDriverGL3_renderLines) // setup material - if ( !setupMaterial(mat) || _LastIB._Values == NULL ) + if (!setupMaterial(mat) || _LastIB._Values == NULL) return false; if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; @@ -43,14 +43,14 @@ bool CDriverGL3::renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines) uint nPass; nPass= beginMultiPass(); // draw all passes. - for(uint pass=0;passisInvalid()) return true; @@ -95,14 +95,14 @@ bool CDriverGL3::renderTriangles(CMaterial& mat, uint32 firstIndex, uint32 ntris nPass= beginMultiPass(); // draw all passes. - for(uint pass=0;passisInvalid()) return true; @@ -180,14 +180,14 @@ bool CDriverGL3::renderRawPoints(CMaterial& mat, uint32 startIndex, uint32 numPo uint nPass; nPass= beginMultiPass(); // draw all passes. - for(uint pass=0;passisInvalid()) return true; @@ -220,14 +220,14 @@ bool CDriverGL3::renderRawLines(CMaterial& mat, uint32 startIndex, uint32 numLin uint nPass; nPass= beginMultiPass(); // draw all passes. - for(uint pass=0;passisInvalid()) return true; @@ -260,14 +260,14 @@ bool CDriverGL3::renderRawTriangles(CMaterial& mat, uint32 startIndex, uint32 nu uint nPass; nPass= beginMultiPass(); // draw all passes. - for(uint pass=0;passisInvalid()) return true; @@ -304,7 +304,7 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua if (!init) { // setup the base index buffer - for(uint k = 0; k < QUAD_BATCH_SIZE; ++k) + for (uint k = 0; k < QUAD_BATCH_SIZE; ++k) { // first tri defaultIndices[k * 6] = (GLshort) (k * 4); @@ -325,10 +325,10 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua uint nPass; nPass= beginMultiPass(); // draw all passes. - for(uint pass=0;pass::iterator itr = shaders.begin(); - while( itr != shaders.end() ) + while (itr != shaders.end()) { SShaderPair sp; sp = itr->getShaders(); diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_shader_cache.h b/code/nel/src/3d/driver/opengl3/driver_opengl_shader_cache.h index 84d0c4796..3fdd18d5f 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_shader_cache.h +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_shader_cache.h @@ -31,10 +31,10 @@ namespace NL3D ~CShaderCache(); /// Checks if there's a shader cached that was generated from the specified descriptor - SShaderPair findShader( const CShaderDesc &desc ) const; + SShaderPair findShader(const CShaderDesc &desc) const; /// Caches a shader with the specified descriptor as key - void cacheShader( CShaderDesc &desc ); + void cacheShader(CShaderDesc &desc); /// Clears the caches, removes the cached shaders void clearCache(); diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_shader_desc.h b/code/nel/src/3d/driver/opengl3/driver_opengl_shader_desc.h index cb7cce2f8..62e8ceecf 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_shader_desc.h +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_shader_desc.h @@ -42,7 +42,7 @@ namespace NL3D } bool empty() const{ - if( ( vp == NULL ) && ( pp == NULL ) ) + if ((vp == NULL) && (pp == NULL)) return true; else return false; @@ -85,14 +85,14 @@ namespace NL3D Spot }; - CShaderDesc(){ - for( int i = 0; i < SHADER_MAX_TEXTURES; i++ ) + CShaderDesc() { + for (int i = 0; i < SHADER_MAX_TEXTURES; i++) texEnvMode[ i ] = 0; - for( int i = 0; i < SHADER_MAX_LIGHTS; i++ ) + for (int i = 0; i < SHADER_MAX_LIGHTS; i++) lightMode[ i ] = Nolight; - for( int i = 0; i < SHADER_MAX_TEXTURES; i++ ) + for (int i = 0; i < SHADER_MAX_TEXTURES; i++) useTextureStage[ i ] = false; useFirstTextureCoordSet = false; noTextures = true; @@ -106,100 +106,100 @@ namespace NL3D pointLight = false; } - ~CShaderDesc(){ + ~CShaderDesc() { } - bool operator==( const CShaderDesc &o ) const + bool operator==(const CShaderDesc &o) const { - if( noTextures != o.noTextures ) + if (noTextures != o.noTextures) return false; - if( shaderType != o.shaderType ) + if (shaderType != o.shaderType) return false; - if( vbFlags != o.vbFlags ) + if (vbFlags != o.vbFlags) return false; - if( nlightmaps != o.nlightmaps ) + if (nlightmaps != o.nlightmaps) return false; - if( features != o.features ) + if (features != o.features) return false; - if( ( features & AlphaTest ) != 0 ) + if ((features & AlphaTest) != 0) { - if( alphaTestTreshold > o.alphaTestTreshold + 0.0001f ) + if (alphaTestTreshold > o.alphaTestTreshold + 0.0001f) return false; - if( alphaTestTreshold < o.alphaTestTreshold - 0.0001f ) + if (alphaTestTreshold < o.alphaTestTreshold - 0.0001f) return false; } - if( fogEnabled() ) + if (fogEnabled()) { - if( fogMode != o.fogMode ) + if (fogMode != o.fogMode) return false; } - if( shaderType == Normal ) + if (shaderType == Normal) { - if( useFirstTextureCoordSet != o.useFirstTextureCoordSet ) + if (useFirstTextureCoordSet != o.useFirstTextureCoordSet) return false; - for( int i = 0; i < SHADER_MAX_TEXTURES; i++ ) - if( texEnvMode[ i ] != o.texEnvMode[ i ] ) + for (int i = 0; i < SHADER_MAX_TEXTURES; i++) + if (texEnvMode[ i ] != o.texEnvMode[ i ]) return false; - for( int i = 0; i < SHADER_MAX_TEXTURES; i++ ) - if( useTextureStage[ i ] != o.useTextureStage[ i ] ) + for (int i = 0; i < SHADER_MAX_TEXTURES; i++) + if (useTextureStage[ i ] != o.useTextureStage[ i ]) return false; } - if( lightingEnabled() ) + if (lightingEnabled()) { - for( int i = 0; i < SHADER_MAX_LIGHTS; i++ ) - if( lightMode[ i ] != o.lightMode[ i ] ) + for (int i = 0; i < SHADER_MAX_LIGHTS; i++) + if (lightMode[ i ] != o.lightMode[ i ]) return false; } return true; } - void setTexEnvMode( uint32 index, uint32 mode ){ texEnvMode[ index ] = mode; } + void setTexEnvMode(uint32 index, uint32 mode) { texEnvMode[ index ] = mode; } - void setUseFirstTexCoords( bool b ){ useFirstTextureCoordSet = b; } + void setUseFirstTexCoords(bool b) { useFirstTextureCoordSet = b; } bool getUseFirstTexCoords() const{ return useFirstTextureCoordSet; } - void setUseTexStage( uint8 stage, bool b ){ useTextureStage[ stage ] = b; } - bool getUseTexStage( uint8 stage ) const{ return useTextureStage[ stage ]; } + void setUseTexStage(uint8 stage, bool b) { useTextureStage[ stage ] = b; } + bool getUseTexStage(uint8 stage) const{ return useTextureStage[ stage ]; } - void setNoTextures( bool b ){ noTextures = b; } + void setNoTextures(bool b) { noTextures = b; } bool useTextures() const{ return !noTextures; } - void setVBFlags( uint32 flags ){ vbFlags = flags; } - bool hasVBFlags( uint32 flags ) const{ - if( ( vbFlags & flags ) != 0 ) + void setVBFlags(uint32 flags) { vbFlags = flags; } + bool hasVBFlags(uint32 flags) const{ + if ((vbFlags & flags) != 0) return true; else return false; } - void setShaderType( uint32 type ){ shaderType = type; } - void setNLightMaps( uint32 n ){ nlightmaps = n; } + void setShaderType(uint32 type) { shaderType = type; } + void setNLightMaps(uint32 n) { nlightmaps = n; } - void setAlphaTest( bool b ) + void setAlphaTest(bool b) { - if( b ) + if (b) features |= AlphaTest; else features &= ~AlphaTest; } - void setAlphaTestThreshold( float t ){ alphaTestTreshold = t; } + void setAlphaTestThreshold(float t) { alphaTestTreshold = t; } - void setFog( bool b ) + void setFog(bool b) { - if( b ) + if (b) features |= Fog; else features &= ~Fog; @@ -207,19 +207,19 @@ namespace NL3D bool fogEnabled() const { - if( ( features & Fog ) != 0 ) + if ((features & Fog) != 0) return true; else return false; } - void setFogMode( TFogMode mode ){ fogMode = mode; } + void setFogMode(TFogMode mode) { fogMode = mode; } uint32 getFogMode() const{ return fogMode; } - void setLighting( bool b ) + void setLighting(bool b) { - if( b ) + if (b) features |= Lighting; else features &= ~Lighting; @@ -227,24 +227,24 @@ namespace NL3D bool lightingEnabled() const { - if( ( features & Lighting ) != 0 ) + if ((features & Lighting) != 0) return true; else return false; } - void setLight( int idx, TLightMode mode ) + void setLight(int idx, TLightMode mode) { lightMode[ idx ] = mode; - if( mode == Point ) + if (mode == Point) pointLight = true; } - TLightMode getLight( int idx ) const{ return lightMode[ idx ]; } + TLightMode getLight(int idx) const{ return lightMode[ idx ]; } bool hasPointLight() const{ return pointLight; } - void setShaders( SShaderPair sp ){ shaderPair = sp; } + void setShaders(SShaderPair sp) { shaderPair = sp; } SShaderPair getShaders() const{ return shaderPair; } private: diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_states.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_states.cpp index 34521c370..10dc2908f 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_states.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_states.cpp @@ -58,11 +58,11 @@ void CDriverGLStates3::init(bool supportTextureCubeMap, bool supportTextureRec _ColorArrayEnabled= false; _SecondaryColorArrayEnabled= false; uint i; - for(i=0; i=_MaxDriverLight) + if (num>=_MaxDriverLight) return; // If different from current setup, update. bool enabled= (enable!=0); #ifndef NL3D_GLSTATE_DISABLE_CACHE - if( enabled != _CurLight[num] ) + if (enabled != _CurLight[num]) #endif { // new state. @@ -286,7 +286,7 @@ void CDriverGLStates3::enableLight(uint num, uint enable) bool CDriverGLStates3::isLightEnabled(uint num) const { H_AUTO_OGL(CDriverGLStates3_isLightEnabled) - if(num>=_MaxDriverLight) + if (num>=_MaxDriverLight) return false; else return _CurLight[num]; @@ -300,13 +300,13 @@ void CDriverGLStates3::enableZWrite(uint enable) // If different from current setup, update. bool enabled= (enable!=0); #ifndef NL3D_GLSTATE_DISABLE_CACHE - if( enabled != _CurZWrite ) + if (enabled != _CurZWrite) #endif { // new state. _CurZWrite= enabled; // Setup GLState. - if(_CurZWrite) + if (_CurZWrite) glDepthMask(GL_TRUE); else glDepthMask(GL_FALSE); @@ -321,13 +321,13 @@ void CDriverGLStates3::enableStencilTest(bool enable) // If different from current setup, update. #ifndef NL3D_GLSTATE_DISABLE_CACHE - if( enable != _CurStencilTest ) + if (enable != _CurStencilTest) #endif { // new state. _CurStencilTest= enable; // Setup GLState. - if(_CurStencilTest) + if (_CurStencilTest) glEnable(GL_STENCIL_TEST); else glDisable(GL_STENCIL_TEST); @@ -341,14 +341,14 @@ void CDriverGLStates3::enableMultisample(bool enable) // If different from current setup, update. #ifndef NL3D_GLSTATE_DISABLE_CACHE - if( enable != _CurMultisample ) + if (enable != _CurMultisample) #endif { // new state. _CurMultisample= enable; // Setup GLState. - if(_CurMultisample) + if (_CurMultisample) glEnable(GL_MULTISAMPLE_ARB); else glDisable(GL_MULTISAMPLE_ARB); @@ -361,7 +361,7 @@ void CDriverGLStates3::blendFunc(GLenum src, GLenum dst) H_AUTO_OGL(CDriverGLStates3_blendFunc) // If different from current setup, update. #ifndef NL3D_GLSTATE_DISABLE_CACHE - if( src!= _CurBlendSrc || dst!=_CurBlendDst ) + if (src!= _CurBlendSrc || dst!=_CurBlendDst) #endif { // new state. @@ -378,7 +378,7 @@ void CDriverGLStates3::depthFunc(GLenum zcomp) H_AUTO_OGL(CDriverGLStates3_depthFunc) // If different from current setup, update. #ifndef NL3D_GLSTATE_DISABLE_CACHE - if( zcomp != _CurDepthFunc ) + if (zcomp != _CurDepthFunc) #endif { // new state. @@ -394,7 +394,7 @@ void CDriverGLStates3::alphaFunc(float threshold) { H_AUTO_OGL(CDriverGLStates3_alphaFunc) #ifndef NL3D_GLSTATE_DISABLE_CACHE - if(threshold != _CurAlphaTestThreshold) + if (threshold != _CurAlphaTestThreshold) #endif { // new state @@ -408,7 +408,7 @@ void CDriverGLStates3::stencilFunc(GLenum func, GLint ref, GLuint mask) { H_AUTO_OGL(CDriverGLStates3_stencilFunc) #ifndef NL3D_GLSTATE_DISABLE_CACHE - if((func!=_CurStencilFunc) || (ref!=_CurStencilRef) || (mask!=_CurStencilMask)) + if ((func!=_CurStencilFunc) || (ref!=_CurStencilRef) || (mask!=_CurStencilMask)) #endif { // new state @@ -427,7 +427,7 @@ void CDriverGLStates3::stencilOp(GLenum fail, GLenum zfail, GLenum zpass) { H_AUTO_OGL(CDriverGLStates3_stencilOp) #ifndef NL3D_GLSTATE_DISABLE_CACHE - if((fail!=_CurStencilOpFail) || (zfail!=_CurStencilOpZFail) || (zpass!=_CurStencilOpZPass)) + if ((fail!=_CurStencilOpFail) || (zfail!=_CurStencilOpZFail) || (zpass!=_CurStencilOpZPass)) #endif { // new state @@ -445,7 +445,7 @@ void CDriverGLStates3::stencilMask(GLuint mask) { H_AUTO_OGL(CDriverGLStates3_stencilMask) #ifndef NL3D_GLSTATE_DISABLE_CACHE - if(mask!=_CurStencilWriteMask) + if (mask!=_CurStencilWriteMask) #endif { // new state @@ -462,7 +462,7 @@ void CDriverGLStates3::setEmissive(uint32 packedColor, const GLfloat color[4]) { H_AUTO_OGL(CDriverGLStates3_setEmissive) #ifndef NL3D_GLSTATE_DISABLE_CACHE - if( packedColor!=_CurEmissive ) + if (packedColor!=_CurEmissive) #endif { _CurEmissive= packedColor; @@ -474,7 +474,7 @@ void CDriverGLStates3::setAmbient(uint32 packedColor, const GLfloat color[4]) { H_AUTO_OGL(CDriverGLStates3_setAmbient) #ifndef NL3D_GLSTATE_DISABLE_CACHE - if( packedColor!=_CurAmbient ) + if (packedColor!=_CurAmbient) #endif { _CurAmbient= packedColor; @@ -486,7 +486,7 @@ void CDriverGLStates3::setDiffuse(uint32 packedColor, const GLfloat color[4]) { H_AUTO_OGL(CDriverGLStates3_setDiffuse) #ifndef NL3D_GLSTATE_DISABLE_CACHE - if( packedColor!=_CurDiffuse ) + if (packedColor!=_CurDiffuse) #endif { _CurDiffuse= packedColor; @@ -498,7 +498,7 @@ void CDriverGLStates3::setSpecular(uint32 packedColor, const GLfloat color[4]) { H_AUTO_OGL(CDriverGLStates3_setSpecular) #ifndef NL3D_GLSTATE_DISABLE_CACHE - if( packedColor!=_CurSpecular ) + if (packedColor!=_CurSpecular) #endif { _CurSpecular= packedColor; @@ -510,7 +510,7 @@ void CDriverGLStates3::setShininess(float shin) { H_AUTO_OGL(CDriverGLStates3_setShininess) #ifndef NL3D_GLSTATE_DISABLE_CACHE - if( shin != _CurShininess ) + if (shin != _CurShininess) #endif { _CurShininess= shin; @@ -534,7 +534,7 @@ void CDriverGLStates3::setVertexColorLighted(bool enable) { H_AUTO_OGL(CDriverGLStates3_setVertexColorLighted) #ifndef NL3D_GLSTATE_DISABLE_CACHE - if( enable != _VertexColorLighted) + if (enable != _VertexColorLighted) #endif { _VertexColorLighted= enable; @@ -609,7 +609,7 @@ void CDriverGLStates3::setTextureMode(TTextureMode texMode) { H_AUTO_OGL(CDriverGLStates3_setTextureMode) TTextureMode oldTexMode = _TextureMode[_CurrentActiveTextureARB]; - if(oldTexMode != texMode) + if (oldTexMode != texMode) { // new mode. @@ -623,7 +623,7 @@ void CDriverGLStates3::activeTextureARB(uint stage) { H_AUTO_OGL(CDriverGLStates3_activeTextureARB); - if( _CurrentActiveTextureARB != stage ) + if (_CurrentActiveTextureARB != stage) { nglActiveTextureARB(GL_TEXTURE0_ARB+stage); @@ -647,10 +647,10 @@ void CDriverGLStates3::enableVertexAttribArrayARB(uint glIndex,bool enable) H_AUTO_OGL(CDriverGLStates3_enableVertexAttribArrayARB); #ifndef NL3D_GLSTATE_DISABLE_CACHE - if(_VertexAttribArrayEnabled[glIndex] != enable) + if (_VertexAttribArrayEnabled[glIndex] != enable) #endif { - if( enable ) + if (enable) nglEnableVertexAttribArray(glIndex); else nglDisableVertexAttribArray(glIndex); @@ -667,7 +667,7 @@ void CDriverGLStates3::enableFog(uint enable) // If different from current setup, update. bool enabled= (enable!=0); #ifndef NL3D_GLSTATE_DISABLE_CACHE - if( enabled != _CurFog ) + if (enabled != _CurFog) #endif { // new state. diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_texture.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_texture.cpp index 5aa76d97a..708734ad2 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_texture.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_texture.cpp @@ -85,13 +85,13 @@ CTextureDrvInfosGL3::~CTextureDrvInfosGL3() // release in TextureUsed. _Driver->_TextureUsed.erase (this); - if(InitFBO) + if (InitFBO) { nglDeleteFramebuffersEXT(1, &FBOId); - if(AttachDepthStencil) + if (AttachDepthStencil) { nglDeleteRenderbuffersEXT(1, &DepthFBOId); - if(!UsePackedDepthStencil) + if (!UsePackedDepthStencil) nglDeleteRenderbuffersEXT(1, &StencilFBOId); } } @@ -100,19 +100,19 @@ CTextureDrvInfosGL3::~CTextureDrvInfosGL3() // *************************************************************************** bool CTextureDrvInfosGL3::initFrameBufferObject(ITexture * tex) { - if(!InitFBO) + if (!InitFBO) { - if(tex->isBloomTexture()) + if (tex->isBloomTexture()) { AttachDepthStencil = !((CTextureBloom*)tex)->isMode2D(); } // generate IDs nglGenFramebuffersEXT(1, &FBOId); - if(AttachDepthStencil) + if (AttachDepthStencil) { nglGenRenderbuffersEXT(1, &DepthFBOId); - if(UsePackedDepthStencil) + if (UsePackedDepthStencil) StencilFBOId = DepthFBOId; else nglGenRenderbuffersEXT(1, &StencilFBOId); @@ -130,9 +130,9 @@ bool CTextureDrvInfosGL3::initFrameBufferObject(ITexture * tex) // opengl.org extension registry). Until a safe approach to add // them is found, there will be no attached stencil for the time // being, aside of using packed depth+stencil buffers. - if(AttachDepthStencil) + if (AttachDepthStencil) { - if(UsePackedDepthStencil) + if (UsePackedDepthStencil) { //nldebug("3D: using packed depth stencil"); nglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, StencilFBOId); @@ -264,7 +264,7 @@ bool CTextureDrvInfosGL3::initFrameBufferObject(ITexture * tex) { nglDeleteRenderbuffersEXT(1, &DepthFBOId); - if(!UsePackedDepthStencil) + if (!UsePackedDepthStencil) nglDeleteRenderbuffersEXT(1, &StencilFBOId); } } @@ -277,9 +277,9 @@ bool CTextureDrvInfosGL3::initFrameBufferObject(ITexture * tex) // *************************************************************************** bool CTextureDrvInfosGL3::activeFrameBufferObject(ITexture * tex) { - if(tex) + if (tex) { - if(initFrameBufferObject(tex)) + if (initFrameBufferObject(tex)) { glBindTexture(TextureMode, 0); nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBOId); @@ -313,12 +313,12 @@ GLint CDriverGL3::getGlTextureFormat(ITexture& tex, bool &compressed) ITexture::TUploadFormat texfmt= tex.getUploadFormat(); // If auto, retrieve the pixel format of the bitmap. - if(texfmt== ITexture::Auto) + if (texfmt== ITexture::Auto) { switch(tex.getPixelFormat()) { case CBitmap::RGBA: - if(_ForceDXTCCompression && tex.allowDegradation() ) + if (_ForceDXTCCompression && tex.allowDegradation()) texfmt= ITexture::DXTC5; else texfmt= ITexture::RGBA8888; @@ -336,7 +336,7 @@ GLint CDriverGL3::getGlTextureFormat(ITexture& tex, bool &compressed) } // Get gl tex format, try S3TC compressed ones. - if(_Extensions.EXTTextureCompressionS3TC) + if (_Extensions.EXTTextureCompressionS3TC) { compressed= true; // Try Compressed ones. @@ -402,7 +402,7 @@ static GLint getGlSrcTextureFormat(ITexture &tex, GLint glfmt) } } - if( glfmt == GL_RG8 ) + if (glfmt == GL_RG8) return GL_RG; // Else, not a Src format for upload, or RGBA. @@ -410,11 +410,11 @@ static GLint getGlSrcTextureFormat(ITexture &tex, GLint glfmt) } // *************************************************************************** -static GLenum getGlSrcTextureComponentType( ITexture &tex, GLint texSrcFormat) +static GLenum getGlSrcTextureComponentType(ITexture &tex, GLint texSrcFormat) { H_AUTO_OGL(getGlSrcTextureComponentType); - if( tex.getPixelFormat() == CBitmap::DsDt ) + if (tex.getPixelFormat() == CBitmap::DsDt) return GL_BYTE; return GL_UNSIGNED_BYTE; @@ -495,7 +495,7 @@ uint CDriverGL3::computeMipMapMemoryUsage(uint w, uint h, GLint glfmt) const static inline GLenum translateWrapToGl(ITexture::TWrapMode mode, const CGlExtensions &extensions) { H_AUTO_OGL(translateWrapToGl) - if(mode== ITexture::Repeat) + if (mode== ITexture::Repeat) return GL_REPEAT; return GL_CLAMP_TO_EDGE; @@ -529,7 +529,7 @@ static inline GLenum translateMinFilterToGl(CTextureDrvInfosGL3 *glText) return GL_NEAREST; #else // NEL_FORCE_NEAREST - if(glText->MipMap) + if (glText->MipMap) { switch(glText->MinFilter) { @@ -569,22 +569,22 @@ static inline bool sameDXTCFormat(ITexture &tex, GLint glfmt) H_AUTO_OGL(sameDXTCFormat); #ifdef GL_COMPRESSED_RGB_S3TC_DXT1_EXT - if(glfmt==GL_COMPRESSED_RGB_S3TC_DXT1_EXT && tex.PixelFormat==CBitmap::DXTC1) + if (glfmt==GL_COMPRESSED_RGB_S3TC_DXT1_EXT && tex.PixelFormat==CBitmap::DXTC1) return true; #endif #ifdef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT - if(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT && tex.PixelFormat==CBitmap::DXTC1Alpha) + if (glfmt==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT && tex.PixelFormat==CBitmap::DXTC1Alpha) return true; #endif #ifdef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT - if(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT3_EXT && tex.PixelFormat==CBitmap::DXTC3) + if (glfmt==GL_COMPRESSED_RGBA_S3TC_DXT3_EXT && tex.PixelFormat==CBitmap::DXTC3) return true; #endif #ifdef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT - if(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT5_EXT && tex.PixelFormat==CBitmap::DXTC5) + if (glfmt==GL_COMPRESSED_RGBA_S3TC_DXT5_EXT && tex.PixelFormat==CBitmap::DXTC5) return true; #endif @@ -597,22 +597,22 @@ static inline bool isDXTCFormat(GLint glfmt) H_AUTO_OGL(isDXTCFormat); #ifdef GL_COMPRESSED_RGB_S3TC_DXT1_EXT - if(glfmt==GL_COMPRESSED_RGB_S3TC_DXT1_EXT) + if (glfmt==GL_COMPRESSED_RGB_S3TC_DXT1_EXT) return true; #endif #ifdef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT - if(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) + if (glfmt==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) return true; #endif #ifdef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT - if(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) + if (glfmt==GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) return true; #endif #ifdef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT - if(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) + if (glfmt==GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) return true; #endif @@ -637,7 +637,7 @@ void CDriverGL3::bindTextureWithMode(ITexture &tex) gltext= getTextureGl(tex); // system of "backup the previous binded texture" seems to not work with some drivers.... _DriverGLStates.activeTextureARB(0); - if(tex.isTextureCube()) + if (tex.isTextureCube()) { if (_Extensions.ARBTextureCubeMap) { @@ -650,7 +650,7 @@ void CDriverGL3::bindTextureWithMode(ITexture &tex) { CDriverGLStates3::TTextureMode textureMode= CDriverGLStates3::Texture2D; - if(gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV) + if (gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV) textureMode = CDriverGLStates3::TextureRect; _DriverGLStates.setTextureMode(textureMode); @@ -673,7 +673,7 @@ void CDriverGL3::setupTextureBasicParameters(ITexture &tex) gltext->WrapT= tex.getWrapT(); gltext->MagFilter= tex.getMagFilter(); gltext->MinFilter= tex.getMinFilter(); - if(tex.isTextureCube()) + if (tex.isTextureCube()) { if (_Extensions.ARBTextureCubeMap) { @@ -708,13 +708,13 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded //nldebug("3D: CDriverGL3::setupTextureEx(%016p, %d, %d, %d)", &tex, bUpload, bAllUploaded, bMustRecreateSharedTexture); bAllUploaded = false; - if(tex.isTextureCube() && (!_Extensions.ARBTextureCubeMap)) + if (tex.isTextureCube() && (!_Extensions.ARBTextureCubeMap)) return true; // 0. Create/Retrieve the driver texture. //======================================= bool mustCreate = false; - if ( !tex.TextureDrvShare ) + if (!tex.TextureDrvShare) { //nldebug("3D: creating CTextureDrvShare()"); // insert into driver list. (so it is deleted when driver is deleted). @@ -727,7 +727,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded } // Does the texture has been touched ? - if ( (!tex.touched()) && (!mustCreate) ) + if ((!tex.touched()) && (!mustCreate)) { // if wrap mode or filter mode is touched, update it here if (tex.filterOrWrapModeTouched()) @@ -758,14 +758,14 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded But this is grave only if a new texture is created, with the same pointer (bad luck). Since an newly allocated texture always pass here before use, we are sure to avoid any problems. */ - for(uint stage = 0; stage < inlGetNumTextStages(); stage++) + for (uint stage = 0; stage < inlGetNumTextStages(); stage++) { activateTexture(stage, NULL); } // A. Share mgt. //============== - if(tex.supportSharing()) + if (tex.supportSharing()) { // Try to get the shared texture. @@ -782,7 +782,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded itTex= rTexDrvInfos.find(name); // texture not found? - if( itTex==rTexDrvInfos.end() ) + if (itTex==rTexDrvInfos.end()) { // insert into driver map. (so it is deleted when driver is deleted). itTex= (rTexDrvInfos.insert(make_pair(name, (ITextureDrvInfos*)NULL))).first; @@ -796,7 +796,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded { tex.TextureDrvShare->DrvTexture= itTex->second; - if(bMustRecreateSharedTexture) + if (bMustRecreateSharedTexture) // reload this shared texture (user request) mustLoadAll= true; else @@ -811,7 +811,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded else { // If texture not already created. - if(!tex.TextureDrvShare->DrvTexture) + if (!tex.TextureDrvShare->DrvTexture) { // Must create it. Create auto a GL id (in constructor). // Do not insert into the map. This un-shared texture will be deleted at deletion of the texture. @@ -821,15 +821,15 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded // need to load ALL this texture. mustLoadAll= true; } - else if(tex.isAllInvalidated()) + else if (tex.isAllInvalidated()) mustLoadAll= true; - else if(tex.touched()) + else if (tex.touched()) mustLoadPart= true; } // B. Setup texture. //================== - if(mustLoadAll || mustLoadPart) + if (mustLoadAll || mustLoadPart) { // system of "backup the previous binded texture" seems to not work with some drivers.... bindTextureWithMode(tex); @@ -848,30 +848,30 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded gltext->TextureMemory= 0; - if(tex.isTextureCube()) + if (tex.isTextureCube()) { CTextureCube *pTC = NLMISC::safe_cast(&tex); // Regenerate all the texture. tex.generate(); - for(uint nText = 0; nText < 6; ++nText) - if(pTC->getTexture((CTextureCube::TFace)nText) != NULL) + for (uint nText = 0; nText < 6; ++nText) + if (pTC->getTexture((CTextureCube::TFace)nText) != NULL) { ITexture *pTInTC = pTC->getTexture((CTextureCube::TFace)nText); // In open GL, we have to flip the faces of the cube map - if( ((CTextureCube::TFace)nText) == CTextureCube::positive_x ) + if (((CTextureCube::TFace)nText) == CTextureCube::positive_x) pTInTC->flipH(); - if( ((CTextureCube::TFace)nText) == CTextureCube::negative_x ) + if (((CTextureCube::TFace)nText) == CTextureCube::negative_x) pTInTC->flipH(); - if( ((CTextureCube::TFace)nText) == CTextureCube::positive_y ) + if (((CTextureCube::TFace)nText) == CTextureCube::positive_y) pTInTC->flipH(); - if( ((CTextureCube::TFace)nText) == CTextureCube::negative_y ) + if (((CTextureCube::TFace)nText) == CTextureCube::negative_y) pTInTC->flipH(); - if( ((CTextureCube::TFace)nText) == CTextureCube::positive_z ) + if (((CTextureCube::TFace)nText) == CTextureCube::positive_z) pTInTC->flipV(); - if( ((CTextureCube::TFace)nText) == CTextureCube::negative_z ) + if (((CTextureCube::TFace)nText) == CTextureCube::negative_z) pTInTC->flipV(); // Get the correct texture format from texture... @@ -880,9 +880,9 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded GLenum glSrcType= getGlSrcTextureComponentType(*pTInTC,glSrcFmt); sint nMipMaps; - if(glSrcFmt==GL_RGBA && pTInTC->getPixelFormat()!=CBitmap::RGBA ) + if (glSrcFmt==GL_RGBA && pTInTC->getPixelFormat()!=CBitmap::RGBA) pTInTC->convertToType(CBitmap::RGBA); - if(tex.mipMapOn()) + if (tex.mipMapOn()) { pTInTC->buildMipMaps(); nMipMaps= pTInTC->getMipMapCount(); @@ -894,7 +894,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded gltext->MipMap= nMipMaps>1; // Fill mipmaps. - for(sint i=0;igetPixels(i).getPtr(); uint w= pTInTC->getWidth(i); @@ -922,7 +922,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded // Regenerate all the texture. tex.generate(); - if(tex.getSize()>0) + if (tex.getSize()>0) { // Get the correct texture format from texture... GLint glfmt= getGlTextureFormat(tex, gltext->Compressed); @@ -931,11 +931,11 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded // DXTC: if same format, and same mipmapOn/Off, use glTexCompressedImage*. // We cannot build the mipmaps if they are not here. - if(_Extensions.EXTTextureCompressionS3TC && sameDXTCFormat(tex, glfmt)) + if (_Extensions.EXTTextureCompressionS3TC && sameDXTCFormat(tex, glfmt)) { sint nMipMaps = 1; - if(tex.mipMapOn()) + if (tex.mipMapOn()) nMipMaps= tex.getMipMapCount(); // MipMap upload? @@ -944,13 +944,13 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded // Degradation in Size allowed only if DXTC texture are provided with mipmaps. // Because use them to resize !!! uint decalMipMapResize= 0; - if(_ForceTextureResizePower>0 && tex.allowDegradation() && nMipMaps>1) + if (_ForceTextureResizePower>0 && tex.allowDegradation() && nMipMaps>1) { decalMipMapResize= min(_ForceTextureResizePower, (uint)(nMipMaps-1)); } // Fill mipmaps. - for(sint i=decalMipMapResize;i0 && tex.allowDegradation()) + if (_ForceTextureResizePower>0 && tex.allowDegradation()) { uint w= tex.getWidth(0) >> _ForceTextureResizePower; uint h= tex.getHeight(0) >> _ForceTextureResizePower; @@ -994,7 +994,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded tex.resample(w, h); } - if(tex.mipMapOn()) + if (tex.mipMapOn()) { tex.buildMipMaps(); nMipMaps= tex.getMipMapCount(); @@ -1006,7 +1006,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded gltext->MipMap= nMipMaps>1; // Fill mipmaps. - for(sint i=0;i0) + if (tex.getSize()>0) { // Get the correct texture format from texture... //=============================================== @@ -1054,15 +1054,15 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded GLenum glSrcType= getGlSrcTextureComponentType(tex,glSrcFmt); sint nMipMaps; - if(glSrcFmt==GL_RGBA && tex.getPixelFormat()!=CBitmap::RGBA ) + if (glSrcFmt==GL_RGBA && tex.getPixelFormat()!=CBitmap::RGBA) tex.convertToType(CBitmap::RGBA); - if(tex.mipMapOn()) + if (tex.mipMapOn()) { bool hadMipMap= tex.getMipMapCount()>1; tex.buildMipMaps(); nMipMaps= tex.getMipMapCount(); // If the texture had no mipmap before, release them. - if(!hadMipMap) + if (!hadMipMap) { tex.releaseMipMaps(); } @@ -1073,7 +1073,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded // For all rect, update the texture/mipmap. //=============================================== list::iterator itRect; - for(itRect=tex._ListInvalidRect.begin(); itRect!=tex._ListInvalidRect.end(); itRect++) + for (itRect=tex._ListInvalidRect.begin(); itRect!=tex._ListInvalidRect.end(); itRect++) { CRect &rect= *itRect; sint x0= rect.X; @@ -1082,7 +1082,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded sint y1= rect.Y+rect.Height; // Fill mipmaps. - for(sint i=0;iTextureMode == GL_TEXTURE_RECTANGLE_NV) + if (gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV) textureMode = CDriverGLStates3::TextureRect; _DriverGLStates.setTextureMode (textureMode); @@ -1229,7 +1229,7 @@ bool CDriverGL3::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap) { nglCompressedTexSubImage2DARB ( GL_TEXTURE_2D, nNumMipMap-decalMipMapResize, - x0, y0, (x1-x0), (y1-y0), glfmt, imageSize, ptr ); + x0, y0, (x1-x0), (y1-y0), glfmt, imageSize, ptr); } else { @@ -1287,7 +1287,7 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex) if (this->_CurrentTexture[stage]!=tex) { _DriverGLStates.activeTextureARB(stage); - if(tex && tex->TextureDrvShare) + if (tex && tex->TextureDrvShare) { // get the drv info. should be not NULL. CTextureDrvInfosGL3* gltext; @@ -1301,18 +1301,18 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex) _TextureUsed.insert (gltext); } - if(tex->isTextureCube()) + if (tex->isTextureCube()) { // setup texture mode, after activeTextureARB() _DriverGLStates.setTextureMode(CDriverGLStates3::TextureCubeMap); - if(_Extensions.ARBTextureCubeMap) + if (_Extensions.ARBTextureCubeMap) { // Activate texturing... //====================== // If the shared texture is the same than before, no op. - if(_CurrentTextureInfoGL[stage] != gltext) + if (_CurrentTextureInfoGL[stage] != gltext) { // Cache setup. _CurrentTextureInfoGL[stage]= gltext; @@ -1322,12 +1322,12 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex) // Change parameters of texture, if necessary. //============================================ - if(gltext->MagFilter!= tex->getMagFilter()) + if (gltext->MagFilter!= tex->getMagFilter()) { gltext->MagFilter= tex->getMagFilter(); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext)); } - if(gltext->MinFilter!= tex->getMinFilter()) + if (gltext->MinFilter!= tex->getMinFilter()) { gltext->MinFilter= tex->getMinFilter(); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext)); @@ -1339,7 +1339,7 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex) { // setup texture mode, after activeTextureARB() CDriverGLStates3::TTextureMode textureMode= CDriverGLStates3::Texture2D; - if(gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV) + if (gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV) textureMode = CDriverGLStates3::TextureRect; _DriverGLStates.setTextureMode(/*CDriverGLStates3::Texture2D*/textureMode); @@ -1347,7 +1347,7 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex) //====================== // If the shared texture is the same than before, no op. - if(_CurrentTextureInfoGL[stage] != gltext) + if (_CurrentTextureInfoGL[stage] != gltext) { // Cache setup. _CurrentTextureInfoGL[stage]= gltext; @@ -1358,22 +1358,22 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex) // Change parameters of texture, if necessary. //============================================ - if(gltext->WrapS!= tex->getWrapS()) + if (gltext->WrapS!= tex->getWrapS()) { gltext->WrapS= tex->getWrapS(); glTexParameteri(gltext->TextureMode,GL_TEXTURE_WRAP_S, translateWrapToGl(gltext->WrapS, _Extensions)); } - if(gltext->WrapT!= tex->getWrapT()) + if (gltext->WrapT!= tex->getWrapT()) { gltext->WrapT= tex->getWrapT(); glTexParameteri(gltext->TextureMode,GL_TEXTURE_WRAP_T, translateWrapToGl(gltext->WrapT, _Extensions)); } - if(gltext->MagFilter!= tex->getMagFilter()) + if (gltext->MagFilter!= tex->getMagFilter()) { gltext->MagFilter= tex->getMagFilter(); glTexParameteri(gltext->TextureMode,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext)); } - if(gltext->MinFilter!= tex->getMinFilter()) + if (gltext->MinFilter!= tex->getMinFilter()) { gltext->MinFilter= tex->getMinFilter(); glTexParameteri(gltext->TextureMode,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext)); @@ -1440,7 +1440,7 @@ void CDriverGL3::activateTexEnvMode(uint stage, const CMaterial::CTexEnv &env) H_AUTO_OGL(CDriverGL3_activateTexEnvMode) // If a special Texture environnement is setuped, or if not the same normal texture environnement, // must setup a new normal Texture environnement. - if(_CurrentTexEnvSpecial[stage] != TexEnvSpecialDisabled || _CurrentTexEnv[stage].EnvPacked!= env.EnvPacked) + if (_CurrentTexEnvSpecial[stage] != TexEnvSpecialDisabled || _CurrentTexEnv[stage].EnvPacked!= env.EnvPacked) { forceActivateTexEnvMode(stage, env); } @@ -1451,7 +1451,7 @@ void CDriverGL3::activateTexEnvMode(uint stage, const CMaterial::CTexEnv &env) void CDriverGL3::activateTexEnvColor(uint stage, const CMaterial::CTexEnv &env) { H_AUTO_OGL(CDriverGL3_activateTexEnvColor) - if(_CurrentTexEnv[stage].ConstantColor!= env.ConstantColor) + if (_CurrentTexEnv[stage].ConstantColor!= env.ConstantColor) { forceActivateTexEnvColor(stage, env); } @@ -1504,7 +1504,7 @@ void CDriverGL3::swapTextureHandle(ITexture &tex0, ITexture &tex1) setupTexture(tex1); // avoid any problem, disable all textures - for(uint stage = 0; stage < inlGetNumTextStages(); stage++) + for (uint stage = 0; stage < inlGetNumTextStages(); stage++) { activateTexture(stage, NULL); } @@ -1539,12 +1539,12 @@ uint CDriverGL3::getTextureHandle(const ITexture &tex) { H_AUTO_OGL(CDriverGL3_getTextureHandle) // If DrvShare not setuped - if(!tex.TextureDrvShare) + if (!tex.TextureDrvShare) return 0; // If DrvInfo not setuped const CTextureDrvInfosGL3 *t0= (const CTextureDrvInfosGL3*)(const ITextureDrvInfos*)(tex.TextureDrvShare->DrvTexture); - if(!t0) + if (!t0) return 0; return t0->ID; @@ -1562,7 +1562,7 @@ uint CDriverGL3::getTextureHandle(const ITexture &tex) bool CDriverGL3::setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 width, uint32 height, uint32 mipmapLevel, uint32 cubeFace) { - H_AUTO_OGL(CDriverGL3_setRenderTarget ) + H_AUTO_OGL(CDriverGL3_setRenderTarget) // make backup of offscreen buffer to old texture if not using FBOs if (!_RenderTargetFBO && _TextureTarget && _TextureTargetUpload && (_TextureTarget != tex || _TextureTargetCubeFace != cubeFace)) @@ -1578,7 +1578,7 @@ bool CDriverGL3::setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 widt // Check the texture is a render target nlassertex (tex->getRenderTarget(), ("The texture must be a render target. Call ITexture::setRenderTarget(true).")); - if(tex->isBloomTexture() && supportBloomEffect()) + if (tex->isBloomTexture() && supportBloomEffect()) { uint32 w, h; getWindowSize(w, h); diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_vertex.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_vertex.cpp index 19dc12ef6..fedd5c5fa 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_vertex.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_vertex.cpp @@ -103,15 +103,15 @@ bool CDriverGL3::setupVertexBuffer(CVertexBuffer& VB) // 2. If necessary, do modifications. //================================== const bool touched = (VB.getTouchFlags() & (CVertexBuffer::TouchedReserve|CVertexBuffer::TouchedVertexFormat)) != 0; - if( touched || (VB.DrvInfos == NULL)) + if (touched || (VB.DrvInfos == NULL)) { // delete first - if(VB.DrvInfos) + if (VB.DrvInfos) delete VB.DrvInfos; VB.DrvInfos = NULL; // create only if some vertices - if(VB.getNumVertices()) + if (VB.getNumVertices()) { // 1. Retrieve/Create driver shader. //================================== @@ -125,7 +125,7 @@ bool CDriverGL3::setupVertexBuffer(CVertexBuffer& VB) CVertexBuffer::TPreferredMemory preferred = VB.getPreferredMemory (); if ((preferred == CVertexBuffer::RAMVolatile) || (preferred == CVertexBuffer::AGPVolatile) || - (preferred == CVertexBuffer::RAMPreferred ) ) + (preferred == CVertexBuffer::RAMPreferred)) preferred = CVertexBuffer::AGPPreferred; const uint size = VB.capacity()*VB.getVertexSize(); @@ -173,7 +173,7 @@ bool CDriverGL3::activeVertexBuffer(CVertexBuffer& VB) if (info->_VBHard == NULL) { // Disable the current vertexBufferHard if setuped. - if(_CurrentVertexBufferHard) + if (_CurrentVertexBufferHard) _CurrentVertexBufferHard->disable(); } else @@ -252,7 +252,7 @@ IVertexBufferHardGL *CDriverGL3::createVertexBufferHard(uint size, uint numVerti } // If this one at least created (an extension support it). - if( !vertexArrayRange ) + if (!vertexArrayRange) return NULL; else { @@ -261,7 +261,7 @@ IVertexBufferHardGL *CDriverGL3::createVertexBufferHard(uint size, uint numVerti // let the VAR create the vbhard. vbHard= vertexArrayRange->createVBHardGL(size, vb); // if fails - if(!vbHard) + if (!vbHard) { return NULL; } @@ -404,7 +404,7 @@ void CDriverGL3::setupGlArrays(CVertexBufferInfo &vb) { mustNormalize = ARBVertexProgramMustNormalizeAttrib[value]; } - nglVertexAttribPointer( glIndex, NumCoordinatesType[type], GLType[ type ], mustNormalize, vb.VertexSize, vb.ValuePtr[value] ); + nglVertexAttribPointer(glIndex, NumCoordinatesType[type], GLType[ type ], mustNormalize, vb.VertexSize, vb.ValuePtr[value]); } else { @@ -461,7 +461,7 @@ void CVertexBufferInfo::setupVertexBuffer(CVertexBuffer &vb) void CDriverGL3::resetVertexArrayRange() { H_AUTO_OGL(CDriverGL3_resetVertexArrayRange) - if(_CurrentVertexBufferHard) + if (_CurrentVertexBufferHard) { // Must ensure it has ended any drawing _CurrentVertexBufferHard->lock(); @@ -480,7 +480,7 @@ bool CDriverGL3::initVertexBufferHard(uint agpMem, uint vramMem) H_AUTO_OGL(CDriverGL3_initVertexBufferHard) // must be supported - if(!_AGPVertexArrayRange || !_VRAMVertexArrayRange) + if (!_AGPVertexArrayRange || !_VRAMVertexArrayRange) return false; // First, reset any VBHard created. diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_vertex_buffer_hard.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_vertex_buffer_hard.cpp index 6b807c5ed..72a64f8da 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_vertex_buffer_hard.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_vertex_buffer_hard.cpp @@ -111,7 +111,7 @@ IVertexBufferHardGL *CVertexArrayRange::createVBHardGL(uint size, CVertexBuffer void CVertexArrayRange::enable() { H_AUTO_OGL(CVertexArrayRangeARB_enable) - if(_Driver->_CurrentVertexArrayRange != this) + if (_Driver->_CurrentVertexArrayRange != this) { _Driver->_CurrentVertexArrayRange= this; } @@ -121,7 +121,7 @@ void CVertexArrayRange::enable() void CVertexArrayRange::disable() { H_AUTO_OGL(CVertexArrayRangeARB_disbale) - if(_Driver->_CurrentVertexBufferHard != NULL) + if (_Driver->_CurrentVertexBufferHard != NULL) { _Driver->_CurrentVertexBufferHard= NULL; } @@ -136,7 +136,7 @@ void CVertexArrayRange::updateLostBuffers() nlassert(_Driver); if (_Driver->isWndActive()) { - for(std::list::iterator it = _LostVBList.begin(); it != _LostVBList.end(); ++it) + for (std::list::iterator it = _LostVBList.begin(); it != _LostVBList.end(); ++it) { nlassert((*it)->_VertexObjectId); GLuint id = (GLuint) (*it)->_VertexObjectId; @@ -261,7 +261,7 @@ void *CVertexBufferHard::lock() // continue to standard mapping code below .. } TTicks beforeLock = 0; - if(_Driver->_VBHardProfiling) + if (_Driver->_VBHardProfiling) { beforeLock= CTime::getPerformanceTime(); } @@ -283,7 +283,7 @@ void *CVertexBufferHard::lock() #endif _Driver->_DriverGLStates.forceBindARBVertexBuffer(0); // Lock Profile? - if(_Driver->_VBHardProfiling) + if (_Driver->_VBHardProfiling) { TTicks afterLock; afterLock= CTime::getPerformanceTime(); @@ -301,7 +301,7 @@ void CVertexBufferHard::unlock() if (_Invalid) return; if (!_VertexObjectId) return; TTicks beforeLock = 0; - if(_Driver->_VBHardProfiling) + if (_Driver->_VBHardProfiling) { beforeLock= CTime::getPerformanceTime(); } @@ -318,7 +318,7 @@ void CVertexBufferHard::unlock() _Unmapping = false; #endif // Lock Profile? - if(_Driver->_VBHardProfiling) + if (_Driver->_VBHardProfiling) { TTicks afterLock; afterLock= CTime::getPerformanceTime(); @@ -354,7 +354,7 @@ void CVertexBufferHard::unlock(uint /* startVert */,uint /* endVert */) void CVertexBufferHard::enable() { H_AUTO_OGL(CVertexBufferHardARB_enable) - if(_Driver->_CurrentVertexBufferHard != this) + if (_Driver->_CurrentVertexBufferHard != this) { /* nlassert(_VertexArrayRange); _VertexArrayRange->enable(); */ @@ -366,7 +366,7 @@ void CVertexBufferHard::enable() void CVertexBufferHard::disable() { H_AUTO_OGL(CVertexBufferHardARB_disable) - if(_Driver->_CurrentVertexBufferHard != NULL) + if (_Driver->_CurrentVertexBufferHard != NULL) { /* nlassert(_VertexArrayRange); _VertexArrayRange->disable(); */ @@ -418,7 +418,7 @@ void CVertexBufferHard::invalidate() { nlwarning("*****************************************************"); nlwarning("Mapped buffers :"); - for(std::list::iterator it = _MappedVBList.begin(); it != _MappedVBList.end(); ++it) + for (std::list::iterator it = _MappedVBList.begin(); it != _MappedVBList.end(); ++it) { CVertexBufferHard &vbarb = **it; nlwarning("Buffer id = %u, size = %u, address = %p", vbarb._VertexObjectId, vbarb.VB->getVertexSize() * vbarb.VB->getNumVertices(), vbarb.getPointer()); diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_window.cpp index 17266a8e8..d4c323d9c 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_window.cpp @@ -61,7 +61,7 @@ bool GlWndProc(CDriverGL3 *driver, HWND hWnd, UINT message, WPARAM wParam, LPARA if (!driver) return false; - if(message == WM_SIZE) + if (message == WM_SIZE) { if (driver->_CurrentMode.Windowed) { @@ -73,7 +73,7 @@ bool GlWndProc(CDriverGL3 *driver, HWND hWnd, UINT message, WPARAM wParam, LPARA driver->_CurrentMode.Height = (uint16)(rect.bottom-rect.top); } } - else if(message == WM_MOVE) + else if (message == WM_MOVE) { if (driver->_CurrentMode.Windowed) { @@ -151,7 +151,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l // disable menu (default ALT-F4 behavior is disabled) if (message == WM_CLOSE) { - if(pDriver && pDriver->ExitFunc) + if (pDriver && pDriver->ExitFunc) { pDriver->ExitFunc(); } @@ -174,7 +174,7 @@ bool GlWndProc(CDriverGL3 *driver, const void* e) { H_AUTO_OGL(GlWndProc) - if(!driver) + if (!driver) return false; NSEvent* event = [NSEvent eventWithEventRef:e]; @@ -214,7 +214,7 @@ bool GlWndProc(CDriverGL3 *driver, XEvent &e) { case DestroyNotify: - if(driver && driver->ExitFunc) + if (driver && driver->ExitFunc) { driver->ExitFunc(); } @@ -316,7 +316,7 @@ bool CDriverGL3::init (uint windowIcon, emptyProc exitFunc) wc.hbrBackground = WHITE_BRUSH; wc.lpszClassName = L"NLClass"; wc.lpszMenuName = NULL; - if ( !RegisterClassW(&wc) ) + if (!RegisterClassW(&wc)) { return false; } @@ -402,11 +402,11 @@ bool CDriverGL3::init (uint windowIcon, emptyProc exitFunc) sint nextensions = 0; char **extensions = XListExtensions(_dpy, &nextensions); - for(sint i = 0; i < nextensions; ++i) + for (sint i = 0; i < nextensions; ++i) { - if(i%5==0) DebugLog->displayRaw("3D: "); + if (i%5==0) DebugLog->displayRaw("3D: "); DebugLog->displayRaw(NLMISC::toString("%s ", extensions[i]).c_str()); - if(i%5==4) DebugLog->displayRaw("\n"); + if (i%5==4) DebugLog->displayRaw("\n"); } DebugLog->displayRaw("\n"); @@ -524,7 +524,7 @@ void CDriverGL3::setWindowIcon(const std::vector &bitmaps) uint bigHeight = GetSystemMetrics(SM_CYICON); // find icons with the exact size - for(uint i = 0; i < bitmaps.size(); ++i) + for (uint i = 0; i < bitmaps.size(); ++i) { if (smallIndex == -1 && bitmaps[i].getWidth() == smallWidth && bitmaps[i].getHeight() == smallHeight) smallIndex = i; @@ -534,7 +534,7 @@ void CDriverGL3::setWindowIcon(const std::vector &bitmaps) } // find icons with taller size (we will resize them) - for(uint i = 0; i < bitmaps.size(); ++i) + for (uint i = 0; i < bitmaps.size(); ++i) { if (smallIndex == -1 && bitmaps[i].getWidth() >= smallWidth && bitmaps[i].getHeight() >= smallHeight) smallIndex = i; @@ -571,7 +571,7 @@ void CDriverGL3::setWindowIcon(const std::vector &bitmaps) if (!bitmaps.empty()) { // process each bitmap - for(uint i = 0; i < bitmaps.size(); ++i) + for (uint i = 0; i < bitmaps.size(); ++i) { convertBitmapToIcon(bitmaps[i], icon_data); } @@ -626,7 +626,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r RECT rc; SetRect (&rc, 0, 0, width, height); AdjustWindowRectEx (&rc, GetWindowStyle (_win), GetMenu (_win) != NULL, GetWindowExStyle (_win)); - SetWindowPos (_win, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); + SetWindowPos (_win, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); // Get the HDC tempHDC = GetDC(tmpHWND); @@ -642,7 +642,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r _pfd.cColorBits = _CurrentMode.Depth; // Choose best suited Depth Buffer. - if(_CurrentMode.Depth<=16) + if (_CurrentMode.Depth<=16) { _pfd.cDepthBits = 16; } @@ -659,7 +659,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r DestroyWindow (tmpHWND); return false; } - if ( !SetPixelFormat(tempHDC,pf,&_pfd) ) + if (!SetPixelFormat(tempHDC,pf,&_pfd)) { nlwarning ("CDriverGL3::setDisplay: SetPixelFormat failed"); DestroyWindow (tmpHWND); @@ -719,7 +719,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r // Attribute arrays must be "0" terminated - for simplicity, first // just zero-out the array then fill from left to right. - for ( int a = 0; a < 2*20; a++ ) + for (int a = 0; a < 2*20; a++) { iattributes[a] = 0; fattributes[a] = 0; @@ -754,10 +754,10 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r // requirements. int pformat[20]; unsigned int nformats; - if ( !nwglChoosePixelFormatARB ( hdc, iattributes, fattributes, - 20, pformat, &nformats ) ) + if (!nwglChoosePixelFormatARB (hdc, iattributes, fattributes, + 20, pformat, &nformats)) { - nlwarning ( "pbuffer creation error: Couldn't find a suitable pixel format." ); + nlwarning ("pbuffer creation error: Couldn't find a suitable pixel format."); wglDeleteContext (tempGLRC); DestroyWindow (tmpHWND); return false; @@ -768,7 +768,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r returned in the list in step #2 and call the function: */ int iattributes2[1] = {0}; // int iattributes2[] = {WGL_PBUFFER_LARGEST_ARB, 1, 0}; - _PBuffer = nwglCreatePbufferARB( hdc, pformat[0], width, height, iattributes2 ); + _PBuffer = nwglCreatePbufferARB(hdc, pformat[0], width, height, iattributes2); if (_PBuffer == NULL) { DWORD error = GetLastError (); @@ -784,7 +784,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r } /* After creating a pbuffer, you may use this functions to determine the dimensions of the pbuffer actually created. */ - if ( !nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width ) ) + if (!nwglQueryPbufferARB(_PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width)) { DWORD error = GetLastError (); nlwarning ("CDriverGL3::setDisplay: wglQueryPbufferARB failed: 0x%x", error); @@ -797,7 +797,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r return false; } - if ( !nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height ) ) + if (!nwglQueryPbufferARB(_PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height)) { DWORD error = GetLastError (); nlwarning ("CDriverGL3::setDisplay: wglQueryPbufferARB failed: 0x%x", error); @@ -815,12 +815,12 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r /* The next step is to create a device context for the newly created pbuffer. To do this, call to the function: */ - _hDC = nwglGetPbufferDCARB( _PBuffer ); + _hDC = nwglGetPbufferDCARB(_PBuffer); if (_hDC == NULL) { DWORD error = GetLastError (); nlwarning ("CDriverGL3::setDisplay: wglGetPbufferDCARB failed: 0x%x", error); - nwglDestroyPbufferARB( _PBuffer ); + nwglDestroyPbufferARB(_PBuffer); wglDeleteContext (tempGLRC); @@ -834,13 +834,13 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r /* The final step of pbuffer creation is to create an OpenGL rendering context and associate it with the handle for the pbuffer's device context created in step #4. This is done as follows */ - _hRC = wglCreateContext( _hDC ); + _hRC = wglCreateContext(_hDC); if (_hRC == NULL) { DWORD error = GetLastError (); nlwarning ("CDriverGL3::setDisplay: wglCreateContext failed: 0x%x", error); - nwglReleasePbufferDCARB( _PBuffer, _hDC ); - nwglDestroyPbufferARB( _PBuffer ); + nwglReleasePbufferDCARB(_PBuffer, _hDC); + nwglDestroyPbufferARB(_PBuffer); wglDeleteContext (tempGLRC); DestroyWindow (tmpHWND); _PBuffer = NULL; @@ -873,8 +873,8 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r nlwarning ("CDriverGL3::setDisplay: wglMakeCurrent failed: 0x%x", error); wglDeleteContext (_hRC); - nwglReleasePbufferDCARB( _PBuffer, _hDC ); - nwglDestroyPbufferARB( _PBuffer ); + nwglReleasePbufferDCARB(_PBuffer, _hDC); + nwglDestroyPbufferARB(_PBuffer); DestroyWindow (tmpHWND); _PBuffer = NULL; @@ -951,7 +951,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r * (http://dev.ryzom.com/issues/1013) */ NSView* view = (NSView*)wnd; - if(view.frame.origin.x != 0 || view.frame.origin.y != 0) { + if (view.frame.origin.x != 0 || view.frame.origin.y != 0) { [view setBoundsOrigin:view.frame.origin]; } } @@ -974,7 +974,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes:att]; - if(!format) + if (!format) nlerror("cannot create NSOpenGLPixelFormat"); // intially set height/width, further updates through CocoaOpenGLView @@ -986,7 +986,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r initWithFrame:NSMakeRect(0, 0, mode.Width, mode.Height) pixelFormat:format]; - if(!_glView) + if (!_glView) nlerror("cannot create view"); // tell the view about the driver so the view is able to update "window" size @@ -1004,7 +1004,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r // create a opengl context for the view _ctx = [_glView openGLContext]; - if(!_ctx) + if (!_ctx) nlerror("cannot create context"); // free the pixel format object @@ -1051,7 +1051,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r XVisualInfo *visual_info = glXChooseVisual (_dpy, DefaultScreen(_dpy), sAttribList24bpp); if (visual_info == NULL) visual_info = glXChooseVisual(_dpy, DefaultScreen(_dpy), sAttribList16bpp); - if(visual_info == NULL) + if (visual_info == NULL) { nlerror("glXChooseVisual() failed"); } @@ -1297,13 +1297,13 @@ bool CDriverGL3::setScreenMode(const GfxMode &mode) devMode.dmPelsWidth = mode.Width; devMode.dmPelsHeight = mode.Height; - if(mode.Depth > 0) + if (mode.Depth > 0) { devMode.dmBitsPerPel = mode.Depth; devMode.dmFields |= DM_BITSPERPEL; } - if(mode.Frequency > 0) + if (mode.Frequency > 0) { devMode.dmDisplayFrequency = mode.Frequency; devMode.dmFields |= DM_DISPLAYFREQUENCY; @@ -1447,7 +1447,7 @@ bool CDriverGL3::createWindow(const GfxMode &mode) initWithContentRect:NSMakeRect(0, 0, mode.Width, mode.Height) styleMask:styleMask backing:NSBackingStoreBuffered defer:NO]; - if(!cocoa_window) + if (!cocoa_window) { nlerror("cannot create cocoa window"); return false; @@ -1490,7 +1490,7 @@ bool CDriverGL3::createWindow(const GfxMode &mode) [cocoa_window setContentView: (NSView*)window]; - if(window == EmptyWindow) + if (window == EmptyWindow) { nldebug("cannot create cocoa view for cocoa window"); return false; @@ -1716,14 +1716,14 @@ bool CDriverGL3::setWindowStyle(EWindowStyle windowStyle) #elif defined(NL_OS_MAC) // leave fullscreen mode, enter windowed mode - if(windowStyle == EWSWindowed && [containerView() isInFullScreenMode]) + if (windowStyle == EWSWindowed && [containerView() isInFullScreenMode]) { // disable manual setting of back buffer size, cocoa handles this // automatically as soon as the view gets resized CGLError error = CGLDisable((CGLContextObj)[_ctx CGLContextObj], kCGLCESurfaceBackingSize); - if(error != kCGLNoError) + if (error != kCGLNoError) nlerror("cannot disable kCGLCESurfaceBackingSize (%s)", CGLErrorString(error)); @@ -1738,13 +1738,13 @@ bool CDriverGL3::setWindowStyle(EWindowStyle windowStyle) } // enter fullscreen, leave windowed mode - else if(windowStyle == EWSFullscreen && ![containerView() isInFullScreenMode]) + else if (windowStyle == EWSFullscreen && ![containerView() isInFullScreenMode]) { // enable manual back buffer size for mode setting in fullscreen CGLError error = CGLEnable((CGLContextObj)[_ctx CGLContextObj], kCGLCESurfaceBackingSize); - if(error != kCGLNoError) + if (error != kCGLNoError) nlerror("cannot enable kCGLCESurfaceBackingSize (%s)", CGLErrorString(error)); @@ -1859,11 +1859,11 @@ static int bppFromDisplayMode(CGDisplayModeRef mode) { CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding(mode); - if(CFStringCompare(pixelEncoding, CFSTR(IO32BitDirectPixels), + if (CFStringCompare(pixelEncoding, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) return 32; - else if(CFStringCompare(pixelEncoding, CFSTR(IO16BitDirectPixels), + else if (CFStringCompare(pixelEncoding, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) return 16; @@ -1900,7 +1900,7 @@ bool CDriverGL3::getModes(std::vector &modes) while (EnumDisplaySettings (NULL, modeIndex, &devMode)) { // Keep only 16 and 32 bits - if ((devMode.dmBitsPerPel == 16 ) || (devMode.dmBitsPerPel == 32)) + if ((devMode.dmBitsPerPel == 16) || (devMode.dmBitsPerPel == 32)) { // Add this mode GfxMode mode; @@ -1922,7 +1922,7 @@ bool CDriverGL3::getModes(std::vector &modes) CGDisplayCount numDisplays; CGDisplayErr err = CGGetActiveDisplayList(kMaxDisplays, display, &numDisplays); - if(err != CGDisplayNoErr) + if (err != CGDisplayNoErr) { nlwarning("Cannot get displays (%d)", err); return false; @@ -2100,7 +2100,7 @@ bool CDriverGL3::getCurrentScreenMode(GfxMode &mode) mode.Depth = NSBitsPerPixelFromDepth([screen depth]); // in fullscreen mode - if([containerView() isInFullScreenMode]) + if ([containerView() isInFullScreenMode]) { // return the size of the back buffer (like having switched monitor mode) mode.Windowed = false; @@ -2352,7 +2352,7 @@ bool CDriverGL3::createContext() _pfd.iPixelType = PFD_TYPE_RGBA; _pfd.cColorBits = _CurrentMode.Depth; // Choose best suited Depth Buffer. - if(_CurrentMode.Depth <= 16) + if (_CurrentMode.Depth <= 16) { _pfd.cDepthBits = 16; } @@ -2369,7 +2369,7 @@ bool CDriverGL3::createContext() return false; } - if ( !SetPixelFormat(_hDC,pf,&_pfd) ) + if (!SetPixelFormat(_hDC,pf,&_pfd)) { return false; } @@ -2398,7 +2398,7 @@ bool CDriverGL3::activate() #elif defined(NL_OS_MAC) - if([NSOpenGLContext currentContext] != _ctx) + if ([NSOpenGLContext currentContext] != _ctx) [_ctx makeCurrentContext]; #elif defined (NL_OS_UNIX) @@ -2466,15 +2466,15 @@ void CDriverGL3::getWindowSize(uint32 &width, uint32 &height) if (_PBuffer) { - nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width ); - nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height ); + nwglQueryPbufferARB(_PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width); + nwglQueryPbufferARB(_PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height); } #endif } else { #ifdef NL_OS_MAC - if([containerView() isInFullScreenMode]) + if ([containerView() isInFullScreenMode]) { width = _backBufferWidth; height = _backBufferHeight; @@ -2517,7 +2517,7 @@ void CDriverGL3::setWindowSize(uint32 width, uint32 height) #elif defined(NL_OS_MAC) // for fullscreen mode, adjust the back buffer size to desired resolution - if([containerView() isInFullScreenMode]) + if ([containerView() isInFullScreenMode]) { // disable and re-enable fullscreen // fixes #1062 (http://dev.ryzom.com/issues/1062) @@ -2530,7 +2530,7 @@ void CDriverGL3::setWindowSize(uint32 width, uint32 height) (CGLContextObj)[_ctx CGLContextObj], kCGLCPSurfaceBackingSize, dim); - if(error != kCGLNoError) + if (error != kCGLNoError) nlerror("cannot set kCGLCPSurfaceBackingSize parameter (%s)", CGLErrorString(error)); @@ -2540,7 +2540,7 @@ void CDriverGL3::setWindowSize(uint32 width, uint32 height) else { // only change the window size if the driver created the window itself - if(_DestroyWindow) + if (_DestroyWindow) { // get the windows current frame NSRect rect = [[containerView() window] frame]; @@ -2635,7 +2635,7 @@ bool CDriverGL3::isActive() // *************************************************************************** bool CDriverGL3::setMonitorColorProperties (const CMonitorColorProperties &properties) { - H_AUTO_OGL(CDriverGL3_setMonitorColorProperties ) + H_AUTO_OGL(CDriverGL3_setMonitorColorProperties) #ifdef NL_OS_WINDOWS @@ -2648,19 +2648,19 @@ bool CDriverGL3::setMonitorColorProperties (const CMonitorColorProperties &prope // For each composant uint c; - for( c=0; c<3; c++ ) + for (c=0; c<3; c++) { uint i; - for( i=0; i<256; i++ ) + for (i=0; i<256; i++) { // Floating value float value = (float)i / 256; // Contrast - value = (float) max (0.0f, (value-0.5f) * (float) pow (3.f, properties.Contrast[c]) + 0.5f ); + value = (float) max (0.0f, (value-0.5f) * (float) pow (3.f, properties.Contrast[c]) + 0.5f); // Gamma - value = (float) pow (value, (properties.Gamma[c]>0) ? 1 - 3 * properties.Gamma[c] / 4 : 1 - properties.Gamma[c] ); + value = (float) pow (value, (properties.Gamma[c]>0) ? 1 - 3 * properties.Gamma[c] / 4 : 1 - properties.Gamma[c]); // Luminosity value = value + properties.Luminosity[c] / 2.f; @@ -2864,7 +2864,7 @@ bool CDriverGL3::convertBitmapToIcon(const NLMISC::CBitmap &bitmap, std::vector< // convert RGBA to ARGB CObjectVector pixels = bitmap.getPixels(); - for(uint j = 0; j < pixels.size(); j+=4) + for (uint j = 0; j < pixels.size(); j+=4) icon[pos++] = pixels[j] << 16 | pixels[j+1] << 8 | pixels[j+2] | pixels[j+3] << 24; return true; diff --git a/code/nel/src/3d/driver/opengl3/unix_event_emitter.cpp b/code/nel/src/3d/driver/opengl3/unix_event_emitter.cpp index 475b58d57..32d4c79cc 100644 --- a/code/nel/src/3d/driver/opengl3/unix_event_emitter.cpp +++ b/code/nel/src/3d/driver/opengl3/unix_event_emitter.cpp @@ -161,7 +161,7 @@ void CUnixEventEmitter::emulateMouseRawMode(bool enable) { _emulateRawMode = enable; - if(_emulateRawMode) + if (_emulateRawMode) { XWindowAttributes xwa; XGetWindowAttributes(_dpy, _win, &xwa); @@ -172,7 +172,7 @@ void CUnixEventEmitter::emulateMouseRawMode(bool enable) // was pulled back to 0.5 / 0.5, so a wrong movement delta would be // reported otherwise XEvent event; - while(XCheckIfEvent(_dpy, &event, &isMouseMoveEvent, NULL)) { }; + while (XCheckIfEvent(_dpy, &event, &isMouseMoveEvent, NULL)) { }; } } @@ -512,10 +512,10 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) TMouseButton button=getMouseButton (event.xbutton.state); // if raw mode should be emulated - if(_emulateRawMode) + if (_emulateRawMode) { // when we just wrapped back the pointer to 0.5 / 0.5, ignore event - if(event.xbutton.x == xwa.width / 2 && event.xbutton.y == xwa.height / 2) + if (event.xbutton.x == xwa.width / 2 && event.xbutton.y == xwa.height / 2) break; // post a CGDMouseMove with the movement delta to the event server @@ -573,7 +573,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) if (keyCode) { TKey key = getKeyFromKeySym(k); - if(key == KeyNOKEY) + if (key == KeyNOKEY) key = getKeyFromKeycode(keyCode); // search for key in map @@ -591,7 +591,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) } Text[c] = '\0'; - if(c>0) + if (c>0) { #ifdef X_HAVE_UTF8_STRING ucstring ucstr; @@ -626,7 +626,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) int c = XLookupString(&event.xkey, NULL, 0, &k, NULL); TKey key = getKeyFromKeySym(k); - if(key == KeyNOKEY) + if (key == KeyNOKEY) key = getKeyFromKeycode(event.xkey.keycode); server->postEvent (new CEventKeyUp (key, getKeyButton(event.xbutton.state), this)); @@ -719,7 +719,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) for (uint i=0; i < nitems; i++) { // nlwarning(" - Type=%s (%u)", XGetAtomName(_dpy, supportedTargets[i]), (uint)supportedTargets[i]); - if (supportedTargets[i] == XA_UTF8_STRING ) + if (supportedTargets[i] == XA_UTF8_STRING) { if (bestTargetElect < 2) { @@ -727,7 +727,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) bestTargetElect = 2; } } - else if (supportedTargets[i] == XA_STRING ) + else if (supportedTargets[i] == XA_STRING) { if (bestTargetElect < 1) { diff --git a/code/nel/src/3d/driver/opengl3/unix_event_emitter.h b/code/nel/src/3d/driver/opengl3/unix_event_emitter.h index 362ed2086..05fef1339 100644 --- a/code/nel/src/3d/driver/opengl3/unix_event_emitter.h +++ b/code/nel/src/3d/driver/opengl3/unix_event_emitter.h @@ -52,7 +52,7 @@ public: /** * sends all events to server - * (should call CEventServer method postEvent() ) + * (should call CEventServer method postEvent()) */ virtual void submitEvents(CEventServer & server, bool allWindows);