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:
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -24,7 +24,9 @@ function createProject(vendor)
|
||||
"../../../src/Bullet3Common/b3Quickprof.cpp",
|
||||
"../../../src/Bullet3Common/b3Quickprof.h",
|
||||
"../../../src/Bullet3OpenCL/Initialize/b3OpenCLUtils.cpp",
|
||||
"../../../src/Bullet3OpenCL/Initialize/b3OpenCLUtils.h"
|
||||
"../../../src/Bullet3OpenCL/Initialize/b3OpenCLUtils.h",
|
||||
"../../../src/Bullet3Common/b3Logging.cpp",
|
||||
"../../../src/Bullet3Common/b3Logging.h",
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
@@ -30,6 +30,9 @@ function createProject(vendor)
|
||||
"../../../src/Bullet3Common/b3AlignedAllocator.cpp",
|
||||
"../../../src/Bullet3Common/b3AlignedAllocator.h",
|
||||
"../../../src/Bullet3Common/b3AlignedObjectArray.h",
|
||||
"../../../src/Bullet3Common/b3Logging.cpp",
|
||||
"../../../src/Bullet3Common/b3Logging.h",
|
||||
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
@@ -639,17 +639,23 @@ void b3CommandLineArgs::GetCmdLineArgument<char*>(const char* arg_name, char* &v
|
||||
|
||||
extern bool gDebugSkipLoadingBinary;
|
||||
|
||||
void myprintf(const char* msg)
|
||||
{
|
||||
(void*) msg;
|
||||
}
|
||||
int main( int argc, char** argv)
|
||||
{
|
||||
//gDebugSkipLoadingBinary = true;
|
||||
|
||||
// b3SetCustomPrintfFunc(myprintf);
|
||||
|
||||
cl_int ciErrNum;
|
||||
b3CommandLineArgs args(argc,argv);
|
||||
|
||||
args.GetCmdLineArgument("deviceId", gPreferredDeviceId);
|
||||
args.GetCmdLineArgument("platformId", gPreferredPlatformId);
|
||||
|
||||
printf("Initialize OpenCL using b3OpenCLUtils_createContextFromType\n");
|
||||
b3Printf("Initialize OpenCL using b3OpenCLUtils_createContextFromType\n");
|
||||
cl_platform_id platformId;
|
||||
// g_cxMainContext = b3OpenCLUtils_createContextFromType(CL_DEVICE_TYPE_ALL, &ciErrNum, 0, 0,gPreferredDeviceId,gPreferredPlatformId,&platformId);
|
||||
g_cxMainContext = b3OpenCLUtils_createContextFromType(CL_DEVICE_TYPE_GPU, &ciErrNum, 0, 0,gPreferredDeviceId,gPreferredPlatformId,&platformId);
|
||||
@@ -661,12 +667,12 @@ int main( int argc, char** argv)
|
||||
|
||||
if (!numDev)
|
||||
{
|
||||
printf("error: no OpenCL devices\n");
|
||||
b3Error("error: no OpenCL devices\n");
|
||||
exit(0);
|
||||
}
|
||||
int devId = 0;
|
||||
g_device = b3OpenCLUtils_getDevice(g_cxMainContext,devId);
|
||||
b3OpenCLUtils_printDeviceInfo(stdout, g_device);
|
||||
b3OpenCLUtils_printDeviceInfo(g_device);
|
||||
// create a command-queue
|
||||
g_cqCommandQueue = clCreateCommandQueue(g_cxMainContext, g_device, 0, &ciErrNum);
|
||||
oclCHECKERROR(ciErrNum, CL_SUCCESS);
|
||||
|
||||
@@ -29,6 +29,9 @@ function createProject(vendor)
|
||||
"../../../src/Bullet3Common/b3AlignedObjectArray.h",
|
||||
"../../../src/Bullet3Common/b3Quickprof.cpp",
|
||||
"../../../src/Bullet3Common/b3Quickprof.h",
|
||||
"../../../src/Bullet3Common/b3Logging.cpp",
|
||||
"../../../src/Bullet3Common/b3Logging.h",
|
||||
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user