glsl; dump shaderlog (#1883)

fix typo
This commit is contained in:
kd-11 2016-07-10 20:16:31 +03:00 committed by raven02
parent 8c3b3f7ab4
commit bbf7e6332c
1 changed files with 23 additions and 2 deletions

View File

@ -1732,8 +1732,6 @@ namespace gl
class shader
{
GLuint m_id = GL_NONE;
public:
enum class type
{
@ -1742,6 +1740,13 @@ namespace gl
geometry = GL_GEOMETRY_SHADER
};
private:
GLuint m_id = GL_NONE;
type shader_type = type::vertex;
public:
shader() = default;
shader(GLuint id)
@ -1777,6 +1782,7 @@ namespace gl
void create(type type_)
{
m_id = glCreateShader((GLenum)type_);
shader_type = type_;
}
void source(const std::string& src) const
@ -1784,6 +1790,21 @@ namespace gl
const char* str = src.c_str();
const GLint length = (GLint)src.length();
{
std::string base_name = "shaderlog/VertexProgram";
switch (shader_type)
{
case type::fragment:
base_name = "shaderlog/FragmentProgram";
break;
case type::geometry:
base_name = "shaderlog/GeometryProgram";
break;
}
fs::file(fs::get_config_dir() + base_name + std::to_string(m_id) + ".glsl", fs::rewrite).write(str);
}
glShaderSource(m_id, 1, &str, &length);
}