Skip to content
Snippets Groups Projects
Commit 334fec28 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

clean up some linting errors

parent 7243ff56
No related branches found
No related tags found
No related merge requests found
print("File has been loaded!")
print(state);
\ No newline at end of file
-- when the scene loads, switch to topdown to show state integration
--switch_scene(state, "topdown");
\ No newline at end of file
......@@ -21,7 +21,6 @@
#include <string>
#include <stdexcept>
#include <GLFW/glfw3.h>
#include <spdlog/spdlog.h>
namespace fggl::display::glfw {
......@@ -34,37 +33,37 @@ namespace fggl::display::glfw {
fgglWindow->framesize(width, height);
}
static void fggl_input_cursor(GLFWwindow *window, double x, double y) {
static void fggl_input_cursor(GLFWwindow *window, double xPos, double yPos) {
auto &input = GlfwInputManager::instance();
auto *fgglWin = static_cast<Window *>(glfwGetWindowUserPointer(window));
#ifndef FGGL_INPUT_SCREEN_COORDS
// convert to nice ranges...
x = (x / fgglWin->width() * 2) - 1.0; // [-1, 1]
y = (y / fgglWin->height() * 2) - 1.0; // [-1, 1]
xPos = (xPos / fgglWin->width() * 2) - 1.0; // [-1, 1]
yPos = (yPos / fgglWin->height() * 2) - 1.0; // [-1, 1]
#endif
// inform the input system
input.onMouseMove(x, y);
input.onMouseMove(xPos, yPos);
}
static void fggl_input_scroll(GLFWwindow *window, double x, double y) {
static void fggl_input_scroll(GLFWwindow */*window*/, double xPos, double yPos) {
auto &input = GlfwInputManager::instance();
input.onMouseScroll(x, y);
input.onMouseScroll(xPos, yPos);
}
static void fggl_input_mouse_btn(GLFWwindow *window, int btn, int action, int mods) {
static void fggl_input_mouse_btn(GLFWwindow */*window*/, int btn, int action, int /*mods*/) {
auto &input = GlfwInputManager::instance();
input.onMouseButton(btn, action == GLFW_PRESS);
}
static void fggl_input_keyboard(GLFWwindow *window, int key, int scancode, int action, int mods) {
static void fggl_input_keyboard(GLFWwindow */*window*/, int /*key*/, int scancode, int action, int /*mods*/) {
auto &input = GlfwInputManager::instance();
input.onKeyEvent(scancode, action == GLFW_PRESS || action == GLFW_REPEAT);
}
static void fggl_update_joystick(fggl::input::GamepadInput &input, int jid) {
bool isGamepad = glfwJoystickIsGamepad(jid);
bool isGamepad = (glfwJoystickIsGamepad(jid) == GLFW_TRUE);
if (isGamepad) {
if (!input.present(jid)) {
......@@ -144,7 +143,7 @@ namespace fggl::display::glfw {
GlfwContext::~GlfwContext() {
glfwTerminate();
spdlog::debug("[glfw] context terminated");
debug::trace("[glfw] context terminated");
}
void GlfwContext::pollEvents() {
......@@ -157,7 +156,9 @@ namespace fggl::display::glfw {
Window::Window(std::shared_ptr<GlfwContext> context, gfx::WindowGraphics *graphics)
: m_context(std::move(context)), m_window(nullptr), m_framesize() {
spdlog::debug("[glfw] creating window");
// don't iconify when focus is lost.
glfwWindowHint( GLFW_AUTO_ICONIFY, GLFW_FALSE );
// FIXME - this ties the graphics API before window creation
auto graphicsConfig = graphics->config();
......@@ -185,8 +186,6 @@ namespace fggl::display::glfw {
// bind the graphics API
glfwMakeContextCurrent(m_window);
m_graphics = graphics->createMain(*this);
spdlog::debug("[glfw] window creation complete");
}
Window::~Window() {
......
......@@ -22,19 +22,9 @@ namespace fggl::math::phs3d {
max = {-FLT_MAX, -FLT_MAX, -FLT_MAX};
}
void AABB::add(const math::vec3 &p) {
if (p.x < min.x)
min.x = p.x;
if (p.x > max.x)
max.x = p.x;
if (p.y < min.y)
min.y = p.y;
if (p.y > min.y)
max.y = p.y;
if (p.z < min.z)
min.z = p.z;
if (p.z > max.z)
max.z = p.z;
void AABB::add(const math::vec3 &point) {
min = minElm(min, point);
max = maxElm(max, point);
}
AABB AABB::fromPoints(const std::vector<math::vec3> &points) {
......
......@@ -103,10 +103,8 @@ namespace fggl::debug {
template<typename ...T>
inline void trace(FmtType fmt, T &&...args) {
#ifdef FGGL_LOG_TRACE
auto fmtStr = fmt::format(fmt::runtime(fmt), args...);
fmt::print(CERR_FMT, level_to_string(Level::trace), fmtStr);
#endif
auto fmtStr = fmt::format(fmt::runtime(fmt), args...);
fmt::print(CERR_FMT, level_to_string(Level::trace), fmtStr);
}
}
......
......@@ -58,7 +58,7 @@ namespace fggl::entity::grid {
}
private:
constexpr static math::vec2i size = math::vec2i(width, height);
constexpr static math::vec2i size = math::vec2ui(width, height);
std::array<T, size.x * size.y> m_cells;
inline uint32_t getCellIndex(GridPos pos) const {
......@@ -111,32 +111,32 @@ namespace fggl::entity::grid {
void clear() {
WallState noWall;
for (auto x = 0U; x<width; ++x) {
for (auto y=0U; y<height; ++y) {
m_floors.set({x, y}, 0);
m_walls.set({x, y}, noWall);
for (auto xPos = 0U; xPos<width; ++xPos) {
for (auto yPos=0U; yPos<height; ++yPos) {
m_floors.set({xPos, yPos}, 0);
m_walls.set({xPos, yPos}, noWall);
}
}
}
inline FloorTile& floorAt(uint32_t x, uint32_t y) {
return m_tiles.m_floors.at( m_floors.get({x, y}) );
inline FloorTile& floorAt(uint32_t xPos, uint32_t yPos) {
return m_tiles.m_floors.at( m_floors.get({xPos, yPos}) );
}
inline void setFloorAt(uint32_t x, uint32_t y, uint32_t floor) {
m_floors.set({x, y}, floor);
inline void setFloorAt(uint32_t xPos, uint32_t yPos, uint32_t floor) {
m_floors.set({xPos, yPos}, floor);
}
inline WallTile& wallAt(uint32_t x, uint32_t y, bool north) {
inline WallTile& wallAt(uint32_t xPos, uint32_t yPos, bool north) {
if (north) {
return m_tiles.m_walls.at(m_walls.get({x, y}).north);
return m_tiles.m_walls.at(m_walls.get({xPos, yPos}).north);
} else {
return m_tiles.m_walls.at(m_walls.get({x, y}).west);
return m_tiles.m_walls.at(m_walls.get({xPos, yPos}).west);
}
}
inline void setWallAt(uint32_t x, uint32_t y, bool north, uint32_t wall) {
auto& state = m_walls.get({x, y});
inline void setWallAt(uint32_t xPos, uint32_t yPos, bool north, uint32_t wall) {
auto& state = m_walls.get({xPos, yPos});
if (north) {
state.north = wall;
} else {
......
......@@ -127,7 +127,7 @@ namespace fggl::math {
}
static data::Vertex2D pointToVertex(const math::vec2 &point) {
return data::Vertex2D{point, {1.0f, 1.0f, 1.0f}};
return data::Vertex2D{point, {1.0F, 1.0F, 1.0F}, {0.0F, 0.0F}};
}
/**
......
......@@ -91,7 +91,7 @@ namespace fggl::math {
/**
* a 2D unsigned integer vector
*/
using vec2ui = glm::ivec2;
using vec2ui = glm::uvec2;
/**
* A 2x2 floating-point matrix.
......@@ -120,6 +120,22 @@ namespace fggl::math {
constexpr static const math::vec3 AXIS_Y{0.0F, 1.0F, 0.0F};
constexpr static const math::vec3 AXIS_Z{0.0F, 0.0F, 1.0F};
constexpr auto minElm(vec3 a, vec3 b) -> vec3{
return {
a.x < b.x ? a.x : b.x,
a.y < b.y ? a.y : b.y,
a.z < b.z ? a.z : b.z
};
}
constexpr auto maxElm(vec3 a, vec3 b) -> vec3 {
return {
a.x > b.x ? a.x : b.x,
a.y > b.y ? a.y : b.y,
a.z > b.z ? a.z : b.z
};
}
// fastFloor from OpenSimplex2
inline int fastFloor(double x) {
int xi = (int) x;
......
......@@ -94,8 +94,7 @@ namespace fggl::util {
// formatter
template<> struct fmt::formatter<fggl::util::GUID> {
constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {
auto it = ctx.begin(), end = ctx.end();
return it;
return ctx.begin();
}
template <typename FormatContext>
......
......@@ -19,11 +19,40 @@
#include "fggl/script/lua/engine.hpp"
#include "fggl/debug/logging.hpp"
#include "fggl/scenes/game.hpp"
#include "fggl/entity/loader/loader.hpp"
#include <cassert>
extern "C" {
int lua_switch_scene(lua_State *L) {
auto *scene = lua_tostring(L, -1);
auto *statePtr = (fggl::AppState *) (lua_topointer(L, -2));
statePtr->owner().change_state(scene);
return 0;
}
int lua_create_entity(lua_State *L) {
/*auto *prototype = lua_tostring(L, -1);
auto *statePtr = (fggl::scenes::Game*) (lua_topointer(L, -2));
auto *factory = statePtr->owner().service<fggl::entity::EntityFactory>();
//factory->create( statePtr->world(), , [](){} );
*/
return 0;
}
static void open_lua_fggl(lua_State *L) {
// switch scene
lua_pushcfunction(L, lua_switch_scene);
lua_setglobal(L, "switch_scene");
}
}
namespace fggl::script::lua {
LuaScriptProvider::LuaScriptProvider(data::Storage *storage) : m_storage(storage) {
}
LuaScriptEngine *LuaScriptProvider::create() {
......@@ -32,6 +61,7 @@ namespace fggl::script::lua {
LuaScriptEngine::LuaScriptEngine(data::Storage* storage) : m_state(luaL_newstate()), m_storage(storage) {
luaL_openlibs(m_state);
open_lua_fggl(m_state);
}
LuaScriptEngine::~LuaScriptEngine() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment