Jump to content
  • Advertisement
Sign in to follow this  
willthiswork89

man filesplitting! help me out

This topic is 4896 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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 happen
int 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 pointer
int 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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!