Advertisement

[DX9] Circles deform when drawing next to eachother

Started by June 14, 2019 06:16 AM
2 comments, last by datboi 5 years, 7 months ago

Hello everyone, I've recently discovered a weird problem with my renderer.

I have the following code


void Surface::DrawFilledCircle( int x, int y, int radius, color32 color )
{	 
	constexpr int segments = 64; 

	std::vector< fxVertex > v;

	for ( int i = 0; i <= segments; ++i )
	{
		float theta = ( ( 2.f * M_PI  ) / ( float )segments ) * i;
		 
		v.emplace_back
		(
			static_cast< float >( x + radius * cosf( theta ) ),
			static_cast< float >( y + radius * sinf( theta ) ),
			0.f,
			color
		);
	}

	m_pRenderer->PushVertices( m_renderList, v.data(), v.size(), fxPrimitiveType::kTriangleFan );   
}

 

The problem begins after the first circle is drawn, as you can see in the link below, it draws fine for the first circle, but after, the rest of the circles become deformed. I'm pretty confused on why this happens in all honesty and would appreciate any advice or if anyone knows whats going on. I thought that I was passing the wrong number of vertices to PushVertices but that is not the case.

https://imgur.com/bAQceiT

EDIT: I think it's worth noting that outlined circles that use D3DPT_LINESTRIP are working perfectly using the same code, so is this an issue with D3DPT_TRIANGLEFAN?

Thanks.

I think you are missing the first vertex, i.e. the center point of the fan.

Advertisement
2 hours ago, Prototype said:

I think you are missing the first vertex, i.e. the center point of the fan.

Fixed, wasn't the code shown.. was something that was just helping optimize in PushVertices. Adjusted it and now it works, but thank you!

This topic is closed to new replies.

Advertisement