Advertisement

Problem With PnP Bios Tutorial

Started by November 03, 2004 11:14 PM
3 comments, last by pures 20 years, 3 months ago
Hello, Here's the problem. I ahve to change the source.w = source->w; and the source.h one as well. They are getting absurd values when I debug and crashing if I run them as is from the tutorial. Now the window displays. but nothing shows, just a blank screen. I've tried moving the file around, anyone help? Thanks. void Draw(int x, int y, SDL_Surface *sprite) { SDL_Rect source; SDL_Rect dest; source.x = 0; source.y = 0; //source.w = sprite->w; //source.h = sprite->h; source.w = 1024; source.h = 768; dest.x = source.x; dest.y = source.y; dest.w = source.w; dest.h = source.h; I have another file, literally identical to this one, except for the filename. when run thru the compiler it shows a blank screen, but when run from command prompt it displays the picture. when this one is run from the command prompt it won't show the pic, jsut a blank screen and I"ve tried moving it around. Anything I might be missing? thanks Pures
What compiler are you using?
I'm assuming it is dev-c++ because you can launch the program from the console. If you wanted to do that in visual C++, you would have to copy it out of the debug/release folder first.

If you are getting bogus values for the sprite->w, and sprite->h, you may want to check and make sure that you have actually loaded the file. In Visual C, everything gets intitalized to 0 when it is created, except for pointers. I think Dev-C++ manualy requires you to set the memory to null. if you don't have the file loaded, you could just be using the previous values at that location.

what good would moving the file do?
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
Advertisement
and btw, I'm trying to get all questions related to my tutorial series pointed back to my MSN group.

I don't know if that is to hard for people to use... or what.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
When running programs from the VS IDE you need to set the projects working directory - this will typically be the directory where you are outputting your executable file.

This is the probable reason for your program not displaying anything when run from within the IDE.

About you getting weird values for the sprites dimensions you might not be getting a valid surface so the values stored by sprite->w and sprite-h will be garbage, try checking the sprite surface to see if it equals NULL before you do anything with the pointer.

This is generally a good idea for any function which takes pointers as parameters to reduce the risk of bugs/possible crashes.
yeah, I'm using VC++ 7.0 .NET

I will try setting it up differently when I get home.

I believe I'm getting a valid surface.

This topic is closed to new replies.

Advertisement