Work on basic logging framework.
This commit is contained in:
parent
1b76395856
commit
97b162ee20
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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<PolyVox::uint8_t> 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
|
||||
|
||||
|
@ -5,6 +5,33 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
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
|
@ -38,7 +38,6 @@ namespace PolyVox
|
||||
Volume<VoxelType>::Volume(uint16_t uSideLength, uint16_t uBlockSideLength)
|
||||
:m_pBlocks(0)
|
||||
{
|
||||
logImpl("In volume constructor");
|
||||
//Debug mode validation
|
||||
assert(isPowerOf2(uSideLength));
|
||||
assert(isPowerOf2(uBlockSideLength));
|
||||
|
@ -1,3 +1,6 @@
|
||||
#include "Log.h"
|
||||
|
||||
void (*logImpl)(std::string) = 0;
|
||||
namespace PolyVox
|
||||
{
|
||||
void (*logHandler)(std::string, int severity) = 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user