|
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 | | -#include "omega/GpuResource.h" |
28 | | -#include "omega/glheaders.h" |
29 | | -using namespace omega; |
30 | | - |
31 | | -uint GpuContext::mysNumContexts = 0; |
32 | | -Lock GpuContext::mysContextLock = Lock(); |
33 | | - |
34 | | -/////////////////////////////////////////////////////////////////////////////// |
35 | | -GpuContext::GpuContext() |
36 | | -{ |
37 | | - mysContextLock.lock(); |
38 | | - myId = mysNumContexts++; |
39 | | - |
40 | | - // Initialize Glew |
41 | | - myGlewContext = new GLEWContext(); |
42 | | - glewSetContext(myGlewContext); |
43 | | - glewInit(); |
44 | | - |
45 | | - mysContextLock.unlock(); |
46 | | -} |
47 | | - |
48 | | -/////////////////////////////////////////////////////////////////////////////// |
49 | | -GpuContext::~GpuContext() |
50 | | -{ |
51 | | - delete myGlewContext; |
52 | | - myGlewContext = NULL; |
53 | | -} |
| 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 | +#include "omega/GpuResource.h" |
| 28 | +#include "omega/glheaders.h" |
| 29 | +using namespace omega; |
| 30 | + |
| 31 | +uint GpuContext::mysNumContexts = 0; |
| 32 | +Lock GpuContext::mysContextLock = Lock(); |
| 33 | + |
| 34 | +/////////////////////////////////////////////////////////////////////////////// |
| 35 | +GpuContext::GpuContext(bool initializeGlew) |
| 36 | +{ |
| 37 | + mysContextLock.lock(); |
| 38 | + myId = mysNumContexts++; |
| 39 | + |
| 40 | + // Initialize Glew |
| 41 | + myGlewContext = new GLEWContext(); |
| 42 | + glewSetContext(myGlewContext); |
| 43 | + if(initializeGlew) |
| 44 | + { |
| 45 | + oflog(Debug, "[GpuContext::GpuContext] <%1%> Glew init", %myId); |
| 46 | + glewInit(); |
| 47 | + } |
| 48 | + |
| 49 | + mysContextLock.unlock(); |
| 50 | +} |
| 51 | + |
| 52 | +/////////////////////////////////////////////////////////////////////////////// |
| 53 | +void GpuContext::makeCurrent() |
| 54 | +{ |
| 55 | + oassert(myGlewContext != NULL); |
| 56 | + glewSetContext(myGlewContext); |
| 57 | +} |
| 58 | + |
| 59 | +/////////////////////////////////////////////////////////////////////////////// |
| 60 | +GpuContext::~GpuContext() |
| 61 | +{ |
| 62 | + delete myGlewContext; |
| 63 | + myGlewContext = NULL; |
| 64 | +} |
0 commit comments