Skip to content

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

Description

@fochen79

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.

`

Activity

  1. fochen79 commented on Nov 14, 2024

    @fochen79
    Author

    this is the error message
    sdl_error

  2. suve commented on Nov 14, 2024

    @suve
    Collaborator

    Can you try compiling with -gl?

  3. fochen79 commented on Nov 14, 2024

    @fochen79
    Author

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

    error

  4. fochen79 commented on Nov 14, 2024

    @fochen79
    Author

    also i tried using gdb it show this :
    gdb

  5. suve commented on Nov 14, 2024

    @suve
    Collaborator

    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);
  6. fochen79 commented on Nov 15, 2024

    @fochen79
    Author

    thanks , yes it works with this workaround

  7. fochen79 commented on Nov 15, 2024

    @fochen79
    Author

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

  8. suve commented on Nov 16, 2024

    @suve
    Collaborator

    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.

  9. fochen79 commented on Nov 16, 2024

    @fochen79
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions