1
0

fix makefile

This commit is contained in:
2025-08-28 23:19:49 +08:00
parent 8ddfe0707a
commit bf137a87a0
3 changed files with 14 additions and 7 deletions

View File

@@ -26,7 +26,7 @@
"defines": [ "defines": [
"USE_OPENGL" "USE_OPENGL"
], ],
"compilerPath": "D:\\msys64\\mingw64\\bin\\gcc.exe", "compilerPath": "C:/MinGW64/bin/gcc.exe",
"cStandard": "c17", "cStandard": "c17",
"cppStandard": "gnu++17", "cppStandard": "gnu++17",
"intelliSenseMode": "windows-gcc-x64" "intelliSenseMode": "windows-gcc-x64"

View File

@@ -1,12 +1,12 @@
TARGET = xplayer TARGET = xplayer
SRCS = main.cpp SRCS = src/main.cpp
OBJS = $(SRCS:.cpp=.o) OBJS = $(SRCS:.cpp=.o)
INCLUDES := -I$(CURDIR) CFLAGS := -O2 -Wall $(shell pkg-config sdl2 --cflags)
CFLAGS := -g -Wall $(INCLUDES)
CXXFLAGS := $(CFLAGS) -std=c++17 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) all: $(TARGET)

View File

@@ -47,18 +47,23 @@ int main(int argc, char* argv[]) {
mpv_set_option_string(mpv, "subs-fallback", "yes"); mpv_set_option_string(mpv, "subs-fallback", "yes");
mpv_set_option_string(mpv, "video-timing-offset", "0"); // 60fps mpv_set_option_string(mpv, "video-timing-offset", "0"); // 60fps
mpv_set_option_string(mpv, "ytdl", "no"); 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, "hwdec", "auto-copy");
mpv_set_option_string(mpv, "vo", "libmpv"); 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"); 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"); if (!window) die("failed to create SDL window");
SDL_GLContext context = SDL_GL_CreateContext(window); SDL_GLContext context = SDL_GL_CreateContext(window);
SDL_GL_MakeCurrent(window, context); SDL_GL_MakeCurrent(window, context);
mpv_opengl_init_params gl_init_params{ 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 params[] = {
{MPV_RENDER_PARAM_API_TYPE, const_cast<char*>(MPV_RENDER_API_TYPE_OPENGL)}, {MPV_RENDER_PARAM_API_TYPE, const_cast<char*>(MPV_RENDER_API_TYPE_OPENGL)},
{MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, &gl_init_params}, {MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, &gl_init_params},
@@ -109,6 +114,8 @@ int main(int argc, char* argv[]) {
case SDLK_SPACE: case SDLK_SPACE:
mpv_command_string(mpv, "cycle pause"); mpv_command_string(mpv, "cycle pause");
break; break;
default:
SDL_Log("SDL_KEYDOWN %d\n", event.key.keysym.scancode);
} }
break; break;
case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONDOWN: