I can draw the outline of an ellipse but I want to draw a filled in ellipse, but I can't seem to get the code to work. Any help would be great! I am using DirectX 9 and D3DX.
There are multiple approaches:
- Cut-out texture
Create a fully transparent texture. Fill the texture with the ellipse shape on the CPU. Render the texture with alpha blend. You only need one texture per ratio of radii, so chances are you can generate some offline.
Create a tessellated sphere, pass radii to vertex shader, deform shpere into ellipsoid in the vertex shader. Project it orthographically onto the screen.
- Pixel Shader
Render a rectangle, pass the radii through to the pixel shader and use trigonometric functions to determine for each pixel whether it's inside the ellipse - or even better it's signed distance to the ellipse's edge. Then fill accordingly. If you compute the signed distance you can even fade it nicely toward the edges to achieve effects like bevel and emboss.