Burningsvideo drawVertexPrimitiveList

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Burningsvideo drawVertexPrimitiveList

Post by Sylence »

I noticed that the Burnigsvideo driver fails to draw the GridSceneNode by Dark_Kilauea while the Direct3d9 and OpenGl driver works perfectly.

I digged a bit around and found out that in CBurningVideoDriver::VertexCache_get() the VertexCache variable
is not initialized properly when called from CBurningVideoDriver::drawVertexPrimitiveList() the second time leading to an access violation.

Tested with SVN 2397 on Vista SP1 x64 and Win7 RC x64 (both as a 32bit application)

This application produces the error:
( Note that the code using the OpenGL drivers works but crashes with BurningsVideo)

Code: Select all

#include "irrlicht.h"
using namespace irr;
using namespace video;
using namespace core;
using namespace scene;

#pragma comment(lib, "irrlicht.lib")

SMeshBuffer Buffer;

void createMeshBuffer()
{
	core::dimension2du m_size( 1024, 1024 );
	SColor color(255,128,128,128);

	u32 m_numVertices = (m_size.Width + 1) * 2 * 2;
	u32 m_numLines = m_numVertices / 2;

	//Temporary buffers
	video::S3DVertex* m_vertexBuffer = new video::S3DVertex[m_numVertices];
	u16* m_indexBuffer = new u16[m_numVertices];

	//Set our left corner
	core::vector3df leftMost = core::vector3df(-512,0,-512);
	//Set our right corner
	core::vector3df rightMost = core::vector3df(512,0,512);

	u32 vertIndex = 0;
	u32 indexIndex = 0;

	//X-axis lines
	for(u32 x = 0; x <= m_size.Width; x++)
	{
		core::vector3df start = leftMost;
		start.X += x ;

		core::vector3df end = rightMost;
		end.X = start.X;

		m_vertexBuffer[vertIndex++] = video::S3DVertex(start, core::vector3df(0,1,0), color, core::vector2df(0.0f, 0.0f));
		m_vertexBuffer[vertIndex++] = video::S3DVertex(end, core::vector3df(0,1,0), color, core::vector2df(0.0f, 0.0f));

		m_indexBuffer[indexIndex] = indexIndex++;
		m_indexBuffer[indexIndex] = indexIndex++;
	}

	//Z-axis lines
	for(u32 z = 0; z <= m_size.Width; z++)
	{
		core::vector3df start = leftMost;
		start.Z += z ;

		core::vector3df end = rightMost;
		end.Z = start.Z;

		m_vertexBuffer[vertIndex++] = video::S3DVertex(start, core::vector3df(0,1,0), color, core::vector2df(0.0f, 0.0f));
		m_vertexBuffer[vertIndex++] = video::S3DVertex(end, core::vector3df(0,1,0), color, core::vector2df(0.0f, 0.0f));

		m_indexBuffer[indexIndex] = indexIndex++;
		m_indexBuffer[indexIndex] = indexIndex++;
	}

	Buffer.append(m_vertexBuffer,m_numVertices,m_indexBuffer,m_numVertices);

	// Create our box, it is the size of the grid exactly, plus 1 in the Y axis
	Buffer.BoundingBox = core::aabbox3df(-(f32)m_size.Width/2,-0.5f,-(f32)m_size.Width/2,(f32)m_size.Width/2,0.5f,(f32)m_size.Width/2);

	delete [] m_vertexBuffer;
	delete [] m_indexBuffer;
}

int main( int argc, char** argv )
{
	createMeshBuffer();

	IrrlichtDevice* device = 0;
	IVideoDriver* driver = 0;

	//////////////////////////////////////////////////////////////////////////

	device = createDevice( EDT_OPENGL );
	driver = device->getVideoDriver();

	driver->beginScene();
	driver->setMaterial( Buffer.Material );
	driver->setTransform( ETS_WORLD, matrix4() );
	driver->drawVertexPrimitiveList(Buffer.getVertices(), Buffer.getVertexCount(), Buffer.getIndices(), Buffer.getVertexCount()/2, video::EVT_STANDARD, scene::EPT_LINES);
	driver->endScene();

	device->closeDevice();
	device->drop();

	//////////////////////////////////////////////////////////////////////////

	device = createDevice( EDT_BURNINGSVIDEO );
	driver = device->getVideoDriver();

	driver->beginScene();
	driver->setMaterial( Buffer.Material );
	driver->setTransform( ETS_WORLD, matrix4() );
	driver->drawVertexPrimitiveList(Buffer.getVertices(), Buffer.getVertexCount(), Buffer.getIndices(), Buffer.getVertexCount()/2, video::EVT_STANDARD, scene::EPT_LINES);
	driver->endScene();

	device->closeDevice();
	device->drop();

	//////////////////////////////////////////////////////////////////////////
	return 0;
}
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Superb test case, thanks! If only all bug reports were so nice :)
Tracked and assigned to Thomas
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Post Reply