Path: chuka.playstation.co.uk!news From: Chris Chadwick Newsgroups: scee.yaroze.programming.3d_graphics Subject: Re: Texture Problems Again Date: Wed, 28 May 1997 00:42:13 -0700 Organization: PlayStation Net Yaroze (SCEE) Lines: 77 Message-ID: <338BE1D5.71D3@dial.pipex.com> References: <33889736.687B@cobradev.demon.co.uk> <338A9D3C.EA8@interactive.sony.com> NNTP-Posting-Host: ak050.du.pipex.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 2.02 (Win95; I; 16bit) Developer Support wrote: > > colin adams wrote: > > > > 1. I have located a Bug in my project, the offending code > > Is appended. The symptom of this code is a complete Crash. > > I would be extremely grateful if someone could examine this > > code & tell me where I may be going wrong. > > > > > > /* Bugged Code */ > > > > #define FLTEX_ADDRESS 0x800c03BC // Floor Texture 64*64, 8 bit clut > > void InitTexture (u_long *address);// texture in sytem memory > > u_long *tptr; > > > > void main() > > { > > tptr =(u_long*)FLTEX_ADDRESS; > > InitTexture (tptr); > > } > > > > void InitTexture (u_long *address) > > { > > GsIMAGE *Info; // tim info ptr // POINTER ONLY > > RECT rect; > > > > // +4 skip header of TIM file > > address++; > > GsGetTimInfo(address,Info); > > rect.x = Info->px; > > rect.y = info->py; > > rect.w = Info->pw; > > rect.h = Info->ph; > > LoadImage(&rect,Info->pixel); > > DrawSync(0); > > > > rect.x = Info->cx; > > rect.y = Info->cy; > > rect.w = Info->cw; > > rect.h = Info->ch; > > LoadImage(&rect,Info->clut); > > DrawSync(0); > > } > > I think the problem is that there is no memory allocated for your > GsIMAGE* pointer to point to (GsGetTimInfo will NOT allocate it > as far as I know). Hence, you cannot store and retrieve things > successfully; I suspect the feed of bad values to LoadImage > is what actually causes the total crash. > > Declare the GsIMAGE as full structure rather than variable, > things should now work. > Also, if you _ever_ need to refer to our use a TIM file > more than once, it's very handy having a GsIMAGE structure > with all the correct info available, so you can make GsIMAGE > structures global for later reuse. > > Lewis Hi, Someone posted to the 2D_graphics group with a related problem to this one. Not only will you have to create an actual GsIMAGE structure variable with 'GsIMAGE info' instead of 'GsIMAGE *info' and pass it's address with 'GsGetTimInfo(address, &info)', but you will also have to initialize the graphics system in main() using GsInitGraph() (before call to InitTexture() ). See Library Ref. page 101 which says none of the 'Gs****' functions work correcly until the graphics system has been initialized. Hence, garbage values returned by GsGetTimInfo() lead later in your code to an almost inevitable crash. Hope this helps! Chris Chadwick