diff --git a/tinygl/README.residual b/tinygl/README.residual index ea6f63dcf84..d0329de33fb 100644 --- a/tinygl/README.residual +++ b/tinygl/README.residual @@ -7,3 +7,4 @@ The changes made from the original version of TinyGL 0.4 are: * Added needed type cast and fixes for proper compile. * Added 't/T' prefix to prevent OpenGl names duplication. * Added light shading texture mapping mode. +* Removed not needed code. diff --git a/tinygl/gl.h b/tinygl/gl.h index 0d36a3991b4..5298a059d92 100644 --- a/tinygl/gl.h +++ b/tinygl/gl.h @@ -802,26 +802,6 @@ void tglTexCoordPointer(TGLint size, TGLenum type, TGLsizei stride, /* opengl 1.2 polygon offset */ void tglPolygonOffset(TGLfloat factor, TGLfloat units); -/* not implemented, just added to compile */ - /* -inline void tglPointSize(float) {} -inline void tglLineWidth(float) {} -inline void tglDeleteLists(int, int) {} -inline void tglDepthFunc(int) {} -inline void tglBlendFunc(int, int) {} -inline void tglTexEnvf(int, int, int) {} -inline void tglOrtho(float,float,float,float,float,float){} -inline void tglVertex2i(int,int) {} -inline void tglDepthMask(int) {} -inline void tglFogi(int, int) {} -inline void tglFogfv(int, const float*) {} -inline void tglFogf(int, float) {} -inline void tglRasterPos2f(float, float) {} -inline void tglPolygonStipple(void*) {} -inline void tglTexParameterf(int, int, int) {}; - */ -/* non compatible functions */ - void tglDebug(int mode); void tglInit(void *zbuffer); diff --git a/tinygl/image_util.cpp b/tinygl/image_util.cpp index 2ec6e13bd8a..ff1ef41921b 100644 --- a/tinygl/image_util.cpp +++ b/tinygl/image_util.cpp @@ -18,22 +18,6 @@ void gl_convertRGB_to_5R6G5B(unsigned short *pixmap,unsigned char *rgb, } } -void gl_convertRGB_to_8A8R8G8B(unsigned int *pixmap, unsigned char *rgb, - int xsize, int ysize) -{ - int i,n; - unsigned char *p; - - p=rgb; - n=xsize*ysize; - for(i=0;ixsize=width; im->ysize=height; if (im->pixmap!=NULL) gl_free(im->pixmap); -#if TGL_FEATURE_RENDER_BITS == 24 - im->pixmap=gl_malloc(width*height*3); - if(im->pixmap) { - memcpy(im->pixmap,pixels1,width*height*3); - } -#elif TGL_FEATURE_RENDER_BITS == 32 - im->pixmap=gl_malloc(width*height*4); - if(im->pixmap) { - gl_convertRGB_to_8A8R8G8B(im->pixmap,pixels1,width,height); - } -#elif TGL_FEATURE_RENDER_BITS == 16 im->pixmap=gl_malloc(width*height*2); if(im->pixmap) { gl_convertRGB_to_5R6G5B((unsigned short *)im->pixmap,pixels1,width,height); } -#else -#error TODO -#endif if (do_free) gl_free(pixels1); } diff --git a/tinygl/zbuffer.h b/tinygl/zbuffer.h index aa4a44de10d..bc4ac4fa0c2 100644 --- a/tinygl/zbuffer.h +++ b/tinygl/zbuffer.h @@ -30,18 +30,6 @@ #define ZB_MODE_RGB24 4 /* 24 bit rgb mode */ #define ZB_NB_COLORS 225 /* number of colors for 8 bit display */ -#if TGL_FEATURE_RENDER_BITS == 15 - -#define RGB_TO_PIXEL(r,g,b) \ - ((((r) >> 1) & 0x7c00) | (((g) >> 6) & 0x03e0) | ((b) >> 11)) -typedef unsigned short PIXEL; -/* bytes per pixel */ -#define PSZB 2 -/* bits per pixel = (1 << PSZH) */ -#define PSZSH 4 - -#elif TGL_FEATURE_RENDER_BITS == 16 - /* 16 bit mode */ #define RGB_TO_PIXEL(r,g,b) \ (((r) & 0xF800) | (((g) >> 5) & 0x07E0) | ((b) >> 11)) @@ -49,28 +37,6 @@ typedef unsigned short PIXEL; #define PSZB 2 #define PSZSH 4 -#elif TGL_FEATURE_RENDER_BITS == 24 - -#define RGB_TO_PIXEL(r,g,b) \ - ((((r) << 8) & 0xff0000) | ((g) & 0xff00) | ((b) >> 8)) -typedef unsigned char PIXEL; -#define PSZB 3 -#define PSZSH 5 - -#elif TGL_FEATURE_RENDER_BITS == 32 - -#define RGB_TO_PIXEL(r,g,b) \ - ((((r) << 8) & 0xff0000) | ((g) & 0xff00) | ((b) >> 8)) -typedef unsigned int PIXEL; -#define PSZB 4 -#define PSZSH 5 - -#else - -#error Incorrect number of bits per pixel - -#endif - typedef struct { int xsize,ysize; int linesize; /* line size, in bytes */ diff --git a/tinygl/zfeatures.h b/tinygl/zfeatures.h index cafe0c207f9..afd32590442 100644 --- a/tinygl/zfeatures.h +++ b/tinygl/zfeatures.h @@ -35,9 +35,6 @@ #define TGL_FEATURE_32_BITS 1 -//#define TGL_FEATURE_RENDER_BITS 15 #define TGL_FEATURE_RENDER_BITS 16 -//#define TGL_FEATURE_RENDER_BITS 24 -//#define TGL_FEATURE_RENDER_BITS 32 #endif /* _tgl_features_h_ */ diff --git a/tinygl/zgl.h b/tinygl/zgl.h index 0f27f51688f..6227cc5243a 100644 --- a/tinygl/zgl.h +++ b/tinygl/zgl.h @@ -313,8 +313,6 @@ GLTexture *alloc_texture(GLContext *c,int h); /* image_util.c */ void gl_convertRGB_to_5R6G5B(unsigned short *pixmap,unsigned char *rgb, int xsize,int ysize); -void gl_convertRGB_to_8A8R8G8B(unsigned int *pixmap, unsigned char *rgb, - int xsize, int ysize); void gl_resizeImage(unsigned char *dest,int xsize_dest,int ysize_dest, unsigned char *src,int xsize_src,int ysize_src); void gl_resizeImageNoInterpolate(unsigned char *dest,int xsize_dest,int ysize_dest, diff --git a/tinygl/zline.cpp b/tinygl/zline.cpp index cb4d7bb9f46..8fdf760bd5a 100644 --- a/tinygl/zline.cpp +++ b/tinygl/zline.cpp @@ -13,13 +13,7 @@ void ZB_plot(ZBuffer * zb, ZBufferPoint * p) pp = (PIXEL *) ((char *) zb->pbuf + zb->linesize * p->y + p->x * PSZB); zz = p->z >> ZB_POINT_Z_FRAC_BITS; if (ZCMP(zz, *pz)) { -#if TGL_FEATURE_RENDER_BITS == 24 - pp[0]=p->r>>8; - pp[1]=p->g>>8; - pp[2]=p->b>>8; -#else *pp = RGB_TO_PIXEL(p->r, p->g, p->b); -#endif *pz = zz; } } diff --git a/tinygl/zline.h b/tinygl/zline.h index 982b3552c0f..128870ee3a9 100644 --- a/tinygl/zline.h +++ b/tinygl/zline.h @@ -2,7 +2,7 @@ int n, dx, dy, sx, pp_inc_1, pp_inc_2; register int a; register PIXEL *pp; -#if defined(INTERP_RGB) || TGL_FEATURE_RENDER_BITS == 24 +#if defined(INTERP_RGB) register unsigned int r, g, b; #endif #ifdef INTERP_RGB @@ -33,27 +33,14 @@ r = p2->r << 8; g = p2->g << 8; b = p2->b << 8; -#elif TGL_FEATURE_RENDER_BITS == 24 - /* for 24 bits, we store the colors in different variables */ - r = p2->r >> 8; - g = p2->g >> 8; - b = p2->b >> 8; #endif #ifdef INTERP_RGB #define RGB(x) x -#if TGL_FEATURE_RENDER_BITS == 24 -#define RGBPIXEL pp[0] = r >> 16, pp[1] = g >> 16, pp[2] = b >> 16 -#else #define RGBPIXEL *pp = RGB_TO_PIXEL(r >> 8,g >> 8,b >> 8) -#endif #else /* INTERP_RGB */ #define RGB(x) -#if TGL_FEATURE_RENDER_BITS == 24 -#define RGBPIXEL pp[0] = r, pp[1] = g, pp[2] = b -#else #define RGBPIXEL *pp = color -#endif #endif /* INTERP_RGB */ #ifdef INTERP_Z diff --git a/tinygl/ztriangle.cpp b/tinygl/ztriangle.cpp index d2906a87741..5ed5b22448d 100644 --- a/tinygl/ztriangle.cpp +++ b/tinygl/ztriangle.cpp @@ -6,37 +6,10 @@ void ZB_fillTriangleFlat(ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { -#if TGL_FEATURE_RENDER_BITS == 24 - unsigned char colorR, colorG, colorB; -#else int color; -#endif #define INTERP_Z -#if TGL_FEATURE_RENDER_BITS == 24 - -#define DRAW_INIT() \ -{ \ - colorR=p2->r>>8; \ - colorG=p2->g>>8; \ - colorB=p2->b>>8; \ -} - -#define PUT_PIXEL(_a) \ -{ \ - zz=z >> ZB_POINT_Z_FRAC_BITS; \ - if (ZCMP(zz,pz[_a])) { \ - pp[3 * _a]=colorR;\ - pp[3 * _a + 1]=colorG;\ - pp[3 * _a + 2]=colorB;\ - pz[_a]=zz; \ - }\ - z+=dzdx; \ -} - -#else - #define DRAW_INIT() \ { \ color=RGB_TO_PIXEL(p2->r,p2->g,p2->b); \ @@ -51,7 +24,6 @@ void ZB_fillTriangleFlat(ZBuffer *zb, } \ z+=dzdx; \ } -#endif /* TGL_FEATURE_RENDER_BITS == 24 */ #include "ztriangle.h" } @@ -64,38 +36,13 @@ void ZB_fillTriangleFlat(ZBuffer *zb, void ZB_fillTriangleSmooth(ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { -#if TGL_FEATURE_RENDER_BITS == 16 int _drgbdx; -#endif #define INTERP_Z #define INTERP_RGB #define SAR_RND_TO_ZERO(v,n) (v / (1<> ZB_POINT_Z_FRAC_BITS; \ - if (ZCMP(zz,pz[_a])) { \ - pp[3 * _a]=or1 >> 8;\ - pp[3 * _a + 1]=og1 >> 8;\ - pp[3 * _a + 2]=ob1 >> 8;\ - pz[_a]=zz; \ - }\ - z+=dzdx; \ - og1+=dgdx; \ - or1+=drdx; \ - ob1+=dbdx; \ -} - -#elif TGL_FEATURE_RENDER_BITS == 16 - #define DRAW_INIT() \ { \ _drgbdx=(SAR_RND_TO_ZERO(drdx,6) << 22) & 0xFFC00000; \ @@ -147,27 +94,6 @@ void ZB_fillTriangleSmooth(ZBuffer *zb, } \ } -#else - -#define DRAW_INIT() \ -{ \ -} - -#define PUT_PIXEL(_a) \ -{ \ - zz=z >> ZB_POINT_Z_FRAC_BITS; \ - if (ZCMP(zz,pz[_a])) { \ - pp[_a] = RGB_TO_PIXEL(or1, og1, ob1);\ - pz[_a]=zz; \ - }\ - z+=dzdx; \ - og1+=dgdx; \ - or1+=drdx; \ - ob1+=dbdx; \ -} - -#endif /* TGL_FEATURE_RENDER_BITS */ - #include "ztriangle.h" } @@ -189,26 +115,6 @@ void ZB_fillTriangleMapping(ZBuffer *zb, texture=zb->current_texture; \ } -#if TGL_FEATURE_RENDER_BITS == 24 - -#define PUT_PIXEL(_a) \ -{ \ - unsigned char *ptr;\ - zz=z >> ZB_POINT_Z_FRAC_BITS; \ - if (ZCMP(zz,pz[_a])) { \ - ptr = texture + (((t & 0x3FC00000) | s) >> 14) * 3; \ - pp[3 * _a]= ptr[0];\ - pp[3 * _a + 1]= ptr[1];\ - pp[3 * _a + 2]= ptr[2];\ - pz[_a]=zz; \ - } \ - z+=dzdx; \ - s+=dsdx; \ - t+=dtdx; \ -} - -#else - #define PUT_PIXEL(_a) \ { \ zz=z >> ZB_POINT_Z_FRAC_BITS; \ @@ -221,18 +127,9 @@ void ZB_fillTriangleMapping(ZBuffer *zb, t+=dtdx; \ } -#endif - #include "ztriangle.h" } -/* - * Texture mapping with perspective correction. - * We use the gradient method to make less divisions. - * TODO: pipeline the division - */ -#if 1 - void ZB_fillTriangleMappingPerspective(ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { @@ -261,26 +158,6 @@ void ZB_fillTriangleMappingPerspective(ZBuffer *zb, } -#if TGL_FEATURE_RENDER_BITS == 24 - -#define PUT_PIXEL(_a) \ -{ \ - unsigned char *ptr;\ - zz=z >> ZB_POINT_Z_FRAC_BITS; \ - if (ZCMP(zz,pz[_a])) { \ - ptr = texture + (((t & 0x3FC00000) | (s & 0x003FC000)) >> 14) * 3;\ - pp[3 * _a]= ptr[0];\ - pp[3 * _a + 1]= ptr[1];\ - pp[3 * _a + 2]= ptr[2];\ - pz[_a]=zz; \ - } \ - z+=dzdx; \ - s+=dsdx; \ - t+=dtdx; \ -} - -#else - #define PUT_PIXEL(_a) \ { \ zz=z >> ZB_POINT_Z_FRAC_BITS; \ @@ -308,8 +185,6 @@ void ZB_fillTriangleMappingPerspective(ZBuffer *zb, rgb=(rgb+drgbdx) & ( ~ 0x00200800); \ } -#endif - #define DRAW_LINE() \ { \ register unsigned short *pz; \ @@ -374,46 +249,3 @@ void ZB_fillTriangleMappingPerspective(ZBuffer *zb, #include "ztriangle.h" } - -#endif - -#if 0 - -/* slow but exact version (only there for reference, incorrect for 24 - bits) */ - -void ZB_fillTriangleMappingPerspective(ZBuffer *zb, - ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) -{ - PIXEL *texture; - -#define INTERP_Z -#define INTERP_STZ - -#define DRAW_INIT() \ -{ \ - texture=zb->current_texture; \ -} - -#define PUT_PIXEL(_a) \ -{ \ - float zinv; \ - int s,t; \ - zz=z >> ZB_POINT_Z_FRAC_BITS; \ - if (ZCMP(zz,pz[_a])) { \ - zinv= 1.0 / (float) z; \ - s= (int) (sz * zinv); \ - t= (int) (tz * zinv); \ - pp[_a]=texture[((t & 0x3FC00000) | s) >> 14]; \ - pz[_a]=zz; \ - } \ - z+=dzdx; \ - sz+=dszdx; \ - tz+=dtzdx; \ -} - -#include "ztriangle.h" -} - - -#endif