move to libuv for the rendering loop
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user