add Intel build support for the OpenCL cloth demo, and use the bullet_logo.png

Thanks to ggjunker for the patch, see Issue 533
This commit is contained in:
erwin.coumans 2011-09-13 01:52:42 +00:00
parent c8b3c9e306
commit 1e360bdb6b
28 changed files with 4885 additions and 812 deletions

View File

@ -125,20 +125,38 @@ IF(MSVC)
IF(AMD_OPENCL_BASE_DIR)
#AMD adds an extras slash at the end of the ATISTREAMSDKROOT variable
SET(AMD_OPENCL_INCLUDES ${AMD_OPENCL_BASE_DIR}/include )
MESSAGE("AMD OPENCL SDK FOUND")
MESSAGE(${AMD_OPENCL_INCLUDES})
IF (CMAKE_CL_64)
SET(CMAKE_ATISTREAMSDK_LIBPATH ${AMD_OPENCL_BASE_DIR}/lib/x86_64 )
ELSE(CMAKE_CL_64)
SET(CMAKE_ATISTREAMSDK_LIBPATH ${AMD_OPENCL_BASE_DIR}/lib/x86 )
SET(CMAKE_ATISTREAMSDK_LIBPATH ${AMD_OPENCL_BASE_DIR}/lib/x86 )
ENDIF(CMAKE_CL_64)
OPTION(BUILD_AMD_OPENCL_DEMOS "Build OpenCL demos for AMD (GPU or CPU)" ON)
ELSE()
OPTION(BUILD_AMD_OPENCL_DEMOS "Build OpenCL demos for AMD (GPU or CPU)" OFF)
ENDIF()
FIND_PATH(INTEL_OPENCL_BASE_DIR include/CL/cl.h PATH $ENV{INTELOCLSDKROOT} )
IF(INTEL_OPENCL_BASE_DIR)
SET(INTEL_OPENCL_INCLUDES ${INTEL_OPENCL_BASE_DIR}/include )
MESSAGE("INTEL OPENCL SDK FOUND")
MESSAGE(${INTEL_OPENCL_INCLUDES})
IF (CMAKE_CL_64)
SET(CMAKE_INTELOCLSDK_LIBPATH ${INTEL_OPENCL_BASE_DIR}/lib/x64 )
ELSE(CMAKE_CL_64)
SET(CMAKE_INTELOCLSDK_LIBPATH ${INTEL_OPENCL_BASE_DIR}/lib/x86 )
ENDIF(CMAKE_CL_64)
SET(INTEL_OPENCL_LIBRARIES ${CMAKE_INTELOCLSDK_LIBPATH}/OpenCL.lib)
OPTION(BUILD_INTEL_OPENCL_DEMOS "Build OpenCL demos for Intel (CPU)" ON)
ELSE()
OPTION(BUILD_INTEL_OPENCL_DEMOS "Build OpenCL demos for Intel (CPU)" OFF)
ENDIF()
FIND_PATH(NVIDIA_OPENCL_BASE_DIR include/CL/cl.h PATH $ENV{CUDA_PATH} )
IF(NVIDIA_OPENCL_BASE_DIR)
SET(NVIDIA_OPENCL_INCLUDES ${NVIDIA_OPENCL_BASE_DIR}/include )
MESSAGE("NVIDIA OPENCL SDK FOUND")
MESSAGE(${NVIDIA_OPENCL_INCLUDES})
IF (CMAKE_CL_64)
SET(CMAKE_NVSDKCOMPUTE_LIBPATH ${NVIDIA_OPENCL_BASE_DIR}/lib/x64 )
@ -167,16 +185,30 @@ IF (MSVC OR APPLE)
ELSE()
OPTION(BUILD_MINICL_OPENCL_DEMOS "Build OpenCL demos for MiniCL (Generic CPU)" OFF)
FIND_PATH(INTEL_OPENCL_INCLUDES CL/cl.h)
FIND_PATH(INTEL_OPENCL_ICD_CFG intelocl64.icd /etc/OpenCL/vendors)
FIND_LIBRARY(INTEL_OPENCL_LIBRARIES OpenCL PATH /usr/lib64)
IF (INTEL_OPENCL_INCLUDES AND INTEL_OPENCL_LIBRARIES AND INTEL_OPENCL_ICD_CFG)
MESSAGE("INTEL OPENCL SDK FOUND")
MESSAGE(${INTEL_OPENCL_LIBRARIES})
OPTION(BUILD_INTEL_OPENCL_DEMOS "Build OpenCL demos for Intel (CPU)" ON)
ELSE ()
MESSAGE("INTEL OPENCL NOT FOUND")
OPTION(BUILD_INTEL_OPENCL_DEMOS "Build OpenCL demos for Intel (CPU)" OFF)
ENDIF ()
FIND_PATH(NVIDIA_OPENCL_INCLUDES CL/cl.h)
FIND_LIBRARY(NVIDIA_OPENCL_LIBRARIES OpenCL PATH /usr/lib /usr/local/lib)
IF (NVIDIA_OPENCL_INCLUDES AND NVIDIA_OPENCL_LIBRARIES)
MESSAGE("OPENCL FOUND")
FIND_PATH(NVIDIA_OPENCL_ICD_CFG nvidia.icd /etc/OpenCL/vendors)
FIND_LIBRARY(NVIDIA_OPENCL_LIBRARIES OpenCL PATH /usr/lib64 /usr/local/lib)
IF (NVIDIA_OPENCL_INCLUDES AND NVIDIA_OPENCL_LIBRARIES AND NVIDIA_OPENCL_ICD_CFG)
MESSAGE("NVidia OPENCL FOUND")
MESSAGE(${NVIDIA_OPENCL_LIBRARIES})
OPTION(BUILD_NVIDIA_OPENCL_DEMOS "Build OpenCL demos for NVidia (GPU)" ON)
ELSE ()
MESSAGE("OPENCL NOT FOUND")
MESSAGE("NVidia OPENCL NOT FOUND")
OPTION(BUILD_NVIDIA_OPENCL_DEMOS "Build OpenCL demos for NVidia (GPU)" OFF)
ENDIF ()
ENDIF()
OPTION(BUILD_CPU_DEMOS "Build original Bullet CPU demos" ON)

