Jump to content
  • Advertisement
Sign in to follow this  
kg3unforgn

SDL IMG_LOAD not working with DLLs

This topic is 1656 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone I am new to SDL, and I saw and read a topic about the IMG_Load function in SDL2. I am currently going through the book SDL2 Game Development with Shawn Mitchell. I am currently on Chapter 2. I could not load BMP images without installing the SDL2 Image Header, everything seemed to be working fine, until I ran into other BMP, JPEG, PNG files were not loading. I researched and found I needed more dlls, so I placed all the Image dlls in the debug folder, but no luck. Nothing pretty much seems to be working here. I created a initImage Function to handle the Image Initialization, it currently works, though, the loading of the images do not. I am not sure what is problem, I tried at least 10 different images, none of them work expect the bmp images I previously had before I installed the header files.  I even tired going on LazyFoo's website and following those directions. I know the images are not corrupted or anything, I mean I can open and close them just fine. I just can't Load them.
 
Here is the source code to my Function, but I am pretty sure it isn't the issue:

 
void Game::initImage()
{
SDL_Surface* pTempSurface = IMG_Load("Assets/kyoko.gif"); // Not working at the moment
gTexture =SDL_CreateTextureFromSurface(gRenderer,pTempSurface);
SDL_FreeSurface(pTempSurface);
 
SDL_QueryTexture(gTexture,NULL,NULL,&gSourceRectangle.w,&gSourceRectangle.h);
gDestinationRectangle.x = gSourceRectangle.x = 100;
gDestinationRectangle.y = gSourceRectangle.y = 100;
gDestinationRectangle.w = gSourceRectangle.w;
gDestinationRectangle.h = gSourceRectangle.h;
}
 
 

Share this post


Link to post
Share on other sites
Advertisement

 

Hey everyone I am new to SDL, and I saw and read a topic about the IMG_Load function in SDL2. I am currently going through the book SDL2 Game Development with Shawn Mitchell. I am currently on Chapter 2. I could not load BMP images without installing the SDL2 Image Header, everything seemed to be working fine, until I ran into other BMP, JPEG, PNG files were not loading. I researched and found I needed more dlls, so I placed all the Image dlls in the debug folder, but no luck. Nothing pretty much seems to be working here. I created a initImage Function to handle the Image Initialization, it currently works, though, the loading of the images do not. I am not sure what is problem, I tried at least 10 different images, none of them work expect the bmp images I previously had before I installed the header files.  I even tired going on LazyFoo's website and following those directions. I know the images are not corrupted or anything, I mean I can open and close them just fine. I just can't Load them.
 
Here is the source code to my Function, but I am pretty sure it isn't the issue:

 
void Game::initImage()
{
SDL_Surface* pTempSurface = IMG_Load("Assets/kyoko.gif"); // Not working at the moment
gTexture =SDL_CreateTextureFromSurface(gRenderer,pTempSurface);
SDL_FreeSurface(pTempSurface);
 
SDL_QueryTexture(gTexture,NULL,NULL,&gSourceRectangle.w,&gSourceRectangle.h);
gDestinationRectangle.x = gSourceRectangle.x = 100;
gDestinationRectangle.y = gSourceRectangle.y = 100;
gDestinationRectangle.w = gSourceRectangle.w;
gDestinationRectangle.h = gSourceRectangle.h;
}

 

 

Stating that "Nothing pretty much seems to be working here" really doesn't help. You have to describe the issue in more detail. For example:

- What is the OS and compiler?

- Does your program compile fine? Does it link succesfully?

- In case it compiles and links fine, does the program work until a particular point and then crash? Or something else happens?

 

I've read that book (I have some complaints about it) and I'm working through LazyFoo's tutorials right now. Off the top of my head:

- Did you remember to call IMG_Init() prior to calling IMG_Load()?

- Have you tried to investigate what is wrong by calling IMG_GetError()?

 

It could also be that you made a mistake when you set up your project. In case you're running Visual Studio 2013, I've made an SDL2 application template that I've attached to this reply; it has a Post-Build Event that copies the DLLs from $SDL2_HOME\lib\x86 to the output folder, so that would be one less possible source of problems to worry about. Here's how to install and use it:

