serge-rgb / milton

An infinite-canvas paint program
GNU General Public License v3.0
1.52k stars 133 forks source link

Undefined references (Linux) #148

Closed Pulfer closed 5 years ago

Pulfer commented 5 years ago

CMakeFiles/Milton.dir/src/unity.cc.o: In function drag_brush_size_start(Milton*, Vector2<int>)': unity.cc:(.text+0x25512): undefined reference toplatform_cursor_get_position' CMakeFiles/Milton.dir/src/unity.cc.o: In function drag_brush_size_stop(Milton*)': unity.cc:(.text+0x25623): undefined reference toplatform_cursor_set_position' CMakeFiles/Milton.dir/src/unity.cc.o: In function binding_dispatch_action(BindableAction, MiltonInput*, Milton*, Vector2<int>)': unity.cc:(.text+0x5d8a4): undefined reference toplatform_cursor_set_position' CMakeFiles/Milton.dir/src/unity.cc.o: In function milton_update_and_render(Milton*, MiltonInput const*)': unity.cc:(.text+0x686cb): undefined reference toplatform_cursor_get_position'

These functions are defined for Mac and Windows but not for Linux (platform_linux.cc).

danfe commented 5 years ago

Two functions are missing from src/platform_linux.cc as shown below:

v2i
platform_cursor_get_position(PlatformState* platform)
{
    v2i pos;

    SDL_GetMouseState(&pos.x, &pos.y);
    return pos;
}

void
platform_cursor_set_position(PlatformState* platform, v2i pos)
{
    SDL_WarpMouseInWindow(platform->window, pos.x, pos.y);
    // Pending mouse move events will have the cursor close
    // to where it was before we set it.
    SDL_FlushEvent(SDL_MOUSEMOTION);
    SDL_FlushEvent(SDL_SYSWMEVENT);
}

Tested under FreeBSD, seems to DTRT.

serge-rgb commented 5 years ago

Thanks for the bug report and fixes!