use std::any

This commit is contained in:
2025-05-05 13:17:38 -05:00
parent c2da1944d8
commit f35c58d3d6
9 changed files with 171 additions and 153 deletions

View File

@@ -48,31 +48,6 @@ namespace Archimedes {
WindowData& data = (WindowData&) *ptr;
switch(e->type) {
}
return true;
}, &data);*/
SDL_GL_MakeCurrent(w, gl_context);
SDL_GL_SetSwapInterval(1); // Enable vsync
SDL_ShowWindow(w);
}
~WindowSDL3() {
SDL_GL_DestroyContext(gl_context);
SDL_DestroyWindow(w);
SDL_Quit();
}
bool shouldClose() { return false; }
void doFrame() { restoreContext(); SDL_GL_SwapWindow(w); }
void pollEvents() {
while(SDL_PollEvent(&e)) {
switch(e.type) {
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
@@ -117,6 +92,69 @@ namespace Archimedes {
default:
break;
}
return true;
}, &data);*/
SDL_GL_MakeCurrent(w, gl_context);
SDL_GL_SetSwapInterval(1); // Enable vsync
SDL_ShowWindow(w);
}
~WindowSDL3() {
SDL_GL_DestroyContext(gl_context);
SDL_DestroyWindow(w);
SDL_Quit();
}
bool shouldClose() { return false; }
void doFrame() { restoreContext(); SDL_GL_SwapWindow(w); }
void pollEvents() {
while(SDL_PollEvent(&e)) {
switch(e.type) {
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
case SDL_EVENT_QUIT:
data.sendEvent(new CloseWindowEvent(data.window, &e));
break;
case SDL_EVENT_WINDOW_RESIZED:
width = e.window.data1;
height = e.window.data2;
data.sendEvent(new ResizeWindowEvent(e.window.data1, e.window.data2, &e));
break;
case SDL_EVENT_WINDOW_MOUSE_ENTER:
case SDL_EVENT_WINDOW_FOCUS_GAINED:
data.sendEvent(new FocusedWindowEvent(data.window, &e));
break;
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
case SDL_EVENT_WINDOW_FOCUS_LOST:
data.sendEvent(new FocusLostWindowEvent(data.window, &e));
break;
case SDL_EVENT_KEY_DOWN:
data.sendEvent(new KeyPressedWindowEvent(e.key.key, e.key.repeat ? 1 : 0, &e));
break;
case SDL_EVENT_KEY_UP:
data.sendEvent(new KeyReleasedWindowEvent(e.key.key, &e));
break;
case SDL_EVENT_MOUSE_MOTION:
data.sendEvent(new MouseMovedWindowEvent(e.motion.x, e.motion.y, &e));
break;
case SDL_EVENT_MOUSE_BUTTON_DOWN:
data.sendEvent(new MouseButtonPressedWindowEvent(e.button.button, &e));
break;
case SDL_EVENT_MOUSE_BUTTON_UP:
data.sendEvent(new MouseButtonReleasedWindowEvent(e.button.button, &e));
break;
case SDL_EVENT_MOUSE_WHEEL:
data.sendEvent(new ScrollWindowEvent(e.wheel.x, e.wheel.y, &e));
break;
default:
data.sendEvent(new AnonymousEvent(&e));
break;
}
}
}