diff --git a/CMakeLists.txt b/CMakeLists.txt index d111e91a..8c77209f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,4 +10,6 @@ SET(POLYVOX_VERSION "${POLYVOX_VERSION_MAJOR}.${POLYVOX_VERSION_MINOR}.${POLYVOX ADD_SUBDIRECTORY(library) ADD_SUBDIRECTORY(examples/OpenGL) +ADD_DEPENDENCIES(OpenGLExample PolyVoxCore PolyVoxUtil) + INCLUDE(Packaging.cmake) diff --git a/examples/OpenGL/CMakeLists.txt b/examples/OpenGL/CMakeLists.txt index 3d567475..74aa48d7 100644 --- a/examples/OpenGL/CMakeLists.txt +++ b/examples/OpenGL/CMakeLists.txt @@ -63,3 +63,11 @@ INSTALL(TARGETS OpenGLExample ARCHIVE DESTINATION Examples/OpenGL/lib COMPONENT example ) + +IF(WIN32) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../library/PolyVoxCore/release/PolyVoxCore.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Release) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../library/PolyVoxUtil/release/PolyVoxUtil.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Release) + + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../library/PolyVoxCore/debug/PolyVoxCore_d.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Debug) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../library/PolyVoxUtil/debug/PolyVoxUtil_d.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Debug) +ENDIF(WIN32) diff --git a/examples/OpenGL/main.cpp b/examples/OpenGL/main.cpp index 7a7f1972..684c13b1 100644 --- a/examples/OpenGL/main.cpp +++ b/examples/OpenGL/main.cpp @@ -21,14 +21,32 @@ using namespace std; using namespace PolyVox; using namespace std; -void exampleLog(string message) +void exampleLog(string message, int severity) { + //Identify how severe the mesage is + switch(severity) + { + case LS_DEBUG: + cout << "DEBUG: "; + break; + case LS_INFO: + cout << "INFO: "; + break; + case LS_WARN: + cout << "WARN: "; + break; + case LS_ERROR: + cout << "ERROR: "; + break; + } + + //Print the message cout << message << endl; } int main(int argc, char *argv[]) - { - logImpl = &exampleLog; +{ + logHandler = &exampleLog; Volume volData(g_uVolumeSideLength); //Make our volume contain a sphere in the center. @@ -48,17 +66,17 @@ int main(int argc, char *argv[]) createCubeInVolume(volData, Vector3DUint16(midPos+1, minPos, midPos+1), Vector3DUint16(maxPos, midPos-1, maxPos), 0); createCubeInVolume(volData, Vector3DUint16(minPos, midPos+1, midPos+1), Vector3DUint16(midPos-1, maxPos, maxPos), 0); - QApplication app(argc, argv); + QApplication app(argc, argv); - OpenGLWidget openGLWidget(0); - + OpenGLWidget openGLWidget(0); - openGLWidget.show(); - openGLWidget.setVolume(&volData); + openGLWidget.show(); - return app.exec(); - } + openGLWidget.setVolume(&volData); + + return app.exec(); +} #ifdef USING_GLUT diff --git a/library/PolyVoxCore/include/Log.h b/library/PolyVoxCore/include/Log.h index 7c221b03..5f1866e6 100644 --- a/library/PolyVoxCore/include/Log.h +++ b/library/PolyVoxCore/include/Log.h @@ -5,6 +5,33 @@ #include -POLYVOXCORE_API extern void (*logImpl)(std::string); +//Note: The functions in this file are not for the user to call - they are +//intended for internal use only. The only exception is that you may set the +//logHandler pointer to point at your own handling funtion for printing, etc. + +namespace PolyVox +{ + enum LogSeverity + { + LS_DEBUG, + LS_INFO, + LS_WARN, + LS_ERROR + }; + + POLYVOXCORE_API extern void (*logHandler)(std::string, int severity); +} + +//Debug severity messages are only used if we are a debug build +#ifdef _DEBUG + #define POLYVOX_LOG_DEBUG(message) if(logHandler){logHandler(message, LS_DEBUG);} +#else + #define POLYVOX_LOG_DEBUG(message) +#endif + +//Other severity levels work in both debug and release +#define POLYVOX_LOG_INFO(message) if(logHandler){logHandler(message, LS_INFO);} +#define POLYVOX_LOG_WARN(message) if(logHandler){logHandler(message, LS_WARN);} +#define POLYVOX_LOG_ERROR(message) if(logHandler){logHandler(message, LS_ERROR);} #endif \ No newline at end of file diff --git a/library/PolyVoxCore/include/Volume.inl b/library/PolyVoxCore/include/Volume.inl index cd95cca8..8e0dbe22 100644 --- a/library/PolyVoxCore/include/Volume.inl +++ b/library/PolyVoxCore/include/Volume.inl @@ -38,7 +38,6 @@ namespace PolyVox Volume::Volume(uint16_t uSideLength, uint16_t uBlockSideLength) :m_pBlocks(0) { - logImpl("In volume constructor"); //Debug mode validation assert(isPowerOf2(uSideLength)); assert(isPowerOf2(uBlockSideLength)); diff --git a/library/PolyVoxCore/source/Log.cpp b/library/PolyVoxCore/source/Log.cpp index 06cbf287..5866828f 100644 --- a/library/PolyVoxCore/source/Log.cpp +++ b/library/PolyVoxCore/source/Log.cpp @@ -1,3 +1,6 @@ #include "Log.h" -void (*logImpl)(std::string) = 0; \ No newline at end of file +namespace PolyVox +{ + void (*logHandler)(std::string, int severity) = 0; +} \ No newline at end of file