37 if (vsSource ==
"" || psSource ==
"")
39 LogError(
"A program must have a vertex shader and a pixel shader.");
66 if (programHandle == 0)
68 LogError(
"Program creation failed.");
79 if (!
Link(programHandle))
94 std::shared_ptr<GLSLVisualProgram>
program =
95 std::make_shared<GLSLVisualProgram>(programHandle, vsHandle,
99 program->SetVShader(std::make_shared<VertexShader>(reflector));
100 program->SetPShader(std::make_shared<PixelShader>(reflector));
103 program->SetGShader(std::make_shared<GeometryShader>(reflector));
113 LogError(
"A program must have a compute shader.");
124 if (programHandle == 0)
126 LogError(
"Program creation failed.");
132 if (!
Link(programHandle))
140 std::shared_ptr<GLSLComputeProgram>
program =
141 std::make_shared<GLSLComputeProgram>(programHandle, csHandle);
144 program->SetCShader(std::make_shared<ComputeShader>(reflector));
165 std::vector<std::string> glslDefines;
166 glslDefines.reserve(definitions.size() + 5);
167 glslDefines.push_back(
version +
"\n");
168 #if defined(GTE_USE_MAT_VEC) 169 glslDefines.push_back(
"#define GTE_USE_MAT_VEC 1\n");
171 glslDefines.push_back(
"#define GTE_USE_MAT_VEC 0\n");
173 #if defined(GTE_USE_ROW_MAJOR) 174 glslDefines.push_back(
"layout(std140, row_major) uniform;\n");
175 glslDefines.push_back(
"layout(std430, row_major) buffer;\n");
177 glslDefines.push_back(
"layout(std140, column_major) uniform;\n");
178 glslDefines.push_back(
"layout(std430, column_major) buffer;\n");
180 for (
auto d : definitions)
182 glslDefines.push_back(
"#define " + d.first +
" " + d.second +
"\n");
184 glslDefines.push_back(source);
187 std::vector<GLchar const*> code;
188 code.reserve(glslDefines.size());
189 for (
auto const& d : glslDefines)
191 code.push_back(d.c_str());
194 glShaderSource(handle, static_cast<GLsizei>(code.size()), &code[0],
206 std::vector<GLchar> log(logLength);
213 LogError(
"Invalid info log length.");
237 std::vector<GLchar> log(logLength);
244 LogError(
"Invalid info log length.");
void APIENTRY glDeleteProgram(GLuint program)
virtual std::shared_ptr< ComputeProgram > CreateFromNamedSource(std::string const &csName, std::string const &csSource) override
#define GL_COMPUTE_SHADER
static std::string defaultCSEntry
std::vector< std::pair< std::string, std::string > > const & Get() const
void APIENTRY glDeleteShader(GLuint shader)
GLuint Compile(GLenum shaderType, std::string const &source)
#define GL_GEOMETRY_SHADER
GLbitfield GLuint program
static std::string defaultGSEntry
void APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint *params)
GLuint APIENTRY glCreateProgram()
void APIENTRY glDetachShader(GLuint program, GLuint shader)
void APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar *const *string, const GLint *length)
virtual std::shared_ptr< VisualProgram > CreateFromNamedSources(std::string const &vsName, std::string const &vsSource, std::string const &psName, std::string const &psSource, std::string const &gsName, std::string const &gsSource) override
void APIENTRY glLinkProgram(GLuint program)
static std::string defaultVSEntry
GLsizei GLsizei GLchar * source
bool Link(GLuint programHandle)
GLsizei const GLchar *const * string
#define LogError(message)
#define GL_FRAGMENT_SHADER
#define GL_INFO_LOG_LENGTH
void APIENTRY glCompileShader(GLuint shader)
static unsigned int defaultFlags
static std::string defaultVersion
#define GL_COMPILE_STATUS
GLuint APIENTRY glCreateShader(GLenum type)
static std::string defaultPSEntry
void APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog)
void APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog)
void APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint *params)
void APIENTRY glAttachShader(GLuint program, GLuint shader)