error with sdl2 64bits on windows 10 64bits
Hi this simple code compiles ok but crashes when runing , but if i uncomment the lines it works ok can you please try it on windows 10 64bits & sdl2 64bits & fpc 3.2 64bits ` {$mode objfpc} {$apptype gui} program demo; uses sdl2;
var win : psdl_window; render: psdl_renderer; ev : tsdl_event; done: boolean = false;
begin //sdl_sethint(sdl_hint_render_driver,'opengl'); sdl_init(sdl_init_video); win := sdl_createwindow('FPC demo',50,50,320,200,sdl_window_shown {or sdl_window_opengl} ); render := sdl_createrenderer(win,-1,sdl_renderer_accelerated);
while not done do begin if boolean(sdl_pollevent(@ev)) then begin case ev.type_ of sdl_quitev:begin done:= true; end; end; end; sdl_setrenderdrawcolor(render, 32, 38, 42, 255); sdl_renderclear(render); sdl_renderpresent(render); end;
sdl_destroyrenderer(render); sdl_destroywindow(win); end.
`
this is the error message
Can you try compiling with -gl?
yes i tried , the line 17 is render := sdl_createrenderer(win,-1,sdl_renderer_accelerated);
also i tried using gdb it show this :
Hmm. This seems very similar to #56. We thought that it's a Linux-only issue, but maybe it happens on Windows as well?
Please check if this will work:
- Add
uses Mathto your code - Add the following two variables:
OldMask, NewMask: TFPUExceptionMask; - Add the following code before the
SDL_CreateRenderercall:
OldMask := Math.GetExceptionMask();
NewMask := OldMask;
Include(NewMask, exInvalidOp);
Include(NewMask, exZeroDivide);
Math.SetExceptionMask(NewMask);
- And then after the renderer is created:
Math.SetExceptionMask(OldMask);
thanks , yes it works with this workaround
dose this mean i will use this workaround always in win10 64bits ?
Well, this bug is specific to software renderers - so if you want to support running the program using SDL2's software renderer, then yes, the workaround will be needed.
I'll try poking around with a debugger a bit to see if I can spot any issues in SDL2 code. If not, I'll open an issue upstream; maybe someone there will have a better idea.
ok , but the software renderer works fine without problem the problem is with SDL_RENDERER_ACCELERATED ,