various small C++ warning fixes

This commit is contained in:
Noel Berry 2021-05-06 21:48:06 -07:00
parent fb91b77900
commit 04f6257b75
20 changed files with 87 additions and 89 deletions

View File

@ -156,13 +156,13 @@ namespace Blah
void rect_rounded_line(const Rect& rect, float radius, int steps, float t, Color color);
void rect_rounded_line(const Rect& rect, float rtl, int rtl_steps, float rtr, int rtr_steps, float rbr, int rbr_steps, float rbl, int rbl_steps, float t, Color color);
void semi_circle(Vec2 center, float start_radians, float end_radians, float radius, int steps, Color centerColor, Color edgeColor);
void semi_circle(Vec2 center, float start_radians, float end_radians, float radius, int steps, Color color);
void semi_circle_line(Vec2 center, float start_radians, float end_radians, float radius, int steps, float t, Color color);
void semi_circle(const Vec2& center, float start_radians, float end_radians, float radius, int steps, Color centerColor, Color edgeColor);
void semi_circle(const Vec2& center, float start_radians, float end_radians, float radius, int steps, Color color);
void semi_circle_line(const Vec2& center, float start_radians, float end_radians, float radius, int steps, float t, Color color);
void circle(const Vec2 center, float radius, int steps, Color color);
void circle(const Vec2 center, float radius, int steps, Color center_color, Color outer_color);
void circle_line(const Vec2 center, float raidus, float t, int steps, Color color);
void circle(const Vec2& center, float radius, int steps, Color color);
void circle(const Vec2& center, float radius, int steps, Color center_color, Color outer_color);
void circle_line(const Vec2& center, float radius, float t, int steps, Color color);
void quad(const Vec2& pos0, const Vec2& pos1, const Vec2& pos2, const Vec2& pos3, Color color);
void quad(const Vec2& pos0, const Vec2& pos1, const Vec2& pos2, const Vec2& pos3, Color col0, Color col1, Color col2, Color col3);

View File

@ -31,7 +31,7 @@ namespace Blah
static MaterialRef create(const ShaderRef& shader);
// Returns the Shader assigned to the Material.
const ShaderRef shader() const;
ShaderRef shader() const;
// Sets the texture
void set_texture(const char* name, const TextureRef& texture, int array_index = 0);

View File

@ -60,7 +60,7 @@ namespace Blah
bool save_jpg(Stream& stream, int quality) const;
// gets the pixels from the given source rectangle
void get_pixels(Color* dest, const Point& dest_pos, const Point& dest_size, RectI source_rect);
void get_pixels(Color* dest, const Point& dest_pos, const Point& dest_size, RectI source_rect) const;
// gets a sub image from this image
Image get_sub_image(const RectI& source_rect);

View File

@ -62,7 +62,7 @@ namespace Blah
Color operator*(float multiply) const;
// assignment from int
Color& operator= (const int rgb);
Color& operator= (int rgb);
// comparisons
bool operator ==(const Color& rhs) const;

View File

@ -19,7 +19,7 @@ namespace Blah
ElasticIn, ElasticOut, ElasticInOut,
BackIn, BackOut, BackInOut,
BounceIn, BounceOut, BounceInOut,
_Count
Count
};
namespace Ease
@ -285,7 +285,7 @@ namespace Blah
case Easers::BounceIn: return &bounce_in;
case Easers::BounceOut: return &bounce_out;
case Easers::BounceInOut: return &bounce_in_out;
case Easers::_Count:
case Easers::Count:
break;
}
@ -328,7 +328,7 @@ namespace Blah
case Easers::BounceIn: return "BounceIn";
case Easers::BounceOut: return "BounceOut";
case Easers::BounceInOut: return "BounceInOut";
case Easers::_Count:
case Easers::Count:
break;
}

View File

@ -13,17 +13,17 @@ namespace Blah
FileStream& operator=(FileStream&& fs) noexcept;
~FileStream();
virtual i64 length() const override;
virtual i64 position() const override;
virtual i64 seek(i64 seekTo) override;
virtual bool is_open() const override;
virtual bool is_readable() const override;
virtual bool is_writable() const override;
virtual void close() override;
i64 length() const override;
i64 position() const override;
i64 seek(i64 seekTo) override;
bool is_open() const override;
bool is_readable() const override;
bool is_writable() const override;
void close() override;
protected:
virtual i64 read_into(void* ptr, i64 length) override;
virtual i64 write_from(const void* ptr, i64 length) override;
i64 read_into(void* ptr, i64 length) override;
i64 write_from(const void* ptr, i64 length) override;
private:
FileMode m_mode;

