I wanted to display an image, and after displaying the image I wanted to free the memory, (so that I can use it to display some other image).
Here is what I did,
Code: Select all
//
//
// g++ -I/home/laeeq/irrl/irrlicht-1.7.1/include -L/home/laeeq/irrl/irrlicht-1.7.1/lib/Linux tt_2.cc -lIrrlicht -lGL -lXxf86vm -lXext -lX11
//
//
#include <irrlicht.h>
#include <unistd.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
IrrlichtDevice *device;
IVideoDriver *driver;
ITexture *tex_1;
int main()
{
int i;
device = createDevice(EDT_OPENGL, dimension2d<u32>(640, 480) );
if(!device)
{
printf("%s:%u unable to create device\n", __FILE__, __LINE__);
return 1;
}
driver = device->getVideoDriver();
while(device->run() && driver)
{
sleep(1);
printf("creating texture.\n");
tex_1 = driver->getTexture("/home/laeeq/multi_media/png_seq/FCAJ_BigWin/FCAJ_BigWin_025.png");
driver->beginScene(true, true, SColor(255, 120, 102, 136) );
driver->draw2DImage(tex_1, position2d<s32>(0, 0), rect<s32>(0, 0, 443, 250), 0, SColor(255, 255, 255, 255), true);
driver->endScene();
sleep(1);
printf("Going to drop\n");
tex_1->drop();
sleep(1);
printf("dropped\n");
}
return 0;
}
Code: Select all
creating texture.
Loaded texture: /home/laeeq/multi_media/png_seq/FCAJ_BigWin/FCAJ_BigWin_025.png
Going to drop
dropped
creating texture.
Loaded texture: /home/laeeq/multi_media/png_seq/FCAJ_BigWin/FCAJ_BigWin_025.png
Going to drop
dropped
creating texture.
Loaded texture: /home/laeeq/multi_media/png_seq/FCAJ_BigWin/FCAJ_BigWin_025.png
Going to drop
dropped
creating texture.
Loaded texture: /home/laeeq/multi_media/png_seq/FCAJ_BigWin/FCAJ_BigWin_025.png
Going to drop
dropped
creating texture.
Segmentation fault
Code: Select all
tex_1->drop();
Let me confess, this is my attempt at learning about basics of textures, I am coming from an SDL background, which doesn't have any notion of texture.