c++ - SDL_Init crashes without apparent reason -
i'm trying write simple sdl2 , opengl program sdl_init
causes application crash right @ beggining. here's code:
#include <iostream> #include <cstdint> #include <windows.h> #include <gl/gl.h> #include <sdl2/sdl.h> #define win_width 800 #define win_height 600 int callback winmain( hinstance hinstance, hinstance hprevinstance, lpstr lpcmdline, int ncmdshow) { int err; sdl_window *window; sdl_glcontext context; uint32_t win_flags = sdl_window_opengl; std::cout << "before"; if (sdl_init(sdl_init_video) < 0) { std::cout << "fail"; std::cout << "sdl init error: " << sdl_geterror() << std::endl; } std::cout << "success"; window = sdl_createwindow("rgb", sdl_windowpos_undefined, sdl_windowpos_undefined, win_width, win_height, win_flags); context = sdl_gl_createcontext(window); sdl_gl_deletecontext(context); sdl_destroywindow(window); sdl_quit(); return 0; }
and output is:
before
then crashes.
debugger output (when enters winmain):
winmain (hinstance=0x0, hprevinstance=0x1d04aa0, lpcmdline=0x0, ncmdshow=0) @ src/main.cpp:15 15 int ncmdshow) { (gdb) s 20 uint32_t win_flags = sdl_window_opengl; (gdb) s 22 std::cout << "before" << std::endl; (gdb) s before 24 if (sdl_init(sdl_init_video) < 0) { (gdb) s program received signal sigsegv, segmentation fault. 0x0000000000000000 in ?? ()
Comments
Post a Comment