annotate test/automated/render/render.c @ 3432:116f74112e8a

Work in progress: SDL_RenderReadPixels() should be implemented soon.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 15 Nov 2009 08:01:07 +0000
parents 22ac66da0765
children 9f62f47d989b
rev   line source
3259
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 * Automated SDL_Surface test.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 *
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4 * Written by Edgar Simo "bobbens"
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 *
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 * Released under Public Domain.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 #include "SDL.h"
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 #include "SDL_at.h"
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 #include "common/common.h"
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 /*
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 * Pull in images for testcases.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 #include "common/images.h"
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #define SCREEN_W 80
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 #define SCREEN_H 60
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 #define FACE_W img_face.width
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #define FACE_H img_face.height
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 /*
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 * Prototypes.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 static int render_compare( const char *msg, const SurfaceImage_t *s );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 static int render_isSupported( int code );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 static int render_hasDrawColor (void);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 static int render_hasBlendModes (void);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 static int render_hasTexColor (void);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 static int render_hasTexAlpha (void);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 static int render_clearScreen (void);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 /* Testcases. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 static int render_testPrimitives (void);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 static int render_testPrimitivesBlend (void);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 static int render_testBlit (void);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 static int render_testBlitColour (void);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 static int render_testBlitAlpha (void);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 static int render_testBlitBlendMode( SDL_TextureID tface, int mode );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 static int render_testBlitBlend (void);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 * @brief Compares screen pixels with image pixels.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 *
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 * @param msg Message on failure.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 * @param s Image to compare against.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 * @return 0 on success.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 static int render_compare( const char *msg, const SurfaceImage_t *s )
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 (void) msg;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 (void) s;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 int ret;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 void *pix;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 SDL_Surface *testsur;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 /* Allocate pixel space. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 pix = malloc( 4*80*60 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 if (SDL_ATassert( "malloc", pix!=NULL ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 return 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 /* Read pixels. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 ret = SDL_RenderReadPixels( NULL, pix, 80*4 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) )
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 return 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 /* Create surface. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 testsur = SDL_CreateRGBSurfaceFrom( pix, 80, 60, 32, 80*4,
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 RMASK, GMASK, BMASK, AMASK );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", testsur!=NULL ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 return 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 /* Compare surface. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 ret = surface_compare( testsur, s );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 if (SDL_ATassert( msg, ret==0 ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 return 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 /* Clean up. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 SDL_FreeSurface( testsur );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 free(pix);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 * @brief Checks to see if functionality is supported.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 static int render_isSupported( int code )
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 return (code == 0);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 * @brief Test to see if we can vary the draw colour.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 static int render_hasDrawColor (void)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 int ret, fail;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 Uint8 r, g, b, a;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 fail = 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 /* Set colour. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 ret = SDL_SetRenderDrawColor( 100, 100, 100, 100 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 ret = SDL_GetRenderDrawColor( &r, &g, &b, &a );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 /* Restore natural. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 ret = SDL_SetRenderDrawColor( 0, 0, 0, SDL_ALPHA_OPAQUE );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 /* Something failed, consider not available. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 if (fail)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 /* Not set properly, consider failed. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 else if ((r != 100) || (g != 100) || (b != 100) || (a != 100))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 return 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 * @brief Test to see if we can vary the blend mode.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 static int render_hasBlendModes (void)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 int fail;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 int ret;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 int mode;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 fail = 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 ret = SDL_GetRenderDrawBlendMode( &mode );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 ret = (mode != SDL_BLENDMODE_BLEND);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 ret = SDL_GetRenderDrawBlendMode( &mode );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 ret = (mode != SDL_BLENDMODE_ADD);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 ret = SDL_GetRenderDrawBlendMode( &mode );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 ret = (mode != SDL_BLENDMODE_MOD);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MASK );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 ret = SDL_GetRenderDrawBlendMode( &mode );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 ret = (mode != SDL_BLENDMODE_MASK);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 ret = SDL_GetRenderDrawBlendMode( &mode );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 ret = (mode != SDL_BLENDMODE_NONE);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 return !fail;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 * @brief Loads the test face.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 static SDL_TextureID render_loadTestFace (void)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 SDL_Surface *face;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 SDL_TextureID tface;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 /* Create face surface. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 img_face.width, img_face.height, 32, img_face.width*4,
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 RMASK, GMASK, BMASK, AMASK );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 if (face == NULL)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 tface = SDL_CreateTextureFromSurface( 0, face );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 SDL_FreeSurface(face);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 return tface;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 * @brief Test to see if can set texture colour mode.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 static int render_hasTexColor (void)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 int fail;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 int ret;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 SDL_TextureID tface;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 Uint8 r, g, b;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 /* Get test face. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 tface = render_loadTestFace();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 if (tface == 0)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 /* See if supported. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 fail = 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 ret = SDL_SetTextureColorMod( tface, 100, 100, 100 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 ret = SDL_GetTextureColorMod( tface, &r, &g, &b );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 /* Clean up. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 SDL_DestroyTexture( tface );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 if (fail)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 else if ((r != 100) || (g != 100) || (b != 100))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 return 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 * @brief Test to see if we can vary the alpha of the texture.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 static int render_hasTexAlpha (void)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 int fail;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 int ret;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 SDL_TextureID tface;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 Uint8 a;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 /* Get test face. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 tface = render_loadTestFace();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 if (tface == 0)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 /* See if supported. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 fail = 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 ret = SDL_SetTextureAlphaMod( tface, 100 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 ret = SDL_GetTextureAlphaMod( tface, &a );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 if (!render_isSupported(ret))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 fail = 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 /* Clean up. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 SDL_DestroyTexture( tface );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 if (fail)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 else if (a != 100)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 return 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 * @brief Clears the screen.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 *
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 * @note We don't test for errors, but they shouldn't happen.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 static int render_clearScreen (void)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 int ret;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 /* Set colour. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 ret = SDL_SetRenderDrawColor( 0, 0, 0, SDL_ALPHA_OPAQUE );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 /*
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 /* Clear screen. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 ret = SDL_RenderFill( NULL );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 /*
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 /* Set defaults. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 /*
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 ret = SDL_SetRenderDrawColor( 255, 255, 255, SDL_ALPHA_OPAQUE );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 /*
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 * @brief Tests the SDL primitives for rendering.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 static int render_testPrimitives (void)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 int ret;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 int x, y;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 SDL_Rect rect;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 /* Clear surface. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 if (render_clearScreen())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 /* Need drawcolour or just skip test. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 if (!render_hasDrawColor())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 /* Draw a rectangle. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 rect.x = 40;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 rect.y = 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 rect.w = 40;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 rect.h = 80;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 ret = SDL_SetRenderDrawColor( 13, 73, 200, SDL_ALPHA_OPAQUE );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 ret = SDL_RenderFill( &rect );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 if (SDL_ATassert( "SDL_RenderRect", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 /* Draw a rectangle. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 rect.x = 10;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 rect.y = 10;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 rect.w = 60;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 rect.h = 40;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 ret = SDL_SetRenderDrawColor( 200, 0, 100, SDL_ALPHA_OPAQUE );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 ret = SDL_RenderFill( &rect );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 if (SDL_ATassert( "SDL_RenderRect", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 /* Draw some points like so:
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 * X.X.X.X..
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 * .X.X.X.X.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 * X.X.X.X.. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 for (y=0; y<3; y++) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 x = y % 2;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 for (; x<80; x+=2) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 ret = SDL_SetRenderDrawColor( x*y, x*y/2, x*y/3, SDL_ALPHA_OPAQUE );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 ret = SDL_RenderPoint( x, y );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 if (SDL_ATassert( "SDL_RenderPoint", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 /* Draw some lines. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 ret = SDL_SetRenderDrawColor( 0, 255, 0, SDL_ALPHA_OPAQUE );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386 ret = SDL_RenderLine( 0, 30, 80, 30 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389 ret = SDL_SetRenderDrawColor( 55, 55, 5, SDL_ALPHA_OPAQUE );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 ret = SDL_RenderLine( 40, 30, 40, 60 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 ret = SDL_SetRenderDrawColor( 5, 105, 105, SDL_ALPHA_OPAQUE );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398 ret = SDL_RenderLine( 0, 60, 80, 0 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 /* See if it's the same. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 if (render_compare( "Primitives output not the same.", &img_primitives ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 * @brief Tests the SDL primitives with alpha for rendering.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 static int render_testPrimitivesBlend (void)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 int ret;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 int i, j;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 SDL_Rect rect;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 /* Clear surface. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 if (render_clearScreen())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 /* Need drawcolour and blendmode or just skip test. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 if (!render_hasDrawColor() || !render_hasBlendModes())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427 /* Create some rectangles for each blend mode. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428 ret = SDL_SetRenderDrawColor( 255, 255, 255, 0 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
429 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434 ret = SDL_RenderFill( NULL );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 rect.x = 10;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438 rect.y = 25;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 rect.w = 40;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
440 rect.h = 25;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441 ret = SDL_SetRenderDrawColor( 240, 10, 10, 75 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
442 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
443 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 ret = SDL_RenderFill( &rect );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
448 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
450 rect.x = 30;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 rect.y = 40;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
452 rect.w = 45;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453 rect.h = 15;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454 ret = SDL_SetRenderDrawColor( 10, 240, 10, 100 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
459 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
460 ret = SDL_RenderFill( &rect );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
461 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
462 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
463 rect.x = 25;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
464 rect.y = 25;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
465 rect.w = 25;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
466 rect.h = 25;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467 ret = SDL_SetRenderDrawColor( 10, 10, 240, 125 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
468 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
469 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
470 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
472 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
473 ret = SDL_RenderFill( &rect );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
474 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
475 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477 /* Draw blended lines, lines for everyone. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
478 for (i=0; i<SCREEN_W; i+=2) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
479 ret = SDL_SetRenderDrawColor( 60+2*i, 240-2*i, 50, 3*i );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
480 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
481 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482 ret = SDL_SetRenderDrawBlendMode((((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
484 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
485 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486 ret = SDL_RenderLine( 0, 0, i, 59 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
487 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
488 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
489 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
490 for (i=0; i<SCREEN_H; i+=2) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
491 ret = SDL_SetRenderDrawColor( 60+2*i, 240-2*i, 50, 3*i );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
492 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
493 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
494 ret = SDL_SetRenderDrawBlendMode((((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
495 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
496 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
497 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
498 ret = SDL_RenderLine( 0, 0, 79, i );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
499 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
500 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
501 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
502
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503 /* Draw points. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
504 for (j=0; j<SCREEN_H; j+=3) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
505 for (i=0; i<SCREEN_W; i+=3) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506 ret = SDL_SetRenderDrawColor( j*4, i*3, j*4, i*3 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
508 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509 ret = SDL_SetRenderDrawBlendMode( ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND :
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
510 ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
511 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
512 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
513 ret = SDL_RenderPoint( i, j );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
514 if (SDL_ATassert( "SDL_RenderPoint", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
515 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
516 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
517 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
519 /* See if it's the same. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
520 if (render_compare( "Blended primitives output not the same.", &img_primitives ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
521 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
522
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
523 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
524 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
525
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
526
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
527 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
528 * @brief Tests some blitting routines.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
529 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
530 static int render_testBlit (void)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
531 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
532 int ret;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
533 SDL_Rect rect;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
534 SDL_Surface *face;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
535 SDL_TextureID tface;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
536 int i, j, ni, nj;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
537
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
538 /* Clear surface. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539 if (render_clearScreen())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
540 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
541
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542 /* Need drawcolour or just skip test. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
543 if (!render_hasDrawColor())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
544 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
545
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
546 /* Create face surface. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
547 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
548 img_face.width, img_face.height, 32, img_face.width*4,
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
549 RMASK, GMASK, BMASK, AMASK );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
550 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
551 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
552 tface = SDL_CreateTextureFromSurface( 0, face );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
553 if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
554 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
555
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
556 /* Constant values. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
557 rect.w = face->w;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
558 rect.h = face->h;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
559 ni = SCREEN_W - face->w;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
560 nj = SCREEN_H - face->h;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
561
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
562 /* Clean up. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
563 SDL_FreeSurface( face );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
564
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
565 /* Loop blit. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
566 for (j=0; j <= nj; j+=4) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
567 for (i=0; i <= ni; i+=4) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
568 /* Blitting. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
569 rect.x = i;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
570 rect.y = j;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
571 ret = SDL_RenderCopy( tface, NULL, &rect );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
572 if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
573 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
574 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
575 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
576
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
577 /* Clean up. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
578 SDL_DestroyTexture( tface );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
579
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
580 /* See if it's the same. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
581 if (render_compare( "Blit output not the same.", &img_blit ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
582 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
583
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
584 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
585 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
586
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
587
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
588 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
589 * @brief Blits doing colour tests.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
590 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
591 static int render_testBlitColour (void)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
592 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
593 int ret;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
594 SDL_Rect rect;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
595 SDL_Surface *face;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
596 SDL_TextureID tface;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
597 int i, j, ni, nj;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
598
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
599 /* Clear surface. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
600 if (render_clearScreen())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
601 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
602
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
603 /* Need drawcolour or just skip test. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
604 if (!render_hasTexColor())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
605 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
606
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
607 /* Create face surface. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
608 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
609 img_face.width, img_face.height, 32, img_face.width*4,
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
610 RMASK, GMASK, BMASK, AMASK );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
611 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
612 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
613 tface = SDL_CreateTextureFromSurface( 0, face );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
614 if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
615 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
616
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
617 /* Constant values. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
618 rect.w = face->w;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
619 rect.h = face->h;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
620 ni = SCREEN_W - face->w;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
621 nj = SCREEN_H - face->h;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
622
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
623 /* Clean up. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
624 SDL_FreeSurface( face );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
625
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
626 /* Test blitting with colour mod. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
627 for (j=0; j <= nj; j+=4) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
628 for (i=0; i <= ni; i+=4) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
629 /* Set colour mod. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
630 ret = SDL_SetTextureColorMod( tface, (255/nj)*j, (255/ni)*i, (255/nj)*j );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
631 if (SDL_ATassert( "SDL_SetTextureColorMod", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
632 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
633
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
634 /* Blitting. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
635 rect.x = i;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
636 rect.y = j;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
637 ret = SDL_RenderCopy( tface, NULL, &rect );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
638 if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
639 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
640 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
641 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
642
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
643 /* Clean up. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
644 SDL_DestroyTexture( tface );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
645
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
646 /* See if it's the same. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
647 if (render_compare( "Blit output not the same (using SDL_SetTextureColorMod).",
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
648 &img_blitColour ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
649 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
650
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
651 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
652 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
653
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
654
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
655 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
656 * @brief Tests blitting with alpha.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
657 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
658 static int render_testBlitAlpha (void)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
659 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
660 int ret;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
661 SDL_Rect rect;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
662 SDL_Surface *face;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
663 SDL_TextureID tface;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
664 int i, j, ni, nj;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
665
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
666 /* Clear surface. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
667 if (render_clearScreen())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
668 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
669
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
670 /* Need alpha or just skip test. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
671 if (!render_hasTexAlpha())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
672 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
673
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
674 /* Create face surface. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
675 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
676 img_face.width, img_face.height, 32, img_face.width*4,
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
677 RMASK, GMASK, BMASK, AMASK );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
678 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
679 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
680 tface = SDL_CreateTextureFromSurface( 0, face );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
681 if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
682 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
683
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
684 /* Constant values. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
685 rect.w = face->w;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
686 rect.h = face->h;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
687 ni = SCREEN_W - face->w;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
688 nj = SCREEN_H - face->h;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
689
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
690 /* Clean up. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
691 SDL_FreeSurface( face );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
692
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
693 /* Clear surface. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
694 if (render_clearScreen())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
695 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
696
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
697 /* Test blitting with alpha mod. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
698 for (j=0; j <= nj; j+=4) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
699 for (i=0; i <= ni; i+=4) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
700 /* Set alpha mod. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
701 ret = SDL_SetTextureAlphaMod( tface, (255/ni)*i );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
702 if (SDL_ATassert( "SDL_SetTextureAlphaMod", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
703 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
704
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
705 /* Blitting. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
706 rect.x = i;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
707 rect.y = j;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
708 ret = SDL_RenderCopy( tface, NULL, &rect );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
709 if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
710 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
711 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
712 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
713
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
714 /* Clean up. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
715 SDL_DestroyTexture( tface );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
716
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
717 /* See if it's the same. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
718 if (render_compare( "Blit output not the same (using SDL_SetSurfaceAlphaMod).",
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
719 &img_blitAlpha ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
720 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
721
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
722 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
723 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
724
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
725
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
726 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
727 * @brief Tests a blend mode.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
728 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
729 static int render_testBlitBlendMode( SDL_TextureID tface, int mode )
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
730 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
731 int ret;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
732 int i, j, ni, nj;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
733 SDL_Rect rect;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
734
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
735 /* Clear surface. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
736 if (render_clearScreen())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
737 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
738
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
739 /* Steps to take. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
740 ni = SCREEN_W - FACE_W;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
741 nj = SCREEN_H - FACE_H;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
742
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
743 /* Constant values. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
744 rect.w = FACE_W;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
745 rect.h = FACE_H;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
746
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
747 /* Test blend mode. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
748 for (j=0; j <= nj; j+=4) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
749 for (i=0; i <= ni; i+=4) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
750 /* Set blend mode. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
751 ret = SDL_SetRenderDrawBlendMode( mode );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
752 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
753 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
754
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
755 /* Blitting. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
756 rect.x = i;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
757 rect.y = j;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
758 ret = SDL_RenderCopy( tface, NULL, &rect );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
759 if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
760 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
761 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
762 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
763
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
764 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
765 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
766
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
767
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
768 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
769 * @brief Tests some more blitting routines.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
770 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
771 static int render_testBlitBlend (void)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
772 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
773 int ret;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
774 SDL_Rect rect;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
775 SDL_Surface *face;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
776 SDL_TextureID tface;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
777 int i, j, ni, nj;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
778 int mode;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
779
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
780 /* Clear surface. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
781 if (render_clearScreen())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
782 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
783
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
784 /* Need drawcolour and blendmode or just skip test. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
785 if (!render_hasBlendModes() || !render_hasTexColor() || !render_hasTexAlpha())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
786 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
787
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
788 /* Create face surface. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
789 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
790 img_face.width, img_face.height, 32, img_face.width*4,
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
791 RMASK, GMASK, BMASK, AMASK );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
792 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
793 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
794 tface = SDL_CreateTextureFromSurface( 0, face );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
795 if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
796 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
797
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
798 /* Steps to take. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
799 ni = SCREEN_W - FACE_W;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
800 nj = SCREEN_H - FACE_H;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
801
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
802 /* Constant values. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
803 rect.w = face->w;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
804 rect.h = face->h;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
805
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
806 /* Clean up. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
807 SDL_FreeSurface( face );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
808
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
809 /* Set alpha mod. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
810 ret = SDL_SetRenderDrawColor( 255, 255, 255, 100 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
811 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
812 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
813
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
814 /* Test None. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
815 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_NONE ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
816 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
817 /* See if it's the same. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
818 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_NONE).",
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
819 &img_blitAlpha ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
820 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
821
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
822 /* Test Mask. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
823 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MASK ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
824 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
825 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MASK).",
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
826 &img_blendMask ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
827 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
828
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
829 /* Test Blend. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
830 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_BLEND ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
831 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
832 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_BLEND).",
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
833 &img_blendBlend ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
834 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
835
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
836 /* Test Add. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
837 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_ADD ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
838 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
839 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_ADD).",
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
840 &img_blendAdd ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
841 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
842
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
843 /* Test Mod. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
844 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MOD ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
845 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
846 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MOD).",
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
847 &img_blendMod ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
848 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
849
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
850 /* Clear surface. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
851 if (render_clearScreen())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
852 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
853
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
854 /* Loop blit. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
855 for (j=0; j <= nj; j+=4) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
856 for (i=0; i <= ni; i+=4) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
857
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
858 /* Set colour mod. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
859 ret = SDL_SetRenderDrawColor( (255/nj)*j, (255/ni)*i, (255/nj)*j, (100/ni)*i );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
860 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
861 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
862
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
863 /* Crazy blending mode magic. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
864 mode = (i/4*j/4) % 4;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
865 if (mode==0) mode = SDL_BLENDMODE_MASK;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
866 else if (mode==1) mode = SDL_BLENDMODE_BLEND;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
867 else if (mode==2) mode = SDL_BLENDMODE_ADD;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
868 else if (mode==3) mode = SDL_BLENDMODE_MOD;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
869 ret = SDL_SetRenderDrawBlendMode( mode );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
870 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
871 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
872
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
873 /* Blitting. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
874 rect.x = i;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
875 rect.y = j;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
876 ret = SDL_RenderCopy( tface, NULL, &rect );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
877 if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
878 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
879 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
880 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
881
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
882 /* Clean up. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
883 SDL_DestroyTexture( tface );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
884
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
885 /* Check to see if matches. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
886 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_*).",
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
887 &img_blendAll ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
888 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
889
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
890 return 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
891 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
892
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
893
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
894 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
895 * @brief Runs all the tests on the surface.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
896 *
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
897 * @return 0 on success.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
898 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
899 int render_runTests (void)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
900 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
901 int ret;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
902
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
903 /* No error. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
904 ret = 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
905
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
906 /* Test functionality first. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
907 if (render_hasDrawColor())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
908 SDL_ATprintVerbose( 1, " Draw Color supported\n" );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
909 if (render_hasBlendModes())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
910 SDL_ATprintVerbose( 1, " Blend Modes supported\n" );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
911 if (render_hasTexColor())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
912 SDL_ATprintVerbose( 1, " Texture Color Mod supported\n" );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
913 if (render_hasTexAlpha())
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
914 SDL_ATprintVerbose( 1, " Texture Alpha Mod supported\n" );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
915
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
916 /* Software surface blitting. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
917 ret = render_testPrimitives();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
918 if (ret)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
919 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
920 ret = render_testPrimitivesBlend();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
921 if (ret)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
922 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
923 ret = render_testBlit();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
924 if (ret)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
925 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
926 ret = render_testBlitColour();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
927 if (ret)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
928 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
929 ret = render_testBlitAlpha();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
930 if (ret)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
931 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
932 ret = render_testBlitBlend();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
933
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
934
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
935 return ret;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
936 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
937
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
938
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
939 /**
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
940 * @brief Entry point.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
941 *
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
942 * This testsuite is tricky, we're creating a testsuite per driver, the thing
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
943 * is we do quite a of stuff outside of the actual testcase which *could*
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
944 * give issues. Don't like that very much, but no way around without creating
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
945 * superfluous testsuites.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
946 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
947 #ifdef TEST_STANDALONE
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
948 int main( int argc, const char *argv[] )
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
949 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
950 (void) argc;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
951 (void) argv;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
952 #else /* TEST_STANDALONE */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
953 int test_render (void)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
954 {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
955 #endif /* TEST_STANDALONE */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
956 int failed;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
957 int i, j, nd, nr;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
958 int ret;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
959 const char *driver, *str;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
960 char msg[256];
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
961 SDL_WindowID wid;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
962 SDL_RendererInfo renderer;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
963
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
964 /* Initializes the SDL subsystems. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
965 ret = SDL_Init(0);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
966 if (ret != 0)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
967 return -1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
968
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
969 /* Get number of drivers. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
970 nd = SDL_GetNumVideoDrivers();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
971 if (nd < 0)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
972 goto err;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
973 SDL_ATprintVerbose( 1, "%d Video Drivers found\n", nd );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
974
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
975 /* Now run on the video mode. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
976 ret = SDL_InitSubSystem( SDL_INIT_VIDEO );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
977 if (ret != 0)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
978 goto err;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
979
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
980 /*
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
981 * Surface on video mode tests.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
982 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
983 /* Run for all video modes. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
984 failed = 0;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
985 for (i=0; i<nd; i++) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
986 /* Get video mode. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
987 driver = SDL_GetVideoDriver(i);
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
988 if (driver == NULL)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
989 goto err;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
990 SDL_ATprintVerbose( 1, " %d) %s\n", i+1, driver );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
991 /* Hack to avoid dummy driver. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
992 if (strcmp(driver,"dummy")==0)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
993 continue;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
994
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
995 /*
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
996 * Initialize testsuite.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
997 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
998 snprintf( msg, sizeof(msg) , "Rendering with %s driver", driver );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
999 SDL_ATinit( msg );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1000
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1001 /*
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1002 * Initialize.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1003 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1004 SDL_ATbegin( "Initializing video mode" );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1005 /* Initialize video mode. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1006 ret = SDL_VideoInit( driver, 0 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1007 if (SDL_ATvassert( ret==0, "SDL_VideoInit( %s, 0 )", driver ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1008 goto err;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1009 /* Check to see if it's the one we want. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1010 str = SDL_GetCurrentVideoDriver();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1011 if (SDL_ATassert( "SDL_GetCurrentVideoDriver", strcmp(driver,str)==0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1012 goto err;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1013 /* Create window. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1014 wid = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1015 80, 60, 0 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1016 if (SDL_ATassert( "SDL_CreateWindow", wid!=0 ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1017 goto err;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1018 /* Check title. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1019 str = SDL_GetWindowTitle( wid );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1020 if (SDL_ATassert( "SDL_GetWindowTitle", strcmp(msg,str)==0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1021 goto err;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1022 /* Get renderers. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1023 nr = SDL_GetNumRenderDrivers();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1024 if (SDL_ATassert("SDL_GetNumRenderDrivers", nr>=0))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1025 goto err;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1026 SDL_ATprintVerbose( 1, " %d Render Drivers\n", nr );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1027 SDL_ATend();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1028 for (j=0; j<nr; j++) {
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1029
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1030 /* Get renderer info. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1031 ret = SDL_GetRenderDriverInfo( j, &renderer );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1032 if (ret != 0)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1033 goto err;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1034 /* Set testcase name. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1035 snprintf( msg, sizeof(msg), "Renderer %s", renderer.name );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1036 SDL_ATprintVerbose( 1, " %d) %s\n", j+1, renderer.name );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1037 SDL_ATbegin( msg );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1038 /* Set renderer. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1039 ret = SDL_CreateRenderer( wid, j, 0 );
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1040 if (SDL_ATassert( "SDL_CreateRenderer", ret==0 ))
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1041 goto err;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1042
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1043 /*
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1044 * Run tests.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1045 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1046 ret = render_runTests();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1047 if (ret)
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1048 continue;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1049
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1050 SDL_ATend();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1051 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1052
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1053 /* Exit the current renderer. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1054 SDL_VideoQuit();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1055
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1056 /*
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1057 * Finish testsuite.
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1058 */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1059 failed += SDL_ATfinish();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1060 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1061
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1062
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1063 /* Exit SDL. */
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1064 SDL_Quit();
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1065
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1066 return failed;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1067
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1068 err:
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1069 return 1;
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1070 }
22ac66da0765 Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1071