## Recommended Posts

I'm working with MS Visual Studio .NET 2003, and I made a new Visual Studio C++ Project (a empty win32 console project). SDL is working fine, and I'm getting my images at my screen, when I'm using the SDL_LoadBMP function. Now I want to use Images I included in my resource-file, but it doesn't work that well. I made this small function, to load an image out of a resource, but I still get a black screen, when I use it as a background. So it doesn't load the image, what am I doing wrong?
SDL_Surface* GetBitmap(int resID)
{
SDL_Surface *image;

HMODULE ownModuleHandle    = GetModuleHandle(NULL);
HRSRC hrsrc = FindResource(ownModuleHandle, MAKEINTRESOURCE(resID), RT_RCDATA);
DWORD size = SizeofResource(ownModuleHandle,hrsrc);
void *buf = LockResource(hglob);

SDL_RWops *rw;
rw = SDL_RWFromMem(buf, size);
SDL_FreeRW(rw);
return image;
}


##### Share on other sites
I did some checks after every step, and I noticed that i get the first error after

Quote:
 HRSRC hrsrc = FindResource(ownModuleHandle, MAKEINTRESOURCE(resID), RT_RCDATA);

If I change the RT_RCDATA to RT_BITMAP, I only get an error after:

Quote:

(It returns a NULL pointer)

Anyone got an idea?

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627689
• Total Posts
2978648

• 13
• 14
• 12
• 10
• 12