Re: weird SDL Rect handling on SDL module

Asko Kauppi <askok-bTK2rvNjUvfD0D/[email protected]> Sat, 20 Aug 2005 23:10:04 +0300
Newsgroups gmane.comp.lang.lua.luacheia
Message-ID <[email protected]>
Yes, you certainly have found the source of the issue.

The +0.5's are there to handle cases where coordinates have been  
calculated, and don't exactly match into integers. Originally, the  
SDL port was tested against Meteor Shower demo, and it most likely  
benefitted from them.

Now, the proper solution would most likely involve some rounding  
function, suggestions welcome. :)

-ak


Rafael Jannone kirjoitti 20.8.2005 kello 2.02:

> Hi all,
>
> This is my first message on the list, so I apologize if this matter  
> has
> been covered before.
>
> Anyway, I'm having a bit of a problem with SDL_FillRect in my code:
> everytime I use negative values on the rectangle, the fill occurs  
> with a
> 1 pixel offset to the left.
>
> So I checked and re-checked on my code, found nothing. Until I came
> accross this section on the luacheia SDL module (sdl_module.cpp):
>
> #define /* SDL_Rect* */ glua_getRectTbl(i)  ( glua_getTable(i) ? \
>            ( _rect_store.x= (int)(glua_getTable_num("x")+0.5), \
>              _rect_store.y= (int)(glua_getTable_num("y")+0.5), \
>              _rect_store.w= (int)(glua_getTable_num("w")+0.5), \
>              _rect_store.h= (int)(glua_getTable_num("h")+0.5), \
>               &_rect_store ) : NULL /*'nil' table*/ )
>
> Which strikes me as odd... could be that the +0.5 offset is causing  
> the
> artifact?
>
> Suppose for example x = -1, so the actual int value would end up as 0,
> right? (since -1 + 0.5 = -0.5)
>
> I think this might be the source of the problem after all.
>
> What do you guys think?
> Thanks in advance,
>
> --
> Rafael Jannone
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle  
> Practices
> Agile & Plan-Driven Development * Managing Projects & Teams *  
> Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/ 
> bsce5sf
> _______________________________________________
> Luacheia-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luacheia-list
>



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf