@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet


Comments:

<0> Anyone seen David Olofson in a while?
<0> Any thoughts on the e-mail I've sent on the SDL 1.3 API?
<1> I smell radical changes towards DX style
<1> or have you sent an e-mail on something else but the video api thing too?
<0> Oh, conversation with somebody, sorry.
<0> :)
<2> hello ppl
<2> I've written a little application which scrolls a text on the screen.
<2> sadly, it's a bit slow.. how could I make it faster?



<2> just a sec and I'll put the source online
<2> http://nefty.hu/~nagyz/scroll.c, http://nefty.hu/~nagyz/verdana.ttf
<2> I'd appriciate any help...
<3> SDL_DisplayFormat
<2> hm? :)
<2> I should call it on the text surface before blitting?
<3> and updating/filling only the parts of the screen were it's necessary
<2> hmm.
<2> that helped a bit..
<2> have another look at the source now, please
<2> I've did your suggestions
<2> not it's very fast.. but sadly, now I cant slow it down.
<2> SDL_Delay( 10 ) makes it way too slow
<2> SDL_Delay( 1 ) does that, too
<2> but without SDL_Delay, it's too fast.. :-))
<3> you have to check how much time has p***ed each frame and move accordingly
<3> time-based movement vs. frame-based movement
<2> hmm.. I dont really understand.
<2> whats wrong with sleeping?
<3> sleeping is fine, but you advance the text every frame
<3> faster computer, more frames, faster text
<3> -> too fast text
<3> slower computer, less frames, slow text
<3> read up on it
<2> well my real problem is that I cant control the speed
<2> if I sleep it gets way too slow, if I dont, it gets really really fast
<2> even if I sleep just a bit (like usleep(1), or SDL_Delay(1)) it gets way too slow...
<3> as i said ... you want time-based movement ... read up on it
<2> whats the difference between if( SDL_GetTicks() - last_gettick >= 100 ) { move.. } and SDL_Delay( 100 ) in a while(1)?
<4> cpu usage and precision
<2> the first is what rnx is suggesting, isnt it?
<4> well yeh sdl_delay(1) will probably always just give you at least 10 ms
<2> hmm
<2> the problem with this is that it eats up the cpu
<2> basically I'm doing now while(1) { if( SDL_GetTicks() - last >= 3 ) { move } }
<2> how can I get it not to eat it up?
<4> also use sdl_delays(1) to release cycles
<2> well thats the problem
<2> even with SDL_Delay(1) it gets way toooooo slow
<2> I've updated http://nefty.hu/~nagyz/scroll.c
<2> have a look please
<2> the text runs really smooth and fast without the SDL_Delay part
<2> but it eats up cpu



<4> that's a blank file
<2> with SDL_Delay(1) it gets way too slow...
<2> hmm
<2> checking
<4> don't sdl_delay(1) each frame
<4> and use sdl_getticks for delta timing
<2> I do use SDL_GetTicks()
<2> check it out now
<2> it's not blank now
<2> where should I place that SDL_Delay(1) now?
<4> well you need update the screen based on framerate, you have to scroll based on deltatime p***ed since the last frame
<2> I dont really understand.. coud you modify the code so I can learn it? :)
<4> well sdl_getticks - l will give you the amount of milliseconds since the last frame, then you can use that value to setup a certain scrollspeed of x pixels per millisecond
<4> else you won't get smooth movment if the framerate fluctuates
<2> I still dont understand how could I actually code it...
<5> though better is to use a fixed timestep and interpolate according to SDL_GetTicks (or better yet, some time source with more granularity)
<5> at least for physical simulations, well, for animation it's less important
<2> lets say I want to do one pixel move in every 3 ms
<2> how would you do that to keep the cpu usage low, yet achieve this?
<5> why would you want to keep the CPU usage low?
<5> all games run at 100% CPU unless waiting for GPU (3D games)
<2> well because let's say 5 of this apps are running and two mpeg decoding apps
<2> ...:)
<2> I'd really like to keep it down
<4> quad processor plz
<2> Harekiet ;>
<5> then you need to have a better scheduler in the operating system... ;)
<4> either way do better timing then so you can sdl_delay :)
<5> which would distribute the CPU time evenly
<2> Harekiet SDL_Delay it waaaay to wrong
<2> SDL_Delay will wait at least 10ms
<4> not really if sdl_delay takes say 10 ms you could still reach 100 fps
<5> no it won't be very good
<4> or you can keep some of target fps and sdl_delay accordingly if you are close to reaching it
<5> Harekiet: the problem is unpredictability
<5> and lack of granularity
<2> it shouldnt be this hard to write a decent scrolling program...
<2> ;(
<4> true it's not like you need sdl_delay if you don't care about 100% :)
<5> only complete newbies would do timing by sleeping
<5> it's completely unpredictable
<2> then how to do it to keep cpu usage low?
<2> I'm open to any good suggestions
<5> under high load and bad scheduler (like windows) even a SDL_Delay(1) call can take, say, 2 seconds
<2> now, I cant buy a quad system
<2> I'm using linux 2.6 :)
<5> why do you want to run 4 apps simultaneously? why not run 1 main loop in which update all of them?
<2> that something I cant control
<2> it's more complex than that.. :)
<2> so?
<4> so it's time to watch tour de france!


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #sdl
or
Go to some related logs:

qmailrocks telnet pop slow localhost
#debian
ubuntu dmx6fire
#math
transgaming-mozctlinstaller -gentoo
#css
hard return symbol
#centos
nvidia alc880 ubuntu install
gentoo orbit TTypeCode Error



Home  |  disclaimer  |  contact  |  submit quotes