CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Common/GPU/OpenGL/GLSLProgram.h
Views: 1401
// Utility code for loading GLSL shaders.1// Has support for auto-reload, see glsl_refresh23#pragma once45#include <string>6#include <time.h>78#include "Common/GPU/OpenGL/GLCommon.h"910// Represent a compiled and linked vshader/fshader pair.11// A just-constructed object is valid but cannot be used as a shader program, meaning that12// yes, you can declare these as globals if you like.13struct GLSLProgram {14char name[16];15char vshader_filename[256];16char fshader_filename[256];17const char *vshader_source;18const char *fshader_source;19time_t vshader_mtime;20time_t fshader_mtime;2122// Locations to some common uniforms. Hardcoded for speed.23GLint sampler0;24GLint sampler1;25GLint u_worldviewproj;26GLint u_world;27GLint u_viewproj;28GLint u_fog; // rgb = color, a = density29GLint u_sundir;30GLint u_camerapos;3132GLint a_position;33GLint a_color;34GLint a_normal;35GLint a_texcoord0;36GLint a_texcoord1;3738// Private to the implementation, do not touch39GLuint vsh_;40GLuint fsh_;41GLuint program_;42};4344// C API, old skool. Not much point either...4546// From files (VFS)47GLSLProgram *glsl_create(const char *vshader_file, const char *fshader_file, std::string *error_message = 0);48// Directly from source code49GLSLProgram *glsl_create_source(const char *vshader_src, const char *fshader_src, std::string *error_message = 0);50void glsl_destroy(GLSLProgram *program);5152// If recompilation of the program fails, the program is untouched and error messages53// are logged and the function returns false.54bool glsl_recompile(GLSLProgram *program, std::string *error_message = 0);55void glsl_bind(const GLSLProgram *program);56const GLSLProgram *glsl_get_program();57void glsl_unbind();58int glsl_attrib_loc(const GLSLProgram *program, const char *name);59int glsl_uniform_loc(const GLSLProgram *program, const char *name);606162