MCPcopy Create free account
hub / github.com/arrayfire/forge / main

Function main

examples/cpu/stream.cpp:69–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69int main(void)
70{
71 /*
72 * First Forge call should be a window creation call
73 * so that necessary OpenGL context is created for any
74 * other forge::* object to be created successfully
75 */
76 forge::Window wnd(DIMX, DIMY, "3D Vector Field Demo");
77 wnd.makeCurrent();
78
79 forge::Chart chart(FG_CHART_3D);
80 chart.setAxesLimits(MINIMUM-1.0f, MAXIMUM,
81 MINIMUM-1.0f, MAXIMUM,
82 MINIMUM-1.0f, MAXIMUM);
83 chart.setAxesTitles("x-axis", "y-axis", "z-axis");
84
85 int numElems = NELEMS*NELEMS*NELEMS;
86 forge::VectorField field = chart.vectorField(numElems, forge::f32);
87 field.setColor(0.f, 1.f, 0.f, 1.f);
88
89 std::vector<float> points;
90 std::vector<float> colors;
91 std::vector<float> dirs;
92 generatePoints(points, dirs);
93 generateColors(colors);
94
95 GfxHandle* handles[3];
96 createGLBuffer(&handles[0], field.vertices(), FORGE_VERTEX_BUFFER);
97 createGLBuffer(&handles[1], field.colors(), FORGE_VERTEX_BUFFER);
98 createGLBuffer(&handles[2], field.directions(), FORGE_VERTEX_BUFFER);
99
100 copyToGLBuffer(handles[0], (ComputeResourceHandle)points.data(), field.verticesSize());
101 copyToGLBuffer(handles[1], (ComputeResourceHandle)colors.data(), field.colorsSize());
102 copyToGLBuffer(handles[2], (ComputeResourceHandle)dirs.data() , field.directionsSize());
103
104 do {
105 wnd.draw(chart);
106 } while(!wnd.close());
107
108 releaseGLBuffer(handles[0]);
109 releaseGLBuffer(handles[1]);
110 releaseGLBuffer(handles[2]);
111
112 return 0;
113}

Callers

nothing calls this directly

Calls 15

generateColorsFunction · 0.85
createGLBufferFunction · 0.85
copyToGLBufferFunction · 0.85
releaseGLBufferFunction · 0.85
vectorFieldMethod · 0.80
generatePointsFunction · 0.70
makeCurrentMethod · 0.45
setAxesLimitsMethod · 0.45
setAxesTitlesMethod · 0.45
setColorMethod · 0.45
verticesMethod · 0.45
colorsMethod · 0.45

Tested by

no test coverage detected