2021-03-02 02:13:17 +00:00
|
|
|
// Project64 - A Nintendo 64 emulator
|
2021-05-18 11:51:36 +00:00
|
|
|
// https://www.pj64-emu.com/
|
2021-03-02 02:13:17 +00:00
|
|
|
// Copyright(C) 2001-2021 Project64
|
|
|
|
// Copyright(C) 2007 Hiroshi Morii
|
|
|
|
// Copyright(C) 2004 Daniel Borca
|
|
|
|
// GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html
|
2013-04-17 10:30:38 +00:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
#include "internal.h"
|
|
|
|
#include "dxtn.h"
|
|
|
|
|
|
|
|
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
|
|
|
|
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
|
|
|
|
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
|
|
|
|
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
|
|
|
|
|
|
|
|
TAPI void TAPIENTRY
|
2017-04-26 10:23:36 +00:00
|
|
|
fetch_2d_texel_rgb_dxt1(int texImage_RowStride,
|
|
|
|
const byte *texImage_Data,
|
|
|
|
int i, int j,
|
|
|
|
byte *texel)
|
2013-04-17 10:30:38 +00:00
|
|
|
{
|
|
|
|
dxt1_rgb_decode_1(texImage_Data, texImage_RowStride, i, j, texel);
|
|
|
|
}
|
|
|
|
|
|
|
|
TAPI void TAPIENTRY
|
2017-04-26 10:23:36 +00:00
|
|
|
fetch_2d_texel_rgba_dxt1(int texImage_RowStride,
|
|
|
|
const byte *texImage_Data,
|
|
|
|
int i, int j,
|
|
|
|
byte *texel)
|
2013-04-17 10:30:38 +00:00
|
|
|
{
|
|
|
|
dxt1_rgba_decode_1(texImage_Data, texImage_RowStride, i, j, texel);
|
|
|
|
}
|
|
|
|
|
|
|
|
TAPI void TAPIENTRY
|
2017-04-26 10:23:36 +00:00
|
|
|
fetch_2d_texel_rgba_dxt3(int texImage_RowStride,
|
|
|
|
const byte *texImage_Data,
|
|
|
|
int i, int j,
|
|
|
|
byte *texel)
|
2013-04-17 10:30:38 +00:00
|
|
|
{
|
|
|
|
dxt3_rgba_decode_1(texImage_Data, texImage_RowStride, i, j, texel);
|
|
|
|
}
|
|
|
|
|
|
|
|
TAPI void TAPIENTRY
|
2017-04-26 10:23:36 +00:00
|
|
|
fetch_2d_texel_rgba_dxt5(int texImage_RowStride,
|
|
|
|
const byte *texImage_Data,
|
|
|
|
int i, int j,
|
|
|
|
byte *texel)
|
2013-04-17 10:30:38 +00:00
|
|
|
{
|
|
|
|
dxt5_rgba_decode_1(texImage_Data, texImage_RowStride, i, j, texel);
|
|
|
|
}
|
|
|
|
|
|
|
|
TAPI void TAPIENTRY
|
2017-04-26 10:23:36 +00:00
|
|
|
tx_compress_dxtn(int srccomps, int width, int height,
|
|
|
|
const byte *source, int destformat, byte *dest,
|
|
|
|
int destRowStride)
|
2013-04-17 10:30:38 +00:00
|
|
|
{
|
|
|
|
int srcRowStride = width * srccomps;
|
|
|
|
int rv;
|
|
|
|
|
|
|
|
switch (destformat) {
|
2017-04-26 10:23:36 +00:00
|
|
|
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
|
|
|
rv = dxt1_rgb_encode(width, height, srccomps,
|
|
|
|
source, srcRowStride,
|
|
|
|
dest, destRowStride);
|
|
|
|
break;
|
|
|
|
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
|
|
|
rv = dxt1_rgba_encode(width, height, srccomps,
|
|
|
|
source, srcRowStride,
|
|
|
|
dest, destRowStride);
|
|
|
|
break;
|
|
|
|
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
|
|
|
rv = dxt3_rgba_encode(width, height, srccomps,
|
|
|
|
source, srcRowStride,
|
|
|
|
dest, destRowStride);
|
|
|
|
break;
|
|
|
|
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
|
|
|
rv = dxt5_rgba_encode(width, height, srccomps,
|
|
|
|
source, srcRowStride,
|
|
|
|
dest, destRowStride);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0);
|
2013-04-17 10:30:38 +00:00
|
|
|
}
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
//return rv;
|
|
|
|
}
|