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

error with sdl2 64bits on windows 10 64bits #148

Open
fochen79 opened this issue Nov 14, 2024 · 9 comments
Open

error with sdl2 64bits on windows 10 64bits #148

fochen79 opened this issue Nov 14, 2024 · 9 comments

Comments

@fochen79
Copy link

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.

`

@fochen79
Copy link
Author

this is the error message
sdl_error

@suve
Copy link
Collaborator

suve commented Nov 14, 2024

Can you try compiling with -gl?

@fochen79
Copy link
Author

yes i tried , the line 17 is render := sdl_createrenderer(win,-1,sdl_renderer_accelerated);

error

@fochen79
Copy link
Author

also i tried using gdb it show this :
gdb

@suve
Copy link
Collaborator

suve commented Nov 14, 2024

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:

  1. Add uses Math to your code
  2. Add the following two variables: OldMask, NewMask: TFPUExceptionMask;
  3. Add the following code before the SDL_CreateRenderer call:
OldMask := Math.GetExceptionMask();
NewMask := OldMask;
Include(NewMask, exInvalidOp);
Include(NewMask, exZeroDivide);
Math.SetExceptionMask(NewMask);
  1. And then after the renderer is created:
Math.SetExceptionMask(OldMask);

@fochen79
Copy link
Author

thanks , yes it works with this workaround

@fochen79
Copy link
Author

dose this mean i will use this workaround always in win10 64bits ?

@suve
Copy link
Collaborator

suve commented Nov 16, 2024

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.

@fochen79
Copy link
Author

ok , but the software renderer works fine without problem
the problem is with SDL_RENDERER_ACCELERATED ,

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

No branches or pull requests

2 participants