Page 1 of 1

SDL drawing to screen

Posted: Tue Apr 27, 2010 2:30 pm
by mary
Hi, I've just started watching your videos on youtube, and just got into programming in SDL. I am currently following the tutorials at lazyfoo, I want to make a box that has a width of 100, and a height of 100, now I know that I use SDL_FillRect(buffer, NULL, 0xAAAAAA); to fill the whole screen, I am wondering that instead of drawing to the buffer I could draw to another object say a box, and then using BlitSurface to draw to the screen. am I on the right track?

Code: Select all

//SDL_FillRect(box, NULL, 0xAAAAAA);
SDL_Rect area = {0, 0, 100, 100};
SDL_BlitSurface(box, &area, buffer, NULL); 
SDL_Flip(buffer);

Re: SDL drawing to screen

Posted: Tue Apr 27, 2010 2:38 pm
by lotios611
Why don't you just do this?

Code: Select all

SDL_Rect area = {0, 0, 100, 100};
SDL_FillRect(buffer, area, 0xAAAAAA);

Re: SDL drawing to screen

Posted: Tue Apr 27, 2010 3:04 pm
by mary
oh, wasn't aware that I could do that, thanks for the help! but the idea behind the othere idea is that I would be able to write on the surface using ttf, would I be able to with this method?

Re: SDL drawing to screen

Posted: Tue Apr 27, 2010 3:55 pm
by eatcomics
Just apply your text onto the rect after its been filled