Browse Source

Merge branch 'master' into compatibility

Vladimír Vondruš 14 years ago
parent
commit
bf9e800be0
  1. 2
      src/Math/Vector.h
  2. 15
      src/Physics/Implementation/BoxRenderer.cpp
  3. 2
      src/Physics/ShapedObjectGroup.h
  4. 3
      src/Shader.cpp
  5. 14
      src/Shaders/FlatShader.cpp

2
src/Math/Vector.h

@ -56,7 +56,7 @@ template<std::size_t size, class T> class Vector: public RectangularMatrix<1, si
* @brief Angle between normalized vectors * @brief Angle between normalized vectors
* *
* @f[ * @f[
* \phi = \frac{a \cdot b}{|a| \cdot |b|} * \phi = acos \left(\frac{a \cdot b}{|a| \cdot |b|} \right)
* @f] * @f]
* @attention Assertion fails on non-normalized vectors and NaN is * @attention Assertion fails on non-normalized vectors and NaN is
* returned. * returned.

15
src/Physics/Implementation/BoxRenderer.cpp

@ -28,8 +28,8 @@ namespace {
template<std::uint8_t> struct BoxMesh {}; template<std::uint8_t> struct BoxMesh {};
template<> struct BoxMesh<2> { template<> struct BoxMesh<2> {
constexpr static char shader[] = "shader2d"; constexpr static ResourceKey shader() { return {"shader2d"}; }
constexpr static char key[] = "box2d"; constexpr static ResourceKey key() { return {"box2d"}; }
static Mesh* mesh(Buffer* buffer) { static Mesh* mesh(Buffer* buffer) {
Primitives::Square square; Primitives::Square square;
@ -42,8 +42,8 @@ namespace {
}; };
template<> struct BoxMesh<3> { template<> struct BoxMesh<3> {
constexpr static char shader[] = "shader3d"; constexpr static ResourceKey shader() { return {"shader3d"}; }
constexpr static char key[] = "box3d"; constexpr static ResourceKey key() { return {"box3d"}; }
static Mesh* mesh(Buffer* buffer) { static Mesh* mesh(Buffer* buffer) {
Primitives::Cube cube; Primitives::Cube cube;
@ -56,12 +56,7 @@ namespace {
}; };
} }
constexpr char BoxMesh<2>::shader[]; template<std::uint8_t dimensions> BoxRenderer<dimensions>::BoxRenderer(Box<dimensions>& box, ResourceKey options, typename SceneGraph::AbstractObject<dimensions>::ObjectType* parent): AbstractDebugRenderer<dimensions>(BoxMesh<dimensions>::shader(), BoxMesh<dimensions>::key(), options, parent), buffer(DebugDrawResourceManager::instance()->get<Buffer>(BoxMesh<dimensions>::key())), box(box) {
constexpr char BoxMesh<2>::key[];
constexpr char BoxMesh<3>::shader[];
constexpr char BoxMesh<3>::key[];
template<std::uint8_t dimensions> BoxRenderer<dimensions>::BoxRenderer(Box<dimensions>& box, ResourceKey options, typename SceneGraph::AbstractObject<dimensions>::ObjectType* parent): AbstractDebugRenderer<dimensions>(BoxMesh<dimensions>::shader, BoxMesh<dimensions>::key, options, parent), buffer(DebugDrawResourceManager::instance()->get<Buffer>(BoxMesh<dimensions>::key)), box(box) {
if(!this->mesh) { if(!this->mesh) {
DebugDrawResourceManager::instance()->set(this->buffer.key(), new Buffer, ResourceDataState::Final, ResourcePolicy::Manual); DebugDrawResourceManager::instance()->set(this->buffer.key(), new Buffer, ResourceDataState::Final, ResourcePolicy::Manual);
DebugDrawResourceManager::instance()->set<Mesh>(this->mesh.key(), BoxMesh<dimensions>::mesh(buffer), ResourceDataState::Final, ResourcePolicy::Manual); DebugDrawResourceManager::instance()->set<Mesh>(this->mesh.key(), BoxMesh<dimensions>::mesh(buffer), ResourceDataState::Final, ResourcePolicy::Manual);

2
src/Physics/ShapedObjectGroup.h

@ -45,7 +45,7 @@ template<std::uint8_t dimensions> class PHYSICS_EXPORT ShapedObjectGroup {
* *
* Marks the group as dirty. * Marks the group as dirty.
*/ */
inline constexpr ShapedObjectGroup(): dirty(true) {} inline ShapedObjectGroup(): dirty(true) {}
/** /**
* @brief Destructor * @brief Destructor

3
src/Shader.cpp

@ -48,7 +48,8 @@ Shader::Shader(Version version, Type type): _type(type), _state(State::Initializ
case Version::GLES300: addSource("#version 300\n"); break; case Version::GLES300: addSource("#version 300\n"); break;
#endif #endif
default: break; default:
CORRADE_ASSERT(false, "Shader::Shader(): unsupported version" << GLint(version), );
} }
} }

14
src/Shaders/FlatShader.cpp

@ -26,13 +26,13 @@ namespace {
template<std::uint8_t dimensions> struct ShaderName {}; template<std::uint8_t dimensions> struct ShaderName {};
template<> struct ShaderName<2> { template<> struct ShaderName<2> {
constexpr static const char* Vertex = "FlatShader2D.vert"; constexpr static const char* vertex() { return "FlatShader2D.vert"; }
constexpr static const char* Fragment = "FlatShader2D.frag"; constexpr static const char* fragment() { return "FlatShader2D.frag"; }
}; };
template<> struct ShaderName<3> { template<> struct ShaderName<3> {
constexpr static const char* Vertex = "FlatShader3D.vert"; constexpr static const char* vertex() { return "FlatShader3D.vert"; }
constexpr static const char* Fragment = "FlatShader3D.frag"; constexpr static const char* fragment() { return "FlatShader3D.frag"; }
}; };
} }
@ -40,19 +40,19 @@ template<std::uint8_t dimensions> FlatShader<dimensions>::FlatShader() {
Corrade::Utility::Resource rs("MagnumShaders"); Corrade::Utility::Resource rs("MagnumShaders");
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
Version v = Context::current()->supportedVersion({/*Version::GL320, */Version::GL210}); Version v = Context::current()->supportedVersion({Version::GL320, Version::GL210});
#else #else
Version v = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); Version v = Context::current()->supportedVersion({Version::GLES300, Version::GLES200});
#endif #endif
Shader vertexShader(v, Shader::Type::Vertex); Shader vertexShader(v, Shader::Type::Vertex);
vertexShader.addSource(rs.get("compatibility.glsl")); vertexShader.addSource(rs.get("compatibility.glsl"));
vertexShader.addSource(rs.get(ShaderName<dimensions>::Vertex)); vertexShader.addSource(rs.get(ShaderName<dimensions>::vertex()));
attachShader(vertexShader); attachShader(vertexShader);
Shader fragmentShader(v, Shader::Type::Fragment); Shader fragmentShader(v, Shader::Type::Fragment);
fragmentShader.addSource(rs.get("compatibility.glsl")); fragmentShader.addSource(rs.get("compatibility.glsl"));
fragmentShader.addSource(rs.get(ShaderName<dimensions>::Fragment)); fragmentShader.addSource(rs.get(ShaderName<dimensions>::fragment()));
attachShader(fragmentShader); attachShader(fragmentShader);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES

Loading…
Cancel
Save