Layout MakeLayout(const Font& font, StrCRef str) { CodePoints cps; UTF8ToCodePoints(str.begin(), str.size(), cps); Layout layout(MakeLayout(font, str.size())); layout.Set(cps.data(), cps.size()); return std::move(layout); }
/// Store the @p value, of the specified @p type under @p name static void Set( NamedStringType type, const StrCRef& name, const StrCRef& value ) { OGLPLUS_GLFUNC(NamedStringARB)( GLenum(type), GLint(name.size()), name.c_str(), GLint(value.size()), value.c_str() ); OGLPLUS_CHECK_SIMPLE(NamedStringARB); }
/// Pushes a debug group static void PushGroup( DebugSource source, GLuint id, StrCRef message ) { PushGroup(source, id, message.size(), message.c_str()); }
/// Deletes the value stored under @p name static void Delete(const StrCRef& name) { OGLPLUS_GLFUNC(DeleteNamedStringARB)( GLint(name.size()), name.c_str() ); OGLPLUS_CHECK_SIMPLE(DeleteNamedStringARB); }
static void ObjectLabel(const ObjectName<ObjTag>& object, StrCRef label) { OGLPLUS_GLFUNC(ObjectLabel) (GetGLName(object), ObjTypeOps<ObjTag>::ObjectType(), label.size(), label.c_str()); OGLPLUS_VERIFY_SIMPLE(ObjectLabel); }
/// Checks if @p name is a stored string static bool IsA(const StrCRef& name) { GLboolean result = OGLPLUS_GLFUNC(IsNamedStringARB)( GLint(name.size()), name.c_str() ); OGLPLUS_CHECK_SIMPLE(IsNamedStringARB); return result == GL_TRUE; }
/// Gets the type of the named string stored under @p name static NamedStringType Type(const StrCRef& name) { GLint result = 0; OGLPLUS_GLFUNC(GetNamedStringivARB)( GLint(name.size()), name.c_str(), GL_NAMED_STRING_TYPE_ARB, &result ); OGLPLUS_CHECK_SIMPLE(GetNamedStringivARB); return NamedStringType(GLenum(result)); }
/// Gets the value stored under @p name static String Get(const StrCRef& name) { GLint len = 0; OGLPLUS_GLFUNC(GetNamedStringivARB)( GLint(name.size()), name.c_str(), GL_NAMED_STRING_LENGTH_ARB, &len ); OGLPLUS_CHECK_SIMPLE(GetNamedStringivARB); String result(len, '\0'); OGLPLUS_GLFUNC(GetNamedStringARB)( GLint(name.size()), name.c_str(), len, &len, &result.front() ); OGLPLUS_CHECK_SIMPLE(GetNamedStringARB); return std::move(result); }
/** * @overload * * @glsymbols * @glfunref{PushDebugGroup} */ Group( DebugOutputSource source, GLuint id, StrCRef message ) { OGLPLUS_GLFUNC(PushDebugGroup)( GLenum(source), id, message.size(), message.begin() ); OGLPLUS_VERIFY_SIMPLE(PushDebugGroup); }
/// Inserts a new message into the debug output static void InsertMessage( DebugOutputARBSource source, DebugOutputARBType type, GLuint id, DebugOutputARBSeverity severity, StrCRef message) { OGLPLUS_GLFUNC(DebugMessageInsertARB) (GLenum(source), GLenum(type), id, GLenum(severity), GLsizei(message.size()), message.c_str()); OGLPLUS_VERIFY_SIMPLE(DebugMessageInsertARB); }
/// Inserts a new message into the debug output static void InsertMessage( DebugSource source, DebugType type, GLuint id, DebugSeverity severity, StrCRef message ) { InsertMessage( source, type, id, severity, message.size(), message.c_str() ); }
void Set(StrCRef str) { Set(UTF8ToCodePoints(str.begin(), str.size())); }
void Set(StrCRef str) { Set(str.begin(), str.size()); }
GLSLString(const StrCRef& str) : _str(str.begin()) , _len(GLint(str.size())) { }
oglplus::Program SpectraSharedObjects::BuildProgramWithXFB( const char* prog_name, const char** xfb_varyings, std::size_t xfb_var_count, bool separate_attribs ) { using namespace oglplus; Program prog = Program(ObjectDesc(prog_name)); std::ifstream prog_file; OpenResourceFile(prog_file, "glsl", prog_name, ".txt"); const std::size_t linesize = 1024; char line[1024] = {'\0'}; int line_no = 0; while(prog_file.getline(line, linesize).good()) { std::size_t line_len = prog_file.gcount(); ++line_no; auto types = EnumValueRange<ShaderType>(); ShaderType type = ShaderType::Fragment; std::size_t name_len = 0; while(!types.Empty()) { type = types.Front(); StrCRef name = EnumValueName(type); name_len = name.size(); if(std::strncmp(line, name.c_str(), name.size()) == 0) break; types.Next(); } if(types.Empty()) { wxString message = wxString::Format( wxGetTranslation(wxT( "Invalid shader type in program '%s' "\ "on line %d: '%s'" )), wxString(prog_name, wxConvUTF8).c_str(), line_no, wxString(line, wxConvUTF8).c_str() ); throw std::runtime_error( (const char*)message.mb_str(wxConvUTF8) ); } // rtrim the name for(std::size_t i = name_len+1; i!=line_len; ++i) { if(std::isspace(line[i])) { line[i] = '\0'; break; } } std::ifstream shader_file; OpenResourceFile(shader_file, "glsl", line+name_len+1, ".glsl"); Shader shader(type); shader.Source(GLSLSource::FromStream(shader_file)); shader.Compile(); prog.AttachShader(shader); } if(xfb_varyings && xfb_var_count) { prog.TransformFeedbackVaryings( xfb_var_count, xfb_varyings, separate_attribs ?TransformFeedbackMode::SeparateAttribs :TransformFeedbackMode::InterleavedAttribs ); } prog.Link().Use(); return std::move(prog); }