mirror of
https://github.com/NoelFB/blah.git
synced 2024-11-28 16:58:57 +08:00
fixing various clang warnings
This commit is contained in:
parent
3913cf7c02
commit
4351d77f73
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <blah/core/common.h>
|
||||
#include <blah/math/vec2.h>
|
||||
#include <blah/containers/str.h>
|
||||
|
||||
// These are generally copied from the SDL2 Scancode Keys
|
||||
#define BLAH_KEY_DEFINITIONS \
|
||||
|
@ -255,12 +256,6 @@ namespace Blah
|
|||
|
||||
// maximum number of keys the input will track
|
||||
constexpr int max_keyboard_keys = 512;
|
||||
|
||||
// maximum length of text input that can be received per-frame
|
||||
constexpr int max_text_input = 256;
|
||||
|
||||
// maximum number of nodes within a virtual input device
|
||||
constexpr int max_virtual_nodes = 32;
|
||||
}
|
||||
|
||||
struct ControllerState
|
||||
|
@ -314,7 +309,7 @@ namespace Blah
|
|||
bool down[Input::max_keyboard_keys];
|
||||
bool released[Input::max_keyboard_keys];
|
||||
u64 timestamp[Input::max_keyboard_keys];
|
||||
char text[Input::max_text_input];
|
||||
String text;
|
||||
};
|
||||
|
||||
struct MouseState
|
||||
|
|
|
@ -44,7 +44,7 @@ void Str::reserve(int size)
|
|||
{
|
||||
char* local = data();
|
||||
m_buffer = new char[m_capacity];
|
||||
strncpy(m_buffer, local, m_local_size);
|
||||
memcpy(m_buffer, local, m_local_size);
|
||||
m_buffer[m_local_size] = '\0';
|
||||
}
|
||||
// expand from empty buffer
|
||||
|
|
|
@ -79,7 +79,7 @@ float SpriteFont::width_of(const String& text) const
|
|||
float width = 0;
|
||||
float line_width = 0;
|
||||
|
||||
u32 last;
|
||||
u32 last = 0;
|
||||
for (int i = 0; i < text.length(); i ++)
|
||||
{
|
||||
if (text[i] == '\n')
|
||||
|
|
|
@ -22,6 +22,7 @@ VertexFormat::VertexFormat(std::initializer_list<VertexAttribute> attributes, in
|
|||
{
|
||||
switch (it.type)
|
||||
{
|
||||
case VertexType::None: break;
|
||||
case VertexType::Float: stride += 4; break;
|
||||
case VertexType::Float2: stride += 8; break;
|
||||
case VertexType::Float3: stride += 12; break;
|
||||
|
|
|
@ -5,28 +5,36 @@
|
|||
|
||||
using namespace Blah;
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-function"
|
||||
|
||||
#define STBTT_STATIC
|
||||
#define STB_TRUETYPE_IMPLEMENTATION
|
||||
#include "../third_party/stb_truetype.h"
|
||||
|
||||
String GetName(stbtt_fontinfo* font, int nameId)
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
namespace
|
||||
{
|
||||
int length = 0;
|
||||
String get_font_name(stbtt_fontinfo* font, int nameId)
|
||||
{
|
||||
int length = 0;
|
||||
|
||||
// get the name
|
||||
const u16* ptr = (const u16*)stbtt_GetFontNameStr(font, &length,
|
||||
STBTT_PLATFORM_ID_MICROSOFT,
|
||||
STBTT_MS_EID_UNICODE_BMP,
|
||||
STBTT_MS_LANG_ENGLISH,
|
||||
nameId);
|
||||
// get the name
|
||||
const u16* ptr = (const u16*)stbtt_GetFontNameStr(font, &length,
|
||||
STBTT_PLATFORM_ID_MICROSOFT,
|
||||
STBTT_MS_EID_UNICODE_BMP,
|
||||
STBTT_MS_LANG_ENGLISH,
|
||||
nameId);
|
||||
|
||||
// we want the size in wide chars
|
||||
length /= 2;
|
||||
// we want the size in wide chars
|
||||
length /= 2;
|
||||
|
||||
String str;
|
||||
if (length > 0)
|
||||
str.append_utf16(ptr, ptr + length, Calc::is_little_endian());
|
||||
return str;
|
||||
String str;
|
||||
if (length > 0)
|
||||
str.append_utf16(ptr, ptr + length, Calc::is_little_endian());
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
Font::Font()
|
||||
|
@ -112,8 +120,8 @@ void Font::load(Stream& stream)
|
|||
m_font = new stbtt_fontinfo();
|
||||
auto fn = (stbtt_fontinfo*)m_font;
|
||||
stbtt_InitFont(fn, m_data, 0);
|
||||
m_family_name = GetName(fn, 1);
|
||||
m_style_name = GetName(fn, 2);
|
||||
m_family_name = get_font_name(fn, 1);
|
||||
m_style_name = get_font_name(fn, 2);
|
||||
|
||||
// properties
|
||||
stbtt_GetFontVMetrics(fn, &m_ascent, &m_descent, &m_line_gap);
|
||||
|
|
|
@ -48,10 +48,9 @@ void InputBackend::frame()
|
|||
g_next_state.mouse.pressed[i] = false;
|
||||
g_next_state.mouse.released[i] = false;
|
||||
}
|
||||
g_next_state.mouse.wheel = Point::zero;
|
||||
|
||||
for (int i = 0; i < Blah::Input::max_text_input; i++)
|
||||
g_next_state.keyboard.text[i] = 0;
|
||||
g_next_state.mouse.wheel = Point::zero;
|
||||
g_next_state.keyboard.text.clear();
|
||||
|
||||
for (int i = 0; i < Blah::Input::max_controllers; i++)
|
||||
{
|
||||
|
@ -139,7 +138,7 @@ void InputBackend::on_key_up(Key key)
|
|||
|
||||
void InputBackend::on_text_utf8(const char* text)
|
||||
{
|
||||
strncat(g_next_state.keyboard.text, text, Blah::Input::max_text_input);
|
||||
g_next_state.keyboard.text += text;
|
||||
}
|
||||
|
||||
void InputBackend::on_controller_connect(int index, const char* name, int is_gamepad, int button_count, int axis_count, u16 vendor, u16 product, u16 version)
|
||||
|
|
|
@ -145,6 +145,7 @@ namespace Blah
|
|||
m_size = width * height * 4;
|
||||
is_depth_stencil = true;
|
||||
break;
|
||||
case TextureFormat::None:
|
||||
case TextureFormat::Count:
|
||||
break;
|
||||
}
|
||||
|
@ -698,7 +699,7 @@ namespace Blah
|
|||
state.last_size = Point(App::draw_width(), App::draw_height());
|
||||
|
||||
// Define Swap Chain
|
||||
DXGI_SWAP_CHAIN_DESC desc = { 0 };
|
||||
DXGI_SWAP_CHAIN_DESC desc;
|
||||
desc.BufferDesc.RefreshRate.Numerator = 0;
|
||||
desc.BufferDesc.RefreshRate.Denominator = 1;
|
||||
desc.BufferDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
|
@ -707,8 +708,9 @@ namespace Blah
|
|||
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
desc.BufferCount = 1;
|
||||
desc.OutputWindow = (HWND)PlatformBackend::d3d11_get_hwnd();
|
||||
//desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
||||
desc.Windowed = true;
|
||||
desc.Flags = 0;
|
||||
desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||
|
||||
// Creation Flags
|
||||
UINT flags = D3D11_CREATE_DEVICE_SINGLETHREADED;
|
||||
|
@ -1246,6 +1248,8 @@ namespace Blah
|
|||
switch (it.type)
|
||||
{
|
||||
case UniformType::None: break;
|
||||
case UniformType::Texture2D: break;
|
||||
case UniformType::Sampler2D: break;
|
||||
case UniformType::Float: size = 1; break;
|
||||
case UniformType::Float2: size = 2; break;
|
||||
case UniformType::Float3: size = 3; break;
|
||||
|
|
Loading…
Reference in New Issue
Block a user