man filesplitting! help me out

Started by
15 comments, last by willthiswork89 18 years, 4 months ago
i know for a fact its there, as ive had this problem once before so if anyof you want my code ill wrap it in a zip and put it up on a geocities site
Advertisement
well any one? i really would love to get this working?
Quote:Original post by willthiswork89
okay it compiled and i get an error that my background is turning out null. which has somting to do with my function Load_Image and returning final back to the background...


So it's failing on the segment:
if(background == NULL){   printf("background turned out null!");   return 1;}

Correct? I mean it says "background turned out null!" right? If so, then see if you can further track down the problem.

SDL_Surface* Load_Image(string filename){SDL_Surface *temp = NULL;SDL_Surface *final = NULL;temp = SDL_LoadBMP(filename.c_str());if(temp != NULL){   final = SDL_DisplayFormat(temp);   if( final == NULL )   {      printf("Error, DisplayFormat failed!");   }   SDL_FreeSurface(temp);}else{   printf("Error, image could not be loaded via SDL_LoadBMP");}   return final;)


Tell us what error you get, or well what message is now displayed.


And here's my other post, that I posted, but lost my net connection so it did not go though.

Quote:Original post by pulpfist
Quote:
yes BUT when you pass a pointer to another cpp file..it gets taken as a COPY instead of directly editing the mempory of the pointer...


One of the other recent thrads talk about this item too...

It doesnt matter if it is in another cpp file realy, it always send a copy


I will first kindly refer you to a few tutorials on Pointers in C++:
Link 1
Link 2

Now let me re-explain this concept with a quick trivial example.

void SetVal(int var){   var = 0;}void SetPtrVal(int* var){   *var = 0;}void Function1(){   int x = 42;   SetVal(x);   // Will display 42   cout << x;   int y = 1024;   SetVal2(&y);   // Will display 0   cout << y;}


In relation to your other post:
// This sends a 'copy' of the object to the function, which is not modifiable// in terms of the ORIGINAL object is not modified, unless a few other specific things happenint render(Surface srf)// This sends the address of the object you are passing in.// It IS the real object when it is dereferenced and represents the address of the real object as a pointerint render(Surface* srf)// This sends the address of the pointer that is pointing to the object you are passing in. Or something weird like that, it depends on how you are using it, what you pass in.int render(Surface* &srf)

Just trying to clear that up for you [wink]
if you look at my code i have SDL_Surface *source??? i dont get it... should that be able to directly edit the crap in mains pointer then?
I cant see that I said anything that conflicts with this, but you sure got the technicalities right. Thanks
okay the error is with loading through LOAD_BMP so...what i need to do is use SDL_image.h and use that one and try it i suppose?
okay i fixed it! thanks for the help guys it turned out that the LoadBMP was bad so i included sdl_image and did IMG_Load and it worked fine! im excited haha thanks guys for the help

This topic is closed to new replies.

Advertisement