| 43 | } |
| 44 | |
| 45 | int main(void) |
| 46 | { |
| 47 | /* |
| 48 | * First Forge call should be a window creation call |
| 49 | * so that necessary OpenGL context is created for any |
| 50 | * other forge::* object to be created successfully |
| 51 | */ |
| 52 | forge::Window wnd(DIMX, DIMY, "Vector Field Demo"); |
| 53 | wnd.makeCurrent(); |
| 54 | |
| 55 | forge::Chart chart(FG_CHART_2D); |
| 56 | chart.setAxesLimits(MINIMUM-1.0f, MAXIMUM, MINIMUM-1.0f, MAXIMUM); |
| 57 | chart.setAxesTitles("x-axis", "y-axis"); |
| 58 | |
| 59 | forge::Plot divPoints = chart.plot(4, forge::u32, FG_PLOT_SCATTER, FG_MARKER_CIRCLE); |
| 60 | divPoints.setColor(0.9f, 0.9f, 0.0f, 1.f); |
| 61 | divPoints.setLegend("Convergence Points"); |
| 62 | divPoints.setMarkerSize(24); |
| 63 | |
| 64 | forge::VectorField field = chart.vectorField((unsigned)(NELEMS*NELEMS), forge::f32); |
| 65 | field.setColor(0.f, 0.6f, 0.3f, 1.f); |
| 66 | |
| 67 | std::vector<float> points; |
| 68 | std::vector<float> dirs; |
| 69 | generatePoints(points, dirs); |
| 70 | |
| 71 | GfxHandle* handles[3]; |
| 72 | |
| 73 | createGLBuffer(&handles[0], divPoints.vertices(), FORGE_VERTEX_BUFFER); |
| 74 | createGLBuffer(&handles[1], field.vertices(), FORGE_VERTEX_BUFFER); |
| 75 | createGLBuffer(&handles[2], field.directions(), FORGE_VERTEX_BUFFER); |
| 76 | |
| 77 | copyToGLBuffer(handles[0], (ComputeResourceHandle)DPOINTS, divPoints.verticesSize()); |
| 78 | copyToGLBuffer(handles[1], (ComputeResourceHandle)points.data(), field.verticesSize()); |
| 79 | copyToGLBuffer(handles[2], (ComputeResourceHandle)dirs.data(), field.directionsSize()); |
| 80 | |
| 81 | do { |
| 82 | wnd.draw(chart); |
| 83 | } while(!wnd.close()); |
| 84 | |
| 85 | // destroy GL-cpu interop buffers |
| 86 | releaseGLBuffer(handles[0]); |
| 87 | releaseGLBuffer(handles[1]); |
| 88 | releaseGLBuffer(handles[2]); |
| 89 | |
| 90 | return 0; |
| 91 | } |
nothing calls this directly
no test coverage detected