Make it atleast start on Windows again.
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m53s
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m53s
TODO fix the mouse buttons and keyboard input. They currently segfault the program.
This commit is contained in:
@@ -33,7 +33,6 @@ enum class RenderingAPI: uint8_t {
|
||||
|
||||
namespace ReWindow
|
||||
{
|
||||
using high_res_timestamp = std::chrono::time_point<std::chrono::system_clock>;
|
||||
using J3ML::LinearAlgebra::Vector2;
|
||||
|
||||
class KeyboardState {
|
||||
@@ -176,6 +175,7 @@ namespace ReWindow
|
||||
/// A special-case function to change our internal size variable, without triggering event updates.
|
||||
void SetSizeWithoutEvent(const Vector2& size); //AAAAAHHHHHHHHH WINDOZE MAKING THINGS DIFFICULT :/ - Redacted.
|
||||
|
||||
void SetLastKnownWindowSize(const Vector2& size);
|
||||
|
||||
// TODO: Josh hates parameter-flags, it's not 1995 :/
|
||||
bool GetFlag(RWindowFlags flag) const;
|
||||
@@ -253,10 +253,10 @@ namespace ReWindow
|
||||
static void GLSwapBuffers();
|
||||
|
||||
/// Returns the current time, represented as a high-resolution std::chrono alias.
|
||||
static high_res_timestamp GetTimestamp();
|
||||
static std::chrono::steady_clock::time_point GetTimestamp();
|
||||
|
||||
/// Computes elapsed time from a start-point and end-point.
|
||||
float ComputeElapsedFrameTimeSeconds(high_res_timestamp start, high_res_timestamp end);
|
||||
float ComputeElapsedFrameTimeSeconds(std::chrono::steady_clock::time_point start, std::chrono::steady_clock::time_point end);
|
||||
|
||||
/// Updates internals to account for the latest calculated frame time.
|
||||
void UpdateFrameTiming(float frame_time);
|
||||
@@ -326,6 +326,8 @@ namespace ReWindow
|
||||
/// @see getCursorPos();
|
||||
Vector2 GetAccurateMouseCoordinates() const;
|
||||
|
||||
public:
|
||||
/// These unfortunately *have* to be public because of the poor design of the windows event loop.
|
||||
#pragma region Event Callers
|
||||
/// Executes event handlers for keyboard rele;ase events.
|
||||
void processKeyRelease (Key key);
|
||||
@@ -350,11 +352,7 @@ namespace ReWindow
|
||||
|
||||
void processMouseWheel(int scrolls);
|
||||
#pragma endregion
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
#pragma endregion
|
||||
};
|
||||
}
|
@@ -126,9 +126,9 @@ void RWindow::SetSizeWithoutEvent(const Vector2& size) {
|
||||
height = size.y;
|
||||
}
|
||||
|
||||
//void RWindow::setLastKnownWindowSize(const Vector2& size) {
|
||||
// lastKnownWindowSize = size;
|
||||
//}
|
||||
void RWindow::SetLastKnownWindowSize(const Vector2& size) {
|
||||
lastKnownWindowSize = size;
|
||||
}
|
||||
|
||||
void RWindow::SetRenderer(RenderingAPI api) {
|
||||
renderer = api;
|
||||
@@ -199,14 +199,14 @@ void RWindow::Refresh() {
|
||||
|
||||
}
|
||||
|
||||
float RWindow::ComputeElapsedFrameTimeSeconds(RWindow::high_res_timestamp start, RWindow::high_res_timestamp end) {
|
||||
float RWindow::ComputeElapsedFrameTimeSeconds(std::chrono::steady_clock::time_point start, std::chrono::steady_clock::time_point end) {
|
||||
auto frame_time = end - start;
|
||||
unsigned long int frame_time_us = std::chrono::duration_cast<std::chrono::microseconds>(frame_time).count();
|
||||
float frame_time_s = frame_time_us / (1000.f * 1000.f);
|
||||
return frame_time_s;
|
||||
}
|
||||
|
||||
RWindow::high_res_timestamp RWindow::GetTimestamp() {
|
||||
std::chrono::steady_clock::time_point RWindow::GetTimestamp() {
|
||||
return std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
|
@@ -14,7 +14,7 @@ HGLRC glContext;
|
||||
void raise() { SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); }
|
||||
void lower() { SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); }
|
||||
|
||||
void RWindow::setFlag(RWindowFlags flag, bool state) {
|
||||
void RWindow::SetFlag(RWindowFlags flag, bool state) {
|
||||
flags[(int) flag] = state;
|
||||
if (flag == RWindowFlags::RESIZABLE && !state) {
|
||||
RECT rect;
|
||||
@@ -24,8 +24,12 @@ void RWindow::setFlag(RWindowFlags flag, bool state) {
|
||||
SetWindowLong(hwnd, GWL_STYLE, style);
|
||||
SetWindowPos(hwnd, nullptr, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER);
|
||||
}
|
||||
}wasd
|
||||
void RWindow::SetResizable(bool resizable) {
|
||||
SetFlag(RWindowFlags::RESIZABLE, resizable);;
|
||||
}
|
||||
|
||||
|
||||
void RWindow::PollEvents() {
|
||||
MSG msg;
|
||||
while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
|
||||
@@ -41,7 +45,7 @@ void RWindow::SetSize(int newWidth, int newHeight) {
|
||||
SetWindowPos(hwnd, nullptr, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER);
|
||||
}
|
||||
|
||||
Vector2 RWindow::getCursorPos() const {
|
||||
Vector2 RWindow::GetAccurateMouseCoordinates() const {
|
||||
POINT point;
|
||||
GetCursorPos(&point);
|
||||
ScreenToClient(hwnd, &point);
|
||||
@@ -68,7 +72,7 @@ void RWindow::SetPos(int x, int y) {
|
||||
}
|
||||
|
||||
void RWindow::SetPos(const Vector2& pos) {
|
||||
setPos(pos.x, pos.y);
|
||||
SetPos(pos.x, pos.y);
|
||||
}
|
||||
|
||||
void RWindow::Fullscreen() {
|
||||
@@ -83,7 +87,7 @@ void RWindow::RestoreFromFullscreen() {
|
||||
SetWindowPos(hwnd, nullptr, 0, 0, width, height, SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER);
|
||||
}
|
||||
|
||||
void RWindow::setVsyncEnabled(bool b) {
|
||||
void RWindow::SetVsyncEnabled(bool b) {
|
||||
typedef BOOL(WINAPI* PFNWGLSWAPINTERVALEXTPROC)(int interval);
|
||||
auto wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress("wglSwapIntervalEXT");
|
||||
|
||||
@@ -91,10 +95,6 @@ void RWindow::setVsyncEnabled(bool b) {
|
||||
wglSwapIntervalEXT(b ? 1 : 0);
|
||||
}
|
||||
|
||||
bool RWindow::isFullscreen() const {
|
||||
return fullscreenmode;
|
||||
}
|
||||
|
||||
RWindow* eWindow = nullptr;
|
||||
KeyboardState* pKeyboard = nullptr;
|
||||
KeyboardState* cKeyboard = nullptr;
|
||||
@@ -113,10 +113,10 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
|
||||
case WM_SIZE: {
|
||||
eWindow->setSizeWithoutEvent({(float) LOWORD(lParam), (float) HIWORD(lParam)});
|
||||
eWindow->SetSizeWithoutEvent({(float) LOWORD(lParam), (float) HIWORD(lParam)});
|
||||
auto eventData = WindowResizeRequestEvent();
|
||||
eventData.Size = {(float) eWindow->getWidth(), (float) eWindow->getHeight()};
|
||||
eWindow->setLastKnownWindowSize({(float) eWindow->getWidth(), (float) eWindow->getHeight()});
|
||||
eventData.Size = {(float) eWindow->GetWidth(), (float) eWindow->GetHeight()};
|
||||
eWindow->SetLastKnownWindowSize({(float) eWindow->GetWidth(), (float) eWindow->GetHeight()});
|
||||
|
||||
// TODO: Implement eWindow->processOnResize()
|
||||
|
||||
@@ -125,7 +125,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
|
||||
//Just to be absolutely sure the OpenGL viewport resizes along with the window.
|
||||
glViewport(0, 0, eWindow->getWidth(), eWindow->getHeight());
|
||||
glViewport(0, 0, eWindow->GetWidth(), eWindow->GetHeight());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
eWindow->processFocusIn();
|
||||
|
||||
eWindow->setFlag(RWindowFlags::IN_FOCUS, true);
|
||||
eWindow->SetFlag(RWindowFlags::IN_FOCUS, true);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -141,12 +141,12 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
eWindow->processFocusOut();
|
||||
|
||||
eWindow->setFlag(RWindowFlags::IN_FOCUS, false);
|
||||
eWindow->SetFlag(RWindowFlags::IN_FOCUS, false);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_SETCURSOR: {
|
||||
if (LOWORD(lParam) == HTCLIENT && eWindow->getCursorVisible() == false)
|
||||
if (LOWORD(lParam) == HTCLIENT && eWindow->GetCursorVisible() == false)
|
||||
SetCursor(nullptr);
|
||||
break;
|
||||
}
|
||||
@@ -297,18 +297,6 @@ void RWindow::GLSwapBuffers() {
|
||||
SwapBuffers(hdc);
|
||||
}
|
||||
|
||||
void RWindow::Refresh() {
|
||||
// TODO: Implement refresh time keeping
|
||||
OnRefresh(0.f);
|
||||
|
||||
// TODO: Check if mouse coords have changed, only then fire OnMouseMove event
|
||||
Vector2 mouse_coords = getCursorPos();
|
||||
|
||||
auto eventData = MouseMoveEvent(mouse_coords);
|
||||
OnMouseMove(eventData);
|
||||
}
|
||||
|
||||
std::string RWindow::getGraphicsDriverVendor()
|
||||
{
|
||||
std::string RWindow::getGraphicsDriverVendor() {
|
||||
return std::string(reinterpret_cast<const char*>(glGetString(GL_VENDOR)));
|
||||
}
|
||||
|
Reference in New Issue
Block a user