2015-06-21 09:33:46 -06:00
/**
* Original code : automated SDL platform test written by Edgar Simo " bobbens "
* Extended and extensively updated by aschiffler at ferzkopp dot net
*/
2022-11-26 21:43:38 -07:00
# include <SDL3/SDL.h>
# include <SDL3/SDL_test.h>
2023-01-26 11:23:57 -07:00
# include "testautomation_images.h"
2023-03-08 08:12:45 -07:00
# include "testautomation_suites.h"
2015-06-21 09:33:46 -06:00
/* ================= Test Case Implementation ================== */
2022-11-30 13:51:59 -07:00
# define TESTRENDER_SCREEN_W 80
# define TESTRENDER_SCREEN_H 60
2015-06-21 09:33:46 -06:00
2022-12-01 09:04:02 -07:00
2022-11-30 13:51:59 -07:00
# define RENDER_COMPARE_FORMAT SDL_PIXELFORMAT_ARGB8888
2023-01-26 15:49:23 -07:00
# define RENDER_COLOR_CLEAR 0xFF000000
2023-01-26 14:58:38 -07:00
# define RENDER_COLOR_GREEN 0xFF00FF00
2015-06-21 09:33:46 -06:00
# define ALLOWABLE_ERROR_OPAQUE 0
# define ALLOWABLE_ERROR_BLENDED 64
2023-02-05 10:08:33 -07:00
# define CHECK_FUNC(FUNC, PARAMS) \
{ \
int result = FUNC PARAMS ; \
if ( result ! = 0 ) { \
SDLTest_AssertCheck ( result = = 0 , " Validate result from %s, expected: 0, got: %i, %s " , # FUNC , result , SDL_GetError ( ) ) ; \
} \
}
2015-06-21 09:33:46 -06:00
/* Test window and renderer */
2023-03-08 08:12:45 -07:00
static SDL_Window * window = NULL ;
static SDL_Renderer * renderer = NULL ;
2015-06-21 09:33:46 -06:00
/* Prototypes for helper functions */
2022-12-29 14:58:16 -07:00
static int clearScreen ( void ) ;
static void compare ( SDL_Surface * reference , int allowable_error ) ;
static int hasTexAlpha ( void ) ;
static int hasTexColor ( void ) ;
static SDL_Texture * loadTestFace ( void ) ;
static int hasBlendModes ( void ) ;
static int hasDrawColor ( void ) ;
static int isSupported ( int code ) ;
2015-06-21 09:33:46 -06:00
/**
* Create software renderer for tests
*/
2023-03-08 08:12:45 -07:00
static void InitCreateRenderer ( void * arg )
2015-06-21 09:33:46 -06:00
{
2023-03-05 15:44:38 -07:00
int width = 320 , height = 240 ;
2023-08-26 19:04:23 -06:00
int renderer_flags = SDL_RENDERER_ACCELERATED ;
2022-11-30 13:51:59 -07:00
renderer = NULL ;
2023-03-05 15:44:38 -07:00
window = SDL_CreateWindow ( " render_testCreateRenderer " , width , height , 0 ) ;
2022-11-30 13:51:59 -07:00
SDLTest_AssertPass ( " SDL_CreateWindow() " ) ;
SDLTest_AssertCheck ( window ! = NULL , " Check SDL_CreateWindow result " ) ;
if ( window = = NULL ) {
return ;
}
2023-08-26 19:04:23 -06:00
if ( SDL_strcmp ( SDL_GetCurrentVideoDriver ( ) , " dummy " ) = = 0 ) {
renderer_flags = 0 ;
}
renderer = SDL_CreateRenderer ( window , NULL , renderer_flags ) ;
2022-11-30 13:51:59 -07:00
SDLTest_AssertPass ( " SDL_CreateRenderer() " ) ;
2024-01-08 11:34:28 -07:00
SDLTest_AssertCheck ( renderer ! = NULL , " Check SDL_CreateRenderer result: %s " , renderer ! = NULL ? " success " : SDL_GetError ( ) ) ;
2022-11-30 13:51:59 -07:00
if ( renderer = = NULL ) {
SDL_DestroyWindow ( window ) ;
return ;
}
2015-06-21 09:33:46 -06:00
}
2023-02-01 16:21:53 -07:00
/**
2015-06-21 09:33:46 -06:00
* Destroy renderer for tests
*/
2023-03-08 08:12:45 -07:00
static void CleanupDestroyRenderer ( void * arg )
2015-06-21 09:33:46 -06:00
{
2023-11-09 14:29:15 -07:00
if ( renderer ) {
2022-11-30 13:51:59 -07:00
SDL_DestroyRenderer ( renderer ) ;
renderer = NULL ;
SDLTest_AssertPass ( " SDL_DestroyRenderer() " ) ;
}
2023-11-09 14:29:15 -07:00
if ( window ) {
2022-11-30 13:51:59 -07:00
SDL_DestroyWindow ( window ) ;
window = NULL ;
SDLTest_AssertPass ( " SDL_DestroyWindow " ) ;
}
2015-06-21 09:33:46 -06:00
}
/**
2023-11-06 08:26:06 -07:00
* Tests call to SDL_GetNumRenderDrivers
2015-06-21 09:33:46 -06:00
*
2023-02-01 16:21:53 -07:00
* \ sa SDL_GetNumRenderDrivers
2015-06-21 09:33:46 -06:00
*/
2023-03-08 08:12:45 -07:00
static int render_testGetNumRenderDrivers ( void * arg )
2015-06-21 09:33:46 -06:00
{
2022-11-30 13:51:59 -07:00
int n ;
n = SDL_GetNumRenderDrivers ( ) ;
SDLTest_AssertCheck ( n > = 1 , " Number of renderers >= 1, reported as %i " , n ) ;
return TEST_COMPLETED ;
2015-06-21 09:33:46 -06:00
}
/**
2023-11-06 08:26:06 -07:00
* Tests the SDL primitives for rendering .
2015-06-21 09:33:46 -06:00
*
2023-02-01 16:21:53 -07:00
* \ sa SDL_SetRenderDrawColor
* \ sa SDL_RenderFillRect
* \ sa SDL_RenderLine
2015-06-21 09:33:46 -06:00
*
*/
2023-03-08 08:12:45 -07:00
static int render_testPrimitives ( void * arg )
2015-06-21 09:33:46 -06:00
{
2022-11-30 13:51:59 -07:00
int ret ;
int x , y ;
2022-12-31 12:19:32 -07:00
SDL_FRect rect ;
2022-11-30 13:51:59 -07:00
SDL_Surface * referenceSurface = NULL ;
int checkFailCount1 ;
int checkFailCount2 ;
/* Clear surface. */
2022-12-29 14:58:16 -07:00
clearScreen ( ) ;
2022-11-30 13:51:59 -07:00
/* Need drawcolor or just skip test. */
2022-12-29 14:58:16 -07:00
SDLTest_AssertCheck ( hasDrawColor ( ) , " _hasDrawColor " ) ;
2022-11-30 13:51:59 -07:00
/* Draw a rectangle. */
2022-12-31 12:19:32 -07:00
rect . x = 40.0f ;
rect . y = 0.0f ;
rect . w = 40.0f ;
rect . h = 80.0f ;
2022-11-30 13:51:59 -07:00
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_SetRenderDrawColor , ( renderer , 13 , 73 , 200 , SDL_ALPHA_OPAQUE ) )
CHECK_FUNC ( SDL_RenderFillRect , ( renderer , & rect ) )
2022-11-30 13:51:59 -07:00
/* Draw a rectangle. */
2022-12-31 12:19:32 -07:00
rect . x = 10.0f ;
rect . y = 10.0f ;
rect . w = 60.0f ;
rect . h = 40.0f ;
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_SetRenderDrawColor , ( renderer , 200 , 0 , 100 , SDL_ALPHA_OPAQUE ) )
CHECK_FUNC ( SDL_RenderFillRect , ( renderer , & rect ) )
2022-11-30 13:51:59 -07:00
/* Draw some points like so:
* X . X . X . X . .
* . X . X . X . X .
* X . X . X . X . . */
checkFailCount1 = 0 ;
checkFailCount2 = 0 ;
for ( y = 0 ; y < 3 ; y + + ) {
for ( x = y % 2 ; x < TESTRENDER_SCREEN_W ; x + = 2 ) {
ret = SDL_SetRenderDrawColor ( renderer , x * y , x * y / 2 , x * y / 3 , SDL_ALPHA_OPAQUE ) ;
if ( ret ! = 0 ) {
checkFailCount1 + + ;
}
2022-12-31 12:19:32 -07:00
ret = SDL_RenderPoint ( renderer , ( float ) x , ( float ) y ) ;
2022-11-30 13:51:59 -07:00
if ( ret ! = 0 ) {
checkFailCount2 + + ;
}
}
}
SDLTest_AssertCheck ( checkFailCount1 = = 0 , " Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i " , checkFailCount1 ) ;
2022-12-27 07:21:13 -07:00
SDLTest_AssertCheck ( checkFailCount2 = = 0 , " Validate results from calls to SDL_RenderPoint, expected: 0, got: %i " , checkFailCount2 ) ;
2022-11-30 13:51:59 -07:00
/* Draw some lines. */
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_SetRenderDrawColor , ( renderer , 0 , 255 , 0 , SDL_ALPHA_OPAQUE ) )
CHECK_FUNC ( SDL_RenderLine , ( renderer , 0.0f , 30.0f , ( float ) TESTRENDER_SCREEN_W , 30.0f ) )
CHECK_FUNC ( SDL_SetRenderDrawColor , ( renderer , 55 , 55 , 5 , SDL_ALPHA_OPAQUE ) )
CHECK_FUNC ( SDL_RenderLine , ( renderer , 40.0f , 30.0f , 40.0f , 60.0f ) )
CHECK_FUNC ( SDL_SetRenderDrawColor , ( renderer , 5 , 105 , 105 , SDL_ALPHA_OPAQUE ) )
CHECK_FUNC ( SDL_RenderLine , ( renderer , 0.0f , 0.0f , 29.0f , 29.0f ) )
CHECK_FUNC ( SDL_RenderLine , ( renderer , 29.0f , 30.0f , 0.0f , 59.0f ) )
CHECK_FUNC ( SDL_RenderLine , ( renderer , 79.0f , 0.0f , 50.0f , 29.0f ) )
CHECK_FUNC ( SDL_RenderLine , ( renderer , 79.0f , 59.0f , 50.0f , 30.0f ) )
2022-11-30 13:51:59 -07:00
/* See if it's the same. */
referenceSurface = SDLTest_ImagePrimitives ( ) ;
2022-12-29 14:58:16 -07:00
compare ( referenceSurface , ALLOWABLE_ERROR_OPAQUE ) ;
2022-11-30 13:51:59 -07:00
/* Make current */
SDL_RenderPresent ( renderer ) ;
/* Clean up. */
2022-12-27 07:36:39 -07:00
SDL_DestroySurface ( referenceSurface ) ;
2022-11-30 13:51:59 -07:00
referenceSurface = NULL ;
return TEST_COMPLETED ;
2015-06-21 09:33:46 -06:00
}
/**
2023-11-06 08:26:06 -07:00
* Tests the SDL primitives with alpha for rendering .
2015-06-21 09:33:46 -06:00
*
2023-02-01 16:21:53 -07:00
* \ sa SDL_SetRenderDrawColor
* \ sa SDL_SetRenderDrawBlendMode
* \ sa SDL_RenderFillRect
2015-06-21 09:33:46 -06:00
*/
2023-03-08 08:12:45 -07:00
static int render_testPrimitivesBlend ( void * arg )
2015-06-21 09:33:46 -06:00
{
2022-11-30 13:51:59 -07:00
int ret ;
int i , j ;
2022-12-31 12:19:32 -07:00
SDL_FRect rect ;
2022-11-30 13:51:59 -07:00
SDL_Surface * referenceSurface = NULL ;
int checkFailCount1 ;
int checkFailCount2 ;
int checkFailCount3 ;
/* Clear surface. */
2022-12-29 14:58:16 -07:00
clearScreen ( ) ;
2022-11-30 13:51:59 -07:00
/* Need drawcolor and blendmode or just skip test. */
2022-12-29 14:58:16 -07:00
SDLTest_AssertCheck ( hasDrawColor ( ) , " _hasDrawColor " ) ;
SDLTest_AssertCheck ( hasBlendModes ( ) , " _hasBlendModes " ) ;
2022-11-30 13:51:59 -07:00
/* Create some rectangles for each blend mode. */
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_SetRenderDrawColor , ( renderer , 255 , 255 , 255 , 0 ) )
CHECK_FUNC ( SDL_SetRenderDrawBlendMode , ( renderer , SDL_BLENDMODE_NONE ) )
CHECK_FUNC ( SDL_RenderFillRect , ( renderer , NULL ) )
2022-11-30 13:51:59 -07:00
2022-12-31 12:19:32 -07:00
rect . x = 10.0f ;
rect . y = 25.0f ;
rect . w = 40.0f ;
rect . h = 25.0f ;
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_SetRenderDrawColor , ( renderer , 240 , 10 , 10 , 75 ) )
CHECK_FUNC ( SDL_SetRenderDrawBlendMode , ( renderer , SDL_BLENDMODE_ADD ) )
CHECK_FUNC ( SDL_RenderFillRect , ( renderer , & rect ) )
2022-11-30 13:51:59 -07:00
2022-12-31 12:19:32 -07:00
rect . x = 30.0f ;
rect . y = 40.0f ;
rect . w = 45.0f ;
rect . h = 15.0f ;
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_SetRenderDrawColor , ( renderer , 10 , 240 , 10 , 100 ) )
CHECK_FUNC ( SDL_SetRenderDrawBlendMode , ( renderer , SDL_BLENDMODE_BLEND ) )
CHECK_FUNC ( SDL_RenderFillRect , ( renderer , & rect ) )
2022-11-30 13:51:59 -07:00
2022-12-31 12:19:32 -07:00
rect . x = 25.0f ;
rect . y = 25.0f ;
rect . w = 25.0f ;
rect . h = 25.0f ;
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_SetRenderDrawColor , ( renderer , 10 , 10 , 240 , 125 ) )
CHECK_FUNC ( SDL_SetRenderDrawBlendMode , ( renderer , SDL_BLENDMODE_NONE ) )
CHECK_FUNC ( SDL_RenderFillRect , ( renderer , & rect ) )
2022-11-30 13:51:59 -07:00
/* Draw blended lines, lines for everyone. */
checkFailCount1 = 0 ;
checkFailCount2 = 0 ;
checkFailCount3 = 0 ;
for ( i = 0 ; i < TESTRENDER_SCREEN_W ; i + = 2 ) {
ret = SDL_SetRenderDrawColor ( renderer , 60 + 2 * i , 240 - 2 * i , 50 , 3 * i ) ;
if ( ret ! = 0 ) {
2022-11-27 09:38:43 -07:00
checkFailCount1 + + ;
2022-11-30 13:51:59 -07:00
}
ret = SDL_SetRenderDrawBlendMode ( renderer , ( ( ( i / 2 ) % 3 ) = = 0 ) ? SDL_BLENDMODE_BLEND : ( ( ( i / 2 ) % 3 ) = = 1 ) ? SDL_BLENDMODE_ADD
: SDL_BLENDMODE_NONE ) ;
if ( ret ! = 0 ) {
checkFailCount2 + + ;
}
2015-06-21 09:33:46 -06:00
2022-12-31 12:19:32 -07:00
ret = SDL_RenderLine ( renderer , 0.0f , 0.0f , ( float ) i , 59.0f ) ;
2022-11-30 13:51:59 -07:00
if ( ret ! = 0 ) {
checkFailCount3 + + ;
}
}
SDLTest_AssertCheck ( checkFailCount1 = = 0 , " Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i " , checkFailCount1 ) ;
SDLTest_AssertCheck ( checkFailCount2 = = 0 , " Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i " , checkFailCount2 ) ;
2022-12-27 07:21:13 -07:00
SDLTest_AssertCheck ( checkFailCount3 = = 0 , " Validate results from calls to SDL_RenderLine, expected: 0, got: %i " , checkFailCount3 ) ;
2022-11-30 13:51:59 -07:00
checkFailCount1 = 0 ;
checkFailCount2 = 0 ;
checkFailCount3 = 0 ;
for ( i = 0 ; i < TESTRENDER_SCREEN_H ; i + = 2 ) {
ret = SDL_SetRenderDrawColor ( renderer , 60 + 2 * i , 240 - 2 * i , 50 , 3 * i ) ;
if ( ret ! = 0 ) {
checkFailCount1 + + ;
}
ret = SDL_SetRenderDrawBlendMode ( renderer , ( ( ( i / 2 ) % 3 ) = = 0 ) ? SDL_BLENDMODE_BLEND : ( ( ( i / 2 ) % 3 ) = = 1 ) ? SDL_BLENDMODE_ADD
: SDL_BLENDMODE_NONE ) ;
if ( ret ! = 0 ) {
checkFailCount2 + + ;
}
2015-06-21 09:33:46 -06:00
2022-12-31 12:19:32 -07:00
ret = SDL_RenderLine ( renderer , 0.0f , 0.0f , 79.0f , ( float ) i ) ;
2022-11-30 13:51:59 -07:00
if ( ret ! = 0 ) {
checkFailCount3 + + ;
}
}
SDLTest_AssertCheck ( checkFailCount1 = = 0 , " Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i " , checkFailCount1 ) ;
SDLTest_AssertCheck ( checkFailCount2 = = 0 , " Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i " , checkFailCount2 ) ;
2022-12-27 07:21:13 -07:00
SDLTest_AssertCheck ( checkFailCount3 = = 0 , " Validate results from calls to SDL_RenderLine, expected: 0, got: %i " , checkFailCount3 ) ;
2022-11-30 13:51:59 -07:00
/* Draw points. */
checkFailCount1 = 0 ;
checkFailCount2 = 0 ;
checkFailCount3 = 0 ;
for ( j = 0 ; j < TESTRENDER_SCREEN_H ; j + = 3 ) {
for ( i = 0 ; i < TESTRENDER_SCREEN_W ; i + = 3 ) {
ret = SDL_SetRenderDrawColor ( renderer , j * 4 , i * 3 , j * 4 , i * 3 ) ;
if ( ret ! = 0 ) {
checkFailCount1 + + ;
}
ret = SDL_SetRenderDrawBlendMode ( renderer , ( ( ( ( i + j ) / 3 ) % 3 ) = = 0 ) ? SDL_BLENDMODE_BLEND : ( ( ( ( i + j ) / 3 ) % 3 ) = = 1 ) ? SDL_BLENDMODE_ADD
: SDL_BLENDMODE_NONE ) ;
if ( ret ! = 0 ) {
checkFailCount2 + + ;
}
2022-12-31 12:19:32 -07:00
ret = SDL_RenderPoint ( renderer , ( float ) i , ( float ) j ) ;
2022-11-30 13:51:59 -07:00
if ( ret ! = 0 ) {
checkFailCount3 + + ;
}
}
}
SDLTest_AssertCheck ( checkFailCount1 = = 0 , " Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i " , checkFailCount1 ) ;
SDLTest_AssertCheck ( checkFailCount2 = = 0 , " Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i " , checkFailCount2 ) ;
2022-12-27 07:21:13 -07:00
SDLTest_AssertCheck ( checkFailCount3 = = 0 , " Validate results from calls to SDL_RenderPoint, expected: 0, got: %i " , checkFailCount3 ) ;
2022-11-30 13:51:59 -07:00
/* See if it's the same. */
referenceSurface = SDLTest_ImagePrimitivesBlend ( ) ;
2022-12-29 14:58:16 -07:00
compare ( referenceSurface , ALLOWABLE_ERROR_BLENDED ) ;
2022-11-30 13:51:59 -07:00
/* Make current */
SDL_RenderPresent ( renderer ) ;
/* Clean up. */
2022-12-27 07:36:39 -07:00
SDL_DestroySurface ( referenceSurface ) ;
2022-11-30 13:51:59 -07:00
referenceSurface = NULL ;
return TEST_COMPLETED ;
}
2015-06-21 09:33:46 -06:00
2024-01-19 17:28:00 -07:00
/**
* Tests the SDL primitives for rendering within a viewport .
*
* \ sa SDL_SetRenderDrawColor
* \ sa SDL_RenderFillRect
* \ sa SDL_RenderLine
*
*/
static int render_testPrimitivesWithViewport ( void * arg )
{
SDL_Rect viewport ;
2024-02-03 11:18:12 -07:00
SDL_Surface * surface ;
2024-01-19 17:28:00 -07:00
/* Clear surface. */
clearScreen ( ) ;
viewport . x = 2 ;
viewport . y = 2 ;
viewport . w = 2 ;
viewport . h = 2 ;
CHECK_FUNC ( SDL_SetRenderViewport , ( renderer , & viewport ) ) ;
CHECK_FUNC ( SDL_SetRenderDrawColor , ( renderer , 255 , 255 , 255 , SDL_ALPHA_OPAQUE ) )
CHECK_FUNC ( SDL_RenderLine , ( renderer , 0.0f , 0.0f , 1.0f , 1.0f ) ) ;
viewport . x = 3 ;
viewport . y = 3 ;
viewport . w = 1 ;
viewport . h = 1 ;
CHECK_FUNC ( SDL_SetRenderViewport , ( renderer , & viewport ) ) ;
2024-02-03 11:18:12 -07:00
surface = SDL_RenderReadPixels ( renderer , NULL ) ;
if ( surface ) {
Uint8 r , g , b , a ;
CHECK_FUNC ( SDL_ReadSurfacePixel , ( surface , 0 , 0 , & r , & g , & b , & a ) ) ;
SDLTest_AssertCheck ( r = = 0xFF & & g = = 0xFF & & b = = 0xFF & & a = = 0xFF , " Validate diagonal line drawing with viewport, expected 0xFFFFFFFF, got 0x%.2x%.2x%.2x%.2x " , r , g , b , a ) ;
SDL_DestroySurface ( surface ) ;
} else {
SDLTest_AssertCheck ( surface ! = NULL , " Validate result from SDL_RenderReadPixels, got NULL, %s " , SDL_GetError ( ) ) ;
}
2024-01-19 17:28:00 -07:00
return TEST_COMPLETED ;
}
2015-06-21 09:33:46 -06:00
/**
2023-11-06 08:26:06 -07:00
* Tests some blitting routines .
2015-06-21 09:33:46 -06:00
*
2023-02-01 16:21:53 -07:00
* \ sa SDL_RenderTexture
* \ sa SDL_DestroyTexture
2015-06-21 09:33:46 -06:00
*/
2023-03-08 08:12:45 -07:00
static int render_testBlit ( void * arg )
2015-06-21 09:33:46 -06:00
{
2022-11-30 13:51:59 -07:00
int ret ;
2022-12-31 12:19:32 -07:00
SDL_FRect rect ;
2022-11-30 13:51:59 -07:00
SDL_Texture * tface ;
SDL_Surface * referenceSurface = NULL ;
Uint32 tformat ;
int taccess , tw , th ;
int i , j , ni , nj ;
int checkFailCount1 ;
/* Clear surface. */
2022-12-29 14:58:16 -07:00
clearScreen ( ) ;
2022-11-30 13:51:59 -07:00
/* Need drawcolor or just skip test. */
2022-12-29 14:58:16 -07:00
SDLTest_AssertCheck ( hasDrawColor ( ) , " _hasDrawColor) " ) ;
2022-11-30 13:51:59 -07:00
/* Create face surface. */
2022-12-29 14:58:16 -07:00
tface = loadTestFace ( ) ;
SDLTest_AssertCheck ( tface ! = NULL , " Verify loadTestFace() result " ) ;
2022-11-30 13:51:59 -07:00
if ( tface = = NULL ) {
return TEST_ABORTED ;
}
/* Constant values. */
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_QueryTexture , ( tface , & tformat , & taccess , & tw , & th ) )
2022-12-31 12:19:32 -07:00
rect . w = ( float ) tw ;
rect . h = ( float ) th ;
2022-11-30 13:51:59 -07:00
ni = TESTRENDER_SCREEN_W - tw ;
nj = TESTRENDER_SCREEN_H - th ;
/* Loop blit. */
checkFailCount1 = 0 ;
for ( j = 0 ; j < = nj ; j + = 4 ) {
for ( i = 0 ; i < = ni ; i + = 4 ) {
/* Blitting. */
2022-12-31 12:19:32 -07:00
rect . x = ( float ) i ;
rect . y = ( float ) j ;
2022-12-27 07:21:13 -07:00
ret = SDL_RenderTexture ( renderer , tface , NULL , & rect ) ;
2022-11-30 13:51:59 -07:00
if ( ret ! = 0 ) {
checkFailCount1 + + ;
}
}
}
2022-12-27 07:21:13 -07:00
SDLTest_AssertCheck ( checkFailCount1 = = 0 , " Validate results from calls to SDL_RenderTexture, expected: 0, got: %i " , checkFailCount1 ) ;
2022-11-30 13:51:59 -07:00
/* See if it's the same */
referenceSurface = SDLTest_ImageBlit ( ) ;
2022-12-29 14:58:16 -07:00
compare ( referenceSurface , ALLOWABLE_ERROR_OPAQUE ) ;
2022-11-30 13:51:59 -07:00
/* Make current */
SDL_RenderPresent ( renderer ) ;
/* Clean up. */
SDL_DestroyTexture ( tface ) ;
2022-12-27 07:36:39 -07:00
SDL_DestroySurface ( referenceSurface ) ;
2022-11-30 13:51:59 -07:00
referenceSurface = NULL ;
return TEST_COMPLETED ;
2015-06-21 09:33:46 -06:00
}
/**
2023-11-06 08:26:06 -07:00
* Blits doing color tests .
2015-06-21 09:33:46 -06:00
*
2023-02-01 16:21:53 -07:00
* \ sa SDL_SetTextureColorMod
* \ sa SDL_RenderTexture
* \ sa SDL_DestroyTexture
2015-06-21 09:33:46 -06:00
*/
2023-03-08 08:12:45 -07:00
static int render_testBlitColor ( void * arg )
2015-06-21 09:33:46 -06:00
{
2022-11-30 13:51:59 -07:00
int ret ;
2022-12-31 12:19:32 -07:00
SDL_FRect rect ;
2022-11-30 13:51:59 -07:00
SDL_Texture * tface ;
SDL_Surface * referenceSurface = NULL ;
Uint32 tformat ;
int taccess , tw , th ;
int i , j , ni , nj ;
int checkFailCount1 ;
int checkFailCount2 ;
/* Clear surface. */
2022-12-29 14:58:16 -07:00
clearScreen ( ) ;
2022-11-30 13:51:59 -07:00
/* Create face surface. */
2022-12-29 14:58:16 -07:00
tface = loadTestFace ( ) ;
SDLTest_AssertCheck ( tface ! = NULL , " Verify loadTestFace() result " ) ;
2022-11-30 13:51:59 -07:00
if ( tface = = NULL ) {
return TEST_ABORTED ;
}
/* Constant values. */
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_QueryTexture , ( tface , & tformat , & taccess , & tw , & th ) )
2022-12-31 12:19:32 -07:00
rect . w = ( float ) tw ;
rect . h = ( float ) th ;
2022-11-30 13:51:59 -07:00
ni = TESTRENDER_SCREEN_W - tw ;
nj = TESTRENDER_SCREEN_H - th ;
/* Test blitting with color mod. */
checkFailCount1 = 0 ;
checkFailCount2 = 0 ;
for ( j = 0 ; j < = nj ; j + = 4 ) {
for ( i = 0 ; i < = ni ; i + = 4 ) {
/* Set color mod. */
ret = SDL_SetTextureColorMod ( tface , ( 255 / nj ) * j , ( 255 / ni ) * i , ( 255 / nj ) * j ) ;
if ( ret ! = 0 ) {
checkFailCount1 + + ;
}
/* Blitting. */
2022-12-31 12:19:32 -07:00
rect . x = ( float ) i ;
rect . y = ( float ) j ;
2022-12-27 07:21:13 -07:00
ret = SDL_RenderTexture ( renderer , tface , NULL , & rect ) ;
2022-11-30 13:51:59 -07:00
if ( ret ! = 0 ) {
checkFailCount2 + + ;
}
}
}
SDLTest_AssertCheck ( checkFailCount1 = = 0 , " Validate results from calls to SDL_SetTextureColorMod, expected: 0, got: %i " , checkFailCount1 ) ;
2022-12-27 07:21:13 -07:00
SDLTest_AssertCheck ( checkFailCount2 = = 0 , " Validate results from calls to SDL_RenderTexture, expected: 0, got: %i " , checkFailCount2 ) ;
2022-11-30 13:51:59 -07:00
/* See if it's the same. */
referenceSurface = SDLTest_ImageBlitColor ( ) ;
2022-12-29 14:58:16 -07:00
compare ( referenceSurface , ALLOWABLE_ERROR_OPAQUE ) ;
2022-11-30 13:51:59 -07:00
/* Make current */
SDL_RenderPresent ( renderer ) ;
/* Clean up. */
SDL_DestroyTexture ( tface ) ;
2022-12-27 07:36:39 -07:00
SDL_DestroySurface ( referenceSurface ) ;
2022-11-30 13:51:59 -07:00
referenceSurface = NULL ;
return TEST_COMPLETED ;
2015-06-21 09:33:46 -06:00
}
/**
2023-11-06 08:26:06 -07:00
* Tests blitting with alpha .
2015-06-21 09:33:46 -06:00
*
2023-02-01 16:21:53 -07:00
* \ sa SDL_SetTextureAlphaMod
* \ sa SDL_RenderTexture
* \ sa SDL_DestroyTexture
2015-06-21 09:33:46 -06:00
*/
2023-03-08 08:12:45 -07:00
static int render_testBlitAlpha ( void * arg )
2015-06-21 09:33:46 -06:00
{
2022-11-30 13:51:59 -07:00
int ret ;
2022-12-31 12:19:32 -07:00
SDL_FRect rect ;
2022-11-30 13:51:59 -07:00
SDL_Texture * tface ;
SDL_Surface * referenceSurface = NULL ;
Uint32 tformat ;
int taccess , tw , th ;
int i , j , ni , nj ;
int checkFailCount1 ;
int checkFailCount2 ;
/* Clear surface. */
2022-12-29 14:58:16 -07:00
clearScreen ( ) ;
2022-11-30 13:51:59 -07:00
/* Need alpha or just skip test. */
2022-12-29 14:58:16 -07:00
SDLTest_AssertCheck ( hasTexAlpha ( ) , " _hasTexAlpha " ) ;
2022-11-30 13:51:59 -07:00
/* Create face surface. */
2022-12-29 14:58:16 -07:00
tface = loadTestFace ( ) ;
SDLTest_AssertCheck ( tface ! = NULL , " Verify loadTestFace() result " ) ;
2022-11-30 13:51:59 -07:00
if ( tface = = NULL ) {
return TEST_ABORTED ;
}
/* Constant values. */
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_QueryTexture , ( tface , & tformat , & taccess , & tw , & th ) )
2022-12-31 12:19:32 -07:00
rect . w = ( float ) tw ;
rect . h = ( float ) th ;
2022-11-30 13:51:59 -07:00
ni = TESTRENDER_SCREEN_W - tw ;
nj = TESTRENDER_SCREEN_H - th ;
/* Test blitting with alpha mod. */
checkFailCount1 = 0 ;
checkFailCount2 = 0 ;
for ( j = 0 ; j < = nj ; j + = 4 ) {
for ( i = 0 ; i < = ni ; i + = 4 ) {
/* Set alpha mod. */
ret = SDL_SetTextureAlphaMod ( tface , ( 255 / ni ) * i ) ;
if ( ret ! = 0 ) {
checkFailCount1 + + ;
}
/* Blitting. */
2022-12-31 12:19:32 -07:00
rect . x = ( float ) i ;
rect . y = ( float ) j ;
2022-12-27 07:21:13 -07:00
ret = SDL_RenderTexture ( renderer , tface , NULL , & rect ) ;
2022-11-30 13:51:59 -07:00
if ( ret ! = 0 ) {
checkFailCount2 + + ;
}
}
}
SDLTest_AssertCheck ( checkFailCount1 = = 0 , " Validate results from calls to SDL_SetTextureAlphaMod, expected: 0, got: %i " , checkFailCount1 ) ;
2022-12-27 07:21:13 -07:00
SDLTest_AssertCheck ( checkFailCount2 = = 0 , " Validate results from calls to SDL_RenderTexture, expected: 0, got: %i " , checkFailCount2 ) ;
2022-11-30 13:51:59 -07:00
/* See if it's the same. */
referenceSurface = SDLTest_ImageBlitAlpha ( ) ;
2022-12-29 14:58:16 -07:00
compare ( referenceSurface , ALLOWABLE_ERROR_BLENDED ) ;
2022-11-30 13:51:59 -07:00
/* Make current */
SDL_RenderPresent ( renderer ) ;
/* Clean up. */
SDL_DestroyTexture ( tface ) ;
2022-12-27 07:36:39 -07:00
SDL_DestroySurface ( referenceSurface ) ;
2022-11-30 13:51:59 -07:00
referenceSurface = NULL ;
return TEST_COMPLETED ;
2015-06-21 09:33:46 -06:00
}
/**
2023-11-06 08:26:06 -07:00
* Tests a blend mode .
2015-06-21 09:33:46 -06:00
*
2023-02-01 16:21:53 -07:00
* \ sa SDL_SetTextureBlendMode
* \ sa SDL_RenderTexture
2015-06-21 09:33:46 -06:00
*/
static void
2022-12-29 14:58:16 -07:00
testBlitBlendMode ( SDL_Texture * tface , int mode )
2015-06-21 09:33:46 -06:00
{
2022-11-30 13:51:59 -07:00
int ret ;
Uint32 tformat ;
int taccess , tw , th ;
int i , j , ni , nj ;
2022-12-31 12:19:32 -07:00
SDL_FRect rect ;
2022-11-30 13:51:59 -07:00
int checkFailCount1 ;
int checkFailCount2 ;
/* Clear surface. */
2022-12-29 14:58:16 -07:00
clearScreen ( ) ;
2022-11-30 13:51:59 -07:00
/* Constant values. */
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_QueryTexture , ( tface , & tformat , & taccess , & tw , & th ) )
2022-12-31 12:19:32 -07:00
rect . w = ( float ) tw ;
rect . h = ( float ) th ;
2022-11-30 13:51:59 -07:00
ni = TESTRENDER_SCREEN_W - tw ;
nj = TESTRENDER_SCREEN_H - th ;
/* Test blend mode. */
checkFailCount1 = 0 ;
checkFailCount2 = 0 ;
for ( j = 0 ; j < = nj ; j + = 4 ) {
for ( i = 0 ; i < = ni ; i + = 4 ) {
/* Set blend mode. */
ret = SDL_SetTextureBlendMode ( tface , ( SDL_BlendMode ) mode ) ;
if ( ret ! = 0 ) {
checkFailCount1 + + ;
}
/* Blitting. */
2022-12-31 12:19:32 -07:00
rect . x = ( float ) i ;
rect . y = ( float ) j ;
2022-12-27 07:21:13 -07:00
ret = SDL_RenderTexture ( renderer , tface , NULL , & rect ) ;
2022-11-30 13:51:59 -07:00
if ( ret ! = 0 ) {
checkFailCount2 + + ;
}
}
}
SDLTest_AssertCheck ( checkFailCount1 = = 0 , " Validate results from calls to SDL_SetTextureBlendMode, expected: 0, got: %i " , checkFailCount1 ) ;
2022-12-27 07:21:13 -07:00
SDLTest_AssertCheck ( checkFailCount2 = = 0 , " Validate results from calls to SDL_RenderTexture, expected: 0, got: %i " , checkFailCount2 ) ;
2015-06-21 09:33:46 -06:00
}
/**
2023-11-06 08:26:06 -07:00
* Tests some more blitting routines .
2015-06-21 09:33:46 -06:00
*
2023-02-01 16:21:53 -07:00
* \ sa SDL_SetTextureColorMod
* \ sa SDL_SetTextureAlphaMod
* \ sa SDL_SetTextureBlendMode
* \ sa SDL_DestroyTexture
2015-06-21 09:33:46 -06:00
*/
2023-03-08 08:12:45 -07:00
static int render_testBlitBlend ( void * arg )
2015-06-21 09:33:46 -06:00
{
2022-11-30 13:51:59 -07:00
int ret ;
2022-12-31 12:19:32 -07:00
SDL_FRect rect ;
2022-11-30 13:51:59 -07:00
SDL_Texture * tface ;
SDL_Surface * referenceSurface = NULL ;
Uint32 tformat ;
int taccess , tw , th ;
int i , j , ni , nj ;
int mode ;
int checkFailCount1 ;
int checkFailCount2 ;
int checkFailCount3 ;
int checkFailCount4 ;
2022-12-29 14:58:16 -07:00
SDLTest_AssertCheck ( hasBlendModes ( ) , " _hasBlendModes " ) ;
SDLTest_AssertCheck ( hasTexColor ( ) , " _hasTexColor " ) ;
SDLTest_AssertCheck ( hasTexAlpha ( ) , " _hasTexAlpha " ) ;
2022-11-30 13:51:59 -07:00
/* Create face surface. */
2022-12-29 14:58:16 -07:00
tface = loadTestFace ( ) ;
SDLTest_AssertCheck ( tface ! = NULL , " Verify loadTestFace() result " ) ;
2022-11-30 13:51:59 -07:00
if ( tface = = NULL ) {
return TEST_ABORTED ;
}
/* Constant values. */
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_QueryTexture , ( tface , & tformat , & taccess , & tw , & th ) )
2022-12-31 12:19:32 -07:00
rect . w = ( float ) tw ;
rect . h = ( float ) th ;
2022-11-30 13:51:59 -07:00
ni = TESTRENDER_SCREEN_W - tw ;
nj = TESTRENDER_SCREEN_H - th ;
/* Set alpha mod. */
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_SetTextureAlphaMod , ( tface , 100 ) )
2022-11-30 13:51:59 -07:00
/* Test None. */
2022-12-29 14:58:16 -07:00
testBlitBlendMode ( tface , SDL_BLENDMODE_NONE ) ;
2022-11-30 13:51:59 -07:00
referenceSurface = SDLTest_ImageBlitBlendNone ( ) ;
/* Compare, then Present */
2022-12-29 14:58:16 -07:00
compare ( referenceSurface , ALLOWABLE_ERROR_OPAQUE ) ;
2022-11-30 13:51:59 -07:00
SDL_RenderPresent ( renderer ) ;
2022-12-27 07:36:39 -07:00
SDL_DestroySurface ( referenceSurface ) ;
2022-11-30 13:51:59 -07:00
referenceSurface = NULL ;
/* Test Blend. */
2022-12-29 14:58:16 -07:00
testBlitBlendMode ( tface , SDL_BLENDMODE_BLEND ) ;
2022-11-30 13:51:59 -07:00
referenceSurface = SDLTest_ImageBlitBlend ( ) ;
/* Compare, then Present */
2022-12-29 14:58:16 -07:00
compare ( referenceSurface , ALLOWABLE_ERROR_BLENDED ) ;
2022-11-30 13:51:59 -07:00
SDL_RenderPresent ( renderer ) ;
2022-12-27 07:36:39 -07:00
SDL_DestroySurface ( referenceSurface ) ;
2022-11-30 13:51:59 -07:00
referenceSurface = NULL ;
/* Test Add. */
2022-12-29 14:58:16 -07:00
testBlitBlendMode ( tface , SDL_BLENDMODE_ADD ) ;
2022-11-30 13:51:59 -07:00
referenceSurface = SDLTest_ImageBlitBlendAdd ( ) ;
/* Compare, then Present */
2022-12-29 14:58:16 -07:00
compare ( referenceSurface , ALLOWABLE_ERROR_BLENDED ) ;
2022-11-30 13:51:59 -07:00
SDL_RenderPresent ( renderer ) ;
2022-12-27 07:36:39 -07:00
SDL_DestroySurface ( referenceSurface ) ;
2022-11-30 13:51:59 -07:00
referenceSurface = NULL ;
/* Test Mod. */
2022-12-29 14:58:16 -07:00
testBlitBlendMode ( tface , SDL_BLENDMODE_MOD ) ;
2022-11-30 13:51:59 -07:00
referenceSurface = SDLTest_ImageBlitBlendMod ( ) ;
/* Compare, then Present */
2022-12-29 14:58:16 -07:00
compare ( referenceSurface , ALLOWABLE_ERROR_BLENDED ) ;
2022-11-30 13:51:59 -07:00
SDL_RenderPresent ( renderer ) ;
2022-12-27 07:36:39 -07:00
SDL_DestroySurface ( referenceSurface ) ;
2022-11-30 13:51:59 -07:00
referenceSurface = NULL ;
/* Clear surface. */
2022-12-29 14:58:16 -07:00
clearScreen ( ) ;
2022-11-30 13:51:59 -07:00
/* Loop blit. */
checkFailCount1 = 0 ;
checkFailCount2 = 0 ;
checkFailCount3 = 0 ;
checkFailCount4 = 0 ;
for ( j = 0 ; j < = nj ; j + = 4 ) {
for ( i = 0 ; i < = ni ; i + = 4 ) {
/* Set color mod. */
ret = SDL_SetTextureColorMod ( tface , ( 255 / nj ) * j , ( 255 / ni ) * i , ( 255 / nj ) * j ) ;
if ( ret ! = 0 ) {
checkFailCount1 + + ;
}
/* Set alpha mod. */
ret = SDL_SetTextureAlphaMod ( tface , ( 100 / ni ) * i ) ;
if ( ret ! = 0 ) {
checkFailCount2 + + ;
}
/* Crazy blending mode magic. */
mode = ( i / 4 * j / 4 ) % 4 ;
if ( mode = = 0 ) {
mode = SDL_BLENDMODE_NONE ;
} else if ( mode = = 1 ) {
mode = SDL_BLENDMODE_BLEND ;
} else if ( mode = = 2 ) {
mode = SDL_BLENDMODE_ADD ;
} else if ( mode = = 3 ) {
mode = SDL_BLENDMODE_MOD ;
}
ret = SDL_SetTextureBlendMode ( tface , ( SDL_BlendMode ) mode ) ;
if ( ret ! = 0 ) {
checkFailCount3 + + ;
}
/* Blitting. */
2022-12-31 12:19:32 -07:00
rect . x = ( float ) i ;
rect . y = ( float ) j ;
2022-12-27 07:21:13 -07:00
ret = SDL_RenderTexture ( renderer , tface , NULL , & rect ) ;
2022-11-30 13:51:59 -07:00
if ( ret ! = 0 ) {
checkFailCount4 + + ;
}
}
}
SDLTest_AssertCheck ( checkFailCount1 = = 0 , " Validate results from calls to SDL_SetTextureColorMod, expected: 0, got: %i " , checkFailCount1 ) ;
SDLTest_AssertCheck ( checkFailCount2 = = 0 , " Validate results from calls to SDL_SetTextureAlphaMod, expected: 0, got: %i " , checkFailCount2 ) ;
SDLTest_AssertCheck ( checkFailCount3 = = 0 , " Validate results from calls to SDL_SetTextureBlendMode, expected: 0, got: %i " , checkFailCount3 ) ;
2022-12-27 07:21:13 -07:00
SDLTest_AssertCheck ( checkFailCount4 = = 0 , " Validate results from calls to SDL_RenderTexture, expected: 0, got: %i " , checkFailCount4 ) ;
2022-11-30 13:51:59 -07:00
/* Clean up. */
SDL_DestroyTexture ( tface ) ;
/* Check to see if final image matches. */
referenceSurface = SDLTest_ImageBlitBlendAll ( ) ;
2022-12-29 14:58:16 -07:00
compare ( referenceSurface , ALLOWABLE_ERROR_BLENDED ) ;
2022-11-30 13:51:59 -07:00
/* Make current */
SDL_RenderPresent ( renderer ) ;
2022-12-27 07:36:39 -07:00
SDL_DestroySurface ( referenceSurface ) ;
2022-11-30 13:51:59 -07:00
referenceSurface = NULL ;
return TEST_COMPLETED ;
2015-06-21 09:33:46 -06:00
}
2023-01-26 14:58:38 -07:00
/**
2023-11-06 08:26:06 -07:00
* Test viewport
2023-01-26 14:58:38 -07:00
*/
2023-03-08 08:12:45 -07:00
static int render_testViewport ( void * arg )
2023-01-26 14:58:38 -07:00
{
2023-01-26 17:10:13 -07:00
SDL_Surface * referenceSurface ;
SDL_Rect viewport ;
2023-01-26 14:58:38 -07:00
2023-01-26 17:10:13 -07:00
viewport . x = TESTRENDER_SCREEN_W / 3 ;
viewport . y = TESTRENDER_SCREEN_H / 3 ;
viewport . w = TESTRENDER_SCREEN_W / 2 ;
viewport . h = TESTRENDER_SCREEN_H / 2 ;
2023-01-26 14:58:38 -07:00
2023-01-26 17:10:13 -07:00
/* Create expected result */
referenceSurface = SDL_CreateSurface ( TESTRENDER_SCREEN_W , TESTRENDER_SCREEN_H , RENDER_COMPARE_FORMAT ) ;
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_FillSurfaceRect , ( referenceSurface , NULL , RENDER_COLOR_CLEAR ) )
CHECK_FUNC ( SDL_FillSurfaceRect , ( referenceSurface , & viewport , RENDER_COLOR_GREEN ) )
2023-02-01 16:21:53 -07:00
2023-01-26 14:58:38 -07:00
/* Clear surface. */
clearScreen ( ) ;
2023-01-26 17:10:13 -07:00
/* Set the viewport and do a fill operation */
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_SetRenderViewport , ( renderer , & viewport ) )
CHECK_FUNC ( SDL_SetRenderDrawColor , ( renderer , 0 , 255 , 0 , SDL_ALPHA_OPAQUE ) )
CHECK_FUNC ( SDL_RenderFillRect , ( renderer , NULL ) )
CHECK_FUNC ( SDL_SetRenderViewport , ( renderer , NULL ) )
2023-01-26 14:58:38 -07:00
/* Check to see if final image matches. */
2023-01-26 15:49:23 -07:00
compare ( referenceSurface , ALLOWABLE_ERROR_OPAQUE ) ;
2023-01-26 17:10:13 -07:00
/*
* Verify that clear ignores the viewport
*/
/* Create expected result */
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_FillSurfaceRect , ( referenceSurface , NULL , RENDER_COLOR_GREEN ) )
2023-02-01 16:21:53 -07:00
2023-01-26 17:10:13 -07:00
/* Clear surface. */
clearScreen ( ) ;
/* Set the viewport and do a clear operation */
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_SetRenderViewport , ( renderer , & viewport ) )
CHECK_FUNC ( SDL_SetRenderDrawColor , ( renderer , 0 , 255 , 0 , SDL_ALPHA_OPAQUE ) )
CHECK_FUNC ( SDL_RenderClear , ( renderer ) )
CHECK_FUNC ( SDL_SetRenderViewport , ( renderer , NULL ) )
2023-01-26 17:10:13 -07:00
/* Check to see if final image matches. */
compare ( referenceSurface , ALLOWABLE_ERROR_OPAQUE ) ;
2023-01-26 15:49:23 -07:00
/* Make current */
SDL_RenderPresent ( renderer ) ;
SDL_DestroySurface ( referenceSurface ) ;
return TEST_COMPLETED ;
}
/**
2023-11-06 08:26:06 -07:00
* Test logical size
2023-01-26 15:49:23 -07:00
*/
2023-03-08 08:12:45 -07:00
static int render_testLogicalSize ( void * arg )
2023-01-26 15:49:23 -07:00
{
2023-01-26 17:10:13 -07:00
SDL_Surface * referenceSurface ;
SDL_Rect viewport ;
2023-01-26 15:49:23 -07:00
SDL_FRect rect ;
int w , h ;
const int factor = 2 ;
2023-01-26 17:10:13 -07:00
viewport . x = ( ( TESTRENDER_SCREEN_W / 4 ) / factor ) * factor ;
viewport . y = ( ( TESTRENDER_SCREEN_H / 4 ) / factor ) * factor ;
viewport . w = ( ( TESTRENDER_SCREEN_W / 2 ) / factor ) * factor ;
viewport . h = ( ( TESTRENDER_SCREEN_H / 2 ) / factor ) * factor ;
2023-01-26 15:49:23 -07:00
2023-01-26 17:10:13 -07:00
/* Create expected result */
referenceSurface = SDL_CreateSurface ( TESTRENDER_SCREEN_W , TESTRENDER_SCREEN_H , RENDER_COMPARE_FORMAT ) ;
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_FillSurfaceRect , ( referenceSurface , NULL , RENDER_COLOR_CLEAR ) )
CHECK_FUNC ( SDL_FillSurfaceRect , ( referenceSurface , & viewport , RENDER_COLOR_GREEN ) )
2023-02-01 16:21:53 -07:00
2023-01-26 15:49:23 -07:00
/* Clear surface. */
clearScreen ( ) ;
2023-01-26 17:10:13 -07:00
/* Set the logical size and do a fill operation */
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_GetCurrentRenderOutputSize , ( renderer , & w , & h ) )
CHECK_FUNC ( SDL_SetRenderLogicalPresentation , ( renderer , w / factor , h / factor ,
2023-02-03 13:25:46 -07:00
SDL_LOGICAL_PRESENTATION_LETTERBOX ,
2023-02-05 10:08:33 -07:00
SDL_SCALEMODE_NEAREST ) )
CHECK_FUNC ( SDL_SetRenderDrawColor , ( renderer , 0 , 255 , 0 , SDL_ALPHA_OPAQUE ) )
2023-01-26 15:49:23 -07:00
rect . x = ( float ) viewport . x / factor ;
rect . y = ( float ) viewport . y / factor ;
rect . w = ( float ) viewport . w / factor ;
rect . h = ( float ) viewport . h / factor ;
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_RenderFillRect , ( renderer , & rect ) )
CHECK_FUNC ( SDL_SetRenderLogicalPresentation , ( renderer , 0 , 0 ,
2023-02-03 13:25:46 -07:00
SDL_LOGICAL_PRESENTATION_DISABLED ,
2023-02-05 10:08:33 -07:00
SDL_SCALEMODE_NEAREST ) )
2023-01-26 15:49:23 -07:00
/* Check to see if final image matches. */
compare ( referenceSurface , ALLOWABLE_ERROR_OPAQUE ) ;
/* Clear surface. */
clearScreen ( ) ;
2023-01-26 17:10:13 -07:00
/* Set the logical size and viewport and do a fill operation */
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_GetCurrentRenderOutputSize , ( renderer , & w , & h ) )
CHECK_FUNC ( SDL_SetRenderLogicalPresentation , ( renderer , w / factor , h / factor ,
2023-02-03 13:25:46 -07:00
SDL_LOGICAL_PRESENTATION_LETTERBOX ,
2023-02-05 10:08:33 -07:00
SDL_SCALEMODE_NEAREST ) )
2023-01-26 17:10:13 -07:00
viewport . x = ( TESTRENDER_SCREEN_W / 4 ) / factor ;
viewport . y = ( TESTRENDER_SCREEN_H / 4 ) / factor ;
viewport . w = ( TESTRENDER_SCREEN_W / 2 ) / factor ;
viewport . h = ( TESTRENDER_SCREEN_H / 2 ) / factor ;
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_SetRenderViewport , ( renderer , & viewport ) )
CHECK_FUNC ( SDL_SetRenderDrawColor , ( renderer , 0 , 255 , 0 , SDL_ALPHA_OPAQUE ) )
CHECK_FUNC ( SDL_RenderFillRect , ( renderer , NULL ) )
CHECK_FUNC ( SDL_SetRenderViewport , ( renderer , NULL ) )
CHECK_FUNC ( SDL_SetRenderLogicalPresentation , ( renderer , 0 , 0 ,
2023-02-03 13:25:46 -07:00
SDL_LOGICAL_PRESENTATION_DISABLED ,
2023-02-05 10:08:33 -07:00
SDL_SCALEMODE_NEAREST ) )
2023-01-26 15:49:23 -07:00
/* Check to see if final image matches. */
compare ( referenceSurface , ALLOWABLE_ERROR_OPAQUE ) ;
2023-01-26 14:58:38 -07:00
2023-01-26 17:10:13 -07:00
/*
* Test a logical size that isn ' t the same aspect ratio as the window
*/
viewport . x = ( TESTRENDER_SCREEN_W / 4 ) ;
viewport . y = 0 ;
viewport . w = TESTRENDER_SCREEN_W ;
viewport . h = TESTRENDER_SCREEN_H ;
/* Create expected result */
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_FillSurfaceRect , ( referenceSurface , NULL , RENDER_COLOR_CLEAR ) )
CHECK_FUNC ( SDL_FillSurfaceRect , ( referenceSurface , & viewport , RENDER_COLOR_GREEN ) )
2023-02-01 16:21:53 -07:00
2023-01-26 17:10:13 -07:00
/* Clear surface. */
clearScreen ( ) ;
/* Set the logical size and do a fill operation */
2023-02-05 10:08:33 -07:00
CHECK_FUNC ( SDL_GetCurrentRenderOutputSize , ( renderer , & w , & h ) )
CHECK_FUNC ( SDL_SetRenderLogicalPresentation , ( renderer ,
2023-02-03 13:25:46 -07:00
w - 2 * ( TESTRENDER_SCREEN_W / 4 ) ,
h ,
SDL_LOGICAL_PRESENTATION_LETTERBOX ,
2023-02-05 10:08:33 -07:00
SDL_SCALEMODE_LINEAR ) )
CHECK_FUNC ( SDL_SetRenderDrawColor , ( renderer , 0 , 255 , 0 , SDL_ALPHA_OPAQUE ) )
CHECK_FUNC ( SDL_RenderFillRect , ( renderer , NULL ) )
CHECK_FUNC ( SDL_SetRenderLogicalPresentation , ( renderer , 0 , 0 ,
2023-02-03 13:25:46 -07:00
SDL_LOGICAL_PRESENTATION_DISABLED ,
2023-02-05 10:08:33 -07:00
SDL_SCALEMODE_NEAREST ) )
2023-01-26 17:10:13 -07:00
/* Check to see if final image matches. */
compare ( referenceSurface , ALLOWABLE_ERROR_OPAQUE ) ;
/* Clear surface. */
clearScreen ( ) ;
2023-01-26 14:58:38 -07:00
/* Make current */
SDL_RenderPresent ( renderer ) ;
SDL_DestroySurface ( referenceSurface ) ;
return TEST_COMPLETED ;
}
/* Helper functions */
2015-06-21 09:33:46 -06:00
/**
2023-11-06 08:26:06 -07:00
* Checks to see if functionality is supported . Helper function .
2015-06-21 09:33:46 -06:00
*/
static int
2022-12-29 14:58:16 -07:00
isSupported ( int code )
2015-06-21 09:33:46 -06:00
{
2022-11-30 13:51:59 -07:00
return code = = 0 ;
2015-06-21 09:33:46 -06:00
}
/**
2023-11-06 08:26:06 -07:00
* Test to see if we can vary the draw color . Helper function .
2015-06-21 09:33:46 -06:00
*
2023-02-01 16:21:53 -07:00
* \ sa SDL_SetRenderDrawColor
* \ sa SDL_GetRenderDrawColor
2015-06-21 09:33:46 -06:00
*/
static int
2022-12-29 14:58:16 -07:00
hasDrawColor ( void )
2015-06-21 09:33:46 -06:00
{
2022-11-30 13:51:59 -07:00
int ret , fail ;
Uint8 r , g , b , a ;
fail = 0 ;
/* Set color. */
ret = SDL_SetRenderDrawColor ( renderer , 100 , 100 , 100 , 100 ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
ret = SDL_GetRenderDrawColor ( renderer , & r , & g , & b , & a ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
/* Restore natural. */
ret = SDL_SetRenderDrawColor ( renderer , 0 , 0 , 0 , SDL_ALPHA_OPAQUE ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
/* Something failed, consider not available. */
if ( fail ) {
return 0 ;
}
/* Not set properly, consider failed. */
else if ( ( r ! = 100 ) | | ( g ! = 100 ) | | ( b ! = 100 ) | | ( a ! = 100 ) ) {
return 0 ;
}
return 1 ;
2015-06-21 09:33:46 -06:00
}
/**
2023-11-06 08:26:06 -07:00
* Test to see if we can vary the blend mode . Helper function .
2015-06-21 09:33:46 -06:00
*
2023-02-01 16:21:53 -07:00
* \ sa SDL_SetRenderDrawBlendMode
* \ sa SDL_GetRenderDrawBlendMode
2015-06-21 09:33:46 -06:00
*/
static int
2022-12-29 14:58:16 -07:00
hasBlendModes ( void )
2015-06-21 09:33:46 -06:00
{
2022-11-30 13:51:59 -07:00
int fail ;
int ret ;
SDL_BlendMode mode ;
fail = 0 ;
ret = SDL_SetRenderDrawBlendMode ( renderer , SDL_BLENDMODE_BLEND ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
ret = SDL_GetRenderDrawBlendMode ( renderer , & mode ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
ret = ( mode ! = SDL_BLENDMODE_BLEND ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
ret = SDL_SetRenderDrawBlendMode ( renderer , SDL_BLENDMODE_ADD ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
ret = SDL_GetRenderDrawBlendMode ( renderer , & mode ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
ret = ( mode ! = SDL_BLENDMODE_ADD ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
ret = SDL_SetRenderDrawBlendMode ( renderer , SDL_BLENDMODE_MOD ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
ret = SDL_GetRenderDrawBlendMode ( renderer , & mode ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
ret = ( mode ! = SDL_BLENDMODE_MOD ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
ret = SDL_SetRenderDrawBlendMode ( renderer , SDL_BLENDMODE_NONE ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
ret = SDL_GetRenderDrawBlendMode ( renderer , & mode ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
ret = ( mode ! = SDL_BLENDMODE_NONE ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
return ! fail ;
2015-06-21 09:33:46 -06:00
}
/**
2023-11-06 08:26:06 -07:00
* Loads the test image ' Face ' as texture . Helper function .
2015-06-21 09:33:46 -06:00
*
2023-02-01 16:21:53 -07:00
* \ sa SDL_CreateTextureFromSurface
2015-06-21 09:33:46 -06:00
*/
static SDL_Texture *
2022-12-29 14:58:16 -07:00
loadTestFace ( void )
2015-06-21 09:33:46 -06:00
{
2022-11-30 13:51:59 -07:00
SDL_Surface * face ;
SDL_Texture * tface ;
2015-06-21 09:33:46 -06:00
2022-11-30 13:51:59 -07:00
face = SDLTest_ImageFace ( ) ;
2023-11-09 14:29:15 -07:00
if ( ! face ) {
2022-11-30 13:51:59 -07:00
return NULL ;
}
2015-06-21 09:33:46 -06:00
2022-11-30 13:51:59 -07:00
tface = SDL_CreateTextureFromSurface ( renderer , face ) ;
2023-11-09 14:29:15 -07:00
if ( ! tface ) {
2022-11-30 13:51:59 -07:00
SDLTest_LogError ( " SDL_CreateTextureFromSurface() failed with error: %s " , SDL_GetError ( ) ) ;
}
2015-06-21 09:33:46 -06:00
2022-12-27 07:36:39 -07:00
SDL_DestroySurface ( face ) ;
2015-06-21 09:33:46 -06:00
2022-11-30 13:51:59 -07:00
return tface ;
2015-06-21 09:33:46 -06:00
}
/**
2023-11-06 08:26:06 -07:00
* Test to see if can set texture color mode . Helper function .
2015-06-21 09:33:46 -06:00
*
2023-02-01 16:21:53 -07:00
* \ sa SDL_SetTextureColorMod
* \ sa SDL_GetTextureColorMod
* \ sa SDL_DestroyTexture
2015-06-21 09:33:46 -06:00
*/
static int
2022-12-29 14:58:16 -07:00
hasTexColor ( void )
2015-06-21 09:33:46 -06:00
{
2022-11-30 13:51:59 -07:00
int fail ;
int ret ;
SDL_Texture * tface ;
Uint8 r , g , b ;
/* Get test face. */
2022-12-29 14:58:16 -07:00
tface = loadTestFace ( ) ;
2023-11-09 14:29:15 -07:00
if ( ! tface ) {
2022-11-30 13:51:59 -07:00
return 0 ;
}
/* See if supported. */
fail = 0 ;
ret = SDL_SetTextureColorMod ( tface , 100 , 100 , 100 ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
ret = SDL_GetTextureColorMod ( tface , & r , & g , & b ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
/* Clean up. */
SDL_DestroyTexture ( tface ) ;
if ( fail ) {
return 0 ;
} else if ( ( r ! = 100 ) | | ( g ! = 100 ) | | ( b ! = 100 ) ) {
return 0 ;
}
return 1 ;
2015-06-21 09:33:46 -06:00
}
/**
2023-11-06 08:26:06 -07:00
* Test to see if we can vary the alpha of the texture . Helper function .
2015-06-21 09:33:46 -06:00
*
2023-02-01 16:21:53 -07:00
* \ sa SDL_SetTextureAlphaMod
* \ sa SDL_GetTextureAlphaMod
* \ sa SDL_DestroyTexture
2015-06-21 09:33:46 -06:00
*/
static int
2022-12-29 14:58:16 -07:00
hasTexAlpha ( void )
2015-06-21 09:33:46 -06:00
{
2022-11-30 13:51:59 -07:00
int fail ;
int ret ;
SDL_Texture * tface ;
Uint8 a ;
/* Get test face. */
2022-12-29 14:58:16 -07:00
tface = loadTestFace ( ) ;
2023-11-09 14:29:15 -07:00
if ( ! tface ) {
2022-11-30 13:51:59 -07:00
return 0 ;
}
/* See if supported. */
fail = 0 ;
ret = SDL_SetTextureAlphaMod ( tface , 100 ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
ret = SDL_GetTextureAlphaMod ( tface , & a ) ;
2022-12-29 14:58:16 -07:00
if ( ! isSupported ( ret ) ) {
2022-11-30 13:51:59 -07:00
fail = 1 ;
}
/* Clean up. */
SDL_DestroyTexture ( tface ) ;
if ( fail ) {
return 0 ;
} else if ( a ! = 100 ) {
return 0 ;
}
return 1 ;
2015-06-21 09:33:46 -06:00
}
/**
2023-11-06 08:26:06 -07:00
* Compares screen pixels with image pixels . Helper function .
2015-06-21 09:33:46 -06:00
*
2023-02-01 16:21:53 -07:00
* \ param referenceSurface Image to compare against .
* \ param allowable_error allowed difference from the reference image
2015-06-21 09:33:46 -06:00
*
2023-02-01 16:21:53 -07:00
* \ sa SDL_RenderReadPixels
* \ sa SDL_CreateSurfaceFrom
* \ sa SDL_DestroySurface
2015-06-21 09:33:46 -06:00
*/
static void
2022-12-29 14:58:16 -07:00
compare ( SDL_Surface * referenceSurface , int allowable_error )
2015-06-21 09:33:46 -06:00
{
2024-02-03 11:18:12 -07:00
int ret ;
SDL_Rect rect ;
SDL_Surface * surface , * testSurface ;
/* Explicitly specify the rect in case the window isn't the expected size... */
rect . x = 0 ;
rect . y = 0 ;
rect . w = TESTRENDER_SCREEN_W ;
rect . h = TESTRENDER_SCREEN_H ;
surface = SDL_RenderReadPixels ( renderer , & rect ) ;
if ( ! surface ) {
SDLTest_AssertCheck ( surface ! = NULL , " Validate result from SDL_RenderReadPixels, got NULL, %s " , SDL_GetError ( ) ) ;
return ;
}
testSurface = SDL_ConvertSurfaceFormat ( surface , RENDER_COMPARE_FORMAT ) ;
SDL_DestroySurface ( surface ) ;
if ( ! testSurface ) {
SDLTest_AssertCheck ( testSurface ! = NULL , " Validate result from SDL_ConvertSurfaceFormat, got NULL, %s " , SDL_GetError ( ) ) ;
return ;
}
/* Compare surface. */
ret = SDLTest_CompareSurfaces ( testSurface , referenceSurface , allowable_error ) ;
SDLTest_AssertCheck ( ret = = 0 , " Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i " , ret ) ;
/* Clean up. */
SDL_DestroySurface ( testSurface ) ;
2015-06-21 09:33:46 -06:00
}
/**
2023-11-06 08:26:06 -07:00
* Clears the screen . Helper function .
2015-06-21 09:33:46 -06:00
*
2023-02-01 16:21:53 -07:00
* \ sa SDL_SetRenderDrawColor
* \ sa SDL_RenderClear
* \ sa SDL_RenderPresent
* \ sa SDL_SetRenderDrawBlendMode
2015-06-21 09:33:46 -06:00
*/
static int
2022-12-29 14:58:16 -07:00
clearScreen ( void )
2015-06-21 09:33:46 -06:00
{
2022-11-30 13:51:59 -07:00
int ret ;
2015-06-21 09:33:46 -06:00
2023-01-26 17:10:13 -07:00
/* Make current */
SDL_RenderPresent ( renderer ) ;
2023-02-01 16:21:53 -07:00
2022-11-30 13:51:59 -07:00
/* Set color. */
ret = SDL_SetRenderDrawColor ( renderer , 0 , 0 , 0 , SDL_ALPHA_OPAQUE ) ;
SDLTest_AssertCheck ( ret = = 0 , " Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i " , ret ) ;
2015-06-21 09:33:46 -06:00
2022-11-30 13:51:59 -07:00
/* Clear screen. */
ret = SDL_RenderClear ( renderer ) ;
SDLTest_AssertCheck ( ret = = 0 , " Validate result from SDL_RenderClear, expected: 0, got: %i " , ret ) ;
2015-06-21 09:33:46 -06:00
2022-11-30 13:51:59 -07:00
/* Set defaults. */
ret = SDL_SetRenderDrawBlendMode ( renderer , SDL_BLENDMODE_NONE ) ;
SDLTest_AssertCheck ( ret = = 0 , " Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i " , ret ) ;
2015-06-21 09:33:46 -06:00
2022-11-30 13:51:59 -07:00
ret = SDL_SetRenderDrawColor ( renderer , 255 , 255 , 255 , SDL_ALPHA_OPAQUE ) ;
SDLTest_AssertCheck ( ret = = 0 , " Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i " , ret ) ;
2015-06-21 09:33:46 -06:00
2022-11-30 13:51:59 -07:00
return 0 ;
2015-06-21 09:33:46 -06:00
}
/* ================= Test References ================== */
/* Render test cases */
2022-11-30 13:51:59 -07:00
static const SDLTest_TestCaseReference renderTest1 = {
( SDLTest_TestCaseFp ) render_testGetNumRenderDrivers , " render_testGetNumRenderDrivers " , " Tests call to SDL_GetNumRenderDrivers " , TEST_ENABLED
} ;
2015-06-21 09:33:46 -06:00
2022-11-30 13:51:59 -07:00
static const SDLTest_TestCaseReference renderTest2 = {
( SDLTest_TestCaseFp ) render_testPrimitives , " render_testPrimitives " , " Tests rendering primitives " , TEST_ENABLED
} ;
2015-06-21 09:33:46 -06:00
/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
2022-11-30 13:51:59 -07:00
static const SDLTest_TestCaseReference renderTest3 = {
( SDLTest_TestCaseFp ) render_testPrimitivesBlend , " render_testPrimitivesBlend " , " Tests rendering primitives with blending " , TEST_DISABLED
} ;
2015-06-21 09:33:46 -06:00
2022-11-30 13:51:59 -07:00
static const SDLTest_TestCaseReference renderTest4 = {
2024-01-19 17:28:00 -07:00
( SDLTest_TestCaseFp ) render_testPrimitivesWithViewport , " render_testPrimitivesWithViewport " , " Tests rendering primitives within a viewport " , TEST_ENABLED
2022-11-30 13:51:59 -07:00
} ;
2015-06-21 09:33:46 -06:00
2022-11-30 13:51:59 -07:00
static const SDLTest_TestCaseReference renderTest5 = {
2024-01-19 17:28:00 -07:00
( SDLTest_TestCaseFp ) render_testBlit , " render_testBlit " , " Tests blitting " , TEST_ENABLED
} ;
static const SDLTest_TestCaseReference renderTest6 = {
2022-11-30 13:51:59 -07:00
( SDLTest_TestCaseFp ) render_testBlitColor , " render_testBlitColor " , " Tests blitting with color " , TEST_ENABLED
} ;
2015-06-21 09:33:46 -06:00
/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
2024-01-19 17:28:00 -07:00
static const SDLTest_TestCaseReference renderTest7 = {
2022-11-30 13:51:59 -07:00
( SDLTest_TestCaseFp ) render_testBlitAlpha , " render_testBlitAlpha " , " Tests blitting with alpha " , TEST_DISABLED
} ;
2015-06-21 09:33:46 -06:00
/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
2024-01-19 17:28:00 -07:00
static const SDLTest_TestCaseReference renderTest8 = {
2022-11-30 13:51:59 -07:00
( SDLTest_TestCaseFp ) render_testBlitBlend , " render_testBlitBlend " , " Tests blitting with blending " , TEST_DISABLED
} ;
2015-06-21 09:33:46 -06:00
2024-01-19 17:28:00 -07:00
static const SDLTest_TestCaseReference renderTest9 = {
2023-01-26 14:58:38 -07:00
( SDLTest_TestCaseFp ) render_testViewport , " render_testViewport " , " Tests viewport " , TEST_ENABLED
} ;
2024-01-19 17:28:00 -07:00
static const SDLTest_TestCaseReference renderTest10 = {
2023-01-26 15:49:23 -07:00
( SDLTest_TestCaseFp ) render_testLogicalSize , " render_testLogicalSize " , " Tests logical size " , TEST_ENABLED
} ;
2015-06-21 09:33:46 -06:00
/* Sequence of Render test cases */
2022-11-30 13:51:59 -07:00
static const SDLTest_TestCaseReference * renderTests [ ] = {
2023-01-26 15:49:23 -07:00
& renderTest1 , & renderTest2 , & renderTest3 , & renderTest4 ,
2023-01-26 17:10:13 -07:00
& renderTest5 , & renderTest6 , & renderTest7 , & renderTest8 ,
2024-01-19 17:28:00 -07:00
& renderTest9 , & renderTest10 , NULL
2015-06-21 09:33:46 -06:00
} ;
/* Render test suite (global) */
SDLTest_TestSuiteReference renderTestSuite = {
" Render " ,
InitCreateRenderer ,
renderTests ,
CleanupDestroyRenderer
} ;