From a10d6e0d0c5882584b8dbaa2783ade62f6af4f04 Mon Sep 17 00:00:00 2001 From: Dario Seyb <dario.seyb@gmail.com> Date: Thu, 23 Nov 2017 16:50:40 +0100 Subject: [PATCH] Fixed compilation under MSVC --- camera/lava-extras/camera/GenericCamera.cc | 14 +++++++------- glfw/lava-extras/glfw/GlfwApp.cc | 12 ++++++------ glfw/lava-extras/glfw/GlfwApp.hh | 2 +- pack/src/lava-extras/pack/pack.cc | 2 +- pipeline/lava-extras/pipeline/RenderingPipeline.cc | 5 ++--- pipeline/lava-extras/pipeline/RenderingPipeline.hh | 4 ++-- pipeline/lava-extras/pipeline/fwd.hh | 2 +- 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/camera/lava-extras/camera/GenericCamera.cc b/camera/lava-extras/camera/GenericCamera.cc index e2fa2ec..fcb7b2a 100644 --- a/camera/lava-extras/camera/GenericCamera.cc +++ b/camera/lava-extras/camera/GenericCamera.cc @@ -134,7 +134,7 @@ void GenericCamera::rotateAroundTaget_helper(float _x, float _y, float _z, glm::vec4 P = glm::vec4(getPosition(), 1.0f); glm::vec4 tempPos = P - T; - glm::mat4 newRotation = glm::rotate(glm::mat4(), _x, _rotationAxes[0]); + glm::mat4 newRotation = glm::rotate(glm::mat4(1.0f), _x, _rotationAxes[0]); newRotation = glm::rotate(newRotation, _y, _rotationAxes[1]); newRotation = glm::rotate(newRotation, _z, _rotationAxes[2]); @@ -240,7 +240,7 @@ glm::mat4 GenericCamera::getStereoViewMatrix(bool _leftEye, // at the look-at distance (focal point) assert(0 && "getStereoViewMatrix() for TOE_IN is not implemented yet!"); - return glm::mat4(); + return glm::mat4(1.0f); } glm::mat4 GenericCamera::getInverseViewMatrix() const { @@ -263,7 +263,7 @@ glm::mat4 GenericCamera::getProjectionMatrix() const { } glm::mat4 GenericCamera::getMonoProjectionMatrix() const { - glm::mat4 projectionMatrix; // identity matrix + glm::mat4 projectionMatrix{}; // identity matrix if (getProjectionMode() == IsometricProjection) { // we don't set the left/right/top/bottom values explicitly, so we want @@ -377,7 +377,7 @@ GenericCamera::getStereoProjectionMatrix(bool _leftEye, // position. assert(0 && "getStereoViewMatrix() is not implemented for OFF_AXIS yet!"); - return glm::mat4(); + return glm::mat4(1.0f); } /// Writes all internal state to one string @@ -502,7 +502,7 @@ void GenericCamera::setLookAtMatrix(const glm::vec3 &_position, } glm::mat4 GenericCamera::getTranslationMatrix4() const { - glm::mat4 trans; + glm::mat4 trans{}; trans[3][0] = -mPosition.x; trans[3][1] = -mPosition.y; trans[3][2] = -mPosition.z; @@ -537,9 +537,9 @@ glm::vec3 GenericCamera::getForwardDirection() const { void GenericCamera::setTarget(const glm::vec3 &_target, const glm::vec3 &_up) { glm::vec3 forwardVector = _target - mPosition; mLookAtDistance = glm::length(forwardVector); - if (mLookAtDistance < .0001) // in case target == mPosition + if (mLookAtDistance < .0001f) // in case target == mPosition { - mLookAtDistance = .0001; + mLookAtDistance = .0001f; forwardVector = glm::vec3(mLookAtDistance, 0, 0); } diff --git a/glfw/lava-extras/glfw/GlfwApp.cc b/glfw/lava-extras/glfw/GlfwApp.cc index d075487..715be9e 100644 --- a/glfw/lava-extras/glfw/GlfwApp.cc +++ b/glfw/lava-extras/glfw/GlfwApp.cc @@ -55,7 +55,7 @@ void GlfwApp::mainLoop() { auto dt = 1.0 / mUpdateRate; auto cpuStart = glfwGetTime(); - update(dt); + update((float)dt); cpuTime += glfwGetTime() - cpuStart; timeAccum -= dt; mCurrentTime += dt; @@ -72,7 +72,7 @@ void GlfwApp::mainLoop() { // mRenderStartQuery->saveTimestamp(); //} - render(renderTimestep); + render((float)renderTimestep); // if (mQueryStats && mPrimitiveQuery) //{ @@ -249,8 +249,8 @@ bool GlfwApp::onMousePosition(double x, double y) { auto dx = x - mMouseLastX; auto dy = y - mMouseLastY; - float ax = dx / mWindowWidth * mCameraTurnSpeed; - float ay = dy / mWindowHeight * mCameraTurnSpeed; + float ax = (float)(dx / mWindowWidth * mCameraTurnSpeed); + float ay = (float)(dy / mWindowHeight * mCameraTurnSpeed); if (mMouseRight && !alt && !ctrl) // from cam { @@ -315,7 +315,7 @@ bool GlfwApp::onMouseButton(double x, double y, int button, int action, glm::vec3 pos; float depth; if (mUseDefaultRendering && mUseDefaultCameraHandling && - mPipeline->queryPosition3D(x, y, &pos, &depth)) { + mPipeline->queryPosition3D((int)x, (int)y, &pos, &depth)) { mCamera->setPosition(pos - mCamera->getForwardDirection() * mCamera->getLookAtDistance()); @@ -333,7 +333,7 @@ bool GlfwApp::onMouseScroll(double sx, double sy) { // camera handling if (mCamera && mUseDefaultCameraHandling && sy != 0) { auto f = glm::pow(1 + mCameraScrollSpeed / 100.0, -sy); - float camDis = mCamera->getLookAtDistance() * f; + float camDis = mCamera->getLookAtDistance() * (float)f; camDis = glm::clamp(camDis, mCamera->getNearClippingPlane() * 2, mCamera->getFarClippingPlane() / 2); diff --git a/glfw/lava-extras/glfw/GlfwApp.hh b/glfw/lava-extras/glfw/GlfwApp.hh index e81e480..35baf17 100644 --- a/glfw/lava-extras/glfw/GlfwApp.hh +++ b/glfw/lava-extras/glfw/GlfwApp.hh @@ -145,7 +145,7 @@ class GlfwApp { LAVA_PROPERTY(QueryStats); LAVA_PROPERTY(UseDefaultRendering); LAVA_PROPERTY(DoubleClickTime); - float getCurrentTime() const { return mCurrentTime; } + float getCurrentTime() const { return (float)mCurrentTime; } double getCurrentTimeD() const { return mCurrentTime; } LAVA_GETTER(Camera); LAVA_GETTER(Pipeline); diff --git a/pack/src/lava-extras/pack/pack.cc b/pack/src/lava-extras/pack/pack.cc index 3d9e492..e47de88 100644 --- a/pack/src/lava-extras/pack/pack.cc +++ b/pack/src/lava-extras/pack/pack.cc @@ -47,7 +47,7 @@ SharedShaderModule shader(const SharedDevice &device, const std::string &name) { auto sha = device->createShader(package.data_begin, package.data_end); auto stage = identifyShader(name); if (stage) { - sha->setStage(stage.get()); + sha->setStage(stage.value()); } return sha; } diff --git a/pipeline/lava-extras/pipeline/RenderingPipeline.cc b/pipeline/lava-extras/pipeline/RenderingPipeline.cc index 956e107..28aa281 100644 --- a/pipeline/lava-extras/pipeline/RenderingPipeline.cc +++ b/pipeline/lava-extras/pipeline/RenderingPipeline.cc @@ -161,9 +161,8 @@ void RenderingPipeline::assignCamera(const camera::SharedGenericCamera &cam, resize(cam->getViewportWidth(), cam->getViewportHeight()); } -void RenderingPipeline::render( - RecordingCommandBuffer &cmd, const SharedFramebuffer &fbo, - const std::function<void(RenderPass const &pass)> &renderFunc) { +void RenderingPipeline::render(lava::RecordingCommandBuffer &cmd, lava::SharedFramebuffer const &fbo, std::function<void(lava::pipeline::RenderPass const &pass)> const &renderFunc) { + assert(renderFunc != nullptr && "no render function provided"); assert(mCamera != nullptr && "no camera provided"); diff --git a/pipeline/lava-extras/pipeline/RenderingPipeline.hh b/pipeline/lava-extras/pipeline/RenderingPipeline.hh index 3584d3f..99f0c08 100644 --- a/pipeline/lava-extras/pipeline/RenderingPipeline.hh +++ b/pipeline/lava-extras/pipeline/RenderingPipeline.hh @@ -137,8 +137,8 @@ class RenderingPipeline { * @param renderFunc function to call for every renderpass. Use the provided * pass information */ - void render(RecordingCommandBuffer &cmd, SharedFramebuffer const &fbo, - std::function<void(RenderPass const &pass)> const &renderFunc); + void render(lava::RecordingCommandBuffer &cmd, lava::SharedFramebuffer const &fbo, + const std::function<void( lava::pipeline::RenderPass const &pass)> &renderFunc); /// Use this to create the FBOs for the Pipeline to output to SharedRenderPass const &outputPass() const { return mPassOutput; } diff --git a/pipeline/lava-extras/pipeline/fwd.hh b/pipeline/lava-extras/pipeline/fwd.hh index 7805f3d..8b9aa92 100644 --- a/pipeline/lava-extras/pipeline/fwd.hh +++ b/pipeline/lava-extras/pipeline/fwd.hh @@ -10,7 +10,7 @@ namespace lava { namespace pipeline { LAVA_FORWARD_DECLARE_CLASS(RenderingPipeline); -class RenderPass; +struct RenderPass; } } -- GitLab