- More coding convention fixes.

- Aliased circles.

svn-id: r31849
This commit is contained in:
Vicent Marti 2008-05-03 21:57:29 +00:00
parent 8004a64c2f
commit eb411d298a
2 changed files with 94 additions and 65 deletions

View file

@ -34,7 +34,7 @@ namespace Graphics {
inline uint32 fp_sqroot( uint32 x ); inline uint32 fp_sqroot( uint32 x );
VectorRenderer *createRenderer() { VectorRenderer *createRenderer() {
return new VectorRendererAA<uint16,ColorMasks<565> >; return new VectorRendererSpec<uint16,ColorMasks<565> >;
} }
@ -256,33 +256,63 @@ inline uint32 fp_sqroot( uint32 x ) {
return root; return root;
} }
template<typename PixelType, typename PixelFormat>
void VectorRendererSpec<PixelType,PixelFormat>::
drawCircleAlg(int x1, int y1, int r) {
#define __CIRCLE_SIM(x,y) { \
putPixel(x1 + (x), y1 + (y)); /* 1st quad */ \
putPixel(x1 + (y), y1 - (x)); \
putPixel(x1 - (x), y1 - (y)); /* 2nd quad */ \
putPixel(x1 - (y), y1 - (x)); \
putPixel(x1 - (y), y1 + (x)); /* 3rd quad */ \
putPixel(x1 - (x), y1 + (y)); \
putPixel(x1 + (y), y1 + (x)); /* 4th quad */ \
putPixel(x1 + (x), y1 - (y)); \
}
int f = 1 - r;
int ddF_x = 0;
int ddF_y = -2 * r;
int x = 0;
int y = r;
__CIRCLE_SIM(x,y);
while(x++ < y) {
if(f >= 0) {
y--;
ddF_y += 2;
f += ddF_y;
}
ddF_x += 2;
f += ddF_x + 1;
__CIRCLE_SIM(x,y);
}
}
template<typename PixelType, typename PixelFormat> template<typename PixelType, typename PixelFormat>
void VectorRendererAA<PixelType,PixelFormat>:: void VectorRendererAA<PixelType,PixelFormat>::
drawCircleAlg(int x1, int y1, int r) { drawCircleAlg(int x1, int y1, int r) {
#define __CIRCLE_SIM(x,y,a) { \ #define __WU_CIRCLE_SIM(x,y,a) { \
blendPixel( x1 + (x), y1 + (y), a ); \ blendPixel(x1 + (x), y1 + (y), a); /* 1st quad */ \
blendPixel( x1 + (x), y1 - (y), a ); \
blendPixel( x1 - (y), y1 + (x), a ); \
blendPixel( x1 + (y), y1 + (x), a ); \
blendPixel( x1 - (x), y1 + (y), a ); \
blendPixel( x1 - (x), y1 - (y), a ); \
blendPixel(x1 + (y), y1 - (x), a); \ blendPixel(x1 + (y), y1 - (x), a); \
blendPixel(x1 - (x), y1 - (y), a); /* 2nd quad */ \
blendPixel(x1 - (y), y1 - (x), a); \ blendPixel(x1 - (y), y1 - (x), a); \
} blendPixel(x1 - (y), y1 + (x), a); /* 3rd quad */ \
blendPixel(x1 - (x), y1 + (y), a); \
// first quadrant blendPixel(x1 + (y), y1 + (x), a); /* 4th quad */ \
/*#define __CIRCLE_SIM(x,y,a) { \
blendPixel(x1 + (x), y1 - (y), a); \ blendPixel(x1 + (x), y1 - (y), a); \
blendPixel( x1 + (y), y1 - (x), a ); \ }
}*/
int x = r; int x = r;
int y = 0; int y = 0;
uint32 rsq = (r * r) << 16; uint32 rsq = (r * r) << 16;
uint32 T = 0, oldT; uint32 T = 0, oldT;
__CIRCLE_SIM( x, y, 255 ); __WU_CIRCLE_SIM(x, y, 255);
while(x > y++) while(x > y++)
{ {
@ -292,8 +322,8 @@ drawCircleAlg(int x1, int y1, int r) {
if (T < oldT) if (T < oldT)
x--; x--;
__CIRCLE_SIM( x, y, (T>>8) ^ 0xFF ); __WU_CIRCLE_SIM(x, y, (T >> 8) ^ 0xFF);
__CIRCLE_SIM( x-1, y, (T>>8) & 0xFF ); __WU_CIRCLE_SIM(x-1, y, (T >> 8) & 0xFF);
} }
} }

View file

@ -249,7 +249,6 @@ public:
* @see VectorRenderer::blendPixel() * @see VectorRenderer::blendPixel()
*/ */
virtual inline void blendPixel( int x, int y, uint8 alpha ) { virtual inline void blendPixel( int x, int y, uint8 alpha ) {
if ( alpha > 0 )
putPixel(x, y); putPixel(x, y);
} }
@ -269,7 +268,7 @@ protected:
/** /**
* @see VectorRenderer::drawCircleAlg() * @see VectorRenderer::drawCircleAlg()
*/ */
virtual void drawCircleAlg(int x, int y, int r) {} virtual void drawCircleAlg(int x, int y, int r);
PixelType _color; /** Color currently being used to draw on the renderer */ PixelType _color; /** Color currently being used to draw on the renderer */
}; };