From a1503b00f863a48a517939a42d512f9cfe77f79c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 16 Jul 2001 15:54:23 +0000 Subject: [PATCH] Various 16-bit GLchan fixes and Win32 fixes (Gerk Huisma) --- src/mesa/main/colormac.h | 4 ++-- src/mesa/main/config.h | 4 +++- src/mesa/main/glheader.h | 10 +++++++++- src/mesa/main/imports.c | 14 +++++++------- src/mesa/main/teximage.c | 4 +++- src/mesa/main/texstore.c | 40 +++++++++++++++++++++------------------- 6 files changed, 45 insertions(+), 31 deletions(-) diff --git a/src/mesa/main/colormac.h b/src/mesa/main/colormac.h index 0812a517047..9b41a0655ef 100644 --- a/src/mesa/main/colormac.h +++ b/src/mesa/main/colormac.h @@ -1,4 +1,4 @@ -/* $Id: colormac.h,v 1.9 2001/03/11 18:49:11 gareth Exp $ */ +/* $Id: colormac.h,v 1.10 2001/07/16 15:54:23 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -81,7 +81,7 @@ #define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC) -#define CHAN_PRODUCT(a, b) ((GLchan) ((((GLint) (a)) * ((GLint) (b))) / 65535)) +#define CHAN_PRODUCT(a, b) ((GLchan) ((((GLuint) (a)) * ((GLuint) (b))) / 65535)) #elif CHAN_BITS == 32 diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index 507f499a1fc..fa65d611bd0 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -1,4 +1,4 @@ -/* $Id: config.h,v 1.33 2001/07/13 20:07:37 brianp Exp $ */ +/* $Id: config.h,v 1.34 2001/07/16 15:54:23 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -152,7 +152,9 @@ * work. 32 doesn't work because of integer overflow problems in the * rasterizer code. */ +#ifndef DEFAULT_SOFTWARE_DEPTH_BITS #define DEFAULT_SOFTWARE_DEPTH_BITS 16 +#endif #if DEFAULT_SOFTWARE_DEPTH_BITS <= 16 #define DEFAULT_SOFTWARE_DEPTH_TYPE GLushort #else diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h index 596bd2d01ee..41c47420409 100644 --- a/src/mesa/main/glheader.h +++ b/src/mesa/main/glheader.h @@ -1,4 +1,4 @@ -/* $Id: glheader.h,v 1.21 2001/06/15 15:22:07 brianp Exp $ */ +/* $Id: glheader.h,v 1.22 2001/07/16 15:54:23 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -173,8 +173,12 @@ typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESC #ifndef CAPI +#ifdef WIN32 +#define CAPI _cdecl +#else #define CAPI #endif +#endif #include @@ -221,6 +225,10 @@ typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESC # define INLINE __inline__ #elif defined(__MSC__) # define INLINE __inline +#elif defined(_MSC_VER) +# define INLINE __inline +#elif defined(__ICL) +# define INLINE __inline #else # define INLINE #endif diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 60cca8433e2..61fbf609157 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -1,4 +1,4 @@ -/* $Id: imports.c,v 1.9 2001/03/27 19:18:02 gareth Exp $ */ +/* $Id: imports.c,v 1.10 2001/07/16 15:54:23 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -71,7 +71,7 @@ _mesa_Free(__GLcontext *gc, void *addr) /* Must be before '#undef getenv' for inclusion in XFree86. */ -static char * +static char * CAPI _mesa_getenv(__GLcontext *gc, const char *var) { (void) gc; @@ -109,33 +109,33 @@ _mesa_fatal(__GLcontext *gc, char *str) abort(); } -static int +static int CAPI _mesa_atoi(__GLcontext *gc, const char *str) { (void) gc; return atoi(str); } -static int +static int CAPI _mesa_sprintf(__GLcontext *gc, char *str, const char *fmt, ...) { /* XXX fix this */ return sprintf(str, fmt); } -static void * +static void * CAPI _mesa_fopen(__GLcontext *gc, const char *path, const char *mode) { return fopen(path, mode); } -static int +static int CAPI _mesa_fclose(__GLcontext *gc, void *stream) { return fclose((FILE *) stream); } -static int +static int CAPI _mesa_fprintf(__GLcontext *gc, void *stream, const char *fmt, ...) { /* XXX fix this */ diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index ffddeffbabc..7d00ed60251 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1,4 +1,4 @@ -/* $Id: teximage.c,v 1.100 2001/07/13 20:07:37 brianp Exp $ */ +/* $Id: teximage.c,v 1.101 2001/07/16 15:54:23 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -520,6 +520,7 @@ make_null_texture(GLint width, GLint height, GLint depth, GLenum format) const GLint numPixels = width * height * depth; GLubyte *data = (GLubyte *) MALLOC(numPixels * components * sizeof(GLubyte)); +#ifdef DEBUG /* * Let's see if anyone finds this. If glTexImage2D() is called with * a NULL image pointer then load the texture image with something @@ -552,6 +553,7 @@ make_null_texture(GLint width, GLint height, GLint depth, GLenum format) } } } +#endif return data; } diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 56ec66e13ae..c71ef966318 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -1,4 +1,4 @@ -/* $Id: texstore.c,v 1.31 2001/07/13 20:07:37 brianp Exp $ */ +/* $Id: texstore.c,v 1.32 2001/07/16 15:54:23 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -189,8 +189,9 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions, const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); const GLint widthInBytes = srcWidth * texComponents * sizeof(GLchan); - GLchan *dst = (GLchan *) texDestAddr + dstYoffset * dstRowStride - + dstXoffset * texComponents; + GLchan *dst = (GLchan *) texDestAddr + + dstYoffset * (dstRowStride / sizeof(GLchan)) + + dstXoffset * texComponents; if (srcRowStride == widthInBytes && dstRowStride == widthInBytes) { MEMCPY(dst, src, srcHeight * widthInBytes); } @@ -198,8 +199,8 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions, GLint i; for (i = 0; i < srcHeight; i++) { MEMCPY(dst, src, widthInBytes); - src += srcRowStride; - dst += dstRowStride; + src += (srcRowStride / sizeof(GLchan)); + dst += (dstRowStride / sizeof(GLchan)); } } return; /* all done */ @@ -211,8 +212,9 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions, srcFormat, srcType, 0, 0, 0); const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLchan *dst = (GLchan *) texDestAddr + dstYoffset * dstRowStride - + dstXoffset * texComponents; + GLchan *dst = (GLchan *) texDestAddr + + dstYoffset * (dstRowStride / sizeof(GLchan)) + + dstXoffset * texComponents; GLint i, j; for (i = 0; i < srcHeight; i++) { const GLchan *s = src; @@ -223,8 +225,8 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions, *d++ = *s++; /*blue*/ s++; /*alpha*/ } - src += srcRowStride; - dst += dstRowStride; + src += (srcRowStride / sizeof(GLchan)); + dst += (dstRowStride / sizeof(GLchan)); } return; /* all done */ } @@ -238,8 +240,8 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions, const GLenum texType = CHAN_TYPE; GLint img, row; GLchan *dest = (GLchan *) texDestAddr + dstZoffset * dstImageStride - + dstYoffset * dstRowStride - + dstXoffset * texComponents; + + dstYoffset * (dstRowStride / sizeof(GLchan)) + + dstXoffset * texComponents; for (img = 0; img < srcDepth; img++) { GLchan *destRow = dest; for (row = 0; row < srcHeight; row++) { @@ -247,7 +249,7 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); _mesa_unpack_index_span(ctx, srcWidth, texType, destRow, srcType, src, srcPacking, transferOps); - destRow += dstRowStride; + destRow += (dstRowStride / sizeof(GLchan)); } dest += dstImageStride; } @@ -257,7 +259,7 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions, GLint img, row; GLubyte *dest = (GLubyte *) texDestAddr + dstZoffset * dstImageStride - + dstYoffset * dstRowStride + + dstYoffset * (dstRowStride / sizeof(GLchan)) + dstXoffset * texComponents; for (img = 0; img < srcDepth; img++) { GLubyte *destRow = dest; @@ -266,7 +268,7 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); _mesa_unpack_depth_span(ctx, srcWidth, (GLfloat *) destRow, srcType, src, srcPacking); - destRow += dstRowStride; + destRow += (dstRowStride / sizeof(GLchan)); } dest += dstImageStride; } @@ -331,7 +333,7 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions, /* packing and transfer ops after convolution */ srcf = convImage; dest = (GLchan *) texDestAddr + (dstZoffset + img) * dstImageStride - + dstYoffset * dstRowStride; + + dstYoffset * (dstRowStride / sizeof(GLchan)); for (row = 0; row < convHeight; row++) { _mesa_pack_float_rgba_span(ctx, convWidth, (const GLfloat (*)[4]) srcf, @@ -340,7 +342,7 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions, transferOps & IMAGE_POST_CONVOLUTION_BITS); srcf += convWidth * 4; - dest += dstRowStride; + dest += (dstRowStride / sizeof(GLchan)); } } @@ -353,8 +355,8 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions, */ GLint img, row; GLchan *dest = (GLchan *) texDestAddr + dstZoffset * dstImageStride - + dstYoffset * dstRowStride - + dstXoffset * texComponents; + + dstYoffset * (dstRowStride / sizeof(GLchan)) + + dstXoffset * texComponents; for (img = 0; img < srcDepth; img++) { GLchan *destRow = dest; for (row = 0; row < srcHeight; row++) { @@ -364,7 +366,7 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions, _mesa_unpack_chan_color_span(ctx, srcWidth, texDestFormat, destRow, srcFormat, srcType, srcRow, srcPacking, transferOps); - destRow += dstRowStride; + destRow += (dstRowStride / sizeof(GLchan)); } dest += dstImageStride; } -- 2.30.2