Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • gamedev/fggl
  • onuralpsezer/fggl
2 results
Show changes
Showing
with 8451 additions and 171 deletions
......@@ -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)) {
......@@ -99,7 +98,7 @@ namespace fggl::display::glfw {
auto &gamepadCtl = input.gamepads();
for (int jid = 0; jid < GLFW_JOYSTICK_LAST; jid++) {
if (glfwJoystickPresent(jid)) {
if (glfwJoystickPresent(jid) == GLFW_TRUE) {
fggl_update_joystick(gamepadCtl, jid);
} else {
gamepadCtl.setActive(jid, false);
......@@ -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();
......@@ -184,12 +185,15 @@ namespace fggl::display::glfw {
// bind the graphics API
glfwMakeContextCurrent(m_window);
m_graphics = std::unique_ptr<gfx::Graphics>(graphics->create(*this));
spdlog::debug("[glfw] window creation complete");
m_graphics = graphics->createMain(*this);
}
Window::~Window() {
if ( m_graphics != nullptr ) {
delete m_graphics;
m_graphics = nullptr;
}
if (m_window != nullptr) {
// prevent dangling pointers
glfwSetWindowUserPointer(m_window, nullptr);
......@@ -215,14 +219,14 @@ namespace fggl::display::glfw {
glfwMakeContextCurrent(m_window);
}
fggl::math::vec2i Window::frameSize() const {
auto Window::frameSize() const -> fggl::math::vec2i {
assert(m_window != nullptr);
math::vec2i size;
glfwGetFramebufferSize(m_window, &size.x, &size.y);
return size;
}
bool Window::wantClose() const {
auto Window::wantClose() const -> bool {
assert(m_window != nullptr);
return glfwWindowShouldClose(m_window) == GLFW_TRUE;
}
......
target_sources( fggl
PRIVATE
hexagon.cpp
)
\ No newline at end of file
/*
* This file is part of FGGL.
*
* FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with FGGL.
* If not, see <https://www.gnu.org/licenses/>.
*/
//
// Created by webpigeon on 10/12/22.
//
#include "fggl/grid/hexagon.hpp"
namespace fggl::grid {
std::vector<IntHex> lineTo(const IntHex& start, const IntHex& end) {
const int distance = start.distance(end);
std::vector<IntHex> line;
for (auto i=0; i < distance; ++i) {
line.push_back( round2(hexLerp(start, end, 1.0F/distance * i)) );
}
return line;
}
} // namespace fggl:grid
target_sources( ${PROJECT_NAME}
PRIVATE
widget.cpp
widgets.cpp
containers.cpp
fonts.cpp
model/parser.cpp
model/structure.cpp
renderer/renderer.cpp
)
find_package(Freetype)
target_link_libraries(${PROJECT_NAME} PUBLIC Freetype::Freetype)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -13,7 +13,6 @@
*/
#include "fggl/math/triangulation.hpp"
#include <iostream>
namespace fggl::math {
......@@ -29,7 +28,7 @@ namespace fggl::math {
// deal with the indices
const auto nTris = polygon.size() - 2;
for (auto i = 0u; i < nTris; i++) {
for (auto i = 0U; i < nTris; i++) {
mesh.add_index(firstIdx);
mesh.add_index(prevIdx);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.