2023-11-28 00:44:47 -05:00
|
|
|
#pragma once
|
|
|
|
/*
|
|
|
|
* Created by Brett on 28/11/23.
|
|
|
|
* Licensed under GNU General Public License V3.0
|
|
|
|
* See LICENSE file for license detail
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BLT_WITH_GRAPHICS_TEMPLATE_WINDOW_H
|
|
|
|
#define BLT_WITH_GRAPHICS_TEMPLATE_WINDOW_H
|
|
|
|
|
2023-12-16 23:52:18 -05:00
|
|
|
#include <blt/gfx/gl_includes.h>
|
2023-11-28 00:44:47 -05:00
|
|
|
#include <GLFW/glfw3.h>
|
2023-11-28 01:56:10 -05:00
|
|
|
#include <functional>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
2023-11-28 00:44:47 -05:00
|
|
|
|
2023-11-28 01:56:10 -05:00
|
|
|
namespace blt::gfx
|
|
|
|
{
|
|
|
|
struct window_context
|
|
|
|
{
|
|
|
|
std::int32_t GL_MAJOR = 4;
|
|
|
|
std::int32_t GL_MINOR = 6;
|
|
|
|
std::int32_t DOUBLE_BUFFER = GLFW_TRUE;
|
|
|
|
std::int32_t GL_PROFILE = GLFW_OPENGL_CORE_PROFILE;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct window_data
|
|
|
|
{
|
|
|
|
std::string title;
|
|
|
|
std::int32_t width;
|
|
|
|
std::int32_t height;
|
|
|
|
std::function<void()> init;
|
|
|
|
std::function<void(std::int32_t, std::int32_t)> update;
|
|
|
|
|
|
|
|
window_context context{};
|
|
|
|
std::int32_t sync_interval = 0;
|
|
|
|
|
|
|
|
window_data(std::string title, std::function<void()> init, std::function<void(std::int32_t, std::int32_t)> update, std::int32_t width = 640,
|
|
|
|
std::int32_t height = 480):
|
|
|
|
title(std::move(title)), width(width), height(height), init(std::move(init)), update(std::move(update))
|
|
|
|
{}
|
|
|
|
|
|
|
|
window_data& setContext(const window_context& ctx)
|
|
|
|
{
|
|
|
|
context = ctx;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
window_data& setSyncInterval(std::int32_t sync)
|
|
|
|
{
|
|
|
|
sync_interval = sync;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void init(const window_data& data);
|
|
|
|
|
2023-12-15 17:24:59 -05:00
|
|
|
double getMouseX();
|
|
|
|
|
|
|
|
double getMouseY();
|
|
|
|
|
|
|
|
double getMouseDX();
|
|
|
|
|
|
|
|
double getMouseDY();
|
|
|
|
|
|
|
|
void lockCursor();
|
|
|
|
|
|
|
|
void unlockCursor();
|
|
|
|
|
|
|
|
bool isCursorLocked();
|
|
|
|
|
|
|
|
bool isCursorInWindow();
|
|
|
|
|
|
|
|
void setRawInput(bool state);
|
|
|
|
|
|
|
|
bool isRawInput();
|
|
|
|
|
|
|
|
void setClipboard(const std::string& str);
|
|
|
|
|
|
|
|
std::string getClipboard();
|
|
|
|
|
2023-12-15 17:43:00 -05:00
|
|
|
bool isMousePressed(int button);
|
|
|
|
|
|
|
|
bool isKeyPressed(int key);
|
|
|
|
|
2023-12-29 18:38:07 -05:00
|
|
|
double getFrameDeltaSeconds();
|
|
|
|
|
|
|
|
double getFrameDeltaMilliseconds();
|
|
|
|
|
|
|
|
std::int64_t getFrameDelta();
|
|
|
|
|
2023-11-28 01:56:10 -05:00
|
|
|
void cleanup();
|
|
|
|
}
|
2023-11-28 00:44:47 -05:00
|
|
|
|
|
|
|
#endif //BLT_WITH_GRAPHICS_TEMPLATE_WINDOW_H
|