SDL Wiki
(This is the legacy documentation for stable SDL2, the current stable version; SDL3 is the current development version.)

SDL_Rect

A rectangle, with the origin at the upper left (integer).

Header File

Defined in [SDL_rect.h](https://github.com/libsdl-org/SDL/blob/SDL2/include/SDL_rect.h), but apps should _only_ `#include "SDL.h"`!

Syntax

typedef struct SDL_Rect
{
    int x, y;
    int w, h;
} SDL_Rect;

Code Examples

SDL_Rect srcrect;
SDL_Rect dstrect;

srcrect.x = 0;
srcrect.y = 0;
srcrect.w = 32;
srcrect.h = 32;
dstrect.x = 640/2;
dstrect.y = 480/2;
dstrect.w = 0;
dstrect.h = 0;

SDL_BlitSurface(src, &srcrect, dst, &dstrect);

See Also

SDL_RectEmpty
SDL_RectEquals
SDL_HasIntersection
SDL_IntersectRect
SDL_IntersectRectAndLine
SDL_UnionRect
SDL_EnclosePoints

Data Fields

int

x

the x location of the rectangle's upper left corner

int

y

the y location of the rectangle's upper left corner

int

w

the width of the rectangle

int

h

the height of the rectangle


CategoryAPI, CategoryAPIStruct, CategoryStruct, CategoryRect


[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.