Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Help with efficient image handling  (Read 1508 times)

0 Members and 1 Guest are viewing this topic.

Marty

  • Newbie
  • *
  • Posts: 6
    • View Profile
Help with efficient image handling
« on: May 13, 2011, 02:08:15 pm »
Hello Everybody (Hi, dr. nick).

Im having an issue working with a few semi-large images.
I have 6 rooms for a small game i've made, in the size of 800x600.
Theres no movement or anything on the screens right now, so their primary function is to serve as a background. (By going through the maze i've programmed the images should change).

Now this works somewhat, but i have a few issues.

1. My program in its console version has a running time (with some debugging couts) of 0-10ms per calculation/move. If i add the images so
it loads them everytime, it ends up at 590ms. I tried making a sprite sheet and putting them all in there (however i cant really get it to "normal size" (128x128, 512x512) due the number of bgs ) - i end up with a whopping 1000+ ms per update. Thats not idea :/
Just tried it with the framerate counter, displaying 1 measly image gives me a framerate of 2fps.

2. I havent figured out how to do the offset yet, it seems i need to define a rectangle somewhere? :P wheres my ImageTex.offset command.
Atm i've just made the whole sf::Image Image thing and loaded the image in.
Figured out this one as well. Such helpfull documentation ^^

3. While not too bothersome, for some reason the window that is opend when the program starts - moves (the actual window) about 50 pixels after the first move. Thats kinda odd :P as i have no code that should influence the window position.

Edit:

4. Hm, noticed another thing. While the primary function of my window (atm.) was just to sit there and look pretty. It will shortly after being started display the "Program is not responding" on the window. Using the console i can still interact with the program - and doing so will refresh the window removing the "issue", it will however reappear shortly afterwards.

//Scratch this one-  i think i figured it out. Its due to the command console. Since they're both within the main game loop, and the loop "pauses" to wait for key input :P the window cant refresh and as such "dies" a little inside. Poor thing.[/b]

Thought of another question:
5. If i stuff all the graphics in a thread, will it then close the window when the thread reaches its end or will it be able to stay alive and be reused? (if so, how :P)

s3rius

  • Newbie
  • *
  • Posts: 21
    • View Profile
Help with efficient image handling
« Reply #1 on: May 16, 2011, 08:47:52 pm »
To 5:
The window will be closed once the sf::RenderWindow is destroyed.
So as long as you make sure that this stays alive, the window should stay.