Sign in to follow this  
willthiswork89

SD_BlitSurface function

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

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