Browse Source

Merge branch 'master' into compatibility

Conflicts:
	src/Magnum/Shader.cpp
Vladimír Vondruš 12 years ago
parent
commit
0bda17e843
  1. 11
      src/Magnum/Mesh.h
  2. 2
      src/Magnum/Platform/Sdl2Application.cpp
  3. 12
      src/Magnum/Shader.cpp
  4. 4
      src/Magnum/Shaders/magnumShadersResourceImport.hpp
  5. 57
      src/MagnumPlugins/ObjImporter/ObjImporter.cpp

11
src/Magnum/Mesh.h

@ -489,7 +489,6 @@ class MAGNUM_EXPORT Mesh: public AbstractObject {
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* Default is @ref MeshPrimitive::Triangles. * Default is @ref MeshPrimitive::Triangles.
* @see @ref setCount()
*/ */
Mesh& setPrimitive(MeshPrimitive primitive) { Mesh& setPrimitive(MeshPrimitive primitive) {
_primitive = primitive; _primitive = primitive;
@ -506,7 +505,7 @@ class MAGNUM_EXPORT Mesh: public AbstractObject {
* If the mesh is indexed, the value is treated as index count, * If the mesh is indexed, the value is treated as index count,
* otherwise the value is vertex count. If set to `0`, no draw commands * otherwise the value is vertex count. If set to `0`, no draw commands
* are issued when calling @ref draw(). Default is `0`. * are issued when calling @ref draw(). Default is `0`.
* @see @ref isIndexed() * @see @ref isIndexed(), @ref setBaseVertex(), @ref setInstanceCount()
*/ */
Mesh& setCount(Int count) { Mesh& setCount(Int count) {
_count = count; _count = count;
@ -522,6 +521,7 @@ class MAGNUM_EXPORT Mesh: public AbstractObject {
* *
* Sets number of vertices of which the vertex buffer will be offset * Sets number of vertices of which the vertex buffer will be offset
* when drawing. Default is `0`. * when drawing. Default is `0`.
* @see @ref setCount(), @ref setBaseInstance()
* @requires_gl32 %Extension @extension{ARB,draw_elements_base_vertex} * @requires_gl32 %Extension @extension{ARB,draw_elements_base_vertex}
* for indexed meshes * for indexed meshes
* @requires_gl Base vertex cannot be specified for indexed meshes in * @requires_gl Base vertex cannot be specified for indexed meshes in
@ -575,6 +575,8 @@ class MAGNUM_EXPORT Mesh: public AbstractObject {
* If set to `1`, non-instanced draw commands are issued when calling * If set to `1`, non-instanced draw commands are issued when calling
* @ref draw(). If set to `0`, no draw commands are issued altogether. * @ref draw(). If set to `0`, no draw commands are issued altogether.
* Default is `1`. * Default is `1`.
* @see @ref setBaseInstance(), @ref setCount(),
* @ref addVertexBufferInstanced()
* @requires_gl31 %Extension @extension{ARB,draw_instanced} * @requires_gl31 %Extension @extension{ARB,draw_instanced}
* @requires_gles30 %Extension @es_extension{ANGLE,instanced_arrays}, * @requires_gles30 %Extension @es_extension{ANGLE,instanced_arrays},
* @es_extension2{EXT,draw_instanced,draw_instanced} or * @es_extension2{EXT,draw_instanced,draw_instanced} or
@ -594,6 +596,7 @@ class MAGNUM_EXPORT Mesh: public AbstractObject {
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* Default is `0`. * Default is `0`.
* @see @ref setInstanceCount(), @ref setBaseVertex()
* @requires_gl42 %Extension @extension{ARB,base_instance} * @requires_gl42 %Extension @extension{ARB,base_instance}
* @requires_gl Base instance cannot be specified in OpenGL ES. * @requires_gl Base instance cannot be specified in OpenGL ES.
*/ */
@ -660,8 +663,8 @@ class MAGNUM_EXPORT Mesh: public AbstractObject {
* must be at most 255 bytes. This is not required anywhere else, * must be at most 255 bytes. This is not required anywhere else,
* but doing so may have performance benefits. * but doing so may have performance benefits.
* *
* @see @ref maxVertexAttributes(), @ref setPrimitive(), * @see @ref addVertexBufferInstanced(), @ref maxVertexAttributes(),
* @ref setCount(), @fn_gl{BindVertexArray}, * @ref setPrimitive(), @ref setCount(), @fn_gl{BindVertexArray},
* @fn_gl{EnableVertexAttribArray}, @fn_gl{BindBuffer}, * @fn_gl{EnableVertexAttribArray}, @fn_gl{BindBuffer},
* @fn_gl{VertexAttribPointer} or * @fn_gl{VertexAttribPointer} or
* @fn_gl_extension{EnableVertexArrayAttrib,EXT,direct_state_access}, * @fn_gl_extension{EnableVertexArrayAttrib,EXT,direct_state_access},

2
src/Magnum/Platform/Sdl2Application.cpp

@ -189,7 +189,7 @@ bool Sdl2Application::tryCreateContext(const Configuration& configuration) {
if(!(window = SDL_CreateWindow(configuration.title().data(), if(!(window = SDL_CreateWindow(configuration.title().data(),
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
configuration.size().x(), configuration.size().y(), configuration.size().x(), configuration.size().y(),
SDL_WINDOW_OPENGL|flags))) SDL_WINDOW_OPENGL|windowFlags)))
{ {
Error() << "Platform::Sdl2Application::tryCreateContext(): cannot create window:" << SDL_GetError(); Error() << "Platform::Sdl2Application::tryCreateContext(): cannot create window:" << SDL_GetError();
return false; return false;

12
src/Magnum/Shader.cpp

@ -688,12 +688,12 @@ bool Shader::compile(std::initializer_list<std::reference_wrapper<Shader>> shade
if(shaders.size() != 1) { if(shaders.size() != 1) {
#if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) && !defined(__MINGW32__) #if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) && !defined(__MINGW32__)
#ifndef CORRADE_GCC44_COMPATIBILITY #ifndef CORRADE_GCC44_COMPATIBILITY
out << ' ' << std::to_string(i); out << " " << std::to_string(i);
#else #else
out << ' ' << std::to_string(static_cast<long long int>(i)); out << " " << std::to_string(static_cast<long long int>(i));
#endif #endif
#else #else
out << ' ' << converter.str(); out << " " << converter.str();
#endif #endif
} }
out << " failed with the following message:\n" out << " failed with the following message:\n"
@ -709,12 +709,12 @@ bool Shader::compile(std::initializer_list<std::reference_wrapper<Shader>> shade
if(shaders.size() != 1) { if(shaders.size() != 1) {
#if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) && !defined(__MINGW32__) #if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) && !defined(__MINGW32__)
#ifndef CORRADE_GCC44_COMPATIBILITY #ifndef CORRADE_GCC44_COMPATIBILITY
out << ' ' << std::to_string(i); out << " " << std::to_string(i);
#else #else
out << ' ' << std::to_string(static_cast<long long int>(i)); out << " " << std::to_string(static_cast<long long int>(i));
#endif #endif
#else #else
out << ' ' << converter.str(); out << " " << converter.str();
#endif #endif
} }
out << " succeeded with the following message:\n" out << " succeeded with the following message:\n"

4
src/Magnum/Shaders/magnumShadersResourceImport.hpp

@ -29,9 +29,9 @@
#ifdef MAGNUM_BUILD_STATIC #ifdef MAGNUM_BUILD_STATIC
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
#include "Magnum/Shaders/resourceImport.h" #include "Magnum/Shaders/resourceImport.hpp"
#else #else
#error use Magnum/Shaders/resourceImport.h instead #error use Magnum/Shaders/resourceImport.hpp instead
#endif #endif
#else #else
#error this header is available only in static build #error this header is available only in static build

57
src/MagnumPlugins/ObjImporter/ObjImporter.cpp

@ -32,11 +32,15 @@
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Utility/String.h> #include <Corrade/Utility/String.h>
#include "Magnum/Mesh.h"
#include "Magnum/MeshTools/CombineIndexedArrays.h"
#include "Magnum/MeshTools/Duplicate.h"
#include "Magnum/Math/Vector3.h" #include "Magnum/Math/Vector3.h"
#include "Magnum/Trade/MeshData3D.h" #include "Magnum/Trade/MeshData3D.h"
#include <Magnum/Mesh.h>
#include <Magnum/MeshTools/CombineIndexedArrays.h> #ifdef CORRADE_TARGET_NACL_NEWLIB
#include <Magnum/MeshTools/Duplicate.h> #include <sstream>
#endif
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {
@ -61,10 +65,28 @@ template<std::size_t size> Math::Vector<size, Float> extractFloatData(std::strin
} }
Math::Vector<size, Float> output; Math::Vector<size, Float> output;
for(std::size_t i = 0; i != size; ++i)
#ifdef CORRADE_TARGET_NACL_NEWLIB
std::istringstream in;
#endif
for(std::size_t i = 0; i != size; ++i) {
#ifndef CORRADE_TARGET_NACL_NEWLIB
output[i] = std::stof(data[i]); output[i] = std::stof(data[i]);
#else
in.str(data[i]);
in >> output[i];
#endif
}
if(data.size() == size+1) *extra = std::stof(data.back()); if(data.size() == size+1) {
#ifndef CORRADE_TARGET_NACL_NEWLIB
*extra = std::stof(data.back());
#else
in.str(data.back());
in >> *extra;
#endif
}
return output; return output;
} }
@ -359,15 +381,36 @@ std::optional<MeshData3D> ObjImporter::doMesh3D(UnsignedInt id) {
} }
/* Position indices */ /* Position indices */
#ifndef CORRADE_TARGET_NACL_NEWLIB
positionIndices.push_back(std::stoul(indices[0]) - positionIndexOffset); positionIndices.push_back(std::stoul(indices[0]) - positionIndexOffset);
#else
std::istringstream in(indices[0]);
UnsignedInt index;
in >> index;
positionIndices.push_back(index - positionIndexOffset);
#endif
/* Texture coordinates */ /* Texture coordinates */
if(indices.size() == 2 || (indices.size() == 3 && !indices[1].empty())) if(indices.size() == 2 || (indices.size() == 3 && !indices[1].empty())) {
#ifndef CORRADE_TARGET_NACL_NEWLIB
textureCoordinateIndices.push_back(std::stoul(indices[1]) - textureCoordinateIndexOffset); textureCoordinateIndices.push_back(std::stoul(indices[1]) - textureCoordinateIndexOffset);
#else
in.str(indices[1]);
in >> index;
textureCoordinateIndices.push_back(index - textureCoordinateIndexOffset);
#endif
}
/* Normal indices */ /* Normal indices */
if(indices.size() == 3) if(indices.size() == 3) {
#ifndef CORRADE_TARGET_NACL_NEWLIB
normalIndices.push_back(std::stoul(indices[2]) - normalIndexOffset); normalIndices.push_back(std::stoul(indices[2]) - normalIndexOffset);
#else
in.str(indices[2]);
in >> index;
normalIndices.push_back(index - normalIndexOffset);
#endif
}
} }
/* Ignore unsupported keywords, error out on unknown keywords */ /* Ignore unsupported keywords, error out on unknown keywords */

Loading…
Cancel
Save