Added some documentation on the lights. Got most everything tidied up. Having some issues with std::moving unique ptrs. Going to change them to shared_ptr
This commit is contained in:
@@ -20,7 +20,7 @@ std::unique_ptr<LightHandle> LightController::create_light(LightPrototype light_
|
||||
unsigned int index = open_list.front();
|
||||
open_list.pop_front();
|
||||
|
||||
std::unique_ptr<PackedData> data(&packed_data_array.at(index));
|
||||
std::unique_ptr<PackedData> data(&packed_data_array.data()[index]);
|
||||
|
||||
std::unique_ptr<LightHandle> handle(new LightHandle(this, index, light_prototype, std::move(data)));
|
||||
|
||||
|
||||
@@ -3,12 +3,18 @@
|
||||
|
||||
|
||||
LightHandle::LightHandle(LightController *const light_controller, unsigned int light_id, LightPrototype light_prototype, std::unique_ptr<PackedData> data_reference) :
|
||||
light_controller_ref(light_controller), data_reference(std::move(data_reference)) {
|
||||
light_controller_ref(light_controller), light_id(light_id) {
|
||||
|
||||
data_reference = std::move(data_reference);
|
||||
|
||||
friction_coefficient = light_prototype.friction;
|
||||
default_impulse = light_prototype.impulse;
|
||||
movement = light_prototype.movement;
|
||||
|
||||
data_reference->direction_cartesian = light_prototype.direction_cartesian;
|
||||
data_reference->position = light_prototype.position;
|
||||
data_reference->rgbi = light_prototype.rgbi;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
17
src/main.cpp
17
src/main.cpp
@@ -22,6 +22,7 @@
|
||||
#include <OpenCL/cl_ext.h>
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <SFML/Graphics.hpp>
|
||||
@@ -36,6 +37,7 @@
|
||||
#include "Pub_Sub.h"
|
||||
#include "NetworkInput.h"
|
||||
#include "LightController.h"
|
||||
#include "LightHandle.h"
|
||||
|
||||
const int WINDOW_X = 1000;
|
||||
const int WINDOW_Y = 1000;
|
||||
@@ -91,8 +93,8 @@ int main() {
|
||||
|
||||
// Start up the raycaster
|
||||
//Hardware_Caster *raycaster = new Hardware_Caster();
|
||||
Hardware_Caster *raycaster = new Hardware_Caster();
|
||||
//std::shared_ptr<Hardware_Caster> raycaster(new Hardware_Caster());
|
||||
//Hardware_Caster *raycaster = new Hardware_Caster();
|
||||
std::shared_ptr<Hardware_Caster> raycaster(new Hardware_Caster());
|
||||
|
||||
if (raycaster->init() != 1) {
|
||||
abort();
|
||||
@@ -123,10 +125,17 @@ int main() {
|
||||
float w = 60.0;
|
||||
float h = 90.0;
|
||||
|
||||
/*sf::Vector3f(256.0f, 256.0f, 256.0f),
|
||||
|
||||
LightController light_controller(raycaster);
|
||||
LightPrototype prototype(
|
||||
sf::Vector3f(256.0f, 256.0f, 256.0f),
|
||||
sf::Vector3f(-1.0f, -1.0f, -1.5f),
|
||||
sf::Vector4f(1.0f, 1.0f, 1.0f, 1.0f)
|
||||
*/
|
||||
);
|
||||
|
||||
std::unique_ptr<LightHandle> handle = light_controller.create_light(prototype);
|
||||
|
||||
|
||||
|
||||
// Light for the currently non functional Bling Phong shader
|
||||
//std::unique_ptr<RayCaster> asdf(raycaster);
|
||||
|
||||
@@ -213,15 +213,15 @@ void Hardware_Caster::create_viewport(int width, int height, float v_fov, float
|
||||
void Hardware_Caster::assign_lights(std::vector<PackedData> *data) {
|
||||
|
||||
// Get a pointer to the packed light data
|
||||
// this->lights = data;
|
||||
this->lights = data;
|
||||
|
||||
light_count = static_cast<int>(lights->size());
|
||||
|
||||
cl_uint packed_size = 0;// sizeof(PackedData);
|
||||
cl_uint packed_size = sizeof(PackedData);
|
||||
|
||||
create_buffer("lights", packed_size * light_count, lights->data(), CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR);
|
||||
|
||||
create_buffer("light_count", sizeof(int), &light_count);
|
||||
create_buffer("light_count", 8, &light_count);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user