hello, you can use
SDL 2.0.3 in
Orwell Dev C++ 5.6.1
in following way (for 32bit):
( latest Dev C++:
http://sourceforge.net/projects/orwelldevcpp/ )
1) download "SDL2-devel-2.0.3-mingw.tar.gz"
from
http://libsdl.org/download-2.0.php
and extract them to "dev_lib" folder (you can choose your own path.)
C:\dev_lib\
2) start Dev C++, create an Empty project: File>new>Project
then select "empty project" press "ok"
3) Tools>Compiler Options > Directories > in C++ includes tab:
add following by click little orange folder icon:
C:\dev_lib\SDL2-2.0.3\i686-w64-mingw32\include\SDL2
4) then in Libraries tab to the left:
add following by click little orange folder icon:
C:\dev_lib\SDL2-2.0.3\i686-w64-mingw32\lib
5) then, Project > Project options > Parameters Tab > Linker :
add this string:
-lmingw32 -lSDL2main -lSDL2 |
6) Directories Tab > Include Directories:
add: C:\dev_lib\SDL2-2.0.3\i686-w64-mingw32\include\SDL2
7) in Library Directories, add: C:\dev_lib\SDL2-2.0.3\i686-w64-mingw32\lib
8) copy the
file from
C:\dev_lib\SDL2-2.0.3\i686-w64-mingw32\bin
to, where your project executable will run.
Done!
now compile and run this SDL code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include <SDL.h>
#include <iostream>
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
int main( int argc, char* args[] ){
SDL_Window* window = NULL;
SDL_Surface* screenSurface = NULL;
if( SDL_Init( SDL_INIT_VIDEO ) < 0 ){
printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
}
else{
window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
if( window == NULL ){
printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
}
else{
screenSurface = SDL_GetWindowSurface( window );
SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0xFF, 0xFF ) );
SDL_UpdateWindowSurface( window );
SDL_Delay( 2000 );
}
}
SDL_DestroyWindow( window );
SDL_Quit();
return 0;
}
|
if you see a white screen for 2 sec, then its ok!
:)
EDIT:
you can use the new created project folder as "template" so you need not initialize for every new SDL project (use copy of the "template")