Commit 0082c27e authored by Johannes Braun's avatar Johannes Braun
Browse files

Exterminate a load of warnings (compiler and opengl)

parent 7c59ec3f
#include "Editor.hpp"
#include <dino/Dino.h>
#include <fstream>
#include <functional>
......
......@@ -8,7 +8,7 @@
#include "./Bounds.h"
#include "./Camera.h"
#include "./Creatable.h"
#include "./Dino.h"
#include "./Editor.h"
#include "./Function.h"
#include "./Modifier.h"
#include "./Operator.h"
......
#include "Editor.hpp"
#include "Editor.h"
#include <dino/editor/iconfont/IconsMaterialDesignIcons.h>
#include <dino/editor/tinyfiledialogs.h>
#include <fstream>
......@@ -120,7 +120,7 @@ void Editor::loadField(const std::filesystem::path path)
}
m_blueprints.back()->setPath(path);
}
catch(const nlohmann::json::exception& e)
catch(const nlohmann::json::exception&)
{
tinyfd_notifyPopup("Load Distance Field",
"Selected file cannot be parsed as a valid json object.",
......@@ -189,8 +189,8 @@ void Editor::drawFieldsTab()
if(ImGui::Button(ICON_MDI_PLUS " Add"))
{
m_selectedFieldIndices.clear();
m_selectedFieldIndices.emplace(m_allFieldIds.size());
m_activeFieldIndex = m_allFieldIds.size();
m_selectedFieldIndices.emplace(static_cast<uint32_t>(m_allFieldIds.size()));
m_activeFieldIndex = static_cast<uint32_t>(m_allFieldIds.size());
m_allFieldIds.push_back(std::nullopt);
m_blueprints.emplace_back(std::make_unique<dino::Blueprints>(*m_window));
glfwShowWindow(*m_editorWindow);
......@@ -204,7 +204,7 @@ void Editor::drawFieldsTab()
{
loadField(filePath);
m_selectedFieldIndices.clear();
m_selectedFieldIndices.emplace(m_allFieldIds.size() - 1);
m_selectedFieldIndices.emplace(static_cast<uint32_t>(m_allFieldIds.size() - 1));
}
}
ImGui::Spring();
......@@ -840,7 +840,7 @@ void Editor::drawRenderingTab()
if(glfwGetMouseButton(*m_window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS)
{
m_layerDragState.dragging = true;
m_layerDragState.draggedLayer = std::distance(m_activeRenderLayers.begin(), it);
m_layerDragState.draggedLayer = static_cast<uint32_t>(std::distance(m_activeRenderLayers.begin(), it));
m_layerDragState.lastItemDelta = 0;
m_layerDragState.dragStart = ImGui::GetMousePos();
m_layerDragState.itemHeight = btnHeight;
......@@ -850,7 +850,7 @@ void Editor::drawRenderingTab()
if(doIncrement)
++it;
}
}
if(m_layerDragState.dragging)
{
......@@ -859,7 +859,7 @@ void Editor::drawRenderingTab()
std::clamp<int>(m_layerDragState.draggedLayer +
static_cast<int>(delta / m_layerDragState.itemHeight),
0,
m_renderer->getRenderLayers().size() - 2) -
static_cast<int>((m_renderer->getRenderLayers().size() - 2))) -
m_layerDragState.draggedLayer;
std::cout << deltaItem << '\n';
......@@ -1039,7 +1039,7 @@ void Editor::select(std::optional<uint32_t> id, bool showBlueprint, bool deselec
{
if(showBlueprint)
glfwShowWindow(*m_editorWindow);
m_activeFieldIndex = std::distance(m_allFieldIds.begin(), it);
m_activeFieldIndex = static_cast<uint32_t>(std::distance(m_allFieldIds.begin(), it));
if(glfwGetKey(*m_window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS)
{
......@@ -1194,8 +1194,8 @@ void Editor::processInputsMain()
if(m_ctrlN.pressed(*m_window))
{
m_selectedFieldIndices.clear();
m_selectedFieldIndices.emplace(m_allFieldIds.size());
m_activeFieldIndex = m_allFieldIds.size();
m_selectedFieldIndices.emplace(static_cast<uint32_t>(m_allFieldIds.size()));
m_activeFieldIndex = static_cast<uint32_t>(m_allFieldIds.size());
m_allFieldIds.push_back(std::nullopt);
m_blueprints.emplace_back(std::make_unique<dino::Blueprints>(*m_window));
glfwShowWindow(*m_editorWindow);
......@@ -1262,7 +1262,7 @@ void Editor::processInputsLights()
if(m_shiftTabMain.pressed(*m_window))
{
m_selectedLightIndices.clear();
m_activeLightIndex = (*m_activeFieldIndex + 1) % m_allFieldIds.size();
m_activeLightIndex = static_cast<uint32_t>((*m_activeFieldIndex + 1) % m_allFieldIds.size());
m_selectedLightIndices.emplace(*m_activeLightIndex);
}
if(m_ctrlA.pressed(*m_window))
......@@ -1277,7 +1277,7 @@ void Editor::processInputsLights()
m_selectedLightIndices.clear();
m_activeLightIndex = 0;
for(size_t i = 0; i < m_allLightIds.size(); ++i)
m_selectedLightIndices.emplace(i);
m_selectedLightIndices.emplace(static_cast<uint32_t>(i));
}
}
}
......@@ -1314,7 +1314,7 @@ void Editor::processInputsFields()
if(optId)
m_renderer->setActivePixelObjectId(*optId);
for(size_t i = 0; i < m_allFieldIds.size(); ++i)
m_selectedFieldIndices.emplace(i);
m_selectedFieldIndices.emplace(static_cast<uint32_t>(i));
}
}
}
......@@ -1344,7 +1344,7 @@ void Editor::drawMenuBar()
void Editor::drawTimer()
{
float currentTime = glfwGetTime();
float currentTime = static_cast<float>(glfwGetTime());
m_nFrames++;
if(currentTime - m_lastTime > 1)
......@@ -1456,7 +1456,7 @@ void Editor::loadScene()
}
}
}
catch(const nlohmann::json::exception& e)
catch(const nlohmann::json::exception&)
{
tinyfd_notifyPopup("Load Distance Field",
"Selected file cannot be parsed as "
......
......@@ -1398,7 +1398,7 @@ bool Blueprints::update(const dino::Renderer& renderer)
static Pin* newNodeLinkPin = nullptr;
static Pin* newLinkPin = nullptr;
int menuBarHeight = 0;
float menuBarHeight = 0;
if(ImGui::BeginMenuBar())
{
menuBarHeight = ImGui::GetWindowSize().x;
......@@ -1744,7 +1744,7 @@ void Blueprints::showStyleEditor(bool* show) const
ImGui::End();
}
void Blueprints::showInfoPane(float paneWidth, bool attach, int yOffset)
void Blueprints::showInfoPane(float paneWidth, bool attach, float yOffset)
{
auto& io = ImGui::GetIO();
if(!attach)
......@@ -1974,7 +1974,7 @@ int Blueprints::getChildren(const std::shared_ptr<Function>& function, const std
m_nodePosY = newPos.y;
if(children.size() == 0)
return 200;
return abs(pos.y - newPos.y);
return static_cast<int>(abs(pos.y - newPos.y));
}
int Blueprints::getParamOpChildren(const std::shared_ptr<ParamOperator>& op, const Node* parentNode,
......@@ -2042,7 +2042,7 @@ int Blueprints::getParamOpChildren(const std::shared_ptr<ParamOperator>& op, con
m_nodePosY = newPos.y;
if(valid == 0)
return 200;
return abs(position.y - newPos.y);
return static_cast<int>(abs(position.y - newPos.y));
}
Node* Blueprints::createNode(const std::shared_ptr<Function>& function)
......@@ -2307,7 +2307,7 @@ Node* Blueprints::createNode(const std::shared_ptr<Function>& function)
{
meshDiscretizer->fromMesh(file, algo, maxRes);
}
catch(std::exception& e)
catch(std::exception&)
{
fail = true;
}
......@@ -2333,7 +2333,7 @@ Node* Blueprints::createNode(const std::shared_ptr<Function>& function)
{
meshDiscretizer->loadFromFile(file);
}
catch(std::exception& e)
catch(std::exception&)
{
fail = true;
}
......@@ -2810,10 +2810,12 @@ const std::vector<Node>& Blueprints::copyNodes()
if(e->AsNode()->ID().AsNodeId() != ed::NodeId(1))
{
getClipboard().saved.push_back(*find(e->AsNode()->ID().AsNodeId()));
centerPosition = centerPosition + ImVec2(e->AsNode()->m_Bounds.location.x,
e->AsNode()->m_Bounds.location.y);
centerPosition =
centerPosition + ImVec2(static_cast<float>(e->AsNode()->m_Bounds.location.x),
static_cast<float>(e->AsNode()->m_Bounds.location.y));
getClipboard().positions.push_back(
ImVec2(e->AsNode()->m_Bounds.location.x, e->AsNode()->m_Bounds.location.y));
ImVec2(static_cast<float>(e->AsNode()->m_Bounds.location.x),
static_cast<float>(e->AsNode()->m_Bounds.location.y)));
}
}
centerPosition = centerPosition * (1.f / temp.size());
......@@ -2837,7 +2839,7 @@ const std::vector<Node>& Blueprints::copyNodes()
getClipboard().saved[i].inputs[n].id));
getClipboard().links.back().color =
getIconColor(getClipboard().saved[j].outputs[m].type);
j = getClipboard().saved.size();
j = static_cast<int>(getClipboard().saved.size());
break;
}
}
......@@ -2935,7 +2937,7 @@ void Blueprints::pasteNodes()
m_links.emplace_back(Link(
ed::LinkId(nextId()), nn[j]->outputs[m].id, nn[i]->inputs[n].id));
m_links.back().color = getIconColor(nn[j]->outputs[m].type);
j = getClipboard().saved.size();
j = static_cast<int>(getClipboard().saved.size());
break;
}
}
......
......@@ -364,7 +364,7 @@ private:
* @param paneWidth width of the pane
* @param attach if true attach pane to left side, if false free floating pane
*/
void showInfoPane(float paneWidth, bool attach, int yOffset = 0);
void showInfoPane(float paneWidth, bool attach, float yOffset = 0);
/**
* @brief Updates the parameter according to the current pin status and data.
......
......@@ -109,6 +109,8 @@ void Buffer<T>::assign(const std::vector<T>& data, GLintptr offset)
template <typename T>
void Buffer<T>::assign(const T* data, GLsizeiptr count, GLintptr offset)
{
if (count == 0)
return;
DINO_ASSERT_LOG(offset + count <= m_size, "Invalid Size and/or offset.");
BufferCompat::get().namedBufferSubData(m_buffer, offset * sizeof(T), count * sizeof(T), data);
}
......
......@@ -27,7 +27,7 @@ float ParamAcos::doOp(float val) { return glm::acos(val); }
float ParamAtan::doOp(float val) { return glm::atan(val); }
float ParamTriWave::doOp(float val)
{
return 1.f - 4.f * glm::abs(0.5f - glm::fract(0.5f * val + 0.25));
return 1.f - 4.f * glm::abs(0.5f - glm::fract(0.5f * val + 0.25f));
}
std::string_view ParamSin::name() const { return "Sine"; }
......
......@@ -393,10 +393,13 @@ void Renderer::render(const glm::mat4& view, const glm::mat4& projection)
}
// update shadow map buffer
if(m_smBuffer.size() != static_cast<GLsizeiptr>(shadowMaps.size()))
if(m_smBuffer.size() < static_cast<GLsizeiptr>(shadowMaps.size()))
m_smBuffer.resize(shadowMaps.size(), GL_DYNAMIC_STORAGE_BIT);
m_smBuffer.assign(shadowMaps);
m_smBuffer.bind(GL_SHADER_STORAGE_BUFFER, SM_STORAGE_BINDING);
if (shadowMaps.size() > 0)
m_smBuffer.bind(GL_SHADER_STORAGE_BUFFER, SM_STORAGE_BINDING);
else
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, SM_STORAGE_BINDING, 0);
// render scene
glCullFace(GL_FRONT);
......@@ -574,7 +577,7 @@ const std::unordered_map<uint32_t, std::shared_ptr<Material>>& Renderer::getMate
return m_materials;
}
int Renderer::fieldCount() const { return m_distanceFields.size(); }
int Renderer::fieldCount() const { return static_cast<int>(m_distanceFields.size()); }
std::shared_ptr<Function> Renderer::getFunctionByID(int id) const
{
......@@ -665,7 +668,7 @@ uint32_t Renderer::addRenderLayer(RenderLayer::Type type)
GL_VERTEX_SHADER, dino::ShaderFile::load("screenFilling.vert"));
m_invalidRenderables = true;
return m_renderLayers.size() - 2;
return static_cast<uint32_t>(m_renderLayers.size() - 2);
}
void Renderer::removeRenderLayer(int layerIndex)
......
......@@ -13454,7 +13454,7 @@ void ImGui::BeginHorizontal(int id, const ImVec2& size/* = ImVec2(0, 0)*/, float
{
ImGuiWindow* window = GetCurrentWindow();
 
BeginLayout(window->GetID(reinterpret_cast<void*>(id)), ImGuiLayoutType_Horizontal, size, align);
BeginLayout(window->GetID(reinterpret_cast<void*>(uint64_t(id))), ImGuiLayoutType_Horizontal, size, align);
}
 
void ImGui::EndHorizontal()
......@@ -13480,7 +13480,7 @@ void ImGui::BeginVertical(int id, const ImVec2& size/* = ImVec2(0, 0)*/, float a
{
ImGuiWindow* window = GetCurrentWindow();
 
BeginLayout(window->GetID(reinterpret_cast<void*>(id)), ImGuiLayoutType_Vertical, size, align);
BeginLayout(window->GetID(reinterpret_cast<void*>(uint64_t(id))), ImGuiLayoutType_Vertical, size, align);
}
 
void ImGui::EndVertical()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment