SDL drawing to screen

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
mary
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 33
Joined: Tue Apr 27, 2010 2:13 pm

SDL drawing to screen

Post 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);
User avatar
lotios611
Chaos Rift Regular
Chaos Rift Regular
Posts: 160
Joined: Sun Jun 14, 2009 12:05 pm
Current Project: Game engine for the PC, PSP, and maybe more.
Favorite Gaming Platforms: Gameboy Micro
Programming Language of Choice: C++

Re: SDL drawing to screen

Post by lotios611 »

Why don't you just do this?

Code: Select all

SDL_Rect area = {0, 0, 100, 100};
SDL_FillRect(buffer, area, 0xAAAAAA);
"Why geeks like computers: unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep." - Unknown
mary
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 33
Joined: Tue Apr 27, 2010 2:13 pm

Re: SDL drawing to screen

Post 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?
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: SDL drawing to screen

Post by eatcomics »

Just apply your text onto the rect after its been filled
Image
Post Reply