SDL简单循环窗口(使用xmake)

//main.cpp

#include 
#pragma mark - thirdpartylib
#include 
#include 
#pragma mark - windowconst

const int WIDTH = 400;
int main(int argc, char const *argv[])
{
    // 一定是     !=0
    if ((SDL_Init(SDL_INIT_EVERYTHING)) != 0)
    {
        return 1;
    }

    int x = 0;
    SDL_Window *window = SDL_CreateWindow("shae", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
                                          WIDTH, WIDTH, SDL_WINDOW_SHOWN);

    SDL_Renderer *render = SDL_CreateRenderer(window, -1, 0);

    bool is_quit = false;
    SDL_Event event;

    SDL_Rect screenRect;
    SDL_GetDisplayBounds(0, &screenRect);
    SDL_SetWindowBordered(window, SDL_FALSE);
    SDL_SetWindowMouseRect(window, &screenRect);

    int direction = 1;
    while (!is_quit)
    {
        while (SDL_PollEvent(&event))
        {
            if (event.type == SDL_QUIT)
            {
                is_quit = true;
            }
        }
        x += direction * 10;
        if (x + WIDTH >= screenRect.w)
            direction = -1;
        else if (x < 0)
            direction = 1;
        SDL_SetWindowPosition(window, x, SDL_WINDOWPOS_CENTERED);
        SDL_RenderPresent(render);
        SDL_Delay(30);
    }

    SDL_Delay(6000);

    SDL_Quit();
    return 0;
}


# api      			#flag


SDL_init        SDL_INIT_EVERYTHING
SDL_Window          
SDL_CreateWindow    SDL_WINDOWPOS_CENTERED SDL_WINDOW_SHOWN SDL_WINDOW_BOARDLESS

SDL_Renderer        
SDL_CreateRenderer 
SDL_RenderPresent
SDL_Clear

SDL_Event       SDL_QUIT
SDL_PollEvent 


SDL_Delay
SDL_SetWindowFull
SDL_GetDisplayBounds
SDL_SetWindowBordered
SDL_SetWindowMouseRect

SDL_DestoryWindow
SDL_DestoryRenderer
SDL_Quit 



# 官网也有分组

你可能感兴趣的:(为c++使用cmake,c++)