Omnimaga

General Discussion => Technology and Development => Computer Programming => Topic started by: jwalker on February 01, 2013, 11:01:26 pm

Title: VS 2012 + SDL issue
Post by: jwalker on February 01, 2013, 11:01:26 pm
I got all of the libs/includes/dll's set up correctly and the program compiles just fine, and runs, but the window that pops up doesn't display anything. What its supposed to do is display an image, after some debugging, I think it SDL_LoadBMP cant seem to find the image. The same code worked just fine on Ubuntu at school. I have the image in the same directory as the program and the project, and I have tried just placing the image in C:\, but it still dosen't work. Has anyone else had this problem?

I can upload the code if you really need it.
Title: Re: VS 2012 + SDL issue
Post by: ruler501 on February 01, 2013, 11:05:04 pm
The code might be important. Try with an absolute path to see if maybe its a problem with relative paths?
Title: Re: VS 2012 + SDL issue
Post by: jwalker on February 01, 2013, 11:52:51 pm
FIXED: I loaded the image before setting the video mode, although I don't know if it dose have anything to do with it
Was:
Code: [Select]
image = LoadImage("image.bmp");
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );

Now:
Code: [Select]
           screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );
image = LoadImage("image.bmp");
Title: Re: VS 2012 + SDL issue
Post by: ruler501 on February 02, 2013, 12:08:41 am
Do you use SDL_DisplayFormat for helping loading the image to format well? That could cause the problem with the image.
Title: Re: VS 2012 + SDL issue
Post by: jwalker on February 02, 2013, 12:57:37 am
Yes, I had that implemented right away, I based this off of a tutorial I have been using, the source is below if anyone wants it.
Title: Re: VS 2012 + SDL issue
Post by: jwalker on February 02, 2013, 09:03:12 pm
New question, when using a list, why does the destructor for the object that you are placing in the list get called?
Title: Re: VS 2012 + SDL issue
Post by: ruler501 on February 02, 2013, 09:13:02 pm
I wouldn't think it would be.
Title: Re: VS 2012 + SDL issue
Post by: jwalker on February 02, 2013, 11:28:29 pm
I was tracing the code with the debugger and it seemed to do that, maybe I messed up somewhere, but it still doesn't make a lot of sense to me that it would call the destructor, when creating an object.
Title: Re: Re: VS 2012 + SDL issue
Post by: Scipi on February 03, 2013, 04:27:45 am
If you are placing an object in one of the SDL containers and goes beyond allocated memory, then the container will move itself to another location in memory. I don't know if it calls the destructor on objects inside itself though.
Title: Re: VS 2012 + SDL issue
Post by: jwalker on February 03, 2013, 10:51:27 am
I'm using an STL list as the container, maybe I should look into an SDL one though
Title: Re: Re: VS 2012 + SDL issue
Post by: Scipi on February 03, 2013, 03:29:10 pm
Oops, that was a typo, I meant to say STL, as in the Standard Library. :P
Title: Re: VS 2012 + SDL issue
Post by: jwalker on February 03, 2013, 08:52:51 pm
Oh, Ok
Title: Re: VS 2012 + SDL issue
Post by: ElementCoder on February 04, 2013, 05:45:45 am
Is the image thing fixed yet? It could be a path issue. The path relativity is from where you run the program, so maybe you're running the program in a different folder than your image?
Title: Re: VS 2012 + SDL issue
Post by: jwalker on February 04, 2013, 08:02:58 am
The image thing is fixed