From 80253733c6421cccaf52d1e36d76ee7794d2211e Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 6 May 2008 19:18:41 +0000 Subject: [PATCH] build on windows --- panda/src/tinydisplay/Sources.pp | 16 +++---- panda/src/tinydisplay/{clip.c => clip.cxx} | 2 +- panda/src/tinydisplay/config_tinydisplay.h | 4 +- panda/src/tinydisplay/{error.c => error.cxx} | 0 .../{image_util.c => image_util.cxx} | 0 panda/src/tinydisplay/{init.c => init.cxx} | 34 ++++++------- panda/src/tinydisplay/{light.c => light.cxx} | 5 +- .../src/tinydisplay/{memory.c => memory.cxx} | 0 .../{msghandling.c => msghandling.cxx} | 0 .../tinydisplay/{specbuf.c => specbuf.cxx} | 2 +- .../tinydisplay/{texture.c => texture.cxx} | 0 panda/src/tinydisplay/tinyGeomMunger.h | 2 +- .../tinydisplay/tinyGraphicsStateGuardian.cxx | 3 -- .../tinydisplay/tinyGraphicsStateGuardian.h | 9 ++-- panda/src/tinydisplay/tinySDLGraphicsPipe.h | 2 +- panda/src/tinydisplay/tinySDLGraphicsWindow.h | 9 ++-- panda/src/tinydisplay/tinyTextureContext.cxx | 3 -- panda/src/tinydisplay/tinyTextureContext.h | 2 +- panda/src/tinydisplay/tinyXGraphicsPipe.h | 2 +- panda/src/tinydisplay/tinyXGraphicsWindow.h | 2 +- .../src/tinydisplay/{vertex.c => vertex.cxx} | 12 ++--- .../tinydisplay/{zbuffer.c => zbuffer.cxx} | 20 ++++---- .../tinydisplay/{zdither.c => zdither.cxx} | 0 panda/src/tinydisplay/zgl.h | 24 +--------- panda/src/tinydisplay/{zline.c => zline.cxx} | 0 panda/src/tinydisplay/{zmath.c => zmath.cxx} | 0 .../{ztriangle.c => ztriangle.cxx} | 48 +++++++++---------- panda/src/tinydisplay/ztriangle.h | 38 +++++++-------- panda/src/tinydisplay/ztriangle_two.h | 12 ++--- 29 files changed, 110 insertions(+), 141 deletions(-) rename panda/src/tinydisplay/{clip.c => clip.cxx} (99%) rename panda/src/tinydisplay/{error.c => error.cxx} (100%) rename panda/src/tinydisplay/{image_util.c => image_util.cxx} (100%) rename panda/src/tinydisplay/{init.c => init.cxx} (55%) rename panda/src/tinydisplay/{light.c => light.cxx} (97%) rename panda/src/tinydisplay/{memory.c => memory.cxx} (100%) rename panda/src/tinydisplay/{msghandling.c => msghandling.cxx} (100%) rename panda/src/tinydisplay/{specbuf.c => specbuf.cxx} (95%) rename panda/src/tinydisplay/{texture.c => texture.cxx} (100%) rename panda/src/tinydisplay/{vertex.c => vertex.cxx} (87%) rename panda/src/tinydisplay/{zbuffer.c => zbuffer.cxx} (94%) rename panda/src/tinydisplay/{zdither.c => zdither.cxx} (100%) rename panda/src/tinydisplay/{zline.c => zline.cxx} (100%) rename panda/src/tinydisplay/{zmath.c => zmath.cxx} (100%) rename panda/src/tinydisplay/{ztriangle.c => ztriangle.cxx} (83%) diff --git a/panda/src/tinydisplay/Sources.pp b/panda/src/tinydisplay/Sources.pp index 034139b1e7..4de1a03e43 100644 --- a/panda/src/tinydisplay/Sources.pp +++ b/panda/src/tinydisplay/Sources.pp @@ -1,5 +1,5 @@ #define BUILD_DIRECTORY $[HAVE_SDL] -//#define BUILDING_DLL BUILDING_TINYDISPLAY +#define BUILDING_DLL BUILDING_TINYDISPLAY #define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \ dtoolutil:c dtoolbase:c dtool:m @@ -21,13 +21,13 @@ tinyTextureContext.I tinyTextureContext.cxx tinyTextureContext.h \ tinyXGraphicsPipe.I tinyXGraphicsPipe.cxx tinyXGraphicsPipe.h \ tinyXGraphicsWindow.h tinyXGraphicsWindow.I tinyXGraphicsWindow.cxx \ - clip.c error.c \ - image_util.c init.c light.c \ - memory.c msghandling.c msghandling.h \ - specbuf.c \ - texture.c vertex.c \ - zbuffer.c zbuffer.h zdither.c zfeatures.h zgl.h zline.c \ - zline.h zmath.c zmath.h ztriangle.c ztriangle.h ztriangle_two.h + clip.cxx error.cxx \ + image_util.cxx init.cxx light.cxx \ + memory.cxx msghandling.cxx msghandling.h \ + specbuf.cxx \ + texture.cxx vertex.cxx \ + zbuffer.cxx zbuffer.h zdither.cxx zfeatures.h zgl.h zline.cxx \ + zline.h zmath.cxx zmath.h ztriangle.cxx ztriangle.h ztriangle_two.h #end lib_target diff --git a/panda/src/tinydisplay/clip.c b/panda/src/tinydisplay/clip.cxx similarity index 99% rename from panda/src/tinydisplay/clip.c rename to panda/src/tinydisplay/clip.cxx index 6fddae1a22..642326f9d4 100644 --- a/panda/src/tinydisplay/clip.c +++ b/panda/src/tinydisplay/clip.cxx @@ -15,7 +15,7 @@ void gl_transform_to_viewport(GLContext *c,GLVertex *v) float winv; /* coordinates */ - winv=1.0/v->pc.W; + winv = 1.0f / v->pc.W; v->zp.x= (int) ( v->pc.X * winv * c->viewport.scale.X + c->viewport.trans.X ); v->zp.y= (int) ( v->pc.Y * winv * c->viewport.scale.Y diff --git a/panda/src/tinydisplay/config_tinydisplay.h b/panda/src/tinydisplay/config_tinydisplay.h index 1cc39ce0d1..0559360c64 100644 --- a/panda/src/tinydisplay/config_tinydisplay.h +++ b/panda/src/tinydisplay/config_tinydisplay.h @@ -25,9 +25,9 @@ #include "configVariableBool.h" #include "configVariableInt.h" -NotifyCategoryDecl(tinydisplay, EXPCL_PANDAGL, EXPTP_PANDAGL); +NotifyCategoryDecl(tinydisplay, EXPCL_TINYDISPLAY, EXPTP_TINYDISPLAY); -extern EXPCL_PANDAGL void init_libtinydisplay(); +extern EXPCL_TINYDISPLAY void init_libtinydisplay(); extern ConfigVariableString display_cfg; extern ConfigVariableBool x_error_abort; diff --git a/panda/src/tinydisplay/error.c b/panda/src/tinydisplay/error.cxx similarity index 100% rename from panda/src/tinydisplay/error.c rename to panda/src/tinydisplay/error.cxx diff --git a/panda/src/tinydisplay/image_util.c b/panda/src/tinydisplay/image_util.cxx similarity index 100% rename from panda/src/tinydisplay/image_util.c rename to panda/src/tinydisplay/image_util.cxx diff --git a/panda/src/tinydisplay/init.c b/panda/src/tinydisplay/init.cxx similarity index 55% rename from panda/src/tinydisplay/init.c rename to panda/src/tinydisplay/init.cxx index c8647dbe8d..7ba1ebb8ae 100644 --- a/panda/src/tinydisplay/init.c +++ b/panda/src/tinydisplay/init.cxx @@ -19,7 +19,7 @@ void glInit(GLContext *c, ZBuffer *zbuffer) /* lights */ c->first_light=NULL; - c->ambient_light_model=gl_V4_New(0.2,0.2,0.2,1); + c->ambient_light_model=gl_V4_New(0.2f, 0.2f, 0.2f, 1.0f); c->local_light_model=0; c->lighting_enabled=0; c->light_model_two_side = 0; @@ -27,28 +27,28 @@ void glInit(GLContext *c, ZBuffer *zbuffer) /* default materials */ for(i=0;i<2;i++) { GLMaterial *m=&c->materials[i]; - m->emission=gl_V4_New(0,0,0,1); - m->ambient=gl_V4_New(0.2,0.2,0.2,1); - m->diffuse=gl_V4_New(0.8,0.8,0.8,1); - m->specular=gl_V4_New(0,0,0,1); + m->emission=gl_V4_New(0.0f, 0.0f, 0.0f, 1.0f); + m->ambient=gl_V4_New(0.2f, 0.2f, 0.2f, 1.0f); + m->diffuse=gl_V4_New(0.8f, 0.8f, 0.8f, 1.0f); + m->specular=gl_V4_New(0.0f, 0.0f, 0.0f, 1.0f); m->shininess=0; } /* default state */ - c->current_color.X=1.0; - c->current_color.Y=1.0; - c->current_color.Z=1.0; - c->current_color.W=1.0; + c->current_color.X=1.0f; + c->current_color.Y=1.0f; + c->current_color.Z=1.0f; + c->current_color.W=1.0f; - c->current_normal.X=1.0; - c->current_normal.Y=0.0; - c->current_normal.Z=0.0; - c->current_normal.W=0.0; + c->current_normal.X=1.0f; + c->current_normal.Y=0.0f; + c->current_normal.Z=0.0f; + c->current_normal.W=0.0f; - c->current_tex_coord.X=0; - c->current_tex_coord.Y=0; - c->current_tex_coord.Z=0; - c->current_tex_coord.W=1; + c->current_tex_coord.X=0.0f; + c->current_tex_coord.Y=0.0f; + c->current_tex_coord.Z=0.0f; + c->current_tex_coord.W=1.0f; c->cull_face_enabled=0; diff --git a/panda/src/tinydisplay/light.c b/panda/src/tinydisplay/light.cxx similarity index 97% rename from panda/src/tinydisplay/light.c rename to panda/src/tinydisplay/light.cxx index ed2bda88f6..3aac9b91e5 100644 --- a/panda/src/tinydisplay/light.c +++ b/panda/src/tinydisplay/light.cxx @@ -1,5 +1,6 @@ #include "zgl.h" #include "msghandling.h" +#include static inline float clampf(float a,float min,float max) { @@ -48,7 +49,7 @@ void gl_shade_vertex(GLContext *c,GLVertex *v) d.X=l->position.v[0]-v->ec.v[0]; d.Y=l->position.v[1]-v->ec.v[1]; d.Z=l->position.v[2]-v->ec.v[2]; - dist=sqrt(d.X*d.X+d.Y*d.Y+d.Z*d.Z); + dist = sqrtf(d.X*d.X+d.Y*d.Y+d.Z*d.Z); if (dist>1E-3) { tmp=1/dist; d.X*=tmp; @@ -97,7 +98,7 @@ void gl_shade_vertex(GLContext *c,GLVertex *v) } else { s.X=d.X; s.Y=d.Y; - s.Z=d.Z+1.0; + s.Z=d.Z+1.0f; } dot_spec=n.X*s.X+n.Y*s.Y+n.Z*s.Z; if (twoside && dot_spec < 0) dot_spec = -dot_spec; diff --git a/panda/src/tinydisplay/memory.c b/panda/src/tinydisplay/memory.cxx similarity index 100% rename from panda/src/tinydisplay/memory.c rename to panda/src/tinydisplay/memory.cxx diff --git a/panda/src/tinydisplay/msghandling.c b/panda/src/tinydisplay/msghandling.cxx similarity index 100% rename from panda/src/tinydisplay/msghandling.c rename to panda/src/tinydisplay/msghandling.cxx diff --git a/panda/src/tinydisplay/specbuf.c b/panda/src/tinydisplay/specbuf.cxx similarity index 95% rename from panda/src/tinydisplay/specbuf.c rename to panda/src/tinydisplay/specbuf.cxx index 7cbfb05717..241b0be3cb 100644 --- a/panda/src/tinydisplay/specbuf.c +++ b/panda/src/tinydisplay/specbuf.cxx @@ -33,7 +33,7 @@ specbuf_get_buffer(GLContext *c, const int shininess_i, } if (oldest == NULL || c->specbuf_num_buffers < MAX_SPECULAR_BUFFERS) { /* create new buffer */ - GLSpecBuf *buf = gl_malloc(sizeof(GLSpecBuf)); + GLSpecBuf *buf = (GLSpecBuf *)gl_malloc(sizeof(GLSpecBuf)); if (!buf) gl_fatal_error("could not allocate specular buffer"); c->specbuf_num_buffers++; buf->next = c->specbuf_first; diff --git a/panda/src/tinydisplay/texture.c b/panda/src/tinydisplay/texture.cxx similarity index 100% rename from panda/src/tinydisplay/texture.c rename to panda/src/tinydisplay/texture.cxx diff --git a/panda/src/tinydisplay/tinyGeomMunger.h b/panda/src/tinydisplay/tinyGeomMunger.h index 1ab044fea0..e233f86dd7 100644 --- a/panda/src/tinydisplay/tinyGeomMunger.h +++ b/panda/src/tinydisplay/tinyGeomMunger.h @@ -30,7 +30,7 @@ // for TinyGL rendering. In particular, it makes sure // colors aren't stored in DirectX's packed_argb format. //////////////////////////////////////////////////////////////////// -class TinyGeomMunger : public StandardMunger { +class EXPCL_TINYDISPLAY TinyGeomMunger : public StandardMunger { public: TinyGeomMunger(GraphicsStateGuardian *gsg, const RenderState *state); virtual ~TinyGeomMunger(); diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index b23fd71982..24da91ad67 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -27,11 +27,8 @@ #include "directionalLight.h" #include "spotlight.h" #include "bitMask.h" - -extern "C" { #include "zgl.h" #include "zmath.h" -} TypeHandle TinyGraphicsStateGuardian::_type_handle; diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.h b/panda/src/tinydisplay/tinyGraphicsStateGuardian.h index 07827d97b7..68432db7c8 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.h +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.h @@ -24,11 +24,8 @@ #include "graphicsStateGuardian.h" #include "tinySDLGraphicsPipe.h" #include "simpleLru.h" - -extern "C" { - #include "zmath.h" - #include "zbuffer.h" -} +#include "zmath.h" +#include "zbuffer.h" class TinyTextureContext; struct GLContext; @@ -41,7 +38,7 @@ struct GLTexture; // Description : An interface to the TinyGL software rendering code // within this module. //////////////////////////////////////////////////////////////////// -class TinyGraphicsStateGuardian : public GraphicsStateGuardian { +class EXPCL_TINYDISPLAY TinyGraphicsStateGuardian : public GraphicsStateGuardian { public: TinyGraphicsStateGuardian(GraphicsPipe *pipe, TinyGraphicsStateGuardian *share_with); diff --git a/panda/src/tinydisplay/tinySDLGraphicsPipe.h b/panda/src/tinydisplay/tinySDLGraphicsPipe.h index 7612477bff..c5ea618a35 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsPipe.h +++ b/panda/src/tinydisplay/tinySDLGraphicsPipe.h @@ -30,7 +30,7 @@ class FrameBufferProperties; // Description : This graphics pipe manages SDL windows for rendering // TinyGL software buffers. //////////////////////////////////////////////////////////////////// -class TinySDLGraphicsPipe : public GraphicsPipe { +class EXPCL_TINYDISPLAY TinySDLGraphicsPipe : public GraphicsPipe { public: TinySDLGraphicsPipe(); virtual ~TinySDLGraphicsPipe(); diff --git a/panda/src/tinydisplay/tinySDLGraphicsWindow.h b/panda/src/tinydisplay/tinySDLGraphicsWindow.h index 6b05a7102f..844241c808 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsWindow.h +++ b/panda/src/tinydisplay/tinySDLGraphicsWindow.h @@ -24,17 +24,14 @@ #include "tinySDLGraphicsPipe.h" #include "graphicsWindow.h" #include "buttonHandle.h" - -extern "C" { - #include "SDL.h" - #include "zbuffer.h" -} +#include "SDL.h" +#include "zbuffer.h" //////////////////////////////////////////////////////////////////// // Class : TinySDLGraphicsWindow // Description : This graphics window class is implemented via SDL. //////////////////////////////////////////////////////////////////// -class TinySDLGraphicsWindow : public GraphicsWindow { +class EXPCL_TINYDISPLAY TinySDLGraphicsWindow : public GraphicsWindow { public: TinySDLGraphicsWindow(GraphicsPipe *pipe, const string &name, diff --git a/panda/src/tinydisplay/tinyTextureContext.cxx b/panda/src/tinydisplay/tinyTextureContext.cxx index 0598d1e81e..8a9ddcf069 100644 --- a/panda/src/tinydisplay/tinyTextureContext.cxx +++ b/panda/src/tinydisplay/tinyTextureContext.cxx @@ -17,10 +17,7 @@ //////////////////////////////////////////////////////////////////// #include "tinyTextureContext.h" - -extern "C" { #include "zgl.h" -} TypeHandle TinyTextureContext::_type_handle; diff --git a/panda/src/tinydisplay/tinyTextureContext.h b/panda/src/tinydisplay/tinyTextureContext.h index cfd1bce6e6..16118ba45c 100644 --- a/panda/src/tinydisplay/tinyTextureContext.h +++ b/panda/src/tinydisplay/tinyTextureContext.h @@ -30,7 +30,7 @@ struct GLTexture; // Class : TinyTextureContext // Description : //////////////////////////////////////////////////////////////////// -class TinyTextureContext : public TextureContext, public SimpleLruPage { +class EXPCL_TINYDISPLAY TinyTextureContext : public TextureContext, public SimpleLruPage { public: INLINE TinyTextureContext(PreparedGraphicsObjects *pgo, Texture *tex); ALLOC_DELETED_CHAIN(TinyTextureContext); diff --git a/panda/src/tinydisplay/tinyXGraphicsPipe.h b/panda/src/tinydisplay/tinyXGraphicsPipe.h index d52b96f9ce..27e904e319 100644 --- a/panda/src/tinydisplay/tinyXGraphicsPipe.h +++ b/panda/src/tinydisplay/tinyXGraphicsPipe.h @@ -53,7 +53,7 @@ typedef int XIC; // creating OpenGL graphics windows on an X-based // (e.g. Unix) client. //////////////////////////////////////////////////////////////////// -class TinyXGraphicsPipe : public GraphicsPipe { +class EXPCL_TINYDISPLAY TinyXGraphicsPipe : public GraphicsPipe { public: TinyXGraphicsPipe(const string &display = string()); virtual ~TinyXGraphicsPipe(); diff --git a/panda/src/tinydisplay/tinyXGraphicsWindow.h b/panda/src/tinydisplay/tinyXGraphicsWindow.h index a303f75464..c00cc85bb7 100644 --- a/panda/src/tinydisplay/tinyXGraphicsWindow.h +++ b/panda/src/tinydisplay/tinyXGraphicsWindow.h @@ -32,7 +32,7 @@ // Description : Opens a window on X11 to display the TinyGL software // rendering. //////////////////////////////////////////////////////////////////// -class TinyXGraphicsWindow : public GraphicsWindow { +class EXPCL_TINYDISPLAY TinyXGraphicsWindow : public GraphicsWindow { public: TinyXGraphicsWindow(GraphicsPipe *pipe, const string &name, diff --git a/panda/src/tinydisplay/vertex.c b/panda/src/tinydisplay/vertex.cxx similarity index 87% rename from panda/src/tinydisplay/vertex.c rename to panda/src/tinydisplay/vertex.cxx index 3469c12d5a..3328ba94f5 100644 --- a/panda/src/tinydisplay/vertex.c +++ b/panda/src/tinydisplay/vertex.cxx @@ -8,13 +8,13 @@ void gl_eval_viewport(GLContext * c) v = &c->viewport; - v->trans.X = ((v->xsize - 0.5) / 2.0) + v->xmin; - v->trans.Y = ((v->ysize - 0.5) / 2.0) + v->ymin; - v->trans.Z = ((zsize - 0.5) / 2.0) + ((1 << ZB_POINT_Z_FRAC_BITS)) / 2; + v->trans.X = ((v->xsize - 0.5f) / 2.0f) + v->xmin; + v->trans.Y = ((v->ysize - 0.5f) / 2.0f) + v->ymin; + v->trans.Z = ((zsize - 0.5f) / 2.0f) + ((1 << ZB_POINT_Z_FRAC_BITS)) / 2; - v->scale.X = (v->xsize - 0.5) / 2.0; - v->scale.Y = -(v->ysize - 0.5) / 2.0; - v->scale.Z = -((zsize - 0.5) / 2.0); + v->scale.X = (v->xsize - 0.5f) / 2.0f; + v->scale.Y = -(v->ysize - 0.5f) / 2.0f; + v->scale.Z = -((zsize - 0.5f) / 2.0f); } /* coords, tranformation , clip code and projection */ diff --git a/panda/src/tinydisplay/zbuffer.c b/panda/src/tinydisplay/zbuffer.cxx similarity index 94% rename from panda/src/tinydisplay/zbuffer.c rename to panda/src/tinydisplay/zbuffer.cxx index 8379476cb5..b2994203f7 100644 --- a/panda/src/tinydisplay/zbuffer.c +++ b/panda/src/tinydisplay/zbuffer.cxx @@ -18,7 +18,7 @@ ZBuffer *ZB_open(int xsize, int ysize, int mode, ZBuffer *zb; int size; - zb = gl_malloc(sizeof(ZBuffer)); + zb = (ZBuffer *)gl_malloc(sizeof(ZBuffer)); if (zb == NULL) return NULL; @@ -51,12 +51,12 @@ ZBuffer *ZB_open(int xsize, int ysize, int mode, size = zb->xsize * zb->ysize * sizeof(unsigned short); - zb->zbuf = gl_malloc(size); + zb->zbuf = (unsigned short *)gl_malloc(size); if (zb->zbuf == NULL) goto error; if (frame_buffer == NULL) { - zb->pbuf = gl_malloc(zb->ysize * zb->linesize); + zb->pbuf = (PIXEL *)gl_malloc(zb->ysize * zb->linesize); if (zb->pbuf == NULL) { gl_free(zb->zbuf); goto error; @@ -64,7 +64,7 @@ ZBuffer *ZB_open(int xsize, int ysize, int mode, zb->frame_buffer_allocated = 1; } else { zb->frame_buffer_allocated = 0; - zb->pbuf = frame_buffer; + zb->pbuf = (PIXEL *)frame_buffer; } zb->current_texture.pixmap = NULL; @@ -102,16 +102,16 @@ void ZB_resize(ZBuffer * zb, void *frame_buffer, int xsize, int ysize) size = zb->xsize * zb->ysize * sizeof(unsigned short); gl_free(zb->zbuf); - zb->zbuf = gl_malloc(size); + zb->zbuf = (unsigned short *)gl_malloc(size); if (zb->frame_buffer_allocated) gl_free(zb->pbuf); if (frame_buffer == NULL) { - zb->pbuf = gl_malloc(zb->ysize * zb->linesize); + zb->pbuf = (PIXEL *)gl_malloc(zb->ysize * zb->linesize); zb->frame_buffer_allocated = 1; } else { - zb->pbuf = frame_buffer; + zb->pbuf = (PIXEL *)frame_buffer; zb->frame_buffer_allocated = 0; } } @@ -125,7 +125,7 @@ static void ZB_copyBuffer(ZBuffer * zb, int y, n; q = zb->pbuf; - p1 = buf; + p1 = (unsigned char *)buf; n = zb->xsize * PSZB; for (y = 0; y < zb->ysize; y++) { memcpy(p1, q, n); @@ -224,7 +224,7 @@ void memset_s(void *adr, int val, int count) unsigned int *p; unsigned short *q; - p = adr; + p = (unsigned int *)adr; v = val | (val << 16); n = count >> 3; @@ -247,7 +247,7 @@ void memset_l(void *adr, int val, int count) int i, n, v; unsigned int *p; - p = adr; + p = (unsigned int *)adr; v = val; n = count >> 2; for (i = 0; i < n; i++) { diff --git a/panda/src/tinydisplay/zdither.c b/panda/src/tinydisplay/zdither.cxx similarity index 100% rename from panda/src/tinydisplay/zdither.c rename to panda/src/tinydisplay/zdither.cxx diff --git a/panda/src/tinydisplay/zgl.h b/panda/src/tinydisplay/zgl.h index e3e320f193..e9745da331 100644 --- a/panda/src/tinydisplay/zgl.h +++ b/panda/src/tinydisplay/zgl.h @@ -9,9 +9,6 @@ #include "zmath.h" #include "zfeatures.h" -#define DEBUG -/* #define NDEBUG */ - /* initially # of allocated GLVertexes (will grow when necessary) */ #define POLYGON_MAX_VERTEX 16 @@ -228,33 +225,16 @@ void gl_fatal_error(char *format, ...); GLSpecBuf *specbuf_get_buffer(GLContext *c, const int shininess_i, const float shininess); -#ifdef __BEOS__ -void dprintf(const char *, ...); - -#else /* !BEOS */ - -#ifdef DEBUG - -#define dprintf(format, args...) \ - fprintf(stderr,"In '%s': " format "\n",__FUNCTION__, ##args); - -#else - -#define dprintf(format, args...) - -#endif -#endif /* !BEOS */ - /* this clip epsilon is needed to avoid some rounding errors after several clipping stages */ -#define CLIP_EPSILON (1E-5) +#define CLIP_EPSILON (1E-5f) static inline int gl_clipcode(float x,float y,float z,float w1) { float w; - w=w1 * (1.0 + CLIP_EPSILON); + w = w1 * (1.0f + CLIP_EPSILON); return (x<-w) | ((x>w)<<1) | ((y<-w)<<2) | diff --git a/panda/src/tinydisplay/zline.c b/panda/src/tinydisplay/zline.cxx similarity index 100% rename from panda/src/tinydisplay/zline.c rename to panda/src/tinydisplay/zline.cxx diff --git a/panda/src/tinydisplay/zmath.c b/panda/src/tinydisplay/zmath.cxx similarity index 100% rename from panda/src/tinydisplay/zmath.c rename to panda/src/tinydisplay/zmath.cxx diff --git a/panda/src/tinydisplay/ztriangle.c b/panda/src/tinydisplay/ztriangle.cxx similarity index 83% rename from panda/src/tinydisplay/ztriangle.c rename to panda/src/tinydisplay/ztriangle.cxx index 522d0d7cd0..831df3af88 100644 --- a/panda/src/tinydisplay/ztriangle.c +++ b/panda/src/tinydisplay/ztriangle.cxx @@ -18,28 +18,28 @@ #define STORE_Z(zpix, z) (zpix) = (z) #define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) ((a) < (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) #define ZCMP(zpix, z) 1 #define FNAME(name) name ## _xx_zon_noblend_aless_znone #include "ztriangle_two.h" #define STORE_Z(zpix, z) (zpix) = (z) #define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) ((a) < (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) #define ZCMP(zpix, z) ((zpix) < (z)) #define FNAME(name) name ## _xx_zon_noblend_aless_zless #include "ztriangle_two.h" #define STORE_Z(zpix, z) (zpix) = (z) #define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) ((a) > (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) #define ZCMP(zpix, z) 1 #define FNAME(name) name ## _xx_zon_noblend_amore_znone #include "ztriangle_two.h" #define STORE_Z(zpix, z) (zpix) = (z) #define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) ((a) > (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) #define ZCMP(zpix, z) ((zpix) < (z)) #define FNAME(name) name ## _xx_zon_noblend_amore_zless #include "ztriangle_two.h" @@ -60,28 +60,28 @@ #define STORE_Z(zpix, z) (zpix) = (z) #define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) ((a) < (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) #define ZCMP(zpix, z) 1 #define FNAME(name) name ## _xx_zon_blend_aless_znone #include "ztriangle_two.h" #define STORE_Z(zpix, z) (zpix) = (z) #define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) ((a) < (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) #define ZCMP(zpix, z) ((zpix) < (z)) #define FNAME(name) name ## _xx_zon_blend_aless_zless #include "ztriangle_two.h" #define STORE_Z(zpix, z) (zpix) = (z) #define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) ((a) > (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) #define ZCMP(zpix, z) 1 #define FNAME(name) name ## _xx_zon_blend_amore_znone #include "ztriangle_two.h" #define STORE_Z(zpix, z) (zpix) = (z) #define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) ((a) > (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) #define ZCMP(zpix, z) ((zpix) < (z)) #define FNAME(name) name ## _xx_zon_blend_amore_zless #include "ztriangle_two.h" @@ -102,28 +102,28 @@ #define STORE_Z(zpix, z) (zpix) = (z) #define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) ((a) < (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) #define ZCMP(zpix, z) 1 #define FNAME(name) name ## _xx_zon_nocolor_aless_znone #include "ztriangle_two.h" #define STORE_Z(zpix, z) (zpix) = (z) #define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) ((a) < (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) #define ZCMP(zpix, z) ((zpix) < (z)) #define FNAME(name) name ## _xx_zon_nocolor_aless_zless #include "ztriangle_two.h" #define STORE_Z(zpix, z) (zpix) = (z) #define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) ((a) > (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) #define ZCMP(zpix, z) 1 #define FNAME(name) name ## _xx_zon_nocolor_amore_znone #include "ztriangle_two.h" #define STORE_Z(zpix, z) (zpix) = (z) #define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) ((a) > (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) #define ZCMP(zpix, z) ((zpix) < (z)) #define FNAME(name) name ## _xx_zon_nocolor_amore_zless #include "ztriangle_two.h" @@ -144,28 +144,28 @@ #define STORE_Z(zpix, z) #define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) ((a) < (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) #define ZCMP(zpix, z) 1 #define FNAME(name) name ## _xx_zoff_noblend_aless_znone #include "ztriangle_two.h" #define STORE_Z(zpix, z) #define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) ((a) < (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) #define ZCMP(zpix, z) ((zpix) < (z)) #define FNAME(name) name ## _xx_zoff_noblend_aless_zless #include "ztriangle_two.h" #define STORE_Z(zpix, z) #define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) ((a) > (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) #define ZCMP(zpix, z) 1 #define FNAME(name) name ## _xx_zoff_noblend_amore_znone #include "ztriangle_two.h" #define STORE_Z(zpix, z) #define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) ((a) > (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) #define ZCMP(zpix, z) ((zpix) < (z)) #define FNAME(name) name ## _xx_zoff_noblend_amore_zless #include "ztriangle_two.h" @@ -186,28 +186,28 @@ #define STORE_Z(zpix, z) #define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) ((a) < (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) #define ZCMP(zpix, z) 1 #define FNAME(name) name ## _xx_zoff_blend_aless_znone #include "ztriangle_two.h" #define STORE_Z(zpix, z) #define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) ((a) < (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) #define ZCMP(zpix, z) ((zpix) < (z)) #define FNAME(name) name ## _xx_zoff_blend_aless_zless #include "ztriangle_two.h" #define STORE_Z(zpix, z) #define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) ((a) > (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) #define ZCMP(zpix, z) 1 #define FNAME(name) name ## _xx_zoff_blend_amore_znone #include "ztriangle_two.h" #define STORE_Z(zpix, z) #define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) ((a) > (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) #define ZCMP(zpix, z) ((zpix) < (z)) #define FNAME(name) name ## _xx_zoff_blend_amore_zless #include "ztriangle_two.h" @@ -228,28 +228,28 @@ #define STORE_Z(zpix, z) #define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) ((a) < (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) #define ZCMP(zpix, z) 1 #define FNAME(name) name ## _xx_zoff_nocolor_aless_znone #include "ztriangle_two.h" #define STORE_Z(zpix, z) #define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) ((a) < (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) #define ZCMP(zpix, z) ((zpix) < (z)) #define FNAME(name) name ## _xx_zoff_nocolor_aless_zless #include "ztriangle_two.h" #define STORE_Z(zpix, z) #define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) ((a) > (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) #define ZCMP(zpix, z) 1 #define FNAME(name) name ## _xx_zoff_nocolor_amore_znone #include "ztriangle_two.h" #define STORE_Z(zpix, z) #define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) ((a) > (zb)->reference_alpha) +#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) #define ZCMP(zpix, z) ((zpix) < (z)) #define FNAME(name) name ## _xx_zoff_nocolor_amore_zless #include "ztriangle_two.h" diff --git a/panda/src/tinydisplay/ztriangle.h b/panda/src/tinydisplay/ztriangle.h index 72a82490f0..761d5646c7 100644 --- a/panda/src/tinydisplay/ztriangle.h +++ b/panda/src/tinydisplay/ztriangle.h @@ -55,16 +55,16 @@ /* we compute dXdx and dXdy for all interpolated values */ - fdx1 = p1->x - p0->x; - fdy1 = p1->y - p0->y; + fdx1 = (float) (p1->x - p0->x); + fdy1 = (float) (p1->y - p0->y); - fdx2 = p2->x - p0->x; - fdy2 = p2->y - p0->y; + fdx2 = (float) (p2->x - p0->x); + fdy2 = (float) (p2->y - p0->y); fz = fdx1 * fdy2 - fdx2 * fdy1; if (fz == 0) return; - fz = 1.0 / fz; + fz = 1.0f / fz; fdx1 *= fz; fdy1 *= fz; @@ -72,43 +72,43 @@ fdy2 *= fz; #ifdef INTERP_Z - d1 = p1->z - p0->z; - d2 = p2->z - p0->z; + d1 = (float) (p1->z - p0->z); + d2 = (float) (p2->z - p0->z); dzdx = (int) (fdy2 * d1 - fdy1 * d2); dzdy = (int) (fdx1 * d2 - fdx2 * d1); #endif #ifdef INTERP_RGB - d1 = p1->r - p0->r; - d2 = p2->r - p0->r; + d1 = (float) (p1->r - p0->r); + d2 = (float) (p2->r - p0->r); drdx = (int) (fdy2 * d1 - fdy1 * d2); drdy = (int) (fdx1 * d2 - fdx2 * d1); - d1 = p1->g - p0->g; - d2 = p2->g - p0->g; + d1 = (float) (p1->g - p0->g); + d2 = (float) (p2->g - p0->g); dgdx = (int) (fdy2 * d1 - fdy1 * d2); dgdy = (int) (fdx1 * d2 - fdx2 * d1); - d1 = p1->b - p0->b; - d2 = p2->b - p0->b; + d1 = (float) (p1->b - p0->b); + d2 = (float) (p2->b - p0->b); dbdx = (int) (fdy2 * d1 - fdy1 * d2); dbdy = (int) (fdx1 * d2 - fdx2 * d1); - d1 = p1->a - p0->a; - d2 = p2->a - p0->a; + d1 = (float) (p1->a - p0->a); + d2 = (float) (p2->a - p0->a); dadx = (int) (fdy2 * d1 - fdy1 * d2); dady = (int) (fdx1 * d2 - fdx2 * d1); #endif #ifdef INTERP_ST - d1 = p1->s - p0->s; - d2 = p2->s - p0->s; + d1 = (float) (p1->s - p0->s); + d2 = (float) (p2->s - p0->s); dsdx = (int) (fdy2 * d1 - fdy1 * d2); dsdy = (int) (fdx1 * d2 - fdx2 * d1); - d1 = p1->t - p0->t; - d2 = p2->t - p0->t; + d1 = (float) (p1->t - p0->t); + d2 = (float) (p2->t - p0->t); dtdx = (int) (fdy2 * d1 - fdy1 * d2); dtdy = (int) (fdx1 * d2 - fdx2 * d1); #endif diff --git a/panda/src/tinydisplay/ztriangle_two.h b/panda/src/tinydisplay/ztriangle_two.h index 80f0be128f..def179a714 100644 --- a/panda/src/tinydisplay/ztriangle_two.h +++ b/panda/src/tinydisplay/ztriangle_two.h @@ -283,7 +283,7 @@ void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb, float sz,tz,fz,zinv; \ n=(x2>>16)-x1; \ fz=(float)z1; \ - zinv=1.0 / fz; \ + zinv=1.0f / fz; \ pp=(PIXEL *)((char *)pp1 + x1 * PSZB); \ pz=pz1+x1; \ z=z1; \ @@ -299,7 +299,7 @@ void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb, dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \ dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \ fz+=fndzdx; \ - zinv=1.0 / fz; \ + zinv=1.0f / fz; \ } \ PUT_PIXEL(0); \ PUT_PIXEL(1); \ @@ -402,7 +402,7 @@ void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb, float sz,tz,fz,zinv; \ n=(x2>>16)-x1; \ fz=(float)z1; \ - zinv=1.0 / fz; \ + zinv=1.0f / fz; \ pp=(PIXEL *)((char *)pp1 + x1 * PSZB); \ pz=pz1+x1; \ z=z1; \ @@ -422,7 +422,7 @@ void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb, dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \ dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \ fz+=fndzdx; \ - zinv=1.0 / fz; \ + zinv=1.0f / fz; \ } \ PUT_PIXEL(0); \ PUT_PIXEL(1); \ @@ -537,7 +537,7 @@ void FNAME(ZB_fillTriangleMappingPerspectiveSmooth) (ZBuffer *zb, float sz,tz,fz,zinv; \ n=(x2>>16)-x1; \ fz=(float)z1; \ - zinv=1.0 / fz; \ + zinv=1.0f / fz; \ pp=(PIXEL *)((char *)pp1 + x1 * PSZB); \ pz=pz1+x1; \ z=z1; \ @@ -557,7 +557,7 @@ void FNAME(ZB_fillTriangleMappingPerspectiveSmooth) (ZBuffer *zb, dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \ dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \ fz+=fndzdx; \ - zinv=1.0 / fz; \ + zinv=1.0f / fz; \ } \ PUT_PIXEL(0); \ PUT_PIXEL(1); \