jME 3.10.0-beta1
jMonkeyEngine Hub
May 31, 2026
sgold:
Many of my apps use GLFW to determine the available resolutions for full-screen display. I’m sure SDL3 has equivalent functionality;
This is what I’ve done so far:
public List<VideoMode> getAvailableVideoModes() {
initVideo();
final List<VideoMode> videoModes = new ArrayList<>();
final PointerBuffer displayModes = SDLVideo.SDL_GetFullscreenDisplayModes(display);
for (int i = 0; i < displayModes.capacity(); i++) {
final SDL_DisplayMode displayMode = SDL_DisplayMode.create(displayModes.get());
final VideoMode videoMode = new VideoMode(displayMode.w(), displayMode.h(), displayMode.refresh_rate());
videoModes.add(videoMode);
}
SDL_free_func.free(displayModes.address());
return videoModes;
}
private void initVideo() {
if ((SDLInit.SDL_WasInit(SDLInit.SDL_INIT_VIDEO) & SDLInit.SDL_INIT_VIDEO) == 0 && !SDLInit.SDL_Init(SDLInit.SDL_INIT_VIDEO)) {
String message = SDLError.SDL_GetError();
logger.log(Level.SEVERE, "CRITICAL ERROR: Failed to initialize SDL3 Video Subsystem!\n * {0}", message);
throw new RuntimeException(message);
}
}
VideoMode is a record I created that holds only width, height and frequency, but SDL_DisplayMode has other data.
public record VideoMode(int width, int height, float refreshRate) {
}
Discussion in the ATmosphere