Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXGLContext.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * G L C o n t e x t C l a s s *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2000,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXGLContext.h,v 1.14 2006/01/22 17:58:02 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXGLCONTEXT_H
25 #define FXGLCONTEXT_H
26 
27 ////////////////////////////// UNDER DEVELOPMENT //////////////////////////////
28 
29 namespace FX {
30 
31 class FXApp;
32 class FXDrawable;
33 class FXGLVisual;
34 
35 
36 /**
37 * A GL context is an object representing the OpenGL state information.
38 * Multiple GL context may share display lists to conserve memory.
39 * When drawing multiple windows, it may be advantageous to share not only
40 * display lists, but also GL contexts. Since the GL context is created
41 * for a certain frame-buffer configuration, sharing of GL contexts is
42 * only possible if the windows sharing the GL context all have the same
43 * GL visual.
44 * However, display lists may be shared between different GL contexts.
45 */
46 class FXAPI FXGLContext : public FXId {
48 private:
49  FXGLVisual *visual; // Visual for this context
50  FXDrawable *surface; // Drawable context is locked on
51  FXGLContext *sgnext; // Share group next in share list
52  FXGLContext *sgprev; // Share group previous in share list
53 protected:
54  void *ctx; // GL Context
55 protected:
56  FXGLContext():visual(NULL),surface(NULL),sgnext(NULL),sgprev(NULL),ctx(NULL){}
57 private:
58  FXGLContext(const FXGLContext&);
59  FXGLContext &operator=(const FXGLContext&);
60 public:
61 
62  /**
63  * Construct an OpenGL context with its own private display list.
64  */
65  FXGLContext(FXApp* a,FXGLVisual *vis);
66 
67  /**
68  * Construct an OpenGL context sharing display lists with an existing GL context.
69  */
70  FXGLContext(FXApp* a,FXGLVisual *vis,FXGLContext *shared);
71 
72  /// Return TRUE if it is sharing display lists
73  FXbool isShared() const;
74 
75  /// Get the visual
76  FXGLVisual* getVisual() const { return visual; }
77 
78  /// Create context
79  virtual void create();
80 
81  /// Detach the server-side resources for this window
82  virtual void detach();
83 
84  /// Destroy the server-side resources for this window
85  virtual void destroy();
86 
87  /// Make OpenGL context current prior to performing OpenGL commands
88  FXbool begin(FXDrawable *drawable);
89 
90  /// Make OpenGL context non current
91  FXbool end();
92 
93  /// Swap front and back buffer
94  void swapBuffers();
95 
96  /// Copy part of backbuffer to front buffer [Mesa]
97  void swapSubBuffers(FXint x,FXint y,FXint w,FXint h);
98 
99  /// Save object to stream
100  virtual void save(FXStream& store) const;
101 
102  /// Load object from stream
103  virtual void load(FXStream& store);
104 
105  /// Destructor
106  virtual ~FXGLContext();
107  };
108 
109 }
110 
111 #endif
112 
#define FXAPI
Definition: fxdefs.h:122
FXuchar FXbool
Definition: fxdefs.h:386
Application Object.
Definition: FXApp.h:158
#define NULL
Definition: fxdefs.h:41
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:99
Encapsulates server side resource.
Definition: FXId.h:37
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:390
A GL context is an object representing the OpenGL state information.
Definition: FXGLContext.h:46
Visual describes pixel format of a drawable.
Definition: FXGLVisual.h:44
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
Drawable is an abstract base class for any surface that can be drawn upon, such as a FXWindow...
Definition: FXDrawable.h:41

Copyright © 1997-2005 Jeroen van der Zijp