Black screen when display a bitmap in ECLIPSE+MINGW+WINDOWS

Hey guies, I studied SDL following lazy’s tutorial.
But, when i try to load a bitmap and display it as tutorial, the screen is always black.
It occurs when debugging.
But when i started the execute in command line and windows, it’s OK.
Could you give me a hand and tell me why?

Code:

#include <SDL\sdl.h>

int main(int argc, char* args[])
{
t
SDL_Surface* pHello = NULL;
SDL_Surface* pScreen = NULL;

SDL_Init(SDL_INIT_EVERYTHING);

pScreen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);

pHello = SDL_LoadBMP("hello.bmp");

SDL_BlitSurface(pHello, NULL, pScreen, NULL);

SDL_Flip(pScreen);

SDL_Delay(2000);

SDL_FreeSurface(pHello);

SDL_Quit();

return 0;

}

Thx.

no one knows?

You don’t have an error checking. Your image could have failed to
load. Try using SDL_GetError() if an error is detected (e.g.
SDL_LoadBMP() returns NULL). Almost all SDL functions can return an
error code.On 23 March 2010 08:43, lth0721 at 163.com <lth0721 at 163.com> wrote:

no one knows?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Brian Barrett wrote:

You don’t have an error checking. Your image could have failed to
load. Try using SDL_GetError() if an error is detected (e.g.
SDL_LoadBMP() returns NULL). Almost all SDL functions can return an
error code.

no one knows?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Yes, the SDL_LoadBMP returns NULL when debugging.
But, when i start the binary file directly, it’s OK.

Mandarx said that the working path might change when debugging. Maybe he is right, and i will try to test it.

And thanks for your help.> On 23 March 2010 08:43, @lth0721_at_163.com <@lth0721_at_163.com> wrote:

Some applications do not set the working directory correctly when running
other programs (Konqueror and Dolphin, I’m looking at you). I’m actually
surprised that Eclipse would mess it up. Code::Blocks works fine.

Jonny DOn Fri, Mar 26, 2010 at 7:01 AM, lth0721 at 163.com <lth0721 at 163.com> wrote:

Brian Barrett wrote:

You don’t have an error checking. Your image could have failed to
load. Try using SDL_GetError() if an error is detected (e.g.
SDL_LoadBMP() returns NULL). Almost all SDL functions can return an
error code.

On 23 March 2010 08:43, <> wrote:

Quote:

no one knows?


SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Yes, the SDL_LoadBMP returns NULL when debugging.
But, when i start the binary file directly, it’s OK.

Mandarx said that the working path might change when debugging. Maybe he is
right, and i will try to test it.

And thanks for your help.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org