40#ifndef GEOGRAM_GFX_BASIC_GLSL
41#define GEOGRAM_GFX_BASIC_GLSL
78 const char*
what() const GEO_NOEXCEPT override;
118 Source(
const std::string& src) : text_string_(src) {
119 text_ = text_string_.c_str();
156 if(rhs.text_string_ !=
"") {
157 text_string_ = rhs.text_string_;
158 text_ = text_string_.c_str();
166 std::string text_string_;
192 typedef void (*PseudoFile)(
205 const std::string& name,
const char* source
218 const std::string& name, PseudoFile file
231 const std::string& name
270 const char* shader1,
const char* shader2 =
nullptr,
271 const char* shader3 =
nullptr,
const char* shader4 =
nullptr,
272 const char* shader5 =
nullptr,
const char* shader6 =
nullptr
298 GLenum target,
const char** sources,
index_t nb_sources
327 const char* source3 =
nullptr,
328 const char* source4 =
nullptr,
329 const char* source5 =
nullptr,
330 const char* source6 =
nullptr,
331 const char* source7 =
nullptr,
332 const char* source8 =
nullptr,
333 const char* source9 =
nullptr,
334 const char* source10 =
nullptr,
335 const char* source11 =
nullptr,
336 const char* source12 =
nullptr,
337 const char* source13 =
nullptr,
338 const char* source14 =
nullptr,
339 const char* source15 =
nullptr,
340 const char* source16 =
nullptr,
341 const char* source17 =
nullptr,
342 const char* source18 =
nullptr,
343 const char* source19 =
nullptr,
344 const char* source20 =
nullptr
404 const char*
string,
bool copy_string =
true
416 const std::string& filename
429 GLuint shader_id,
const char* name, T val
438 template<>
inline bool set_program_uniform_by_name(
439 GLuint shader_id,
const char* name,
bool val
441 GLint location = glGetUniformLocation(shader_id, name) ;
445 glUseProgram(shader_id);
446 glUniform1i(location, val ? 1 : 0) ;
452 GLuint shader_id,
const char* name,
float val
454 GLint location = glGetUniformLocation(shader_id, name) ;
458 glUseProgram(shader_id);
459 glUniform1f(location, val) ;
465 GLuint shader_id,
const char* name,
double val
467 GLint location = glGetUniformLocation(shader_id, name) ;
471 glUseProgram(shader_id);
472 glUniform1f(location,
float(val)) ;
478 GLuint shader_id,
const char* name,
int val
480 GLint location = glGetUniformLocation(shader_id, name) ;
484 glUseProgram(shader_id);
485 glUniform1i(location, val) ;
492 GLuint shader_id,
const char* name,
unsigned int val
494 GLint location = glGetUniformLocation(shader_id, name) ;
498 glUseProgram(shader_id);
500 glUniform1ui(location, val) ;
502 glUniform1i(location, GLint(val)) ;
517 GLuint shader_id,
const char* name,
index_t count,
float* values
519 GLint location = glGetUniformLocation(shader_id, name) ;
523 glUseProgram(shader_id);
524 glUniform1fv(location, GLsizei(count), values) ;
529 inline bool set_program_uniform_by_name(
530 GLuint shader_id,
const char* name,
float x,
float y
532 GLint location = glGetUniformLocation(shader_id, name) ;
536 glUseProgram(shader_id);
537 glUniform2f(location, x, y);
551 GLuint program,
const char* varname
563 GLuint program,
const char* varname
GLuint GEOGRAM_GFX_API create_program_from_shaders(GLuint shader,...)
Creates a GLSL program from a zero-terminated list of shaders.
GLuint GEOGRAM_GFX_API create_program_from_file_no_link(const std::string &filename)
Creates a GLSL program from a file.
const char * get_GLSL_include_file(const std::string &name)
Gets a GLSL include file by file name.
void GEOGRAM_GFX_API introspect_program(GLuint program)
Outputs to the logger everything that can be queried about a program using OpenGL introspection APIs.
GLuint GEOGRAM_GFX_API compile_shader(GLenum target, const char **sources, index_t nb_sources)
Compiles a shader for a specific target.
GLuint GEOGRAM_GFX_API compile_shader_with_includes(GLenum target, const char *source, PseudoFileProvider *provider)
Compiles a shader for a specific target.
GLuint GEOGRAM_GFX_API create_program_from_shaders_no_link(GLuint shader,...)
Creates a GLSL program from a zero-terminated list of shaders.
GLuint GEOGRAM_GFX_API create_program_from_string_no_link(const char *string, bool copy_string=true)
Creates a GLSL program from a string.
GLuint GEOGRAM_GFX_API compile_program_with_includes_no_link(PseudoFileProvider *provider, const char *shader1, const char *shader2=nullptr, const char *shader3=nullptr, const char *shader4=nullptr, const char *shader5=nullptr, const char *shader6=nullptr)
Compiles a program from shader sources.
size_t GEOGRAM_GFX_API get_uniform_variable_array_stride(GLuint program, const char *varname)
Queries array stride for a variable in a GLSL program using introspection.
void GEOGRAM_GFX_API link_program(GLuint program)
Links a program.
GLint GEOGRAM_GFX_API get_uniform_variable_offset(GLuint program, const char *varname)
Gets the offset of a uniform variable relative to the uniform block it is declared in.
bool set_program_uniform_by_name(GLuint shader_id, const char *name, T val)
Sets a uniform variable in a shader by name.
void GEOGRAM_GFX_API register_GLSL_include_file(const std::string &name, const char *source)
Registers a file in the GLSL pseudo file system.
#define geo_assert_not_reached
Sets a non reachable point in the program.
A class that can register functions to the GLSL pseudo file system.
virtual ~PseudoFileProvider()
PseudoFileProvider destructor.
Source & operator=(const Source &rhs)
Source assignment operator.
const char * text()
Gets the text.
void copy(const Source &rhs)
Copies a Source.
Source()
Source constructor.
Source(const Source &rhs)
Source copy constructor.
Source(const std::string &src)
Source constructor from a string.
Source(const char *src)
Source constructor from a char pointer.
#define GEOGRAM_GFX_API
Linkage declaration for geogram symbols.
Common include file, providing basic definitions. Should be included before anything else by all head...
Global Vorpaline namespace.
void geo_argused(const T &)
Suppresses compiler warnings about unused parameters.
geo_index_t index_t
The type for storing and manipulating indices.
Types and functions for numbers manipulation.
Exception thrown when a GLSL shader fails to compiled.
const char * what() const GEO_NOEXCEPT override
Gets the string identifying the exception.