The function now compiles, but the program crashes
when the blitting function has been called, i’m now
unlocking the screen before the blit, but not the
window (src) content surface ( the program crashes
at startup when you unlock the content surface ).
Bellow is the updated code.
void window(struct container *screen, struct colour colour, SDL_Rect
area, struct container *content, char name[1000], int shade, int
titlebar, int border, int close, int iconify, int zoom, int update )
{
int x,y;
SDL_Rect title;
SDL_Rect cbutton;
SDL_Rect shaded;
SDL_Rect windowarea;
SDL_Rect blank;
struct colour fillcolour;
struct colour background;
fillcolour.R=0;
fillcolour.G=0;
fillcolour.B=colour.B-150;
background.R=25;
background.G=50;
background.B=75;
cbutton.x=area.w-25;
cbutton.y=area.y+5;
cbutton.w=area.w-5;
cbutton.h=area.h-5;
title.x=area.x+4;
title.y=area.y+4;
title.w=area.w-1;
title.h=area.y+30;
windowarea.x=area.x+5;
windowarea.y=area.y+35;
windowarea.w=area.w;
windowarea.h=area.h;
shaded.x=area.x;
shaded.y=area.y;
shaded.w=area.w-1;
shaded.h=area.y+31;
blank.x=0;
blank.y=0;
blank.w=content->area.w;
blank.h=content->area.h;
// check if window isnt shaded
if ( titlebar )
{
FillRect(screen, fillcolour, title, 0);
// draw title bar if there is one
DrawFrame(screen,colour,title,0,1,0);
title.x=area.x+15;
title.y=area.y+15;
title.w=area.w-35;
title.h=area.x+25;
drawText(screen, colour, title, name, 1,1, 0);
if ( close )
{
cbutton.x=area.w;
cbutton.y=area.y;
cbutton.w=area.w;
cbutton.h=area.y+25;
//button(screen,colour,cbutton,1,0,0);
}
if ( shade )
{
if ( border )
DrawFrame(screen,colour,shaded,0,2,0);
}else{
if ( border )
DrawFrame(screen,colour,area,0,2,0);
// draw window contents
for(y=windowarea.y; y < windowarea.h; y++)
{
for(x=windowarea.x; x < windowarea.w; x++)
{
DrawPixel(screen,background,x,y,0);
}
}
SDL_UnlockSurface(screen->image);
//SDL_UnlockSurface(content->image);
if( SDL_BlitSurface(content->image, &blank, screen->image,
&windowarea) < 0 )
fprintf(stderr, “BlitSurface error: %s\n”, SDL_GetError());
SDL_LockSurface(screen->image);
//SDL_LockSurface(content->image);
}
}
if ( update )
SDL_UpdateRects(screen->image, 1, &area);
}