Cleanup / Wextra

Added -Wextra and fixed warnings that appeared

Converted olcPixelGameEngine to unix line endings because it was
annoying me
This commit is contained in:
Thomas Muller 2021-05-01 17:30:05 -04:00
parent 439051e52c
commit 3029d22fd8
Signed by: thomas
GPG key ID: AF006EB730564952
4 changed files with 5115 additions and 5106 deletions

View file

@ -4,7 +4,7 @@ project(main)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
include_directories(src) include_directories(src)
add_definitions(-g) add_definitions(-g)

View file

@ -20,6 +20,8 @@ bool App::OnUserCreate()
bool App::OnUserUpdate(float delta) bool App::OnUserUpdate(float delta)
{ {
(void)delta;
Vector2<int> screen = {ScreenWidth(), ScreenHeight()}; Vector2<int> screen = {ScreenWidth(), ScreenHeight()};
Vector2<int> mouse = {GetMouseX(), GetMouseY()}; Vector2<int> mouse = {GetMouseX(), GetMouseY()};

View file

@ -3201,8 +3201,8 @@ namespace olc
PGEX::PGEX(bool bHook) { if(bHook) pge->pgex_Register(this); } PGEX::PGEX(bool bHook) { if(bHook) pge->pgex_Register(this); }
void PGEX::OnBeforeUserCreate() {} void PGEX::OnBeforeUserCreate() {}
void PGEX::OnAfterUserCreate() {} void PGEX::OnAfterUserCreate() {}
void PGEX::OnBeforeUserUpdate(float& fElapsedTime) {} void PGEX::OnBeforeUserUpdate(float& fElapsedTime) { (void)fElapsedTime; }
void PGEX::OnAfterUserUpdate(float fElapsedTime) {} void PGEX::OnAfterUserUpdate(float fElapsedTime) { (void)fElapsedTime; }
// Need a couple of statics as these are singleton instances // Need a couple of statics as these are singleton instances
// read from multiple locations // read from multiple locations
@ -3305,6 +3305,7 @@ namespace olc
olc::rcode CreateDevice(std::vector<void*> params, bool bFullScreen, bool bVSYNC) override olc::rcode CreateDevice(std::vector<void*> params, bool bFullScreen, bool bVSYNC) override
{ {
#if defined(OLC_PLATFORM_WINAPI) #if defined(OLC_PLATFORM_WINAPI)
(void)bFullScreen;
// Create Device Context // Create Device Context
glDeviceContext = GetDC((HWND)(params[0])); glDeviceContext = GetDC((HWND)(params[0]));
PIXELFORMATDESCRIPTOR pfd = PIXELFORMATDESCRIPTOR pfd =
@ -3329,6 +3330,7 @@ namespace olc
#endif #endif
#if defined(OLC_PLATFORM_X11) #if defined(OLC_PLATFORM_X11)
(void)bFullScreen;
using namespace X11; using namespace X11;
// Linux has tighter coupling between OpenGL and X11, so we store // Linux has tighter coupling between OpenGL and X11, so we store
// various "platform" handles in the renderer // various "platform" handles in the renderer
@ -3368,6 +3370,7 @@ namespace olc
#endif #endif
} }
#else #else
(void)bFullScreen;
glEnable(GL_TEXTURE_2D); // Turn on texturing glEnable(GL_TEXTURE_2D); // Turn on texturing
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
#endif #endif
@ -3520,6 +3523,7 @@ namespace olc
void ReadTexture(uint32_t id, olc::Sprite* spr) override void ReadTexture(uint32_t id, olc::Sprite* spr) override
{ {
(void)id;
glReadPixels(0, 0, spr->width, spr->height, GL_RGBA, GL_UNSIGNED_BYTE, spr->GetData()); glReadPixels(0, 0, spr->width, spr->height, GL_RGBA, GL_UNSIGNED_BYTE, spr->GetData());
} }
@ -4237,6 +4241,8 @@ namespace olc
olc::rcode SaveImageResource(olc::Sprite* spr, const std::string& sImageFile) override olc::rcode SaveImageResource(olc::Sprite* spr, const std::string& sImageFile) override
{ {
(void)spr;
(void)sImageFile;
return olc::rcode::OK; return olc::rcode::OK;
} }
}; };

View file

@ -7,6 +7,7 @@ class Vector2 {
public: public:
Vector2() = default; Vector2() = default;
Vector2(T x, T y) : m_x(x), m_y(y) {} Vector2(T x, T y) : m_x(x), m_y(y) {}
Vector2(const Vector2<T> &other) = default;
T x() { return m_x; } T x() { return m_x; }
T y() { return m_y; } T y() { return m_y; }