Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.

This commit is contained in:
Sam Lantinga
2010-01-21 06:21:52 +00:00
parent b4fc8d890d
commit e0a31b4dbb
73 changed files with 854 additions and 1068 deletions

View File

@@ -43,7 +43,7 @@ static int render_testPrimitivesBlend (void);
static int render_testBlit (void);
static int render_testBlitColour (void);
static int render_testBlitAlpha (void);
static int render_testBlitBlendMode( SDL_TextureID tface, int mode );
static int render_testBlitBlendMode( SDL_Texture * tface, int mode );
static int render_testBlitBlend (void);
@@ -225,10 +225,10 @@ static int render_hasBlendModes (void)
/**
* @brief Loads the test face.
*/
static SDL_TextureID render_loadTestFace (void)
static SDL_Texture * render_loadTestFace (void)
{
SDL_Surface *face;
SDL_TextureID tface;
SDL_Texture *tface;
/* Create face surface. */
face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
@@ -261,7 +261,7 @@ static int render_hasTexColor (void)
{
int fail;
int ret;
SDL_TextureID tface;
SDL_Texture *tface;
Uint8 r, g, b;
/* Get test face. */
@@ -296,7 +296,7 @@ static int render_hasTexAlpha (void)
{
int fail;
int ret;
SDL_TextureID tface;
SDL_Texture *tface;
Uint8 a;
/* Get test face. */
@@ -606,7 +606,7 @@ static int render_testBlit (void)
{
int ret;
SDL_Rect rect;
SDL_TextureID tface;
SDL_Texture *tface;
int i, j, ni, nj;
/* Clear surface. */
@@ -658,7 +658,7 @@ static int render_testBlitColour (void)
{
int ret;
SDL_Rect rect;
SDL_TextureID tface;
SDL_Texture *tface;
int i, j, ni, nj;
/* Clear surface. */
@@ -716,7 +716,7 @@ static int render_testBlitAlpha (void)
{
int ret;
SDL_Rect rect;
SDL_TextureID tface;
SDL_Texture *tface;
int i, j, ni, nj;
/* Clear surface. */
@@ -774,7 +774,7 @@ static int render_testBlitAlpha (void)
/**
* @brief Tests a blend mode.
*/
static int render_testBlitBlendMode( SDL_TextureID tface, int mode )
static int render_testBlitBlendMode( SDL_Texture * tface, int mode )
{
int ret;
int i, j, ni, nj;
@@ -820,7 +820,7 @@ static int render_testBlitBlend (void)
{
int ret;
SDL_Rect rect;
SDL_TextureID tface;
SDL_Texture *tface;
int i, j, ni, nj;
int mode;
@@ -1004,7 +1004,7 @@ int test_render (void)
int ret;
const char *driver, *str;
char msg[256];
SDL_WindowID wid;
SDL_Window *w;
SDL_RendererInfo renderer;
/* Initializes the SDL subsystems. */
@@ -1054,12 +1054,12 @@ int test_render (void)
if (SDL_ATassert( "SDL_GetCurrentVideoDriver", SDL_strcmp(driver,str)==0))
goto err_cleanup;
/* Create window. */
wid = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
w = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
80, 60, SDL_WINDOW_SHOWN );
if (SDL_ATassert( "SDL_CreateWindow", wid!=0 ))
if (SDL_ATassert( "SDL_CreateWindow", w!=NULL ))
goto err_cleanup;
/* Check title. */
str = SDL_GetWindowTitle( wid );
str = SDL_GetWindowTitle( w );
if (SDL_ATassert( "SDL_GetWindowTitle", SDL_strcmp(msg,str)==0))
goto err_cleanup;
/* Get renderers. */
@@ -1072,10 +1072,10 @@ int test_render (void)
/* We have to recreate window each time, because opengl and opengles renderers */
/* both add SDL_WINDOW_OPENGL flag for window, that was last used */
SDL_DestroyWindow(wid);
wid = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
SDL_DestroyWindow(w);
w = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
80, 60, SDL_WINDOW_SHOWN );
if (SDL_ATassert( "SDL_CreateWindow", wid!=0 ))
if (SDL_ATassert( "SDL_CreateWindow", w!=NULL ))
goto err_cleanup;
/* Get renderer info. */
@@ -1089,7 +1089,7 @@ int test_render (void)
SDL_ATbegin( msg );
/* Set renderer. */
ret = SDL_CreateRenderer( wid, j, 0 );
ret = SDL_CreateRenderer( w, j, 0 );
if (SDL_ATassert( "SDL_CreateRenderer", ret==0 ))
goto err_cleanup;

View File

@@ -761,7 +761,7 @@ CommonInit(CommonState * state)
fullscreen_mode.refresh_rate = state->refresh_rate;
state->windows =
(SDL_WindowID *) SDL_malloc(state->num_windows *
(SDL_Window **) SDL_malloc(state->num_windows *
sizeof(*state->windows));
if (!state->windows) {
fprintf(stderr, "Out of memory!\n");

View File

@@ -32,7 +32,7 @@ typedef struct
int depth;
int refresh_rate;
int num_windows;
SDL_WindowID *windows;
SDL_Window **windows;
/* Renderer info */
const char *renderdriver;

View File

@@ -19,7 +19,7 @@ static int current_color = 255;
static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
void
DrawPoints(SDL_WindowID window)
DrawPoints(SDL_Window * window)
{
int i;
int x, y;
@@ -64,7 +64,7 @@ DrawPoints(SDL_WindowID window)
}
void
DrawLines(SDL_WindowID window)
DrawLines(SDL_Window * window)
{
int i;
int x1, y1, x2, y2;
@@ -118,7 +118,7 @@ DrawLines(SDL_WindowID window)
}
void
DrawRects(SDL_WindowID window)
DrawRects(SDL_Window * window)
{
int i;
SDL_Rect rect;
@@ -249,7 +249,7 @@ main(int argc, char *argv[])
case SDL_WINDOWEVENT:
switch (event.window.event) {
case SDL_WINDOWEVENT_EXPOSED:
SDL_SelectRenderer(event.window.windowID);
SDL_SelectRenderer(SDL_GetWindowFromID(event.window.windowID));
SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
SDL_RenderClear();
break;

View File

@@ -20,7 +20,7 @@ static int current_color = 255;
static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
void
DrawPoints(SDL_WindowID window)
DrawPoints(SDL_Window * window)
{
int i;
int x, y;
@@ -86,7 +86,7 @@ add_line(int x1, int y1, int x2, int y2)
void
DrawLines(SDL_WindowID window)
DrawLines(SDL_Window * window)
{
int i;
int x1, y1, x2, y2;
@@ -139,7 +139,7 @@ add_rect(int x1, int y1, int x2, int y2)
}
static void
DrawRects(SDL_WindowID window)
DrawRects(SDL_Window * window)
{
int i;
int window_w, window_h;
@@ -156,7 +156,7 @@ DrawRects(SDL_WindowID window)
}
static void
DrawRectLineIntersections(SDL_WindowID window)
DrawRectLineIntersections(SDL_Window * window)
{
int i, j, window_w, window_h;
@@ -186,7 +186,7 @@ DrawRectLineIntersections(SDL_WindowID window)
}
static void
DrawRectRectIntersections(SDL_WindowID window)
DrawRectRectIntersections(SDL_Window * window)
{
int i, j;
@@ -324,7 +324,7 @@ main(int argc, char *argv[])
case SDL_WINDOWEVENT:
switch (event.window.event) {
case SDL_WINDOWEVENT_EXPOSED:
SDL_SelectRenderer(event.window.windowID);
SDL_SelectRenderer(SDL_GetWindowFromID(event.window.windowID));
SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
SDL_RenderClear();
break;

View File

@@ -36,11 +36,11 @@ quit(int rc)
exit(rc);
}
SDL_TextureID
LoadSprite(SDL_WindowID window, char *file)
SDL_Texture *
LoadSprite(SDL_Window * window, char *file)
{
SDL_Surface *temp;
SDL_TextureID sprite;
SDL_Texture *sprite;
/* Load the sprite image */
temp = SDL_LoadBMP(file);
@@ -69,7 +69,7 @@ LoadSprite(SDL_WindowID window, char *file)
}
void
MoveSprites(SDL_WindowID window, SDL_TextureID sprite)
MoveSprites(SDL_Window * window, SDL_Texture * sprite)
{
int i, n;
int window_w, window_h;
@@ -113,8 +113,8 @@ main(int argc, char *argv[])
{
int i, done;
const char *driver;
SDL_WindowID window;
SDL_TextureID sprite;
SDL_Window *window;
SDL_Texture *sprite;
int window_w, window_h;
int sprite_w, sprite_h;
SDL_Event event;

View File

@@ -11,7 +11,7 @@
static CommonState *state;
static int num_sprites;
static SDL_TextureID *sprites;
static SDL_Texture **sprites;
static SDL_bool cycle_color;
static SDL_bool cycle_alpha;
static int cycle_direction = 1;
@@ -98,7 +98,7 @@ LoadSprite(char *file)
}
void
MoveSprites(SDL_WindowID window, SDL_TextureID sprite)
MoveSprites(SDL_Window * window, SDL_Texture * sprite)
{
int i, n;
int window_w, window_h;
@@ -294,7 +294,7 @@ main(int argc, char *argv[])
/* Create the windows, initialize the renderers, and load the textures */
sprites =
(SDL_TextureID *) SDL_malloc(state->num_windows * sizeof(*sprites));
(SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites));
if (!sprites) {
fprintf(stderr, "Out of memory!\n");
quit(2);
@@ -346,7 +346,7 @@ main(int argc, char *argv[])
case SDL_WINDOWEVENT:
switch (event.window.event) {
case SDL_WINDOWEVENT_EXPOSED:
SDL_SelectRenderer(event.window.windowID);
SDL_SelectRenderer(SDL_GetWindowFromID(event.window.windowID));
SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
SDL_RenderClear();
break;

View File

@@ -12,7 +12,7 @@
#define NUM_SPRITES 100
#define MAX_SPEED 1
static SDL_TextureID sprite;
static SDL_Texture *sprite;
static SDL_Rect positions[NUM_SPRITES];
static SDL_Rect velocities[NUM_SPRITES];
static int sprite_w, sprite_h;
@@ -78,7 +78,7 @@ LoadSprite(char *file)
}
void
MoveSprites(SDL_WindowID window, SDL_TextureID sprite)
MoveSprites(SDL_Window * window, SDL_Texture * sprite)
{
int i;
int window_w = WINDOW_WIDTH;
@@ -115,7 +115,7 @@ MoveSprites(SDL_WindowID window, SDL_TextureID sprite)
int
main(int argc, char *argv[])
{
SDL_WindowID window;
SDL_Window *window;
int i, done;
SDL_Event event;