new win32 deps script; using pkgconfig for openal
[chaz/yoink] / src / Moof / Video.hh
1
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
4 *
5 * vi:ts=4 sw=4 tw=75
6 *
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
9 *
10 **************************************************************************/
11
12 #ifndef _MOOF_VIDEO_HH_
13 #define _MOOF_VIDEO_HH_
14
15 #include <string>
16
17 #include <boost/shared_ptr.hpp>
18 #include <SDL/SDL.h>
19
20 #include <Moof/Backend.hh>
21
22
23 namespace Mf {
24
25
26 class Settings;
27
28 class Video;
29 typedef boost::shared_ptr<Video> VideoP;
30
31
32 class Video
33 {
34 public:
35
36 struct Attributes
37 {
38 // OpenGL attributes
39 int colorBuffer[4]; // rgba
40 int frameBuffer;
41 bool doubleBuffer;
42 int depthBuffer;
43 int stencilBuffer;
44 int accumBuffer[4]; // rgba
45 bool stereo;
46 int multisampleBuffers;
47 int multisampleSamples;
48 bool swapControl;
49 bool hardwareOnly;
50
51 // Window attributes
52 std::string caption;
53 std::string icon;
54 int mode[3]; // width, height, bpp
55 bool fullscreen;
56 bool resizable;
57 bool cursorVisible;
58 bool cursorGrab;
59
60 Attributes();
61 Attributes(const Settings& settings);
62
63 private:
64
65 void init();
66
67 Backend mBackend;
68 };
69
70
71 static VideoP alloc(const Attributes& attribs)
72 {
73 return VideoP(new Video(attribs));
74 }
75
76 Video();
77 explicit Video(const Attributes& attribs);
78 ~Video();
79
80 void setVideoMode(const int mode[3]);
81 Attributes attributes() const;
82
83 void resize(int width, int height);
84 bool iconify();
85
86 void setCaption(const std::string& caption);
87 std::string getCaption() const;
88
89 const std::string& getIcon() const;
90
91 void setFull(bool full);
92 void toggleFull();
93 bool isFull() const;
94
95 void setCursorVisible(bool hasCursor);
96 void toggleCursorVisible();
97 bool isCursorVisible() const;
98
99 void setResizable(bool resizable);
100 void toggleResizable();
101 bool isResizable() const;
102
103 void setCursorGrab(bool cursorGrab);
104 void toggleCursorGrab();
105 bool isCursorGrab() const;
106
107 void swap();
108
109 int getWidth() const;
110 int getHeight() const;
111
112 void makeCurrent() const;
113
114 static Video* current()
115 {
116 return gCurrentVideo;
117 }
118
119 private:
120
121 void init();
122
123 void recreateContext();
124 void setOpenGLAttributes();
125
126 void setIcon();
127
128 // TODO this implementation should be hidden
129
130 SDL_Surface* mContext;
131 unsigned mFlags;
132 Attributes mAttribs;
133
134 static Video* gCurrentVideo;
135 };
136
137
138 } // namespace Mf
139
140 #endif // _MOOF_VIDEO_HH_
141
This page took 0.040109 seconds and 4 git commands to generate.