comparison test/automated/render/render.c @ 5143:e743b9c3f6d6

Making the API simpler, the blend modes are "none, blend, add" and are supported by all renderers.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 31 Jan 2011 23:23:57 -0800
parents 35afe807b51c
children 3e4086b3bcd2
comparison
equal deleted inserted replaced
5142:57851a238c8f 5143:e743b9c3f6d6
186 fail = 1; 186 fail = 1;
187 ret = SDL_GetRenderDrawBlendMode( &mode ); 187 ret = SDL_GetRenderDrawBlendMode( &mode );
188 if (!render_isSupported(ret)) 188 if (!render_isSupported(ret))
189 fail = 1; 189 fail = 1;
190 ret = (mode != SDL_BLENDMODE_ADD); 190 ret = (mode != SDL_BLENDMODE_ADD);
191 if (!render_isSupported(ret))
192 fail = 1;
193 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD );
194 if (!render_isSupported(ret))
195 fail = 1;
196 ret = SDL_GetRenderDrawBlendMode( &mode );
197 if (!render_isSupported(ret))
198 fail = 1;
199 ret = (mode != SDL_BLENDMODE_MOD);
200 if (!render_isSupported(ret))
201 fail = 1;
202 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MASK );
203 if (!render_isSupported(ret))
204 fail = 1;
205 ret = SDL_GetRenderDrawBlendMode( &mode );
206 if (!render_isSupported(ret))
207 fail = 1;
208 ret = (mode != SDL_BLENDMODE_MASK);
209 if (!render_isSupported(ret)) 191 if (!render_isSupported(ret))
210 fail = 1; 192 fail = 1;
211 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE ); 193 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
212 if (!render_isSupported(ret)) 194 if (!render_isSupported(ret))
213 fail = 1; 195 fail = 1;
856 /* See if it's the same. */ 838 /* See if it's the same. */
857 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_NONE).", 839 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_NONE).",
858 &img_blendNone, ALLOWABLE_ERROR_OPAQUE )) 840 &img_blendNone, ALLOWABLE_ERROR_OPAQUE ))
859 return -1; 841 return -1;
860 842
861 /* Test Mask. */
862 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MASK ))
863 return -1;
864 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MASK).",
865 &img_blendMask, ALLOWABLE_ERROR_OPAQUE ))
866 return -1;
867
868 /* Test Blend. */ 843 /* Test Blend. */
869 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_BLEND )) 844 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_BLEND ))
870 return -1; 845 return -1;
871 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_BLEND).", 846 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_BLEND).",
872 &img_blendBlend, ALLOWABLE_ERROR_BLENDED )) 847 &img_blendBlend, ALLOWABLE_ERROR_BLENDED ))
875 /* Test Add. */ 850 /* Test Add. */
876 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_ADD )) 851 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_ADD ))
877 return -1; 852 return -1;
878 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_ADD).", 853 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_ADD).",
879 &img_blendAdd, ALLOWABLE_ERROR_BLENDED )) 854 &img_blendAdd, ALLOWABLE_ERROR_BLENDED ))
880 return -1;
881
882 /* Test Mod. */
883 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MOD ))
884 return -1;
885 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MOD).",
886 &img_blendMod, ALLOWABLE_ERROR_BLENDED ))
887 return -1; 855 return -1;
888 856
889 /* Clear surface. */ 857 /* Clear surface. */
890 if (render_clearScreen()) 858 if (render_clearScreen())
891 return -1; 859 return -1;
904 if (SDL_ATassert( "SDL_SetTextureAlphaMod", ret == 0)) 872 if (SDL_ATassert( "SDL_SetTextureAlphaMod", ret == 0))
905 return -1; 873 return -1;
906 874
907 /* Crazy blending mode magic. */ 875 /* Crazy blending mode magic. */
908 mode = (i/4*j/4) % 4; 876 mode = (i/4*j/4) % 4;
909 if (mode==0) mode = SDL_BLENDMODE_MASK; 877 if (mode==0) mode = SDL_BLENDMODE_NONE;
910 else if (mode==1) mode = SDL_BLENDMODE_BLEND; 878 else if (mode==1) mode = SDL_BLENDMODE_BLEND;
911 else if (mode==2) mode = SDL_BLENDMODE_ADD; 879 else if (mode==2) mode = SDL_BLENDMODE_ADD;
912 else if (mode==3) mode = SDL_BLENDMODE_MOD; 880 else if (mode==3) mode = SDL_BLENDMODE_NONE;
913 ret = SDL_SetTextureBlendMode( tface, mode ); 881 ret = SDL_SetTextureBlendMode( tface, mode );
914 if (SDL_ATassert( "SDL_SetTextureBlendMode", ret == 0)) 882 if (SDL_ATassert( "SDL_SetTextureBlendMode", ret == 0))
915 return -1; 883 return -1;
916 884
917 /* Blitting. */ 885 /* Blitting. */