Skip to content

Commit 5da8d77

Browse files
febretrenambot-uic
authored andcommitted
FIX: #156 - Equalizer crash due to wrong glew initialization
1 parent 1f49f15 commit 5da8d77

File tree

4 files changed

+73
-57
lines changed

4 files changed

+73
-57
lines changed

include/omega/GpuResource.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ namespace omega
9494
TextureUnit2 = GL_TEXTURE2,
9595
TextureUnit3 = GL_TEXTURE3 };
9696

97-
GpuContext();
97+
GpuContext(bool initializeGlew = true);
9898
~GpuContext();
9999

100100
uint getId() { return myId; }
101-
//GLEWContext* getGlewContext() { return myGlewContext; }
101+
GLEWContext* getGlewContext() { return myGlewContext; }
102+
void makeCurrent();
102103
//void setGlewContext(GLEWContext* ctx) { myGlewContext = ctx; }
103104

104105
private:

src/displaySystems/Equalizer/PipeImpl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ PipeImpl::~PipeImpl()
4747
/////////////////////////////////////////////////////////////////////////////////////////////////////
4848
bool PipeImpl::configInit(const uint128_t& initID)
4949
{
50-
myGpuContext = new GpuContext();
50+
// false = do not initialize GLEW in GpuContext. Equalizer takes care of Glew initialization.
51+
myGpuContext = new GpuContext(false);
5152
return Pipe::configInit(initID);
5253
}

src/displaySystems/Equalizer/WindowImpl.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ bool WindowImpl::configInit(const uint128_t& initID)
8787
sInitLock.lock();
8888
bool res = Window::configInit(initID);
8989
sInitLock.unlock();
90+
oflog(Debug, "[WindowImpl::configInit] <%1%> done", %initID);
9091
return res;
9192
}
9293

@@ -207,7 +208,9 @@ void WindowImpl::frameStart(const uint128_t& frameID, const uint32_t frameNumber
207208
// NOTE: getting the glew context from the first window is correct since all
208209
// windows attached to the same pape share the same Glew (and OpenGL) contexts.
209210
// NOTE2: do NOT remove these two lines. rendering explodes if you do.
210-
const GLEWContext* glewc = this->glewGetContext();
211+
const GLEWContext* glewc = myRenderer->getGpuContext()->getGlewContext();
212+
myRenderer->getGpuContext()->makeCurrent();
213+
oassert(glewc != NULL);
211214
//myRenderer->getGpuContext()->setGlewContext(glewc);
212215
glewSetContext(glewc);
213216
}

src/omega/GpuResource.cpp

Lines changed: 64 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,64 @@
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

Comments
 (0)