Re: weird SDL Rect handling on SDL module
Asko Kauppi <[email protected]> Sat, 27 Aug 2005 16:41:41 +0300
| Newsgroups | gmane.comp.lang.lua.luacheia |
|---|---|
| Message-ID | <[email protected]> |
I did answer to this, didn't I?
The criticism is justified, and actually the same issue that was
discussed in Lua list lately.
Fixes to LuaX (where the SDL module comes from) are welcomed; you'd
need to test the solution for negative numbers; I didn't even know
SDL would work with them. The rounding is so that calculated
coordinates would work appropriately.
And yes, I'm still alive (but more busy in work than before)..
-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