You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.8 KiB
82 lines
1.8 KiB
#pragma once
|
|
|
|
#include "fbo.hpp"
|
|
#include "quaternion.hpp"
|
|
#include <moggle/core/gl.hpp>
|
|
#include <moggle/core/shader.hpp>
|
|
#include <moggle/core/vao.hpp>
|
|
#include <moggle/core/vbo.hpp>
|
|
|
|
#include <cl2.hpp>
|
|
#include <NSGLWrapper.hpp>
|
|
|
|
#include <initializer_list>
|
|
|
|
// Used for the bare points
|
|
using GLPoint = moggle::hvector4<GLfloat>;
|
|
|
|
// Used for rendering a textured quad
|
|
struct Vertex {
|
|
moggle::vector2<GLfloat> pos;
|
|
moggle::vector2<GLfloat> tex;
|
|
};
|
|
|
|
struct Parameters{
|
|
Parameters(cl::Context& cl_context, std::initializer_list<float> x);
|
|
void resize(size_t n);
|
|
size_t size() const;
|
|
|
|
auto begin() { return parameters.begin(); }
|
|
auto end() { return parameters.end(); }
|
|
|
|
auto begin() const { return parameters.begin(); }
|
|
auto end() const { return parameters.end(); }
|
|
|
|
float & operator[](size_t n);
|
|
float operator[](size_t n) const;
|
|
|
|
cl::Buffer const & get_cl() const;
|
|
|
|
private:
|
|
cl::Context& cl_context;
|
|
std::vector<float> parameters;
|
|
cl::Buffer cl_parameter_buffer;
|
|
};
|
|
|
|
struct App {
|
|
size_t W = 128;
|
|
size_t H = 128;
|
|
size_t N = 1 << 19;
|
|
float time = 0;
|
|
float maxf = 10;
|
|
float gamma = 2;
|
|
bool clear = false;
|
|
|
|
using quaternion = boost::math::quaternion<float>;
|
|
quaternion rotation = quaternion(1, 0, 0, 0);
|
|
|
|
App(GLContext & gl_context);
|
|
void draw(std::function<void(void)> bind, std::function<void(void)> flush);
|
|
void resize(size_t w, size_t h);
|
|
|
|
private:
|
|
moggle::vbo<GLPoint> gl_vbo;
|
|
moggle::vao gl_vao;
|
|
moggle::vbo<Vertex> gl_quad_vbo;
|
|
moggle::vao gl_quad_vao;
|
|
moggle::shader_program gl_points_program;
|
|
moggle::shader_program gl_texture_program;
|
|
moggle::fbo gl_fbo;
|
|
|
|
cl::Context cl_context;
|
|
cl::Device cl_device;
|
|
cl::CommandQueue cl_queue;
|
|
cl::BufferGL cl_buffer;
|
|
cl::Program cl_program;
|
|
KernelOp k_update;
|
|
|
|
cl::Program create_cl_program(std::string file);
|
|
|
|
public:
|
|
Parameters parameters;
|
|
};
|
|
|