Added new demo, tweaked some values to produce better lighting

This commit is contained in:
MitchellHansen
2017-03-20 22:22:53 -07:00
parent 0d82cd5a20
commit 5e222a0331
5 changed files with 33 additions and 14 deletions

View File

@@ -35,7 +35,6 @@
#include "Camera.h"
#include "Input.h"
#include "Pub_Sub.h"
#include "NetworkInput.h"
#include "LightController.h"
#include "LightHandle.h"
#include "imgui/imgui-SFML.h"
@@ -105,7 +104,7 @@ int main() {
window.setKeyRepeatEnabled(false);
window.setFramerateLimit(60);
window.setVerticalSyncEnabled(false);
ImGui::SFML::Init(window);
window.resetGLStates();
@@ -142,7 +141,7 @@ int main() {
LightController light_controller(raycaster);
LightPrototype prototype(
sf::Vector3f(100.0f, 100.0f, 30.0f),
sf::Vector3f(100.0f, 100.0f, 75.0f),
sf::Vector3f(-1.0f, -1.0f, -1.5f),
sf::Vector4f(0.2f, 0.9f, 0.0f, 1.0f)
);
@@ -276,6 +275,13 @@ int main() {
handle->set_position(light);
}
light_pos[0] = sin(elapsed_time) * 100.0f + 300.0f;
light_pos[1] = sin(elapsed_time) * 100.0f + 300.0f;
sf::Vector3f light(light_pos[0], light_pos[1], light_pos[2]);
handle->set_position(light);
ImGui::End();

View File

@@ -292,7 +292,7 @@ int Hardware_Caster::acquire_platform_and_device() {
// Check to see if we even have OpenCL on this machine
if (deviceIdCount == 0) {
std::cout << "There appears to be no platforms supporting OpenCL" << std::endl;
std::cout << "There appears to be no devices, or none at least supporting OpenCL" << std::endl;
return OPENCL_NOT_SUPPORTED;
}
@@ -372,6 +372,10 @@ int Hardware_Caster::acquire_platform_and_device() {
// Upon success of a condition, set the current best device values
//if (strcmp(device.version, "OpenCL 1.2 ") == 0 && strcmp(device.version, current_best_device.version) != 0) {
// current_best_device = device;
//}
// If the current device is not a GPU and we are comparing it to a GPU
if (device.type == CL_DEVICE_TYPE_GPU && current_best_device.type != CL_DEVICE_TYPE_GPU) {
current_best_device = device;
@@ -399,7 +403,7 @@ int Hardware_Caster::acquire_platform_and_device() {
}
}
platform_id = current_best_device.platform;
platform_id = current_best_device.platform;
device_id = current_best_device.id;
std::cout << std::endl;
@@ -453,6 +457,8 @@ int Hardware_Caster::create_shared_context() {
#endif
// Create our shared context
context = clCreateContext(
context_properties,
@@ -518,7 +524,8 @@ int Hardware_Caster::compile_kernel(std::string kernel_source, bool is_path, std
// Try and build the program
error = clBuildProgram(program, 1, &device_id, "-cl-finite-math-only -cl-fast-relaxed-math -cl-unsafe-math-optimizations", NULL, NULL);
// "-cl-finite-math-only -cl-fast-relaxed-math -cl-unsafe-math-optimizations"
error = clBuildProgram(program, 1, &device_id, NULL, NULL, NULL);
// Check to see if it errored out
if (vr_assert(error, "clBuildProgram")) {
@@ -901,6 +908,12 @@ bool Hardware_Caster::vr_assert(int error_code, std::string function_name) {
case CL_INVALID_DEVICE_PARTITION_COUNT:
err_msg = "CL_INVALID_DEVICE_PARTITION_COUNT";
break;
case CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR :
err_msg = "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR";
break;
case CL_PLATFORM_NOT_FOUND_KHR :
err_msg = "CL_PLATFORM_NOT_FOUND_KHR";
break;
case RayCaster::SHARING_NOT_SUPPORTED:
err_msg = "SHARING_NOT_SUPPORTED";
break;