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

Author Topic: Framerate, rendering and optimisations  (Read 5028 times)

0 Members and 1 Guest are viewing this topic.

Stew_822

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • http://circean-studios.co.cc
    • Email
Framerate, rendering and optimisations
« on: February 15, 2012, 10:57:04 pm »
Hi! :)

So I'm coding this little game, just for fun, and when I add say more than twenty objects, it starts to go downhill. I have a recent computer with a graphics card (nvidia geforce GT 540m, it says) and a intel core i5 CPU. So it's not slow or anything.

Could it possibly be because I'm using linux, and I couldn't work out the drivers and I think I'm using the software renderer? AssaultCube runs really slowly on it. Is that the cause?

I commented out the line that initiates the rendering, and got an FPS of about 64-70. Which is good, because I set the renderWindow to have a max framerate of 64. But when the line is uncommented (that is, I allow it to render my objects, of which I only have about 40, 32x32 sprites) the FPS drops. A lot. I got it down to 18 once.

I was going to post a whole lot more info, but it just hit me that it's probably the software renderer, isn't it?

*groans* I'm going to have to reinstall linux :(
It's better to keep your mouth shut and give the impression that you're stupid than to open it and remove all doubt.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Framerate, rendering and optimisations
« Reply #1 on: February 16, 2012, 08:01:35 am »
1) Please stop that smiley flooding -- I thought a spam bot posted here.

2) Show source code, maybe you're doing something terribly wrong.

3) Do other OpenGL applications run slow, too? What does glxinfo say?

4) You mostly NEVER want to reinstall Linux. Better repair it...

Sam42

  • Newbie
  • *
  • Posts: 16
    • View Profile
Framerate, rendering and optimisations
« Reply #2 on: February 16, 2012, 01:08:20 pm »
I assume you're using a laptop, and so the problem is likely to do with nvidia optimus, and its poor support in linux.

Likely you'll want to give this a careful read

Essentially bumblebee/ironhide is currently your only option to actually use the nvidia card. Do not install the nvidia drivers directly, they will cause you to lose all acceleration, even from the integrated chip.

Aside from that, what tank said.

danman

  • Hero Member
  • *****
  • Posts: 1121
    • View Profile
    • Email
Framerate, rendering and optimisations
« Reply #3 on: February 16, 2012, 04:39:20 pm »
Stew : which drivers are you using ? default drivers (nv or nouveau) ? proprietary drivers ?
Which distribution are you using ?

No, it's not a normal behavior ;) .
Pointilleur professionnel

N1ghtly

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Framerate, rendering and optimisations
« Reply #4 on: February 16, 2012, 05:14:37 pm »
What smiley flooding? I only see two?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Framerate, rendering and optimisations
« Reply #5 on: February 16, 2012, 07:42:16 pm »
Quote
What smiley flooding? I only see two?

I edited the post.
Laurent Gomila - SFML developer

Stew_822

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • http://circean-studios.co.cc
    • Email
Framerate, rendering and optimisations
« Reply #6 on: February 16, 2012, 09:03:36 pm »
1) It looked alright when I was editing it. I agree it was a bit much after I posted it. The smiley faces are a bit bright. I didn't think anyone would care that much though or I would've edited it. I'm sorry if I hurt your eyes ;)

2) My source code goes pretty much like this:
Code: [Select]

while( running ) {
    // process events and call "step" on all objects
    for( int i=0; i<objects.size(); i++ ) {
        objects[i]->render( m_renderwindow );
    }
}

That is virtually all there is to it. In the render() function they just do window.Draw( sprite ). It's virtual, too, so that no doubt contributes, but so is the step() function. My actual source code is pretty messy (I'm going with the "lets just get this sh!t done" approach, because all the other times I've tried to "do things properly" I've spent hours coding stuff and ending up nowhere).

3) Yes, other OpenGL apps run slowly too. AssaultCube does, when it runs perfectly fine on windows (I dual boot). I get like 220 FPS on windows. Here's the output from glxinfo: http://codepad.org/wrSbMhzm

4) How come? Mine's pretty stuffed up - I can't play videos and it's just really messed up.

I am using a laptop, sorry, should've said that. Thanks heaps for that info; I'll follow that up. It ain't looking good for my card, is it? XD

I don't know what drivers I'm using. Every time I tried to install the propietary drivers, it wouldn't boot up, and I'd have to fall back to whatever the default is. I think it's the software renderer. How do I tell which drivers I'm using?

At least it's not my coding. That is something I'm happy about. I like to think that I'm a half-decent coder :wink:

And Tank, I don't know if you remember trying to teach me what a quadtree is (I'm the tennis-playing guy), but I finally managed to implement one.
It's better to keep your mouth shut and give the impression that you're stupid than to open it and remove all doubt.

Sam42

  • Newbie
  • *
  • Posts: 16
    • View Profile
Framerate, rendering and optimisations
« Reply #7 on: February 16, 2012, 09:41:29 pm »
Quote
OpenGL renderer string: Software Rasterizer


That certainly doesn't look right. The intel driver should be sitting in that spot showing something along the lines of 'Mesa DRI Intel(R)'. I suspect that whatever you did to allow it to boot through after installing the nvidia driver has blacklisted the intel one.

At this point, i'd advise you to follow the instructions for properly removing the nvidia driver in the link I gave you, and then follow the instructions for installing bumblebee once you've got acceleration back under the intel chip.

This will mean that your laptop will be using the intel integrated chip for all standard acceleration (such as desktop effects), and you will be able to start programs using the optirun prefix to render them with your nvidia chip. It should also allow you to turn off the nvidia card when not in use.

As to reinstalling, as long as you can be bothered, there is no particular reason to avoid it. Especially if you keep your root and home partitions separate. Repairing it is, of course, a preferable solution however.

Ultimately this is probably a better question for the forum of whatever distro you're using, as it's not directly related to sfml!

Stew_822

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • http://circean-studios.co.cc
    • Email
Framerate, rendering and optimisations
« Reply #8 on: February 17, 2012, 08:07:26 am »
I'll do that sometime next week (I'm going to be really busy over the next few days & I can only download stuff in the morning thanks to internet limits.). Thanks heaps for your help; I really appreciate it.

Aye, it is a better question for a different forum, but when I started the topic, I thought my coding with SFML might have been the issue. Then it hit me that it might be my software setup. If I have any more problems, I'll start a new thread over at the ubuntu forums.

Thank you :)
It's better to keep your mouth shut and give the impression that you're stupid than to open it and remove all doubt.

Stew_822

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • http://circean-studios.co.cc
    • Email
Framerate, rendering and optimisations
« Reply #9 on: February 24, 2012, 04:46:45 am »
Just a follow-up, I installed Bumblebee and it works great. My game runs at about 60-ish FPS compared to the 18-25 I was getting before. Thanks for your help in getting that set up :)

So all in all, everything's great :D
It's better to keep your mouth shut and give the impression that you're stupid than to open it and remove all doubt.