|
1 | | -/************************************************************************************************** |
2 | | - * THE OMEGA LIB PROJECT |
3 | | - *------------------------------------------------------------------------------------------------- |
4 | | - * Copyright 2010-2015 Electronic Visualization Laboratory, University of Illinois at Chicago |
5 | | - * Authors: |
6 | | - * Alessandro Febretti [email protected] |
7 | | - *------------------------------------------------------------------------------------------------- |
8 | | - * Copyright (c) 2010-2015, Electronic Visualization Laboratory, University of Illinois at Chicago |
9 | | - * All rights reserved. |
10 | | - * Redistribution and use in source and binary forms, with or without modification, are permitted |
11 | | - * provided that the following conditions are met: |
12 | | - * |
13 | | - * Redistributions of source code must retain the above copyright notice, this list of conditions |
14 | | - * and the following disclaimer. Redistributions in binary form must reproduce the above copyright |
15 | | - * notice, this list of conditions and the following disclaimer in the documentation and/or other |
16 | | - * materials provided with the distribution. |
17 | | - * |
18 | | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR |
19 | | - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
20 | | - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
21 | | - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
22 | | - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
23 | | - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
24 | | - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
25 | | - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | | - *************************************************************************************************/ |
27 | 1 | /****************************************************************************** |
28 | 2 | * THE OMEGA LIB PROJECT |
29 | 3 | *----------------------------------------------------------------------------- |
@@ -82,44 +56,50 @@ typedef struct GLEWContextStruct GLEWContext; |
82 | 56 |
|
83 | 57 | namespace omega |
84 | 58 | { |
85 | | - /////////////////////////////////////////////////////////////////////////////////////////////// |
86 | | - class OMEGA_API GpuContext: public ReferenceType |
87 | | - { |
88 | | - public: |
89 | | - static const unsigned int MaxContexts = 64; |
90 | | - enum TextureUnit { |
91 | | - TextureUnitInvalid = 0, |
92 | | - TextureUnit0 = GL_TEXTURE0, |
93 | | - TextureUnit1 = GL_TEXTURE1, |
94 | | - TextureUnit2 = GL_TEXTURE2, |
95 | | - TextureUnit3 = GL_TEXTURE3 }; |
| 59 | + /////////////////////////////////////////////////////////////////////////// |
| 60 | + class OMEGA_API GpuContext: public ReferenceType |
| 61 | + { |
| 62 | + public: |
| 63 | + static const unsigned int MaxContexts = 64; |
| 64 | + enum TextureUnit { |
| 65 | + TextureUnitInvalid = 0, |
| 66 | + TextureUnit0 = GL_TEXTURE0, |
| 67 | + TextureUnit1 = GL_TEXTURE1, |
| 68 | + TextureUnit2 = GL_TEXTURE2, |
| 69 | + TextureUnit3 = GL_TEXTURE3 }; |
96 | 70 |
|
97 | | - GpuContext(bool initializeGlew = true); |
98 | | - ~GpuContext(); |
| 71 | + //! Initializes a GPU context. If the passed GLEW context is null, |
| 72 | + //! a glew context will be created internally and GLEW will be |
| 73 | + //! initialized by this contstructor. |
| 74 | + //! @remarks This method needs to be called from within a valid OpenGL |
| 75 | + //! context. |
| 76 | + GpuContext(GLEWContext* ctx = NULL); |
| 77 | + ~GpuContext(); |
99 | 78 |
|
100 | | - uint getId() { return myId; } |
101 | | - GLEWContext* getGlewContext() { return myGlewContext; } |
| 79 | + uint getId() { return myId; } |
| 80 | + GLEWContext* getGlewContext() { return myGlewContext; } |
102 | 81 | void makeCurrent(); |
103 | 82 | //void setGlewContext(GLEWContext* ctx) { myGlewContext = ctx; } |
104 | 83 |
|
105 | | - private: |
106 | | - static uint mysNumContexts; |
107 | | - static Lock mysContextLock; |
| 84 | + private: |
| 85 | + static uint mysNumContexts; |
| 86 | + static Lock mysContextLock; |
108 | 87 |
|
109 | | - uint myId; |
110 | | - GLEWContext* myGlewContext; |
111 | | - }; |
| 88 | + uint myId; |
| 89 | + GLEWContext* myGlewContext; |
| 90 | + bool myOwnGlewContext; |
| 91 | + }; |
112 | 92 |
|
113 | | - /////////////////////////////////////////////////////////////////////////////////////////////// |
114 | | - class OMEGA_API GpuResource: public ReferenceType |
115 | | - { |
116 | | - public: |
117 | | - GpuResource(GpuContext* ctx): myContext(ctx) { } |
118 | | - GpuContext* getContext() { return myContext; } |
119 | | - virtual void dispose() = 0; |
120 | | - private: |
121 | | - GpuContext* myContext; |
122 | | - }; |
| 93 | + /////////////////////////////////////////////////////////////////////////////////////////////// |
| 94 | + class OMEGA_API GpuResource: public ReferenceType |
| 95 | + { |
| 96 | + public: |
| 97 | + GpuResource(GpuContext* ctx): myContext(ctx) { } |
| 98 | + GpuContext* getContext() { return myContext; } |
| 99 | + virtual void dispose() = 0; |
| 100 | + private: |
| 101 | + GpuContext* myContext; |
| 102 | + }; |
123 | 103 | }; // namespace omega |
124 | 104 |
|
125 | 105 | #endif |
0 commit comments