@virgola While Pingus indeed use SDL2, and other stuff which we have, it also use BOOST libs : modules such as signals2 and format. Probably , it can be not very hard to rewrite, but to someone who know programming well.
We have on os4depot very old version of boost, but there is only few modules done, most of them just stubs which do nothing.
It can be cool if , someday, someone, will properly port whole boost thing, but that very time consuming and hard part, to make it all properly, imho.
@Capehill Found another error, which you may want to fix in sdl: If we request OpenGL ES 3.0 context (while we have 2.0), then it crashes after we try to do something GLES based.
// Create the window
window = SDL_CreateWindow("GLES3+SDL2 Tutorial", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, DISP_WIDTH, DISP_HEIGHT,
SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
if (!window) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
"Couldn't create the main window.", NULL);
return EXIT_FAILURE;
}
context = SDL_GL_CreateContext(window);
if (!context) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
"Couldn't create an OpenGL context.", NULL);
return EXIT_FAILURE;
}
// Clear to black
glClearColor(0.5f, 0.7f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// Update the window
SDL_GL_SwapWindow(window);
// Wait for the user to quit
bool quit = false;
while (!quit) {
SDL_Event event;
if (SDL_WaitEvent(&event) != 0) {
if (event.type == SDL_QUIT) {
// User wants to quit
quit = true;
}
}
}
return EXIT_SUCCESS;
}
Once you replace SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); on SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
(i.e. to request opengles3), then , instead of fallback to 2, or instead to quit with words "no gles3 possible", it continue to work, create instead opengl (so minigl) context, and then crashes.
With SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); (i.e. gles1), its fallback to version 2 fine.
Probably we need or the same fallback from 3 to 2 , or exit with words "sorry, no gles3 possible". But, most of gles3 code will works on gles2, so maybe fallback to 2 is better.
Once you replace SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); on SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
(i.e. to request opengles3), then , instead of fallback to 2, or instead to quit with words "no gles3 possible", it continue to work, create instead opengl (so minigl) context, and then crashes.
SDL_GL_CreateContext(window) should return NULL if it can't create a context of the requested version.
Quote:
With SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); (i.e. gles1), its fallback to version 2 fine.
Wait, you're saying that GLES1 falls back to GLES2? If so, that needs to be changed immediately. GLES2 is completely incompatible with GLES1 (the old fixed pipeline is removed to make writing drivers easier). Falling back to MiniGL (so OpenGL 1.x) is probably okay.
Quote:
Probably we need or the same fallback from 3 to 2 , or exit with words "sorry, no gles3 possible". But, most of gles3 code will works on gles2, so maybe fallback to 2 is better.
Hmm, not sure which is best. Part of me wants to say "just return a NULL context," but games/apps will quickly detect which GLES3 features are and aren't available (and they should be checking the error codes).
I prefer a GLES3 context just for being able to use layout(location = n) and layout(binding = n) in the shaders (which our GLES2 supports), even when I'm not using geometry shaders or any other advanced feature. Falling back to GLES2 (with the bits I want supported) would save me from having to manually select GLES2 and then query the extensions I want to use.
@Hans Thanks for input ! Probably from test-case above you got that i trying your gles3+sdl2 tutor adapting on os4 :) Example01 working with minigmal change (as you see just includes, sdl_main on main, and 3 on 2 in major version). And example02 works too with very minimal changes. If you in interest once i will make it all compiles and works on os4,i can put it somewhere.
Also that all can be good test case for our sdl2+gles2 combo. At least with example01 it already show us something to fix.
Quote:
Wait, you're saying that GLES1 falls back to GLES2? If so, that needs to be changed immediately. GLES2 is completely incompatible with GLES1 (the old fixed pipeline is removed to make writing drivers easier). Falling back to MiniGL (so OpenGL 1.x) is probably okay.
Yes, majorversoin 1 fallback to gles2 (so open ogles2.libary and co, checked that with snoopy), and majorversion3 fallback to opengl(so open minig.library, also checked that with snoopy).
In other words, we need probably version3 fallback to version2, and version 1 fallback to opengl, i.e. reverse to what is now.
Thanks for input ! Probably from test-case above you got that i trying your gles3+sdl2 tutor adapting on os4 :) Example01 working with minigmal change (as you see just includes, sdl_main on main, and 3 on 2 in major version). And example02 works too with very minimal changes. If you in interest once i will make it all compiles and works on os4,i can put it somewhere.
Also that all can be good test case for our sdl2+gles2 combo. At least with example01 it already show us something to fix.
Nice! Once it's all fixed, if you send me the details then I can update the tutorial, or create an AmigaOS 4 version.
@Capehill Another error (or maybe feature, dunno), is that when i run any SDL2 based app (at least those which i test: gigalomania game and some simple sdl2+ogles2 based test examples), then, while SDL2 waits for their events, massive flood on timer.device is happens.
I.e. its just enough to run snoopy, then sdl2 based stuff, and log will fast growup with lots of :
I checked SDL1 based apps (Grafx2 app and Beret game), and there is no such flood.
Probably that can slow down all SDL2 apps.. If you in interst, i can provide the minimal test case ,but its enough to just open window and wait for events.
There is only checking for OpenGL ES 2.0. In other cases is falls back to MiniGL and seems that this has to be removed because it conflicts with user intention (SDL_opengles2.h).
Preprocessor has replaced glCalls anyway with IOGLES->glCall so disaster waits if ogles.library wasn't opened correctly.
Regarding timer.device, please provide a minimal example that demonstrates it. SDL2 shouldn't explicitly open timer.device.
There is only checking for OpenGL ES 2.0. In other cases is falls back to MiniGL and seems that this has to be removed because it conflicts with user intention (SDL_opengles2.h).
Preprocessor has replaced glCalls anyway with IOGLES->glCall so disaster waits if ogles.library wasn't opened correctly.
Its even not always fallback to MiniGL now, its fallback only when we request OpenGL ES 3.0, but if we request OpenGL ES 1.0, then it fallback to OpenGL ES 2.0. While in all cases it probably should just return NULL.. Or at least when coder request OpenGL ES 1.0 return NULL, but when he request OpenGL ES 3.0, fallback it to OpenGL ES 2.0.
Quote:
Regarding timer.device, please provide a minimal example that demonstrates it. SDL2 shouldn't explicitly open timer.device.
Sure, just opening of window and wait for quit is enough. There is test code:
const unsigned int DISP_WIDTH = 640;
const unsigned int DISP_HEIGHT = 480;
//int SDL_main(int argc, char *args[]) {
int main(int argc, char *args[]) {
// The window
SDL_Window *window = NULL;
// Init SDL
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
SDL_Log("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
}
// Setup the exit hook
atexit(SDL_Quit);
// Create the window
window = SDL_CreateWindow("GLES3+SDL2 Tutorial", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, DISP_WIDTH, DISP_HEIGHT,
SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
if (!window) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
"Couldn't create the main window.", NULL);
return EXIT_FAILURE;
}
// Wait for the user to quit
bool quit = false;
while (!quit) {
SDL_Event event;
if (SDL_WaitEvent(&event) != 0) {
if (event.type == SDL_QUIT) {
// User wants to quit
quit = true;
}
}
}
return EXIT_SUCCESS;
}
After you will compile it, run it , and then run "snoopy". You will see, that while sdl2 app is working, we have flood of opening of timer.devices. That with any SDL2 based app i test at moment. With SDL1 there is no such flood, that why i think it can be bug which slow things down..
I have created a branch called fix-opengl. SDL2's OpenGL version defaulted to 2.1, changed to 1.3 (which is the MiniGL's OpenGL version I think). Then also MiniGL fallback was removed so it should be a little bit safer now.
I have created a branch called fix-opengl. SDL2's OpenGL version defaulted to 2.1, changed to 1.3 (which is the MiniGL's OpenGL version I think). Then also MiniGL fallback was removed so it should be a little bit safer now.
Tested fix-opengl branch and result are:
For first tested to create pure opengl window: all works fine, minigl.library opens.
Then testes openglES:
- when request OGLES1, return error !window for sdl_createwidow() : probably good, but fallback to minigl in that case can be also ok imho.
- when request OGLES2, open ogles2.library, return ogels2 context, all works: good
- when request OGLES3, return error !window for sdl_createwidow() : probably good. Dunno if it make sense to fallback it to OGLES2, but that can be changed later if there will be demand imho.
Also for sake of fun trying to ask for OGLES0, and OGLES4 , and as expected return same !window for sdl_createwidow, which mean all handles good and well.
Also did more tests related to "flood of opening of timer.device" issue, and found that its because of "if (SDL_WaitEvent(&event) != 0)". I.e. SDL_WaitEvent doing something nasty (or tasty), which on os4 cause massive flood of open timer.device in loop.
And, i see something cool , its another branch together with opengl-fix :) Really nice ! Will you implement it just as default, so no needs for any flags and co, just window mode will have 3st gadget as usuall ones, without needs to worry about ?
@Capehill Is src/timer/amigaos4/SDL_os4timer.c file is used at all for sdl2 ? I see it used for SDL1 (does not matter if i use ./configure and create new makefile, or use pure makefile.amigao4, in both cases SDL_os4timer.c compiles in), but in my build of SDL2 that file didn't used.
Instead, configure process seems to use just src/timer/SDL_timer.c and src/timer/unix/SDL_systimer.c. Probably that can be reassons of that "open timer.device flood", as it use bunch of posix kind functions realted to timing, so probably that cause those issues in end.
Will you implement it just as default, so no needs for any flags and co, just window mode will have 3st gadget as usuall ones, without needs to worry about
@amigablitter It works over winuae, just if your sdl app opengl based, it may cause problems, as minigl didnt work on winuae as it, as no hardware w3d support, and you need to use waZp3d to make minigl works on winuae, which, in turn, have some set of options with which you need to take care of.
Instead, configure process seems to use just src/timer/SDL_timer.c and src/timer/unix/SDL_systimer.c. Probably that can be reassons of that "open timer.device flood", as it use bunch of posix kind functions realted to timing, so probably that cause those issues in end.
That is highly likely.
But just to check on another posibilty what gfx lib are you using and what machine?
One thing to note though, since the opening of timer.device is there to create a timed delay or some such, it's not likely to slow anythig down, unless you are running snoopy or similar....