diff --git a/Demos3/GpuDemos/GpuDemo.cpp b/Demos3/GpuDemos/GpuDemo.cpp index aaa6c86b1..e931f699e 100644 --- a/Demos3/GpuDemos/GpuDemo.cpp +++ b/Demos3/GpuDemos/GpuDemo.cpp @@ -4,9 +4,9 @@ #include "Bullet3OpenCL/Initialize/b3OpenCLUtils.h" #include "OpenGLWindow/ShapeData.h" #include "OpenGLWindow/GLInstancingRenderer.h" - +#include "OpenGLWindow/OpenGLInclude.h" bool gAllowCpuOpenCL = false; - +#include "stb_image/stb_image.h" GpuDemo::GpuDemo() :m_clData(0) { @@ -121,4 +121,11 @@ int GpuDemo::registerGraphicsSphereShape(const ConstructionInfo& ci, float radiu } } return graphicsShapeIndex; -} \ No newline at end of file +} + + +unsigned char* GpuDemo::loadImage(const char* fileName, int& width, int& height, int& n) +{ + unsigned char *data = stbi_load(fileName, &width, &height, &n, 0); + return data; +} diff --git a/Demos3/GpuDemos/GpuDemo.h b/Demos3/GpuDemos/GpuDemo.h index a1d053c2f..8970d639e 100644 --- a/Demos3/GpuDemos/GpuDemo.h +++ b/Demos3/GpuDemos/GpuDemo.h @@ -48,9 +48,9 @@ public: arraySizeZ(10), #else - arraySizeX(20), - arraySizeY(20), - arraySizeZ(20), + arraySizeX(30), + arraySizeY(30), + arraySizeZ(30), #endif m_useConcaveMesh(false), gapX(16.3), @@ -77,6 +77,8 @@ public: virtual void clientMoveAndDisplay()=0; + unsigned char* loadImage(const char* fileName, int& width, int& height, int& n); + int registerGraphicsSphereShape(const ConstructionInfo& ci, float radius, bool usePointSprites=true, int largeSphereThreshold=100, int mediumSphereThreshold=10); struct GpuDemoInternalData* getInternalData(); diff --git a/Demos3/GpuDemos/rigidbody/GpuConvexScene.cpp b/Demos3/GpuDemos/rigidbody/GpuConvexScene.cpp index 9c992d8df..95946a84a 100644 --- a/Demos3/GpuDemos/rigidbody/GpuConvexScene.cpp +++ b/Demos3/GpuDemos/rigidbody/GpuConvexScene.cpp @@ -89,15 +89,38 @@ int GpuBoxPlaneScene::createDynamicsObjects(const ConstructionInfo& ci) int strideInBytes = 9*sizeof(float); int numVertices = sizeof(cube_vertices)/strideInBytes; int numIndices = sizeof(cube_indices)/sizeof(int); - return createDynamicsObjects2(ci,cube_vertices,numVertices,cube_indices,numIndices); + return createDynamicsObjects2(ci,cube_vertices_textured,numVertices,cube_indices,numIndices); } int GpuConvexScene::createDynamicsObjects2(const ConstructionInfo& ci, const float* vertices, int numVertices, const int* indices, int numIndices) { int strideInBytes = 9*sizeof(float); + int textureIndex = -1; + { + int width,height,n; + + const char* filename = "data/cube.png"; + const unsigned char* image=0; + + const char* prefix[]={"./","../","../../","../../../","../../../../"}; + int numprefix = sizeof(prefix)/sizeof(const char*); + + for (int i=0;!image && iregisterTexture(image,width,height); + } + } - int shapeId = ci.m_instancingRenderer->registerShape(&vertices[0],numVertices,indices,numIndices); + int shapeId = ci.m_instancingRenderer->registerShape(&vertices[0],numVertices,indices,numIndices,B3_GL_TRIANGLES,textureIndex); int group=1; int mask=1; int index=0; diff --git a/Demos3/GpuDemos/softbody/GpuSoftBodyDemo.cpp b/Demos3/GpuDemos/softbody/GpuSoftBodyDemo.cpp index fb4208ef3..cd15924fc 100644 --- a/Demos3/GpuDemos/softbody/GpuSoftBodyDemo.cpp +++ b/Demos3/GpuDemos/softbody/GpuSoftBodyDemo.cpp @@ -14,7 +14,7 @@ #include "Bullet3Collision/NarrowPhaseCollision/b3Config.h" #include "GpuSoftBodyDemoInternalData.h" #include "Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.h" -#include "stb_image/stb_image.h" + static b3KeyboardCallback oldCallback = 0; extern bool gReset; @@ -298,50 +298,6 @@ GpuSoftClothDemo::~GpuSoftClothDemo() } -unsigned char* GpuSoftClothDemo::loadImage(const char* fileName, int& width, int& height, int& n) -{ - unsigned char *data = stbi_load(fileName, &width, &height, &n, 0); - if (data) - { - GLubyte* image=new GLubyte[512*256*4]; - for(int y=0;y<256;++y) - { - const int t=y>>4; - GLubyte* pi=image+y*512*3; - for(int x=0;x<512;++x) - { - 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; - } - } - - { - - for (int i=0;i