Merge commit 'upstream/master'

This commit is contained in:
Marc Zinnschlag 2010-06-15 09:14:26 +02:00
commit 12427b1f3e

View file

@ -177,9 +177,13 @@ static void createMaterial(const String &name,
// make sure that all materials are given unique names. // make sure that all materials are given unique names.
static String getUniqueName(const String &input) static String getUniqueName(const String &input)
{ {
#ifdef WIN32
#define snprintf _snprintf
#endif
static int addon = 0; static int addon = 0;
static char buf[8]; static char buf[8];
snprintf(buf,8,"_%d", addon++); snprintf(buf, 8, "_%d", addon++);
// Don't overflow the buffer // Don't overflow the buffer
if(addon > 999999) addon = 0; if(addon > 999999) addon = 0;
@ -248,8 +252,8 @@ static void createOgreMesh(Mesh *mesh, NiTriShape *shape, const String &material
{ {
const float *colors = data->colors.ptr; const float *colors = data->colors.ptr;
RenderSystem* rs = Root::getSingleton().getRenderSystem(); RenderSystem* rs = Root::getSingleton().getRenderSystem();
RGBA colorsRGB[numVerts]; std::vector<RGBA> colorsRGB(numVerts);
RGBA *pColour = colorsRGB; RGBA *pColour = &colorsRGB.front();
for(int i=0; i<numVerts; i++) for(int i=0; i<numVerts; i++)
{ {
rs->convertColourValue(ColourValue(colors[0],colors[1],colors[2], rs->convertColourValue(ColourValue(colors[0],colors[1],colors[2],
@ -260,7 +264,7 @@ static void createOgreMesh(Mesh *mesh, NiTriShape *shape, const String &material
vbuf = HardwareBufferManager::getSingleton().createVertexBuffer( vbuf = HardwareBufferManager::getSingleton().createVertexBuffer(
VertexElement::getTypeSize(VET_COLOUR), VertexElement::getTypeSize(VET_COLOUR),
numVerts, HardwareBuffer::HBU_STATIC_WRITE_ONLY); numVerts, HardwareBuffer::HBU_STATIC_WRITE_ONLY);
vbuf->writeData(0, vbuf->getSizeInBytes(), colorsRGB, true); vbuf->writeData(0, vbuf->getSizeInBytes(), &colorsRGB.front(), true);
bind->setBinding(nextBuf++, vbuf); bind->setBinding(nextBuf++, vbuf);
} }