View File

@ -10,22 +10,22 @@ namespace Blah
MemoryStream(char* data, i64 length);
MemoryStream(MemoryStream&& ms) noexcept;
MemoryStream& operator=(MemoryStream&& ms) noexcept;
~MemoryStream() { m_data = nullptr; m_length = m_position = 0; }
~MemoryStream() override { m_data = nullptr; m_length = m_position = 0; }
virtual i64 length() const override { return m_length; }
virtual i64 position() const override { return m_position; }
virtual i64 seek(i64 seekTo) override { return m_position = (seekTo < 0 ? 0 : (seekTo > m_length ? m_length : seekTo)); }
virtual bool is_open() const override { return m_data != nullptr; }
virtual bool is_readable() const override { return true; }
virtual bool is_writable() const override { return true; }
virtual void close() override { m_data = nullptr; m_length = m_position = 0; }
i64 length() const override { return m_length; }
i64 position() const override { return m_position; }
i64 seek(i64 seekTo) override { return m_position = (seekTo < 0 ? 0 : (seekTo > m_length ? m_length : seekTo)); }
bool is_open() const override { return m_data != nullptr; }
bool is_readable() const override { return true; }
bool is_writable() const override { return true; }
void close() override { m_data = nullptr; m_length = m_position = 0; }
char* data() { return m_data; }
const char* data() const { return m_data; }
protected:
virtual i64 read_into(void* ptr, i64 length) override;
virtual i64 write_from(const void* ptr, i64 length) override;
i64 read_into(void* ptr, i64 length) override;
i64 write_from(const void* ptr, i64 length) override;
private:
char* m_data;

View File

@ -266,29 +266,29 @@ namespace
Attachments empty_attachments;
TextureRef empty_texture;
virtual Attachments& attachments() override
Attachments& attachments() override
{
BLAH_ASSERT(false, "Backbuffer doesn't have any attachments");
return empty_attachments;
}
virtual const Attachments& attachments() const override
const Attachments& attachments() const override
{
BLAH_ASSERT(false, "Backbuffer doesn't have any attachments");
return empty_attachments;
}
virtual int width() const override
int width() const override
{
return App::draw_width();
}
virtual int height() const override
int height() const override
{
return App::draw_height();
}
virtual void clear(Color color, float depth, u8 stencil, ClearMask mask) override
void clear(Color color, float depth, u8 stencil, ClearMask mask) override
{
GraphicsBackend::clear_backbuffer(color, depth, stencil, mask);
}

View File

