@@ -811,6 +811,46 @@ int render_testBlitBlend(void *arg)
811
811
return TEST_COMPLETED ;
812
812
}
813
813
814
+ /**
815
+ * @brief Tests setting and getting texture scale mode.
816
+ *
817
+ * \sa
818
+ * http://wiki.libsdl.org/SDL2/SDL_SetTextureScaleMode
819
+ * http://wiki.libsdl.org/SDL2/SDL_GetTextureScaleMode
820
+ */
821
+ int render_testGetSetTextureScaleMode (void * arg )
822
+ {
823
+ const struct {
824
+ const char * name ;
825
+ SDL_ScaleMode mode ;
826
+ } modes [] = {
827
+ { "SDL_ScaleModeNearest" , SDL_ScaleModeNearest },
828
+ { "SDL_ScaleModeLinear" , SDL_ScaleModeLinear },
829
+ { "SDL_ScaleModeBest" , SDL_ScaleModeBest }
830
+ };
831
+ size_t i ;
832
+
833
+ for (i = 0 ; i < SDL_arraysize (modes ); i ++ ) {
834
+ SDL_Texture * texture ;
835
+ int result ;
836
+ SDL_ScaleMode actual_mode = SDL_ScaleModeNearest ;
837
+
838
+ SDL_ClearError ();
839
+ SDLTest_AssertPass ("About to call SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 16, 16)" );
840
+ texture = SDL_CreateTexture (renderer , SDL_PIXELFORMAT_ARGB8888 , SDL_TEXTUREACCESS_STREAMING , 16 , 16 );
841
+ SDLTest_AssertCheck (texture != NULL , "SDL_CreateTexture must return a non-NULL texture" );
842
+ SDLTest_AssertPass ("About to call SDL_SetTextureScaleMode(texture, %s)" , modes [i ].name );
843
+ result = SDL_SetTextureScaleMode (texture , modes [i ].mode );
844
+ SDLTest_AssertCheck (result == 0 , "SDL_SetTextureScaleMode must return 0, actual %d" , result );
845
+ SDLTest_AssertPass ("About to call SDL_GetTextureScaleMode(texture)" );
846
+ result = SDL_GetTextureScaleMode (texture , & actual_mode );
847
+ SDLTest_AssertCheck (result == 0 , "SDL_SetTextureScaleMode must return 0, actual %d" , result );
848
+ SDLTest_AssertCheck (actual_mode == modes [i ].mode , "SDL_GetTextureScaleMode must return %s (%d), actual=%d" ,
849
+ modes [i ].name , modes [i ].mode , actual_mode );
850
+ }
851
+ return TEST_COMPLETED ;
852
+ }
853
+
814
854
/**
815
855
* @brief Checks to see if functionality is supported. Helper function.
816
856
*/
@@ -1161,9 +1201,13 @@ static const SDLTest_TestCaseReference renderTest7 = {
1161
1201
(SDLTest_TestCaseFp )render_testBlitBlend , "render_testBlitBlend" , "Tests blitting with blending" , TEST_DISABLED
1162
1202
};
1163
1203
1204
+ static const SDLTest_TestCaseReference renderTest8 = {
1205
+ (SDLTest_TestCaseFp )render_testGetSetTextureScaleMode , "render_testGetSetTextureScaleMode" , "Tests setting/getting texture scale mode" , TEST_ENABLED
1206
+ };
1207
+
1164
1208
/* Sequence of Render test cases */
1165
1209
static const SDLTest_TestCaseReference * renderTests [] = {
1166
- & renderTest1 , & renderTest2 , & renderTest3 , & renderTest4 , & renderTest5 , & renderTest6 , & renderTest7 , NULL
1210
+ & renderTest1 , & renderTest2 , & renderTest3 , & renderTest4 , & renderTest5 , & renderTest6 , & renderTest7 , & renderTest8 , NULL
1167
1211
};
1168
1212
1169
1213
/* Render test suite (global) */
0 commit comments