Hello all who read this.
I have some code framework.
I have linked the SDL main libary with no problem, How ever I cannot seem to link the SDL_image libary with dev c++ linker.
using linker flag: -lSDL_image
and all SDL_image .dlls are in the same directory as my dev c++ project along with the SDL main .dll.
and Dev c++ derectories are pointing to SDL image includes and libs/x86 folder. What I get when I run this bad boy is just a flicker of the program window and then it closes.
If your in the same boat as I am or have been all through this before please post.
Thanks.
(here is what i have and it all compiles fine)
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
int main( int argc, char* args[] )
{
bool running = true ;
//Define constant variables, such as screen dimensions, and bpp.
const int screen_width = 640;
const int screen_height = 480;
const int screen_bpp = 32;
//Define all surfaces
SDL_Surface* screen = NULL;
SDL_Surface* image = NULL;
// define condition if SDL fails to initialise
if(SDL_Init(SDL_INIT_EVERYTHING) == -1)
{
running = false ;
}
// defined pointer too computer graphics card video RAM (hardware accelarated) for screen dimensions to be drawn
screen = SDL_SetVideoMode(screen_width, screen_height, screen_bpp, SDL_HWSURFACE) ;
// windows only (maybe not my android)
SDL_WM_SetCaption("Game", NULL) ;
// define condition if screen has not been passed set values
if(screen == NULL)
{
running = false ;
}
SDL_Event occur ;
image = SDL_LoadBMP("test.bmp");
SDL_Rect offset ;
offset.x = 50,offset.y = 50 ;
// modifies the alpha transparency of SDL_Surface images
SDL_SetAlpha(image,SDL_SRCALPHA,80) ;
// pointer to array that stores key presses each variable in the array will respon to a key
Uint8 *keystates = SDL_GetKeyState(NULL) ;
// iffantley refreshing and filling the screen with a black rectangle , then flips to bring to the front on z index
while(running)
{
// SDL listens to own SDL and user key events, if events do occur store at address memory location, quit if quit events occurs
SDL_PollEvent(&occur) ;
if(occur.type == SDL_QUIT)
{
running = false ;
}
// test key address of pointer array keystates, SDL_Event occur lsitening for keyboard keypresses
if(keystates[SDLK_w])
{
offset.y -=1 ;
}
if(keystates[SDLK_a])
{
offset.x -=1 ;
}
if(keystates[SDLK_s])
{
offset.y +=1 ;
}
if(keystates[SDLK_d])
{
offset.x +=1 ;
}
SDL_FillRect(screen, NULL, 0) ;
// drawing
SDL_BlitSurface(image, NULL, screen, &offset) ;
SDL_Flip(screen) ;
}
SDL_Quit();
return 0;
}