wrap imgui impl funcs

This commit is contained in:
2025-05-04 22:51:45 -05:00
parent 853881e5e8
commit 2820387851
4 changed files with 136 additions and 78 deletions

View File

@@ -42,16 +42,16 @@ namespace Archimedes {
std::abort();
}
SDL_AddEventWatch([](void* ptr, SDL_Event* e) -> bool {
/*SDL_AddEventWatch([](void* ptr, SDL_Event* e) -> bool {
WindowData& d = (WindowData&) *ptr;
WindowData& data = (WindowData&) *ptr;
switch(e->type) {
}
return true;
}, &data);
}, &data);*/
SDL_GL_MakeCurrent(w, gl_context);
@@ -65,6 +65,8 @@ namespace Archimedes {
SDL_Quit();
}
bool shouldClose() { return false; }
void doFrame() { restoreContext(); SDL_GL_SwapWindow(w); }
void pollEvents() {
@@ -74,53 +76,53 @@ namespace Archimedes {
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
case SDL_EVENT_QUIT:
d.sendEvent(new CloseWindowEvent(d.window));
data.sendEvent(new CloseWindowEvent(data.window));
break;
case SDL_EVENT_WINDOW_RESIZED:
w = e.window.data1;
h = e.window.data2;
d.sendEvent(new ResizeWindowEvent(e.window.data1, e.window.data2));
width = e.window.data1;
height = e.window.data2;
data.sendEvent(new ResizeWindowEvent(e.window.data1, e.window.data2));
break;
case SDL_EVENT_WINDOW_MOUSE_ENTER:
case SDL_EVENT_WINDOW_FOCUS_GAINED:
d.sendEvent(new FocusedWindowEvent(d.window));
data.sendEvent(new FocusedWindowEvent(data.window));
break;
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
case SDL_EVENT_WINDOW_FOCUS_LOST:
d.sendEvent(new FocusLostWindowEvent(d.window));
data.sendEvent(new FocusLostWindowEvent(data.window));
break;
case SDL_EVENT_KEY_DOWN:
d.sendEvent(new KeyPressedWindowEvent(e.key.key, e.key.repeat ? 1 : 0));
data.sendEvent(new KeyPressedWindowEvent(e.key.key, e.key.repeat ? 1 : 0));
break;
case SDL_EVENT_KEY_UP:
d.sendEvent(new KeyReleasedWindowEvent(e.key.key));
data.sendEvent(new KeyReleasedWindowEvent(e.key.key));
break;
case SDL_EVENT_TEXT_EDITING:
break;
case SDL_EVENT_TEXT_INPUT:
break;
case SDL_EVENT_MOUSE_MOTION:
d.sendEvent(new MouseMovedWindowEvent(e.motion.x, e.motion.y));
data.sendEvent(new MouseMovedWindowEvent(e.motion.x, e.motion.y));
break;
case SDL_EVENT_MOUSE_BUTTON_DOWN:
d.sendEvent(new MouseButtonPressedWindowEvent(e.button.button));
data.sendEvent(new MouseButtonPressedWindowEvent(e.button.button));
break;
case SDL_EVENT_MOUSE_BUTTON_UP:
d.sendEvent(new MouseButtonReleasedWindowEvent(e.button.button));
data.sendEvent(new MouseButtonReleasedWindowEvent(e.button.button));
break;
case SDL_EVENT_MOUSE_WHEEL:
d.sendEvent(new ScrollWindowEvent(e.wheel.x, e.wheel.y));
data.sendEvent(new ScrollWindowEvent(e.wheel.x, e.wheel.y));
break;
default:
break;
}
}
void restoreContext() { SDL_GLMakeCurrent(w, gl_context); }
void restoreContext() { SDL_GL_MakeCurrent(w, gl_context); }
void getSize(int& w, int& h) {
w = this->w;
h = this->h;
w = this->width;
h = this->height;
}
SDL_Window* getWindow() { return w; }
@@ -131,7 +133,7 @@ namespace Archimedes {
private:
SDL_Window* w;
int w = 0, h = 0;
int width = 0, height = 0;
SDL_GLContext gl_context;
SDL_Event e;