Vladar4 / sdl2_nim

Wrapper of the SDL 2 library for the Nim language.
Other
147 stars 24 forks source link

WindowEventID size is of cint but should be of uint8. #5

Closed ftsf closed 7 years ago

ftsf commented 7 years ago

This exhibits behaviour of getting incorrect values w,h values from resize events.

To test:

elif evt.kind == WindowEvent and  evt.window.event == WindowEvent_Resized:
  echo evt.window.data1, " ", evt.window.data2

data1 will be the height and data2 will be incorrect.

# from private/video.nim
type
  WindowEventID* {.size: sizeof(cint).} = enum ##  \
# from /usr/include/SDL2/SDL_events.h
typedef struct SDL_WindowEvent
{
    Uint32 type;        /**< ::SDL_WINDOWEVENT */
    Uint32 timestamp;
    Uint32 windowID;    /**< The associated window */
    Uint8 event;        /**< ::SDL_WindowEventID */
    Uint8 padding1;
    Uint8 padding2;
    Uint8 padding3;
    Sint32 data1;       /**< event dependent data */
    Sint32 data2;       /**< event dependent data */
} SDL_WindowEvent;

private/video.nim should be modified to have WindowEventID's size be changed to sizeof(uint8)

ftsf commented 7 years ago

Oh... Looks like this is already fixed in your repo, however when installing via nimble it is not. Are you able to push the updated version to nimble?

Vladar4 commented 7 years ago

Until the new release, use nimble install sdl2_nim@#head command. I plan to release a new version along with the next nimgame2 release.

Vladar4 commented 7 years ago

Included into v2.0.5.0.