Skip to content

Commit

Permalink
Clean up compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed Jul 18, 2024
1 parent f5da6a7 commit a8d0464
Show file tree
Hide file tree
Showing 50 changed files with 266 additions and 231 deletions.
2 changes: 1 addition & 1 deletion src/apps/rdemo/Demo_Environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ auto Demo_Environment = [](Application& app)

if (ImGuiLTable::Begin("environment"))
{
float hours = dt.hours();
float hours = (float)dt.hours();
if (ImGuiLTable::SliderFloat("Time of day (UTC)", &hours, 0.0f, 23.999f, "%.1f"))
{
dt = DateTime(dt.year(), dt.month(), dt.day(), hours);
Expand Down
13 changes: 8 additions & 5 deletions src/apps/rdemo/Demo_Label.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@ auto Demo_Label = [](Application& app)
auto& label = app.entities.get<Label>(entity);
ImGuiLTable::Checkbox("Visible", &label.active);

char buf[256];
strcpy(&buf[0], label.text.c_str());
if (ImGuiLTable::InputText("Text", buf, 255))
if (label.text.length() <= 255)
{
label.text = std::string(buf);
label.dirty();
char buf[256];
std::copy(label.text.begin(), label.text.end(), buf);
if (ImGuiLTable::InputText("Text", &buf[0], 255))
{
label.text = std::string(buf);
label.dirty();
}
}

if (ImGuiLTable::SliderFloat("Point size", &label.style.pointSize, 8.0f, 144.0f, "%.1f"))
Expand Down
2 changes: 1 addition & 1 deletion src/apps/rdemo/Demo_LineFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ auto Demo_LineFeatures = [](Application& app)

// apply a style for geometry creation:
feature_view.styles.line = LineStyle{
{ 1,1,0.3,1 }, // color
{ 1,1,0.3f,1 }, // color
2.0f, // width
0xffff, // stipple pattern
1, // stipple factor
Expand Down
10 changes: 5 additions & 5 deletions src/apps/rdemo/Demo_Mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ auto Demo_Mesh_Absolute = [](Application& app)
}

// Set a dynamic style that we can change at runtime.
mesh.style = { { 1,0.4,0.1,0.75 }, 32.0f, 1e-7f };
mesh.style = { { 1.0f, 0.4f, 0.1f, 0.75f }, 32.0f, 1e-7f };

// Turn off depth buffer writes
mesh.writeDepth = false;
Expand Down Expand Up @@ -104,7 +104,7 @@ auto Demo_Mesh_Relative = [](Application& app)
0,1,5, 0,5,4, 2,3,7, 2,7,6
};

vsg::vec4 color{ 1, 0, 1, 0.85 };
vsg::vec4 color{ 1, 0, 1, 0.85f };

for (unsigned i = 0; i < 48; )
{
Expand All @@ -113,7 +113,7 @@ auto Demo_Mesh_Relative = [](Application& app)
{color, color, color} });

if ((i % 6) == 0)
color.r *= 0.8, color.b *= 0.8;
color.r *= 0.8f, color.b *= 0.8f;
}

// Add a transform component so we can position our mesh relative
Expand Down Expand Up @@ -184,7 +184,7 @@ auto Demo_Mesh_Multi = [](Application& app)
0,1,5, 0,5,4, 2,3,7, 2,7,6
};

vsg::vec4 color{ 1, 0, 1, 0.85 };
vsg::vec4 color{ 1, 0, 1, 0.85f };

for (unsigned i = 0; i < 48; )
{
Expand All @@ -193,7 +193,7 @@ auto Demo_Mesh_Multi = [](Application& app)
{color, color, color} });

if ((i % 6) == 0)
color.r *= 0.8, color.b *= 0.8;
color.r *= 0.8f, color.b *= 0.8f;
}

// Add a transform component so we can position our mesh relative
Expand Down
4 changes: 2 additions & 2 deletions src/apps/rdemo/Demo_RTT.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ auto Demo_RTT = [](Application& app)
{lon, lat + step, alt} };

