Align documented commands with the CLI, enable optional GUI/test targets, and remove committed API secrets so the project is safer to build and run. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
#include <cstdio>
|
|
#include <cstdlib>
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include "dstalk/dstalk_api.h"
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
if (dstalk_init(nullptr) != 0) {
|
|
std::fprintf(stderr, "[dstalk] 初始化失败\n");
|
|
return 1;
|
|
}
|
|
|
|
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
|
std::fprintf(stderr, "[dstalk] SDL 初始化失败: %s\n", SDL_GetError());
|
|
dstalk_destroy();
|
|
return 1;
|
|
}
|
|
|
|
SDL_Window* window = SDL_CreateWindow(
|
|
"dstalk", 1024, 768, SDL_WINDOW_RESIZABLE);
|
|
if (!window) {
|
|
std::fprintf(stderr, "[dstalk] 窗口创建失败: %s\n", SDL_GetError());
|
|
SDL_Quit();
|
|
dstalk_destroy();
|
|
return 1;
|
|
}
|
|
|
|
SDL_Renderer* renderer = SDL_CreateRenderer(window, nullptr);
|
|
if (!renderer) {
|
|
SDL_DestroyWindow(window);
|
|
SDL_Quit();
|
|
dstalk_destroy();
|
|
return 1;
|
|
}
|
|
|
|
bool running = true;
|
|
SDL_Event event;
|
|
while (running) {
|
|
while (SDL_PollEvent(&event)) {
|
|
if (event.type == SDL_EVENT_QUIT) {
|
|
running = false;
|
|
}
|
|
}
|
|
SDL_SetRenderDrawColor(renderer, 0x1E, 0x1E, 0x2E, 0xFF);
|
|
SDL_RenderClear(renderer);
|
|
SDL_RenderPresent(renderer);
|
|
}
|
|
|
|
SDL_DestroyRenderer(renderer);
|
|
SDL_DestroyWindow(window);
|
|
SDL_Quit();
|
|
dstalk_destroy();
|
|
return 0;
|
|
}
|