Sign in to follow this  

SD_BlitSurface function

This topic is 4402 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

im trying to split my sdl engine intp peices...so my main isnt so messy and hard to readsinc eim new to file splitting im trying to keep it easy so it just blits an image to the screen its really easy but for my function for blitting void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination ) { //Make a temporary rect to hold the offsets SDL_Rect Offset; //Give the offsets to the rect Offset.x = x; Offset.y = y; SDL_BlitSurface( source, NULL, destination, &Offset ); } how could i put that into the SDLENGINE.cpp and be able to return it to main because from what i hear if you try to send a pointer to a function in another cpp it only gets a copy... here the tutorial http://lazyfooproductions.com/SDL_tutorials/lesson02/index.php

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
i looked extern up and really didnt see anything having to do with directly ewditing pointers with it through another cpp file?

Share this post


Link to post
Share on other sites
Quote:

from what i hear if you try to send a pointer to a function in another cpp it only gets a copy...


If you send the pointer like this

int render(Surface* srf)
{
srf->...
}

srf will be a copy, but if you do it like this

int render(Surface* &srf)
{
srf->...
}

srf will be the original pointer
The way I see it is that you are sending the address of the pointer

EDIT:
There is another common way to solve it using extern among other things

Share this post


Link to post
Share on other sites

This topic is 4402 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this