didattici:esempio1sfml
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
didattici:esempio1sfml [2019/01/31 00:57] – created profpro | didattici:esempio1sfml [2020/06/08 22:20] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | Esempio 1 | ||
+ | Prima potrebbe essere necessario installare tutti i pacchetti elencati nella pagina [[didattici: | ||
+ | |||
+ | Poi per compilare questo file si deve usare il comando | ||
+ | |||
+ | gcc main.c -lcsfml-graphics -lcsfml-system -lcsfml-window | ||
+ | |||
+ | <file c main.c> | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | sfVideoMode mode = {400, 200, 32}; | ||
+ | sfRenderWindow* window; | ||
+ | sfTexture* texture; | ||
+ | sfFont* font; | ||
+ | sfText* text; | ||
+ | |||
+ | sfEvent event; | ||
+ | /* Create the main window */ | ||
+ | window = sfRenderWindow_create(mode, | ||
+ | if (!window) | ||
+ | return EXIT_FAILURE; | ||
+ | |||
+ | /* Create a graphical text to display */ | ||
+ | font = sfFont_createFromFile("/ | ||
+ | /* font = sfFont_createFromFile("/ | ||
+ | text = sfText_create(); | ||
+ | sfText_setString(text, | ||
+ | sfText_setFont(text, | ||
+ | sfText_setCharacterSize(text, | ||
+ | |||
+ | /* sfColor colore = sfColor_fromRGB(111, | ||
+ | /* Start the game loop */ | ||
+ | while (sfRenderWindow_isOpen(window)) | ||
+ | { | ||
+ | /* Process events */ | ||
+ | while (sfRenderWindow_pollEvent(window, | ||
+ | { | ||
+ | /* Close window : exit */ | ||
+ | if (event.type == sfEvtClosed) | ||
+ | sfRenderWindow_close(window); | ||
+ | } | ||
+ | /* Clear the screen */ | ||
+ | sfRenderWindow_clear(window, | ||
+ | /* Draw the text */ | ||
+ | | ||
+ | |||
+ | /* Draw the text */ | ||
+ | | ||
+ | /* Update the window */ | ||
+ | sfRenderWindow_display(window); | ||
+ | } | ||
+ | /* Cleanup resources */ | ||
+ | |||
+ | sfText_destroy(text); | ||
+ | |||
+ | sfRenderWindow_destroy(window); | ||
+ | return EXIT_SUCCESS; | ||
+ | } | ||
+ | </ |
didattici/esempio1sfml.txt · Last modified: 2020/06/08 22:20 by 127.0.0.1