Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

adding texture scaling functionally to SDL2_perl

7 views
Skip to first unread message

Mason James

unread,
Aug 9, 2013, 2:25:33 PM8/9/13
to sdl-...@perl.org
hi sdl-devel

i am planning/researching about adding a small amount of SDL2_Perl code into my existing SDL_Perl app, for a framerate increase
i have one long-standingly slow bit of code in my app, that i would like to replace with SDL2 code

my slow code is a SDL::GFX::Rotozoom::surface() call. but SDL2 has 'hardware accelerated' stretching/scaling/zooming [1], yay!


i checked the SDL2 version of ./SDL2_rotozoom.c, and it is still using the current slow software method (no changes)
but the good news is… there seems to be a preferred method to achieve this fast hardware scaling in SDL2

SDL2's SDL_RenderCopyEx() function [2] will scale a texture using a fast HW method, (but...i have not benchmarked my theory yet)


my plan is to attempt to add some missing SDL2 functionality to SDL2_Perl.
then swap my slow SDL::GFX::Rotozoom::surface() call, with the faster SDL2 equivalent

so basically, i need to implement the 'test/testrendercopyex.c' demo [3], in SDL2_Perl,
and add access to these missing SDL2 functions in SDL2_Perl...

SDL_LoadBMP(),
SDL_CreateTextureFromSurface(),
SDL_FreeSurface()
SDL_RenderGetViewport()
SDL_CreateTexture()
SDL_SetRenderTarget()
SDL_RenderCopy()
SDL_RenderCopyEx(),
SDL_QueryTexture()



fyi: the testrendercopyex.c demo is nice and simple, it...

- loads a .bmp file to a surface
- converts the surface to a HW texture
- then randomly moves, rotates and scales that texture around the window, in a loop

i believe this demo is using the new hardware-accelerated scaling on a 'texture' in SDL2


[1] http://wiki.libsdl.org/moin.fcg/Introduction
[2] http://wiki.libsdl.org/moin.fcg/SDL_RenderCopyEx
[3] http://hg.libsdl.org/SDL/file/90ff13467550/test/testrendercopyex.c

any comments or suggestions, folks?


cheers, Mason

Kartik Thakore

unread,
Aug 9, 2013, 2:37:28 PM8/9/13
to Mason James, sdl-...@perl.org
Thanks mason,

Can you make these feature requests as issues on http://github.com/PerlGameDev/SDL2

Mason James

unread,
Aug 9, 2013, 2:53:38 PM8/9/13
to sdl-...@perl.org

On 2013-08-10, at 6:25 AM, Mason James wrote:

> hi sdl-devel
>
> i am planning/researching about adding a small amount of SDL2_Perl code into my existing SDL_Perl app, for a framerate increase
> i have one long-standingly slow bit of code in my app, that i would like to replace with SDL2 code
>
>
> so basically, i need to implement the 'test/testrendercopyex.c' demo [3], in SDL2_Perl,


aaah, the SDL2 'test/testscale.c' demo is a slightly better example

http://hg.libsdl.org/SDL/file/90ff13467550/test/testscale.c

Kartik Thakore

unread,
Aug 9, 2013, 7:16:56 PM8/9/13
to Mason James, sdl-...@perl.org

Mason James

unread,
Aug 11, 2013, 4:32:43 AM8/11/13
to Kartik Thakore, sdl-...@perl.org

On 2013-08-10, at 6:37 AM, Kartik Thakore wrote:

> Thanks mason,
>
> Can you make these feature requests as issues on http://github.com/PerlGameDev/SDL2
>

yes, will do :)
cheers, Mason
--
KohaAloha, NZ

Mason James

unread,
Aug 11, 2013, 4:33:44 AM8/11/13
to Kartik Thakore, sdl-...@perl.org

On 2013-08-10, at 11:16 AM, Kartik Thakore wrote:

> Added it to https://github.com/PerlGameDev/SDL2/issues/2
>

awesome, thanks Kartik
0 new messages