SDL_Rect rectangle function

Today I’ve decided to check SDL 1.3,
I was surprised to find that all rectangle function like [SDL_UnionRect, SDL_IntersectRect, SDL_HasIntersection], are incorrect,
the do not work with negative rectangles.

Code:
SDL_Rect a;
SDL_Rect a;
a.x = 20;
a.y = 20;
a.h = 70;
a.w = 70;

	SDL_Rect b;
b.x = 60;
	b.y = 60;
	b.h = -20;
	b.w = -20;

SDL_HasIntersection(…) => false

I’m pretty sure SDL 1.3 SDL_Rects still use unsigned variables for the width
and height. You’re actually setting the values to something like UINT_MAX -
20.

Jonny DOn Fri, Sep 24, 2010 at 4:02 PM, RomanZ wrote:

Today I’ve decided to check SDL 1.3,
I was surprised to find that all rectangle function like [SDL_UnionRect,
SDL_IntersectRect, SDL_HasIntersection], are incorrect,
the do not work with negative rectangles.

Code:

SDL_Rect a;
SDL_Rect a;
a.x = 20;
a.y = 20;
a.h = 70;
a.w = 70;

  SDL_Rect b;

b.x = 60;
b.y = 60;
b.h = -20;
b.w = -20;
SDL_HasIntersection(…) => false


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

[…]

What Jonathan said.

Allowing negative sizes just adds redundancy, making the code more
complicated, and probably slower. I do see how some algorithms may generate
"flipped" rectangles, but it’s probably cleaner and more efficient to deal
with that when and where it happens.On Friday 24 September 2010, at 22.02.59, “RomanZ” wrote:

Today I’ve decided to check SDL 1.3,
I was surprised to find that all rectangle function like [SDL_UnionRect,
SDL_IntersectRect, SDL_HasIntersection], are incorrect, the do not work
with negative rectangles.

//David Olofson - Developer, Artist, Open Source Advocate

.— Games, examples, libraries, scripting, sound, music, graphics —.
| http://olofson.net http://kobodeluxe.com http://audiality.org |
| http://eel.olofson.net http://zeespace.net http://reologica.se |
’---------------------------------------------------------------------’