Whoops, forgot to save the files, same commit as before
This commit is contained in:
@@ -43,6 +43,8 @@ public:
|
||||
|
||||
int create_command_queue();
|
||||
|
||||
int check_cl_khr_gl_sharing();
|
||||
|
||||
int compile_kernel(std::string kernel_source, bool is_path, std::string kernel_name);
|
||||
|
||||
int create_buffer(std::string buffer_name, cl_uint size, void* data);
|
||||
@@ -60,11 +62,14 @@ public:
|
||||
cl_kernel getKernel(std::string kernel_name);
|
||||
cl_command_queue getCommandQueue();
|
||||
|
||||
bool was_init_valid();
|
||||
|
||||
private:
|
||||
|
||||
int error = 0;
|
||||
bool initialized = false;
|
||||
bool cl_khr_gl_sharing_fallback = false;
|
||||
bool cl_supported = false;
|
||||
|
||||
cl_platform_id platform_id;
|
||||
cl_device_id device_id;
|
||||
|
||||
@@ -2,23 +2,32 @@
|
||||
#include <SFML/System/Vector3.hpp>
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include <Map.h>
|
||||
#include "Old_map.h"
|
||||
|
||||
|
||||
// What about a parent, child relationship between the raycaster and it's two
|
||||
// different modes? Raycaster -> ClCaster, SoftwareCaster
|
||||
class Camera;
|
||||
|
||||
class RayCaster {
|
||||
public:
|
||||
RayCaster(Map *map,
|
||||
sf::Vector3<int> map_dimensions,
|
||||
sf::Vector2<int> viewport_resolution);
|
||||
|
||||
RayCaster();
|
||||
~RayCaster();
|
||||
|
||||
void setFOV(float fov);
|
||||
void setResolution(sf::Vector2<int> resolution);
|
||||
virtual void assign_map(Old_Map *map) = 0;
|
||||
virtual void assign_camera(Camera *camera) = 0;
|
||||
virtual void assign_viewport(int width, int height, float v_fov, float h_fov) = 0;
|
||||
virtual void assign_light(Light light) = 0;
|
||||
|
||||
// draw will abstract the gl sharing and software rendering
|
||||
// methods of retrieving the screen buffer
|
||||
virtual void draw(sf::RenderWindow* window) = 0;
|
||||
|
||||
sf::Color* CastRays(sf::Vector3<float> camera_direction, sf::Vector3<float> camera_position);
|
||||
void moveCamera(sf::Vector2f v);
|
||||
private:
|
||||
|
||||
sf::Vector3<int> map_dimensions;
|
||||
Map *map;
|
||||
Old_Map *map;
|
||||
|
||||
// The XY resolution of the viewport
|
||||
sf::Vector2<int> resolution;
|
||||
|
||||
@@ -1 +1,20 @@
|
||||
#include "Renderer.h"
|
||||
|
||||
Renderer::Renderer() {
|
||||
|
||||
cl = new CL_Wrapper();
|
||||
if (!cl->was_init_valid()) {
|
||||
delete cl;
|
||||
rc = new RayCaster();
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::register_camera(Camera *camera)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Renderer::draw()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "SFML/Graphics.hpp"
|
||||
#include "CL_Wrapper.h"
|
||||
#include "Camera.h"
|
||||
#include "Old_map.h"
|
||||
#include "RayCaster.h"
|
||||
|
||||
// Renderer needs to handle the distinction between a few difference circumstances.
|
||||
// A.) The machine supports OpenCL and cl_khr_gl_sharing
|
||||
@@ -18,6 +20,9 @@
|
||||
// intent of leaving it specialized to only the raycaster. Any further OpenCL
|
||||
// work can use its own class
|
||||
|
||||
// Perhaps in the future there will be a container "scene" which will
|
||||
// hold the current map, camera, and light objects. The renderer will
|
||||
// then be passed that scene which it will then use to render with
|
||||
|
||||
class Renderer {
|
||||
|
||||
@@ -26,9 +31,11 @@ public:
|
||||
|
||||
// The renderer needs all of the things that are required
|
||||
// by CL in order to render the screen
|
||||
void register_camera(Camera camera);
|
||||
|
||||
|
||||
void register_camera(Camera* camera);
|
||||
void register_map(Old_Map* map);
|
||||
void register_lights();
|
||||
void create_viewport(float v_fov, float h_fov, int height, int width);
|
||||
void register_light(light l);
|
||||
|
||||
void draw();
|
||||
sf::RenderWindow* get_window();
|
||||
@@ -36,10 +43,19 @@ public:
|
||||
private:
|
||||
|
||||
CL_Wrapper *cl;
|
||||
RayCaster *rc;
|
||||
|
||||
bool sharing_supported = false;
|
||||
sf::Uint8 *drawing_surface;
|
||||
bool cl_supported = false;
|
||||
|
||||
sf::Uint8 *drawing_surface;
|
||||
sf::RenderWindow* window;
|
||||
|
||||
std::vector<light> lights;
|
||||
Old_Map* map;
|
||||
Camera* camera;
|
||||
sf::Uint8 *view_matrix;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,17 @@
|
||||
#include <math.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include "Vector4.hpp"
|
||||
|
||||
const double PI = 3.141592653589793238463;
|
||||
const float PI_F = 3.14159265358979f;
|
||||
|
||||
struct Light {
|
||||
sf::Vector4f rgbi;
|
||||
sf::Vector3f position;
|
||||
sf::Vector3f direction_cartesian;
|
||||
};
|
||||
|
||||
struct fps_counter {
|
||||
public:
|
||||
fps_counter(){
|
||||
|
||||
Reference in New Issue
Block a user