User Tools

Site Tools


projtec:sdl2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
projtec:sdl2 [2017/02/14 09:07] orelprojtec:sdl2 [2024/03/18 15:06] (current) – external edit 127.0.0.1
Line 51: Line 51:
 #define PRINT(STR, ...) do { SDL_Log(STR, ##__VA_ARGS__);  } while(0) #define PRINT(STR, ...) do { SDL_Log(STR, ##__VA_ARGS__);  } while(0)
 #define ERROR(STR, ...) do { SDL_Log(STR, ##__VA_ARGS__); exit(EXIT_FAILURE); } while(0)  #define ERROR(STR, ...) do { SDL_Log(STR, ##__VA_ARGS__); exit(EXIT_FAILURE); } while(0) 
-// #define LOG(TAG, STR, ...) __android_log_print(ANDROID_LOG_VERBOSE, TAG ,STR, ##__VA_ARGS__) 
 # else # else
 #define PRINT(STR, ...) do { printf(STR, ##__VA_ARGS__); } while(0) #define PRINT(STR, ...) do { printf(STR, ##__VA_ARGS__); } while(0)
Line 75: Line 74:
 // SDL2 Demo by aurelien.esnard@u-bordeaux.fr // SDL2 Demo by aurelien.esnard@u-bordeaux.fr
            
-#include <SDL2/SDL.h> +#include <SDL.h> 
-#include <SDL2/SDL_image.h>  // required to load transparent texture from PNG +#include <SDL_image.h>  // required to load transparent texture from PNG 
-#include <SDL2/SDL_ttf.h>    // required to use TTF fonts     +#include <SDL_ttf.h>    // required to use TTF fonts     
 #include <stdio.h> #include <stdio.h>
 #include <stdbool.h> #include <stdbool.h>
Line 87: Line 86:
  
   /* initialize SDL2 and some extensions */   /* initialize SDL2 and some extensions */
-  if(SDL_Init(SDL_INIT_VIDEO) != 0) ERROR("SDL_Init VIDEO");  +  if(SDL_Init(SDL_INIT_VIDEO) != 0) ERROR("Error: SDL_Init VIDEO (%s)", SDL_GetError());   
-  if(IMG_Init(IMG_INIT_PNG & IMG_INIT_PNG) != IMG_INIT_PNG) ERROR("IMG_Init PNG"); +  if(IMG_Init(IMG_INIT_PNG & IMG_INIT_PNG) != IMG_INIT_PNG) ERROR("Error: IMG_Init PNG (%s)", SDL_GetError());   
-  if(TTF_Init() != 0) ERROR("TTF_Init");  +  if(TTF_Init() != 0) ERROR("Error: TTF_Init (%s)", SDL_GetError());  
            
   /* create window and renderer */   /* create window and renderer */
   SDL_Window * win = SDL_CreateWindow(APP_NAME, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,   SDL_Window * win = SDL_CreateWindow(APP_NAME, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
           SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);           SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
-  if(!win) ERROR("SDL_CreateWindow");  +  if(!win) ERROR("Error: SDL_CreateWindow (%s)", SDL_GetError());  
   SDL_Renderer * ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);   SDL_Renderer * ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
-  if(!ren) ERROR("SDL_CreateWindow");    +  if(!ren) ERROR("Error: SDL_CreateRenderer (%s)", SDL_GetError());  
            
   /* initialize your environment */   /* initialize your environment */
Line 142: Line 141:
 // SDL2 Demo by aurelien.esnard@u-bordeaux.fr // SDL2 Demo by aurelien.esnard@u-bordeaux.fr
  
-#include <SDL2/SDL.h> +#include <SDL.h> 
-#include <SDL2/SDL_image.h>  // required to load transparent texture from PNG +#include <SDL_image.h>  // required to load transparent texture from PNG 
-#include <SDL2/SDL_ttf.h>    // required to use TTF fonts     +#include <SDL_ttf.h>    // required to use TTF fonts     
  
 #include <stdio.h> #include <stdio.h>
Line 205: Line 204:
 ==== 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:android|c'est ici !]]
  
projtec/sdl2.1487063265.txt.gz · Last modified: 2024/03/18 15:05 (external edit)