Commit dcadc7da authored by Hossain Mahmud's avatar Hossain Mahmud Committed by Christian Schulte zu Berge

rewritten init() with the glcontextmanager instead of qtcontextmanager,...

rewritten init() with the glcontextmanager instead of qtcontextmanager, updated ImageData, NumericProperty, GenericProperty test codes
parent 9670d2b0
......@@ -5,8 +5,8 @@
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
// Technische Universit�t M�nchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
......
......@@ -37,7 +37,7 @@ ADD_EXECUTABLE(test-campvis
ADD_DEFINITIONS(${CampvisGlobalDefinitions} ${CampvisModulesDefinitions} ${CampvisApplicationDefinitions} ${QT_DEFINITIONS})
INCLUDE_DIRECTORIES(${CampvisGlobalIncludeDirs} ${CampvisModulesIncludeDirs} ${CampvisHome}/ext/gtest-1.7.0/ ${CampvisHome}/ext/gtest-1.7.0/include)
TARGET_LINK_LIBRARIES(test-campvis campvis-modules campvis-core tgt gtest ${CampvisGlobalExternalLibs} ${CampvisModulesExternalLibs})
TARGET_LINK_LIBRARIES(test-campvis campvis-modules campvis-core tgt gtest ${CampvisGlobalExternalLibs} ${CampvisModulesExternalLibs} ${QT_LIBRARIES})
IF(CAMPVIS_GROUP_SOURCE_FILES)
DEFINE_SOURCE_GROUPS_FROM_SUBDIR(TestCampvisSources ${CampvisHome}/test "")
......
......@@ -42,7 +42,7 @@ using namespace campvis;
class DataContainerTest : public ::testing::Test {
protected:
DataContainerTest() {
this->_data = new ImageData(2, tgt::svec3(1,2,3), 4);
this->_data = new ImageData(2, tgt::svec3(1,2,1), 4);
this->_dc0 = new DataContainer("dc0");
}
......@@ -109,7 +109,7 @@ TEST_F(DataContainerTest, getDataHandlesCopyTest) {
TEST_F(DataContainerTest, concurrentAccessTest) {
this->_dc0->addData("data1", this->_data);
DataHandle dh = this->_dc0->getData("data1");
AbstractData *someData = new ImageData(2, tgt::svec3(1,2,3), 4);
AbstractData *someData = new ImageData(2, tgt::svec3(1,2,1), 4);
this->_dc0->addData("data1", someData);
EXPECT_EQ(someData, this->_dc0->getData("data1").getData());
......
......@@ -41,7 +41,7 @@
class DataHandleTest : public testing::Test {
protected:
DataHandleTest() {
_data1 = new campvis::ImageData(2, tgt::svec3(1,2,3), 4);
_data1 = new campvis::ImageData(2, tgt::svec3(1,2,1), 4);
_dh0 = campvis::DataHandle();
_dh1 = campvis::DataHandle(_data1);
......
......@@ -39,7 +39,7 @@
class ImageDataTest : public testing::Test {
protected:
ImageDataTest() {
_imgData0 = new campvis::ImageData(2, tgt::svec3(1,2,3), 4);
_imgData0 = new campvis::ImageData(2, tgt::svec3(1,2,1), 4);
_imgData1 = _imgData0->clone();
_absData1 = _imgData1;
}
......@@ -79,8 +79,8 @@ TEST_F(ImageDataTest, miscellaneousTest) {
EXPECT_EQ(2, _imgData0->getDimensionality());
EXPECT_EQ(4, _imgData0->getNumChannels());
EXPECT_EQ(tgt::hmul(tgt::svec3(1,2,3)), _imgData0->getNumElements());
EXPECT_EQ(tgt::svec3(1,2,3).size, _imgData0->getSize().size);
EXPECT_EQ(tgt::hmul(tgt::svec3(1,2,1)), _imgData0->getNumElements());
EXPECT_EQ(tgt::svec3(1,2,1).size, _imgData0->getSize().size);
tgt::Bounds bound0 = _imgData0->getWorldBounds();
tgt::Bounds bound1 = _imgData1->getWorldBounds();
......@@ -117,28 +117,3 @@ TEST_F(ImageDataTest, cloneTest) {
EXPECT_EQ(_imgData0->getVideoMemoryFootprint(), _imgData1->getVideoMemoryFootprint());
}
/**
* Tests getSubImage() method.
*
* For test cases 1. whole image and 2. images of size (1,1,1) were checked
*/
TEST_F(ImageDataTest, getSubImageTest) {
campvis::ImageData *cloned = _imgData0->getSubImage(tgt::svec3(0,0,0), _imgData0->getSize());
ASSERT_TRUE(nullptr != _imgData1);
EXPECT_EQ(_imgData0->getDimensionality(), cloned->getDimensionality());
EXPECT_EQ(_imgData0->getLocalMemoryFootprint(), cloned->getLocalMemoryFootprint());
EXPECT_TRUE(_imgData0->getMappingInformation() == cloned->getMappingInformation());
EXPECT_EQ(_imgData0->getNumChannels(), cloned->getNumChannels());
EXPECT_EQ(_imgData0->getNumElements(), cloned->getNumElements());
//EXPECT_EQ(_imgData0->getRepresentation(), cloned->getRepresentation());
EXPECT_EQ(_imgData0->getSize(), cloned->getSize());
//EXPECT_EQ(_imgData0->getSubImage(), cloned->getSubImage());
EXPECT_EQ(_imgData0->getVideoMemoryFootprint(), cloned->getVideoMemoryFootprint());
delete cloned;
cloned = _imgData0->getSubImage(_imgData0->getSize()-tgt::svec3(1,1,1), _imgData0->getSize());
EXPECT_EQ(tgt::svec3(1,1,1), cloned->getSize());
}
......@@ -39,7 +39,7 @@
class ImageSeriesTest : public testing::Test {
protected:
ImageSeriesTest() {
_image = new campvis::ImageData(2, tgt::svec3(1,2,3), 4);
_image = new campvis::ImageData(2, tgt::svec3(1,2,1), 4);
_dh = campvis::DataHandle(_image);
_imgSeries2.addImage(_image);
......
......@@ -47,10 +47,10 @@ class NumericPropertyTest : public ::testing::Test {
protected:
NumericPropertyTest()
: imax(10), imin(-10), istep(1)
, _intProp("intProp", "title_intProp", 0, -10, 10, 1, AbstractProcessor::INVALID_RESULT)
, _intProp2("intProp2", "title_intProp2", 0, -10, 10, 1, AbstractProcessor::INVALID_RESULT)
, _intProp("intProp", "title_intProp", 0, -10, 10, 1)
, _intProp2("intProp2", "title_intProp2", 0, -10, 10, 1)
, dmax(1), dmin(-1), dstep(0.1)
, _doubleProp("_doubleProp", "title_doubleProp", 0, -1, 1, 0.1, AbstractProcessor::INVALID_RESULT)
, _doubleProp("_doubleProp", "title_doubleProp", 0, -1, 1, 0.1)
{
}
......
......@@ -44,8 +44,8 @@ using namespace campvis;
class StringPropertyTest : public ::testing::Test {
protected:
StringPropertyTest()
: _strProp1("prop1", "title_prop1", "value1", AbstractProcessor::INVALID_RESULT)
, _strProp2("prop2", "title_prop2", "value2", AbstractProcessor::INVALID_RESULT)
: _strProp1("prop1", "title_prop1", "value1")
, _strProp2("prop2", "title_prop2", "value2")
{
}
......
......@@ -36,30 +36,26 @@
//#include "tgt/glcanvas.h"
#include "tgt/gpucapabilities.h"
#include "tgt/shadermanager.h"
#include "tgt/qt/qtapplication.h"
//#include "tgt/qt/qtthreadedcanvas.h"
#include "tgt/qt/qtcontextmanager.h"
#include "tgt/glcontextmanager.h"
#include "tgt/qt/qtthreadedcanvas.h"
#include "tgt/logmanager.h"
#include "tgt/qt/qtapplication.h"
//#include "tbb/compat/thread"
#include "core/tools/simplejobprocessor.h"
#include "core/tools/opengljobprocessor.h"
#include "core/tools/quadrenderer.h"
//using namespace campvis;
#ifdef Q_WS_X11
#include <X11/Xlib.h>
#endif
/// Not sure, whether or not we need it!!
QApplication *app;
/// Flag, whether CampVisApplication was correctly initialized
bool _initialized;
/// A local OpenGL context used for initialization
/**?
* how this variable is related with tgt macros!!
*/
tgt::GLCanvas* _localContext = nullptr;
static const std::string loggerCat_;
......@@ -67,26 +63,28 @@ void init() {
// Make Xlib and GLX thread safe under X11
QApplication::setAttribute(Qt::AA_X11InitThreads);
tgt::QtContextManager::init();
tgt::GlContextManager::init();
campvis::OpenGLJobProcessor::init();
campvis::SimpleJobProcessor::init();
tgtAssert(_initialized == false, "Tried to initialize CampVisApplication twice.");
// Init TGT
tgt::InitFeature::Features featureset = tgt::InitFeature::ALL;
tgt::init(featureset);
LogMgr.getConsoleLog()->addCat("", true);
// create a local OpenGL context and init GL
_localContext = tgt::GlContextManager::getRef().createContext("AppContext", "", tgt::ivec2(16, 16));
tgtAssert(nullptr != _localContext, "Could not create local OpenGL context");
_localContext = new tgt::QtThreadedCanvas("", tgt::ivec2(16, 16));
//TODO: why I had to reorder next couple of statements ?!
tgt::GLContextScopedLock lock(_localContext);
tgt::GlContextManager::getRef().registerContextAndInitGlew(_localContext);
tgt::initGL(featureset);
ShdrMgr.setDefaultGlslVersion("330");
campvis::QuadRenderer::init();
#ifdef CAMPVIS_SOURCE_DIR
......@@ -113,13 +111,6 @@ void init() {
void deinit() {
tgtAssert(_initialized, "Tried to deinitialize uninitialized CampVisApplication.");
/**?
* Grrrrrrrrrrrrrrrr :#
* What with this BLOCK :-/ without it the program doesn't exit.
* OpenGLJobProcessor::deinit() halts in Singleton::deinit()
* WHY IS STACK SCOPE IMPORTANT HERE!!!
*/
{
// Deinit everything OpenGL related using the local context.
tgt::GLContextScopedLock lock(_localContext);
......@@ -135,7 +126,7 @@ void deinit() {
campvis::OpenGLJobProcessor::deinit();
tgt::QtContextManager::deinit();
tgt::GlContextManager::deinit();
tgt::deinit();
_initialized = false;
......@@ -143,6 +134,12 @@ void deinit() {
GTEST_API_ int main(int argc, char **argv) {
printf("Running main() from main.cpp\n");
#ifdef Q_WS_X11
XInitThreads();
#endif
app = new QApplication(argc, argv);
testing::InitGoogleTest(&argc, argv);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment