Added b3Printf, b3Warning and b3Error that can be re-routed to custom handlers.

See in src/Bullet3Common/b3Logging.h for details
This commit is contained in:
erwin coumans
2013-06-03 13:10:27 -07:00
parent 70b4ead641
commit 76b0d7697a
21 changed files with 321 additions and 175 deletions

View File

@@ -22,33 +22,53 @@ cl_context g_cxMainContext;
cl_command_queue g_cqCommandQue;
#include "Bullet3Common/b3Logging.h"
#include <Windows.h>
void myprintf(const char* msg)
{
#ifdef _WINDOWS
OutputDebugStringA(msg);
#else
printf(msg);
#endif
}
int main(int argc, char* argv[])
{
b3SetCustomPrintfFunc(myprintf);
b3SetCustomWarningMessageFunc(myprintf);
b3SetCustomErrorMessageFunc(myprintf);
b3Printf("test b3Printf\n");
b3Warning("test warning\n");
b3Error("test error\n");
int ciErrNum = 0;
cl_device_type deviceType = CL_DEVICE_TYPE_ALL;
const char* vendorSDK = b3OpenCLUtils::getSdkVendorName();
printf("This program was compiled using the %s OpenCL SDK\n",vendorSDK);
b3Printf("This program was compiled using the %s OpenCL SDK\n",vendorSDK);
int numPlatforms = b3OpenCLUtils::getNumPlatforms();
printf("Num Platforms = %d\n", numPlatforms);
b3Printf("Num Platforms = %d\n", numPlatforms);
for (int i=0;i<numPlatforms;i++)
{
cl_platform_id platform = b3OpenCLUtils::getPlatform(i);
b3OpenCLPlatformInfo platformInfo;
b3OpenCLUtils::getPlatformInfo(platform,&platformInfo);
printf("--------------------------------\n");
printf("Platform info for platform nr %d:\n",i);
printf(" CL_PLATFORM_VENDOR: \t\t\t%s\n",platformInfo.m_platformVendor);
printf(" CL_PLATFORM_NAME: \t\t\t%s\n",platformInfo.m_platformName);
printf(" CL_PLATFORM_VERSION: \t\t\t%s\n",platformInfo.m_platformVersion);
b3Printf("--------------------------------\n");
b3Printf("Platform info for platform nr %d:\n",i);
b3Printf(" CL_PLATFORM_VENDOR: \t\t\t%s\n",platformInfo.m_platformVendor);
b3Printf(" CL_PLATFORM_NAME: \t\t\t%s\n",platformInfo.m_platformName);
b3Printf(" CL_PLATFORM_VERSION: \t\t\t%s\n",platformInfo.m_platformVersion);
cl_context context = b3OpenCLUtils::createContextFromPlatform(platform,deviceType,&ciErrNum);
int numDevices = b3OpenCLUtils::getNumDevices(context);
printf("Num Devices = %d\n", numDevices);
b3Printf("Num Devices = %d\n", numDevices);
for (int j=0;j<numDevices;j++)
{
cl_device_id dev = b3OpenCLUtils::getDevice(context,j);
@@ -65,7 +85,7 @@ int main(int argc, char* argv[])
void* glCtx=0;
void* glDC = 0;
printf("Initialize OpenCL using b3OpenCLUtils::createContextFromType for CL_DEVICE_TYPE_GPU\n");
b3Printf("Initialize OpenCL using b3OpenCLUtils::createContextFromType for CL_DEVICE_TYPE_GPU\n");
g_cxMainContext = b3OpenCLUtils::createContextFromType(deviceType, &ciErrNum, glCtx, glDC);
oclCHECKERROR(ciErrNum, CL_SUCCESS);
@@ -92,9 +112,9 @@ int main(int argc, char* argv[])
}
else {
printf("No OpenCL capable GPU found!");
b3Printf("No OpenCL capable GPU found!");
}
printf("press <Enter>\n");
b3Printf("press <Enter>\n");
getchar();
return 0;
}

View File

@@ -19,7 +19,8 @@ function createProject(vendor)
files {
"main.cpp",
"../../../src/Bullet3OpenCL/Initialize/b3OpenCLUtils.cpp",
"../../../src/Bullet3OpenCL/Initialize/b3OpenCLUtils.h"
"../../../src/Bullet3OpenCL/Initialize/b3OpenCLUtils.h",
"../../../src/Bullet3Common/b3Logging.cpp",
}
end