diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index a369758..3028829 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -26,7 +26,7 @@ "defines": [ "USE_OPENGL" ], - "compilerPath": "D:\\msys64\\mingw64\\bin\\gcc.exe", + "compilerPath": "C:/MinGW64/bin/gcc.exe", "cStandard": "c17", "cppStandard": "gnu++17", "intelliSenseMode": "windows-gcc-x64" diff --git a/Makefile.mingw b/Makefile.mingw index d04e238..0b46972 100644 --- a/Makefile.mingw +++ b/Makefile.mingw @@ -1,12 +1,12 @@ TARGET = xplayer -SRCS = main.cpp +SRCS = src/main.cpp OBJS = $(SRCS:.cpp=.o) -INCLUDES := -I$(CURDIR) -CFLAGS := -g -Wall $(INCLUDES) +CFLAGS := -O2 -Wall $(shell pkg-config sdl2 --cflags) CXXFLAGS := $(CFLAGS) -std=c++17 -LDFLAGS := `pkg-config sdl2 mpv --libs` +LDFLAGS := -Wl,-Bdynamic $(shell pkg-config sdl2 mpv --libs) \ + -mconsole -static-libgcc -static-libstdc++ -static all: $(TARGET) diff --git a/src/main.cpp b/src/main.cpp index b4bba3c..09a4d18 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,18 +47,23 @@ int main(int argc, char* argv[]) { mpv_set_option_string(mpv, "subs-fallback", "yes"); mpv_set_option_string(mpv, "video-timing-offset", "0"); // 60fps mpv_set_option_string(mpv, "ytdl", "no"); + // mpv_set_option_string(mpv, "terminal", "yes"); mpv_set_option_string(mpv, "hwdec", "auto-copy"); mpv_set_option_string(mpv, "vo", "libmpv"); +#ifdef _DEBUG + mpv_set_option_string(mpv, "msg-level", "all=v"); +#endif if (mpv_initialize(mpv) < 0) die("init mpv failed"); - SDL_Window* window = SDL_CreateWindow(argv[1], 0, 0, 1280, 720, 0); + SDL_Window* window = SDL_CreateWindow(argv[1], SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, + SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); if (!window) die("failed to create SDL window"); SDL_GLContext context = SDL_GL_CreateContext(window); SDL_GL_MakeCurrent(window, context); mpv_opengl_init_params gl_init_params{ - [](void* fn_ctx, const char* name) { return (void*)SDL_GL_GetProcAddress(name); }, nullptr}; + [](void* fn_ctx, const char* name) -> void* { return (void*)SDL_GL_GetProcAddress(name); }, nullptr}; mpv_render_param params[] = { {MPV_RENDER_PARAM_API_TYPE, const_cast(MPV_RENDER_API_TYPE_OPENGL)}, {MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, &gl_init_params}, @@ -109,6 +114,8 @@ int main(int argc, char* argv[]) { case SDLK_SPACE: mpv_command_string(mpv, "cycle pause"); break; + default: + SDL_Log("SDL_KEYDOWN %d\n", event.key.keysym.scancode); } break; case SDL_JOYBUTTONDOWN: