Welcome! Log In Create A New Profile

Advanced

Drawing to the screen (codemii tutorial 4)?

Posted by rhyno_dagreat 
Drawing to the screen (codemii tutorial 4)?
June 17, 2009 06:31AM
I was wondering if someone could explain the drawing method used in codemii tutorial # 4 (the square cursor, in particular). It looks like there's a pointer to video memory in which colors are being drawn to, but why are all the x's >>= 1? Also what's the resolution in this, because in the DrawHLine you're multiplying y * 320 (which I was guessing was the width of a scanline), and in DrawVLine, you're doing (640 * y)/2. Why couldn't you just do (320 * y)?

Thanks for your time! ^_^
Re: Drawing to the screen (codemii tutorial 4)?
June 19, 2009 07:18PM
Does anyone here know how this works? I can't find any documentation on it.
Re: Drawing to the screen (codemii tutorial 4)?
June 19, 2009 07:24PM
The cursor is a 2x2 square, which is defined at the coordinates ir.x, (ir.x+1), ir.y, and (ir.y+1). The increment is used to define the other end of the line.

i.e. draw horizontal line from ir.x to ir.x+1, then draw vertical line from ir.y to ir.y +1.
Re: Drawing to the screen (codemii tutorial 4)?
June 20, 2009 04:07AM
Thanks! But why are the x's right shifted by 1?
Re: Drawing to the screen (codemii tutorial 4)?
June 20, 2009 08:40AM
Quote
rhyno_dagreat
Thanks! But why are the x's right shifted by 1?
Shifting 1 to the right is the same as dividing the number by two. I'm not sure if that's why the shift was used though.
Re: Drawing to the screen (codemii tutorial 4)?
June 21, 2009 12:07AM
because in the framebuffer each 32 bit word in a line stores two pixels information... and it's not rgb by the way...
Re: Drawing to the screen (codemii tutorial 4)?
June 21, 2009 03:20AM
Quote
I.R.on
because in the framebuffer each 32 bit word in a line stores two pixels information... and it's not rgb by the way...

Thanks! If it's not RGB, do you know what the layout is? Or is it just random constants representing colors?
Re: Drawing to the screen (codemii tutorial 4)?
June 21, 2009 12:24PM
There is a broad discussion about it here : [www.dbfinteractive.com]

In memory two pixel's information is stored as Y1CbY2Cr.... Y1 and Y2 respectively luminance value for those two pixels... Cb and Cr values (Chrominance blue, Chrominance red) are shared by two pixels adjacent horizontally...

ps: by the way, reading about it all probably you will end up trying to convert from RGB to Y1CbY2Cr like I did when I was introducing fade in & fade out effects into Crazy Intro... Instead I opted to use Grrlib which abstracts these details...



Edited 1 time(s). Last edit at 06/21/2009 12:27PM by I.R.on.
Sorry, only registered users may post in this forum.

Click here to login