View File

@ -80,6 +80,7 @@ public:
}
void draw(void)
{

View File

@ -45,8 +45,8 @@ IF (USE_GLUT)
# ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL/GLDebugDrawer.cpp
../gl_win.cpp
../clstuff.cpp
../bmpLoader.cpp
../bmpLoader.h
../clstuff.h
../gl_win.h
../cloth.h
@ -73,8 +73,7 @@ IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(CMAKE_CL_64)
ENDIF(WIN32)
ADD_CUSTOM_COMMAND( TARGET AppOpenCLClothDemo_AMD POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenCLClothDemo/amdFlag.bmp ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenCLClothDemo/atiFlag.bmp ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/bullet_logo.png ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)

View File

@ -39,8 +39,6 @@ IF (USE_GLUT)
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclCommon.cpp
../gl_win.cpp
../clstuff.cpp
../bmpLoader.cpp
../bmpLoader.h
../clstuff.h
../gl_win.h

View File

@ -1,5 +1,9 @@
SUBDIRS( MiniCL )
IF(BUILD_INTEL_OPENCL_DEMOS)
SUBDIRS(Intel)
ENDIF()
IF(BUILD_AMD_OPENCL_DEMOS)
SUBDIRS(AMD)
ENDIF()

View File

@ -0,0 +1,86 @@
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL
${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
${INTEL_OPENCL_INCLUDES}
)
ADD_DEFINITIONS(-DUSE_INTEL_OPENCL)
ADD_DEFINITIONS(-DCL_PLATFORM_INTEL)
IF (CMAKE_CL_64)
SET(CMAK_GLEW_LIBRARY
${BULLET_PHYSICS_SOURCE_DIR}/Glut/glew64.lib )
ELSE(CMAKE_CL_64)
SET(CMAK_GLEW_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/Glut/glew32.lib )
ENDIF(CMAKE_CL_64)
IF (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport
BulletSoftBodySolvers_OpenCL_Intel
BulletMultiThreaded
BulletSoftBody
BulletDynamics
BulletCollision
LinearMath
${GLUT_glut_LIBRARY}
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
${CMAK_GLEW_LIBRARY}
${INTEL_OPENCL_LIBRARIES}
)
ADD_EXECUTABLE(AppOpenCLClothDemo_Intel
../cl_cloth_demo.cpp
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclUtils.h
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclCommon.h
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclUtils.cpp
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclCommon.cpp
# ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL/GLDebugDrawer.cpp
../gl_win.cpp
../clstuff.cpp
../clstuff.h
../gl_win.h
../cloth.h
)
ELSE (USE_GLUT)
ENDIF (USE_GLUT)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF(WIN32)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND( TARGET AppOpenCLClothDemo_Intel POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ADD_CUSTOM_COMMAND( TARGET AppOpenCLClothDemo_Intel POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLEW64.DLL ${CMAKE_CURRENT_BINARY_DIR})
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND( TARGET AppOpenCLClothDemo_Intel POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ADD_CUSTOM_COMMAND( TARGET AppOpenCLClothDemo_Intel POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLEW32.DLL ${CMAKE_CURRENT_BINARY_DIR})
ENDIF(CMAKE_CL_64)
ENDIF(WIN32)
ADD_CUSTOM_COMMAND( TARGET AppOpenCLClothDemo_Intel POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/bullet_logo.png ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (UNIX)
TARGET_LINK_LIBRARIES(AppOpenCLClothDemo_Intel pthread)
ENDIF(UNIX)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppOpenCLClothDemo_Intel PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppOpenCLClothDemo_Intel PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppOpenCLClothDemo_Intel PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@ -40,8 +40,6 @@ IF (USE_GLUT)
../cl_cloth_demo.cpp
../gl_win.cpp
../clstuff.cpp
../bmpLoader.cpp
../bmpLoader.h
../clstuff.h
../gl_win.h
${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/MiniCL/MiniCLTaskWrap.cpp
@ -77,8 +75,7 @@ ENDIF(WIN32)
IF(NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ADD_CUSTOM_COMMAND( TARGET AppOpenCLClothDemo_Mini POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenCLClothDemo/amdFlag.bmp ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenCLClothDemo/atiFlag.bmp ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/bullet_logo.png ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF()
IF (UNIX)

View File

@ -46,8 +46,6 @@ IF (USE_GLUT)
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclCommon.cpp
../gl_win.cpp
../clstuff.cpp
../bmpLoader.cpp
../bmpLoader.h
../clstuff.h
../gl_win.h

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

View File

@ -1,325 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2010 Advanced Micro Devices
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "bmpLoader.h"
#include <new>
#include <cstring>
#include <cstdio>
namespace amd
{
static const short bitMapID = 19778;
void
BitMap::releaseResources(void)
{
if (pixels_ != NULL) {
delete[] pixels_;
}
if (colors_ != NULL) {
delete[] colors_;
}
pixels_ = NULL;
colors_ = NULL;
isLoaded_ = false;
}
BitMap& BitMap::operator=(const BitMap& rhs)
{
if (this == &rhs) {
return *this;
}
// Copy header
id = rhs.id;
size = rhs.size;
reserved1 = rhs.reserved1;
reserved2 = rhs.reserved2;
offset = rhs.offset;
// Copy header info
sizeInfo = rhs.sizeInfo;
width = rhs.width;
height = rhs.height;
planes = rhs.planes;
bitsPerPixel = rhs.bitsPerPixel;
compression = rhs.compression;
imageSize = rhs.imageSize;
xPelsPerMeter = rhs.xPelsPerMeter;
yPelsPerMeter = rhs.yPelsPerMeter;
clrUsed = rhs.clrUsed;
clrImportant = rhs.clrImportant;
numColors_ = rhs.numColors_;
isLoaded_ = rhs.isLoaded_;
pixels_ = NULL;
colors_ = NULL;
if (isLoaded_) {
if (rhs.colors_ != NULL) {
colors_ = new ColorPalette[numColors_];
if (colors_ == NULL) {
isLoaded_ = false;
return *this;
}
memcpy(colors_, rhs.colors_, numColors_ * sizeof(ColorPalette));
}
pixels_ = new uchar4[width * height];
if (pixels_ == NULL) {
delete[] colors_;
colors_ = NULL;
isLoaded_ = false;
return *this;
}
memcpy(pixels_, rhs.pixels_, width * height * sizeof(uchar4));
}
return *this;
}
void
BitMap::load(const char * filename)
{
// Release any existing resources
releaseResources();
// Open BMP file
FILE * fd = fopen(filename, "rb");
// Opened OK
if (fd != NULL) {
// Read header
fread((BitMapHeader *)this, sizeof(BitMapHeader), 1, fd);
// Failed to read header
if (ferror(fd)) {
fclose(fd);
return;
}
// Confirm that we have a bitmap file
if (id != bitMapID) {
fclose(fd);
return;
}
// Read map info header
fread((BitMapInfoHeader *)this, sizeof(BitMapInfoHeader), 1, fd);
// Failed to read map info header
if (ferror(fd)) {
fclose(fd);
return;
}
// No support for compressed images
if (compression) {
fclose(fd);
return;
}
// Support only 8 or 24 bits images
if (bitsPerPixel < 8) {
fclose(fd);
return;
}
// Store number of colors
numColors_ = 1 << bitsPerPixel;
//load the palate for 8 bits per pixel
if(bitsPerPixel == 8) {
colors_ = new ColorPalette[numColors_];
if (colors_ == NULL) {
fclose(fd);
return;
}
fread(
(char *)colors_,
numColors_ * sizeof(ColorPalette),
1,
fd);
// Failed to read colors
if (ferror(fd)) {
fclose(fd);
return;
}
}
// Allocate buffer to hold all pixels
unsigned int sizeBuffer = size - offset;
unsigned char * tmpPixels = new unsigned char[sizeBuffer];
if (tmpPixels == NULL) {
delete colors_;
colors_ = NULL;
fclose(fd);
return;
}
// Read pixels from file, including any padding
fread(tmpPixels, sizeBuffer * sizeof(unsigned char), 1, fd);
// Failed to read pixel data
if (ferror(fd)) {
delete colors_;
colors_ = NULL;
delete tmpPixels;
fclose(fd);
return;
}
// Allocate image
pixels_ = new uchar4[width * height];
if (pixels_ == NULL) {
delete colors_;
colors_ = NULL;
delete tmpPixels;
fclose(fd);
return;
}
// Set image, including w component (white)
memset(pixels_, 0xff, width * height * sizeof(uchar4));
unsigned int index = 0;
for(int y = 0; y < height; y++) {
for(int x = 0; x < width; x++) {
// Read RGB values
if (bitsPerPixel == 8) {
pixels_[(y * width + x)] = colors_[tmpPixels[index++]];
}
else { // 24 bit
pixels_[(y * width + x)].z = tmpPixels[index++];
pixels_[(y * width + x)].y = tmpPixels[index++];
pixels_[(y * width + x)].x = tmpPixels[index++];
}
}
// Handle padding
for(int x = 0; x < (4 - (3 * width) % 4) % 4; x++) {
index++;
}
}
// Loaded file so we can close the file.
fclose(fd);
delete[] tmpPixels;
// Loaded file so record this fact
isLoaded_ = true;
}
}
int
BitMap::colorIndex(uchar4 color)
{
for (int i = 0; i < numColors_; i++) {
if (colors_[i].x == color.x &&
colors_[i].y == color.y &&
colors_[i].z == color.z &&
colors_[i].w == color.w) {
return i;
}
}
return 0;
}
bool
BitMap::write(const char * filename)
{
if (!isLoaded_) {
return false;
}
// Open BMP file
FILE * fd = fopen(filename, "wb");
// Opened OK
if (fd != NULL) {
// Write header
fwrite((BitMapHeader *)this, sizeof(BitMapHeader), 1, fd);
// Failed to write header
if (ferror(fd)) {
fclose(fd);
return false;
}
// Write map info header
fwrite((BitMapInfoHeader *)this, sizeof(BitMapInfoHeader), 1, fd);
// Failed to write map info header
if (ferror(fd)) {
fclose(fd);
return false;
}
// Write palate for 8 bits per pixel
if(bitsPerPixel == 8) {
fwrite(
(char *)colors_,
numColors_ * sizeof(ColorPalette),
1,
fd);
// Failed to write colors
if (ferror(fd)) {
fclose(fd);
return false;
}
}
for(int y = 0; y < height; y++) {
for(int x = 0; x < width; x++) {
// Read RGB values
if (bitsPerPixel == 8) {
fputc(
colorIndex(
pixels_[(y * width + x)]),
fd);
}
else { // 24 bit
fputc(pixels_[(y * width + x)].z, fd);
fputc(pixels_[(y * width + x)].y, fd);
fputc(pixels_[(y * width + x)].x, fd);
if (ferror(fd)) {
fclose(fd);
return false;
}
}
}
// Add padding
for(int x = 0; x < (4 - (3 * width) % 4) % 4; x++) {
fputc(0, fd);
}
}
return true;
}
return false;
}
} // amd

View File

@ -1,200 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2010 Advanced Micro Devices
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BMPLOADER_H_
#define BMPLOADER_H_
#include <stdlib.h>
namespace amd
{
//! @fixme this needs to be moved to common types header?
#pragma pack(1)
typedef struct
{
unsigned char x;
unsigned char y;
unsigned char z;
unsigned char w;
} uchar4;
typedef uchar4 ColorPalette;
//! \struct Bitmap header info
typedef struct {
short id;
int size;
short reserved1;
short reserved2;
int offset;
} BitMapHeader;
//! \struct Bitmap info header
typedef struct {
int sizeInfo;
int width;
int height;
short planes;
short bitsPerPixel;
unsigned compression;
unsigned imageSize;
int xPelsPerMeter;
int yPelsPerMeter;
int clrUsed;
int clrImportant;
} BitMapInfoHeader;
//! \class Bitmap used to load a bitmap image from a file.
class BitMap : public BitMapHeader, public BitMapInfoHeader
{
private:
uchar4 * pixels_;
int numColors_;
ColorPalette * colors_;
bool isLoaded_;
void releaseResources(void);
int colorIndex(uchar4 color);
public:
//! \brief Default constructor
BitMap()
: pixels_(NULL),
numColors_(0),
colors_(NULL),
isLoaded_(false)
{}
/*!\brief Constructor
*
* Tries to load bitmap image from filename provided.
*
* \param filename pointer to null terminated string that is the path and
* filename to the bitmap image to be loaded.
*
* In the base of an error, e.g. the bitmap file could not be loaded for
* some reason, then a following call to isLoaded will return false.
*/
BitMap(const char * filename)
: pixels_(NULL),
numColors_(0),
colors_(NULL),
isLoaded_(false)
{
load(filename);
}
/*! \brief Copy constructor
*
* \param rhs is the bitmap to be copied (cloned).
*/
BitMap(const BitMap& rhs)
{
*this = rhs;
}
//! \brief Destructor
~BitMap()
{
releaseResources();
}
/*! \brief Assignment
* \param rhs is the bitmap to be assigned (cloned).
*/
BitMap& operator=(const BitMap& rhs);
/*! \brief Load Bitmap image
*
* \param filename is a pointer to a null terminated string that is the
* path and filename name to the the bitmap file to be loaded.
*
* In the base of an error, e.g. the bitmap file could not be loaded for
* some reason, then a following call to isLoaded will return false.
*/
void
load(const char * filename);
/*! \brief Write Bitmap image
*
* \param filename is a pointer to a null terminated string that is the
* path and filename name to the the bitmap file to be written.
*
* \return In the case that the bitmap is written true is returned. In
* the case that a bitmap image is not already loaded or the write fails
* for some reason false is returned.
*/
bool
write(const char * filename);
/*! \brief Get image width
*
* \return If a bitmap image has been successfully loaded, then the width
* image is returned, otherwise -1;
*/
int
getWidth(void) const
{
if (isLoaded_) {
return width;
}
else {
return -1;
}
}
/*! \brief Get image height
*
* \return If a bitmap image has been successfully loaded, then the height
* image is returned, otherwise -1.
*/
int
getHeight(void) const
{
if (isLoaded_) {
return height;
}
else {
return -1;
}
}
/*! \brief Get image width
*
* \return If a bitmap image has been successfully loaded, then returns
* a pointer to image's pixels, otherwise NULL.
*/
const uchar4 *
getPixels(void) const { return pixels_; }
/*! \brief Is an image currently loaded
*
* \return If a bitmap image has been successfully loaded, then returns
* true, otherwise if an image could not be loaded or an image has yet
* to be loaded false is returned.
*/
bool
isLoaded(void) const { return isLoaded_; }
};
#pragma pack()
}
#endif // BMPLOADER_H_

View File

@ -1,189 +0,0 @@
//
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
//
#ifndef BMPLOADER_H_
#define BMPLOADER_H_
#include <cstdlib>
#include <iostream>
namespace amd
{
//! @fixme this needs to be moved to common types header?
#pragma pack(1)
typedef struct
{
unsigned char x;
unsigned char y;
unsigned char z;
unsigned char w;
} uchar4;
typedef uchar4 ColorPalette;
//! \struct Bitmap header info
typedef struct {
short id;
int size;
short reserved1;
short reserved2;
int offset;
} BitMapHeader;
//! \struct Bitmap info header
typedef struct {
int sizeInfo;
int width;
int height;
short planes;
short bitsPerPixel;
unsigned compression;
unsigned imageSize;
int xPelsPerMeter;
int yPelsPerMeter;
int clrUsed;
int clrImportant;
} BitMapInfoHeader;
//! \class Bitmap used to load a bitmap image from a file.
class BitMap : public BitMapHeader, public BitMapInfoHeader
{
private:
uchar4 * pixels_;
int numColors_;
ColorPalette * colors_;
bool isLoaded_;
void releaseResources(void);
int colorIndex(uchar4 color);
public:
//! \brief Default constructor
BitMap()
: pixels_(NULL),
numColors_(0),
colors_(NULL),
isLoaded_(false)
{}
/*!\brief Constructor
*
* Tries to load bitmap image from filename provided.
*
* \param filename pointer to null terminated string that is the path and
* filename to the bitmap image to be loaded.
*
* In the base of an error, e.g. the bitmap file could not be loaded for
* some reason, then a following call to isLoaded will return false.
*/
BitMap(const char * filename)
: pixels_(NULL),
numColors_(0),
colors_(NULL),
isLoaded_(false)
{
load(filename);
}
/*! \brief Copy constructor
*
* \param rhs is the bitmap to be copied (cloned).
*/
BitMap(const BitMap& rhs)
{
*this = rhs;
}
//! \brief Destructor
~BitMap()
{
releaseResources();
}
/*! \brief Assignment
* \param rhs is the bitmap to be assigned (cloned).
*/
BitMap& operator=(const BitMap& rhs);
/*! \brief Load Bitmap image
*
* \param filename is a pointer to a null terminated string that is the
* path and filename name to the the bitmap file to be loaded.
*
* In the base of an error, e.g. the bitmap file could not be loaded for
* some reason, then a following call to isLoaded will return false.
*/
void
load(const char * filename);
/*! \brief Write Bitmap image
*
* \param filename is a pointer to a null terminated string that is the
* path and filename name to the the bitmap file to be written.
*
* \return In the case that the bitmap is written true is returned. In
* the case that a bitmap image is not already loaded or the write fails
* for some reason false is returned.
*/
bool
write(const char * filename);
/*! \brief Get image width
*
* \return If a bitmap image has been successfully loaded, then the width
* image is returned, otherwise -1;
*/
int
getWidth(void) const
{
if (isLoaded_) {
return width;
}
else {
return -1;
}
}
/*! \brief Get image height
*
* \return If a bitmap image has been successfully loaded, then the height
* image is returned, otherwise -1.
*/
int
getHeight(void) const
{
if (isLoaded_) {
return height;
}
else {
return -1;
}
}
/*! \brief Get image width
*
* \return If a bitmap image has been successfully loaded, then returns
* a pointer to image's pixels, otherwise NULL.
*/
const uchar4 *
getPixels(void) const { return pixels_; }
/*! \brief Is an image currently loaded
*
* \return If a bitmap image has been successfully loaded, then returns
* true, otherwise if an image could not be loaded or an image has yet
* to be loaded false is returned.
*/
bool
isLoaded(void) const { return isLoaded_; }
};
#pragma pack()
}
#endif // BMPLOADER_H_

View File

@ -41,7 +41,7 @@ const int numFlags = 5;
const int clothWidth = 40;
const int clothHeight = 60;//60;
float _windAngle = 1.0;//0.4;
float _windStrength = 15;
float _windStrength = 10.;
@ -256,7 +256,7 @@ void createFlag( btSoftBodySolver &solver, int width, int height, btAlignedObjec
}
float rotateAngleRoundZ = 0.5;
float rotateAngleRoundZ = 0.0;
float rotateAngleRoundX = 0.5;
btMatrix3x3 defaultRotate;
defaultRotate[0] = btVector3(cos(rotateAngleRoundZ), sin(rotateAngleRoundZ), 0.f);
@ -589,8 +589,8 @@ int main(int argc, char *argv[])
m_dynamicsWorld->stepSimulation(1./60.,0);
std::string flagTexs[] = {
"atiFlag.bmp",
"amdFlag.bmp",
"bullet_logo.png",
"bullet_logo.png",
};
int numFlagTexs = 2;

View File

@ -16,7 +16,8 @@ subject to the following restrictions:
#include "gl_win.h" //for OpenGL stuff
#include "bmpLoader.h"
#include "stb_image.h"
#include <string>
#include <cstring>
#include "LinearMath/btScalar.h"
@ -84,7 +85,7 @@ class piece_of_cloth
glEnable(GL_DEPTH_TEST);
glColor3f(0.0f, 1.0f, 1.0f);
glColor3f(1.0f, 1.0f, 1.0f);
#ifdef USE_GPU_COPY
int error = 0;
glBindBuffer(GL_ARRAY_BUFFER, clothVBO);
@ -134,82 +135,60 @@ class piece_of_cloth
void create_texture(std::string filename)
{
amd::BitMap texBMP(filename.c_str());
int width,height,n;
unsigned char *data = stbi_load(filename.c_str(), &width, &height, &n, 0);
if ( !texBMP.isLoaded() )
{
//alternative path
char newPath[1024];
sprintf(newPath,"Demos/OpenCLClothDemo/%s",filename.c_str());
texBMP.load(newPath);
if (!texBMP.isLoaded())
GLubyte* image=new GLubyte[512*256*4];
for(int y=0;y<256;++y)
{
const int t=y>>4;
GLubyte* pi=image+y*512*4;
for(int x=0;x<512;++x)
{
sprintf(newPath,"../../../../../Demos/OpenCLClothDemo/%s",filename.c_str());
texBMP.load(newPath);
const int s=x>>5;
const GLubyte b=180;
GLubyte c=b+((s+t&1)&1)*(255-b);
pi[0]=pi[1]=pi[2]=c;pi[3]=1;pi+=4;
}
}
if ( texBMP.isLoaded() ) {
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &m_texture);
glBindTexture(GL_TEXTURE_2D, m_texture);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glTexImage2D(
GL_TEXTURE_2D,
0,
GL_RGBA8,
texBMP.getWidth(),
texBMP.getHeight(),
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
texBMP.getPixels());
glBindTexture(GL_TEXTURE_2D, 0);
}
else {
printf("ERROR: could not load bitmap, using placeholder\n");
GLubyte* image=new GLubyte[256*256*3];
for(int y=0;y<256;++y)
if ( data )
{
for (int i=0;i<width;i++)
{
for (int j=0;j<height;j++)
{
const int t=y>>4;
GLubyte* pi=image+y*256*3;
for(int x=0;x<256;++x)
{
const int s=x>>4;
const GLubyte b=180;
GLubyte c=b+((s+t&1)&1)*(255-b);
pi[0]=pi[1]=pi[2]=c;pi+=3;
}
}
int offsetx = (512-width)/2;
int offsety = (256-height)/2;
glGenTextures(1,(GLuint*)&m_texture);
glBindTexture(GL_TEXTURE_2D,m_texture);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
gluBuild2DMipmaps(GL_TEXTURE_2D,3,256,256,GL_RGB,GL_UNSIGNED_BYTE,image);
delete[] image;
GLubyte* pi=image+((j+offsety)*512+i+offsetx)*4;
const GLubyte* src=data+(j*width+i)*4;
pi[0] = src[0];
pi[1] = src[1];
pi[2] = src[2];
pi[3] = 1;
}
}
}
else
{
printf("ERROR: could not load bitmap, using placeholder\n");
}
glGenTextures(1,(GLuint*)&m_texture);
glBindTexture(GL_TEXTURE_2D,m_texture);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
gluBuild2DMipmaps(GL_TEXTURE_2D,4,512,256,GL_RGBA,GL_UNSIGNED_BYTE,image);
delete[] image;
}
void create_buffers(int width_, int height_)
@ -237,8 +216,8 @@ class piece_of_cloth
cpu_buffer[y*width+x].normal[0] = 1;
cpu_buffer[y*width+x].normal[1] = 0;
cpu_buffer[y*width+x].normal[2] = 0;
cpu_buffer[y*width+x].texcoord[0] = x/((float)(width-1));
cpu_buffer[y*width+x].texcoord[1] = y/((float)(height-1));
cpu_buffer[y*width+x].texcoord[0] = 1*x/((float)(width-1));
cpu_buffer[y*width+x].texcoord[1] = (1.f-4*y/((float)(height-1)));
}
}

View File

@ -34,6 +34,8 @@ void initCL( void* glCtx, void* glDC )
#if defined(CL_PLATFORM_MINI_CL)
cl_device_type deviceType = CL_DEVICE_TYPE_CPU;//or use CL_DEVICE_TYPE_DEBUG to debug MiniCL
#elif defined(CL_PLATFORM_INTEL)
cl_device_type deviceType = CL_DEVICE_TYPE_CPU;
#elif defined(CL_PLATFORM_AMD)
cl_device_type deviceType = CL_DEVICE_TYPE_GPU;
#elif defined(CL_PLATFORM_NVIDIA)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 768 KiB

View File

@ -42,6 +42,8 @@ ADD_LIBRARY(OpenGLSupport
GlutStuff.cpp
GlutStuff.h
stb_image.cpp
stb_image.h
Win32DemoApplication.cpp
Win32DemoApplication.h

4342
Demos/OpenGL/stb_image.cpp Normal file

File diff suppressed because it is too large Load Diff

332
Demos/OpenGL/stb_image.h Normal file
View File

@ -0,0 +1,332 @@
/* stbi-1.33 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c
when you control the images you're loading
no warranty implied; use at your own risk
QUICK NOTES:
Primarily of interest to game developers and other people who can
avoid problematic images and only need the trivial interface
JPEG baseline (no JPEG progressive)
PNG 8-bit only
TGA (not sure what subset, if a subset)
BMP non-1bpp, non-RLE
PSD (composited view only, no extra channels)
GIF (*comp always reports as 4-channel)
HDR (radiance rgbE format)
PIC (Softimage PIC)
- decode from memory or through FILE (define STBI_NO_STDIO to remove code)
- decode from arbitrary I/O callbacks
- overridable dequantizing-IDCT, YCbCr-to-RGB conversion (define STBI_SIMD)
Latest revisions:
1.33 (2011-07-14) minor fixes suggested by Dave Moore
1.32 (2011-07-13) info support for all filetypes (SpartanJ)
1.31 (2011-06-19) a few more leak fixes, bug in PNG handling (SpartanJ)
1.30 (2011-06-11) added ability to load files via io callbacks (Ben Wenger)
1.29 (2010-08-16) various warning fixes from Aurelien Pocheville
1.28 (2010-08-01) fix bug in GIF palette transparency (SpartanJ)
1.27 (2010-08-01) cast-to-uint8 to fix warnings (Laurent Gomila)
allow trailing 0s at end of image data (Laurent Gomila)
1.26 (2010-07-24) fix bug in file buffering for PNG reported by SpartanJ
See end of file for full revision history.
TODO:
stbi_info support for BMP,PSD,HDR,PIC
============================ Contributors =========================
Image formats Optimizations & bugfixes
Sean Barrett (jpeg, png, bmp) Fabian "ryg" Giesen
Nicolas Schulz (hdr, psd)
Jonathan Dummer (tga) Bug fixes & warning fixes
Jean-Marc Lienher (gif) Marc LeBlanc
Tom Seddon (pic) Christpher Lloyd
Thatcher Ulrich (psd) Dave Moore
Won Chun
the Horde3D community
Extensions, features Janez Zemva
Jetro Lauha (stbi_info) Jonathan Blow
James "moose2000" Brown (iPhone PNG) Laurent Gomila
Ben "Disch" Wenger (io callbacks) Aruelien Pocheville
Martin "SpartanJ" Golini Ryamond Barbiero
David Woo
If your name should be here but isn't, let Sean know.
*/
#ifndef STBI_INCLUDE_STB_IMAGE_H
#define STBI_INCLUDE_STB_IMAGE_H
// To get a header file for this, either cut and paste the header,
// or create stb_image.h, #define STBI_HEADER_FILE_ONLY, and
// then include stb_image.c from it.
//// begin header file ////////////////////////////////////////////////////
//
// Limitations:
// - no jpeg progressive support
// - non-HDR formats support 8-bit samples only (jpeg, png)
// - no delayed line count (jpeg) -- IJG doesn't support either
// - no 1-bit BMP
// - GIF always returns *comp=4
//
// Basic usage (see HDR discussion below):
// int x,y,n;
// unsigned char *data = stbi_load(filename, &x, &y, &n, 0);
// // ... process data if not NULL ...
// // ... x = width, y = height, n = # 8-bit components per pixel ...
// // ... replace '0' with '1'..'4' to force that many components per pixel
// // ... but 'n' will always be the number that it would have been if you said 0
// stbi_image_free(data)
//
// Standard parameters:
// int *x -- outputs image width in pixels
// int *y -- outputs image height in pixels
// int *comp -- outputs # of image components in image file
// int req_comp -- if non-zero, # of image components requested in result
//
// The return value from an image loader is an 'unsigned char *' which points
// to the pixel data. The pixel data consists of *y scanlines of *x pixels,
// with each pixel consisting of N interleaved 8-bit components; the first
// pixel pointed to is top-left-most in the image. There is no padding between
// image scanlines or between pixels, regardless of format. The number of
// components N is 'req_comp' if req_comp is non-zero, or *comp otherwise.
// If req_comp is non-zero, *comp has the number of components that _would_
// have been output otherwise. E.g. if you set req_comp to 4, you will always
// get RGBA output, but you can check *comp to easily see if it's opaque.
//
// An output image with N components has the following components interleaved
// in this order in each pixel:
//
// N=#comp components
// 1 grey
// 2 grey, alpha
// 3 red, green, blue
// 4 red, green, blue, alpha
//
// If image loading fails for any reason, the return value will be NULL,
// and *x, *y, *comp will be unchanged. The function stbi_failure_reason()
// can be queried for an extremely brief, end-user unfriendly explanation
// of why the load failed. Define STBI_NO_FAILURE_STRINGS to avoid
// compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly
// more user-friendly ones.
//
// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized.
//
// ===========================================================================
//
// iPhone PNG support:
//
// By default we convert iphone-formatted PNGs back to RGB; nominally they
// would silently load as BGR, except the existing code should have just
// failed on such iPhone PNGs. But you can disable this conversion by
// by calling stbi_convert_iphone_png_to_rgb(0), in which case
// you will always just get the native iphone "format" through.
//
// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per
// pixel to remove any premultiplied alpha *only* if the image file explicitly
// says there's premultiplied data (currently only happens in iPhone images,
// and only if iPhone convert-to-rgb processing is on).
//
// ===========================================================================
//
// HDR image support (disable by defining STBI_NO_HDR)
//
// stb_image now supports loading HDR images in general, and currently
// the Radiance .HDR file format, although the support is provided
// generically. You can still load any file through the existing interface;
// if you attempt to load an HDR file, it will be automatically remapped to
// LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1;
// both of these constants can be reconfigured through this interface:
//
// stbi_hdr_to_ldr_gamma(2.2f);
// stbi_hdr_to_ldr_scale(1.0f);
//
// (note, do not use _inverse_ constants; stbi_image will invert them
// appropriately).
//
// Additionally, there is a new, parallel interface for loading files as
// (linear) floats to preserve the full dynamic range:
//
// float *data = stbi_loadf(filename, &x, &y, &n, 0);
//
// If you load LDR images through this interface, those images will
// be promoted to floating point values, run through the inverse of
// constants corresponding to the above:
//
// stbi_ldr_to_hdr_scale(1.0f);
// stbi_ldr_to_hdr_gamma(2.2f);
//
// Finally, given a filename (or an open file or memory block--see header
// file for details) containing image data, you can query for the "most
// appropriate" interface to use (that is, whether the image is HDR or
// not), using:
//
// stbi_is_hdr(char *filename);
//
// ===========================================================================
//
// I/O callbacks
//
// I/O callbacks allow you to read from arbitrary sources, like packaged
// files or some other source. Data read from callbacks are processed
// through a small internal buffer (currently 128 bytes) to try to reduce
// overhead.
//
// The three functions you must define are "read" (reads some bytes of data),
// "skip" (skips some bytes of data), "eof" (reports if the stream is at the end).
#ifndef STBI_NO_STDIO
#if defined(_MSC_VER) && _MSC_VER >= 0x1400
#define _CRT_SECURE_NO_WARNINGS // suppress bogus warnings about fopen()
#endif
#include <stdio.h>
#endif
#define STBI_VERSION 1
enum
{
STBI_default = 0, // only used for req_comp
STBI_grey = 1,
STBI_grey_alpha = 2,
STBI_rgb = 3,
STBI_rgb_alpha = 4
};
typedef unsigned char stbi_uc;
#ifdef __cplusplus
extern "C" {
#endif
//////////////////////////////////////////////////////////////////////////////
//
// PRIMARY API - works on images of any type
//
//
// load image by filename, open file, or memory buffer
//
extern stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp);
#ifndef STBI_NO_STDIO
extern stbi_uc *stbi_load (char const *filename, int *x, int *y, int *comp, int req_comp);
extern stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp);
// for stbi_load_from_file, file pointer is left pointing immediately after image
#endif
typedef struct
{
int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read
void (*skip) (void *user,unsigned n); // skip the next 'n' bytes
int (*eof) (void *user); // returns nonzero if we are at end of file/data
} stbi_io_callbacks;
extern stbi_uc *stbi_load_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp);
#ifndef STBI_NO_HDR
extern float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp);
#ifndef STBI_NO_STDIO
extern float *stbi_loadf (char const *filename, int *x, int *y, int *comp, int req_comp);
extern float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *comp, int req_comp);
#endif
extern float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp);
extern void stbi_hdr_to_ldr_gamma(float gamma);
extern void stbi_hdr_to_ldr_scale(float scale);
extern void stbi_ldr_to_hdr_gamma(float gamma);
extern void stbi_ldr_to_hdr_scale(float scale);
#endif // STBI_NO_HDR
// stbi_is_hdr is always defined
extern int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user);
extern int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len);
#ifndef STBI_NO_STDIO
extern int stbi_is_hdr (char const *filename);
extern int stbi_is_hdr_from_file(FILE *f);
#endif // STBI_NO_STDIO
// get a VERY brief reason for failure
// NOT THREADSAFE
extern const char *stbi_failure_reason (void);
// free the loaded image -- this is just free()
extern void stbi_image_free (void *retval_from_stbi_load);
// get image dimensions & components without fully decoding
extern int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp);
extern int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp);
#ifndef STBI_NO_STDIO
extern int stbi_info (char const *filename, int *x, int *y, int *comp);
extern int stbi_info_from_file (FILE *f, int *x, int *y, int *comp);
#endif
// for image formats that explicitly notate that they have premultiplied alpha,
// we just return the colors as stored in the file. set this flag to force
// unpremultiplication. results are undefined if the unpremultiply overflow.
extern void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply);
// indicate whether we should process iphone images back to canonical format,
// or just pass them through "as-is"
extern void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert);
// ZLIB client - used by PNG, available for other purposes
extern char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen);
extern char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen);
extern int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);
extern char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen);
extern int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);
// define faster low-level operations (typically SIMD support)
#ifdef STBI_SIMD
typedef void (*stbi_idct_8x8)(stbi_uc *out, int out_stride, short data[64], unsigned short *dequantize);
// compute an integer IDCT on "input"
// input[x] = data[x] * dequantize[x]
// write results to 'out': 64 samples, each run of 8 spaced by 'out_stride'
// CLAMP results to 0..255
typedef void (*stbi_YCbCr_to_RGB_run)(stbi_uc *output, stbi_uc const *y, stbi_uc const *cb, stbi_uc const *cr, int count, int step);
// compute a conversion from YCbCr to RGB
// 'count' pixels
// write pixels to 'output'; each pixel is 'step' bytes (either 3 or 4; if 4, write '255' as 4th), order R,G,B
// y: Y input channel
// cb: Cb input channel; scale/biased to be 0..255
// cr: Cr input channel; scale/biased to be 0..255
extern void stbi_install_idct(stbi_idct_8x8 func);
extern void stbi_install_YCbCr_to_RGB(stbi_YCbCr_to_RGB_run func);
#endif // STBI_SIMD
#ifdef __cplusplus
}
#endif
//
//
//// end header file /////////////////////////////////////////////////////
#endif // STBI_INCLUDE_STB_IMAGE_H

