X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fprogram.cpp;h=33c53cd7755fe4f0e4d7b1bd293c2f6af30c8748;hp=d6bd5ee88d889c4efc02a0b9ee86a8051b8ec9a2;hb=fcde8390ad577fe434dcd4b29e0f410d29f867c9;hpb=7f0e08f04536bf42b8f64e7dff5cc3e18b916c7b diff --git a/source/core/program.cpp b/source/core/program.cpp index d6bd5ee8..33c53cd7 100644 --- a/source/core/program.cpp +++ b/source/core/program.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -123,6 +124,11 @@ unsigned Program::add_stage(Stage type) stage_ids[type] = stage_id; glAttachShader(id, stage_id); +#ifdef DEBUG + if(!debug_name.empty() && KHR_debug) + set_stage_debug_name(stage_id, type); +#endif + return stage_id; } @@ -767,6 +773,33 @@ void Program::unbind() glUseProgram(0); } +void Program::set_debug_name(const string &name) +{ +#ifdef DEBUG + debug_name = name; + if(KHR_debug) + { + glObjectLabel(GL_PROGRAM, id, name.size(), name.c_str()); + for(unsigned i=0; i(i)); + } +#else + (void)name; +#endif +} + +void Program::set_stage_debug_name(unsigned stage_id, Stage type) +{ +#ifdef DEBUG + static const char *const suffixes[] = { " [VS]", " [GS]", " [FS]" }; + string name = debug_name+suffixes[type]; + glObjectLabel(GL_SHADER, stage_id, name.size(), name.c_str()); +#else + (void)stage_id; (void)type; +#endif +} + Program::UniformInfo::UniformInfo(): block(0),