X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=context.cpp;h=eb62183a3b3a8c9c7c9065f6d212a21b92e8257e;hb=6ffaabac0a523617b686f40c154a25cb548cc561;hp=6ce57446b08983c670a3c7b7c99aaf452cc0fe61;hpb=ce8077a29627c7a55c5afdfdf5b56a4b179c7d62;p=nageru diff --git a/context.cpp b/context.cpp index 6ce5744..eb62183 100644 --- a/context.cpp +++ b/context.cpp @@ -1,27 +1,35 @@ #include +#include + #include #include #include +#include #include -class QSurface; - QGLWidget *global_share_widget = nullptr; +bool using_egl = false; + +using namespace std; QSurface *create_surface(const QSurfaceFormat &format) { QOffscreenSurface *surface = new QOffscreenSurface; surface->setFormat(format); -// QWindow *surface = new QWindow; surface->create(); if (!surface->isValid()) { - printf("ERROR: surface not valid!\n"); -// abort(); + fprintf(stderr, "ERROR: surface not valid!\n"); + exit(1); } return surface; } +QSurface *create_surface_with_same_format(const QSurface *surface) +{ + return create_surface(surface->format()); +} + QOpenGLContext *create_context(const QSurface *surface) { QOpenGLContext *context = new QOpenGLContext; @@ -35,3 +43,8 @@ bool make_current(QOpenGLContext *context, QSurface *surface) { return context->makeCurrent(surface); } + +void delete_context(QOpenGLContext *context) +{ + delete context; +}