Writing /net/www/auesnard/teaching/data/meta/projtec/sdl2.meta failed
projtec:sdl2
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
projtec:sdl2 [2017/02/13 09:46] – orel | projtec:sdl2 [2024/03/18 15:06] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 6: | Line 6: | ||
* https:// | * https:// | ||
* https:// | * https:// | ||
+ | |||
+ | Voici quelques tuoriels utiles pour bien commençer : | ||
+ | |||
+ | * http:// | ||
+ | |||
+ | Nous proposons ici un modèle de programme avec SDL2, et une petit exemple d' | ||
+ | |||
+ | |||
+ | {{ : | ||
+ | |||
==== Un Modèle de Programme SDL2 ==== | ==== Un Modèle de Programme SDL2 ==== | ||
Line 11: | Line 21: | ||
Notre modèle se compose de trois fichiers : //main.c//, //model.h// et // | Notre modèle se compose de trois fichiers : //main.c//, //model.h// et // | ||
- | * init() | + | * La fonction //init()// permet l' |
- | * clean() | + | * La fonction //clean()// permet principalement de terminer votre programme, en libérant les allocations |
- | * process() | + | * La fonction //process()// est appelée dans la boucle principale de votre programme, afin de traiter tous les èvenements SDL2 (souris, clavier, ...). |
- | * render() | + | * La fonction //render()// est appelée dans la boucle principale |
Voici la déclaration des fonctions utiles à notre modèle : | Voici la déclaration des fonctions utiles à notre modèle : | ||
Line 41: | Line 51: | ||
#define PRINT(STR, ...) do { SDL_Log(STR, | #define PRINT(STR, ...) do { SDL_Log(STR, | ||
#define ERROR(STR, ...) do { SDL_Log(STR, | #define ERROR(STR, ...) do { SDL_Log(STR, | ||
- | // #define LOG(TAG, STR, ...) __android_log_print(ANDROID_LOG_VERBOSE, | ||
# else | # else | ||
#define PRINT(STR, ...) do { printf(STR, ## | #define PRINT(STR, ...) do { printf(STR, ## | ||
Line 65: | Line 74: | ||
// SDL2 Demo by aurelien.esnard@u-bordeaux.fr | // SDL2 Demo by aurelien.esnard@u-bordeaux.fr | ||
- | #include <SDL2/SDL.h> | + | #include < |
- | #include <SDL2/SDL_image.h> | + | #include < |
- | #include <SDL2/SDL_ttf.h> | + | #include < |
#include < | #include < | ||
#include < | #include < | ||
Line 77: | Line 86: | ||
{ | { | ||
/* initialize SDL2 and some extensions */ | /* initialize SDL2 and some extensions */ | ||
- | if(SDL_Init(SDL_INIT_VIDEO) != 0) ERROR(" | + | if(SDL_Init(SDL_INIT_VIDEO) != 0) ERROR(" |
- | if(IMG_Init(IMG_INIT_PNG & IMG_INIT_PNG) != IMG_INIT_PNG) ERROR(" | + | if(IMG_Init(IMG_INIT_PNG & IMG_INIT_PNG) != IMG_INIT_PNG) ERROR(" |
- | if(TTF_Init() != 0) ERROR(" | + | if(TTF_Init() != 0) ERROR(" |
/* create window and renderer */ | /* create window and renderer */ | ||
SDL_Window * win = SDL_CreateWindow(APP_NAME, | SDL_Window * win = SDL_CreateWindow(APP_NAME, | ||
SCREEN_WIDTH, | SCREEN_WIDTH, | ||
- | if(!win) ERROR(" | + | if(!win) ERROR(" |
SDL_Renderer * ren = SDL_CreateRenderer(win, | SDL_Renderer * ren = SDL_CreateRenderer(win, | ||
- | if(!ren) ERROR(" | + | if(!ren) ERROR(" |
/* initialize your environment */ | /* initialize your environment */ | ||
Line 132: | Line 141: | ||
// SDL2 Demo by aurelien.esnard@u-bordeaux.fr | // SDL2 Demo by aurelien.esnard@u-bordeaux.fr | ||
- | #include <SDL2/SDL.h> | + | #include < |
- | #include <SDL2/SDL_image.h> | + | #include < |
- | #include <SDL2/SDL_ttf.h> | + | #include < |
#include < | #include < | ||
Line 192: | Line 201: | ||
</ | </ | ||
- | ==== Démo ==== | ||
- | |||
- | Pour illustrer notre modèle, voici une petite démo qui montre les différentes possibilités de SDL2 (texte TTF, texture transparente PNG, ...). Vous trouverez tout cela dans l' | ||
==== Portage sous Android | ==== Portage sous Android | ||
- | Le code proposé ci-dessus est 100% portable sous Android... Plus dé détails bientôt. | + | Le code proposé ci-dessus est 100% portable sous Android |
projtec/sdl2.1486979161.txt.gz · Last modified: 2024/03/18 15:05 (external edit)