Path: chuka.playstation.co.uk!news From: Chris Chadwick Newsgroups: scee.yaroze.beginners Subject: Re: DrawSync confusion. Date: Tue, 11 Aug 1998 00:56:55 -0700 Organization: PlayStation Net Yaroze (SCEE) Lines: 69 Message-ID: <35CFF947.10D5@dial.pipex.com> References: <35c6f063.10719834@news.playstation.co.uk> <35C6F927.4765EF18@scee.sony.co.uk> NNTP-Posting-Host: usern605.uk.uudial.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 2.02 (Win95; I; 16bit) James Russell wrote: > > 1) When you're loading TIMs into VRAM using LoadImage, the GPU will queue up the LoadImage command > (which means that it doesn't get executed immmediately). When it gets around to processing it, it > will use the values in the RECT structure that exists at the time of the GPU processing, rather than > the values that were in the RECT when you did the LoadImage. Thus doing this: > > setRect(&myRect,1,2,3,4); > LoadImage(&myRect,&myTimData); > setRect(&myRect,5,6,7,8); > > is more likely to use the _latter_ rectangle instead of the intended former rectangle. To get around > this, it is advisable to do a DrawSync(0) directly after the LoadImage instruction, which guarantees > that the values the GPU will use will be the ones you intend. > Are you sure about this? I only ask as I use MoveImage without a subsequent DrawSync and everything works OK. I use the following function to dynamically create a sprite by using MoveImage to copy characters from a font TIM into the sprite area of VRAM: //*------------------------------------------------------------------------------------------ //* MakeAmmoBarText //*------------------------------------------------------------------------------------- void MakeAmmoBarText(char *charp) { RECT src; int len=0; int destX = timData[TIM_POLYCART].px+31; //* 31 is 124>>2 because of 4bit pixels int destY = timData[TIM_POLYCART].py+40; int ascii; int fontX = timData[TIM_POLYCART].px+4; //* Set font image source rect (constant members) src.y = destY; src.h = 5; src.w = 1; //* 1 is 4 4bit pixels wide //* Copy chars to sprite image area while (ascii = *charp++) { if (ascii==' ') src.x = fontX + 26; //* Space pattern is after Z else src.x = fontX + (ascii - 'A'); MoveImage(&src, destX++, destY); len++; } //* Update .x and .w sprite settings for this text ammoText->x = AMMO_BAR_X + ((BAR_MAX - (ammoText->w=len<<2)) >> 1); } As you can see, the main loop copies a character at a time from the font TIM using MoveImage (altering the RECT on each iteration!) without a subsequent DrawSync. This is vital as this function will be called from within the main game loop where a DrawSync issued anywhere other than before the main VSync would cause havoc. When I queried the EXACT operation of MoveImage a couple of months back, I was told (by someone at tech support, I think) it was OK to do this as a copy of the RECT is made when the MoveImage request is put in the GPU queue. Thus, the RECT can be altered immediately after MoveImage without fear of getting undesirable results. This indeed appears to be the case as the above function works fine. I would, then, be very surprised if LoadImage doesnt also operate in the same manner by storing a copy of the RECT when executed. Then again, I've been surprised before :) Regards, -Chris