I was wondering if it's possible to move the vertices and indices into the GPU and then remove it from memory locally.
You probably know that in OpenGL you can, for example, do this:
Code: Select all
Vertex *vertices = new Vertex[147456];
// Generate vertices ...
glBindBuffer(...)
glBufferData(...)
delete[] vertices;
Code: Select all
#include <irrlicht/irrlicht.h>
int main()
{
irr::IrrlichtDevice *device = irr::createDevice(irr::video::E_DRIVER_TYPE::EDT_OPENGL, irr::core::dimension2du(1280, 720), 32U, false, false, false, 0);
if (device)
{
device->setResizable(true);
irr::video::IVideoDriver *driver = device->getVideoDriver();
irr::scene::CDynamicMeshBuffer *buffer = new irr::scene::CDynamicMeshBuffer(irr::video::E_VERTEX_TYPE::EVT_STANDARD, irr::video::E_INDEX_TYPE::EIT_16BIT);
buffer->Material.Lighting = false;
buffer->Material.UseMipMaps = false;
buffer->Material.BackfaceCulling = true;
buffer->Material.TextureLayer[0].BilinearFilter = false;
buffer->Material.TextureLayer[0].AnisotropicFilter = 16;
{
irr::core::rectf uv(0.0f, 0.0f, 1.0f, 1.0f);
irr::scene::IVertexBuffer &vertices = buffer->getVertexBuffer();
irr::scene::IIndexBuffer &indices = buffer->getIndexBuffer();
vertices.push_back(irr::video::S3DVertex(-1, 1, 0, 0, 0, 0, irr::video::SColor(255, 255, 255, 255), uv.UpperLeftCorner.X, uv.UpperLeftCorner.Y));
vertices.push_back(irr::video::S3DVertex(1, 1, 0, 0, 0, 0, irr::video::SColor(255, 255, 255, 255), uv.LowerRightCorner.X, uv.UpperLeftCorner.Y));
vertices.push_back(irr::video::S3DVertex(-1, -1, 0, 0, 0, 0, irr::video::SColor(255, 255, 255, 255), uv.UpperLeftCorner.X, uv.LowerRightCorner.Y));
vertices.push_back(irr::video::S3DVertex(1, 1, 0, 0, 0, 0, irr::video::SColor(255, 255, 255, 255), uv.LowerRightCorner.X, uv.UpperLeftCorner.Y));
vertices.push_back(irr::video::S3DVertex(1, -1, 0, 0, 0, 0, irr::video::SColor(255, 255, 255, 255), uv.LowerRightCorner.X, uv.LowerRightCorner.Y));
vertices.push_back(irr::video::S3DVertex(-1, -1, 0, 0, 0, 0, irr::video::SColor(255, 255, 255, 255), uv.UpperLeftCorner.X, uv.LowerRightCorner.Y));
indices.push_back(0);
indices.push_back(1);
indices.push_back(2);
indices.push_back(3);
indices.push_back(4);
indices.push_back(5);
}
while (device->run())
{
driver->beginScene();
irr::core::matrix4 matrix;
matrix.setScale(irr::core::vector3df(0.5f, 0.5f, 0.5f));
driver->setTransform(irr::video::E_TRANSFORMATION_STATE::ETS_WORLD, matrix);
driver->setMaterial(buffer->Material);
driver->drawMeshBuffer(buffer);
driver->endScene();
}
}
}