/**
* \file texcompress_fxt1.c
- * GL_EXT_texture_compression_fxt1 support.
+ * GL_3DFX_texture_compression_FXT1 support.
*/
#include "glheader.h"
#include "imports.h"
#include "colormac.h"
-#include "context.h"
-#include "convolve.h"
#include "image.h"
+#include "macros.h"
#include "mipmap.h"
#include "texcompress.h"
#include "texcompress_fxt1.h"
#include "texstore.h"
+#if FEATURE_texture_fxt1
+
+
static void
fxt1_encode (GLuint width, GLuint height, GLint comps,
const void *source, GLint srcRowStride,
GLint i, GLint j, GLchan *rgba);
-/**
- * Called during context initialization.
- */
-void
-_mesa_init_texture_fxt1( GLcontext *ctx )
-{
- (void) ctx;
-}
-
-
/**
* Store user's image in rgb_fxt1 format.
*/
srcPacking);
if (!tempImage)
return GL_FALSE; /* out of memory */
- _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
pixels = tempImage;
srcRowStride = 3 * srcWidth;
srcFormat = GL_RGB;
dst, dstRowStride);
if (tempImage)
- _mesa_free((void*) tempImage);
+ free((void*) tempImage);
return GL_TRUE;
}
srcPacking);
if (!tempImage)
return GL_FALSE; /* out of memory */
- _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
pixels = tempImage;
srcRowStride = 4 * srcWidth;
srcFormat = GL_RGBA;
dst, dstRowStride);
if (tempImage)
- _mesa_free((void*) tempImage);
+ free((void*) tempImage);
return GL_TRUE;
}
-void
-_mesa_fetch_texel_2d_rgba_fxt1( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLchan *texel )
-{
- (void) k;
- fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, texel);
-}
-
-
void
_mesa_fetch_texel_2d_f_rgba_fxt1( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
}
-void
-_mesa_fetch_texel_2d_rgb_fxt1( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLchan *texel )
-{
- (void) k;
- fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, texel);
- texel[ACOMP] = 255;
-}
-
-
void
_mesa_fetch_texel_2d_f_rgb_fxt1( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
} hist[N_TEXELS];
GLint lenh = 0;
- _mesa_memset(hist, 0, sizeof(hist));
+ memset(hist, 0, sizeof(hist));
for (k = 0; k < n; k++) {
GLint l;
* for each sample color
* sort to nearest vector.
*
- * replace each vector with the centroid of it's matching colors.
+ * replace each vector with the centroid of its matching colors.
*
* repeat until RMS doesn't improve.
*
#else
GLint best = fxt1_bestcol(vec, nv, input[k], nc, &err);
#endif
+ assert(best >= 0);
/* add in closest color */
for (i = 0; i < nc; i++) {
sum[best][i] += input[k][i];
if (comps == 3) {
/* make the whole block opaque */
- _mesa_memset(input, -1, sizeof(input));
+ memset(input, -1, sizeof(input));
}
/* 8 texels each line */
if ((width & 7) | (height & 3)) {
GLint newWidth = (width + 7) & ~7;
GLint newHeight = (height + 3) & ~3;
- newSource = _mesa_malloc(comps * newWidth * newHeight * sizeof(GLchan));
+ newSource = malloc(comps * newWidth * newHeight * sizeof(GLchan));
if (!newSource) {
GET_CURRENT_CONTEXT(ctx);
_mesa_error(ctx, GL_OUT_OF_MEMORY, "texture compression");
if (CHAN_TYPE != GL_UNSIGNED_BYTE) {
const GLuint n = width * height * comps;
const GLchan *src = (const GLchan *) source;
- GLubyte *dest = (GLubyte *) _mesa_malloc(n * sizeof(GLubyte));
+ GLubyte *dest = (GLubyte *) malloc(n * sizeof(GLubyte));
GLuint i;
if (!dest) {
GET_CURRENT_CONTEXT(ctx);
dest[i] = CHAN_TO_UBYTE(src[i]);
}
if (newSource != NULL) {
- _mesa_free(newSource);
+ free(newSource);
}
newSource = dest; /* we'll free this buffer before returning */
source = dest; /* the new, GLubyte incoming image */
cleanUp:
if (newSource != NULL) {
- _mesa_free(newSource);
+ free(newSource);
}
}
decode_1[mode](code, t, rgba);
}
+
+
+#endif /* FEATURE_texture_fxt1 */