| 72 | } |
| 73 | |
| 74 | int main(void) |
| 75 | { |
| 76 | try { |
| 77 | |
| 78 | /* |
| 79 | * First Forge call should be a window creation call |
| 80 | * so that necessary OpenGL context is created for any |
| 81 | * other forge::* object to be created successfully |
| 82 | */ |
| 83 | forge::Window wnd(DIMX, DIMY, "Three dimensional line plot demo"); |
| 84 | wnd.makeCurrent(); |
| 85 | |
| 86 | forge::Chart chart(FG_CHART_3D); |
| 87 | |
| 88 | chart.setAxesLabelFormat("%3.1f", "%3.1f", "%.2e"); |
| 89 | |
| 90 | chart.setAxesLimits(-1.1f, 1.1f, -1.1f, 1.1f, 0.f, 10.f); |
| 91 | |
| 92 | chart.setAxesTitles("x-axis", "y-axis", "z-axis"); |
| 93 | |
| 94 | forge::Plot plot3 = chart.plot(ZSIZE, forge::f32); |
| 95 | |
| 96 | /* |
| 97 | * Helper function to create a CLGL interop context. |
| 98 | * This function checks for if the extension is available |
| 99 | * and creates the context on the appropriate device. |
| 100 | * Note: context and queue are defined in cl_helpers.h |
| 101 | */ |
| 102 | context = createCLGLContext(wnd); |
| 103 | Device device = context.getInfo<CL_CONTEXT_DEVICES>()[0]; |
| 104 | queue = CommandQueue(context, device); |
| 105 | |
| 106 | cl::Buffer devOut(context, CL_MEM_READ_WRITE, sizeof(float) * ZSIZE * 3); |
| 107 | static float t=0; |
| 108 | kernel(devOut, queue, t); |
| 109 | |
| 110 | GfxHandle* handle; |
| 111 | createGLBuffer(&handle, plot3.vertices(), FORGE_VERTEX_BUFFER); |
| 112 | /* copy your data into the pixel buffer object exposed by |
| 113 | * forge::Surface class and then proceed to rendering. |
| 114 | * To help the users with copying the data from compute |
| 115 | * memory to display memory, Forge provides copy headers |
| 116 | * along with the library to help with this task |
| 117 | */ |
| 118 | copyToGLBuffer(handle, (ComputeResourceHandle)devOut(), plot3.verticesSize()); |
| 119 | |
| 120 | do { |
| 121 | t+=0.01f; |
| 122 | kernel(devOut, queue, t); |
| 123 | copyToGLBuffer(handle, (ComputeResourceHandle)devOut(), plot3.verticesSize()); |
| 124 | wnd.draw(chart); |
| 125 | } while(!wnd.close()); |
| 126 | |
| 127 | releaseGLBuffer(handle); |
| 128 | |
| 129 | }catch (forge::Error err) { |
| 130 | std::cout << err.what() << "(" << err.err() << ")" << std::endl; |
| 131 | } catch (cl::Error err) { |
nothing calls this directly
no test coverage detected