@Capehill
Do you mean that should be done on the OS level, not software-implemented in SDL ?
Btw, found another little issue when fixing irrlicht : this time its about SDL_ListModes() and maybe togeter with SDL_GetVideoInfo().
Issue is (long story):
When you create a window/fullscreen via SetVideoMode where you provide bitdepth as anything you don't have (let's say "24"), then, while all creates well, SDL_ListModes() will fail to list video modes (that expected, as if you don't have 24 bit modes what it will list). So that are expected, and it the same for win32 too.
I.e. that kind of code are fail on both win32 and amigaos4:
#include <stdio.h>
#include <SDL/SDL.h>
int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Surface *Screen = SDL_SetVideoMode(1024, 768, 24, SDL_ANYFORMAT | SDL_OPENGL);
const SDL_VideoInfo *vi = SDL_GetVideoInfo();
SDL_Rect **modes = SDL_ListModes(vi->vfmt, SDL_FULLSCREEN);
printf("bitserpixel = %d\n", vi->vfmt->BitsPerPixel);
if(modes == (SDL_Rect **)0){
printf("No modes available!\n");
SDL_Quit();
}
if (modes != 0)
{
if (modes == (SDL_Rect **)-1) {
printf("All mode available\n");
}
else
{
for (int i=0; modes[i]; ++i) {
printf(" %d x %d x %d\n", modes[i]->w, modes[i]->h, vi->vfmt->BitsPerPixel);
}
}
}
SDL_Quit();
}
So that is fine and expected to be like this.
But then, to make SDL_ListMode works even if we have set "24" in the SetVideoMode, we set manually pixel format to 32 , and then it should works. And it works on win32 and on linux, but fail on our side. There is that failing on os4 testcase:
#include <stdio.h>
#include <SDL/SDL.h>
int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Surface *Screen = SDL_SetVideoMode(1024, 768, 24, SDL_ANYFORMAT | SDL_OPENGL);
const SDL_VideoInfo *vi = SDL_GetVideoInfo();
SDL_PixelFormat pixelFormat = *(vi->vfmt);
pixelFormat.BitsPerPixel = 32;
SDL_Rect **modes = SDL_ListModes(&pixelFormat, SDL_FULLSCREEN);
printf("SDL: flags are set to %x\n", SDL_FULLSCREEN);
printf("bitserpixel = %d\n", vi->vfmt->BitsPerPixel);
if (modes != 0)
{
if (modes == (SDL_Rect **)-1) {
printf("All mode available\n");
}
else
{
for (int i=0; modes[i]; ++i) {
}
}
}
/* Check is there are any modes available */
if(modes == (SDL_Rect **)0){
printf("No modes available!\n");
SDL_Quit();
}
/* Check if our resolution is restricted */
else if(modes == (SDL_Rect **)-1){
printf("All resolutions available.\n");
}
else{
/* Print valid modes */
printf("Available Modes\n");
for(int i=0;modes[i];++i)
printf(" %d x %d\n", modes[i]->w, modes[i]->h);
}
SDL_Quit();
}
As you can see there i just set manually 32 bit to format before calling SDL_ListModes(). And that fail.
It can be that SDL_ListModes() fail to parse pixelFormat properly ?
I checked SDL_GetVideoInfo() call right after i call SetVideoMode, and in both case and on win32 and on os4 it return 24, as expected. But then, when i set pixelFormat.BitsPerPixel to 32, it then works on win32 when i call SDL_ListModes(&pixelFormat, SDL_FULLSCREEN);, but didn't on os4.
So my bet that there can be one of 2 issues:
1. just first argument of SDL_ListModes or do not parsed correctly
2. it is parsed correclty, but there maybe some "compare" , like if bits in 1st arg of pixelformat in the SDL_ListVideo mode do not equal to the bits used in the SetVideoMode call , then we fail (while should't). At least that prove while for example if we set in test case "16" to the SetVideoMode, but still keep 32 for SDL_ListModes it fail, but when we set 16 on both places , it works. Or if we have 32 in both places it works. But if SetVideoMode have one bits, and ListModes ask to list modes with other bits : then we fail.
While of course we should't fail , as we ask to list modes of bits we ask. And it works like this on win32 and linux, so probabaly that is bug on our side.
Edited by kas1e on 2019/10/10 12:48:43