diff --git a/base/stringutil.h b/base/stringutil.h index 59b1d0d03d..7cc61b3086 100644 --- a/base/stringutil.h +++ b/base/stringutil.h @@ -34,3 +34,22 @@ inline void StringToHexString(const std::string &data, std::string *output) { // highly unsafe and not recommended. unsigned int parseHex(const char* _szValue); + + +// Suitable for inserting into maps, unlike char*, and cheaper than std::string. +// Strings must be constant and preferably be stored in the read-only part +// of the binary. +class ConstString { +public: + ConstString(const char *ptr) { + ptr_ = ptr; + } + bool operator <(const ConstString &other) const { + return strcmp(ptr_, other.ptr_) < 0; + } + bool operator ==(const ConstString &other) const { + return ptr_ == other.ptr_ || !strcmp(ptr_, other.ptr_); + } +private: + const char *ptr_; +}; diff --git a/gfx_es2/glsl_program.h b/gfx_es2/glsl_program.h index 58392f64d2..2d5f0adc0a 100644 --- a/gfx_es2/glsl_program.h +++ b/gfx_es2/glsl_program.h @@ -16,6 +16,7 @@ #endif #endif +#include #include #include "gfx/gl_lost_manager.h" @@ -54,6 +55,9 @@ struct GLSLProgram : public GfxResourceHolder { void GLLost(); }; + +// C API, old skool + GLSLProgram *glsl_create(const char *vshader_file, const char *fshader_file); void glsl_destroy(GLSLProgram *program);