Various 16-bit GLchan fixes and Win32 fixes (Gerk Huisma)

This commit is contained in:
Brian Paul 2001-07-16 15:54:23 +00:00
parent fba5e95468
commit a1503b00f8
6 changed files with 45 additions and 31 deletions

View file

@ -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 * Mesa 3-D graphics library
@ -81,7 +81,7 @@
#define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC) #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 #elif CHAN_BITS == 32

View file

@ -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 * Mesa 3-D graphics library
@ -152,7 +152,9 @@
* work. 32 doesn't work because of integer overflow problems in the * work. 32 doesn't work because of integer overflow problems in the
* rasterizer code. * rasterizer code.
*/ */
#ifndef DEFAULT_SOFTWARE_DEPTH_BITS
#define DEFAULT_SOFTWARE_DEPTH_BITS 16 #define DEFAULT_SOFTWARE_DEPTH_BITS 16
#endif
#if DEFAULT_SOFTWARE_DEPTH_BITS <= 16 #if DEFAULT_SOFTWARE_DEPTH_BITS <= 16
#define DEFAULT_SOFTWARE_DEPTH_TYPE GLushort #define DEFAULT_SOFTWARE_DEPTH_TYPE GLushort
#else #else

View file

@ -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 * Mesa 3-D graphics library
@ -173,8 +173,12 @@ typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESC
#ifndef CAPI #ifndef CAPI
#ifdef WIN32
#define CAPI _cdecl
#else
#define CAPI #define CAPI
#endif #endif
#endif
#include <GL/internal/glcore.h> #include <GL/internal/glcore.h>
@ -221,6 +225,10 @@ typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESC
# define INLINE __inline__ # define INLINE __inline__
#elif defined(__MSC__) #elif defined(__MSC__)
# define INLINE __inline # define INLINE __inline
#elif defined(_MSC_VER)
# define INLINE __inline
#elif defined(__ICL)
# define INLINE __inline
#else #else
# define INLINE # define INLINE
#endif #endif

View file

