add GLShader::create() which takes a PathRef

This commit is contained in:
Josh Holtrop 2014-06-23 16:11:20 -04:00
parent d54e772803
commit 5558eec534
2 changed files with 16 additions and 0 deletions

View File

@ -55,4 +55,18 @@ namespace jes
}
return false;
}
bool GLShader::create(GLenum shader_type, PathRef path)
{
uint8_t * file;
size_t size;
if (!path->read(&file, &size))
return false;
if (size == 0u)
return false;
bool result = create(shader_type, (const char *)file, size);
delete[] file;
return result;
}
}

View File

@ -2,6 +2,7 @@
#define GLSHADER_H
#include "jes/Ref.h"
#include "jes/Path.h"
#include "gl3w.h"
namespace jes
@ -12,6 +13,7 @@ namespace jes
GLShader() { m_id = 0u; }
~GLShader();
bool create(GLenum shader_type, const char *source, size_t size);
bool create(GLenum shader_type, PathRef path);
GLuint get_id() { return m_id; }
bool valid() { return m_id > 0; }
protected: