Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SDL2 #508

Merged
merged 15 commits into from
Jan 8, 2025
Merged

Add support for SDL2 #508

merged 15 commits into from
Jan 8, 2025

Conversation

sneakywumpus
Copy link
Contributor

Since SDL2 requires the main() function to be called with C linkage, and I don't wan't to mess around with linking C with C++ anymore, I just converted the frontpanel library to C...

With SDL2 the JPEG code in the frontpanel library isn't used anymore, instead SDL2_image is used to load texture files. This also adds support for other file types (bmp, png, ppm, ...).

SDL2 (and macOS, and possible other OS's) require drawing, event handling, window creation etc. to be done from the main thread. So the simulator code now runs in a separate thread.

Added a typeahead buffer for VDM/VIO for SDL2 because there is only one event loop for all windows.

Added mouse wheel/touchpad scrolling support to zoom in/out of the 3-D frontpanel view.

Invoking just "make" compiles for X11, "WANT_SDL=YES make" compiles for SDL2.

Since SDL2 requires the main() function to be called with C linkage,
and I don't wan't to mess around with linking C with C++ anymore, I
just converted the frontpanel library to C...

With SDL2 the JPEG code in the frontpanel library isn't used anymore,
instead SDL2_image is used to load texture files. This also adds support
for other file types (bmp, png, ppm, ...).

SDL2 (and macOS, and possible other OS's) require drawing, event
handling, window creation etc. to be done from the main thread.
So the simulator code now runs in a separate thread.

Invoking just "make" compiles for X11, "WANT_SDL=YES make" compiles
for SDL2.

Not perfect, more work to do.
SDL_RenderDrawPoint was slow, now the FPS stays at 60,
previously it dropped into the 30's.
Make fps display work in 3-D mode.
Don't cut of descenders of font.
Don't overlap fps and cursor position display.
The GL context attributes also apply to the other accelerated windows
(Dazzler, VDM, VIO), so reset them after creating the frontpanel context.

Don't install SDL signal handlers, we have our own.
These are what cmake uses when generating for macOS.
@sneakywumpus
Copy link
Contributor Author

I used apitrace to generate a trace of OpenGL calls and this looked a bit chaotic, this was the reason for the clean-up in 6228b89.

@udo-munk udo-munk merged commit caa8f40 into udo-munk:master Jan 8, 2025
1 check passed
@sneakywumpus
Copy link
Contributor Author

Arghh. This pull request was against master, sorry... Do you want to revert this and I submit it against dev?

@udo-munk
Copy link
Owner

udo-munk commented Jan 8, 2025

Just figured, no is OK, as far as I've seen it doesn't create new issues with X11 build.

@sneakywumpus
Copy link
Contributor Author

Could you merge master into dev, so I can submit more PR's, thanks.

@udo-munk
Copy link
Owner

udo-munk commented Jan 9, 2025

Sure, done.

@sneakywumpus sneakywumpus deleted the addsdl2 branch January 9, 2025 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants