Commit 0be65bc3 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Merge branch 'tgt-dll' into 'development'

Tgt Dll
parents da038689 464f1ff4
...@@ -27,11 +27,11 @@ ...@@ -27,11 +27,11 @@
#include "tgt/assert.h" #include "tgt/assert.h"
#include "tgt/exception.h" #include "tgt/exception.h"
#include "tgt/glcanvas.h" #include "tgt/glcanvas.h"
#include "tgt/glcontextmanager.h"
#include "tgt/gpucapabilities.h" #include "tgt/gpucapabilities.h"
#include "tgt/shadermanager.h" #include "tgt/shadermanager.h"
#include "tgt/qt/qtapplication.h" #include "tgt/qt/qtapplication.h"
#include "tgt/qt/qtthreadedcanvas.h" #include "tgt/qt/qtthreadedcanvas.h"
#include "tgt/qt/qtcontextmanager.h"
#include "tbb/compat/thread" #include "tbb/compat/thread"
#include "application/campvispainter.h" #include "application/campvispainter.h"
...@@ -61,7 +61,7 @@ namespace campvis { ...@@ -61,7 +61,7 @@ namespace campvis {
QApplication::setAttribute(Qt::AA_X11InitThreads); QApplication::setAttribute(Qt::AA_X11InitThreads);
_mainWindow = new MainWindow(this); _mainWindow = new MainWindow(this);
tgt::QtContextManager::init(); tgt::GlContextManager::init();
OpenGLJobProcessor::init(); OpenGLJobProcessor::init();
SimpleJobProcessor::init(); SimpleJobProcessor::init();
...@@ -85,23 +85,14 @@ namespace campvis { ...@@ -85,23 +85,14 @@ namespace campvis {
void CampVisApplication::init() { void CampVisApplication::init() {
tgtAssert(_initialized == false, "Tried to initialize CampVisApplication twice."); tgtAssert(_initialized == false, "Tried to initialize CampVisApplication twice.");
// parse argument list and create pipelines
QStringList pipelinesToAdd = this->arguments();
for (int i = 1; i < pipelinesToAdd.size(); ++i) {
DataContainer* dc = createAndAddDataContainer("DataContainer #" + StringUtils::toString(_dataContainers.size() + 1));
AbstractPipeline* p = PipelineFactory::getRef().createPipeline(pipelinesToAdd[i].toStdString(), dc);
if (p != 0)
addPipeline(pipelinesToAdd[i].toStdString(), p);
}
// Init TGT // Init TGT
tgt::InitFeature::Features featureset = tgt::InitFeature::ALL; tgt::InitFeature::Features featureset = tgt::InitFeature::ALL;
tgt::init(featureset); tgt::init(featureset);
LogMgr.getConsoleLog()->addCat("", true); LogMgr.getConsoleLog()->addCat("", true);
// create a local OpenGL context and init GL // create a local OpenGL context and init GL
_localContext = tgt::GlContextManager::getRef().createContext("AppContext", "", tgt::ivec2(16, 16)); _localContext = new QtThreadedCanvas("", tgt::ivec2(16, 16));
tgtAssert(_localContext != 0, "Could not create local OpenGL context"); tgt::GlContextManager::getRef().registerContextAndInitGlew(_localContext);
tgt::GLContextScopedLock lock(_localContext); tgt::GLContextScopedLock lock(_localContext);
...@@ -143,18 +134,18 @@ namespace campvis { ...@@ -143,18 +134,18 @@ namespace campvis {
LERROR("Your system does not support GLSL Shader Version 3.30, which is mandatory. CAMPVis will probably not work as intended."); LERROR("Your system does not support GLSL Shader Version 3.30, which is mandatory. CAMPVis will probably not work as intended.");
} }
// init pipeline first GLJobProc.start();
for (std::vector<AbstractPipeline*>::iterator it = _pipelines.begin(); it != _pipelines.end(); ++it) { GLJobProc.registerContext(_localContext);
(*it)->init();
}
// Now init painters: // parse argument list and create pipelines
for (std::vector< std::pair<AbstractPipeline*, CampVisPainter*> >::iterator it = _visualizations.begin(); it != _visualizations.end(); ++it) { QStringList pipelinesToAdd = this->arguments();
it->second->init(); for (int i = 1; i < pipelinesToAdd.size(); ++i) {
DataContainer* dc = createAndAddDataContainer("DataContainer #" + StringUtils::toString(_dataContainers.size() + 1));
AbstractPipeline* p = PipelineFactory::getRef().createPipeline(pipelinesToAdd[i].toStdString(), dc);
if (p != 0)
addPipeline(pipelinesToAdd[i].toStdString(), p);
} }
GLJobProc.start();
GLJobProc.registerContext(_localContext);
_initialized = true; _initialized = true;
} }
...@@ -188,7 +179,7 @@ namespace campvis { ...@@ -188,7 +179,7 @@ namespace campvis {
OpenGLJobProcessor::deinit(); OpenGLJobProcessor::deinit();
PipelineFactory::deinit(); PipelineFactory::deinit();
tgt::QtContextManager::deinit(); tgt::GlContextManager::deinit();
tgt::deinit(); tgt::deinit();
// MainWindow dtor needs a valid CampVisApplication, so we need to call it here instead of during destruction. // MainWindow dtor needs a valid CampVisApplication, so we need to call it here instead of during destruction.
...@@ -214,30 +205,8 @@ namespace campvis { ...@@ -214,30 +205,8 @@ namespace campvis {
void CampVisApplication::addPipeline(const std::string& name, AbstractPipeline* pipeline) { void CampVisApplication::addPipeline(const std::string& name, AbstractPipeline* pipeline) {
tgtAssert(pipeline != 0, "Pipeline must not be 0."); tgtAssert(pipeline != 0, "Pipeline must not be 0.");
// if CAMPVis is already fully initialized, we need to temporarily shut down its
// OpenGL job processor, since we need to create a new context.
if (_initialized) {
GLJobProc.pause();
{
tgt::QtThreadedCanvas* canvas = dynamic_cast<tgt::QtThreadedCanvas*>(tgt::GlContextManager::getRef().createContext(name, "CAMPVis", tgt::ivec2(512, 512)));
tgtAssert(canvas != 0, "Dynamic cast failed. This should not be the case, since we initialized the GlContextManager singleton with a QtContextManager.");
tgt::GLContextScopedLock lock(canvas);
addPipelineImpl(canvas, name, pipeline);
}
GLJobProc.resume();
}
else {
tgt::QtThreadedCanvas* canvas = dynamic_cast<tgt::QtThreadedCanvas*>(tgt::GlContextManager::getRef().createContext(name, "CAMPVis", tgt::ivec2(512, 512)));
tgtAssert(canvas != 0, "Dynamic cast failed. This should not be the case, since we initialized the GlContextManager singleton with a QtContextManager.");
addPipelineImpl(canvas, name, pipeline);
}
s_PipelinesChanged();
}
void CampVisApplication::addPipelineImpl(tgt::QtThreadedCanvas* canvas, const std::string& name, AbstractPipeline* pipeline) {
// create canvas and painter for the pipeline and connect all together // create canvas and painter for the pipeline and connect all together
tgt::QtThreadedCanvas* canvas = new tgt::QtThreadedCanvas("CAMPVis", tgt::ivec2(512, 512));
GLJobProc.registerContext(canvas); GLJobProc.registerContext(canvas);
canvas->init(); canvas->init();
...@@ -248,17 +217,25 @@ namespace campvis { ...@@ -248,17 +217,25 @@ namespace campvis {
_visualizations.push_back(std::make_pair(pipeline, painter)); _visualizations.push_back(std::make_pair(pipeline, painter));
_pipelines.push_back(pipeline); _pipelines.push_back(pipeline);
if (_initialized) {
LGL_ERROR;
pipeline->init();
LGL_ERROR;
painter->init();
LGL_ERROR;
}
tgt::GlContextManager::getRef().releaseCurrentContext();
_mainWindow->addVisualizationPipelineWidget(name, canvas); _mainWindow->addVisualizationPipelineWidget(name, canvas);
// initialize context (GLEW) and pipeline in OpenGL thread)
GLJobProc.enqueueJob(
canvas,
makeJobOnHeap<CampVisApplication, tgt::GLCanvas*, AbstractPipeline*>(this, &CampVisApplication::initGlContextAndPipeline, canvas, pipeline),
OpenGLJobProcessor::SerialJob);
s_PipelinesChanged();
}
void CampVisApplication::initGlContextAndPipeline(tgt::GLCanvas* canvas, AbstractPipeline* pipeline) {
tgt::GlContextManager::getRef().registerContextAndInitGlew(canvas);
pipeline->init();
LGL_ERROR;
canvas->getPainter()->init();
LGL_ERROR;
// enable pipeline and invalidate all processors // enable pipeline and invalidate all processors
pipeline->setEnabled(true); pipeline->setEnabled(true);
for (std::vector<AbstractProcessor*>::const_iterator it = pipeline->getProcessors().begin(); it != pipeline->getProcessors().end(); ++it) { for (std::vector<AbstractProcessor*>::const_iterator it = pipeline->getProcessors().begin(); it != pipeline->getProcessors().end(); ++it) {
......
...@@ -130,7 +130,8 @@ namespace campvis { ...@@ -130,7 +130,8 @@ namespace campvis {
sigslot::signal0<> s_DataContainersChanged; sigslot::signal0<> s_DataContainersChanged;
private: private:
void addPipelineImpl(tgt::QtThreadedCanvas* canvas, const std::string& name, AbstractPipeline* pipeline); void initGlContextAndPipeline(tgt::GLCanvas* canvas, AbstractPipeline* pipeline);
/// All pipelines /// All pipelines
std::vector<AbstractPipeline*> _pipelines; std::vector<AbstractPipeline*> _pipelines;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "tgt/painter.h" #include "tgt/painter.h"
#include "tgt/event/eventlistener.h" #include "tgt/event/eventlistener.h"
#include "tgt/event/mouseevent.h" #include "tgt/event/mouseevent.h"
#include "tgt/qt/qtcontextmanager.h" #include "tgt/glcontextmanager.h"
#include "tgt/qt/qtthreadedcanvas.h" #include "tgt/qt/qtthreadedcanvas.h"
#include "tbb/mutex.h" #include "tbb/mutex.h"
......
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
#include "tgt/filesystem.h" #include "tgt/filesystem.h"
#include "tgt/shadermanager.h" #include "tgt/shadermanager.h"
#include "tgt/textureunit.h" #include "tgt/textureunit.h"
#include "tgt/qt/qtcontextmanager.h"
#include "tgt/qt/qtthreadedcanvas.h"
#ifdef CAMPVIS_HAS_MODULE_DEVIL #ifdef CAMPVIS_HAS_MODULE_DEVIL
#include <IL/il.h> #include <IL/il.h>
...@@ -53,7 +51,7 @@ ...@@ -53,7 +51,7 @@
#include "application/gui/datacontainertreewidget.h" #include "application/gui/datacontainertreewidget.h"
#include "application/gui/qtdatahandle.h" #include "application/gui/qtdatahandle.h"
#include "application//gui/datacontainerfileloaderwidget.h" #include "application/gui/datacontainerfileloaderwidget.h"
#include "modules/io/processors/genericimagereader.h" #include "modules/io/processors/genericimagereader.h"
#include <QFileDialog> #include <QFileDialog>
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include "sigslot/sigslot.h" #include "sigslot/sigslot.h"
#include "tgt/painter.h" #include "tgt/painter.h"
#include "tgt/qt/qtcontextmanager.h"
#include "tgt/qt/qtthreadedcanvas.h"
#include "tbb/mutex.h" #include "tbb/mutex.h"
#include "application/gui/qtdatahandle.h" #include "application/gui/qtdatahandle.h"
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include "sigslot/sigslot.h" #include "sigslot/sigslot.h"
#include "tgt/painter.h" #include "tgt/painter.h"
#include "tgt/qt/qtcontextmanager.h"
#include "tgt/qt/qtthreadedcanvas.h"
#include "tbb/mutex.h" #include "tbb/mutex.h"
#include "application/tools/bufferinglog.h" #include "application/tools/bufferinglog.h"
......
...@@ -248,8 +248,8 @@ namespace campvis { ...@@ -248,8 +248,8 @@ namespace campvis {
QLabel* lblOpacityBottom = new QLabel(tr("0%"), this); QLabel* lblOpacityBottom = new QLabel(tr("0%"), this);
_layout->addWidget(lblOpacityBottom, 3, 0, 1, 1, Qt::AlignRight); _layout->addWidget(lblOpacityBottom, 3, 0, 1, 1, Qt::AlignRight);
_canvas = dynamic_cast<tgt::QtThreadedCanvas*>(tgt::GlContextManager::getRef().createContext("tfcanvas", "", tgt::ivec2(256, 128), tgt::GLCanvas::RGBA_BUFFER, false)); _canvas = new tgt::QtThreadedCanvas("", tgt::ivec2(256, 128), tgt::GLCanvas::RGBA_BUFFER, false);
tgtAssert(_canvas != 0, "Could not cast to QtThreadedCanvas*, something is wrong here!"); tgt::GlContextManager::getRef().registerContextAndInitGlew(_canvas);
GLJobProc.registerContext(_canvas); GLJobProc.registerContext(_canvas);
_canvas->setPainter(this, false); _canvas->setPainter(this, false);
......
...@@ -229,8 +229,8 @@ namespace campvis { ...@@ -229,8 +229,8 @@ namespace campvis {
QLabel* lblOpacityBottom = new QLabel(tr("0%"), this); QLabel* lblOpacityBottom = new QLabel(tr("0%"), this);
_layout->addWidget(lblOpacityBottom, 3, 0, 1, 1, Qt::AlignRight); _layout->addWidget(lblOpacityBottom, 3, 0, 1, 1, Qt::AlignRight);
_canvas = dynamic_cast<tgt::QtThreadedCanvas*>(tgt::GlContextManager::getRef().createContext("tfcanvas ", "", tgt::ivec2(256, 128), tgt::GLCanvas::RGBA_BUFFER, false)); _canvas = new tgt::QtThreadedCanvas("", tgt::ivec2(256, 128), tgt::GLCanvas::RGBA_BUFFER, false);
tgtAssert(_canvas != 0, "Could not cast to QtThreadedCanvas*, something is wrong here!"); tgt::GlContextManager::getRef().registerContextAndInitGlew(_canvas);
GLJobProc.registerContext(_canvas); GLJobProc.registerContext(_canvas);
_canvas->setPainter(this, false); _canvas->setPainter(this, false);
......
...@@ -90,6 +90,7 @@ IF(WIN32) ...@@ -90,6 +90,7 @@ IF(WIN32)
LIST(APPEND CampvisGlobalDefinitions "-DNOMINMAX" "-D_CRT_SECURE_NO_DEPRECATE") LIST(APPEND CampvisGlobalDefinitions "-DNOMINMAX" "-D_CRT_SECURE_NO_DEPRECATE")
# Disable warnings for Microsoft compiler: # Disable warnings for Microsoft compiler:
# C4251 class needs to have dll interface (used for std classes)
# C4290: C++ exception specification ignored except to indicate a function is # C4290: C++ exception specification ignored except to indicate a function is
# not __declspec(nothrow) # not __declspec(nothrow)
# C4390: ';' : empty controlled statement found; is this the intent? # C4390: ';' : empty controlled statement found; is this the intent?
...@@ -97,7 +98,7 @@ IF(WIN32) ...@@ -97,7 +98,7 @@ IF(WIN32)
# C4503: The decorated name was longer than the compiler limit (4096), and was truncated. # C4503: The decorated name was longer than the compiler limit (4096), and was truncated.
# Occurs in AutoEvaluatePipeline due to some nested nested map-iterator-map. Could # Occurs in AutoEvaluatePipeline due to some nested nested map-iterator-map. Could
# not be deactivated locally... # not be deactivated locally...
LIST(APPEND CampvisGlobalDefinitions /wd4290 /wd4390 /wd4503) LIST(APPEND CampvisGlobalDefinitions /wd4251 /wd4290 /wd4390 /wd4503)
# enable parallel builds in Visual Studio # enable parallel builds in Visual Studio
LIST(APPEND CampvisGlobalDefinitions /MP) LIST(APPEND CampvisGlobalDefinitions /MP)
...@@ -112,6 +113,7 @@ IF(WIN32) ...@@ -112,6 +113,7 @@ IF(WIN32)
IF(CAMPVIS_SHARED_LIBS) IF(CAMPVIS_SHARED_LIBS)
# Linking against Windows DLLs requires explicit instantiation of templates # Linking against Windows DLLs requires explicit instantiation of templates
LIST(APPEND CampvisGlobalDefinitions "-DDLL_TEMPLATE_INST") LIST(APPEND CampvisGlobalDefinitions "-DDLL_TEMPLATE_INST")
LIST(APPEND CampvisGlobalDefinitions "-DCAMPVIS_DYNAMIC_LIBS")
IF(NOT CAMPVIS_GENERATE_MANIFEST) IF(NOT CAMPVIS_GENERATE_MANIFEST)
# Do not embed manifest into binaries in debug mode (slows down incremental linking) # Do not embed manifest into binaries in debug mode (slows down incremental linking)
......
...@@ -12,7 +12,14 @@ IF(TGT_WITH_WMI) ...@@ -12,7 +12,14 @@ IF(TGT_WITH_WMI)
ADD_DEFINITIONS("-DTGT_WITH_WMI") ADD_DEFINITIONS("-DTGT_WITH_WMI")
ADD_DEFINITIONS("-D_WIN32_DCOM") #< for CoInitializeSecurity() to be defined ADD_DEFINITIONS("-D_WIN32_DCOM") #< for CoInitializeSecurity() to be defined
LIST(APPEND CampvisGlobalExternalLibs "WbemUuid") LIST(APPEND CampvisGlobalExternalLibs "WbemUuid")
ENDIF(TGT_WITH_WMI) ENDIF(TGT_WITH_WMI)
IF(CAMPVIS_SHARED_LIBS)
SET(BUILD_SHARED_LIBS TRUE)
IF(MSVC)
ADD_DEFINITIONS("-DTGT_BUILD_DLL")
ENDIF()
ENDIF()
# headers # headers
...@@ -74,14 +81,12 @@ IF(TGT_WITH_QT) ...@@ -74,14 +81,12 @@ IF(TGT_WITH_QT)
LIST(APPEND TGT_HEADERS LIST(APPEND TGT_HEADERS
qt/qtapplication.h qt/qtapplication.h
qt/qtcanvas.h qt/qtcanvas.h
qt/qtcontextmanager.h
qt/qtthreadedcanvas.h qt/qtthreadedcanvas.h
qt/qttimer.h) qt/qttimer.h)
LIST(APPEND TGT_SOURCES LIST(APPEND TGT_SOURCES
qt/qtapplication.cpp qt/qtapplication.cpp
qt/qtcanvas.cpp qt/qtcanvas.cpp
qt/qtcontextmanager.cpp
qt/qtthreadedcanvas.cpp qt/qtthreadedcanvas.cpp
qt/qttimer.cpp) qt/qttimer.cpp)
ENDIF(TGT_WITH_QT) ENDIF(TGT_WITH_QT)
...@@ -92,9 +97,6 @@ ENDIF(TGT_WITH_QT) ...@@ -92,9 +97,6 @@ ENDIF(TGT_WITH_QT)
################################################################################ ################################################################################
ADD_LIBRARY(tgt ${TGT_SOURCES} ${TGT_HEADERS}) ADD_LIBRARY(tgt ${TGT_SOURCES} ${TGT_HEADERS})
ADD_DEFINITIONS(${CampvisGlobalDefinitions} ${CampvisModulesDefinitions} ${QT_DEFINITIONS}) ADD_DEFINITIONS(${CampvisGlobalDefinitions} ${CampvisModulesDefinitions} ${QT_DEFINITIONS})
IF(CAMPVIS_SHARED_LIBS AND MSVC)
ADD_DEFINITIONS("-DTGT_BUILD_DLL")
ENDIF()
INCLUDE_DIRECTORIES(${CampvisGlobalIncludeDirs} ${CampvisModulesIncludeDirs}) INCLUDE_DIRECTORIES(${CampvisGlobalIncludeDirs} ${CampvisModulesIncludeDirs})
TARGET_LINK_LIBRARIES(tgt ${CampvisGlobalExternalLibs} ${QT_LIBRARIES}) TARGET_LINK_LIBRARIES(tgt ${CampvisGlobalExternalLibs} ${QT_LIBRARIES})
......
...@@ -196,7 +196,7 @@ protected: ...@@ -196,7 +196,7 @@ protected:
}; };
/// ostream-operator /// ostream-operator
std::ostream& operator<< (std::ostream& o, const Bounds& b); TGT_API std::ostream& operator<< (std::ostream& o, const Bounds& b);
} // namespace } // namespace
......
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
#include "tgt/exception.h" #include "tgt/exception.h"
#include "tgt/tgt_gl.h" #include "tgt/tgt_gl.h"
#include "tgt/types.h"
#include <set> #include <set>
namespace tgt { namespace tgt {
class VertexAttribute; class VertexAttribute;
class BufferObject { class TGT_API BufferObject {
public: public:
enum TargetType { enum TargetType {
ARRAY_BUFFER = GL_ARRAY_BUFFER, ARRAY_BUFFER = GL_ARRAY_BUFFER,
......
...@@ -194,6 +194,11 @@ public: ...@@ -194,6 +194,11 @@ public:
/// Getter /// Getter
bool isInitialized() const { return initialized_; } bool isInitialized() const { return initialized_; }
/// Acqures this canvas as current context
virtual void acquireAsCurrentContext() = 0;
/// Releases this canvas as current context
virtual void releaseAsCurrentContext() = 0;
protected: protected:
/// Use the painter_ to actually paint something on the canvas /// Use the painter_ to actually paint something on the canvas
......
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
#include "tgt/assert.h" #include "tgt/assert.h"
namespace tgt { namespace tgt {
GlContextManager* GlContextManager::singletonClass_ = 0;
GlContextManager::GlContextManager() GlContextManager::GlContextManager()
: _currentContext(0) : _currentContext(0)
{ {
...@@ -13,22 +11,12 @@ namespace tgt { ...@@ -13,22 +11,12 @@ namespace tgt {
GlContextManager::~GlContextManager() GlContextManager::~GlContextManager()
{ {
for (std::map<std::string, GLCanvas*>::iterator it = _contexts.begin(); it != _contexts.end(); ++it) { for (std::set<GLCanvas*>::iterator it = _contexts.begin(); it != _contexts.end(); ++it) {
delete it->second; delete *it;
} }
_contexts.clear(); _contexts.clear();
} }
GLCanvas* GlContextManager::getContextByKey(const std::string& key) {
tbb::mutex::scoped_lock lock(_localMutex);
std::map<std::string, GLCanvas*>::iterator it = _contexts.find(key);
if (it != _contexts.end())
return it->second;
else
return 0;
}
void GlContextManager::lock() { void GlContextManager::lock() {
_glMutex.lock(); _glMutex.lock();
} }
...@@ -51,20 +39,6 @@ namespace tgt { ...@@ -51,20 +39,6 @@ namespace tgt {
return _currentContext; return _currentContext;
} }
GlContextManager* GlContextManager::getPtr() {
tgtAssert( singletonClass_ != 0, "singletonClass_ has not been intitialized." );
return singletonClass_;
}
GlContextManager& GlContextManager::getRef() {
tgtAssert( singletonClass_ != 0 , "singletonClass_ has not been intitialized." );
return *singletonClass_;
}
bool GlContextManager::isInited() {
return (singletonClass_ != 0);
}
void GlContextManager::lockAndAcquire(GLCanvas* context) { void GlContextManager::lockAndAcquire(GLCanvas* context) {
lock(); lock();
setCurrent(context); setCurrent(context);
...@@ -79,16 +53,52 @@ namespace tgt { ...@@ -79,16 +53,52 @@ namespace tgt {
setCurrent(context); setCurrent(context);
} }
void GlContextManager::registerContextAndInitGlew(GLCanvas* context) {
tgtAssert(context != 0, "Given context must not be 0.");
tgtAssert(_contexts.find(context) == _contexts.end(), "Tried to double register the same context.");
{
tbb::mutex::scoped_lock localLock(_localMutex);
_contexts.insert(context);
}
// Init GLEW for this context
GLenum err = glewInit();
if (err != GLEW_OK) {
// Problem: glewInit failed, something is seriously wrong.
tgtAssert(false, "glewInit failed");
std::cerr << "glewInit failed, error: " << glewGetErrorString(err) << std::endl;
exit(EXIT_FAILURE);
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
}
void GlContextManager::removeContext(GLCanvas* context) { void GlContextManager::removeContext(GLCanvas* context) {
_currentContext = 0; _currentContext = 0;
tbb::mutex::scoped_lock lock(_localMutex); tbb::mutex::scoped_lock lock(_localMutex);
for (std::map<std::string, GLCanvas*>::iterator it = _contexts.begin(); it != _contexts.end(); ++it) { std::set<GLCanvas*>::iterator it = _contexts.find(context);
if (it->second == context) { if (it != _contexts.end()) {
_contexts.erase(it); _contexts.erase(it);
break; }
}
void GlContextManager::setCurrent(GLCanvas* context) {
if (_currentContext != context) {
if (context == 0) {
// explicitely release OpenGL context
_currentContext->releaseAsCurrentContext();
_currentContext = 0;
}
else {
context->acquireAsCurrentContext();
LGL_ERROR;
_currentContext = context;
} }
} }