Browse Source

Remove obsolete string/number Android workarounds.

pull/205/head
Vladimír Vondruš 8 years ago
parent
commit
e3b0fab79c
  1. 26
      src/Magnum/AbstractShaderProgram.cpp
  2. 18
      src/Magnum/DebugOutput.cpp
  3. 40
      src/Magnum/Shader.cpp
  4. 67
      src/MagnumPlugins/ObjImporter/ObjImporter.cpp

26
src/Magnum/AbstractShaderProgram.cpp

@ -38,10 +38,6 @@
#include "Implementation/ShaderProgramState.h"
#include "Implementation/State.h"
#ifdef CORRADE_TARGET_ANDROID
#include <sstream>
#endif
namespace Magnum {
namespace Implementation {
@ -419,36 +415,18 @@ bool AbstractShaderProgram::link(std::initializer_list<std::reference_wrapper<Ab
glGetProgramInfoLog(shader._id, message.size(), nullptr, &message[0]);
message.resize(std::max(logLength, 1)-1);
/** @todo Remove when this is fixed everywhere (also the include above) */
#ifdef CORRADE_TARGET_ANDROID
std::ostringstream converter;
converter << i;
#endif
/* Show error log */
if(!success) {
Error out{Debug::Flag::NoNewlineAtTheEnd};
out << "AbstractShaderProgram::link(): linking";
if(shaders.size() != 1) {
#ifndef CORRADE_TARGET_ANDROID
out << "of shader" << std::to_string(i);
#else
out << "of shader" << converter.str();
#endif
}
if(shaders.size() != 1) out << "of shader" << i;
out << "failed with the following message:" << Debug::newline << message;
/* Or just warnings, if any */
} else if(!message.empty() && !Implementation::isProgramLinkLogEmpty(message)) {
Warning out{Debug::Flag::NoNewlineAtTheEnd};
out << "AbstractShaderProgram::link(): linking";
if(shaders.size() != 1) {
#ifndef CORRADE_TARGET_ANDROID
out << "of shader" << std::to_string(i);
#else
out << "of shader" << converter.str();
#endif
}
if(shaders.size() != 1) out << "of shader" << i;
out << "succeeded with the following message:" << Debug::newline << message;
}

18
src/Magnum/DebugOutput.cpp

@ -34,10 +34,6 @@
#include "Magnum/Implementation/State.h"
#include "Magnum/Implementation/DebugState.h"
#ifdef CORRADE_TARGET_ANDROID
#include <sstream>
#endif
namespace Magnum {
namespace {
@ -103,19 +99,7 @@ void defaultCallback(const DebugOutput::Source source, const DebugOutput::Type t
case DebugOutput::Type::Other: ;
}
/** @todo Remove when this is fixed everywhere (also the include above) */
#ifdef CORRADE_TARGET_ANDROID
std::ostringstream converter;
converter << id;
#endif
output << '(' +
#ifndef CORRADE_TARGET_ANDROID
std::to_string(id) +
#else
converter.str() +
#endif
"):" << string;
output << "(" << Debug::nospace << id << Debug::nospace << "):" << string;
}
}

40
src/Magnum/Shader.cpp

@ -39,10 +39,6 @@
#include "Implementation/State.h"
#include "Implementation/ShaderState.h"
#ifdef CORRADE_TARGET_ANDROID
#include <sstream>
#endif
/* libgles-omap3-dev_4.03.00.02-r15.6 on BeagleBoard/Ångström linux 2011.3 doesn't have GLchar */
#ifdef MAGNUM_TARGET_GLES
typedef char GLchar;
@ -708,12 +704,6 @@ std::vector<std::string> Shader::sources() const { return _sources; }
Shader& Shader::addSource(std::string source) {
if(!source.empty()) {
/** @todo Remove when newlib has this fixed (also the include above) */
#ifdef CORRADE_TARGET_ANDROID
std::ostringstream converter;
converter << (_sources.size()+1)/2;
#endif
/* Fix line numbers, so line 41 of third added file is marked as 3(41)
in case shader version was not Version::None, because then source 0
is the #version directive added in constructor.
@ -725,13 +715,7 @@ Shader& Shader::addSource(std::string source) {
order to avoid complex logic in compile() where we assert for at
least some user-provided source, an empty string is added here
instead. */
if(!_sources.empty()) _sources.push_back("#line 1 " +
#ifndef CORRADE_TARGET_ANDROID
std::to_string((_sources.size()+1)/2) +
#else
converter.str() +
#endif
'\n');
if(!_sources.empty()) _sources.push_back("#line 1 " + std::to_string((_sources.size()+1)/2) + '\n');
else _sources.emplace_back();
_sources.push_back(std::move(source));
@ -789,36 +773,18 @@ bool Shader::compile(std::initializer_list<std::reference_wrapper<Shader>> shade
glGetShaderInfoLog(shader._id, message.size(), nullptr, &message[0]);
message.resize(std::max(logLength, 1)-1);
/** @todo Remove when this is fixed everywhere (also the include above) */
#ifdef CORRADE_TARGET_ANDROID
std::ostringstream converter;
converter << i;
#endif
/* Show error log */
if(!success) {
Error out{Debug::Flag::NoNewlineAtTheEnd};
out << "Shader::compile(): compilation of" << shaderName(shader._type) << "shader";
if(shaders.size() != 1) {
#ifndef CORRADE_TARGET_ANDROID
out << std::to_string(i);
#else
out << converter.str();
#endif
}
if(shaders.size() != 1) out << i;
out << "failed with the following message:" << Debug::newline << message;
/* Or just warnings, if any */
} else if(!message.empty() && !Implementation::isShaderCompilationLogEmpty(message)) {
Warning out{Debug::Flag::NoNewlineAtTheEnd};
out << "Shader::compile(): compilation of" << shaderName(shader._type) << "shader";
if(shaders.size() != 1) {
#ifndef CORRADE_TARGET_ANDROID
out << std::to_string(i);
#else
out << converter.str();
#endif
}
if(shaders.size() != 1) out << i;
out << "succeeded with the following message:" << Debug::newline << message;
}

67
src/MagnumPlugins/ObjImporter/ObjImporter.cpp

@ -62,34 +62,15 @@ template<std::size_t size> Math::Vector<size, Float> extractFloatData(const std:
Math::Vector<size, Float> output;
for(std::size_t i = 0; i != size; ++i) {
#ifndef CORRADE_TARGET_ANDROID
for(std::size_t i = 0; i != size; ++i)
output[i] = std::stof(data[i]);
#else
/* CRAPPY ANDROID GODDAMIT! It's also not exposed in std:: namespace,
unlike std::strtoul() and others. WTF! */
char* end{};
output[i] = strtof(data[i].data(), &end);
if(end == data[i].data() || output[i] == HUGE_VALF)
throw std::exception{};
#endif
}
if(data.size() == size+1) {
/* This should be obvious from the first if, but add this just to make
Clang Analyzer happy */
CORRADE_INTERNAL_ASSERT(extra);
#ifndef CORRADE_TARGET_ANDROID
*extra = std::stof(data.back());
#else
/* CRAPPY ANDROID GODDAMIT! It's also not exposed in std:: namespace,
unlike std::strtoul() and others. WTF! */
char* end{};
*extra = strtof(data.back().data(), &end);
if(end == data.back().data() || *extra == HUGE_VALF)
throw std::exception{};
#endif
}
return output;
@ -370,52 +351,16 @@ Containers::Optional<MeshData3D> ObjImporter::doMesh3D(UnsignedInt id) {
return Containers::NullOpt;
}
#ifdef CORRADE_TARGET_ANDROID
char* end{};
#endif
/* Position indices */
positionIndices.push_back(
#ifndef CORRADE_TARGET_ANDROID
std::stoul(indices[0])
#else
std::strtoul(indices[0].data(), &end, 10)
#endif
- positionIndexOffset);
#ifdef CORRADE_TARGET_ANDROID
if(end == indices[0].data()) throw std::exception{};
#endif
positionIndices.push_back(std::stoul(indices[0]) - positionIndexOffset);
/* Texture coordinates */
if(indices.size() == 2 || (indices.size() == 3 && !indices[1].empty())) {
textureCoordinateIndices.push_back(
#ifndef CORRADE_TARGET_ANDROID
std::stoul(indices[1])
#else
std::strtoul(indices[1].data(), &end, 10)
#endif
- textureCoordinateIndexOffset);
#ifdef CORRADE_TARGET_ANDROID
if(end == indices[1].data()) throw std::exception{};
#endif
}
if(indices.size() == 2 || (indices.size() == 3 && !indices[1].empty()))
textureCoordinateIndices.push_back(std::stoul(indices[1]) - textureCoordinateIndexOffset);
/* Normal indices */
if(indices.size() == 3) {
normalIndices.push_back(
#ifndef CORRADE_TARGET_ANDROID
std::stoul(indices[2])
#else
std::strtoul(indices[2].data(), &end, 10)
#endif
- normalIndexOffset);
#ifdef CORRADE_TARGET_ANDROID
if(end == indices[2].data()) throw std::exception{};
#endif
}
if(indices.size() == 3)
normalIndices.push_back(std::stoul(indices[2]) - normalIndexOffset);
}
/* Ignore unsupported keywords, error out on unknown keywords */

Loading…
Cancel
Save