1) Create a system environment variable called SDL2_HOME pointing to the folder where you installed SDL2.
2) Copy the attached ZIP file to Documents\Visual Studio 2013\Templates\ProjectTemplates under your home folder.
3) Open Visual Studio and click FILE, New Project... The "SDL2 Application" Visual C++ template is now available. Create your project.
4) The project is all set up, and the small bundled sample program is ready to compile.

Edited by georger.araujo

Share this post


Link to post
Share on other sites


I researched and found I needed more dlls, so I placed all the Image dlls in the debug folder, but no luck.

 

Have you tried placing the .dll files in the same folder as your header and source files? Placing them in the debug folder will only matter if you run your game from application file in that folder.

Share this post


Link to post
Share on other sites

 

 

Hey everyone I am new to SDL, and I saw and read a topic about the IMG_Load function in SDL2. I am currently going through the book SDL2 Game Development with Shawn Mitchell. I am currently on Chapter 2. I could not load BMP images without installing the SDL2 Image Header, everything seemed to be working fine, until I ran into other BMP, JPEG, PNG files were not loading. I researched and found I needed more dlls, so I placed all the Image dlls in the debug folder, but no luck. Nothing pretty much seems to be working here. I created a initImage Function to handle the Image Initialization, it currently works, though, the loading of the images do not. I am not sure what is problem, I tried at least 10 different images, none of them work expect the bmp images I previously had before I installed the header files.  I even tired going on LazyFoo's website and following those directions. I know the images are not corrupted or anything, I mean I can open and close them just fine. I just can't Load them.
 
Here is the source code to my Function, but I am pretty sure it isn't the issue:

 
void Game::initImage()
{
SDL_Surface* pTempSurface = IMG_Load("Assets/kyoko.gif"); // Not working at the moment
gTexture =SDL_CreateTextureFromSurface(gRenderer,pTempSurface);
SDL_FreeSurface(pTempSurface);
 
SDL_QueryTexture(gTexture,NULL,NULL,&gSourceRectangle.w,&gSourceRectangle.h);
gDestinationRectangle.x = gSourceRectangle.x = 100;
gDestinationRectangle.y = gSourceRectangle.y = 100;
gDestinationRectangle.w = gSourceRectangle.w;
gDestinationRectangle.h = gSourceRectangle.h;
}

 

 

Stating that "Nothing pretty much seems to be working here" really doesn't help. You have to describe the issue in more detail. For example:

- What is the OS and compiler?

- Does your program compile fine? Does it link succesfully?

- In case it compiles and links fine, does the program work until a particular point and then crash? Or something else happens?

 

I've read that book (I have some complaints about it) and I'm working through LazyFoo's tutorials right now. Off the top of my head:

- Did you remember to call IMG_Init() prior to calling IMG_Load()?

- Have you tried to investigate what is wrong by calling IMG_GetError()?

 

It could also be that you made a mistake when you set up your project. In case you're running Visual Studio 2013, I've made an SDL2 application template that I've attached to this reply; it has a Post-Build Event that copies the DLLs from $SDL2_HOME\lib\x86 to the output folder, so that would be one less possible source of problems to worry about. Here's how to install and use it:

1) Create a system environment variable called SDL2_HOME pointing to the folder where you installed SDL2.
2) Copy the attached ZIP file to Documents\Visual Studio 2013\Templates\ProjectTemplates under your home folder.
3) Open Visual Studio and click FILE, New Project... The "SDL2 Application" Visual C++ template is now available. Create your project.
4) The project is all set up, and the small bundled sample program is ready to compile.

 

Thanks for Replying. Your correct I just cannot say it does not work, there is always a reason. ESP. for a programmer. I am using Visual Studios 2012 at the moment, and I am on Windows 7.  The program complies just fine, although it has a warning  "warning LNK4090 default 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library"

I also have not tried IMG_GetError() or IMG_Init(). I am going to try those righ tnow and see what happens. as well research in to more in depth of what is going on and what I am I doing wrong.

Share this post


Link to post
Share on other sites

 


I researched and found I needed more dlls, so I placed all the Image dlls in the debug folder, but no luck.

 

Have you tried placing the .dll files in the same folder as your header and source files? Placing them in the debug folder will only matter if you run your game from application file in that folder.

 

I have tried that, but that did not work either before. Let me try that one more time to see if that works too.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!