| 34 | } |
| 35 | |
| 36 | int main(void) |
| 37 | { |
| 38 | std::vector<float> sinData; |
| 39 | std::vector<float> cosData; |
| 40 | std::vector<float> tanData; |
| 41 | std::vector<float> logData; |
| 42 | map_range_to_vec_vbo(FRANGE_START, FRANGE_END, 0.1f, sinData, &sinf); |
| 43 | map_range_to_vec_vbo(FRANGE_START, FRANGE_END, 0.1f, cosData, &cosf); |
| 44 | map_range_to_vec_vbo(FRANGE_START, FRANGE_END, 0.1f, tanData, &tanf); |
| 45 | map_range_to_vec_vbo(FRANGE_START, FRANGE_END, 0.1f, logData, &log10f); |
| 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, "Plotting Demo"); |
| 53 | wnd.makeCurrent(); |
| 54 | |
| 55 | forge::Chart chart(FG_CHART_2D); |
| 56 | chart.setAxesLimits(FRANGE_START, FRANGE_END, -1.0f, 1.0f); |
| 57 | |
| 58 | /* Create several plot objects which creates the necessary |
| 59 | * vertex buffer objects to hold the different plot types |
| 60 | */ |
| 61 | forge::Plot plt0 = chart.plot((unsigned)(sinData.size()/2), forge::f32); //create a default plot |
| 62 | forge::Plot plt1 = chart.plot((unsigned)(cosData.size()/2), forge::f32, FG_PLOT_LINE, FG_MARKER_NONE); //or specify a specific plot type |
| 63 | forge::Plot plt2 = chart.plot((unsigned)(tanData.size()/2), forge::f32, FG_PLOT_LINE, FG_MARKER_TRIANGLE); //last parameter specifies marker shape |
| 64 | forge::Plot plt3 = chart.plot((unsigned)(logData.size()/2), forge::f32, FG_PLOT_SCATTER, FG_MARKER_CROSS); |
| 65 | |
| 66 | /* |
| 67 | * Set plot colors |
| 68 | */ |
| 69 | plt0.setColor(FG_RED); |
| 70 | plt1.setColor(FG_BLUE); |
| 71 | plt2.setColor(FG_YELLOW); //use a forge predefined color |
| 72 | plt3.setColor((forge::Color) 0x257973FF); //or any hex-valued color |
| 73 | /* |
| 74 | * Set plot legends |
| 75 | */ |
| 76 | plt0.setLegend("Sine"); |
| 77 | plt1.setLegend("Cosine"); |
| 78 | plt2.setLegend("Tangent"); |
| 79 | plt3.setLegend("Log base 10"); |
| 80 | |
| 81 | GfxHandle* handles[4]; |
| 82 | createGLBuffer(&handles[0], plt0.vertices(), FORGE_VERTEX_BUFFER); |
| 83 | createGLBuffer(&handles[1], plt1.vertices(), FORGE_VERTEX_BUFFER); |
| 84 | createGLBuffer(&handles[2], plt2.vertices(), FORGE_VERTEX_BUFFER); |
| 85 | createGLBuffer(&handles[3], plt3.vertices(), FORGE_VERTEX_BUFFER); |
| 86 | |
| 87 | /* copy your data into the pixel buffer object exposed by |
| 88 | * forge::Plot class and then proceed to rendering. |
| 89 | * To help the users with copying the data from compute |
| 90 | * memory to display memory, Forge provides copy headers |
| 91 | * along with the library to help with this task |
| 92 | */ |
| 93 | copyToGLBuffer(handles[0], (ComputeResourceHandle)sinData.data(), plt0.verticesSize()); |
nothing calls this directly
no test coverage detected