parent
555bed312f
commit
9547300fc4
@ -0,0 +1,57 @@ |
||||
#include "../jade.h" |
||||
#include "sdl2.inc" |
||||
|
||||
// SCREEN DIMENSIONS
|
||||
CONSTANT INT SCREEN_WIDTH = 640; |
||||
CONSTANT INT SCREEN_HEIGHT = 480; |
||||
|
||||
MAIN |
||||
DIM AS PWINDOW window = NULL; |
||||
DIM AS PSURFACE screenSurface = NULL; |
||||
DIM AS BOOL quit = false; |
||||
DIM AS SDL_Event e; |
||||
|
||||
IF ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) THEN |
||||
PRINT( SDL_GetError() ); |
||||
ELSE |
||||
//Create Window
|
||||
window = SDL_CreateWindow( "SDL Simple Window", |
||||
SDL_WINDOWPOS_UNDEFINED, |
||||
SDL_WINDOWPOS_UNDEFINED, |
||||
SCREEN_WIDTH, |
||||
SCREEN_HEIGHT, |
||||
SDL_WINDOW_SHOWN); |
||||
|
||||
IF ( window == NULL ) THEN |
||||
PRINT( SDL_GetError() ); |
||||
ELSE |
||||
// Get Window Surface
|
||||
screenSurface = SDL_GetWindowSurface( window ); |
||||
|
||||
|
||||
WHILE (NOT quit) BEGIN |
||||
WHILE ( SDL_PollEvent( ADDR e) != 0 ) BEGIN |
||||
SELECT (e.type) BEGIN |
||||
CASE SDL_QUIT: |
||||
quit = true; |
||||
ENDCASE |
||||
ENDSELECT |
||||
WEND |
||||
// Fill the surface with White
|
||||
SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 255, 255, 255 ) ); |
||||
// Update the Surface
|
||||
SDL_UpdateWindowSurface( window ); |
||||
|
||||
WEND |
||||
ENDIF |
||||
ENDIF |
||||
|
||||
//Destroy Window
|
||||
SDL_DestroyWindow( window ); |
||||
|
||||
// Shutdown SDL
|
||||
SDL_Quit(); |
||||
|
||||
RETURN 0; |
||||
|
||||
END |
@ -0,0 +1,40 @@ |
||||
You will find simple test code |
||||
to compare SDL2 with SFML2. |
||||
|
||||
They will be as follows: |
||||
======= |
||||
01sdl \ |
||||
> simple blank window with background color |
||||
01sfml / |
||||
======= |
||||
02sdl \ |
||||
> simple window with image background |
||||
02sfml / |
||||
======= |
||||
03sdl \ |
||||
> simple 2D drawing |
||||
03sfml / |
||||
======= |
||||
04sdl \ |
||||
> simple 2D sprites |
||||
04sfml / |
||||
======= |
||||
05sdl \ |
||||
> simple 2D animated sprites |
||||
05sfml / |
||||
======= |
||||
06sdl \ |
||||
> simple 2D animated sprites keyboard control |
||||
06sfml / |
||||
======= |
||||
07sdl \ |
||||
> simple 2D animated sprites mouse control |
||||
07sfml / |
||||
======= |
||||
08sdl \ |
||||
> simple 3D window rotating colored cube with keyboard control |
||||
08sfml / |
||||
======= |
||||
09sdl \ |
||||
> simple 3D window rotating textured cube with keyboard control |
||||
09sfml / |
@ -0,0 +1,33 @@ |
||||
#ifdef _WIN32 |
||||
#include "SDL2\SDL.h" |
||||
#include "SDL2\SDL_image.h" |
||||
#include "SDL2\SDL_mixer.h" |
||||
#include "SDL2\SDL_ttf.h" |
||||
#else |
||||
#include <SDL.h> |
||||
#include <SDL_image.h> |
||||
#include <SDL_mixer.h> |
||||
#include <SDL_ttf.h> |
||||
#endif |
||||
|
||||
typedef SDL_Window* PWINDOW; |
||||
typedef SDL_Surface* PSURFACE; |
||||
typedef SDL_Renderer* PRENDERER; |
||||
typedef SDL_Event EVENT; |
||||
typedef SDL_Rect RECT; |
||||
|
||||
#define SetRenderDrawColor SDL_SetRenderDrawColor |
||||
#define RenderClear SDL_RenderClear |
||||
#define RenderDrawRect SDL_RenderDrawRect |
||||
#define RenderFillRect SDL_RenderFillRect |
||||
#define RenderDrawLine SDL_RenderDrawLine |
||||
#define RenderPresent SDL_RenderPresent |
||||
#define Delay SDL_Delay |
||||
#define Quit SDL_Quit |
||||
#define CreateWindow SDL_CreateWindow |
||||
#define CreateRenderer SDL_CreateRenderer |
||||
#define PollEvent SDL_PollEvent |
||||
#define KEYDOWN SDL_KEYDOWN |
||||
#define KEYUP SDL_KEYUP |
||||
#define Init SDL_Init |
||||
#define Rect SDL_Rect |
Loading…
Reference in new issue