Perl 6 - the future is here, just unevenly distributed

IRC log for #sdl, 2013-08-09

| Channels | #sdl index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:18 FROGGS joined #sdl
00:48 FROGGS joined #sdl
01:28 FROGGS joined #sdl
01:54 FROGGS_ joined #sdl
03:18 FROGGS_ joined #sdl
04:40 FROGGS_ joined #sdl
05:12 FROGGS joined #sdl
06:11 FROGGS joined #sdl
06:52 dod joined #sdl
07:07 dod joined #sdl
09:35 daxim joined #sdl
10:42 dod joined #sdl
14:50 kaare joined #sdl
15:36 t4nk137 joined #sdl
16:30 dod joined #sdl
16:52 mtj hi kthakore, i have finally installed sdl2_perl on my lappy
16:52 mtj and i am making some good progress looking thru the code, very nice! :)
16:53 mtj i think i now understand what missing SDL2 functions i require
16:53 mtj so, i will attempt to write some perl tests for them
16:55 mtj the good news is that there are not too many, only 5 perhaps...
16:55 FROGGS joined #sdl
16:55 mtj heya FROGGS
16:57 mtj kthakore, hopefully i have the skill to write some of this code myself, rather than just making tests
16:58 mtj ill send an email to the list about my general plan
16:59 daxim yes please, I'm stoked
16:59 FROGGS hi mtj
17:00 FROGGS garu / perigrin: can you please give slavorg op?
17:01 perigrin Bender1: do you trust slavorg ?
17:01 Bender1 Yes I do
17:01 perigrin Bender2: do you trust slavorg?
17:01 Bender2 Yes I do
17:04 FROGGS I have no idea why that doesnt work right :/
17:04 FROGGS but thanks perigrin
17:04 perigrin nor do I
17:04 * perigrin got busy when he last expected free time to re-write bender
17:38 varnie joined #sdl
17:39 varnie hello
17:40 varnie when I draw many images (32x32 px), I experience bad FPS.
17:42 varnie I output them using my_image_surface->blit_by, and finally I perform world_surface->flip.
17:43 varnie I can show you the code;)
17:46 arbo joined #sdl
17:49 FROGGS varnie: yeah, please no-paste it, maybe we see something
17:49 varnie okay, here it is (I just made a github repo, yay!): https://github.com/varnie/yup/blob/master/code/yup.pl
17:50 varnie the loops (the lines from127 to 134 lines) cause performance loss.
17:54 varnie currently, there are 950 "blocks"  on fullscreen (1680x1050px) made of the same chunk of image.
17:54 varnie and I have around 13 frames per second.
17:54 varnie If I change my map so that there will be for instance 100 blocks, I'll have 25-30 frames per second.
17:56 FROGGS varnie: does everything on the screen *needs* to be updated?
17:57 FROGGS it might make sense to only blit+update regions that changed
17:57 varnie as long as my character moves (user presses arrows) the scene should be redrawn
17:57 FROGGS ahh, so the map scrolls and the player is sort of centered?
17:57 varnie yes, exactly
18:00 FROGGS I guess you should implement a camera/view based on the player position
18:00 varnie I render only these blocks which are seen at this moment
18:01 FROGGS so that you blit to the map when things on the map change or when another map needs to be loaded, and then you draw the given part of the map and then the players/objects on top
18:01 FROGGS so you safe the loop where you blit to the map
18:02 FROGGS but you update that surface entirely
18:03 varnie when the player changes the position, I calculate which blocks should be redrawn and blit only them.
18:03 FROGGS if you have a map that is bigger as the screen, and you "move the camera coordinates", it is cheaper to update the screen at once than drawing hundreds of little 32x32 buckets
18:03 FROGGS varnie: I believe that is still some overhead
18:03 FROGGS at least the function call overhead to the libsdl C-library
18:04 varnie but to be able to update the screen at once I have to redraw it (the part which is "visible" at this moment)
18:04 varnie and this part consists of some blocks
18:04 FROGGS true, but this is just one blit+flip
18:04 varnie these are the only ones which I re-blit.
18:05 FROGGS not hundreds of blits + 1flip
18:06 varnie hmm, then I don't quite well understand how to blit many thingies onto one surface with one blit...
18:06 FROGGS no, the map (behind the objects) doesnt change that often, right?
18:06 varnie yes
18:07 varnie my map == blocks.
18:07 FROGGS so when the player walks, you just say: blit that reagon of the once-rendered background map
18:07 varnie which have the coordinates.
18:07 varnie hmm, well. this is my fault. I regenerate the resulting image each time
18:08 FROGGS and this causes a lot of overhead
18:08 varnie thanks a lot, FROGGS. I'll give it a go.
18:08 FROGGS tip: make a screenshot or so, save it to png or bmp, load it in a test script, and move it when pressing left/up/down/right
18:09 FROGGS than you can see how fast that would be, when blitting+flipping the entire screen, using a prerendered surface
18:09 FROGGS :o)
18:09 varnie alrighty;)
18:10 varnie I completely forgot that I can create an auxiliary surface presenting the map. ;)
18:11 FROGGS that would be handy anyway, when you want to be able to scale your app
18:12 FROGGS like supporting 4:3 and 16:9 screens
18:12 varnie yes, makes sense
18:16 varnie one moment pls, how do I instantiate a SDL_Surface object which lately be updated with my whole map pregenerated image?
18:16 varnie ah, there's new (-from => $buffer, ...)
18:18 FROGGS I would have guessed you just blit a part of your map to the screen, and then the player and objects
18:18 FROGGS so you usually never draw to that map, you just change its coordinates, and the coords of all objects
18:18 FROGGS the map would only change if you have animated water or so
18:19 varnie but before that I should make that big image buffer mapped into the new surface.
18:19 varnie yes, I got the idea.
18:19 varnie I mean, I need to create that surface beforehand
18:19 FROGGS SDLx::Surface->new, no? where do you got that buffer from?
18:20 varnie I have no buffer, all I have the blocks' coordinates
18:20 varnie and going through the loop I can make the whole map image
18:22 FROGGS right
18:22 varnie SDLx::Surface->new( width=> my_w, height=> my_h)
18:22 varnie I think this will suit my needs;)
18:47 varnie hmm, SDL::Image::load(...) returns SDL::Surface, not SDLx::Surface
18:47 varnie and SDL::Surface doesn't have blit/blit_bu
18:48 varnie I'll try SDLx::Surface->load(...)
18:48 FROGGS see: http://sdl.perl.org/SDLx-Surface.html#new
18:48 FROGGS the first example
18:58 varnie okay, and is it possible to dump SDL Surface to a file?
18:58 FROGGS SDL::Video::save_bitmap or so
19:02 varnie thanks!
19:02 FROGGS you're welcome
19:04 varnie sorry for being so pesky, but it gives me blank black bmp image.
19:05 FROGGS it expects a surface, not an sdlx::surface if I remember correctly
19:05 FROGGS so you would have to pass surfacex->{surface} as argument
19:16 varnie still no luck. if I draw rectangles in the surface and save it - it works. but when I do $src_surface->blit($dst_surface, $src_surface_rect, $dst_surface_rect); and after that I save $dst_surface to BMP - I get black rectangle.
19:18 FROGGS you need to update or flip the surface
19:18 varnie yes, I have it already
19:18 FROGGS hmmm
19:18 varnie $dst_surface->update;
19:18 FROGGS right
19:19 FROGGS that should do
19:19 varnie "$tiles_surface->blit($whole_map_surface, $tile_rect, [0, 0, 32, 32]);" #let it be "[0, 0, 32, 32] for testing
19:19 varnie then: $whole_map_surface->update;
19:19 varnie SDL::Video::save_BMP($whole_map_surface->surface, "foo.bmp");
19:20 FROGGS can you try that please? SDL::Video::save_BMP($whole_map_surface->{surface}, "foo.bmp");
19:20 varnie "Not a HASH reference at"
19:21 FROGGS hmmm, dunno what to try next
19:21 varnie please wait...
19:22 varnie SDLx::Surface->new returns a reference
19:23 varnie hm, no ideas.
19:34 varnie hm, when I draw something onto my surface and after that I blit another surface onto it - then it works;)
19:34 varnie without any draw it is considered to be empty(?)
19:38 FROGGS well yes, if you never blit to it, it is empty
19:39 varnie no, I blit and draw_rect - then it works
19:39 FROGGS when you create an sdlx from a surface, you only create an sdlx with its properties, not its pixel data
19:39 FROGGS hmmm
19:39 varnie but when I simply blit - then it doesn't
20:32 varnie one more question - SDL::Surface::set_color_key is a not so long ago added method?
20:33 FROGGS hmmm, no, this one should be pretty old, why?
20:33 varnie weird, I have "Can't locate object method "set_color_key" via package "SDLx::Surface""
20:34 varnie when I do "$sdlx_surface->set_color_key(...)"
20:34 varnie I even tried "$sdlx_surface->surface->set_color_key(...)"
20:34 FROGGS $set_color_key = SDL::Video::set_color_key( $surface, $flag, $key );
20:35 FROGGS it is not a surface method
20:35 varnie in the docs it is stated so.
20:35 FROGGS where?
20:35 varnie http://search.cpan.org/~wkeenan/SDL-sdlpl-1.08/lib/SDL/Surface.pm
20:35 varnie maybe it is old version.
20:36 FROGGS this is 13 years old, and has not much todo with the current SDL module :o)
20:36 varnie huh, sorry;))
20:36 FROGGS use this page: http://sdl.perl.org/documentation.html
21:02 varnie omg, I finally made it work!
21:03 varnie everything works as it should (I used your approach, FROGGS).
21:03 varnie saving to BMP works as well. I missed SDL::Video::set_alpha.
21:04 varnie now I have 20-22 FPS running fullscreen (1680x1050) and having a lots of blocks in the map.
21:06 varnie thank you, sir.
21:23 varnie bye!
21:23 varnie left #sdl
23:23 kthakore Hallo
23:25 kthakore mtj: cool looking forward to it
23:59 perlgamedev-SDL2 joined #sdl
23:59 perlgamedev-SDL2 [SDL201] kthakore created experimental (+2 new commits): http://git.io/S9yXOQ
23:59 perlgamedev-SDL2 SDL2/experimental 6cf5653 Kartik Thakore: Adding texture xs, pm and tests
23:59 perlgamedev-SDL2 SDL2/experimental b430abb Kartik Thakore: Also adding texture. WIP #2
23:59 perlgamedev-SDL2 left #sdl

| Channels | #sdl index | Today | | Search | Google Search | Plain-Text | summary