SDL

Форк
0
/
template.c 
50 строк · 1.6 Кб
1
/*
2
 * This example code $WHAT_IT_DOES.
3
 *
4
 * This code is public domain. Feel free to use it for any purpose!
5
 */
6

7
#define SDL_MAIN_USE_CALLBACKS 1  /* use the callbacks instead of main() */
8
#include <SDL3/SDL.h>
9
#include <SDL3/SDL_main.h>
10

11
/* We will use this renderer to draw into this window every frame. */
12
static SDL_Window *window = NULL;
13
static SDL_Renderer *renderer = NULL;
14

15

16
/* This function runs once at startup. */
17
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
18
{
19
    if (SDL_Init(SDL_INIT_VIDEO) == -1) {
20
        SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);
21
        return SDL_APP_FAILURE;
22
    }
23

24
    if (SDL_CreateWindowAndRenderer("examples/CATEGORY/NAME", 640, 480, 0, &window, &renderer) == -1) {
25
        SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't create window/renderer!", SDL_GetError(), NULL);
26
        return SDL_APP_FAILURE;
27
    }
28
    return SDL_APP_CONTINUE;  /* carry on with the program! */
29
}
30

31
/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
32
SDL_AppResult SDL_AppEvent(void *appstate, const SDL_Event *event)
33
{
34
    if (event->type == SDL_EVENT_QUIT) {
35
        return SDL_APP_SUCCESS;  /* end the program, reporting success to the OS. */
36
    }
37
    return SDL_APP_CONTINUE;  /* carry on with the program! */
38
}
39

40
/* This function runs once per frame, and is the heart of the program. */
41
SDL_AppResult SDL_AppIterate(void *appstate)
42
{
43
    return SDL_APP_CONTINUE;  /* carry on with the program! */
44
}
45

46
/* This function runs once at shutdown. */
47
void SDL_AppQuit(void *appstate)
48
{
49
    /* SDL will clean up the window/renderer for us. */
50
}
51

52

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.