| 17 | static const int N = 2 * M; |
| 18 | |
| 19 | int main(int, char**) { |
| 20 | try { |
| 21 | // Initialize the kernel array just once |
| 22 | af::info(); |
| 23 | af::Window myWindow(800, 800, "3D Surface example: ArrayFire"); |
| 24 | |
| 25 | // Creates grid of between [-1 1] with precision of 1 / M |
| 26 | const array x = iota(dim4(N, 1), dim4(1, N)) / M - 1; |
| 27 | const array y = iota(dim4(1, N), dim4(N, 1)) / M - 1; |
| 28 | |
| 29 | static float t = 0; |
| 30 | while (!myWindow.close()) { |
| 31 | t += 0.07; |
| 32 | array z = 10 * x * -abs(y) * cos(x * x * (y + t)) + |
| 33 | sin(y * (x + t)) - 1.5; |
| 34 | myWindow.surface(x, y, z); |
| 35 | } |
| 36 | |
| 37 | } catch (af::exception& e) { |
| 38 | fprintf(stderr, "%s\n", e.what()); |
| 39 | throw; |
| 40 | } |
| 41 | return 0; |
| 42 | } |