A problem with SDL_LoadBMP

I’m currently writing a game and I’ve come across a problem. I have a
string named curset that contains “tiles/bfloor.bmp” . This string is
loaded in from a file. When I go to put it in the SDL_LoadBMP function,
like so SDL_LoadBMP(curset) , it just returns as NULL. The image location
is right. What should I do?

Check you’re current directory (the directory that the application sees as
it’s current directory.) If you supply the complete path to your image file
(as in “c:\myCode\myGame\tiles\bfloor.bmp”) and that works, then the current
directory your application has is not the one you expect.> ----- Original Message -----

From: sketch@d3cod3.net ()
To:
Sent: Saturday, June 01, 2002 11:42 PM
Subject: [SDL] A problem with SDL_LoadBMP

I’m currently writing a game and I’ve come across a problem. I have a
string named curset that contains “tiles/bfloor.bmp” . This string is
loaded in from a file. When I go to put it in the SDL_LoadBMP function,
like so SDL_LoadBMP(curset) , it just returns as NULL. The image location
is right. What should I do?


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

It’s not a directory problem. I’m in my game directory. It’s acting like
the function doesn’t understand the string value.On Sat, 1 Jun 2002, Blake Senftner wrote:

Check you’re current directory (the directory that the application sees as
it’s current directory.) If you supply the complete path to your image file
(as in “c:\myCode\myGame\tiles\bfloor.bmp”) and that works, then the current
directory your application has is not the one you expect.

----- Original Message -----
From: <@sketch_at_d3cod3.net>
To:
Sent: Saturday, June 01, 2002 11:42 PM
Subject: [SDL] A problem with SDL_LoadBMP

I’m currently writing a game and I’ve come across a problem. I have a
string named curset that contains “tiles/bfloor.bmp” . This string is
loaded in from a file. When I go to put it in the SDL_LoadBMP function,
like so SDL_LoadBMP(curset) , it just returns as NULL. The image location
is right. What should I do?


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

okay, something like:

SDL_Surface *temp;
char curset[17] = “tiles/bfloor.bmp”;

temp = SDL_LoadBMP(curset);
if (temp == NULL) {
fprint(stderr, “Could not load %s.\n”, curset);
}

should work fine. does it on your system? also, do other apps on your
system that were compiled w/ sdl work correctly?On Sat, 2002-06-01 at 23:42, sketch at d3cod3.net wrote:

I’m currently writing a game and I’ve come across a problem. I have a
string named curset that contains “tiles/bfloor.bmp” . This string is
loaded in from a file. When I go to put it in the SDL_LoadBMP function,
like so SDL_LoadBMP(curset) , it just returns as NULL. The image location
is right. What should I do?


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Chris
@Christopher_Thielen

It’s not a directory problem. I’m in my game directory. It’s acting like
the function doesn’t understand the string value.

Try changing environment / compiler, if you can. If you’re using VC++ 6, it has MANY bugs in the management of
strings (at least in C, don’t know about C++).

sketch at d3cod3.net wrote:

I’m currently writing a game and I’ve come across a problem. I have a
string named curset that contains “tiles/bfloor.bmp” . This string is
loaded in from a file. When I go to put it in the SDL_LoadBMP function,
like so SDL_LoadBMP(curset) , it just returns as NULL. The image location
is right. What should I do?

make sure the BMP file isn’t RLE encoded, I don’t know if that compression is supported in SDL_LoadBMP…

there’s a comment in the SDL code:

This code currently supports Win32 DIBs in uncompressed 8 and 24 bpp.–
-==-
Jon Atkins
http://jcatki.2y.net/

I managed to get it to work, it was picking up a new line character in
the string when I used fread(). So I put in the null terminator and it
worked.On 1 Jun 2002, Chris wrote:

okay, something like:

SDL_Surface *temp;
char curset[17] = “tiles/bfloor.bmp”;

temp = SDL_LoadBMP(curset);
if (temp == NULL) {
fprint(stderr, “Could not load %s.\n”, curset);
}

should work fine. does it on your system? also, do other apps on your
system that were compiled w/ sdl work correctly?

On Sat, 2002-06-01 at 23:42, @sketch_at_d3cod3.net wrote:

I’m currently writing a game and I’ve come across a problem. I have a
string named curset that contains “tiles/bfloor.bmp” . This string is
loaded in from a file. When I go to put it in the SDL_LoadBMP function,
like so SDL_LoadBMP(curset) , it just returns as NULL. The image location
is right. What should I do?


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Chris
chris at luethy.net


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Jonathan Atkins wrote:

sketch at d3cod3.net wrote:

I’m currently writing a game and I’ve come across a problem. I have a
string named curset that contains “tiles/bfloor.bmp” . This string is
loaded in from a file. When I go to put it in the SDL_LoadBMP function,
like so SDL_LoadBMP(curset) , it just returns as NULL. The image
location
is right. What should I do?

make sure the BMP file isn’t RLE encoded, I don’t know if that
compression is supported in SDL_LoadBMP…

there’s a comment in the SDL code:

This code currently supports Win32 DIBs in uncompressed 8 and 24 bpp.

I recommend using DevIL (http://www.imagelib.org/) to load any image
(works with lot’s of image types, on lot’s of compilers and lot’s of
platforms…).
AFAIK, it can load compressed BMP too…
What I don’t know is how lo load the image into a SDL surface, since I
use it with OpenGL textures, but it’s probably quite easy.

RK.

Not to mention that Win32 uses \ instead of /.

-JohnOn Sun, Jun 02, 2002 at 12:13:06PM +0200, CRV?ADER/KY wrote:

It’s not a directory problem. I’m in my game directory. It’s acting like
the function doesn’t understand the string value.

Try changing environment / compiler, if you can. If you’re using VC++ 6, it has MANY bugs in the management of
strings (at least in C, don’t know about C++).

Curiously enough Windows usually seems happy to deal with forward slashes in
filenames though. However, changing the slash is worth a try anyway.

cu,
NicolaiAm Sonntag, 2. Juni 2002 21:49 schrieb overcode at overcode.net:

On Sun, Jun 02, 2002 at 12:13:06PM +0200, CRV?ADER/KY wrote:

It’s not a directory problem. I’m in my game directory. It’s acting
like the function doesn’t understand the string value.

Try changing environment / compiler, if you can. If you’re using VC++ 6,
it has MANY bugs in the management of strings (at least in C, don’t know
about C++).

Not to mention that Win32 uses \ instead of /.

WRONG!

The Win32 API can use / just as well as .
The only program that doesn’t support / is
cmd.com (The command shell).

The problem lies in the applications that continue
to use \ as an history reason.

Paulo Pinto> -----Original Message-----

From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org]On Behalf Of
overcode at overcode.net
Sent: domingo, 2 de Junho de 2002 20:50
To: sdl at libsdl.org
Subject: Re: [SDL] A problem with SDL_LoadBMP

On Sun, Jun 02, 2002 at 12:13:06PM +0200, CRV?ADER/KY wrote:

It’s not a directory problem. I’m in my game directory.
It’s acting like

the function doesn’t understand the string value.

Try changing environment / compiler, if you can. If you’re
using VC++ 6, it has MANY bugs in the management of
strings (at least in C, don’t know about C++).

Not to mention that Win32 uses \ instead of /.

-John


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl