12 Replies - 766 Views - Last Post: 04 September 2011 - 06:11 AM Rate Topic: -----

#1 DivideByZero  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 238
  • View blog
  • Posts: 551
  • Joined: 02-December 10

Loading bmp SDL problem

Posted 01 September 2011 - 11:24 AM

Hi guys,

I started to look at StayCrisp's SDL tutorial and got to the stage where you compile SDL.
The linking stage went fine, no compiler issues at all.

But for some reason, whenever I try to load a bmp I get this error:
Unhandled exception at 0x77bd15ee in SDL_Tutorial.exe: 0xC0000005: Access violation reading location 0x00000008.

This occurs when stepping past this line of code:
targetarea.w = bmp->w; // target width



I'm using SDL 1.2.14 and as you can see from the picture I've attached, I use Visual Studio 2010.
Attached Image

And here's what my solution explorer looks like.
Attached Image
Can anyone help me get started?

Thanks :)

This post has been edited by DivideByZero: 01 September 2011 - 11:26 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Loading bmp SDL problem

#2 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: Loading bmp SDL problem

Posted 01 September 2011 - 01:11 PM

Do you have the bitmap in the same directory as the project? The fact that it compiles points to the fact that it can't find the bitmap you are trying to load.
Was This Post Helpful? 1
  • +
  • -

#3 DivideByZero  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 238
  • View blog
  • Posts: 551
  • Joined: 02-December 10

Re: Loading bmp SDL problem

Posted 01 September 2011 - 01:21 PM

View Poststayscrisp, on 01 September 2011 - 01:11 PM, said:

Do you have the bitmap in the same directory as the project? The fact that it compiles points to the fact that it can't find the bitmap you are trying to load.

I don't know to be honest, how do I do that?
I added the bitmap to the solution explorer, to which it made a folder for it.
And I assumed that was all that was needed to be done (this is what I do in XNA and it works fine).

I got this from the output window if this is of any help:
Spoiler


In case you ask, here is where I put the sdl.dll:
Attached Image

Thanks again for you help :)

This post has been edited by DivideByZero: 01 September 2011 - 01:23 PM

Was This Post Helpful? 0
  • +
  • -

#4 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: Loading bmp SDL problem

Posted 01 September 2011 - 01:38 PM

Just use windows explorer and copy and paste the .bmp into the folder that has your code in it, you will also have to put the .bmp into the folder with your .exe in it if you want to run it outside visual studio.

And no problem :) Hope you enjoy the tutorials!
Was This Post Helpful? 1
  • +
  • -

#5 DivideByZero  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 238
  • View blog
  • Posts: 551
  • Joined: 02-December 10

Re: Loading bmp SDL problem

Posted 01 September 2011 - 01:50 PM

That did the trick :)

It's funny, I've tried DirectX, OpenGL, SFML and SDL, and only SDL has managed to compile and show expected output :D
Was This Post Helpful? 0
  • +
  • -

#6 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: Loading bmp SDL problem

Posted 01 September 2011 - 02:08 PM

I like SDL it's quite easy to learn and you can create some fantastic games with it :)
Was This Post Helpful? 0
  • +
  • -

#7 DivideByZero  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 238
  • View blog
  • Posts: 551
  • Joined: 02-December 10

Re: Loading bmp SDL problem

Posted 02 September 2011 - 04:57 AM

I'm hoping it can do 3D well as making little 2D games in XNA isn't really that impressive.
That was the plan for DirectX, but I just couldn't get it to compile :/
So I chose SDL as my former tutor recommends it.
Was This Post Helpful? 0
  • +
  • -

#8 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: Loading bmp SDL problem

Posted 02 September 2011 - 05:53 AM

Well it can't do 3D so you will have to use OpenGL with SDL for window creation and image loading.
Was This Post Helpful? 1
  • +
  • -

#9 bonyjoe  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 175
  • View blog
  • Posts: 548
  • Joined: 08-September 10

Re: Loading bmp SDL problem

Posted 02 September 2011 - 02:34 PM

Rather than copy pasting all the time you can click the resource and then in the properties set it to copy to output directory either always or when new. This way it will copy automatically to both debug and release builds. I think you can also just set the folder resources to this as well so any content you add to it will be automatically copied.
Was This Post Helpful? 1
  • +
  • -

#10 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: Loading bmp SDL problem

Posted 03 September 2011 - 02:14 AM

I normally just write a little batch file to handle it for me :)
Was This Post Helpful? 0
  • +
  • -

#11 bonyjoe  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 175
  • View blog
  • Posts: 548
  • Joined: 08-September 10

Re: Loading bmp SDL problem

Posted 03 September 2011 - 07:59 AM

View Poststayscrisp, on 03 September 2011 - 10:14 AM, said:

I normally just write a little batch file to handle it for me :)


But visual studio does it all for you, why make extra work :P
Was This Post Helpful? 0
  • +
  • -

#12 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: Loading bmp SDL problem

Posted 04 September 2011 - 02:37 AM

Work!? I'm a programmer :P
Was This Post Helpful? 0
  • +
  • -

#13 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Loading bmp SDL problem

Posted 04 September 2011 - 06:11 AM

Seriously though, you should do as much within the IDE as it can do for you project - that is it's purpose. For large projects having separate batch files offers the potential to seriously break the code base, as well as having configuration issues when a team of programmers are working on a project. It just won't work. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1