Skip to main content
GameDev.net gamedev.net
🔒 Locked

Rectangle Intersections

Started by Snowy May 9, 2003 at 2:55 PM 0 replies 750+ views
Original Post
Snowy
Snowy
I''ve created a struct like this, I need floats for OpenGL.
  
typedef struct {
   float left;
   float right;
   float top;
   float bottom;
} RECTf;
  
Now, I want to know how to make a function like:
  
bool IntersectRects(RECTf *src, RECTf *dest);
  
Windows has one like it, but only for longs... any help would be apreciated.
"To code, is an extension of the soul, creation of imagination by bits and funcs, mastering the machine and warping the registers. Controlling the way you see, think and feel on a pc...it is LIFE!"
brassfish89
brassfish89

  
bool IntersectRects(RECTf* src,RECTf* dest)
{
if(src->right<dest->left)
return 0;
if(src->left>dest->right)
return 0;
if(src->bottom<dest->top)
return 0;
if(src->top>dest->bottom)
return 0;
return 1;
}




doh, nuts. Mmmm... donuts
My website

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.