summaryrefslogtreecommitdiff
path: root/test/headless.cpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-04-30 12:01:26 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-04-30 12:01:26 +0200
commit1216a061d3e46eae983a38e42e71115e5c9faef6 (patch)
tree7ddb57f2885072db82657dc56dff64e49e28db76 /test/headless.cpp
parentddc359f006c47e2a503b616d27e22f5d29c13e5b (diff)
downloadqtlocation-mapboxgl-1216a061d3e46eae983a38e42e71115e5c9faef6.tar.gz
move to libuv for the rendering loop
Diffstat (limited to 'test/headless.cpp')
-rw-r--r--test/headless.cpp48
1 files changed, 16 insertions, 32 deletions
diff --git a/test/headless.cpp b/test/headless.cpp
index 0da898245a..c515b36c9a 100644
--- a/test/headless.cpp
+++ b/test/headless.cpp
@@ -11,23 +11,24 @@
#include <uv.h>
-double llmr::platform::elapsed() {
- return 0;
-}
+class View : public llmr::View {
+public:
+ void make_active() {
+ CGLError error = CGLSetCurrentContext(gl_context);
+ if (error) {
+ fprintf(stderr, "Switching OpenGL context failed\n");
+ }
+ }
+ void swap() {}
-void llmr::platform::restart() {
- // noop
-}
+CGLContextObj gl_context;
+};
TEST(Headless, initialize) {
- llmr::Settings settings;
-
- llmr::Map map(settings);
-
llmr::util::timer timer;
// Setup OpenGL
- CGLContextObj gl_context;
+ View view;
// TODO: test if OpenGL 4.1 with GL_ARB_ES2_compatibility is supported
// If it is, use kCGLOGLPVersion_3_2_Core and enable that extension.
@@ -46,18 +47,14 @@ TEST(Headless, initialize) {
return;
}
- error = CGLCreateContext(pixelFormat, NULL, &gl_context);
+ error = CGLCreateContext(pixelFormat, NULL, &view.gl_context);
CGLDestroyPixelFormat(pixelFormat);
if (error) {
fprintf(stderr, "Error creating GL context object\n");
return;
}
- error = CGLSetCurrentContext(gl_context);
- if (error) {
- fprintf(stderr, "Switching OpenGL context failed\n");
- return;
- }
+ view.make_active();
timer.report("gl setup");
@@ -102,31 +99,18 @@ TEST(Headless, initialize) {
timer.report("gl framebuffer");
- map.setup();
- timer.report("map setup");
+ llmr::Map map(view);
map.resize(width, height);
timer.report("map resize");
- map.loadSettings();
-
- timer.report("map settings");
-
- map.update();
-
- timer.report("map update");
-
// Run the loop. It will terminate when we don't have any further listeners.
map.run();
timer.report("map loop");
- map.render();
-
- timer.report("map render");
-
uint32_t *pixels = new uint32_t[width * height];
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
@@ -149,7 +133,7 @@ TEST(Headless, initialize) {
glDeleteTextures(1, &fbo_color);
glDeleteRenderbuffersEXT(1, &fbo_depth_stencil);
- CGLDestroyContext(gl_context);
+ CGLDestroyContext(view.gl_context);
timer.report("destruct");
}