Need a script that shows a picture...

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.
Post Reply
IrrGamer
Posts: 22
Joined: Fri Oct 05, 2007 3:30 am

Need a script that shows a picture...

Post by IrrGamer »

I have a start menu picture (with "new game" only lol) and I need to show it once I draw the device in full screen. How can I post a simple picture in Irrlicht and wait for the Enter Key?
Cristiano87
Posts: 13
Joined: Wed Oct 03, 2007 9:00 am
Location: Milano, Italia

Post by Cristiano87 »

you should study about "state machine teory" and extending IEventReceiver class (check the tutorials)
IrrGamer
Posts: 22
Joined: Fri Oct 05, 2007 3:30 am

Post by IrrGamer »

Hi,
I am currently studying the tutorials on Irrlicht3d.org and I think I'm starting to understand- until I hit a pitfall.

I understood creating devices and initializing etc, but now I'm confused at the end part of the tutorial.

Here's what I don't get:

Code: Select all

int lastFPS = -1;while(device->run())

{

  driver->beginScene(true, true, video::SColor(0,200,200,200));

  smgr->drawAll();

  driver->endScene();  int fps = driver->getFPS();  if (lastFPS != fps)

  {

     core::stringw str = L"Irrlicht Engine - Quake 3 Map example [";     str += driver->getName();     str += "] FPS:";     str += fps;     device->setWindowCaption(str.c_str());     lastFPS = fps;

  }

}
And here's what I want to learn more of:

Code: Select all

smgr->addCameraSceneNodeFPS(); 
Can someone describe me what these two mean in english?

Thx
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

the 1st is the main render loop...
it starts a new screen (clears it), draws all 3d stuff (SceneManager) and ends the drawing,,, then it gets the actual FPS (frames per second) rate and writes it to the window caption...

the 2nd simply adds a FPS (first person) camera to the scene...
search in the API docu (the help file) for more informations, also for other Irrlicht functions you don't know, all is explained there... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrGamer
Posts: 22
Joined: Fri Oct 05, 2007 3:30 am

Post by IrrGamer »

I understand now. That makes sense... getFPS gathers the FPS and the if command writes it in the window. That makes sense :)
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

no, not exactly this way, but the code is a little bit unformatted...
here the same code better formatted and with comments:

Code: Select all

// get the actual FPS
int fps = driver->getFPS();  

// compare lastFPS with actual FPS to see if the FPS rate has changed
if (lastFPS != fps){ 

  // creating a string
  core::stringw str = L"Irrlicht Engine - Quake 3 Map example [";     
  str += driver->getName();     
  str += "] FPS:";
  str += fps;     

  // set the new window caption
  device->setWindowCaption(str.c_str());     
  
  // set lastFPS to actual fps for next comparsion (if)
  lastFPS = fps;

}
the comparsion of last FPS and actual FPS is not really neccessary but it saves CPU power and reduces flickering of the caption (try it without the if statement and you'll see it works too)... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrGamer
Posts: 22
Joined: Fri Oct 05, 2007 3:30 am

Post by IrrGamer »

Without the If command it flickers to much on my laptop (most likely because it isn't meant for gaming) but on my desktop it looks steady...

Would it still work if you removed the whole if command, device->getFPS() and the integer fps? I do not see why I would want to waste CPU power in my game because my game is Fullscreen, so screen captioning isn't neccessary.

Thx for helpin' me. Anyways, how can I use IGUIEnvironment to display pictures on the screen? I loaded a Quake 3 map and I want to display maybe a small logo at the top left corner. I know one of the examples has it but I don't know how they implemented it.

EDIT: Uhh, DUH! lol, a tut named 2d graphics was right in the tutorial section! Nevermind about the logo thing.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

IrrGamer wrote:Without the If command it flickers to much on my laptop (most likely because it isn't meant for gaming) but on my desktop it looks steady...
yes, it's normal, I told you the if reduces (almost turns off) the flickering of the caption...
IrrGamer wrote:Would it still work if you removed the whole if command, device->getFPS() and the integer fps? I do not see why I would want to waste CPU power in my game because my game is Fullscreen, so screen captioning isn't neccessary.
Correct, or set the caption at the beginning so you still have a caption but don't update it... ;)
IrrGamer wrote:Thx for helpin' me.
np ;)
IrrGamer wrote:Anyways, how can I use IGUIEnvironment to display pictures on the screen? I loaded a Quake 3 map and I want to display maybe a small logo at the top left corner. I know one of the examples has it but I don't know how they implemented it.
EDIT: Uhh, DUH! lol, a tut named 2d graphics was right in the tutorial section! Nevermind about the logo thing.
nc :lol:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply