Files
MapLibreParticleLab/common/headless_view.hpp
Leith Bade c004c03696 Add View::make_inactive() to remove context from rendering thread
View::make_inactive() is called just before termination of the
rendering thread. The implementation must clear the thread's GL
context.

This ensures there is no context still bound to a thread during
GL shutdown. This is needed as GL will not actually delete a
context until it is not active on any thread.

Fixes mapbox/mapbox-gl-native#340

Conflicts:
	common/glfw_view.hpp
	include/llmr/map/view.hpp
	test/headless.cpp
2014-09-10 18:21:03 -04:00

54 lines
944 B
C++

#ifndef MBGL_COMMON_HEADLESS_CGL
#define MBGL_COMMON_HEADLESS_CGL
#ifdef __APPLE__
#define MBGL_USE_CGL 1
#else
#include <GL/glx.h>
#define MBGL_USE_GLX 1
#endif
#include <mbgl/map/view.hpp>
#include <mbgl/platform/gl.hpp>
#include <mbgl/util/time.hpp>
namespace mbgl {
class HeadlessView : public View {
public:
HeadlessView();
~HeadlessView();
void resize(int width, int height);
void notify_map_change(MapChange change, timestamp delay = 0);
void make_active();
void make_inactive();
void swap();
unsigned int root_fbo();
private:
void clear_buffers();
private:
#if MBGL_USE_CGL
CGLContextObj gl_context;
GLuint fbo = 0;
GLuint fbo_depth_stencil = 0;
GLuint fbo_color = 0;
#endif
#if MBGL_USE_GLX
GLXContext gl_context = nullptr;
XVisualInfo *x_info = nullptr;
Display *x_display = nullptr;
Pixmap x_pixmap = 0;
GLXPixmap glx_pixmap = 0;
#endif
};
}
#endif