]> git.tdb.fi Git - libs/gui.git/blob - source/glcontext.h
297bc34b4a4f7c40fe3da8cbefbc258552ae8999
[libs/gui.git] / source / glcontext.h
1 /* $Id$
2
3 This file is part of libmspgbase
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GBASE_GLCONTEXT_H_
9 #define MSP_GBASE_GLCONTEXT_H_
10
11 #ifndef WIN32
12 #include <GL/glx.h>
13 #endif
14 #include "types.h"
15
16 namespace Msp {
17 namespace Graphics {
18
19 class Display;
20
21 struct GLOptions
22 {
23         bool alpha;
24         bool stencil;
25         bool doublebuffer;
26         unsigned multisample;
27
28         GLOptions();
29 };
30
31 class GLContext
32 {
33 private:
34 #ifdef WIN32
35         typedef HGLRC Context;
36 #else
37         typedef GLXContext Context;
38 #endif
39
40         Display &display;
41         Window &window;
42         Context context;
43 #ifndef WIN32
44         WindowHandle subwnd;
45 #endif
46
47 public:
48         GLContext(Window &wnd, const GLOptions &opts=GLOptions());
49         ~GLContext();
50
51         void swap_buffers();
52 private:
53         void window_resized(unsigned, unsigned);
54 };
55
56 } // namespace Graphics
57 } // namespace Msp
58
59 #endif