Too slow 2D

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
GRAVITY
Posts: 13
Joined: Thu Feb 25, 2010 6:58 pm

Too slow 2D

Post by GRAVITY »

Hello everyone! :)
I just recently started to use IrrLicht

I decided to experiment with 2D graphics. upload picture "demoback.jpg" from the folder "media". well, and rendered them in the loop 4 times. draw the same cursor-image.

when drawing visible plume from the cursor x_x.
Surely such a small speed of rendering in 2D IrrLicht?

I work in ubuntu9.10, using code blocks.
video card - gf9500gt, 2 gigabytes of RAM, intel dual core 3GHz.

sorry for my bad english
Last edited by GRAVITY on Sun Feb 28, 2010 5:02 pm, edited 1 time in total.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

what?
show some code please
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
GRAVITY
Posts: 13
Joined: Thu Feb 25, 2010 6:58 pm

Post by GRAVITY »

Code: Select all

#include <irrlicht.h>
#include "driverChoice.h"
#include <string.h>

using namespace irr;

using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif

int initGraphics(void);

IrrlichtDevice *device;
IVideoDriver* driver;
ISceneManager* smgr;
IGUIEnvironment* guienv;

class MyEventReceiver : public IEventReceiver
{
public:
	// This is the one method that we have to implement
	virtual bool OnEvent(const SEvent& event)
	{
		// Remember whether each key is down or up
		if (event.EventType == irr::EET_KEY_INPUT_EVENT)
			KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;

		return false;
	}

	// This is used to check whether a key is being held down
	virtual bool IsKeyDown(EKEY_CODE keyCode) const
	{
		return KeyIsDown[keyCode];
	}

	MyEventReceiver()
	{
		for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
			KeyIsDown[i] = false;
	}

private:
	// We use this array to store the current state of each key
	bool KeyIsDown[KEY_KEY_CODES_COUNT];
};

MyEventReceiver receiver;




int main()
{
    initGraphics();
 
	ITexture* img_pl = driver->getTexture("demoback.jpg");
//	ITexture* img_pl = driver->getTexture("pl.png");
	//driver->makeColorKeyTexture(images, position2d<s32>(0,0));

	gui::IGUIFont* font = device->getGUIEnvironment()->getBuiltInFont();
	gui::IGUIFont* font2 = device->getGUIEnvironment()->getFont("../irrlicht-1.7.1/media/fonthaettenschweiler.bmp");

    //rect<s32> imp1(0,0,385,78);
//	rect<s32> imp2(387,15,423,78);

	driver->getMaterial2D().TextureLayer[0].BilinearFilter=true;
	driver->getMaterial2D().AntiAliasing=16;

	while(device->run())
	{
	    u32 time = device->getTimer()->getTime();
		position2d<s32> m = device->getCursorControl()->getPosition();

        if(receiver.IsKeyDown(KEY_ESCAPE)) break;

		driver->beginScene(true, true, SColor(255,100,101,140));

			driver->draw2DImage(img_pl, position2d<s32>(0,0),
				rect<s32>(0,0,512,512), 0,
				SColor(255,255,255,255), true);

			driver->draw2DImage(img_pl, position2d<s32>(0,512),
				rect<s32>(0,0,512,512), 0,
				SColor(155,255,255,255), true);

			driver->draw2DImage(img_pl, position2d<s32>(512,512),
				rect<s32>(0,0,512,512), 0,
				SColor(155,255,255,255), true);
			driver->draw2DImage(img_pl, position2d<s32>(512,0),
				rect<s32>(0,0,512,512), 0,
				SColor(155,255,255,255), true);

				font2->draw(L"This demo shows that Irrlicht is also capable of drawing 2D graphics.",
					core::rect<s32>(m.X-20, m.Y-20, m.X+20, m.Y+20),
					video::SColor(255,255,255,255),1,1);

			driver->draw2DRectangle(video::SColor(155,255,255,0),
				core::rect<s32>(m.X-20, m.Y-20, m.X+20, m.Y+20));


		smgr->drawAll();
//		guienv->drawAll();

		driver->endScene();
	}

	device->drop();

	return 0;
}


int initGraphics()
{
    device = createDevice(EDT_OPENGL, dimension2d<u32>(1280, 1024), 32, true, false, false, &receiver);
	if (!device) return 1;

	device->setWindowCaption(L"Just a caption :)");


	driver = device->getVideoDriver();
	smgr = device->getSceneManager();
	guienv = device->getGUIEnvironment();

	return 0;
}
Thx!
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

Try changing antialiasing to 0 and see if speed increases.
GRAVITY
Posts: 13
Joined: Thu Feb 25, 2010 6:58 pm

Post by GRAVITY »

speed has not increased :(
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post by randomMesh »

GRAVITY wrote:

Code: Select all

dimension2d<u32>(1280, 1024)
Are you sure your graphic card supports this strange resolution? Maybe try a more common one.
Last edited by randomMesh on Sun Feb 28, 2010 8:44 pm, edited 1 time in total.
"Whoops..."
Murloc992
Posts: 272
Joined: Mon Apr 13, 2009 2:45 pm
Location: Utena,Lithuania

Post by Murloc992 »

randomMesh wrote:
GRAVITY wrote:

Code: Select all

device = dimension2d<u32>(1280, 1024)
Are you sure your graphic card supports this strange resolution? Maybe try a more common one.
That's not a strange resolution :) That's a common 4:3 19" display :)
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post by randomMesh »

Murloc992 wrote:That's not a strange resolution :) That's a common 4:3 19" display :)
Oh, sorry, my bad. Just misread it. I run the same resolution. ;)
"Whoops..."
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Using the 2dmaterial settings has some performance problem. However, I don't know how much performance drop "visible plume" means. Some numbers about FPS would help more.
GRAVITY
Posts: 13
Joined: Thu Feb 25, 2010 6:58 pm

Post by GRAVITY »

only 19 FPS.

Another such moment .. I use the built-in video driver. hmm ... perhaps this is the reason for such a low fps
I'll try to setup nvidia drivers, and then report the results!

Thanks for the answers!)
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Post by polylux »

GRAVITY wrote:only 19 FPS.

Another such moment .. I use the built-in video driver. hmm ... perhaps this is the reason for such a low fps
I'll try to setup nvidia drivers, and then report the results!

Thanks for the answers!)
Replace "perhaps" with "for sure". ;)
beer->setMotivationCallback(this);
GRAVITY
Posts: 13
Joined: Thu Feb 25, 2010 6:58 pm

Post by GRAVITY »

exactly))

I did not think that the built-in drivers such slow)
Now I was convinced :)

FPF risen to 400)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well built-in driver is probably the wrong term. It's a software renderer, which means no hardware acceleration.
GRAVITY
Posts: 13
Joined: Thu Feb 25, 2010 6:58 pm

Post by GRAVITY »

Thanks for the explanation.

I have another question:
I have image size 1000x1000. And i want draw this in another resolution - 500x500. How can I scale this?

Thanks a lot.
Ubuntu 9.10 + Codeblocks 8.02 + irrlicht 1.7.1
GRAVITY
Posts: 13
Joined: Thu Feb 25, 2010 6:58 pm

Post by GRAVITY »

Help ))
Ubuntu 9.10 + Codeblocks 8.02 + irrlicht 1.7.1
Post Reply