Anyone use SDL?

Pages: 12
closed account (jw6XoG1T)
im having trouble getting a BMP image to load on my screen. Im following Lazyfoo.net's tutorial and all i get is a black screen. I put the BMP in the same file as the exe. but it still doesnt work. I've been trying to find out whats wrong since yesterday but no one's been able to help me out.
At Line 22 of your code (I looked up your past posts) put this in:
1
2
if(image == NULL)
{return 0;}

Tell us if the program just quits now instead of displaying the all black window.

Also the file names are CASE SENSITIVE.
Sure, post your code and I'll take a look. Have you checked if your SDL_Surface is NULL after you attempt to load it?
closed account (jw6XoG1T)
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
29
30
31
32
33
34
35
#include <SDL.h>
#include <iostream>

int main(int argc, char* args[] )
{
	//The images

	SDL_Surface *screen = NULL;
	SDL_Surface *image = NULL;

	//Start SDL

	SDL_Init (SDL_INIT_EVERYTHING);

	//Set Screen

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

	//Load image

	image = SDL_LoadBMP("hello.bmp");

	//Apply to Screen

	SDL_BlitSurface(image, NULL, screen, NULL); 
	SDL_Flip(screen);
	SDL_Delay(2000);
	SDL_FreeSurface(image);

	//Quit SDL

	SDL_Quit();

	return 0;
}



and yeah....it cant find the BMP file for some reason even though it's in the same file as the exe.
Is "hello.bmp" the real file name? I ask because Windows has this useless option to hide known file extentions, so if the file name is "hello.bmp.bmp" then it would still be valid but your app wouldn't see it.

The option is under Folder Options if I remeber correctly.
Last edited on
closed account (jw6XoG1T)
well when i saved the image the exact thing i typed in was "hello.bmp"
Which if the file extentions are hidden would be saved as "hello.bmp.bmp", give it a shot. It takes 2 seconds what have you got to lose?
closed account (jw6XoG1T)
i tried it and it didnt work lol :(
And you're not getting any errors? Or warnings either? What IDE are you using?
closed account (jw6XoG1T)
no im not getting any warnings or errors. Im on VC++ 2010. it compiles and runs perfectly except for the fact that its not loading the image
closed account (jw6XoG1T)
ok so here are all the messages im getting when i compile it. Any clue whats wrong?


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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'crap.exe': Loaded 'C:\Users\Danielle\Documents\Visual Studio 2010\Projects\crap\Debug\crap.exe', Symbols loaded.
'crap.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Users\Danielle\Documents\Visual Studio 2010\Projects\crap\Debug\SDL.dll', Binary was not built with debug information.
'crap.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\msvcr100.dll', Symbols loaded.
'crap.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\ddraw.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\dciman32.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Cannot find or open the PDB file
'crap.exe': Unloaded 'C:\Windows\SysWOW64\ddraw.dll'
'crap.exe': Unloaded 'C:\Windows\SysWOW64\dwmapi.dll'
'crap.exe': Unloaded 'C:\Windows\SysWOW64\setupapi.dll'
'crap.exe': Unloaded 'C:\Windows\SysWOW64\devobj.dll'
'crap.exe': Unloaded 'C:\Windows\SysWOW64\oleaut32.dll'
'crap.exe': Unloaded 'C:\Windows\SysWOW64\ole32.dll'
'crap.exe': Unloaded 'C:\Windows\SysWOW64\cfgmgr32.dll'
'crap.exe': Unloaded 'C:\Windows\SysWOW64\dciman32.dll'
'crap.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Program Files (x86)\Common Files\Motive\McciContextHook_DSR.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\shell32.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Program Files (x86)\Common Files\microsoft shared\ink\tiptsf.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\KBDUS.DLL', Cannot find or open the PDB file
'crap.exe': Unloaded 'C:\Windows\SysWOW64\KBDUS.DLL'
'crap.exe': Loaded 'C:\Windows\SysWOW64\KBDUS.DLL', Cannot find or open the PDB file
'crap.exe': Unloaded 'C:\Windows\SysWOW64\KBDUS.DLL'
'crap.exe': Loaded 'C:\Windows\SysWOW64\dsound.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\powrprof.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\dinput.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\hid.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\wintrust.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\crypt32.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\msasn1.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\clbcatq.dll', Cannot find or open the PDB file
'crap.exe': Loaded 'C:\Windows\SysWOW64\oleacc.dll', Cannot find or open the PDB file
The thread 'Win32 Thread' (0xc74) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x13fc) has exited with code 0 (0x0).
The program '[2208] crap.exe: Native' has exited with code 0 (0x0).
Those are runtime errors that are basically saying that some program databases can't be found (or opened). What I'm wondering is how this is supposed to have an impact, aside from the debugger having limited access to debugging information (I'm more of a UNIX programmer, maybe I shouldn't be in this particular thread...).

-Albatross
@Albatross: Because Visual Studio like to throw the kitchen sink at your project in case you forgot something.

@OP: Check those directories, are the files actually there?
closed account (jw6XoG1T)
so what your saying is that all this has nothing to do with why the image isn't being loaded? lol
closed account (jw6XoG1T)
yeah i checked the some of the directories. The files are there
closed account (jw6XoG1T)
@ Computergeek01: Do you have SDL set up in VC++ 2010? and if so, does this code work on your computer?
Just a quick check but Visual Studio is working with simpler programs right? If you were to start a new project and make a "Hello World" then it would work?

EDIT: I actually don't use VC++ because of the crap that it gives you when you try linking, I'm almost afraid that's what we are seeing here but I haven't given up yet.
Last edited on
closed account (jw6XoG1T)
yes my hello world program worked
closed account (jw6XoG1T)
what IDE do you use? Code::Blocks?
Code::Blocks and wxDev-C++ I'm moving to Code::Blocks because of the trouble that wxDev-C++ has.

By the way at the bottom of lazyfoo's website it says:
If you're using Visual Studio and the compiler complains 'SDL/SDL.h': No such file or directory, go to the top of the source code and make sure it says #include "SDL.h".

And I noticed that your code uses #include <SDL.h>
Have you tried this other form?

EDIT: Also:

If you run the program and the images don't show up or the window flashes for a second and you find in stderr.txt:
Fatal signal: Segmentation Fault (SDL Parachute Deployed)
It's because the program tried to access memory it wasn't supposed to. Odds are its because it tried to access NULL when SDL_BlitSurface() was called. This means you need to make sure the bitmap files are in the same directory as the program. Visual Studio users will need to put the bitmap file in the same directory as your vcproj file.
Last edited on
Pages: 12