View File

@ -2,6 +2,10 @@ IF(BUILD_MINICL_OPENCL_DEMOS)
SUBDIRS( MiniCL )
ENDIF()
IF(BUILD_INTEL_OPENCL_DEMOS)
SUBDIRS(Intel)
ENDIF()
IF(BUILD_AMD_OPENCL_DEMOS)
SUBDIRS(AMD)
ENDIF()

View File

@ -339,8 +339,12 @@ void btParticlesDynamicsWorld::initCLKernels(int argc, char** argv)
{
// m_cxMainContext = clCreateContextFromType(0, CL_DEVICE_TYPE_ALL, NULL, NULL, &ciErrNum);
#ifdef USE_INTEL_OPENCL
m_cxMainContext = btOclCommon::createContextFromType(CL_DEVICE_TYPE_ALL, &ciErrNum);
#else
m_cxMainContext = btOclCommon::createContextFromType(CL_DEVICE_TYPE_GPU, &ciErrNum);
//m_cxMainContext = btOclCommon::createContextFromType(CL_DEVICE_TYPE_ALL, &ciErrNum);
#endif
oclCHECKERROR(ciErrNum, CL_SUCCESS);
m_cdDevice = btOclGetMaxFlopsDev(m_cxMainContext);

View File

@ -21,6 +21,8 @@ subject to the following restrictions:
static char* spPlatformVendor =
#if defined(CL_PLATFORM_MINI_CL)
"MiniCL, SCEA";
#elif defined(CL_PLATFORM_INTEL)
"Intel(R) Corporation";
#elif defined(CL_PLATFORM_AMD)
"Advanced Micro Devices, Inc.";
#elif defined(CL_PLATFORM_NVIDIA)

View File

@ -100,7 +100,10 @@ cl_device_id btOclGetMaxFlopsDev(cl_context cxMainContext)
} else if( device_type == CL_DEVICE_TYPE_GPU ) {
// Approximation to GPU compute power
// As long as this beats the CPU number that's the important thing, really
#if defined(CL_PLATFORM_AMD)
#if defined(CL_PLATFORM_INTEL)
// SSE - 4, AVX1,2 - 8 : TODO: detect AVX?
SIMDmultiplier = 4;
#elif defined(CL_PLATFORM_AMD)
// 16 processing elements, 5 ALUs each
SIMDmultiplier = 80;
#elif defined(CL_PLATFORM_NVIDIA)

View File

@ -1,6 +1,6 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
Copyright (c) 2003-2011 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
@ -14,6 +14,4 @@ subject to the following restrictions:
*/
All files in the Bullet/src folder are under this Zlib license.
Optional Extras/GIMPACT and Extras/GIMPACTBullet is also under ZLib license. Other optional external libraries in Extras/Demos have own license,see respective files.
This means Bullet can freely be used in any software, including commercial and console software. A Playstation 3 optimized version is available through Sony.
Files in the Extras and Demos folder may have a different license, see the respective files.

BIN
bullet_logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -107,9 +107,9 @@ ATTRIBUTE_ALIGNED16 (struct) btOptimizedBvhNode
//for child nodes
int m_subPart;
int m_triangleIndex;
int m_padding[5];//bad, due to alignment
//pad the size to 64 bytes
char m_padding[20];
};

View File

@ -1,5 +1,9 @@
SUBDIRS( MiniCL )
IF(BUILD_INTEL_OPENCL_DEMOS)
SUBDIRS(Intel)
ENDIF()
IF(BUILD_AMD_OPENCL_DEMOS)
SUBDIRS(AMD)
ENDIF()