Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Renamed SDL_RenderPoint() and SDL_RenderLine() to SDL_RenderDrawPoint() and SDL_RenderDrawLine(). Added API for rectangle drawing (as opposed to filling) Added placeholder API functions for circles and ellipses ... I'm not sure whether these will stay. Optimized software line drawing quite a bit. Added support for Wu's anti-aliased line drawing, currently disabled by default. --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404346
This commit is contained in:
parent
d45158ea85
commit
6da163ab81
24 changed files with 1685 additions and 549 deletions
|
@ -1,6 +1,6 @@
|
|||
|
||||
|
||||
CFLAGS := -W -Wall -Wextra -g `sdl-config --cflags`
|
||||
CFLAGS := -W -Wall -Wextra -g `sdl-config --cflags` -DSDL_NO_COMPAT
|
||||
LDFLAGS := `sdl-config --libs`
|
||||
|
||||
# If it doesn't pick up defaults
|
||||
|
|
|
@ -341,9 +341,9 @@ static int render_clearScreen (void)
|
|||
*/
|
||||
|
||||
/* Clear screen. */
|
||||
ret = SDL_RenderRect( NULL );
|
||||
ret = SDL_RenderFillRect( NULL );
|
||||
/*
|
||||
if (SDL_ATassert( "SDL_RenderRect", ret == 0))
|
||||
if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
|
||||
return -1;
|
||||
*/
|
||||
|
||||
|
@ -413,8 +413,8 @@ static int render_testPrimitives (void)
|
|||
ret = SDL_SetRenderDrawColor( 13, 73, 200, SDL_ALPHA_OPAQUE );
|
||||
if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_RenderRect( &rect );
|
||||
if (SDL_ATassert( "SDL_RenderRect", ret == 0))
|
||||
ret = SDL_RenderFillRect( &rect );
|
||||
if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
|
||||
return -1;
|
||||
|
||||
/* Draw a rectangle. */
|
||||
|
@ -425,8 +425,8 @@ static int render_testPrimitives (void)
|
|||
ret = SDL_SetRenderDrawColor( 200, 0, 100, SDL_ALPHA_OPAQUE );
|
||||
if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_RenderRect( &rect );
|
||||
if (SDL_ATassert( "SDL_RenderRect", ret == 0))
|
||||
ret = SDL_RenderFillRect( &rect );
|
||||
if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
|
||||
return -1;
|
||||
|
||||
/* Draw some points like so:
|
||||
|
@ -439,8 +439,8 @@ static int render_testPrimitives (void)
|
|||
ret = SDL_SetRenderDrawColor( x*y, x*y/2, x*y/3, SDL_ALPHA_OPAQUE );
|
||||
if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_RenderPoint( x, y );
|
||||
if (SDL_ATassert( "SDL_RenderPoint", ret == 0))
|
||||
ret = SDL_RenderDrawPoint( x, y );
|
||||
if (SDL_ATassert( "SDL_RenderDrawPoint", ret == 0))
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -449,29 +449,29 @@ static int render_testPrimitives (void)
|
|||
ret = SDL_SetRenderDrawColor( 0, 255, 0, SDL_ALPHA_OPAQUE );
|
||||
if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_RenderLine( 0, 30, 80, 30 );
|
||||
if (SDL_ATassert( "SDL_RenderLine", ret == 0))
|
||||
ret = SDL_RenderDrawLine( 0, 30, 80, 30 );
|
||||
if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_SetRenderDrawColor( 55, 55, 5, SDL_ALPHA_OPAQUE );
|
||||
if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_RenderLine( 40, 30, 40, 60 );
|
||||
if (SDL_ATassert( "SDL_RenderLine", ret == 0))
|
||||
ret = SDL_RenderDrawLine( 40, 30, 40, 60 );
|
||||
if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_SetRenderDrawColor( 5, 105, 105, SDL_ALPHA_OPAQUE );
|
||||
if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_RenderLine( 0, 0, 29, 29 );
|
||||
if (SDL_ATassert( "SDL_RenderLine", ret == 0))
|
||||
ret = SDL_RenderDrawLine( 0, 0, 29, 29 );
|
||||
if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_RenderLine( 29, 30, 0, 59 );
|
||||
if (SDL_ATassert( "SDL_RenderLine", ret == 0))
|
||||
ret = SDL_RenderDrawLine( 29, 30, 0, 59 );
|
||||
if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_RenderLine( 79, 0, 50, 29 );
|
||||
if (SDL_ATassert( "SDL_RenderLine", ret == 0))
|
||||
ret = SDL_RenderDrawLine( 79, 0, 50, 29 );
|
||||
if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_RenderLine( 79, 59, 50, 30 );
|
||||
if (SDL_ATassert( "SDL_RenderLine", ret == 0))
|
||||
ret = SDL_RenderDrawLine( 79, 59, 50, 30 );
|
||||
if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
|
||||
return -1;
|
||||
|
||||
/* See if it's the same. */
|
||||
|
@ -506,8 +506,8 @@ static int render_testPrimitivesBlend (void)
|
|||
ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
|
||||
if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_RenderRect( NULL );
|
||||
if (SDL_ATassert( "SDL_RenderRect", ret == 0))
|
||||
ret = SDL_RenderFillRect( NULL );
|
||||
if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
|
||||
return -1;
|
||||
rect.x = 10;
|
||||
rect.y = 25;
|
||||
|
@ -519,8 +519,8 @@ static int render_testPrimitivesBlend (void)
|
|||
ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD );
|
||||
if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_RenderRect( &rect );
|
||||
if (SDL_ATassert( "SDL_RenderRect", ret == 0))
|
||||
ret = SDL_RenderFillRect( &rect );
|
||||
if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
|
||||
return -1;
|
||||
rect.x = 30;
|
||||
rect.y = 40;
|
||||
|
@ -532,8 +532,8 @@ static int render_testPrimitivesBlend (void)
|
|||
ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND );
|
||||
if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_RenderRect( &rect );
|
||||
if (SDL_ATassert( "SDL_RenderRect", ret == 0))
|
||||
ret = SDL_RenderFillRect( &rect );
|
||||
if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
|
||||
return -1;
|
||||
rect.x = 25;
|
||||
rect.y = 25;
|
||||
|
@ -545,8 +545,8 @@ static int render_testPrimitivesBlend (void)
|
|||
ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD );
|
||||
if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_RenderRect( &rect );
|
||||
if (SDL_ATassert( "SDL_RenderRect", ret == 0))
|
||||
ret = SDL_RenderFillRect( &rect );
|
||||
if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
|
||||
return -1;
|
||||
|
||||
/* Draw blended lines, lines for everyone. */
|
||||
|
@ -558,8 +558,8 @@ static int render_testPrimitivesBlend (void)
|
|||
(((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
|
||||
if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_RenderLine( 0, 0, i, 59 );
|
||||
if (SDL_ATassert( "SDL_RenderLine", ret == 0))
|
||||
ret = SDL_RenderDrawLine( 0, 0, i, 59 );
|
||||
if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
|
||||
return -1;
|
||||
}
|
||||
for (i=0; i<SCREEN_H; i+=2) {
|
||||
|
@ -570,8 +570,8 @@ static int render_testPrimitivesBlend (void)
|
|||
(((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
|
||||
if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_RenderLine( 0, 0, 79, i );
|
||||
if (SDL_ATassert( "SDL_RenderLine", ret == 0))
|
||||
ret = SDL_RenderDrawLine( 0, 0, 79, i );
|
||||
if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -585,8 +585,8 @@ static int render_testPrimitivesBlend (void)
|
|||
((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
|
||||
if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
|
||||
return -1;
|
||||
ret = SDL_RenderPoint( i, j );
|
||||
if (SDL_ATassert( "SDL_RenderPoint", ret == 0))
|
||||
ret = SDL_RenderDrawPoint( i, j );
|
||||
if (SDL_ATassert( "SDL_RenderDrawPoint", ret == 0))
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,8 +56,7 @@ static void surface_testLoad( SDL_Surface *testsur )
|
|||
|
||||
/* Set transparent pixel as the pixel at (0,0) */
|
||||
if (face->format->palette) {
|
||||
ret = SDL_SetColorKey(face, (SDL_SRCCOLORKEY | SDL_RLEACCEL),
|
||||
*(Uint8 *) face->pixels);
|
||||
ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels);
|
||||
if (SDL_ATassert( "SDL_SetColorKey", ret == 0))
|
||||
return;
|
||||
}
|
||||
|
@ -184,29 +183,29 @@ static void surface_testPrimitivesBlend( SDL_Surface *testsur )
|
|||
return;
|
||||
|
||||
/* Create some rectangles for each blend mode. */
|
||||
ret = SDL_BlendRect( testsur, NULL, SDL_BLENDMODE_NONE, 255, 255, 255, 0 );
|
||||
if (SDL_ATassert( "SDL_BlendRect", ret == 0))
|
||||
ret = SDL_BlendFillRect( testsur, NULL, SDL_BLENDMODE_NONE, 255, 255, 255, 0 );
|
||||
if (SDL_ATassert( "SDL_BlendFillRect", ret == 0))
|
||||
return;
|
||||
rect.x = 10;
|
||||
rect.y = 25;
|
||||
rect.w = 40;
|
||||
rect.h = 25;
|
||||
ret = SDL_BlendRect( testsur, &rect, SDL_BLENDMODE_ADD, 240, 10, 10, 75 );
|
||||
if (SDL_ATassert( "SDL_BlendRect", ret == 0))
|
||||
ret = SDL_BlendFillRect( testsur, &rect, SDL_BLENDMODE_ADD, 240, 10, 10, 75 );
|
||||
if (SDL_ATassert( "SDL_BlendFillRect", ret == 0))
|
||||
return;
|
||||
rect.x = 30;
|
||||
rect.y = 40;
|
||||
rect.w = 45;
|
||||
rect.h = 15;
|
||||
ret = SDL_BlendRect( testsur, &rect, SDL_BLENDMODE_BLEND, 10, 240, 10, 100 );
|
||||
if (SDL_ATassert( "SDL_BlendRect", ret == 0))
|
||||
ret = SDL_BlendFillRect( testsur, &rect, SDL_BLENDMODE_BLEND, 10, 240, 10, 100 );
|
||||
if (SDL_ATassert( "SDL_BlendFillRect", ret == 0))
|
||||
return;
|
||||
rect.x = 25;
|
||||
rect.y = 25;
|
||||
rect.w = 25;
|
||||
rect.h = 25;
|
||||
ret = SDL_BlendRect( testsur, &rect, SDL_BLENDMODE_MOD, 10, 10, 240, 125 );
|
||||
if (SDL_ATassert( "SDL_BlendRect", ret == 0))
|
||||
ret = SDL_BlendFillRect( testsur, &rect, SDL_BLENDMODE_MOD, 10, 10, 240, 125 );
|
||||
if (SDL_ATassert( "SDL_BlendFillRect", ret == 0))
|
||||
return;
|
||||
|
||||
/* Draw blended lines, lines for everyone. */
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* Released under Public Domain.
|
||||
*/
|
||||
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_at.h"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue