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
268 const char* shader1,
const char* shader2 =
nullptr,
const char* shader3 =
nullptr,
269 const char* shader4 =
nullptr,
const char* shader5 =
nullptr,
const char* shader6 =
nullptr
295 GLenum target,
const char** sources,
index_t nb_sources
324 const char* source3 =
nullptr,
325 const char* source4 =
nullptr,
326 const char* source5 =
nullptr,
327 const char* source6 =
nullptr,
328 const char* source7 =
nullptr,
329 const char* source8 =
nullptr,
330 const char* source9 =
nullptr,
331 const char* source10 =
nullptr,
332 const char* source11 =
nullptr,
333 const char* source12 =
nullptr,
334 const char* source13 =
nullptr,
335 const char* source14 =
nullptr,
336 const char* source15 =
nullptr,
337 const char* source16 =
nullptr,
338 const char* source17 =
nullptr,
339 const char* source18 =
nullptr,
340 const char* source19 =
nullptr,
341 const char* source20 =
nullptr
401 const char*
string,
bool copy_string =
true
413 const std::string& filename
426 GLuint shader_id,
const char* name, T val
435 template<>
inline bool set_program_uniform_by_name(
436 GLuint shader_id,
const char* name,
bool val
438 GLint location = glGetUniformLocation(shader_id, name) ;
442 glUseProgram(shader_id);
443 glUniform1i(location, val ? 1 : 0) ;
449 GLuint shader_id,
const char* name,
float val
451 GLint location = glGetUniformLocation(shader_id, name) ;
455 glUseProgram(shader_id);
456 glUniform1f(location, val) ;
462 GLuint shader_id,
const char* name,
double val
464 GLint location = glGetUniformLocation(shader_id, name) ;
468 glUseProgram(shader_id);
469 glUniform1f(location,
float(val)) ;
475 GLuint shader_id,
const char* name,
int val
477 GLint location = glGetUniformLocation(shader_id, name) ;
481 glUseProgram(shader_id);
482 glUniform1i(location, val) ;
489 GLuint shader_id,
const char* name,
unsigned int val
491 GLint location = glGetUniformLocation(shader_id, name) ;
495 glUseProgram(shader_id);
497 glUniform1ui(location, val) ;
499 glUniform1i(location, GLint(val)) ;
514 GLuint shader_id,
const char* name,
index_t count,
float* values
516 GLint location = glGetUniformLocation(shader_id, name) ;
520 glUseProgram(shader_id);
521 glUniform1fv(location, GLsizei(count), values) ;
526 inline bool set_program_uniform_by_name(
527 GLuint shader_id,
const char* name,
float x,
float y
529 GLint location = glGetUniformLocation(shader_id, name) ;
533 glUseProgram(shader_id);
534 glUniform2f(location, x, y);
548 GLuint program,
const char* varname
560 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.
void copy(const Source &rhs)
Copies a Source.
const char * text()
Gets the text.
Source()
Source constructor.
Source & operator=(const Source &rhs)
Source assignment operator.
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...
void copy(void *to, const void *from, size_t size)
Copies a memory block.
Global Vorpaline namespace.
void terminate()
Cleans up Geogram.
void geo_argused(const T &)
Suppresses compiler warnings about unused parameters.
geo_index_t index_t
The type for storing and manipulating indices.
void initialize(int flags=GEOGRAM_INSTALL_NONE)
Initialize Geogram.
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.