Browse Source

Properly count line numbers in shaders.

Now line 41 of third added file is marked as 3(41). Source 0 is the
`#version` string added in Shader constructor.

Huh, deinlining that Shader::addSource() function also significantly
reduced debug binary sizes.
pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
d3ebbabb27
  1. 8
      src/Shader.cpp
  2. 5
      src/Shader.h

8
src/Shader.cpp

@ -79,6 +79,14 @@ Shader& Shader::operator=(Shader&& other) {
return *this;
}
Shader& Shader::addSource(const std::string& source) {
if(_state == State::Initialized)
/* Fix line numbers, so line 41 of third added file is marked as 3(41).
Source 0 is the #version string added in constructor. */
sources.push_back("#line 1 " + std::to_string(sources.size()) + '\n' + source);
return *this;
}
Shader& Shader::addFile(const std::string& filename) {
/* Open file */
std::ifstream file(filename.c_str());

5
src/Shader.h

@ -142,10 +142,7 @@ class MAGNUM_EXPORT Shader {
* one source.
* @see addFile()
*/
inline Shader& addSource(const std::string& source) {
if(_state == State::Initialized) sources.push_back(source);
return *this;
}
Shader& addSource(const std::string& source);
/**
* @brief Add source file

Loading…
Cancel
Save