From b05e87dc5004f5badc02508570ddc55f31b451cc Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Sat, 17 Mar 2018 17:51:19 +0100 Subject: Correct line endings. --- BuddhaTest/include/Helpers.h | 168 +++++++++++++++++++++---------------------- 1 file changed, 84 insertions(+), 84 deletions(-) (limited to 'BuddhaTest/include') diff --git a/BuddhaTest/include/Helpers.h b/BuddhaTest/include/Helpers.h index 76f790b..a585b88 100644 --- a/BuddhaTest/include/Helpers.h +++ b/BuddhaTest/include/Helpers.h @@ -1,84 +1,84 @@ -#pragma once -#include -#include -#include -#include //includes FILE typedef -#include - -namespace Helpers -{ - GLuint LoadShaders(const std::string &vertex_file_path, const std::string &fragment_file_path); - GLuint LoadComputeShader(const std::string &compute_file_path, unsigned int localSizeX, unsigned int localSizeY, unsigned int localSizeZ); - - bool DoesFileExist(const std::string& path); - - void WriteOutputPNG(const std::string& path, const std::vector& data, unsigned int width, unsigned int bufferHeight, double gamma, double colorScale); - - /** Wraps around a C file descriptor. Libpng could be taught to use C++ streams, but I'm too lazy and rather wrap this ugly thing up, so it gets cleaned... */ - class ScopedCFileDescriptor - { - public: - ScopedCFileDescriptor(const char *path, const char *mode); - ~ScopedCFileDescriptor(); - FILE * Get() const; - bool IsValid() const; - private: - FILE * Descriptor; - }; - - struct RenderSettings - { - unsigned int imageWidth = 1024; - unsigned int imageHeight = 576; - - unsigned int windowWidth = 1024; - unsigned int windowHeight = 576; - - unsigned int orbitLengthRed = 10; - unsigned int orbitLengthGreen = 100; - unsigned int orbitLengthBlue = 1000; - - unsigned int localWorkgroupSizeX = 1024; - unsigned int localWorkgroupSizeY = 1; - unsigned int localWorkgroupSizeZ = 1; - - unsigned int globalWorkGroupSizeX = 1024; - unsigned int globalWorkGroupSizeY = 1; - unsigned int globalWorkGroupSizeZ = 1; - - unsigned int targetFrameRate = 60; - - std::string pngFilename = ""; - double pngGamma = 1.0; - double pngColorScale = 2.0; - - unsigned int ignoreMaxBufferSize = 0; - - bool CheckValidity(); - bool ParseCommandLine(int argc, char * argv[]); - }; - - template - class PIDController - { - public: - PIDController(ValueType prop, ValueType diff, ValueType integral) : propFactor(prop), diffFactor(diff), intFactor(integral) {} - - ValueType Update(TimeType dT, ValueType Error) - { - errorSum += Error * dT; - const auto differential{(Error - lastError)/dT}; - lastError = Error; - return Error * propFactor + errorSum * intFactor + differential * diffFactor; - } - - protected: - ValueType propFactor{}; - ValueType diffFactor{}; - ValueType intFactor{}; - - private: - ValueType errorSum{}; - ValueType lastError{}; - }; -} +#pragma once +#include +#include +#include +#include //includes FILE typedef +#include + +namespace Helpers +{ + GLuint LoadShaders(const std::string &vertex_file_path, const std::string &fragment_file_path); + GLuint LoadComputeShader(const std::string &compute_file_path, unsigned int localSizeX, unsigned int localSizeY, unsigned int localSizeZ); + + bool DoesFileExist(const std::string& path); + + void WriteOutputPNG(const std::string& path, const std::vector& data, unsigned int width, unsigned int bufferHeight, double gamma, double colorScale); + + /** Wraps around a C file descriptor. Libpng could be taught to use C++ streams, but I'm too lazy and rather wrap this ugly thing up, so it gets cleaned... */ + class ScopedCFileDescriptor + { + public: + ScopedCFileDescriptor(const char *path, const char *mode); + ~ScopedCFileDescriptor(); + FILE * Get() const; + bool IsValid() const; + private: + FILE * Descriptor; + }; + + struct RenderSettings + { + unsigned int imageWidth = 1024; + unsigned int imageHeight = 576; + + unsigned int windowWidth = 1024; + unsigned int windowHeight = 576; + + unsigned int orbitLengthRed = 10; + unsigned int orbitLengthGreen = 100; + unsigned int orbitLengthBlue = 1000; + + unsigned int localWorkgroupSizeX = 1024; + unsigned int localWorkgroupSizeY = 1; + unsigned int localWorkgroupSizeZ = 1; + + unsigned int globalWorkGroupSizeX = 1024; + unsigned int globalWorkGroupSizeY = 1; + unsigned int globalWorkGroupSizeZ = 1; + + unsigned int targetFrameRate = 60; + + std::string pngFilename = ""; + double pngGamma = 1.0; + double pngColorScale = 2.0; + + unsigned int ignoreMaxBufferSize = 0; + + bool CheckValidity(); + bool ParseCommandLine(int argc, char * argv[]); + }; + + template + class PIDController + { + public: + PIDController(ValueType prop, ValueType diff, ValueType integral) : propFactor(prop), diffFactor(diff), intFactor(integral) {} + + ValueType Update(TimeType dT, ValueType Error) + { + errorSum += Error * dT; + const auto differential{(Error - lastError)/dT}; + lastError = Error; + return Error * propFactor + errorSum * intFactor + differential * diffFactor; + } + + protected: + ValueType propFactor{}; + ValueType diffFactor{}; + ValueType intFactor{}; + + private: + ValueType errorSum{}; + ValueType lastError{}; + }; +} -- cgit v1.2.3