]> git.sesse.net Git - nageru/blob - context.cpp
Initial checkin.
[nageru] / context.cpp
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 #include <QOpenGLContext>
5 #include <QOffscreenSurface>
6 #include <QWindow>
7
8 QSurface *create_surface(const QSurfaceFormat &format)
9 {
10         QOffscreenSurface *surface = new QOffscreenSurface;
11         surface->setFormat(format);
12 //      QWindow *surface = new QWindow;
13         surface->create();
14         if (!surface->isValid()) {
15                 printf("ERROR: surface not valid!\n");
16 //              abort();
17         }
18         return surface;
19 }
20
21 QOpenGLContext *create_context()
22 {
23         QOpenGLContext *context = new QOpenGLContext;
24         context->setShareContext(QOpenGLContext::globalShareContext());
25         context->create();
26         return context;
27 }
28
29 bool make_current(QOpenGLContext *context, QSurface *surface)
30 {
31         return context->makeCurrent(surface);
32 }