Path: chuka.playstation.co.uk!news From: James Russell Newsgroups: scea.yaroze.programming.2d_graphics Subject: Re: Get pixel Date: Thu, 30 Jul 1998 13:31:49 +0100 Organization: Sony Computer Entertainment Europe Lines: 40 Message-ID: <35C067B5.7273F0C6@scee.sony.co.uk> References: <01bdb8c7$48efce00$0100fc9d@skynet> NNTP-Posting-Host: mailgate.scee.sony.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.5b1 [en] (Win95; I) X-Accept-Language: en Antony Arciuolo wrote: > > My real question is can I directly access the frame buffer (a short > GetPixel(short X, short Y) function) and how can I use this to reference > the palette of the puddle so I can use palette collision detection? unsigned short GetPixel(short X, short Y) { static RECT getPixelRect = { 0, 0, 1, 1 }; // x=y=0, w=h=1. unsigned short returnVal; getPixelRect.x = X; getPixelRect.y = Y; StoreImage(&getPixelRect,&returnVal); DrawSync(0); returnVal = (returnVal << 8) | (returnVal >> 8); return returnVal; } Notes: o X and Y are Frame Buffer coordinates, not screen coordinates. o A StoreImage is just a GPU command, and hence is put in the GPU queue (see the new FAQ on the main page for more info), so the StoreImage is not executed until everything else in the queue has been processed. That's why you have to do a DrawSync (which waits for the GPU to finish), because if you don't, then returnVal will contain a junk number. o VRAM is stored in big-endian order, not little-endian. So I do some bit shifting to turn it into a number that you'd expect. o Don't expect this method to be fast. > How are references laid out in the frame buffer since I assume all graphics > are translated into 16-bit for the final screen plotting? Yup. -- == James_Russell@scee.sony.co.uk +44 (171) 447-1626 == Developer Support Engineer - Sony Computer Entertainment Europe #'M ST#P#D "I'd like to buy a vowel, Pat. An `O' please."