Exception for shader errors.

This commit is contained in:
Boldizsár Lipka 2014-08-03 14:06:52 +02:00
parent becd1843df
commit dbf7958bdd
2 changed files with 15 additions and 3 deletions

View file

@ -29,17 +29,17 @@ shader_program::shader_program(const std::string &vsrc, const std::string &fsrc)
{
vertex_object_ = GPU_LoadShader(GPU_VERTEX_SHADER, vsrc.c_str());
if (!vertex_object_) {
//TODO: report error
throw shader_error("Failed to compile vertex shader");
}
fragment_object_ = GPU_LoadShader(GPU_FRAGMENT_SHADER, fsrc.c_str());
if (!fragment_object_) {
//TODO: report error
throw shader_error("Failed to compile fragment shader");
}
program_object_ = GPU_LinkShaders(vertex_object_, fragment_object_);
if (!program_object_) {
//TODO: report error
throw shader_error("Failed to link shader program");
}
attr_color_mod_ = GPU_GetAttributeLocation(program_object_,
@ -122,5 +122,10 @@ void shader_program::set_submerge(float val)
GPU_SetAttributef(attr_submerge_, val);
}
shader_error::shader_error(const std::string &op)
: game::error(op + "\n" + GPU_GetShaderMessage())
{
}
}
#endif

View file

@ -19,6 +19,7 @@
#include <string>
#include <vector>
#include <boost/noncopyable.hpp>
#include "exceptions.hpp"
namespace sdl {
@ -45,5 +46,11 @@ private:
unsigned *refcount_;
};
class shader_error : public game::error
{
public:
shader_error(const std::string &op);
};
}
#endif