| 173 | } |
| 174 | |
| 175 | void autoTest(char **argv) |
| 176 | { |
| 177 | CFrameBufferObject *fbo = new CFrameBufferObject(wWidth, wHeight, 4, false, GL_TEXTURE_2D); |
| 178 | g_CheckRender = new CheckFBO(wWidth, wHeight, 4, fbo); |
| 179 | g_CheckRender->setPixelFormat(GL_RGBA); |
| 180 | g_CheckRender->setExecPath(argv[0]); |
| 181 | g_CheckRender->EnableQAReadback(true); |
| 182 | |
| 183 | fbo->bindRenderPath(); |
| 184 | |
| 185 | reshape(wWidth, wHeight); |
| 186 | |
| 187 | for (int count = 0; count < g_iFrameToCompare; count++) { |
| 188 | simulateFluids(); |
| 189 | |
| 190 | // add in a little force so the automated testing is interesting. |
| 191 | if (ref_file) { |
| 192 | int x = wWidth / (count + 1); |
| 193 | int y = wHeight / (count + 1); |
| 194 | float fx = (x / (float)wWidth); |
| 195 | float fy = (y / (float)wHeight); |
| 196 | int nx = (int)(fx * DIM); |
| 197 | int ny = (int)(fy * DIM); |
| 198 | |
| 199 | int ddx = 35; |
| 200 | int ddy = 35; |
| 201 | fx = ddx / (float)wWidth; |
| 202 | fy = ddy / (float)wHeight; |
| 203 | int spy = ny - FR; |
| 204 | int spx = nx - FR; |
| 205 | |
| 206 | addForces(dvfield, DIM, DIM, spx, spy, FORCE * DT * fx, FORCE * DT * fy, FR); |
| 207 | lastx = x; |
| 208 | lasty = y; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | display(); |
| 213 | |
| 214 | fbo->unbindRenderPath(); |
| 215 | |
| 216 | // compare to official reference image, printing PASS or FAIL. |
| 217 | printf("> (Frame %d) Readback BackBuffer\n", 100); |
| 218 | g_CheckRender->readback(wWidth, wHeight); |
| 219 | g_CheckRender->savePPM("fluidsGL.ppm", true, NULL); |
| 220 | |
| 221 | if (!g_CheckRender->PPMvsPPM("fluidsGL.ppm", ref_file, MAX_EPSILON_ERROR, 0.25f)) { |
| 222 | g_TotalErrors++; |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | // very simple von neumann middle-square prng. can't use rand() in -qatest |
| 227 | // mode because its implementation varies across platforms which makes testing |
no test coverage detected