# texture problem.

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

## 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 ( 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 on other sites
Well have you checked if CreatTexture actually did the job? Also have you allocated memory for m_pTextures?

##### Share on other sites
Quote:
 Original post by markhuntleyUnhandled 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 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.

1. 1
Rutin
45
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632984
• Total Posts
3009720
• ### Who's Online (See full list)

There are no registered users currently online

×