
my friend told me that i need add code to 2Drender
but
why when i add this to my 2DRender
BOOL C2DRender::RenderTextureCircle( CPoint pt, CTexture* pTexture, float radius, BOOL bIsCenter, DWORD dwBlendFactorAlpha, FLOAT fScale )
{
pt += m_ptOrigin;
if( pTexture == NULL )
return FALSE;
if( radius == 0.0f )
radius = float(min(pTexture->m_size.cx,pTexture->m_size.cy)/2);//assuring that whole circle can be displayed
radius *= fScale;
if( !bIsCenter )
{
pt.x += long(radius);
pt.y += long(radius);
}
TEXTUREVERTEX pVertex[366];
float x1 = float(pt.x);
float y1 = float(pt.y);
float u1 = 0.5f;
float v1 = 0.5f;
for( int i=0;i<=363; )
{
float angle = ( i / 57.3f );
float x2 = pt.x + ( radius * sin( angle ) );
float y2 = pt.y + ( radius * cos( angle ) );
float u2 = 0.5f + ( 0.5f * sin( angle ) );
float v2 = 0.5f + ( 0.5f * cos( angle ) );
SetTextureVertex( &pVertex[i++], float(pt.x), float(pt.y), 0.5f, 0.5f );
SetTextureVertex( &pVertex[i++], x1, y1, u1, v1 );
SetTextureVertex( &pVertex[i++], x2, y2, u2, v2 );
y1 = y2;
x1 = x2;
u1 = u2;
v1 = v2;
}
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, 1 );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, 1 );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, D3DCOLOR_ARGB( dwBlendFactorAlpha, 0, 0, 0 ) );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR );
m_pd3dDevice->SetVertexShader( NULL );
m_pd3dDevice->SetTexture( 0, pTexture->m_pTexture );
m_pd3dDevice->SetFVF( D3DFVF_TEXTUREVERTEX );
m_pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 363, pVertex, sizeof( TEXTUREVERTEX ) );
m_pd3dDevice->SetTexture( 0, NULL );
return TRUE;
}
{
pt += m_ptOrigin;
if( pTexture == NULL )
return FALSE;
if( radius == 0.0f )
radius = float(min(pTexture->m_size.cx,pTexture->m_size.cy)/2);//assuring that whole circle can be displayed
radius *= fScale;
if( !bIsCenter )
{
pt.x += long(radius);
pt.y += long(radius);
}
TEXTUREVERTEX pVertex[366];
float x1 = float(pt.x);
float y1 = float(pt.y);
float u1 = 0.5f;
float v1 = 0.5f;
for( int i=0;i<=363; )
{
float angle = ( i / 57.3f );
float x2 = pt.x + ( radius * sin( angle ) );
float y2 = pt.y + ( radius * cos( angle ) );
float u2 = 0.5f + ( 0.5f * sin( angle ) );
float v2 = 0.5f + ( 0.5f * cos( angle ) );
SetTextureVertex( &pVertex[i++], float(pt.x), float(pt.y), 0.5f, 0.5f );
SetTextureVertex( &pVertex[i++], x1, y1, u1, v1 );
SetTextureVertex( &pVertex[i++], x2, y2, u2, v2 );
y1 = y2;
x1 = x2;
u1 = u2;
v1 = v2;
}
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, 1 );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, 1 );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, D3DCOLOR_ARGB( dwBlendFactorAlpha, 0, 0, 0 ) );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR );
m_pd3dDevice->SetVertexShader( NULL );
m_pd3dDevice->SetTexture( 0, pTexture->m_pTexture );
m_pd3dDevice->SetFVF( D3DFVF_TEXTUREVERTEX );
m_pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 363, pVertex, sizeof( TEXTUREVERTEX ) );
m_pd3dDevice->SetTexture( 0, NULL );
return TRUE;
}
my neuz logs
2013/12/12 13:15:01 Dec 12 2013 11:31:10 1 rCnt=1
Neuz.exe caused an EXCEPTION_ACCESS_VIOLATION in module d3d9.dll at 001B:6B1FB999, Direct3DCreate9Ex()+126148 byte(s)
- Registers
EAX=0C8642C8 EBX=00000073 ECX=050E3E60 EDX=050E3E60 ESI=05058120
EDI=0C8642C8 EBP=0012F434 ESP=0012F40C EIP=6B1FB999 FLG=00010202
CS=001B DS=0023 SS=0023 ES=0023 FS=003B GS=0000
001B:6B1FB999 d3d9.dll, Direct3DCreate9Ex()+126148 byte(s)
001B:00727F83 Neuz.exe
001B:007281A1 Neuz.exe
001B:007D579A Neuz.exe
001B:007D4D39 Neuz.exe
001B:004ED977 Neuz.exe
001B:0051A3EC Neuz.exe
001B:0051A1CE Neuz.exe
001B:00470B70 Neuz.exe
001B:0049A56F Neuz.exe
001B:0049A381 Neuz.exe
001B:004783BC Neuz.exe
001B:0094DF32 Neuz.exe
001B:75FFED5C kernel32.dll, BaseThreadInitThunk()+0018 byte(s)
001B:778137EB ntdll.dll, RtlInitializeExceptionChain()+0239 byte(s)
001B:778137BE ntdll.dll, RtlInitializeExceptionChain()+0194 byte(s)
Neuz.exe caused an EXCEPTION_ACCESS_VIOLATION in module d3d9.dll at 001B:6B1FB999, Direct3DCreate9Ex()+126148 byte(s)
- Registers
EAX=0C8642C8 EBX=00000073 ECX=050E3E60 EDX=050E3E60 ESI=05058120
EDI=0C8642C8 EBP=0012F434 ESP=0012F40C EIP=6B1FB999 FLG=00010202
CS=001B DS=0023 SS=0023 ES=0023 FS=003B GS=0000
001B:6B1FB999 d3d9.dll, Direct3DCreate9Ex()+126148 byte(s)
001B:00727F83 Neuz.exe
001B:007281A1 Neuz.exe
001B:007D579A Neuz.exe
001B:007D4D39 Neuz.exe
001B:004ED977 Neuz.exe
001B:0051A3EC Neuz.exe
001B:0051A1CE Neuz.exe
001B:00470B70 Neuz.exe
001B:0049A56F Neuz.exe
001B:0049A381 Neuz.exe
001B:004783BC Neuz.exe
001B:0094DF32 Neuz.exe
001B:75FFED5C kernel32.dll, BaseThreadInitThunk()+0018 byte(s)
001B:778137EB ntdll.dll, RtlInitializeExceptionChain()+0239 byte(s)
001B:778137BE ntdll.dll, RtlInitializeExceptionChain()+0194 byte(s)
help me pls
thanks in advance






