Mercurial > sdl-ios-xcode
annotate test/automated/render/render.c @ 5156:3e4086b3bcd2
Fixed compiling with the latest API changes
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 02 Feb 2011 14:34:24 -0800 |
parents | e743b9c3f6d6 |
children | e2b3f003e085 |
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" |
3481
c32c53fca10d
Fixed include paths for Visual C++
Sam Lantinga <slouken@libsdl.org>
parents:
3477
diff
changeset
|
11 #include "../SDL_at.h" |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
3481
c32c53fca10d
Fixed include paths for Visual C++
Sam Lantinga <slouken@libsdl.org>
parents:
3477
diff
changeset
|
13 #include "../common/common.h" |
3259
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 */ |
3481
c32c53fca10d
Fixed include paths for Visual C++
Sam Lantinga <slouken@libsdl.org>
parents:
3477
diff
changeset
|
19 #include "../common/images.h" |
3259
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 |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
28 static SDL_Renderer *renderer; |
3259
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 /* |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 * Prototypes. |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 */ |
3477
2c07bb579922
We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.
Sam Lantinga <slouken@libsdl.org>
parents:
3471
diff
changeset
|
33 static int render_compare( const char *msg, const SurfaceImage_t *s, int allowable_error ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 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
|
35 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
|
36 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
|
37 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
|
38 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
|
39 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
|
40 /* Testcases. */ |
3558
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
41 static int render_testReadWrite (void); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 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
|
43 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
|
44 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
|
45 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
|
46 static int render_testBlitAlpha (void); |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
47 static int render_testBlitBlendMode( SDL_Texture * tface, int mode ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 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
|
49 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 |
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 * @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
|
53 * |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 * @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
|
55 * @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
|
56 * @return 0 on success. |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 */ |
3477
2c07bb579922
We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.
Sam Lantinga <slouken@libsdl.org>
parents:
3471
diff
changeset
|
58 static int render_compare( const char *msg, const SurfaceImage_t *s, int allowable_error ) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 int ret; |
3531
61b7f5821576
On Windows the minimum window size may be larger than 80, so explicitly request the expected rectangle.
Sam Lantinga <slouken@libsdl.org>
parents:
3482
diff
changeset
|
61 SDL_Rect rect; |
3467
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
62 Uint8 pix[4*80*60]; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 SDL_Surface *testsur; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 /* Read pixels. */ |
3531
61b7f5821576
On Windows the minimum window size may be larger than 80, so explicitly request the expected rectangle.
Sam Lantinga <slouken@libsdl.org>
parents:
3482
diff
changeset
|
66 /* Explicitly specify the rect in case the window isn't expected size... */ |
61b7f5821576
On Windows the minimum window size may be larger than 80, so explicitly request the expected rectangle.
Sam Lantinga <slouken@libsdl.org>
parents:
3482
diff
changeset
|
67 rect.x = 0; |
61b7f5821576
On Windows the minimum window size may be larger than 80, so explicitly request the expected rectangle.
Sam Lantinga <slouken@libsdl.org>
parents:
3482
diff
changeset
|
68 rect.y = 0; |
61b7f5821576
On Windows the minimum window size may be larger than 80, so explicitly request the expected rectangle.
Sam Lantinga <slouken@libsdl.org>
parents:
3482
diff
changeset
|
69 rect.w = 80; |
61b7f5821576
On Windows the minimum window size may be larger than 80, so explicitly request the expected rectangle.
Sam Lantinga <slouken@libsdl.org>
parents:
3482
diff
changeset
|
70 rect.h = 60; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
71 ret = SDL_RenderReadPixels(renderer, &rect, FORMAT, pix, 80*4 ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 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
|
73 return 1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 /* Create surface. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 testsur = SDL_CreateRGBSurfaceFrom( pix, 80, 60, 32, 80*4, |
3444
50fca98abc24
Fixed endianness of the face image surface
Sam Lantinga <slouken@libsdl.org>
parents:
3442
diff
changeset
|
77 RMASK, GMASK, BMASK, AMASK); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 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
|
79 return 1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 /* Compare surface. */ |
3477
2c07bb579922
We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.
Sam Lantinga <slouken@libsdl.org>
parents:
3471
diff
changeset
|
82 ret = surface_compare( testsur, s, allowable_error ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 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
|
84 return 1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 /* Clean up. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 SDL_FreeSurface( testsur ); |
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 |
3467
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
92 #if 0 |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
93 static int dump_screen( int index ) |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
94 { |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
95 int ret; |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
96 char name[1024]; |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
97 Uint8 pix[4*80*60]; |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
98 SDL_Surface *testsur; |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
99 SDL_RendererInfo info; |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
100 |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
101 /* Read pixels. */ |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
102 ret = SDL_RenderReadPixels(renderer, NULL, FORMAT, pix, 80*4 ); |
3467
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
103 if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) ) |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
104 return 1; |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
105 |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
106 /* Create surface. */ |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
107 testsur = SDL_CreateRGBSurfaceFrom( pix, 80, 60, 32, 80*4, |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
108 RMASK, GMASK, BMASK, AMASK); |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
109 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", testsur!=NULL )) |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
110 return 1; |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
111 |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
112 /* Dump surface. */ |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
113 SDL_GetRendererInfo(renderer,&info); |
3467
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
114 sprintf(name, "%s-%s-%d.bmp", SDL_GetCurrentVideoDriver(), info.name, index); |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
115 SDL_SaveBMP(testsur, name); |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
116 |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
117 /* Clean up. */ |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
118 SDL_FreeSurface( testsur ); |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
119 |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
120 return 0; |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
121 } |
383c2058d973
pixels don't need to be dynamically allocated
Sam Lantinga <slouken@libsdl.org>
parents:
3466
diff
changeset
|
122 #endif |
3259
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 /** |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 * @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
|
126 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 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
|
128 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 return (code == 0); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 } |
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 * @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
|
135 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 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
|
137 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 int ret, fail; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 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
|
140 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 fail = 0; |
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 /* Set colour. */ |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
144 ret = SDL_SetRenderDrawColor(renderer, 100, 100, 100, 100 ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 if (!render_isSupported(ret)) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 fail = 1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
147 ret = SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 if (!render_isSupported(ret)) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 fail = 1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 /* Restore natural. */ |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
151 ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE ); |
3259
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 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 /* 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
|
156 if (fail) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 return 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 /* 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
|
159 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
|
160 return 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 return 1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 /** |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 * @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
|
167 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 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
|
169 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 int fail; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 int ret; |
5008 | 172 SDL_BlendMode mode; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 fail = 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
176 ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 if (!render_isSupported(ret)) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 fail = 1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
179 ret = SDL_GetRenderDrawBlendMode(renderer, &mode ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 if (!render_isSupported(ret)) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 fail = 1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 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
|
183 if (!render_isSupported(ret)) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 fail = 1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
185 ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 if (!render_isSupported(ret)) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 fail = 1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
188 ret = SDL_GetRenderDrawBlendMode(renderer, &mode ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 if (!render_isSupported(ret)) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 fail = 1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 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
|
192 if (!render_isSupported(ret)) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 fail = 1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
194 ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 if (!render_isSupported(ret)) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 fail = 1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
197 ret = SDL_GetRenderDrawBlendMode(renderer, &mode ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 if (!render_isSupported(ret)) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 fail = 1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 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
|
201 if (!render_isSupported(ret)) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 fail = 1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 return !fail; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 /** |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 * @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
|
210 */ |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
211 static SDL_Texture * render_loadTestFace (void) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 SDL_Surface *face; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
214 SDL_Texture *tface; |
3259
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 /* Create face surface. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 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
|
218 img_face.width, img_face.height, 32, img_face.width*4, |
3444
50fca98abc24
Fixed endianness of the face image surface
Sam Lantinga <slouken@libsdl.org>
parents:
3442
diff
changeset
|
219 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) |
50fca98abc24
Fixed endianness of the face image surface
Sam Lantinga <slouken@libsdl.org>
parents:
3442
diff
changeset
|
220 0xff000000, /* Red bit mask. */ |
50fca98abc24
Fixed endianness of the face image surface
Sam Lantinga <slouken@libsdl.org>
parents:
3442
diff
changeset
|
221 0x00ff0000, /* Green bit mask. */ |
50fca98abc24
Fixed endianness of the face image surface
Sam Lantinga <slouken@libsdl.org>
parents:
3442
diff
changeset
|
222 0x0000ff00, /* Blue bit mask. */ |
50fca98abc24
Fixed endianness of the face image surface
Sam Lantinga <slouken@libsdl.org>
parents:
3442
diff
changeset
|
223 0x000000ff /* Alpha bit mask. */ |
50fca98abc24
Fixed endianness of the face image surface
Sam Lantinga <slouken@libsdl.org>
parents:
3442
diff
changeset
|
224 #else |
50fca98abc24
Fixed endianness of the face image surface
Sam Lantinga <slouken@libsdl.org>
parents:
3442
diff
changeset
|
225 0x000000ff, /* Red bit mask. */ |
50fca98abc24
Fixed endianness of the face image surface
Sam Lantinga <slouken@libsdl.org>
parents:
3442
diff
changeset
|
226 0x0000ff00, /* Green bit mask. */ |
50fca98abc24
Fixed endianness of the face image surface
Sam Lantinga <slouken@libsdl.org>
parents:
3442
diff
changeset
|
227 0x00ff0000, /* Blue bit mask. */ |
50fca98abc24
Fixed endianness of the face image surface
Sam Lantinga <slouken@libsdl.org>
parents:
3442
diff
changeset
|
228 0xff000000 /* Alpha bit mask. */ |
50fca98abc24
Fixed endianness of the face image surface
Sam Lantinga <slouken@libsdl.org>
parents:
3442
diff
changeset
|
229 #endif |
50fca98abc24
Fixed endianness of the face image surface
Sam Lantinga <slouken@libsdl.org>
parents:
3442
diff
changeset
|
230 ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 if (face == NULL) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 return 0; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
233 tface = SDL_CreateTextureFromSurface(renderer, 0, face ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 SDL_FreeSurface(face); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 return tface; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 |
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 /** |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 * @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
|
242 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 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
|
244 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 int fail; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 int ret; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
247 SDL_Texture *tface; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 Uint8 r, g, b; |
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 /* Get test face. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 tface = render_loadTestFace(); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 if (tface == 0) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 return 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 /* See if supported. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 fail = 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 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
|
258 if (!render_isSupported(ret)) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 fail = 1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 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
|
261 if (!render_isSupported(ret)) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 fail = 1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 /* Clean up. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 SDL_DestroyTexture( tface ); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 if (fail) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 return 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 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
|
270 return 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 return 1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 |
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 /** |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 * @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
|
277 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 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
|
279 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 int fail; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 int ret; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
282 SDL_Texture *tface; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 Uint8 a; |
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 /* Get test face. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 tface = render_loadTestFace(); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 if (tface == 0) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 return 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 /* See if supported. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 fail = 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 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
|
293 if (!render_isSupported(ret)) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 fail = 1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 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
|
296 if (!render_isSupported(ret)) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 fail = 1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 /* Clean up. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 SDL_DestroyTexture( tface ); |
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 if (fail) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 return 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 else if (a != 100) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 return 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 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 /** |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 * @brief Clears the screen. |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 * |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 * @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
|
314 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 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
|
316 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 int ret; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 /* Set colour. */ |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
320 ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 /* |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 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
|
323 return -1; |
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 /* Clear screen. */ |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
327 ret = SDL_RenderFillRect(renderer, NULL ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 /* |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
329 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 /* Set defaults. */ |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
334 ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 /* |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 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
|
337 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 */ |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
339 ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, SDL_ALPHA_OPAQUE ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 /* |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 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
|
342 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 return 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 /** |
3558
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
350 * @brief Test reading and writing framebuffer |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
351 */ |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
352 static int render_testReadWrite (void) |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
353 { |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
354 int ret; |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
355 SDL_Rect rect; |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
356 |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
357 /* Write pixels. */ |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
358 rect.x = 0; |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
359 rect.y = 0; |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
360 rect.w = 80; |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
361 rect.h = 60; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
362 ret = SDL_RenderWritePixels(renderer, &rect, SDL_PIXELFORMAT_RGB24, img_primitives.pixel_data, img_primitives.width*img_primitives.bytes_per_pixel ); |
3558
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
363 if (SDL_ATassert( "SDL_RenderWritePixels", ret==0) ) |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
364 return 1; |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
365 |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
366 /* See if it's the same. */ |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
367 if (render_compare( "Read/write output not the same.", &img_primitives, ALLOWABLE_ERROR_OPAQUE )) |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
368 return -1; |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
369 |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
370 return 0; |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
371 } |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
372 |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
373 |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
374 /** |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 * @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
|
376 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 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
|
378 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 int ret; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 int x, y; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 SDL_Rect rect; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 /* Clear surface. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 if (render_clearScreen()) |
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 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 /* 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
|
388 if (!render_hasDrawColor()) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 return 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 /* Draw a rectangle. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 rect.x = 40; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 rect.y = 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 rect.w = 40; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 rect.h = 80; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
396 ret = SDL_SetRenderDrawColor(renderer, 13, 73, 200, SDL_ALPHA_OPAQUE ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 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
|
398 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
399 ret = SDL_RenderFillRect(renderer, &rect ); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
400 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
401 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 /* Draw a rectangle. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 rect.x = 10; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 rect.y = 10; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 rect.w = 60; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 rect.h = 40; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
408 ret = SDL_SetRenderDrawColor(renderer, 200, 0, 100, SDL_ALPHA_OPAQUE ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 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
|
410 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
411 ret = SDL_RenderFillRect(renderer, &rect ); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
412 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 return -1; |
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 /* 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
|
416 * X.X.X.X.. |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 * .X.X.X.X. |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 * X.X.X.X.. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 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
|
420 x = y % 2; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 for (; x<80; x+=2) { |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
422 ret = SDL_SetRenderDrawColor(renderer, x*y, x*y/2, x*y/3, SDL_ALPHA_OPAQUE ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 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
|
424 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
425 ret = SDL_RenderDrawPoint(renderer, x, y ); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
426 if (SDL_ATassert( "SDL_RenderDrawPoint", ret == 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 /* Draw some lines. */ |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
432 ret = SDL_SetRenderDrawColor(renderer, 0, 255, 0, SDL_ALPHA_OPAQUE ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 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
|
434 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
435 ret = SDL_RenderDrawLine(renderer, 0, 30, 80, 30 ); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
436 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
437 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
438 ret = SDL_SetRenderDrawColor(renderer, 55, 55, 5, SDL_ALPHA_OPAQUE ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
439 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
|
440 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
441 ret = SDL_RenderDrawLine(renderer, 40, 30, 40, 60 ); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
442 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
444 ret = SDL_SetRenderDrawColor(renderer, 5, 105, 105, SDL_ALPHA_OPAQUE ); |
3259
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_SetRenderDrawColor", 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; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
447 ret = SDL_RenderDrawLine(renderer, 0, 0, 29, 29 ); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
448 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) |
3471
da53c4046c65
Use 45 degree lines for the diagonal test to avoid aliasing errors in line drawing.
Sam Lantinga <slouken@libsdl.org>
parents:
3467
diff
changeset
|
449 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
450 ret = SDL_RenderDrawLine(renderer, 29, 30, 0, 59 ); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
451 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) |
3471
da53c4046c65
Use 45 degree lines for the diagonal test to avoid aliasing errors in line drawing.
Sam Lantinga <slouken@libsdl.org>
parents:
3467
diff
changeset
|
452 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
453 ret = SDL_RenderDrawLine(renderer, 79, 0, 50, 29 ); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
454 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) |
3471
da53c4046c65
Use 45 degree lines for the diagonal test to avoid aliasing errors in line drawing.
Sam Lantinga <slouken@libsdl.org>
parents:
3467
diff
changeset
|
455 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
456 ret = SDL_RenderDrawLine(renderer, 79, 59, 50, 30 ); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
457 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
460 /* See if it's the same. */ |
3477
2c07bb579922
We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.
Sam Lantinga <slouken@libsdl.org>
parents:
3471
diff
changeset
|
461 if (render_compare( "Primitives output not the same.", &img_primitives, ALLOWABLE_ERROR_OPAQUE )) |
3259
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 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 return 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 /** |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
469 * @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
|
470 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
471 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
|
472 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
473 int ret; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 int i, j; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
475 SDL_Rect rect; |
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 /* Clear surface. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 if (render_clearScreen()) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
480 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 /* 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
|
482 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
|
483 return 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 /* Create some rectangles for each blend mode. */ |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
486 ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, 0 ); |
3259
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_SetRenderDrawColor", 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; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
489 ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 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
|
491 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
492 ret = SDL_RenderFillRect(renderer, NULL ); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
493 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
494 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
495 rect.x = 10; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
496 rect.y = 25; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
497 rect.w = 40; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
498 rect.h = 25; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
499 ret = SDL_SetRenderDrawColor(renderer, 240, 10, 10, 75 ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
500 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
|
501 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
502 ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
503 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
|
504 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
505 ret = SDL_RenderFillRect(renderer, &rect ); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
506 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
507 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 rect.x = 30; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
509 rect.y = 40; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
510 rect.w = 45; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
511 rect.h = 15; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
512 ret = SDL_SetRenderDrawColor(renderer, 10, 240, 10, 100 ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
513 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
|
514 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
515 ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 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
|
517 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
518 ret = SDL_RenderFillRect(renderer, &rect ); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
519 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
520 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
521 rect.x = 25; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
522 rect.y = 25; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
523 rect.w = 25; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
524 rect.h = 25; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
525 ret = SDL_SetRenderDrawColor(renderer, 10, 10, 240, 125 ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 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
|
527 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
528 ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
529 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
|
530 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
531 ret = SDL_RenderFillRect(renderer, &rect ); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
532 if (SDL_ATassert( "SDL_RenderFillRect", ret == 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
533 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
534 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
535 /* 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
|
536 for (i=0; i<SCREEN_W; i+=2) { |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
537 ret = SDL_SetRenderDrawColor(renderer, 60+2*i, 240-2*i, 50, 3*i ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
538 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
|
539 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
540 ret = SDL_SetRenderDrawBlendMode(renderer,(((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : |
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
541 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
542 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
|
543 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
544 ret = SDL_RenderDrawLine(renderer, 0, 0, i, 59 ); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
545 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
546 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
547 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
548 for (i=0; i<SCREEN_H; i+=2) { |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
549 ret = SDL_SetRenderDrawColor(renderer, 60+2*i, 240-2*i, 50, 3*i ); |
3259
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_SetRenderDrawColor", ret == 0)) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
551 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
552 ret = SDL_SetRenderDrawBlendMode(renderer,(((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : |
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
553 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
554 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
|
555 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
556 ret = SDL_RenderDrawLine(renderer, 0, 0, 79, i ); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
557 if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
558 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
559 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
560 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
561 /* Draw points. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
562 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
|
563 for (i=0; i<SCREEN_W; i+=3) { |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
564 ret = SDL_SetRenderDrawColor(renderer, j*4, i*3, j*4, i*3 ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
565 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
|
566 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
567 ret = SDL_SetRenderDrawBlendMode(renderer, ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND : |
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
568 ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
569 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
|
570 return -1; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
571 ret = SDL_RenderDrawPoint(renderer, i, j ); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3558
diff
changeset
|
572 if (SDL_ATassert( "SDL_RenderDrawPoint", ret == 0)) |
3259
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 /* See if it's the same. */ |
3477
2c07bb579922
We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.
Sam Lantinga <slouken@libsdl.org>
parents:
3471
diff
changeset
|
578 if (render_compare( "Blended primitives output not the same.", &img_blend, ALLOWABLE_ERROR_BLENDED )) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
579 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
580 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
581 return 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
582 } |
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 |
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 * @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
|
587 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
588 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
|
589 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
590 int ret; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
591 SDL_Rect rect; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
592 SDL_Texture *tface; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
593 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
|
594 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
595 /* Clear surface. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
596 if (render_clearScreen()) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
597 return -1; |
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 /* 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
|
600 if (!render_hasDrawColor()) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
601 return 0; |
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 /* Create face surface. */ |
3445
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
604 tface = render_loadTestFace(); |
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
605 if (SDL_ATassert( "render_loadTestFace()", tface != 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
606 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
607 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
608 /* Constant values. */ |
3445
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
609 rect.w = img_face.width; |
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
610 rect.h = img_face.height; |
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
611 ni = SCREEN_W - img_face.width; |
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
612 nj = SCREEN_H - img_face.height; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
613 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
614 /* Loop blit. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
615 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
|
616 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
|
617 /* Blitting. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
618 rect.x = i; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
619 rect.y = j; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
620 ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
621 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
|
622 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
623 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
624 } |
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 /* Clean up. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
627 SDL_DestroyTexture( tface ); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
628 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
629 /* See if it's the same. */ |
3477
2c07bb579922
We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.
Sam Lantinga <slouken@libsdl.org>
parents:
3471
diff
changeset
|
630 if (render_compare( "Blit output not the same.", &img_blit, ALLOWABLE_ERROR_OPAQUE )) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
631 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
632 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
633 return 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
634 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
635 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
636 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
637 /** |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
638 * @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
|
639 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
640 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
|
641 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
642 int ret; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
643 SDL_Rect rect; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
644 SDL_Texture *tface; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
645 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
|
646 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
647 /* Clear surface. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
648 if (render_clearScreen()) |
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 /* 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
|
652 if (!render_hasTexColor()) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
653 return 0; |
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 /* Create face surface. */ |
3445
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
656 tface = render_loadTestFace(); |
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
657 if (SDL_ATassert( "render_loadTestFace()", tface != 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
658 return -1; |
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 /* Constant values. */ |
3445
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
661 rect.w = img_face.width; |
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
662 rect.h = img_face.height; |
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
663 ni = SCREEN_W - img_face.width; |
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
664 nj = SCREEN_H - img_face.height; |
3259
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 /* 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
|
667 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
|
668 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
|
669 /* Set colour mod. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
670 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
|
671 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
|
672 return -1; |
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 /* Blitting. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
675 rect.x = i; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
676 rect.y = j; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
677 ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); |
3259
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_RenderCopy", ret == 0)) |
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 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
681 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
682 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
683 /* Clean up. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
684 SDL_DestroyTexture( tface ); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
685 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
686 /* 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
|
687 if (render_compare( "Blit output not the same (using SDL_SetTextureColorMod).", |
3477
2c07bb579922
We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.
Sam Lantinga <slouken@libsdl.org>
parents:
3471
diff
changeset
|
688 &img_blitColour, ALLOWABLE_ERROR_OPAQUE )) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
689 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
690 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
691 return 0; |
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 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
694 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
695 /** |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
696 * @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
|
697 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
698 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
|
699 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
700 int ret; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
701 SDL_Rect rect; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
702 SDL_Texture *tface; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
703 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
|
704 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
705 /* Clear surface. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
706 if (render_clearScreen()) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
707 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
708 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
709 /* 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
|
710 if (!render_hasTexAlpha()) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
711 return 0; |
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 /* Create face surface. */ |
3445
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
714 tface = render_loadTestFace(); |
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
715 if (SDL_ATassert( "render_loadTestFace()", tface != 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
716 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
717 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
718 /* Constant values. */ |
3445
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
719 rect.w = img_face.width; |
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
720 rect.h = img_face.height; |
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
721 ni = SCREEN_W - img_face.width; |
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
722 nj = SCREEN_H - img_face.height; |
3259
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 /* Clear surface. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
725 if (render_clearScreen()) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
726 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
727 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
728 /* 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
|
729 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
|
730 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
|
731 /* Set alpha mod. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
732 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
|
733 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
|
734 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
735 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
736 /* Blitting. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
737 rect.x = i; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
738 rect.y = j; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
739 ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
740 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
|
741 return -1; |
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 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
744 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
745 /* Clean up. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
746 SDL_DestroyTexture( tface ); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
747 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
748 /* 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
|
749 if (render_compare( "Blit output not the same (using SDL_SetSurfaceAlphaMod).", |
3477
2c07bb579922
We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.
Sam Lantinga <slouken@libsdl.org>
parents:
3471
diff
changeset
|
750 &img_blitAlpha, ALLOWABLE_ERROR_BLENDED )) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
751 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
752 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
753 return 0; |
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 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
756 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
757 /** |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
758 * @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
|
759 */ |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
760 static int render_testBlitBlendMode( SDL_Texture * tface, int mode ) |
3259
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 int ret; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
763 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
|
764 SDL_Rect rect; |
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 /* Clear surface. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
767 if (render_clearScreen()) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
768 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
769 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
770 /* Steps to take. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
771 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
|
772 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
|
773 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
774 /* Constant values. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
775 rect.w = FACE_W; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
776 rect.h = FACE_H; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
777 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
778 /* Test blend mode. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
779 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
|
780 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
|
781 /* Set blend mode. */ |
3453
bb35055cb101
Fixed a bunch of bugs in the blit blend mode tests
Sam Lantinga <slouken@libsdl.org>
parents:
3449
diff
changeset
|
782 ret = SDL_SetTextureBlendMode( tface, mode ); |
bb35055cb101
Fixed a bunch of bugs in the blit blend mode tests
Sam Lantinga <slouken@libsdl.org>
parents:
3449
diff
changeset
|
783 if (SDL_ATassert( "SDL_SetTextureBlendMode", ret == 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
784 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
785 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
786 /* Blitting. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
787 rect.x = i; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
788 rect.y = j; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
789 ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
790 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
|
791 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
792 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
793 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
794 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
795 return 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
796 } |
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 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
799 /** |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
800 * @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
|
801 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
802 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
|
803 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
804 int ret; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
805 SDL_Rect rect; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
806 SDL_Texture *tface; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
807 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
|
808 int mode; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
809 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
810 /* Clear surface. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
811 if (render_clearScreen()) |
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 /* 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
|
815 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
|
816 return 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
817 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
818 /* Create face surface. */ |
3445
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
819 tface = render_loadTestFace(); |
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
820 if (SDL_ATassert( "render_loadTestFace()", tface != 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
821 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
822 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
823 /* Steps to take. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
824 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
|
825 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
|
826 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
827 /* Constant values. */ |
3445
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
828 rect.w = img_face.width; |
de72b49bb695
Refactored to use render_loadTestFace()
Sam Lantinga <slouken@libsdl.org>
parents:
3444
diff
changeset
|
829 rect.h = img_face.height; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
830 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
831 /* Set alpha mod. */ |
3453
bb35055cb101
Fixed a bunch of bugs in the blit blend mode tests
Sam Lantinga <slouken@libsdl.org>
parents:
3449
diff
changeset
|
832 ret = SDL_SetTextureAlphaMod( tface, 100 ); |
bb35055cb101
Fixed a bunch of bugs in the blit blend mode tests
Sam Lantinga <slouken@libsdl.org>
parents:
3449
diff
changeset
|
833 if (SDL_ATassert( "SDL_SetTextureAlphaMod", ret == 0)) |
3259
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 None. */ |
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_NONE )) |
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 /* 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
|
840 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_NONE).", |
3477
2c07bb579922
We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.
Sam Lantinga <slouken@libsdl.org>
parents:
3471
diff
changeset
|
841 &img_blendNone, ALLOWABLE_ERROR_OPAQUE )) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
842 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
843 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
844 /* Test Blend. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
845 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
|
846 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
847 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_BLEND).", |
3477
2c07bb579922
We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.
Sam Lantinga <slouken@libsdl.org>
parents:
3471
diff
changeset
|
848 &img_blendBlend, ALLOWABLE_ERROR_BLENDED )) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
849 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
850 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
851 /* Test Add. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
852 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
|
853 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
854 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_ADD).", |
3477
2c07bb579922
We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.
Sam Lantinga <slouken@libsdl.org>
parents:
3471
diff
changeset
|
855 &img_blendAdd, ALLOWABLE_ERROR_BLENDED )) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
856 return -1; |
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 /* Clear surface. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
859 if (render_clearScreen()) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
860 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
861 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
862 /* Loop blit. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
863 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
|
864 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
|
865 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
866 /* Set colour mod. */ |
3453
bb35055cb101
Fixed a bunch of bugs in the blit blend mode tests
Sam Lantinga <slouken@libsdl.org>
parents:
3449
diff
changeset
|
867 ret = SDL_SetTextureColorMod( tface, (255/nj)*j, (255/ni)*i, (255/nj)*j ); |
bb35055cb101
Fixed a bunch of bugs in the blit blend mode tests
Sam Lantinga <slouken@libsdl.org>
parents:
3449
diff
changeset
|
868 if (SDL_ATassert( "SDL_SetTextureColorMod", ret == 0)) |
bb35055cb101
Fixed a bunch of bugs in the blit blend mode tests
Sam Lantinga <slouken@libsdl.org>
parents:
3449
diff
changeset
|
869 return -1; |
bb35055cb101
Fixed a bunch of bugs in the blit blend mode tests
Sam Lantinga <slouken@libsdl.org>
parents:
3449
diff
changeset
|
870 |
bb35055cb101
Fixed a bunch of bugs in the blit blend mode tests
Sam Lantinga <slouken@libsdl.org>
parents:
3449
diff
changeset
|
871 /* Set alpha mod. */ |
bb35055cb101
Fixed a bunch of bugs in the blit blend mode tests
Sam Lantinga <slouken@libsdl.org>
parents:
3449
diff
changeset
|
872 ret = SDL_SetTextureAlphaMod( tface, (100/ni)*i ); |
bb35055cb101
Fixed a bunch of bugs in the blit blend mode tests
Sam Lantinga <slouken@libsdl.org>
parents:
3449
diff
changeset
|
873 if (SDL_ATassert( "SDL_SetTextureAlphaMod", ret == 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
874 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
875 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
876 /* Crazy blending mode magic. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
877 mode = (i/4*j/4) % 4; |
5143
e743b9c3f6d6
Making the API simpler, the blend modes are "none, blend, add" and are supported by all renderers.
Sam Lantinga <slouken@libsdl.org>
parents:
5008
diff
changeset
|
878 if (mode==0) mode = SDL_BLENDMODE_NONE; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
879 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
|
880 else if (mode==2) mode = SDL_BLENDMODE_ADD; |
5143
e743b9c3f6d6
Making the API simpler, the blend modes are "none, blend, add" and are supported by all renderers.
Sam Lantinga <slouken@libsdl.org>
parents:
5008
diff
changeset
|
881 else if (mode==3) mode = SDL_BLENDMODE_NONE; |
3453
bb35055cb101
Fixed a bunch of bugs in the blit blend mode tests
Sam Lantinga <slouken@libsdl.org>
parents:
3449
diff
changeset
|
882 ret = SDL_SetTextureBlendMode( tface, mode ); |
bb35055cb101
Fixed a bunch of bugs in the blit blend mode tests
Sam Lantinga <slouken@libsdl.org>
parents:
3449
diff
changeset
|
883 if (SDL_ATassert( "SDL_SetTextureBlendMode", ret == 0)) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
884 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
885 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
886 /* Blitting. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
887 rect.x = i; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
888 rect.y = j; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
889 ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
890 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
|
891 return -1; |
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 /* Clean up. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
896 SDL_DestroyTexture( tface ); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
897 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
898 /* 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
|
899 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_*).", |
3477
2c07bb579922
We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.
Sam Lantinga <slouken@libsdl.org>
parents:
3471
diff
changeset
|
900 &img_blendAll, ALLOWABLE_ERROR_BLENDED )) |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
901 return -1; |
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 return 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
904 } |
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 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
907 /** |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
908 * @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
|
909 * |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
910 * @return 0 on success. |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
911 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
912 int render_runTests (void) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
913 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
914 int ret; |
3464
09136f534198
1. SDL_RenderPresent() call has been added after each test to be sure, that all graphics output is flushed in case if it was asynchronous.
Mike Gorchak <lestat@i.com.ua>
parents:
3453
diff
changeset
|
915 |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
916 /* No error. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
917 ret = 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
918 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
919 /* Test functionality first. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
920 if (render_hasDrawColor()) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
921 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
|
922 if (render_hasBlendModes()) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
923 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
|
924 if (render_hasTexColor()) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
925 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
|
926 if (render_hasTexAlpha()) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
927 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
|
928 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
929 /* Software surface blitting. */ |
3558
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
930 ret = render_testReadWrite(); |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
931 if (ret) |
5f038ec1a1af
Added a test to check the read/write pixels API
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
932 return -1; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
933 ret = render_testPrimitives(); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
934 if (ret) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
935 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
936 ret = render_testPrimitivesBlend(); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
937 if (ret) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
938 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
939 ret = render_testBlit(); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
940 if (ret) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
941 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
942 ret = render_testBlitColour(); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
943 if (ret) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
944 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
945 ret = render_testBlitAlpha(); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
946 if (ret) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
947 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
948 ret = render_testBlitBlend(); |
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 return ret; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
951 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
952 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
953 |
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 * @brief Entry point. |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
956 * |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
957 * 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
|
958 * 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
|
959 * 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
|
960 * superfluous testsuites. |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
961 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
962 #ifdef TEST_STANDALONE |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
963 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
|
964 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
965 (void) argc; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
966 (void) argv; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
967 #else /* TEST_STANDALONE */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
968 int test_render (void) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
969 { |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
970 #endif /* TEST_STANDALONE */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
971 int failed; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
972 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
|
973 int ret; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
974 const char *driver, *str; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
975 char msg[256]; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
976 SDL_Window *w; |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
977 SDL_RendererInfo info; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
978 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
979 /* Initializes the SDL subsystems. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
980 ret = SDL_Init(0); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
981 if (ret != 0) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
982 return -1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
983 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
984 /* Get number of drivers. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
985 nd = SDL_GetNumVideoDrivers(); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
986 if (nd < 0) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
987 goto err; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
988 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
|
989 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
990 /* 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
|
991 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
|
992 if (ret != 0) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
993 goto err; |
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 * 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
|
997 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
998 /* 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
|
999 failed = 0; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1000 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
|
1001 /* Get video mode. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1002 driver = SDL_GetVideoDriver(i); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1003 if (driver == NULL) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1004 goto err; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1005 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
|
1006 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1007 /* |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1008 * Initialize testsuite. |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1009 */ |
3482
78db4f7ae2f3
More fixes to compile under Visual C++
Sam Lantinga <slouken@libsdl.org>
parents:
3481
diff
changeset
|
1010 SDL_snprintf( msg, sizeof(msg) , "Rendering with %s driver", driver ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1011 SDL_ATinit( msg ); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1012 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1013 /* |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1014 * Initialize. |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1015 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1016 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
|
1017 /* Initialize video mode. */ |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
1018 ret = SDL_VideoInit( driver ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1019 if (SDL_ATvassert( ret==0, "SDL_VideoInit( %s, 0 )", driver )) |
3449
7bd010656baf
Fixes for the automated rendering test
Sam Lantinga <slouken@libsdl.org>
parents:
3445
diff
changeset
|
1020 goto err_cleanup; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1021 /* 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
|
1022 str = SDL_GetCurrentVideoDriver(); |
3482
78db4f7ae2f3
More fixes to compile under Visual C++
Sam Lantinga <slouken@libsdl.org>
parents:
3481
diff
changeset
|
1023 if (SDL_ATassert( "SDL_GetCurrentVideoDriver", SDL_strcmp(driver,str)==0)) |
3449
7bd010656baf
Fixes for the automated rendering test
Sam Lantinga <slouken@libsdl.org>
parents:
3445
diff
changeset
|
1024 goto err_cleanup; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1025 /* Create window. */ |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
1026 w = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, |
3471
da53c4046c65
Use 45 degree lines for the diagonal test to avoid aliasing errors in line drawing.
Sam Lantinga <slouken@libsdl.org>
parents:
3467
diff
changeset
|
1027 80, 60, SDL_WINDOW_SHOWN ); |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
1028 if (SDL_ATassert( "SDL_CreateWindow", w!=NULL )) |
3449
7bd010656baf
Fixes for the automated rendering test
Sam Lantinga <slouken@libsdl.org>
parents:
3445
diff
changeset
|
1029 goto err_cleanup; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1030 /* Check title. */ |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
1031 str = SDL_GetWindowTitle( w ); |
3482
78db4f7ae2f3
More fixes to compile under Visual C++
Sam Lantinga <slouken@libsdl.org>
parents:
3481
diff
changeset
|
1032 if (SDL_ATassert( "SDL_GetWindowTitle", SDL_strcmp(msg,str)==0)) |
3449
7bd010656baf
Fixes for the automated rendering test
Sam Lantinga <slouken@libsdl.org>
parents:
3445
diff
changeset
|
1033 goto err_cleanup; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1034 /* Get renderers. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1035 nr = SDL_GetNumRenderDrivers(); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1036 if (SDL_ATassert("SDL_GetNumRenderDrivers", nr>=0)) |
3449
7bd010656baf
Fixes for the automated rendering test
Sam Lantinga <slouken@libsdl.org>
parents:
3445
diff
changeset
|
1037 goto err_cleanup; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1038 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
|
1039 SDL_ATend(); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1040 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
|
1041 |
3464
09136f534198
1. SDL_RenderPresent() call has been added after each test to be sure, that all graphics output is flushed in case if it was asynchronous.
Mike Gorchak <lestat@i.com.ua>
parents:
3453
diff
changeset
|
1042 /* We have to recreate window each time, because opengl and opengles renderers */ |
09136f534198
1. SDL_RenderPresent() call has been added after each test to be sure, that all graphics output is flushed in case if it was asynchronous.
Mike Gorchak <lestat@i.com.ua>
parents:
3453
diff
changeset
|
1043 /* both add SDL_WINDOW_OPENGL flag for window, that was last used */ |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
1044 SDL_DestroyWindow(w); |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
1045 w = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, |
3471
da53c4046c65
Use 45 degree lines for the diagonal test to avoid aliasing errors in line drawing.
Sam Lantinga <slouken@libsdl.org>
parents:
3467
diff
changeset
|
1046 80, 60, SDL_WINDOW_SHOWN ); |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
1047 if (SDL_ATassert( "SDL_CreateWindow", w!=NULL )) |
3464
09136f534198
1. SDL_RenderPresent() call has been added after each test to be sure, that all graphics output is flushed in case if it was asynchronous.
Mike Gorchak <lestat@i.com.ua>
parents:
3453
diff
changeset
|
1048 goto err_cleanup; |
09136f534198
1. SDL_RenderPresent() call has been added after each test to be sure, that all graphics output is flushed in case if it was asynchronous.
Mike Gorchak <lestat@i.com.ua>
parents:
3453
diff
changeset
|
1049 |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1050 /* Get renderer info. */ |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
1051 ret = SDL_GetRenderDriverInfo( j, &info ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1052 if (ret != 0) |
3449
7bd010656baf
Fixes for the automated rendering test
Sam Lantinga <slouken@libsdl.org>
parents:
3445
diff
changeset
|
1053 goto err_cleanup; |
3471
da53c4046c65
Use 45 degree lines for the diagonal test to avoid aliasing errors in line drawing.
Sam Lantinga <slouken@libsdl.org>
parents:
3467
diff
changeset
|
1054 |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1055 /* Set testcase name. */ |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
1056 SDL_snprintf( msg, sizeof(msg), "Renderer %s", info.name ); |
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
1057 SDL_ATprintVerbose( 1, " %d) %s\n", j+1, info.name ); |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1058 SDL_ATbegin( msg ); |
3471
da53c4046c65
Use 45 degree lines for the diagonal test to avoid aliasing errors in line drawing.
Sam Lantinga <slouken@libsdl.org>
parents:
3467
diff
changeset
|
1059 |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1060 /* Set renderer. */ |
5156
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
1061 renderer = SDL_CreateRenderer( w, j, 0 ); |
3e4086b3bcd2
Fixed compiling with the latest API changes
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
1062 if (SDL_ATassert( "SDL_CreateRenderer", renderer!=0 )) |
3449
7bd010656baf
Fixes for the automated rendering test
Sam Lantinga <slouken@libsdl.org>
parents:
3445
diff
changeset
|
1063 goto err_cleanup; |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1064 |
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 * Run tests. |
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 ret = render_runTests(); |
3464
09136f534198
1. SDL_RenderPresent() call has been added after each test to be sure, that all graphics output is flushed in case if it was asynchronous.
Mike Gorchak <lestat@i.com.ua>
parents:
3453
diff
changeset
|
1069 |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1070 if (ret) |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1071 continue; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1072 SDL_ATend(); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1073 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1074 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1075 /* Exit the current renderer. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1076 SDL_VideoQuit(); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1077 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1078 /* |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1079 * Finish testsuite. |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1080 */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1081 failed += SDL_ATfinish(); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1082 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1083 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1084 /* Exit SDL. */ |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1085 SDL_Quit(); |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1086 |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1087 return failed; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1088 |
3449
7bd010656baf
Fixes for the automated rendering test
Sam Lantinga <slouken@libsdl.org>
parents:
3445
diff
changeset
|
1089 err_cleanup: |
7bd010656baf
Fixes for the automated rendering test
Sam Lantinga <slouken@libsdl.org>
parents:
3445
diff
changeset
|
1090 SDL_ATfinish(); |
7bd010656baf
Fixes for the automated rendering test
Sam Lantinga <slouken@libsdl.org>
parents:
3445
diff
changeset
|
1091 |
3259
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1092 err: |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1093 return 1; |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1094 } |
22ac66da0765
Merged Edgar's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1095 |