@ -140,11 +140,11 @@ namespace
}
#define MAKE_VERTEX(vert, mat, px, py, tx, ty, c, m, w, f) \
(vert)->pos.x = ((px) * mat.m11) + ((py) * mat.m21) + mat.m31; \
(vert)->pos.y = ((px) * mat.m12) + ((py) * mat.m22) + mat.m32; \
(vert)->pos.x = ((px) * (mat).m11) + ((py) * (mat).m21) + (mat).m31; \
(vert)->pos.y = ((px) * (mat).m12) + ((py) * (mat).m22) + (mat).m32; \
(vert)->tex.x = tx; \
if (m_batch.flip_vertically) \
(vert)->tex.y = 1.0f - ty; \
(vert)->tex.y = 1.0f - (ty); \
else \
(vert)->tex.y = ty; \
(vert)->col = c; \
@ -194,7 +194,7 @@ do { \
// Compares a Batcher variable, and starts a new batch if it has changed
#define SET_BATCH_VAR(variable) \
if (m_batch.elements > 0 && variable != m_batch.variable) \
if (m_batch.elements > 0 && (variable) != m_batch.variable) \
INSERT_BATCH(); \
m_batch.variable = variable;
@ -757,7 +757,7 @@ void Batch::rect_rounded_line(const Rect& r, float rtl, int rtl_steps, float rtr
}
}
void Batch::semi_circle(Vec2 center, float start_radians, float end_radians, float radius, int steps, Color centerColor, Color edgeColor)
void Batch::semi_circle(const Vec2& center, float start_radians, float end_radians, float radius, int steps, Color centerColor, Color edgeColor)
{
Vec2 last = Vec2::from_angle(start_radians, radius);
float add = Calc::angle_diff(start_radians, end_radians);
@ -770,12 +770,12 @@ void Batch::semi_circle(Vec2 center, float start_radians, float end_radians, flo
}
}
void Batch::semi_circle(Vec2 center, float start_radians, float end_radians, float radius, int steps, Color color)
void Batch::semi_circle(const Vec2& center, float start_radians, float end_radians, float radius, int steps, Color color)
{
semi_circle(center, start_radians, end_radians, radius, steps, color, color);
}
void Batch::semi_circle_line(Vec2 center, float start_radians, float end_radians, float radius, int steps, float t, Color color)
void Batch::semi_circle_line(const Vec2& center, float start_radians, float end_radians, float radius, int steps, float t, Color color)
{
if (t >= radius)
{
@ -801,12 +801,12 @@ void Batch::semi_circle_line(Vec2 center, float start_radians, float end_radians
}
}
void Batch::circle(const Vec2 center, float radius, int steps, Color color)
void Batch::circle(const Vec2& center, float radius, int steps, Color color)
{
circle(center, radius, steps, color, color);
}
void Batch::circle(const Vec2 center, float radius, int steps, Color center_color, Color outer_color)
void Batch::circle(const Vec2& center, float radius, int steps, Color center_color, Color outer_color)
{
Vec2 last = Vec2(center.x + radius, center.y);
@ -821,7 +821,7 @@ void Batch::circle(const Vec2 center, float radius, int steps, Color center_colo
}
}
void Batch::circle_line(const Vec2 center, float radius, float t, int steps, Color color)
void Batch::circle_line(const Vec2& center, float radius, float t, int steps, Color color)
{
if (t >= radius)
{

View File

@ -70,7 +70,7 @@ Material::Material(const ShaderRef& shader)
m_data.expand(float_size);
}
const ShaderRef Material::shader() const
ShaderRef Material::shader() const
{
return m_shader;
}

View File

@ -11,9 +11,7 @@
using namespace Blah;
Aseprite::Aseprite()
{
}
= default;
Aseprite::Aseprite(const FilePath& path)
{
@ -77,9 +75,7 @@ Aseprite& Aseprite::operator=(Aseprite&& src) noexcept
}
Aseprite::~Aseprite()
{
}
= default;
void Aseprite::parse(Stream& stream)
{

View File

@ -233,7 +233,7 @@ bool Font::get_image(const Font::Character& ch, Color* pixels) const
{
// we actually use the image buffer as our temporary buffer, and fill the pixels out backwards after
// kinda weird but it works & saves creating more memory
unsigned char* src = (unsigned char*)pixels;
auto* src = (unsigned char*)pixels;
stbtt_MakeGlyphBitmap((stbtt_fontinfo*)m_font, src, ch.width, ch.height, ch.width, ch.scale, ch.scale, ch.glyph);
int len = ch.width * ch.height;

View File

@ -96,6 +96,8 @@ Image::Image(const Image& src)
Image& Image::operator=(const Image& src)
{
dispose();
width = src.width;
height = src.height;
m_stbi_ownership = src.m_stbi_ownership;
@ -269,7 +271,7 @@ bool Image::save_jpg(Stream& stream, int quality) const
return false;
}
void Image::get_pixels(Color* dest, const Point& dest_pos, const Point& dest_size, RectI source_rect)
void Image::get_pixels(Color* dest, const Point& dest_pos, const Point& dest_size, RectI source_rect) const
{
// can't be outside of the source image
if (source_rect.x < 0) source_rect.x = 0;

View File

@ -5,7 +5,7 @@
#include <blah/core/common.h>
#include <blah/math/point.h>
#include "../internal/input_backend.h"
#include <string.h>
#include <cstring>
using namespace Blah;
@ -148,7 +148,7 @@ void InputBackend::on_controller_connect(int index, const char* name, int is_gam
ControllerState* controller = &(g_next_state.controllers[index]);
*controller = g_empty_controller;
controller->name = name;
controller->is_connected = 1;
controller->is_connected = true;
controller->is_gamepad = is_gamepad;
controller->button_count = button_count;
controller->axis_count = axis_count;
@ -171,8 +171,8 @@ void InputBackend::on_button_down(int index, int button)
g_next_state.controllers[index].is_connected &&
button < g_next_state.controllers[index].button_count)
{
g_next_state.controllers[index].down[button] = 1;
g_next_state.controllers[index].pressed[button] = 1;
g_next_state.controllers[index].down[button] = true;
g_next_state.controllers[index].pressed[button] = true;
g_next_state.controllers[index].button_timestamp[button] = Time::ticks;
}
}
@ -184,8 +184,8 @@ void InputBackend::on_button_up(int index, int button)
g_next_state.controllers[index].is_connected &&
button < g_next_state.controllers[index].button_count)
{
g_next_state.controllers[index].down[button] = 0;
g_next_state.controllers[index].released[button] = 1;
g_next_state.controllers[index].down[button] = false;
g_next_state.controllers[index].released[button] = true;
}
}

View File

@ -6,9 +6,9 @@
#include "../internal/graphics_backend.h"
#include "../internal/platform_backend.h"
#include <blah/core/common.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <cstdio>
#include <cstring>
#include <cstddef>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@ -193,22 +193,22 @@ namespace Blah
view = nullptr;
}
virtual int width() const override
int width() const override
{
return m_width;
}
virtual int height() const override
int height() const override
{
return m_height;
}
virtual TextureFormat format() const override
TextureFormat format() const override
{
return m_format;
}
virtual void set_data(unsigned char* data) override
void set_data(unsigned char* data) override
{
// bounds
D3D11_BOX box;
@ -229,7 +229,7 @@ namespace Blah
0);
}
virtual void get_data(unsigned char* data) override
void get_data(unsigned char* data) override
{
HRESULT hr;
@ -278,7 +278,7 @@ namespace Blah
state.context->Unmap(staging, 0);
}
virtual bool is_framebuffer() const override
bool is_framebuffer() const override
{
return m_is_framebuffer;
}
@ -322,17 +322,17 @@ namespace Blah
color_views.clear();
}
virtual Attachments& attachments() override
Attachments& attachments() override
{
return m_attachments;
}
virtual const Attachments& attachments() const override
const Attachments& attachments() const override
{
return m_attachments;
}
virtual void clear(Color color, float depth, u8 stencil, ClearMask mask) override
void clear(Color color, float depth, u8 stencil, ClearMask mask) override
{
float col[4] = { color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f };
@ -489,7 +489,7 @@ namespace Blah
valid = true;
}
~D3D11_Shader()
~D3D11_Shader() override
{
if (vertex)
vertex->Release();
@ -511,12 +511,12 @@ namespace Blah
fragment_blob = nullptr;
}
virtual Vector<UniformInfo>& uniforms() override
Vector<UniformInfo>& uniforms() override
{
return uniform_list;
}
virtual const Vector<UniformInfo>& uniforms() const override
const Vector<UniformInfo>& uniforms() const override
{
return uniform_list;
}
@ -550,7 +550,7 @@ namespace Blah
index_buffer->Release();
}
virtual void index_data(IndexFormat format, const void* indices, i64 count) override
void index_data(IndexFormat format, const void* indices, i64 count) override
{
m_index_count = count;
@ -604,7 +604,7 @@ namespace Blah
}
}
virtual void vertex_data(const VertexFormat& format, const void* vertices, i64 count) override
void vertex_data(const VertexFormat& format, const void* vertices, i64 count) override
{
m_vertex_count = count;
@ -652,22 +652,22 @@ namespace Blah
}
}
virtual void instance_data(const VertexFormat& format, const void* instances, i64 count) override
void instance_data(const VertexFormat& format, const void* instances, i64 count) override
{
}
virtual i64 index_count() const override
i64 index_count() const override
{
return m_index_count;
}
virtual i64 vertex_count() const override
i64 vertex_count() const override
{
return m_vertex_count;
}
virtual i64 instance_count() const override
i64 instance_count() const override
{
return 0;
}

View File

@ -1,6 +1,6 @@
#include <blah/math/calc.h>
#include <math.h>
#include <stdlib.h>
#include <cmath>
#include <cstdlib>
using namespace Blah;

View File

@ -178,7 +178,7 @@ Color Color::operator*(float multiply) const
(int)(a * multiply));
}
Color& Color::operator=(const int rgb)
Color& Color::operator=(int rgb)
{
r = (u8)((rgb & 0xFF0000) >> 16);
g = (u8)((rgb & 0x00FF00) >> 8);

View File

@ -1,7 +1,7 @@
#include <blah/math/mat3x2.h>
#include <blah/math/vec2.h>
#include <string.h>
#include <math.h>
#include <cstring>
#include <cmath>
using namespace Blah;

View File

@ -1,7 +1,7 @@
#include <blah/streams/filestream.h>
#include <blah/core/common.h>
#include "../internal/platform_backend.h"
#include <string.h>
#include <cstring>
using namespace Blah;

View File

@ -1,5 +1,5 @@
#include <blah/streams/memorystream.h>
#include <string.h>
#include <cstring>
using namespace Blah;