for (int i = 0; i < 4; ++i) {
uv[i].s = (v[i].x - lon0) / (lon1 - lon0);
uv[i].t = (v[i].y - lat0) / (lat1 - lat0);
uv[i].s = (float)((v[i].x - lon0) / (lon1 - lon0));
uv[i].t = (float)((v[i].y - lat0) / (lat1 - lat0));
xform(v[i], v[i]);
}

Expand Down
29 changes: 15 additions & 14 deletions src/apps/rdemo/Demo_Stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ namespace
Timings update(frame_count);
Timings record(frame_count);
int frame_num = 0;
char buf[256];
float get_timings(void* data, int index) {
return 0.001 * (float)(*(Timings*)data)[index].count();
return 0.001f * (float)(*(Timings*)data)[index].count();
};
unsigned long long average(void* data, int count, int start) {
Timings& t = *(Timings*)(data);
Expand All @@ -55,26 +54,28 @@ auto Demo_Stats = [](Application& app)

if (app.debugLayerOn())
{
ImGui::TextColored(ImVec4(1, .3, .3, 1), "Warning: debug validation is ON");
ImGui::TextColored(ImVec4(1, .3f, .3f, 1), "Warning: debug validation is ON");
}
if (app.instance.runtime().asyncCompile == false)
{
ImGui::TextColored(ImVec4(1, .3, .3, 1), "Warning: async compilation is OFF");
ImGui::TextColored(ImVec4(1, .3f, .3f, 1), "Warning: async compilation is OFF");
}

if (ImGuiLTable::Begin("Timings"))
{
sprintf(buf, "%.2f ms", 0.001f * (float)app.stats.frame.count());
ImGuiLTable::PlotLines("Frame", get_timings, &frames, frame_count, f, buf, 0.0f, 17.0f);
std::string buf;

sprintf(buf, u8"%lld \x00B5s", average(&events, over, f));
ImGuiLTable::PlotLines("Event", get_timings, &events, frame_count, f, buf, 0.0f, 10.0f);
buf = util::format("%.2f ms", 0.001f * (float)app.stats.frame.count());
ImGuiLTable::PlotLines("Frame", get_timings, &frames, frame_count, f, buf.c_str(), 0.0f, 17.0f);

sprintf(buf, u8"%lld \x00B5s", average(&update, over, f));
ImGuiLTable::PlotLines("Update", get_timings, &update, frame_count, f, buf, 0.0f, 10.0f);
buf = util::format(u8"%lld \x00B5s", average(&events, over, f));
ImGuiLTable::PlotLines("Event", get_timings, &events, frame_count, f, buf.c_str(), 0.0f, 10.0f);

sprintf(buf, u8"%lld \x00B5s", average(&record, over, f));
ImGuiLTable::PlotLines("Record", get_timings, &record, frame_count, f, buf, 0.0f, 10.0f);
buf = util::format(u8"%lld \x00B5s", average(&update, over, f));
ImGuiLTable::PlotLines("Update", get_timings, &update, frame_count, f, buf.c_str(), 0.0f, 10.0f);

buf = util::format(u8"%lld \x00B5s", average(&record, over, f));
ImGuiLTable::PlotLines("Record", get_timings, &record, frame_count, f, buf.c_str(), 0.0f, 10.0f);

ImGuiLTable::End();
}
Expand Down Expand Up @@ -103,8 +104,8 @@ auto Demo_Stats = [](Application& app)
if (m)
{
std::string name = m->name.empty() ? "default" : m->name;
sprintf(buf, "(%d) %d / %d", (int)m->concurrency, (int)m->running, (int)m->pending);
ImGuiLTable::Text(name.c_str(), buf);
auto buf = util::format("(%d) %d / %d", (int)m->concurrency, (int)m->running, (int)m->pending);
ImGuiLTable::Text(name.c_str(), buf.c_str());
}
}
ImGuiLTable::End();
Expand Down
2 changes: 1 addition & 1 deletion src/apps/rdemo/Demo_Tethering.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ auto Demo_Tethering = [](Application& app)
auto& mesh = app.entities.emplace<Mesh>(entity);
vsg::vec3 verts[4] = { { -s, -s, 0 }, { s, -s, 0 }, { s, s, 0 }, { -s, s, 0 } };
unsigned indices[6] = { 0,1,2, 0,2,3 };
vsg::vec4 color{ 1, 1, 0, 0.55 };
vsg::vec4 color{ 1, 1, 0, 0.55f };
for (unsigned i = 0; i < 6; ) {
mesh.add({
{verts[indices[i++]], verts[indices[i++]], verts[indices[i++]]},
Expand Down
16 changes: 9 additions & 7 deletions src/apps/rdemo/Demo_Views.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,31 @@ auto Demo_Views = [](Application& app)
bool vp_dirty = false;
auto old_vp = view->camera->getViewport();
auto vp = view->camera->getViewport();
if (ImGuiLTable::SliderFloat("X", &vp.x, 0, window->traits()->width))
if (ImGuiLTable::SliderFloat("X", &vp.x, 0, (float)window->traits()->width))
{
vp_dirty = true;
}
if (ImGuiLTable::SliderFloat("Y", &vp.y, 0, window->traits()->height))
if (ImGuiLTable::SliderFloat("Y", &vp.y, 0, (float)window->traits()->height))
{
vp_dirty = true;
}
if (ImGuiLTable::SliderFloat("Width", &vp.width, 0, window->traits()->width))
if (ImGuiLTable::SliderFloat("Width", &vp.width, 0, (float)window->traits()->width))
{
vp_dirty = true;
}
if (ImGuiLTable::SliderFloat("Height", &vp.height, 0, window->traits()->height))
if (ImGuiLTable::SliderFloat("Height", &vp.height, 0, (float)window->traits()->height))
{
vp_dirty = true;
}

if (vp_dirty)
{
if (vp.x + vp.width >= window->traits()->width) vp.x = window->traits()->width - vp.width - 1;
if (vp.y + vp.height >= window->traits()->height) vp.y = window->traits()->height - vp.height - 1;
if (vp.x + vp.width >= (float)window->traits()->width) vp.x = (float)window->traits()->width - (float)vp.width - 1;
if (vp.y + vp.height >= (float)window->traits()->height) vp.y = (float)window->traits()->height - (float)vp.height - 1;
view->camera->projectionMatrix->changeExtent(VkExtent2D{ (unsigned)old_vp.width, (unsigned)old_vp.height }, VkExtent2D{ (unsigned)vp.width, (unsigned)vp.height });
view->camera->viewportState->set(vp.x, vp.y, vp.width, vp.height);
view->camera->viewportState->set(
(std::uint32_t)vp.x, (std::uint32_t)vp.y,
(std::uint32_t)vp.width, (std::uint32_t)vp.height);
app.displayManager->refreshView(view);
}

Expand Down
4 changes: 2 additions & 2 deletions src/apps/rdemo/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace ImGuiLTable
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(-1);
std::string s("##" + std::string(label));
float temp = *v;
float temp = (float)*v;
bool ok = ImGui::SliderFloat(s.c_str(), &temp, (float)v_min, (float)v_max, format);
if (ok) *v = (double)temp;
return ok;
Expand All @@ -71,7 +71,7 @@ namespace ImGuiLTable
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(-1);
std::string s("##" + std::string(label));
float temp = *v;
float temp = (float)*v;
bool ok = ImGui::SliderFloat(s.c_str(), &temp, (float)v_min, (float)v_max, format, flags);
if (ok) *v = (double)temp;
return ok;
Expand Down
2 changes: 1 addition & 1 deletion src/apps/rdemoqt/rdemoqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void newWindow(rocky::Application& app)
auto dm = app.displayManager;
app.onNextUpdate([dm]()
{
int i = dm->windowsAndViews.size();
auto i = dm->windowsAndViews.size();

// the window:
auto window = new QWidget();
Expand Down
2 changes: 1 addition & 1 deletion src/apps/rsimple/rsimple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int main(int argc, char** argv)
}
}

mesh.style = { {1, 0.4, 0.1, 0.75}, 32.0f, 1e-7f };
mesh.style = { {1, 0.4f, 0.1f, 0.75f}, 32.0f, 1e-7f };
mesh.writeDepth = true;

return app.run();
Expand Down
10 changes: 5 additions & 5 deletions src/rocky/Color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ Color::Color(const std::string& input, Format format)
t.size() >= 2 && t[0] == '0' && t[1] == 'x' ? 2 :
t.size() >= 1 && t[0] == '#' ? 1 :
0;
unsigned len = t.length() - e;
unsigned len = (unsigned)t.length() - e;
if (len == 3)
{
// This is a 3 digit hex code, so turn it into a 6 digit hex code
Expand Down Expand Up @@ -360,7 +360,7 @@ Color::asHSL() const
B = glm::fvec4(r, p.y, p.z, p.x);
glm::fvec4 q = glm::mix(A, B, step(p.x, r));
float d = q.x - std::min(q.w, q.y);
const float e = 1.0e-10;
const float e = 1.0e-10f;
return glm::fvec4(
fabs(q.z + (q.w - q.y) / (6.0f*d + e)),
d / (q.x + e),
Expand Down Expand Up @@ -424,13 +424,13 @@ Color::createRandomColorRamp(
std::mt19937 gen(seed >= 0 ? seed : 0);
std::uniform_int_distribution<> prng(0, 360);

double hueAngle = (double)prng(gen);// prng.next(360);
float hueAngle = (float)prng(gen);// prng.next(360);
glm::fvec4 hsv(0, 0, 0, 1);

for (unsigned i = 0; i < count; ++i)
{
hueAngle = fmod(hueAngle + 137.50776, 360.0);
hsv[0] = hueAngle / 360.0;
hueAngle = fmodf(hueAngle + 137.50776f, 360.0f);
hsv[0] = hueAngle / 360.0f;
hsv[1] = satMin + (float)prng(gen)*(satMax - satMin);
hsv[2] = valMin + (float)prng(gen)*(valMax - valMin);
hsv2rgb(hsv);
Expand Down
17 changes: 3 additions & 14 deletions src/rocky/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
#pragma once

#if defined(_MSC_VER)
#pragma warning( disable : 4244 )
#pragma warning( disable : 4251 )
#pragma warning( disable : 4267 )
#pragma warning( disable : 4275 )
#pragma warning( disable : 4290 )
#pragma warning( disable : 4786 )
#pragma warning( disable : 4305 )
#pragma warning( disable : 4996 )
//#pragma warning(disable : 4996) // disable warnings about deprecated functions
#pragma warning(disable:4244) // disable precision loss warnings (e.g., double to float)
#endif

#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__)
Expand All @@ -35,6 +29,7 @@
#include <string>
#include <memory>
#include <iostream>
#include <cstdlib>

namespace ROCKY_NAMESPACE
{
Expand Down Expand Up @@ -111,12 +106,6 @@ namespace ROCKY_NAMESPACE

#define ROCKY_ABOUT(NAME, VER) namespace { struct __about_##NAME { __about_##NAME() { rocky::Instance::about().insert(std::string(#NAME) + " " + VER); } }; __about_##NAME about_##NAME; }

#ifdef _MSC_VER
// VS ignores
#pragma warning (disable: 4224)
#pragma warning (disable: 4180)
#endif

#define ROCKY_DEPRECATED(A, B) rocky::Log::warn() << #A << " is deprecated; please use " << #B << std::endl

#if defined(_MSC_VER)
Expand Down
Loading

0 comments on commit a8d0464

Please sign in to comment.