Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 266 267 [268] 269 270 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 883424 times)

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4005 on: February 26, 2013, 04:42:57 am »

 :-[

it was running a function every frame, when really it only needed to be ran when that part of the screen needed to be updated,
so instead of updating that part of the screen every frame, that section is only set to update when something changes.

The function included setting, blitting, and freeing multiple surfaces as well as setting a handful of variables.

 
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4006 on: February 26, 2013, 01:27:12 pm »

:-[

it was running a function every frame, when really it only needed to be ran when that part of the screen needed to be updated,
so instead of updating that part of the screen every frame, that section is only set to update when something changes.

The function included setting, blitting, and freeing multiple surfaces as well as setting a handful of variables.
Setting and freeing multiple surfaces? Sounds CPU-intensive. It's probably easier to just keep and reuse those surfaces.
Logged

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4007 on: February 26, 2013, 05:02:28 pm »

The way it's set up, is there are 5 or so surfaces available for the menus.   when the menu changes, so do all of the surfaces.  I thought it would be a better option than keeping ALL of the surfaces for ALL of the menus in memory at the same time and just switching them out.  Its a tradeout, cpu for ram, but both are so small that it doesn't really make a dent in either one way or another.

But yeah, NORMALLY you'd want to keep a surface in memory if you think it's going to be used again. 
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4008 on: February 26, 2013, 08:44:39 pm »

The way it's set up, is there are 5 or so surfaces available for the menus.   when the menu changes, so do all of the surfaces.  I thought it would be a better option than keeping ALL of the surfaces for ALL of the menus in memory at the same time and just switching them out.  Its a tradeout, cpu for ram, but both are so small that it doesn't really make a dent in either one way or another.

But yeah, NORMALLY you'd want to keep a surface in memory if you think it's going to be used again.
Memory is cheap. If something comes down to a question of memory vs cpu time, you should almost always spend more memory to save CPU time simply because you have so incredibly much space in memory.

Also keep in mind that most things with graphics involve communication back and forth between the CPU and GPU. I can't say for certain exactly how SDL is doing that surface modification, as it changes based on how you're compiling it (SDL is basically a shiny wrapper which incorporates a bunch of other graphics libraries like DirectX and OpenGL, then figures out which one to use based on how you use it/what system you're on). However, I can say that the surface modification very likely includes such CPU-GPU communications; which tend to be very slow. Which is why doing it every frame was eating up several times more computation time than the rest of your code combined.

In this case, it's not too important, as it is just a menu opening (though you may get frame stuttering upon opening it), but just keep this in mind when using it in the future. Modifying surfaces, or worse, recreating them, is incredibly expensive.
« Last Edit: February 26, 2013, 08:46:58 pm by alway »
Logged

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4009 on: February 26, 2013, 11:23:51 pm »

Using SDL withough DirectX or OpenGL, so software accelerated instead of hardware accelerated. 
meaning not using the GPU at all.
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #4010 on: February 26, 2013, 11:34:32 pm »

It automatically uses OpenGL or DirectX, is what alway is saying I think.
Software drawing is slooooooow. D:
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

alexandertnt

  • Bay Watcher
  • (map 'list (lambda (post) (+ post awesome)) posts)
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4011 on: February 27, 2013, 05:06:53 am »

Does Dirty Rectangles have any use when you intend to scroll the whole screen for significant periods of time (A 2D game where the camera follows the player, causing the entire background to move)? Because it would seem that I would need to program my game to be fast enough to update the entire screen anyway.

Also my program using software blitting is running at a good 100 fps (pygame/sdl). Tried to force opengl to see what difference it would make and it segfaulted ::)

Logged
This is when I imagine the hilarity which may happen if certain things are glichy. Such as targeting your own body parts to eat.

You eat your own head
YOU HAVE BEEN STRUCK DOWN!

The Darkling Wolf

  • Bay Watcher
  • Arf!
    • View Profile
    • Cataclysm - Dark Days Ahead
Re: if (u.is_programmer) post(); //Programming Thread
« Reply #4012 on: February 27, 2013, 05:27:14 am »

Posting to follow.
« Last Edit: March 14, 2013, 06:23:14 am by The Darkling Wolf »
Logged
My cabbages!
[Thunderfury, Blessed Blade of the Windseeker]

I am fat, eating is my great joy.

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4013 on: February 27, 2013, 05:52:22 am »

Yep, and looking at those, some of them may or may not do some sort of hardware acceleration depending on the weather and what time of the year it is. So as to what it's really doing under the hood, who knows... But in any case, recreating and modifying any drawn surfaces is slow regardless of the method used, whether it's due to GPU communication or simply memcopying a couple megs of data.
Logged

alexandertnt

  • Bay Watcher
  • (map 'list (lambda (post) (+ post awesome)) posts)
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4014 on: February 27, 2013, 06:33:35 am »

But in any case, recreating and modifying any drawn surfaces is slow regardless of the method used, whether it's due to GPU communication or simply memcopying a couple megs of data.

Oh absolutely. Store/reuse/precompute as many surfaces as is possible.
Logged
This is when I imagine the hilarity which may happen if certain things are glichy. Such as targeting your own body parts to eat.

You eat your own head
YOU HAVE BEEN STRUCK DOWN!

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4015 on: February 27, 2013, 07:18:41 am »

Posting to follow.
Wait, what? All that time you've been on the forums, your sig says you've been a programmer for quite a long time now, and you posted in this thread only now? Someone must have Python issues. :P
Logged

The Darkling Wolf

  • Bay Watcher
  • Arf!
    • View Profile
    • Cataclysm - Dark Days Ahead
Re: if self.isCoder(): post() #Programming Thread
« Reply #4016 on: February 28, 2013, 06:54:47 am »

I only noticed the durned thread a while ago :P
Logged
My cabbages!
[Thunderfury, Blessed Blade of the Windseeker]

I am fat, eating is my great joy.

Zrk2

  • Bay Watcher
  • Emperor of the Damned
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4017 on: February 28, 2013, 04:58:24 pm »

How willing are you guys to troubleshoot an assignment I'm working on? It's quite simple and I hate to run to the internet for answers, but I'm not sure what my issue is.
Logged
He's just keeping up with the Cardassians.

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4018 on: February 28, 2013, 06:13:14 pm »

Ok, take this form. It includes details such as reason for project, language, current known errors and marital status. Just fill it out and we will see what we can do.

Dutchling

  • Bay Watcher
  • Ridin' with Biden
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4019 on: February 28, 2013, 06:14:13 pm »

Don't forget your martial status.
Logged
Pages: 1 ... 266 267 [268] 269 270 ... 796