fix some compile issues using premake

use textured cube/sphere model for test
This commit is contained in:
Erwin Coumans
2016-06-02 13:54:52 -07:00
parent aa4d2ae01d
commit 5bf125cab5
7 changed files with 23 additions and 15 deletions

View File

@@ -10,5 +10,5 @@ newmtl cube
Ks 0.0000 0.0000 0.0000 Ks 0.0000 0.0000 0.0000
Ke 0.0000 0.0000 0.0000 Ke 0.0000 0.0000 0.0000
map_Ka cube.tga map_Ka cube.tga
map_Kd floor_diffuse.tga map_Kd cube.png

View File

@@ -147,7 +147,9 @@ TinyRendererSetup::TinyRendererSetup(struct GUIHelperInterface* gui)
m_internalData = new TinyRendererSetupInternalData(gui->getAppInterface()->m_window->getWidth(),gui->getAppInterface()->m_window->getHeight()); m_internalData = new TinyRendererSetupInternalData(gui->getAppInterface()->m_window->getWidth(),gui->getAppInterface()->m_window->getHeight());
m_app->m_renderer->enableBlend(true); m_app->m_renderer->enableBlend(true);
const char* fileName = "teddy.obj";//cube.obj";//textured_sphere_smooth.obj";//cube.obj";
const char* fileName = "textured_sphere_smooth.obj";
fileName = "cube.obj";
{ {

View File

@@ -527,7 +527,6 @@ void PhysicsClientExample::initPhysics()
m_selectedBody = -1; m_selectedBody = -1;
m_prevSelectedBody = -1; m_prevSelectedBody = -1;
if (m_options == eCLIENTEXAMPLE_SERVER)
{ {
m_canvas = m_guiHelper->get2dCanvasInterface(); m_canvas = m_guiHelper->get2dCanvasInterface();
if (m_canvas) if (m_canvas)
@@ -557,9 +556,13 @@ void PhysicsClientExample::initPhysics()
} }
m_isOptionalServerConnected = m_physicsServer.connectSharedMemory( m_guiHelper);
} }
if (m_options == eCLIENTEXAMPLE_SERVER)
{
m_isOptionalServerConnected = m_physicsServer.connectSharedMemory( m_guiHelper);
}
m_physicsClientHandle = b3ConnectSharedMemory(m_sharedMemoryKey); m_physicsClientHandle = b3ConnectSharedMemory(m_sharedMemoryKey);
//m_physicsClientHandle = b3ConnectPhysicsLoopback(SHARED_MEMORY_KEY); //m_physicsClientHandle = b3ConnectPhysicsLoopback(SHARED_MEMORY_KEY);
//m_physicsClientHandle = b3ConnectPhysicsDirect(); //m_physicsClientHandle = b3ConnectPhysicsDirect();

View File

@@ -111,7 +111,8 @@ public:
if (shapeIndex>=0) if (shapeIndex>=0)
{ {
TinyRenderObjectData* swObj = new TinyRenderObjectData(m_swWidth,m_swHeight,m_rgbColorBuffer,m_depthBuffer); TinyRenderObjectData* swObj = new TinyRenderObjectData(m_swWidth,m_swHeight,m_rgbColorBuffer,m_depthBuffer);
swObj->registerMeshShape(vertices,numvertices,indices,numIndices); float rgbaColor[4] = {1,1,1,1};
swObj->registerMeshShape(vertices,numvertices,indices,numIndices,rgbaColor);
//swObj->createCube(1,1,1);//MeshShape(vertices,numvertices,indices,numIndices); //swObj->createCube(1,1,1);//MeshShape(vertices,numvertices,indices,numIndices);
m_swRenderObjects.insert(shapeIndex,swObj); m_swRenderObjects.insert(shapeIndex,swObj);
} }

View File

@@ -254,7 +254,8 @@ struct TinyRendererGUIHelper : public GUIHelperInterface
int shapeIndex = m_swRenderObjects.size(); int shapeIndex = m_swRenderObjects.size();
TinyRenderObjectData* swObj = new TinyRenderObjectData(m_swWidth,m_swHeight,m_rgbColorBuffer,m_depthBuffer); TinyRenderObjectData* swObj = new TinyRenderObjectData(m_swWidth,m_swHeight,m_rgbColorBuffer,m_depthBuffer);
swObj->registerMeshShape(vertices,numvertices,indices,numIndices); float rgbaColor[4] = {1,1,1,1};
swObj->registerMeshShape(vertices,numvertices,indices,numIndices,rgbaColor);
//swObj->createCube(1,1,1);//MeshShape(vertices,numvertices,indices,numIndices); //swObj->createCube(1,1,1);//MeshShape(vertices,numvertices,indices,numIndices);
m_swRenderObjects.insert(shapeIndex,swObj); m_swRenderObjects.insert(shapeIndex,swObj);
return shapeIndex; return shapeIndex;

View File

@@ -76,11 +76,12 @@ struct Shader : public IShader {
float diff = ambient+b3Min(b3Max(0.f, bn*m_light_dir_local),(1-ambient)); float diff = ambient+b3Min(b3Max(0.f, bn*m_light_dir_local),(1-ambient));
//float diff = b3Max(0.f, n*m_light_dir_local); //float diff = b3Max(0.f, n*m_light_dir_local);
color = m_model->diffuse(uv)*diff; color = m_model->diffuse(uv)*diff;
//colors are store in BGRA?
color = TGAColor(color[0]*m_colorRGBA[2], //warning: bgra color is swapped to rgba to upload texture
color[1]*m_colorRGBA[1], color.bgra[0] *= m_colorRGBA[0];
color[2]*m_colorRGBA[0], color.bgra[1] *= m_colorRGBA[1];
color[3]*m_colorRGBA[3]); color.bgra[2] *= m_colorRGBA[2];
color.bgra[3] *= m_colorRGBA[3];
return false; return false;
} }

View File

@@ -57,9 +57,9 @@ void Model::setDiffuseTextureFromData(unsigned char* textureImage,int textureWid
for (int j=0;j<textureHeight;j++) for (int j=0;j<textureHeight;j++)
{ {
TGAColor color; TGAColor color;
color.bgra[0] = textureImage[(i+j*textureWidth)*3+0]; color.bgra[0] = textureImage[(i+j*textureWidth)*3+0];
color.bgra[1] = textureImage[(i+j*textureWidth)*3+1]; color.bgra[1] = textureImage[(i+j*textureWidth)*3+1];
color.bgra[2] = textureImage[(i+j*textureWidth)*3+2]; color.bgra[2] = textureImage[(i+j*textureWidth)*3+2];
color.bgra[3] = 255; color.bgra[3] = 255;
color.bytespp = 3; color.bytespp = 3;