-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
49 lines (39 loc) · 1.19 KB
/
main.cpp
File metadata and controls
49 lines (39 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <SDL3/SDL.h>
#include <cstdio>
#include "Window.h"
#include "GamepadManager.h"
#include "GUI.h"
int main(int argc, char **argv) {
// 1. Initialize SDL subsystems
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD) == false) {
std::cout << "Could not initialize SDL: " << SDL_GetError() << std::endl;
return -1;
}
Window window("Gamepad Tester", 1200, 750);
//
GamepadManager gamepad;
GUI gui(window, gamepad);
// --- State Variables ---
bool running = true;
SDL_Event event;
// Main Application Loop
while (running) {
// Events
while (SDL_PollEvent(&event)) {
ImGui_ImplSDL3_ProcessEvent(&event);
gamepad.passEvent(&event);
if (event.type == SDL_EVENT_QUIT) running = false;
}
// Update
gui.newFrame();
gui.updateUI();
// Draw
SDL_SetRenderDrawColor(window.getRenderer(), 30, 30, 30, 255);
// Clear the buffer
SDL_RenderClear(window.getRenderer());
gui.render(); // Draw UI on top
SDL_RenderPresent(window.getRenderer()); // Swap buffers
}
return 0;
}