• Create Account

### #ActualASnogarD

Posted 09 July 2012 - 07:46 AM

This is a modified OnDraw function where I was trying to get a normal picture to blit to the surf_Trial surface, then call the proper OnDraw function to blit to the surface.

bool R_Surface::OnDraw_exp(SDL_Surface* surf_Source, int X, int Y) {
// Check if either Dest or Source surfaces are NULL
if(surf_Source == NULL) {
// If NULL return false
return false;
}
// A rectangle to hold X and Y co-ords
SDL_Rect DestR;
DestR.x = X;
DestR.y = Y;
// Put the contents of the source surface onto the destination surface
// at the X and Y given by the DestR object
SDL_BlitSurface(surf_Source, NULL, surf_Trial, &DestR);
OnDraw(surf_Trial,10,10);
// Surface was blitted successfully
return true;
}


surf_Trial pointer is declared in the header : extern SDL_Surface* surf_Trial; and set to NULL in the cpp file : extern SDL_Surface* surf_Trial = NULL;

The image I am trying to blit is declared in a different class, so is its surface but its pretty basic ... a surface is declared in the header file (none extern) , initiated in the contructor to NULL, the loader is also the typical load image and convert to screen format to opimise it.

... is that enough code to go with ? The whole lot is too much to post as it a framework for me to use to program other 2D games so it handles a lot of stuff.

EDIT: I forgot to mention the part that calls the experimental function : R_Surface::OnDraw_exp(surf_Splash, 650, 5);
surf_Splash is the image, and all I was trying to do was blit the image onto the intermediate surface (surf_Trial) and then blit the contents of the surf_Trial onto the main display surface (surf_Display).

### #1ASnogarD

Posted 09 July 2012 - 07:42 AM

This is a modified OnDraw function where I was trying to get a normal picture to blit to the surf_Trial surface, then call the proper OnDraw function to blit to the surface.

bool R_Surface::OnDraw_exp(SDL_Surface* surf_Source, int X, int Y) {
// Check if either Dest or Source surfaces are NULL
if(surf_Source == NULL) {
// If NULL return false
return false;
}
// A rectangle to hold X and Y co-ords
SDL_Rect DestR;
DestR.x = X;
DestR.y = Y;
// Put the contents of the source surface onto the destination surface
// at the X and Y given by the DestR object
SDL_BlitSurface(surf_Source, NULL, surf_Trial, &DestR);
OnDraw(surf_Trial,10,10);
// Surface was blitted successfully
return true;
}


surf_Trial pointer is declared in the header : extern SDL_Surface* surf_Trial; and set to NULL in the cpp file : extern SDL_Surface* surf_Trial = NULL;

The image I am trying to blit is declared in a different class, so is its surface but its pretty basic ... a surface is declared in the header file (none extern) , initiated in the contructor to NULL, the loader is also the typical load image and convert to screen format to opimise it.

... is that enough code to go with ? The whole lot is too much to post as it a framework for me to use to program other 2D games so it handles a lot of stuff.

PARTNERS