add debug markers for easier gl debugging

This commit is contained in:
Konstantin Käfer
2014-04-15 14:30:05 -04:00
parent f859945e06
commit 3c656d2bf2
6 changed files with 61 additions and 11 deletions

View File

@@ -53,7 +53,7 @@ private:
Type type;
std::list<uint32_t> zooms;
const char *url;
const std::string url;
uint32_t tile_size;
uint32_t min_zoom;
uint32_t max_zoom;

View File

@@ -1,6 +1,8 @@
#ifndef LLMR_RENDERER_GL
#define LLMR_RENDERER_GL
#include <string>
#ifdef NVIDIA
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
@@ -33,6 +35,28 @@
#include <GL/glext.h>
#endif
namespace llmr {
namespace gl {
// Debug group markers, useful for debuggin on iOS
inline void start_group(const std::string &str) {
#if GL_EXT_debug_marker
glPushGroupMarkerEXT(0, str.c_str());
#endif
}
inline void end_group() {
#if GL_EXT_debug_marker
glPopGroupMarkerEXT();
#endif
}
struct group {
inline group(const std::string &str) { start_group(str); }
~group() { end_group(); };
};
}
}
#ifdef GL_ES_VERSION_2_0
#define glClearDepth glClearDepthf
#define glDepthRange glDepthRangef

View File

@@ -6,13 +6,18 @@
namespace llmr {
namespace util {
template<typename... Args>
template<size_t max, typename... Args>
inline std::string sprintf(const char *msg, Args... args) {
char res[1024];
char res[max];
int len = snprintf(res, sizeof(res), msg, args...);
return std::string(res, len);
}
template<size_t max, typename... Args>
inline std::string sprintf(const std::string &msg, Args... args) {
return sprintf<max>(msg.c_str(), args...);
}
}
}