Jump to content

  • Log In with Google      Sign In   
  • Create Account

SDL IMG_LOAD not working with DLLs


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 kg3unforgn   Members   -  Reputation: 117

Like
0Likes
Like

Posted 21 May 2014 - 06:26 PM

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;
}
 
 


Sponsor:

#2 georger.araujo   Members   -  Reputation: 818

Like
0Likes
Like

Posted 21 May 2014 - 07:19 PM

 

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.

Attached Files


Edited by georger.araujo, 21 May 2014 - 07:21 PM.


#3 Ludus   Members   -  Reputation: 970

Like
-2Likes
Like

Posted 21 May 2014 - 11:51 PM


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.



#4 kg3unforgn   Members   -  Reputation: 117

Like
0Likes
Like

Posted 22 May 2014 - 07:30 PM

 

 

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.



#5 kg3unforgn   Members   -  Reputation: 117

Like
0Likes
Like

Posted 22 May 2014 - 07:31 PM

 


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.



#6 Aldacron   GDNet+   -  Reputation: 3191

Like
0Likes
Like

Posted 31 May 2014 - 12:03 AM

Did you call IMG_Init with the proper arguments?






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS