in swrast/s_spantemp.h to allow dithering to be used in the SNAP drivers.
-/* $Id: fb_dri.c,v 1.1 2003/08/06 18:11:57 keithw Exp $ */
+/* $Id: fb_dri.c,v 1.2 2003/10/08 01:53:30 kendallb Exp $ */
/*
* Mesa 3-D graphics library
#define INIT_PIXEL_PTR(P, X, Y) \
GLubyte *P = (char *)dPriv->currentBuffer + (Y) * dPriv->currentPitch + (X) * 3
#define INC_PIXEL_PTR(P) P += 3
-#define STORE_RGB_PIXEL(P, R, G, B) \
+#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
P[0] = B; P[1] = G; P[2] = R
-#define STORE_RGBA_PIXEL(P, R, G, B, A) \
+#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
P[0] = B; P[1] = G; P[2] = R
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = P[2]; G = P[1]; B = P[0]; A = CHAN_MAX
#define INIT_PIXEL_PTR(P, X, Y) \
GLubyte *P = (char *)dPriv->currentBuffer + (Y) * dPriv->currentPitch + (X) * 4;
#define INC_PIXEL_PTR(P) P += 4
-#define STORE_RGB_PIXEL(P, R, G, B) \
+#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
P[0] = B; P[1] = G; P[2] = R; P[3] = 255
-#define STORE_RGBA_PIXEL(P, R, G, B, A) \
+#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
P[0] = B; P[1] = G; P[2] = R; P[3] = A
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = P[2]; G = P[1]; B = P[0]; A = P[3]
#define INIT_PIXEL_PTR(P, X, Y) \
GLushort *P = (GLushort *) ((char *)dPriv->currentBuffer + (Y) * dPriv->currentPitch + (X) * 2)
#define INC_PIXEL_PTR(P) P += 1
-#define STORE_RGB_PIXEL(P, R, G, B) \
+#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
*P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
-#define STORE_RGBA_PIXEL(P, R, G, B, A) \
+#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
*P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = ( (((*P) >> 8) & 0xf8) | (((*P) >> 11) & 0x7) ); \
#define INIT_PIXEL_PTR(P, X, Y) \
GLushort *P = (GLushort *) ((char *)dPriv->currentBuffer + (Y) * dPriv->currentPitch + (X) * 2)
#define INC_PIXEL_PTR(P) P += 1
-#define STORE_RGB_PIXEL(P, R, G, B) \
+#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
*P = ( (((R) & 0xf8) << 7) | (((G) & 0xf8) << 2) | ((B) >> 3) )
-#define STORE_RGBA_PIXEL(P, R, G, B, A) \
+#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
*P = ( (((R) & 0xf8) << 7) | (((G) & 0xf8) << 2) | ((B) >> 3) )
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = ( (((*P) >> 7) & 0xf8) | (((*P) >> 10) & 0x7) ); \
GLchan *P = osmesa->rowaddr[Y] + 4 * (X)
#define INC_PIXEL_PTR(P) P += 4
#if CHAN_TYPE == GL_FLOAT
-#define STORE_RGB_PIXEL(P, R, G, B) \
+#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
P[0] = MAX2((R), 0.0F); \
P[1] = MAX2((G), 0.0F); \
P[2] = MAX2((B), 0.0F); \
P[3] = CHAN_MAXF
-#define STORE_RGBA_PIXEL(P, R, G, B, A) \
+#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
P[0] = MAX2((R), 0.0F); \
P[1] = MAX2((G), 0.0F); \
P[2] = MAX2((B), 0.0F); \
P[3] = CLAMP((A), 0.0F, CHAN_MAXF)
#else
-#define STORE_RGB_PIXEL(P, R, G, B) \
+#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
P[0] = R; P[1] = G; P[2] = B; P[3] = CHAN_MAX
-#define STORE_RGBA_PIXEL(P, R, G, B, A) \
+#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
P[0] = R; P[1] = G; P[2] = B; P[3] = A
#endif
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
#define INIT_PIXEL_PTR(P, X, Y) \
GLchan *P = osmesa->rowaddr[Y] + 4 * (X)
#define INC_PIXEL_PTR(P) P += 4
-#define STORE_RGB_PIXEL(P, R, G, B) \
+#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
P[2] = R; P[1] = G; P[0] = B; P[3] = CHAN_MAX
-#define STORE_RGBA_PIXEL(P, R, G, B, A) \
+#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
P[2] = R; P[1] = G; P[0] = B; P[3] = A
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = P[2]; G = P[1]; B = P[0]; A = P[3]
#define INIT_PIXEL_PTR(P, X, Y) \
GLchan *P = osmesa->rowaddr[Y] + 4 * (X)
#define INC_PIXEL_PTR(P) P += 4
-#define STORE_RGB_PIXEL(P, R, G, B) \
+#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
P[1] = R; P[2] = G; P[3] = B; P[0] = CHAN_MAX
-#define STORE_RGBA_PIXEL(P, R, G, B, A) \
+#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
P[1] = R; P[2] = G; P[3] = B; P[0] = A
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = P[1]; G = P[2]; B = P[3]; A = P[0]
#define INIT_PIXEL_PTR(P, X, Y) \
GLchan *P = osmesa->rowaddr[Y] + 4 * (X)
#define INC_PIXEL_PTR(P) P += 4
-#define STORE_RGB_PIXEL(P, R, G, B) \
+#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
P[0] = R; P[1] = G; P[2] = B
-#define STORE_RGBA_PIXEL(P, R, G, B, A) \
+#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
P[0] = R; P[1] = G; P[2] = B
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = P[0]; G = P[1]; B = P[2]; A = CHAN_MAX
#define INIT_PIXEL_PTR(P, X, Y) \
GLchan *P = osmesa->rowaddr[Y] + 4 * (X)
#define INC_PIXEL_PTR(P) P += 4
-#define STORE_RGB_PIXEL(P, R, G, B) \
+#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
P[0] = B; P[1] = G; P[2] = R
-#define STORE_RGBA_PIXEL(P, R, G, B, A) \
+#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
P[0] = B; P[1] = G; P[2] = R
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
B = P[0]; G = P[1]; R = P[2]; A = CHAN_MAX
#define INIT_PIXEL_PTR(P, X, Y) \
GLushort *P = (GLushort *) osmesa->rowaddr[Y] + (X)
#define INC_PIXEL_PTR(P) P += 1
-#define STORE_RGB_PIXEL(P, R, G, B) \
+#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
*P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
-#define STORE_RGBA_PIXEL(P, R, G, B, A) \
+#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
*P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = ( (((*P) >> 8) & 0xf8) | (((*P) >> 11) & 0x7) ); \
#endif
-#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__)
+#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
# define __WIN32__
# define finite _finite
#endif
-#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__))
+#if defined(__WATCOMC__)
+# define finite _finite
+#endif
+
+#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP)
# pragma warning( disable : 4068 ) /* unknown pragma */
# pragma warning( disable : 4710 ) /* function 'foo' not inlined */
# pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
# endif
# define GLWINAPI __stdcall
# define GLWINAPIV __cdecl
-#elif !defined(__SCITECH_SNAP__)
+#elif !defined(BUILD_FOR_SNAP)
/* non-Windows compilation */
# define GLAPI extern
# define GLAPIENTRY
/* compatibility guard so we don't need to change client code */
-#if defined(_WIN32) && !defined(_WINDEF_) && !defined(_WINDEF_H) && !defined(_GNU_H_WINDOWS32_BASE) && !defined(OPENSTEP) && !defined(__CYGWIN__)
+#if defined(_WIN32) && !defined(_WINDEF_) && !defined(_WINDEF_H) && !defined(_GNU_H_WINDOWS32_BASE) && !defined(OPENSTEP) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
#if 0
# define CALLBACK GLCALLBACK
typedef void *HGLRC;
#define GL_GLEXT_PROTOTYPES
-#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_WINGDI_H) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP)
+#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_WINGDI_H) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(BUILD_FOR_SNAP)
# define WGL_FONT_LINES 0
# define WGL_FONT_POLYGONS 1
#ifndef _GNU_H_WINDOWS32_FUNCTIONS
#ifndef CAPI
-#ifdef WIN32
+#if defined(WIN32) && !defined(BUILD_FOR_SNAP)
#define CAPI _cdecl
#else
#define CAPI
#endif
-#if defined(__SCITECH_SNAP__) && defined(CHECKED)
+#if defined(BUILD_FOR_SNAP) && defined(CHECKED)
# define ASSERT(X) _CHECK(X)
#elif defined(DEBUG)
# define ASSERT(X) assert(X)
# define ALIGN16 __attribute__ ((aligned (16)))
#elif defined(__MSC__)
# define ALIGN16 __declspec(align(16)) /* GH: Does this work? */
+#elif defined(__WATCOMC__)
+# define ALIGN16 /* Watcom does not support this */
#else
# warning "ALIGN16 will not 16-byte align!\n"
# define ALIGN16
* SPAN_VARS to declare any local variables
* INIT_PIXEL_PTR(P, X, Y) to initialize a pointer to a pixel
* INC_PIXEL_PTR(P) to increment a pixel pointer by one pixel
- * STORE_RGB_PIXEL(P, R, G, B) to store RGB values in pixel P
- * STORE_RGBA_PIXEL(P, R, G, B, A) to store RGBA values in pixel P
+ * STORE_RGB_PIXEL(P, X, Y, R, G, B) to store RGB values in pixel P
+ * STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) to store RGBA values in pixel P
* FETCH_RGBA_PIXEL(R, G, B, A, P) to fetch RGBA values from pixel P
+ *
+ * Note that in the above STORE_RGBx_PIXEL macros, we also pass in the (X,Y)
+ * coordinates for the pixels to be stored, which enables dithering in 8-bit
+ * and 15/16-bit display modes. Most undithered modes or 24/32-bit display
+ * modes will simply ignore the passed in (X,Y) values.
+ *
* For color index mode:
* STORE_CI_PIXEL(P, CI) to store a color index in pixel P
* FETCH_CI_PIXEL(CI, P) to fetch a pixel index from pixel P
if (mask) {
for (i = 0; i < n; i++) {
if (mask[i]) {
- STORE_RGBA_PIXEL(pixel, rgba[i][RCOMP], rgba[i][GCOMP],
+ STORE_RGBA_PIXEL(pixel, x+i, y, rgba[i][RCOMP], rgba[i][GCOMP],
rgba[i][BCOMP], rgba[i][ACOMP]);
}
INC_PIXEL_PTR(pixel);
}
else {
for (i = 0; i < n; i++) {
- STORE_RGBA_PIXEL(pixel, rgba[i][RCOMP], rgba[i][GCOMP],
+ STORE_RGBA_PIXEL(pixel, x+i, y, rgba[i][RCOMP], rgba[i][GCOMP],
rgba[i][BCOMP], rgba[i][ACOMP]);
INC_PIXEL_PTR(pixel);
}
if (mask) {
for (i = 0; i < n; i++) {
if (mask[i]) {
- STORE_RGB_PIXEL(pixel, rgb[i][RCOMP], rgb[i][GCOMP],
+ STORE_RGB_PIXEL(pixel, x+i, y, rgb[i][RCOMP], rgb[i][GCOMP],
rgb[i][BCOMP]);
}
INC_PIXEL_PTR(pixel);
}
else {
for (i = 0; i < n; i++) {
- STORE_RGB_PIXEL(pixel, rgb[i][RCOMP], rgb[i][GCOMP],
+ STORE_RGB_PIXEL(pixel, x+i, y, rgb[i][RCOMP], rgb[i][GCOMP],
rgb[i][BCOMP]);
INC_PIXEL_PTR(pixel);
}
if (mask) {
for (i = 0; i < n; i++) {
if (mask[i]) {
- STORE_RGBA_PIXEL(pixel, color[RCOMP], color[GCOMP],
+ STORE_RGBA_PIXEL(pixel, x+i, y, color[RCOMP], color[GCOMP],
color[BCOMP], color[ACOMP]);
}
INC_PIXEL_PTR(pixel);
}
else {
for (i = 0; i < n; i++) {
- STORE_RGBA_PIXEL(pixel, color[RCOMP], color[GCOMP],
+ STORE_RGBA_PIXEL(pixel, x+i, y, color[RCOMP], color[GCOMP],
color[BCOMP], color[ACOMP]);
INC_PIXEL_PTR(pixel);
}
for (i = 0; i < n; i++) {
if (mask[i]) {
INIT_PIXEL_PTR(pixel, x[i], y[i]);
- STORE_RGBA_PIXEL(pixel, rgba[i][RCOMP], rgba[i][GCOMP],
+ STORE_RGBA_PIXEL(pixel, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP],
rgba[i][BCOMP], rgba[i][ACOMP]);
}
}
for (i = 0; i < n; i++) {
if (mask[i]) {
INIT_PIXEL_PTR(pixel, x[i], y[i]);
- STORE_RGBA_PIXEL(pixel, color[RCOMP], color[GCOMP],
+ STORE_RGBA_PIXEL(pixel, x[i], y[i], color[RCOMP], color[GCOMP],
color[BCOMP], color[ACOMP]);
}
}