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

Author Topic: 512x512 texture slowing game down  (Read 4357 times)

0 Members and 1 Guest are viewing this topic.

wademcgillis

  • Newbie
  • *
  • Posts: 36
    • View Profile
512x512 texture slowing game down
« on: February 13, 2010, 07:22:30 pm »
SFML's graphics rendering is supposed to be faster than Game Maker, right?

Well, I'm trying to display two 512x512 png images on the screen, and the framerate drops drastically.


http://www.wademcgillis.com/downloads/stupidcode.zip

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
512x512 texture slowing game down
« Reply #1 on: February 14, 2010, 12:21:38 am »
Quote
SFML's graphics rendering is supposed to be faster than Game Maker, right?

I have no idea, I don't know how Game Maker is implemented, and I've never used it.

Quote
Well, I'm trying to display two 512x512 png images on the screen, and the framerate drops drastically

Can you show your code?

Quote
http://www.wademcgillis.com/downloads/stupidcode.png

This link doesn't work.
Laurent Gomila - SFML developer

Xeon06

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
512x512 texture slowing game down
« Reply #2 on: February 14, 2010, 01:15:13 am »
Are you sure you're not also loading the images every frame?

wademcgillis

  • Newbie
  • *
  • Posts: 36
    • View Profile
512x512 texture slowing game down
« Reply #3 on: February 14, 2010, 01:20:01 am »
Quote from: "Laurent"

Quote
http://www.wademcgillis.com/downloads/stupidcode.png

This link doesn't work.


Oops. I wrote png instead of zip

Quote from: "Xeon06"
Are you sure you're not also loading the images every frame?

Yes. I'm sure.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
512x512 texture slowing game down
« Reply #4 on: February 14, 2010, 01:41:33 am »
I've done a comparison of Game Maker and SFML before. SFML was much faster at everything. It's most likely your code. Also, your code is VERY messy and unsafe. You call new a lot but I don't see you calling delete anywhere!
I use the latest build of SFML2

wademcgillis

  • Newbie
  • *
  • Posts: 36
    • View Profile
512x512 texture slowing game down
« Reply #5 on: February 14, 2010, 01:57:54 am »
Quote from: "OniLink10"
I've done a comparison of Game Maker and SFML before. SFML was much faster at everything. It's most likely your code. Also, your code is VERY messy and unsafe. You call new a lot but I don't see you calling delete anywhere!


How do I call new "a lot"? Each new only gets called once, it's not like it's a memory leak since the game goes out of memory when it closes.


Also, my code is very readable in my perspective. I'd probably think your code is very messy too.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
512x512 texture slowing game down
« Reply #6 on: February 14, 2010, 05:50:07 am »
Quote from: "wademcgillis"
Quote from: "OniLink10"
I've done a comparison of Game Maker and SFML before. SFML was much faster at everything. It's most likely your code. Also, your code is VERY messy and unsafe. You call new a lot but I don't see you calling delete anywhere!


How do I call new "a lot"? Each new only gets called once, it's not like it's a memory leak since the game goes out of memory when it closes.


Also, my code is very readable in my perspective. I'd probably think your code is very messy too.
By "a lot", I mean "multiple times without calling delete". If you use new, your objects will NEVER go out of scope, because new defines them OUTSIDE of your program's scope, on the GLOBAL heap. You need to call delete to make them go out of scope. If you don't, they won't go out of scope until the computer is shut down.
I use the latest build of SFML2

dunce

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
512x512 texture slowing game down
« Reply #7 on: February 14, 2010, 07:00:19 pm »
Quote
Also, my code is very readable in my perspective. I'd probably think your code is very messy too.

I have not seen OniLink10's code, but have seen yours. Sorry but it's really a mess. Not only because of allocating memory without freeing it. Classes and c-stylish free functions, lumps of implementation code in *.h files that should be placed in *.cpp files, and so on... No offense, just my friendly opinion. :wink:

wademcgillis

  • Newbie
  • *
  • Posts: 36
    • View Profile
512x512 texture slowing game down
« Reply #8 on: February 14, 2010, 11:12:31 pm »
Quote from: "dunce"
Quote
Also, my code is very readable in my perspective. I'd probably think your code is very messy too.

I have not seen OniLink10's code, but have seen yours. Sorry but it's really a mess. Not only because of allocating memory without freeing it. Classes and c-stylish free functions, lumps of implementation code in *.h files that should be placed in *.cpp files, and so on... No offense, just my friendly opinion. :wink:


I have never been able to link multiple cpp files together. Well, I have... but never when code in one cpp file depends on code in another. If I try to do that, "multiple defintion. ur code is fubar'd"

edit1: This wasn't a discussion of my code. This is a discussion of why, when I display two 512x512 textures, the game runs like poo.

edit2: wow. All openGL based games are doing this. Sorry, it wasn't a problem with SFML...

wademcgillis

  • Newbie
  • *
  • Posts: 36
    • View Profile
512x512 texture slowing game down
« Reply #9 on: February 14, 2010, 11:32:30 pm »
edit: how did I double post?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
512x512 texture slowing game down
« Reply #10 on: February 14, 2010, 11:35:51 pm »
Maybe you just need to update your graphics drivers.
Laurent Gomila - SFML developer

wademcgillis

  • Newbie
  • *
  • Posts: 36
    • View Profile
512x512 texture slowing game down
« Reply #11 on: February 14, 2010, 11:51:50 pm »
Quote from: "Laurent"
Maybe you just need to update your graphics drivers.


I started doing that right before you made that post.

Jedimace1

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
512x512 texture slowing game down
« Reply #12 on: February 25, 2010, 03:34:48 am »
Quote from: "wademcgillis"
Quote from: "OniLink10"
I've done a comparison of Game Maker and SFML before. SFML was much faster at everything. It's most likely your code. Also, your code is VERY messy and unsafe. You call new a lot but I don't see you calling delete anywhere!


How do I call new "a lot"? Each new only gets called once, it's not like it's a memory leak since the game goes out of memory when it closes.


Also, my code is very readable in my perspective. I'd probably think your code is very messy too.


If you have pointers pointing to a variable using new, then the pointers go out of scope but the data they point to doesn't.
-Jedimace1