• Advertisement
Sign in to follow this  

texture problem.

This topic is 4258 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey. i have had a few texturing problems and i cant seem to figure out what i need to do to fix it. this is the error i am getting Unhandled exception at 0x4fe5798b in startingD3D9.exe: 0xC0000005: Access violation writing location 0xcdcdcd7d. and it breaks at this line
//set the texture
	m_pDestinationDevice->SetTexture ( 0 , m_pTextures [ nImage ] ) ;



//constructor
CSpriteSet::CSpriteSet(IDirect3DDevice9* pDevice , LPCTSTR FileName , D3DFORMAT Format )
{
	//set the device
	m_pDestinationDevice = pDevice ;

	m_nTextureCount = 0 ;
	nImageHeight = 0;
	nImageWidth = 0;

	//load the image
	Load ( FileName, Format ) ;
}

//create an image surface to hold the largest cell
IDirect3DSurface9* pSurface ;
m_pDestinationDevice->CreateOffscreenPlainSurface ( nImageWidth , nImageHeight , Format , D3DPOOL_DEFAULT, &pSurface , NULL) ;

//create texture
m_pDestinationDevice->CreateTexture ( nTextureWidth , nTextureHeight , 1 , 0 , Format , D3DPOOL_DEFAULT , &m_pTextures [ nImage ], NULL ) ;

//copy rectangle
m_pDestinationDevice->UpdateSurface ( pSurface , &rcSrc , pTextureSurface , &ptDst ) ;

//set the texture
m_pDestinationDevice->SetTexture ( 0 , m_pTextures [ nImage ] ) ;

//render
m_pDestinationDevice->DrawPrimitiveUP ( D3DPT_TRIANGLESTRIP , 2 , &vert , sizeof ( SpriteSetVertex ) ) ;


this is the code i have used for texuring. i have cut out most of the other stuff i didnt think was important. i sort of understand the error but im stugling with a way to fix it. any help would be great thanks

Share this post


Link to post
Share on other sites
Advertisement
Well have you checked if CreatTexture actually did the job? Also have you allocated memory for m_pTextures?

Share this post


Link to post
Share on other sites
Quote:
Original post by markhuntley
Unhandled exception at 0x4fe5798b in startingD3D9.exe: 0xC0000005: Access violation writing location 0xcdcdcd7d.
The 0xcdcdcd7d looks VERY similar to one of VStudio's special debugging codes. Double check it, but I think 0xCDCDCDCD is an uninitialized variable/pointer - the 7d part could just be that you've offset it via the array look-up (or similar).

Either way, I don't think its a DirectX-specific error - probably more a general software one [smile]

Are you sure that the memory is still valid? Try stepping through the code in the debugger and seeing what happens to that piece of memory. Introduction to Debugging might be of interest if you're not familiar with this.

hth
Jack

Share this post


Link to post
Share on other sites
just spent a while looking threw it and i seem to have fixed that problem. well i think i have, there is another problem now but its differant. the original 1 seems to be working. thanks for your help.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement