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