Browse Source

Merge branch 'master' into compatibility

Vladimír Vondruš 13 years ago
parent
commit
54cecb35ea
  1. 13
      src/Shaders/MeshVisualizer.cpp
  2. 15
      src/Shaders/MeshVisualizer.frag
  3. 2
      src/Shaders/MeshVisualizer.h
  4. 6
      src/Shaders/MeshVisualizer.vert
  5. 2
      src/Shaders/magnumShadersResourceImport.hpp
  6. 2
      src/TextureTools/magnumTextureToolsResourceImport.hpp

13
src/Shaders/MeshVisualizer.cpp

@ -36,6 +36,9 @@ MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationP
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(flags & Flag::Wireframe && !(flags & Flag::NoGeometryShader)) if(flags & Flag::Wireframe && !(flags & Flag::NoGeometryShader))
MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::geometry_shader4); MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::geometry_shader4);
#elif defined(MAGNUM_TARGET_GLES2)
if(flags & Flag::Wireframe)
MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::OES::standard_derivatives);
#endif #endif
Utility::Resource rs("MagnumShaders"); Utility::Resource rs("MagnumShaders");
@ -109,6 +112,16 @@ MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationP
viewportSizeUniform = uniformLocation("viewportSize"); viewportSizeUniform = uniformLocation("viewportSize");
} }
} }
/* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */
#ifdef MAGNUM_TARGET_GLES
setColor(Color3<>(1.0f));
if(flags & Flag::Wireframe) {
setWireframeColor(Color3<>(0.0f));
setWireframeWidth(1.0f);
setSmoothness(2.0f);
}
#endif
} }
}} }}

15
src/Shaders/MeshVisualizer.frag

@ -25,6 +25,7 @@
#ifndef NEW_GLSL #ifndef NEW_GLSL
#define in varying #define in varying
#define fragmentColor gl_FragColor #define fragmentColor gl_FragColor
#define const
#endif #endif
#ifndef EXPLICIT_UNIFORM_LOCATION #ifndef EXPLICIT_UNIFORM_LOCATION
@ -49,15 +50,17 @@ uniform lowp float smoothness;
#endif #endif
#ifndef NO_GEOMETRY_SHADER #ifndef NO_GEOMETRY_SHADER
noperspective in vec3 dist; noperspective in lowp vec3 dist;
#else #else
in vec3 barycentric; in lowp vec3 barycentric;
#endif #endif
#endif #endif
#ifdef NEW_GLSL
out vec4 fragmentColor; out vec4 fragmentColor;
#endif
#if defined(WIREFRAME_RENDERING) && defined(NO_GEOMETRY_SHADER) && defined(GL_ES) #if defined(WIREFRAME_RENDERING) && defined(GL_ES) && __VERSION__ < 300
#extension GL_OES_standard_derivatives : enable #extension GL_OES_standard_derivatives : enable
#endif #endif
@ -70,9 +73,9 @@ void main() {
/* Smooth step between face color and wireframe color based on distance */ /* Smooth step between face color and wireframe color based on distance */
fragmentColor = mix(wireframeColor, color, smoothstep(wireframeWidth-smoothness, wireframeWidth+smoothness, nearest)); fragmentColor = mix(wireframeColor, color, smoothstep(wireframeWidth-smoothness, wireframeWidth+smoothness, nearest));
#else #else
const vec3 d = fwidth(barycentric); const lowp vec3 d = fwidth(barycentric);
const vec3 factor = smoothstep(vec3(0.0), d*1.5, barycentric); const lowp vec3 factor = smoothstep(vec3(0.0), d*1.5, barycentric);
const float nearest = min(min(factor.x, factor.y), factor.z); const lowp float nearest = min(min(factor.x, factor.y), factor.z);
fragmentColor = mix(wireframeColor, color, nearest); fragmentColor = mix(wireframeColor, color, nearest);
#endif #endif

2
src/Shaders/MeshVisualizer.h

@ -110,7 +110,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
* @brief Constructor * @brief Constructor
* @param flags %Flags * @param flags %Flags
*/ */
explicit MeshVisualizer(Flags flags); explicit MeshVisualizer(Flags flags = Flags());
/** /**
* @brief Set transformation and projection matrix * @brief Set transformation and projection matrix

6
src/Shaders/MeshVisualizer.vert

@ -42,7 +42,7 @@ in highp vec4 position;
#if defined(WIREFRAME_RENDERING) && defined(NO_GEOMETRY_SHADER) #if defined(WIREFRAME_RENDERING) && defined(NO_GEOMETRY_SHADER)
#if (!defined(GL_ES) && __VERSION__ < 140) || (defined(GL_ES) && __VERSION__ < 300) #if (!defined(GL_ES) && __VERSION__ < 140) || (defined(GL_ES) && __VERSION__ < 300)
#ifdef EXPLICIT_ATTRIB_LOCATION #ifdef EXPLICIT_ATTRIB_LOCATION
layout(location = 1) highp in float vertexIndex; layout(location = 1) in lowp float vertexIndex;
#else #else
in lowp float vertexIndex; in lowp float vertexIndex;
#endif #endif
@ -57,6 +57,10 @@ void main() {
#if defined(WIREFRAME_RENDERING) && defined(NO_GEOMETRY_SHADER) #if defined(WIREFRAME_RENDERING) && defined(NO_GEOMETRY_SHADER)
barycentric = vec3(0.0); barycentric = vec3(0.0);
#ifndef NEW_GLSL
barycentric[int(mod(vertexIndex, 3.0))] = 1.0;
#else
barycentric[gl_VertexID % 3] = 1.0; barycentric[gl_VertexID % 3] = 1.0;
#endif #endif
#endif
} }

2
src/Shaders/magnumShadersResourceImport.hpp

@ -28,6 +28,8 @@
#ifdef MAGNUM_BUILD_STATIC #ifdef MAGNUM_BUILD_STATIC
#include <Utility/Resource.h> #include <Utility/Resource.h>
#include <Utility/utilities.h>
static int magnumShadersResourceImport() { static int magnumShadersResourceImport() {
CORRADE_RESOURCE_INITIALIZE(MagnumShaders_RCS) CORRADE_RESOURCE_INITIALIZE(MagnumShaders_RCS)
return 0; return 0;

2
src/TextureTools/magnumTextureToolsResourceImport.hpp

@ -28,6 +28,8 @@
#ifdef MAGNUM_BUILD_STATIC #ifdef MAGNUM_BUILD_STATIC
#include <Utility/Resource.h> #include <Utility/Resource.h>
#include <Utility/utilities.h>
static int magnumTextureToolsResourceImport() { static int magnumTextureToolsResourceImport() {
CORRADE_RESOURCE_INITIALIZE(MagnumTextureTools_RCS) CORRADE_RESOURCE_INITIALIZE(MagnumTextureTools_RCS)
return 0; return 0;

Loading…
Cancel
Save