@ -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 * Mesa 3-D graphics library
@ -71,7 +71,7 @@ _mesa_Free(__GLcontext *gc, void *addr)
/* Must be before '#undef getenv' for inclusion in XFree86. /* Must be before '#undef getenv' for inclusion in XFree86.
*/ */
static char * static char * CAPI
_mesa_getenv(__GLcontext *gc, const char *var) _mesa_getenv(__GLcontext *gc, const char *var)
{ {
(void) gc; (void) gc;
@ -109,33 +109,33 @@ _mesa_fatal(__GLcontext *gc, char *str)
abort(); abort();
} }
static int static int CAPI
_mesa_atoi(__GLcontext *gc, const char *str) _mesa_atoi(__GLcontext *gc, const char *str)
{ {
(void) gc; (void) gc;
return atoi(str); return atoi(str);
} }
static int static int CAPI
_mesa_sprintf(__GLcontext *gc, char *str, const char *fmt, ...) _mesa_sprintf(__GLcontext *gc, char *str, const char *fmt, ...)
{ {
/* XXX fix this */ /* XXX fix this */
return sprintf(str, fmt); return sprintf(str, fmt);
} }
static void * static void * CAPI
_mesa_fopen(__GLcontext *gc, const char *path, const char *mode) _mesa_fopen(__GLcontext *gc, const char *path, const char *mode)
{ {
return fopen(path, mode); return fopen(path, mode);
} }
static int static int CAPI
_mesa_fclose(__GLcontext *gc, void *stream) _mesa_fclose(__GLcontext *gc, void *stream)
{ {
return fclose((FILE *) stream); return fclose((FILE *) stream);
} }
static int static int CAPI
_mesa_fprintf(__GLcontext *gc, void *stream, const char *fmt, ...) _mesa_fprintf(__GLcontext *gc, void *stream, const char *fmt, ...)
{ {
/* XXX fix this */ /* XXX fix this */

View file

@ -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 * 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; const GLint numPixels = width * height * depth;
GLubyte *data = (GLubyte *) MALLOC(numPixels * components * sizeof(GLubyte)); GLubyte *data = (GLubyte *) MALLOC(numPixels * components * sizeof(GLubyte));
#ifdef DEBUG
/* /*
* Let's see if anyone finds this. If glTexImage2D() is called with * Let's see if anyone finds this. If glTexImage2D() is called with
* a NULL image pointer then load the texture image with something * 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; return data;
} }

View file

@ -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 * Mesa 3-D graphics library
@ -189,7 +189,8 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions,
const GLint srcRowStride = _mesa_image_row_stride(srcPacking, const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
srcWidth, srcFormat, srcType); srcWidth, srcFormat, srcType);
const GLint widthInBytes = srcWidth * texComponents * sizeof(GLchan); const GLint widthInBytes = srcWidth * texComponents * sizeof(GLchan);
GLchan *dst = (GLchan *) texDestAddr + dstYoffset * dstRowStride GLchan *dst = (GLchan *) texDestAddr
+ dstYoffset * (dstRowStride / sizeof(GLchan))
+ dstXoffset * texComponents; + dstXoffset * texComponents;
if (srcRowStride == widthInBytes && dstRowStride == widthInBytes) { if (srcRowStride == widthInBytes && dstRowStride == widthInBytes) {
MEMCPY(dst, src, srcHeight * widthInBytes); MEMCPY(dst, src, srcHeight * widthInBytes);
@ -198,8 +199,8 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions,
GLint i; GLint i;
for (i = 0; i < srcHeight; i++) { for (i = 0; i < srcHeight; i++) {
MEMCPY(dst, src, widthInBytes); MEMCPY(dst, src, widthInBytes);
src += srcRowStride; src += (srcRowStride / sizeof(GLchan));
dst += dstRowStride; dst += (dstRowStride / sizeof(GLchan));
} }
} }
return; /* all done */ return; /* all done */
@ -211,7 +212,8 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions,
srcFormat, srcType, 0, 0, 0); srcFormat, srcType, 0, 0, 0);
const GLint srcRowStride = _mesa_image_row_stride(srcPacking, const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
srcWidth, srcFormat, srcType); srcWidth, srcFormat, srcType);
GLchan *dst = (GLchan *) texDestAddr + dstYoffset * dstRowStride GLchan *dst = (GLchan *) texDestAddr
+ dstYoffset * (dstRowStride / sizeof(GLchan))
+ dstXoffset * texComponents; + dstXoffset * texComponents;
GLint i, j; GLint i, j;
for (i = 0; i < srcHeight; i++) { for (i = 0; i < srcHeight; i++) {
@ -223,8 +225,8 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions,
*d++ = *s++; /*blue*/ *d++ = *s++; /*blue*/
s++; /*alpha*/ s++; /*alpha*/
} }
src += srcRowStride; src += (srcRowStride / sizeof(GLchan));
dst += dstRowStride; dst += (dstRowStride / sizeof(GLchan));
} }
return; /* all done */ return; /* all done */
} }
@ -238,7 +240,7 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions,
const GLenum texType = CHAN_TYPE; const GLenum texType = CHAN_TYPE;
GLint img, row; GLint img, row;
GLchan *dest = (GLchan *) texDestAddr + dstZoffset * dstImageStride GLchan *dest = (GLchan *) texDestAddr + dstZoffset * dstImageStride
+ dstYoffset * dstRowStride + dstYoffset * (dstRowStride / sizeof(GLchan))
+ dstXoffset * texComponents; + dstXoffset * texComponents;
for (img = 0; img < srcDepth; img++) { for (img = 0; img < srcDepth; img++) {
GLchan *destRow = dest; GLchan *destRow = dest;
@ -247,7 +249,7 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
_mesa_unpack_index_span(ctx, srcWidth, texType, destRow, _mesa_unpack_index_span(ctx, srcWidth, texType, destRow,
srcType, src, srcPacking, transferOps); srcType, src, srcPacking, transferOps);
destRow += dstRowStride; destRow += (dstRowStride / sizeof(GLchan));
} }
dest += dstImageStride; dest += dstImageStride;
} }
@ -257,7 +259,7 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions,
GLint img, row; GLint img, row;
GLubyte *dest = (GLubyte *) texDestAddr GLubyte *dest = (GLubyte *) texDestAddr
+ dstZoffset * dstImageStride + dstZoffset * dstImageStride
+ dstYoffset * dstRowStride + dstYoffset * (dstRowStride / sizeof(GLchan))
+ dstXoffset * texComponents; + dstXoffset * texComponents;
for (img = 0; img < srcDepth; img++) { for (img = 0; img < srcDepth; img++) {
GLubyte *destRow = dest; GLubyte *destRow = dest;
@ -266,7 +268,7 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
_mesa_unpack_depth_span(ctx, srcWidth, (GLfloat *) destRow, _mesa_unpack_depth_span(ctx, srcWidth, (GLfloat *) destRow,
srcType, src, srcPacking); srcType, src, srcPacking);
destRow += dstRowStride; destRow += (dstRowStride / sizeof(GLchan));
} }
dest += dstImageStride; dest += dstImageStride;
} }
@ -331,7 +333,7 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions,
/* packing and transfer ops after convolution */ /* packing and transfer ops after convolution */
srcf = convImage; srcf = convImage;
dest = (GLchan *) texDestAddr + (dstZoffset + img) * dstImageStride dest = (GLchan *) texDestAddr + (dstZoffset + img) * dstImageStride
+ dstYoffset * dstRowStride; + dstYoffset * (dstRowStride / sizeof(GLchan));
for (row = 0; row < convHeight; row++) { for (row = 0; row < convHeight; row++) {
_mesa_pack_float_rgba_span(ctx, convWidth, _mesa_pack_float_rgba_span(ctx, convWidth,
(const GLfloat (*)[4]) srcf, (const GLfloat (*)[4]) srcf,
@ -340,7 +342,7 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions,
transferOps transferOps
& IMAGE_POST_CONVOLUTION_BITS); & IMAGE_POST_CONVOLUTION_BITS);
srcf += convWidth * 4; srcf += convWidth * 4;
dest += dstRowStride; dest += (dstRowStride / sizeof(GLchan));
} }
} }
@ -353,7 +355,7 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions,
*/ */
GLint img, row; GLint img, row;
GLchan *dest = (GLchan *) texDestAddr + dstZoffset * dstImageStride GLchan *dest = (GLchan *) texDestAddr + dstZoffset * dstImageStride
+ dstYoffset * dstRowStride + dstYoffset * (dstRowStride / sizeof(GLchan))
+ dstXoffset * texComponents; + dstXoffset * texComponents;
for (img = 0; img < srcDepth; img++) { for (img = 0; img < srcDepth; img++) {
GLchan *destRow = dest; GLchan *destRow = dest;
@ -364,7 +366,7 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions,
_mesa_unpack_chan_color_span(ctx, srcWidth, texDestFormat, _mesa_unpack_chan_color_span(ctx, srcWidth, texDestFormat,
destRow, srcFormat, srcType, srcRow, destRow, srcFormat, srcType, srcRow,
srcPacking, transferOps); srcPacking, transferOps);
destRow += dstRowStride; destRow += (dstRowStride / sizeof(GLchan));
} }
dest += dstImageStride; dest += dstImageStride;
} }