aboutsummaryrefslogtreecommitdiff
path: root/util/fbcompose/OpenGLScreen.hh
diff options
context:
space:
mode:
authorGediminas Liktaras <gliktaras@gmail.com>2011-12-08 13:34:09 (GMT)
committerPaul Tagliamonte <paultag@fluxbox.org>2011-12-10 16:13:19 (GMT)
commitcd339169d1961eb508ea89cee2609ec6d0fc0c15 (patch)
tree01acd158a03fb17a72e067ff0b36701da75e49dc /util/fbcompose/OpenGLScreen.hh
parent85ac5c4b2c6a526992f483a6e91867dc2f82a19e (diff)
downloadfluxbox_paul-cd339169d1961eb508ea89cee2609ec6d0fc0c15.zip
fluxbox_paul-cd339169d1961eb508ea89cee2609ec6d0fc0c15.tar.bz2
fbcompose - A compositing addon for fluxbox window manager.
fbcompose(1) is an optional compositing addon for fluxbox window manager. It augments fluxbox with a number of graphical features. Most notably, fbcompose allows fluxbox to properly display applications that require compositing (docky, for example), adds support for true window transparency (as opposed to fluxbox's pseudo transparency) and provides a plugin framework to extend the compositor's functionality. As this is still a beta version of the compositor, the bugs are likely.
Diffstat (limited to 'util/fbcompose/OpenGLScreen.hh')
-rw-r--r--util/fbcompose/OpenGLScreen.hh297
1 files changed, 297 insertions, 0 deletions
diff --git a/util/fbcompose/OpenGLScreen.hh b/util/fbcompose/OpenGLScreen.hh
new file mode 100644
index 0000000..1ab0608
--- /dev/null
+++ b/util/fbcompose/OpenGLScreen.hh
@@ -0,0 +1,297 @@
1/** OpenGLScreen.hh file for the fluxbox compositor. */
2
3// Copyright (c) 2011 Gediminas Liktaras (gliktaras at gmail dot com)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21// THE SOFTWARE.
22
23
24#ifndef FBCOMPOSITOR_XRENDERAUTOSCREEN_HH
25#define FBCOMPOSITOR_XRENDERAUTOSCREEN_HH
26
27
28#include "BaseScreen.hh"
29#include "OpenGLPlugin.hh"
30#include "OpenGLShaders.hh"
31#include "OpenGLTexPartitioner.hh"
32#include "OpenGLWindow.hh"
33
34#include <GL/glxew.h>
35#include <GL/glx.h>
36
37
38namespace FbCompositor {
39
40 class BaseCompWindow;
41 class CompositorConfig;
42
43
44 /**
45 * Manages screen in OpenGL rendering mode.
46 */
47 class OpenGLScreen : public BaseScreen {
48 public:
49 //--- CONSTRUCTORS AND DESTRUCTORS -------------------------------------
50
51 /** Constructor. */
52 OpenGLScreen(int screen_number, const CompositorConfig &config);
53
54 /** Destructor. */
55 ~OpenGLScreen();
56
57
58 //--- OTHER INITIALIZATION ---------------------------------------------
59
60 /** Initializes the screen's plugins. */
61 void initPlugins(const CompositorConfig &config);
62
63
64 //--- DEFAULT OPENGL OBJECT ACCESSORS ----------------------------------
65
66 /** \returns the default element buffer (rectangle, corners in order of NW, NE, SW, SE). */
67 OpenGLBufferPtr defaultElementBuffer() const;
68
69 /** \returns the default primitive position buffer (four corners of the root window). */
70 OpenGLBufferPtr defaultPrimPosBuffer() const;
71
72 /** \returns the default texture position buffer (the whole texture). */
73 OpenGLBufferPtr defaultTexCoordBuffer() const;
74
75
76 /** \returns the default black texture. */
77 OpenGL2DTexturePtr blackTexture() const;
78
79 /** \returns the default white texture. */
80 OpenGL2DTexturePtr whiteTexture() const;
81
82
83 //--- OTHER ACCESSORS --------------------------------------------------
84
85 /** \return the main GLX context. */
86 GLXContext context() const;
87
88 /** \returns the main GLXFBConfig. */
89 GLXFBConfig fbConfig() const;
90
91 /** \returns maximum supported texture size. */
92 int maxTextureSize() const;
93
94
95 //--- SCREEN MANIPULATION ----------------------------------------------
96
97 /** Notifies the screen of the background change. */
98 void setRootPixmapChanged();
99
100 /** Notifies the screen of a root window change. */
101 void setRootWindowSizeChanged();
102
103
104 //--- SCREEN RENDERING -------------------------------------------------
105
106 /** Renders the screen's contents. */
107 void renderScreen();
108
109
110 protected:
111 //--- WINDOW MANIPULATION ----------------------------------------------
112
113 /** Creates a window object from its XID. */
114 BaseCompWindow *createWindowObject(Window window);
115
116
117 private:
118 //--- INITIALIZATION FUNCTIONS -----------------------------------------
119
120 /** Creates OpenGL resources. */
121 void createResources();
122
123 /** Early initialization of GLX function pointers. */
124 void earlyInitGLXPointers();
125
126 /** Finds the maximum usable texture size. */
127 void findMaxTextureSize();
128
129 /** Finishes the initialization of the rendering context and surface. */
130 void finishRenderingInit();
131
132 /** Initializes GLEW. */
133 void initGlew();
134
135 /** Finish plugin initialization. */
136 void initPlugins();
137
138 /** Initializes the rendering context. */
139 void initRenderingContext();
140
141 /** Initializes the rendering surface. */
142 void initRenderingSurface();
143
144
145 //--- OTHER FUNCTIONS --------------------------------------------------
146
147 /** Renews the background texture. */
148 void updateBackgroundTexture();
149
150 /** React to the geometry change of the root window. */
151 void updateOnRootWindowResize();
152
153
154 //--- RENDERING FUNCTIONS ----------------------------------------------
155
156 /** Render the desktop background. */
157 void renderBackground();
158
159 /** Perform extra rendering jobs from plugins. */
160 void renderExtraJobs();
161
162 /** Render the reconfigure rectangle. */
163 void renderReconfigureRect();
164
165 /** Render a particular window onto the screen. */
166 void renderWindow(OpenGLWindow &window);
167
168
169 /** Execute multiple rendering jobs. */
170 void executeMultipleJobs(OpenGLPlugin *plugin, const std::vector<OpenGLRenderingJob> &jobs);
171
172 /** Execute a given rendering job. */
173 void executeRenderingJob(const OpenGLRenderingJob &job);
174
175 /** Render something onto the screen. */
176 void render(GLenum rendering_mode, OpenGLBufferPtr prim_pos_buffer,
177 OpenGLBufferPtr main_tex_coord_buffer, OpenGL2DTexturePtr main_texture,
178 OpenGLBufferPtr shape_tex_coord_buffer, OpenGL2DTexturePtr shape_texture,
179 OpenGLBufferPtr element_buffer, GLuint element_count, GLfloat alpha);
180
181
182 //--- MAIN RENDERING-RELATED VARIABLES ---------------------------------
183
184 /** The main FBConfig. */
185 GLXFBConfig m_fb_config;
186
187 /** The GLX context. */
188 GLXContext m_glx_context;
189
190 /** Shaders. */
191 OpenGLShaderProgramPtr m_shader_program;
192
193
194 /** GLX handle to the rendering window. */
195 GLXWindow m_glx_rendering_window;
196
197 /** Rendering window. */
198 Window m_rendering_window;
199
200 /** Whether the root window has changed since the last update. */
201 bool m_root_window_changed;
202
203
204 //--- DESKTOP BACKGROUND RELATED ---------------------------------------
205
206 /** The background texture. */
207 OpenGL2DTexturePartitionPtr m_bg_texture;
208
209 /** Position buffers of the background texture partitions. */
210 std::vector<OpenGLBufferPtr> m_bg_pos_buffers;
211
212 /** Whether the background changed since the last update. */
213 bool m_bg_changed;
214
215
216 //--- DEFAULT OPENGL ELEMENTS ------------------------------------------
217
218 /** Default element buffer. */
219 OpenGLBufferPtr m_default_element_buffer;
220
221 /** Default primitive position buffer. */
222 OpenGLBufferPtr m_default_prim_pos_buffer;
223
224 /** Default texture position buffer. */
225 OpenGLBufferPtr m_default_tex_coord_buffer;
226
227
228 /** Default black texture. */
229 OpenGL2DTexturePtr m_black_texture;
230
231 /** Default white texture. */
232 OpenGL2DTexturePtr m_white_texture;
233
234
235 //--- RESIZE FRAME RELATED ---------------------------------------------
236
237 /** The reconfigure rectangle element buffer. */
238 OpenGLBufferPtr m_rec_rect_element_buffer;
239
240 /** The reconfigure rectangle primitive position array buffer. */
241 OpenGLBufferPtr m_rec_rect_line_pos_buffer;
242
243
244 //--- OTHER VARIABLES --------------------------------------------------
245
246 /** Whether we have a double-buffered window. */
247 bool m_have_double_buffering;
248
249 /** Maximum texture size. */
250 int m_max_texture_size;
251 };
252
253
254 //--- INLINE FUNCTIONS -----------------------------------------------------
255
256 // Returns the default black texture.
257 inline OpenGL2DTexturePtr OpenGLScreen::blackTexture() const {
258 return m_black_texture;
259 }
260
261 // Return the main GLX context.
262 inline GLXContext OpenGLScreen::context() const {
263 return m_glx_context;
264 }
265
266 // Returns the default element buffer.
267 inline OpenGLBufferPtr OpenGLScreen::defaultElementBuffer() const {
268 return m_default_element_buffer;
269 }
270
271 // Returns the default primitive position buffer.
272 inline OpenGLBufferPtr OpenGLScreen::defaultPrimPosBuffer() const {
273 return m_default_prim_pos_buffer;
274 }
275
276 // Returns the default texture position buffer.
277 inline OpenGLBufferPtr OpenGLScreen::defaultTexCoordBuffer() const {
278 return m_default_tex_coord_buffer;
279 }
280
281 // Returns the main GLXFBConfig.
282 inline GLXFBConfig OpenGLScreen::fbConfig() const {
283 return m_fb_config;
284 }
285
286 // Returns maximum supported texture size.
287 inline int OpenGLScreen::maxTextureSize() const {
288 return m_max_texture_size;
289 }
290
291 // Returns the default white texture.
292 inline OpenGL2DTexturePtr OpenGLScreen::whiteTexture() const {
293 return m_white_texture;
294 }
295}
296
297#endif // FBCOMPOSITOR_XRENDERAUTOSCREEN_HH