| 38 | } |
| 39 | |
| 40 | int main(void) |
| 41 | { |
| 42 | std::vector<float> cosData; |
| 43 | std::vector<float> tanData; |
| 44 | |
| 45 | map_range_to_vec_vbo(FRANGE_START, FRANGE_END, 0.1f, cosData, &cosf); |
| 46 | map_range_to_vec_vbo(FRANGE_START, FRANGE_END, 0.1f, tanData, &tanf); |
| 47 | |
| 48 | std::random_device r; |
| 49 | |
| 50 | std::default_random_engine e1(r()); |
| 51 | std::mt19937_64 gen(r()); |
| 52 | |
| 53 | std::uniform_int_distribution<int> uDist(20, 80); |
| 54 | std::uniform_real_distribution<float> cDist(0.2f, 0.6f); |
| 55 | std::uniform_real_distribution<float> fDist(0.4f, 0.6f); |
| 56 | |
| 57 | auto clr = std::bind(cDist, gen); |
| 58 | auto rnd = std::bind(uDist, e1); |
| 59 | auto alp = std::bind(fDist, gen); |
| 60 | |
| 61 | std::vector<float> colors(3*tanData.size()); |
| 62 | std::vector<float> alphas(tanData.size()); |
| 63 | std::vector<float> radii(tanData.size()); |
| 64 | |
| 65 | std::generate(colors.begin(), colors.end(), clr); |
| 66 | std::generate(radii.begin(), radii.end(), rnd); |
| 67 | std::generate(alphas.begin(), alphas.end(), alp); |
| 68 | |
| 69 | /* |
| 70 | * First Forge call should be a window creation call |
| 71 | * so that necessary OpenGL context is created for any |
| 72 | * other forge::* object to be created successfully |
| 73 | */ |
| 74 | forge::Window wnd(DIMX, DIMY, "Bubble chart with Transparency Demo"); |
| 75 | wnd.makeCurrent(); |
| 76 | |
| 77 | forge::Chart chart(FG_CHART_2D); |
| 78 | chart.setAxesLimits(FRANGE_START, FRANGE_END, -1.0f, 1.0f); |
| 79 | |
| 80 | /* Create several plot objects which creates the necessary |
| 81 | * vertex buffer objects to hold the different plot types |
| 82 | */ |
| 83 | forge::Plot plt1 = chart.plot((unsigned)(cosData.size()/2), forge::f32, |
| 84 | FG_PLOT_LINE, FG_MARKER_TRIANGLE); //or specify a specific plot type |
| 85 | forge::Plot plt2 = chart.plot((unsigned)(tanData.size()/2), forge::f32, |
| 86 | FG_PLOT_LINE, FG_MARKER_CIRCLE); //last parameter specifies marker shape |
| 87 | |
| 88 | /* Set plot colors */ |
| 89 | plt1.setColor(FG_RED); |
| 90 | plt2.setColor(FG_GREEN); //use a forge predefined color |
| 91 | /* Set plot legends */ |
| 92 | plt1.setLegend("Cosine"); |
| 93 | plt2.setLegend("Tangent"); |
| 94 | /* set plot global marker size */ |
| 95 | plt1.setMarkerSize(20); |
| 96 | /* copy your data into the opengl buffer object exposed by |
| 97 | * forge::Plot class and then proceed to rendering. |
nothing calls this directly
no test coverage detected