08 Jul 2007
This commit is contained in:
parent
7bd2d4d702
commit
9fc3c56bee
|
@ -1,4 +1,11 @@
|
|||
Текущие задачи
|
||||
|
||||
1. Имплементация DDS загрузчика
|
||||
{
|
||||
DXT1 - форматы DXT1a и DXT1c - настроить оба типа загрузчиков
|
||||
подключить загрузку мипмапов OK
|
||||
подключить загрузку мипмапов для софт-загрузчика
|
||||
|
||||
|
||||
|
||||
Xash Studio:
|
||||
|
||||
|
@ -31,20 +38,9 @@ launcher.dll
|
|||
5. подключить кастомный хандлер для ошибок
|
||||
|
||||
platform.dll
|
||||
1. пофиксить баг с неправильным именем лаунчера OK
|
||||
2. разобраться наконец с записью файлов
|
||||
3. создать FS_Gets OK
|
||||
4. FS_LoadImage, подключить палитру и bpp в структуре OK
|
||||
5. подключить палитру к Jpg и Png файлам
|
||||
6. написать MemMove, Memset, MemCopy
|
||||
1. разобраться наконец с записью файлов
|
||||
2. переписать LoadJPG чтобы он читал из буффера OK
|
||||
|
||||
spritegen - апгрейд до версии 0.2 ОК
|
||||
1. избавится от определения явных параметров OK
|
||||
2. заменить groupstart\groupend на фигурные скобки ОК
|
||||
3. убить группы и все что с ними связано OK
|
||||
4. создать пустое изображение ОК
|
||||
5. Переписать лоадер BMP ОК
|
||||
6. Сделать динамическое выделение памяти OK
|
||||
|
||||
studiomdl - апгрейд до версии 0.2
|
||||
1. тщательный тест всех возможностей OK
|
||||
|
@ -55,12 +51,6 @@ platform.dll
|
|||
1. сделать парсинг "ambient" из карты
|
||||
2. сделать новый contents для Null
|
||||
|
||||
qcclib
|
||||
1. Первичная "сырая" имплементация.
|
||||
2. Убить внутренние типы
|
||||
3. Убить qcc_cmdlib
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
// то, что уже готово
|
||||
|
|
|
@ -8,14 +8,6 @@
|
|||
#include "baseutils.h"
|
||||
#include "blankframe.h"
|
||||
|
||||
//=======================================================================
|
||||
// BYTE ORDER FUNCTIONS
|
||||
//=======================================================================
|
||||
dword BuffBigLong (const byte *buffer){ return (buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3];}
|
||||
word BuffBigShort (const byte *buffer){ return (buffer[0] << 8) | buffer[1]; }
|
||||
dword BuffLittleLong (const byte *buffer){ return (buffer[3] << 24) | (buffer[2] << 16) | (buffer[1] << 8) | buffer[0];}
|
||||
word BuffLittleShort (const byte *buffer){return (buffer[1] << 8) | buffer[0];}
|
||||
|
||||
char *strupr (char *start)
|
||||
{
|
||||
char *in;
|
||||
|
|
|
@ -89,12 +89,6 @@ void FS_Shutdown (void);
|
|||
#define Mem_Move(dest, src, size ) _Mem_Move (dest, src, size, __FILE__, __LINE__)
|
||||
#define Mem_Copy(dest, src, size ) _Mem_Copy (dest, src, size, __FILE__, __LINE__)
|
||||
|
||||
//only for internal use
|
||||
dword BuffBigLong (const byte *buffer);
|
||||
word BuffBigShort (const byte *buffer);
|
||||
dword BuffLittleLong (const byte *buffer);
|
||||
word BuffLittleShort (const byte *buffer);
|
||||
|
||||
stdio_api_t std;
|
||||
extern gameinfo_t GI;
|
||||
|
||||
|
|
|
@ -87,11 +87,56 @@ typedef struct
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
#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
|
||||
#define DDSHEADER ((' '<<24)+('S'<<16)+('D'<<8)+'D') // little-endian "DDS "
|
||||
|
||||
//other four-cc types
|
||||
#define TYPE_DXT1 (('1'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT1"
|
||||
#define TYPE_DXT2 (('2'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT2"
|
||||
#define TYPE_DXT3 (('3'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT3"
|
||||
#define TYPE_DXT4 (('4'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT4"
|
||||
#define TYPE_DXT5 (('5'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT5"
|
||||
|
||||
#define TYPE_ATI1 (('1'<<24)+('I'<<16)+('T'<<8)+'A') // little-endian "ATI1"
|
||||
#define TYPE_ATI2 (('2'<<24)+('I'<<16)+('T'<<8)+'A') // little-endian "ATI2"
|
||||
|
||||
|
||||
#define TYPE_RXGB (('B'<<24)+('G'<<16)+('X'<<8)+'R') // little-endian "RXGB" doom3 normalmaps
|
||||
#define TYPE_$ (('\0'<<24)+('\0'<<16)+('\0'<<8)+'$') // little-endian "$"
|
||||
#define TYPE_o (('\0'<<24)+('\0'<<16)+('\0'<<8)+'o') // little-endian "o"
|
||||
#define TYPE_p (('\0'<<24)+('\0'<<16)+('\0'<<8)+'p') // little-endian "p"
|
||||
#define TYPE_q (('\0'<<24)+('\0'<<16)+('\0'<<8)+'q') // little-endian "q"
|
||||
#define TYPE_r (('\0'<<24)+('\0'<<16)+('\0'<<8)+'r') // little-endian "r"
|
||||
#define TYPE_s (('\0'<<24)+('\0'<<16)+('\0'<<8)+'s') // little-endian "s"
|
||||
#define TYPE_t (('\0'<<24)+('\0'<<16)+('\0'<<8)+'t') // little-endian "t"
|
||||
|
||||
#define DDS_CAPS 0x00000001L
|
||||
#define DDS_HEIGHT 0x00000002L
|
||||
#define DDS_WIDTH 0x00000004L
|
||||
|
||||
#define DDS_RGB 0x00000040L
|
||||
#define DDS_PIXELFORMAT 0x00001000L
|
||||
#define DDS_LUMINANCE 0x00020000L
|
||||
|
||||
#define DDS_ALPHAPIXELS 0x00000001L
|
||||
#define DDS_ALPHA 0x00000002L
|
||||
#define DDS_FOURCC 0x00000004L
|
||||
#define DDS_PITCH 0x00000008L
|
||||
#define DDS_COMPLEX 0x00000008L
|
||||
#define DDS_TEXTURE 0x00001000L
|
||||
#define DDS_MIPMAPCOUNT 0x00020000L
|
||||
#define DDS_LINEARSIZE 0x00080000L
|
||||
#define DDS_VOLUME 0x00200000L
|
||||
#define DDS_MIPMAP 0x00400000L
|
||||
#define DDS_DEPTH 0x00800000L
|
||||
|
||||
//support cubemap loading
|
||||
#define DDS_CUBEMAP 0x00000200L
|
||||
#define DDS_CUBEMAP_POSITIVEX 0x00000400L
|
||||
#define DDS_CUBEMAP_NEGATIVEX 0x00000800L
|
||||
#define DDS_CUBEMAP_POSITIVEY 0x00001000L
|
||||
#define DDS_CUBEMAP_NEGATIVEY 0x00002000L
|
||||
#define DDS_CUBEMAP_POSITIVEZ 0x00004000L
|
||||
#define DDS_CUBEMAP_NEGATIVEZ 0x00008000L
|
||||
|
||||
typedef struct dds_pf_s
|
||||
{
|
||||
|
@ -103,104 +148,33 @@ typedef struct dds_pf_s
|
|||
uint dwGBitMask;
|
||||
uint dwBBitMask;
|
||||
uint dwAlphaBitMask;
|
||||
} dds_pf_t;
|
||||
} dds_pixf_t;
|
||||
|
||||
// DDCAPS2
|
||||
typedef struct dds_caps_s
|
||||
{
|
||||
uint dwCaps1;
|
||||
uint dwCaps2;
|
||||
uint dwDDSX;
|
||||
uint dwReserved;
|
||||
uint dwCaps3;
|
||||
uint dwCaps4;
|
||||
} dds_caps_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint dwMagic;
|
||||
uint dwIdent; // must matched with DDSHEADER
|
||||
uint dwSize;
|
||||
uint dwFlags;
|
||||
uint dwFlags; // determines what fields are valid
|
||||
uint dwHeight;
|
||||
uint dwWidth;
|
||||
uint dwPitchOrLinearSize;
|
||||
uint dwDepth;
|
||||
uint dwMipMapCount;
|
||||
uint dwReserved1[11];
|
||||
dds_pf_t ddpfPixelFormat;
|
||||
dds_caps_t ddsCaps;
|
||||
uint dwReserved2;
|
||||
uint dwLinearSize; // Formless late-allocated optimized surface size
|
||||
uint dwDepth; // depth if a volume texture
|
||||
uint dwMipMapCount; // number of mip-map levels requested
|
||||
uint dwAlphaBitDepth; // depth of alpha buffer requested
|
||||
uint dwReserved1[10]; // reserved for future expansions
|
||||
dds_pixf_t dsPixelFormat;
|
||||
dds_caps_t dsCaps;
|
||||
uint dwTextureStage;
|
||||
} dds_t;
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.PNG image format
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
#define PNG_LIBPNG_VER_STRING "1.2.4"
|
||||
|
||||
#define PNG_COLOR_MASK_PALETTE 1
|
||||
#define PNG_COLOR_MASK_COLOR 2
|
||||
#define PNG_COLOR_MASK_ALPHA 4
|
||||
#define PNG_COLOR_TYPE_GRAY 0
|
||||
#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
|
||||
#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
|
||||
#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
|
||||
#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
|
||||
|
||||
#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA
|
||||
#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA
|
||||
#define PNG_INFO_tRNS 0x0010
|
||||
|
||||
extern void png_set_sig_bytes (void*, int);
|
||||
extern int png_sig_cmp (const byte*, size_t, size_t);
|
||||
extern void* png_create_read_struct (const char*, void*, void*, void*);
|
||||
extern void* png_create_info_struct (void*);
|
||||
extern void png_read_info (void*, void*);
|
||||
extern void png_set_expand (void*);
|
||||
extern void png_set_gray_1_2_4_to_8 (void*);
|
||||
extern void png_set_palette_to_rgb (void*);
|
||||
extern void png_set_tRNS_to_alpha (void*);
|
||||
extern void png_set_gray_to_rgb (void*);
|
||||
extern void png_set_filler (void*, unsigned int, int);
|
||||
extern void png_read_update_info (void*, void*);
|
||||
extern void png_read_image (void*, unsigned char**);
|
||||
extern void png_read_end (void*, void*);
|
||||
extern void png_destroy_read_struct (void**, void**, void**);
|
||||
extern void png_set_read_fn (void*, void*, void*);
|
||||
extern dword png_get_valid (void*, void*, unsigned int);
|
||||
extern dword png_get_rowbytes (void*, void*);
|
||||
extern byte png_get_channels (void*, void*);
|
||||
extern byte png_get_bit_depth (void*, void*);
|
||||
extern dword png_get_IHDR (void*, void*, dword*, dword*, int *, int *, int *, int *, int *);
|
||||
extern char* png_get_libpng_ver (void*);
|
||||
extern void png_set_strip_16 (void*);
|
||||
|
||||
static struct
|
||||
{
|
||||
const byte *tmpBuf;
|
||||
int tmpBuflength;
|
||||
int tmpi;
|
||||
//int FBgColor;
|
||||
//int FTransparent;
|
||||
dword FRowBytes;
|
||||
//double FGamma;
|
||||
//double FScreenGamma;
|
||||
byte **FRowPtrs;
|
||||
byte *Data;
|
||||
//char *Title;
|
||||
//char *Author;
|
||||
//char *Description;
|
||||
int BitDepth;
|
||||
int BytesPerPixel;
|
||||
int ColorType;
|
||||
unsigned int Height;
|
||||
unsigned int Width;
|
||||
int Interlace;
|
||||
int Compression;
|
||||
int Filter;
|
||||
//double LastModified;
|
||||
//int Transparent;
|
||||
}png_buf;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
@ -209,285 +183,57 @@ static struct
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
#define JPEG_LIB_VERSION 62 // Version 6b
|
||||
|
||||
typedef void *j_common_ptr;
|
||||
typedef struct jpeg_compress_struct *j_compress_ptr;
|
||||
typedef struct jpeg_decompress_struct *j_decompress_ptr;
|
||||
typedef enum
|
||||
typedef struct huffman_table_s
|
||||
{
|
||||
JCS_UNKNOWN,
|
||||
JCS_GRAYSCALE,
|
||||
JCS_RGB,
|
||||
JCS_YCbCr,
|
||||
JCS_CMYK,
|
||||
JCS_YCCK
|
||||
}J_COLOR_SPACE;
|
||||
// Huffman coding tables
|
||||
byte bits[16];
|
||||
byte hval[256];
|
||||
byte size[256];
|
||||
word code[256];
|
||||
|
||||
typedef enum {JPEG_DUMMY1} J_DCT_METHOD;
|
||||
typedef enum {JPEG_DUMMY2} J_DITHER_MODE;
|
||||
typedef dword JDIMENSION;
|
||||
} huffman_table_t;
|
||||
|
||||
#define JPOOL_PERMANENT 0 // lasts until master record is destroyed
|
||||
#define JPOOL_IMAGE 1 // lasts until done with image/datastream
|
||||
|
||||
#define JPEG_EOI 0xD9 // EOI marker code
|
||||
#define JMSG_STR_PARM_MAX 80
|
||||
#define DCTSIZE2 64
|
||||
#define NUM_QUANT_TBLS 4
|
||||
#define NUM_HUFF_TBLS 4
|
||||
#define NUM_ARITH_TBLS 16
|
||||
#define MAX_COMPS_IN_SCAN 4
|
||||
#define C_MAX_BLOCKS_IN_MCU 10
|
||||
#define D_MAX_BLOCKS_IN_MCU 10
|
||||
|
||||
struct jpeg_memory_mgr
|
||||
typedef struct jpg_s
|
||||
{
|
||||
void* (*alloc_small) (j_common_ptr cinfo, int pool_id, size_t sizeofobject);
|
||||
void (*alloc_large) ();
|
||||
void (*alloc_sarray) ();
|
||||
void (*alloc_barray) ();
|
||||
void (*request_virt_sarray) ();
|
||||
void (*request_virt_barray) ();
|
||||
void (*realize_virt_arrays) ();
|
||||
void (*access_virt_sarray) ();
|
||||
void (*access_virt_barray) ();
|
||||
void (*free_pool) ();
|
||||
void (*self_destruct) ();
|
||||
long max_memory_to_use;
|
||||
long max_alloc_chunk;
|
||||
};
|
||||
// Jpeg file parameter
|
||||
file_t *file; // file
|
||||
byte *buffer; // jpg buffer
|
||||
|
||||
int width; // width image
|
||||
int height; // height image
|
||||
byte *data; // image
|
||||
int data_precision; // bit per component
|
||||
int num_components; // number component
|
||||
int restart_interval; // restart interval
|
||||
bool progressive_mode; // progressive format
|
||||
|
||||
struct jpeg_error_mgr
|
||||
{
|
||||
void (*error_exit) (j_common_ptr cinfo);
|
||||
void (*emit_message) (j_common_ptr cinfo, int msg_level);
|
||||
void (*output_message) (j_common_ptr cinfo);
|
||||
void (*format_message) (j_common_ptr cinfo, char * buffer);
|
||||
void (*reset_error_mgr) (j_common_ptr cinfo);
|
||||
int msg_code;
|
||||
union
|
||||
struct
|
||||
{
|
||||
int i[8];
|
||||
char s[JMSG_STR_PARM_MAX];
|
||||
}msg_parm;
|
||||
int id; // identifier
|
||||
int h; // horizontal sampling factor
|
||||
int v; // vertical sampling factor
|
||||
int t; // Quantization table selector
|
||||
int td; // DC table selector
|
||||
int ta; // AC table selector
|
||||
} component_info[3];
|
||||
|
||||
huffman_table_t hac[4]; // AC table
|
||||
huffman_table_t hdc[4]; // DC table
|
||||
|
||||
int trace_level;
|
||||
long num_warnings;
|
||||
const char * const * jpeg_message_table;
|
||||
int last_jpeg_message;
|
||||
const char * const * addon_message_table;
|
||||
int first_addon_message;
|
||||
int last_addon_message;
|
||||
};
|
||||
int qtable[4][64]; // Quantization table
|
||||
|
||||
struct jpeg_source_mgr
|
||||
{
|
||||
const unsigned char *next_input_byte;
|
||||
size_t bytes_in_buffer;
|
||||
struct
|
||||
{
|
||||
int ss,se; // progressive jpeg spectral selection
|
||||
int ah,al; // progressive jpeg successive approx
|
||||
} scan;
|
||||
|
||||
void (*init_source) (j_decompress_ptr cinfo);
|
||||
jboolean (*fill_input_buffer) (j_decompress_ptr cinfo);
|
||||
void (*skip_input_data) (j_decompress_ptr cinfo, long num_bytes);
|
||||
jboolean (*resync_to_restart) (j_decompress_ptr cinfo, int desired);
|
||||
void (*term_source) (j_decompress_ptr cinfo);
|
||||
};
|
||||
int dc[3];
|
||||
int curbit;
|
||||
byte curbyte;
|
||||
|
||||
struct jpeg_decompress_struct
|
||||
{
|
||||
struct jpeg_error_mgr *err; // USED
|
||||
struct jpeg_memory_mgr *mem; // USED
|
||||
} jpg_t;
|
||||
|
||||
void *progress;
|
||||
void *client_data;
|
||||
jboolean is_decompressor;
|
||||
int global_state;
|
||||
|
||||
struct jpeg_source_mgr *src; // USED
|
||||
JDIMENSION image_width; // USED
|
||||
JDIMENSION image_height; // USED
|
||||
|
||||
int num_components;
|
||||
J_COLOR_SPACE jpeg_color_space;
|
||||
J_COLOR_SPACE out_color_space;
|
||||
dword scale_num, scale_denom;
|
||||
double output_gamma;
|
||||
jboolean buffered_image;
|
||||
jboolean raw_data_out;
|
||||
J_DCT_METHOD dct_method;
|
||||
jboolean do_fancy_upsampling;
|
||||
jboolean do_block_smoothing;
|
||||
jboolean quantize_colors;
|
||||
J_DITHER_MODE dither_mode;
|
||||
jboolean two_pass_quantize;
|
||||
int desired_number_of_colors;
|
||||
jboolean enable_1pass_quant;
|
||||
jboolean enable_external_quant;
|
||||
jboolean enable_2pass_quant;
|
||||
JDIMENSION output_width;
|
||||
JDIMENSION output_height; // USED
|
||||
|
||||
int out_color_components;
|
||||
int output_components; // USED
|
||||
int rec_outbuf_height;
|
||||
int actual_number_of_colors;
|
||||
void *colormap;
|
||||
JDIMENSION output_scanline; // USED
|
||||
|
||||
int input_scan_number;
|
||||
JDIMENSION input_iMCU_row;
|
||||
int output_scan_number;
|
||||
JDIMENSION output_iMCU_row;
|
||||
int (*coef_bits)[DCTSIZE2];
|
||||
void *quant_tbl_ptrs[NUM_QUANT_TBLS];
|
||||
void *dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
|
||||
void *ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
|
||||
int data_precision;
|
||||
void *comp_info;
|
||||
jboolean progressive_mode;
|
||||
jboolean arith_code;
|
||||
byte arith_dc_L[NUM_ARITH_TBLS];
|
||||
byte arith_dc_U[NUM_ARITH_TBLS];
|
||||
byte arith_ac_K[NUM_ARITH_TBLS];
|
||||
dword restart_interval;
|
||||
jboolean saw_JFIF_marker;
|
||||
byte JFIF_major_version;
|
||||
byte JFIF_minor_version;
|
||||
byte density_unit;
|
||||
word X_density;
|
||||
word Y_density;
|
||||
jboolean saw_Adobe_marker;
|
||||
byte Adobe_transform;
|
||||
jboolean CCIR601_sampling;
|
||||
void *marker_list;
|
||||
int max_h_samp_factor;
|
||||
int max_v_samp_factor;
|
||||
int min_DCT_scaled_size;
|
||||
JDIMENSION total_iMCU_rows;
|
||||
void *sample_range_limit;
|
||||
int comps_in_scan;
|
||||
void *cur_comp_info[MAX_COMPS_IN_SCAN];
|
||||
JDIMENSION MCUs_per_row;
|
||||
JDIMENSION MCU_rows_in_scan;
|
||||
int blocks_in_MCU;
|
||||
int MCU_membership[D_MAX_BLOCKS_IN_MCU];
|
||||
int Ss, Se, Ah, Al;
|
||||
int unread_marker;
|
||||
void *master;
|
||||
void *main;
|
||||
void *coef;
|
||||
void *post;
|
||||
void *inputctl;
|
||||
void *marker;
|
||||
void *entropy;
|
||||
void *idct;
|
||||
void *upsample;
|
||||
void *cconvert;
|
||||
void *cquantize;
|
||||
};
|
||||
|
||||
|
||||
struct jpeg_compress_struct
|
||||
{
|
||||
struct jpeg_error_mgr *err;
|
||||
struct jpeg_memory_mgr *mem;
|
||||
void *progress;
|
||||
void *client_data;
|
||||
jboolean is_decompressor;
|
||||
int global_state;
|
||||
|
||||
void *dest;
|
||||
JDIMENSION image_width;
|
||||
JDIMENSION image_height;
|
||||
int input_components;
|
||||
J_COLOR_SPACE in_color_space;
|
||||
double input_gamma;
|
||||
int data_precision;
|
||||
|
||||
int num_components;
|
||||
J_COLOR_SPACE jpeg_color_space;
|
||||
void *comp_info;
|
||||
void *quant_tbl_ptrs[NUM_QUANT_TBLS];
|
||||
void *dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
|
||||
void *ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
|
||||
byte arith_dc_L[NUM_ARITH_TBLS];
|
||||
byte arith_dc_U[NUM_ARITH_TBLS];
|
||||
byte arith_ac_K[NUM_ARITH_TBLS];
|
||||
|
||||
int num_scans;
|
||||
const void *scan_info;
|
||||
jboolean raw_data_in;
|
||||
jboolean arith_code;
|
||||
jboolean optimize_coding;
|
||||
jboolean CCIR601_sampling;
|
||||
int smoothing_factor;
|
||||
J_DCT_METHOD dct_method;
|
||||
|
||||
dword restart_interval;
|
||||
int restart_in_rows;
|
||||
|
||||
jboolean write_JFIF_header;
|
||||
byte JFIF_major_version;
|
||||
byte JFIF_minor_version;
|
||||
byte density_unit;
|
||||
word X_density;
|
||||
word Y_density;
|
||||
jboolean write_Adobe_marker;
|
||||
JDIMENSION next_scanline;
|
||||
|
||||
jboolean progressive_mode;
|
||||
int max_h_samp_factor;
|
||||
int max_v_samp_factor;
|
||||
JDIMENSION total_iMCU_rows;
|
||||
int comps_in_scan;
|
||||
void *cur_comp_info[MAX_COMPS_IN_SCAN];
|
||||
JDIMENSION MCUs_per_row;
|
||||
JDIMENSION MCU_rows_in_scan;
|
||||
int blocks_in_MCU;
|
||||
int MCU_membership[C_MAX_BLOCKS_IN_MCU];
|
||||
int Ss, Se, Ah, Al;
|
||||
|
||||
void *master;
|
||||
void *main;
|
||||
void *prep;
|
||||
void *coef;
|
||||
void *marker;
|
||||
void *cconvert;
|
||||
void *downsample;
|
||||
void *fdct;
|
||||
void *entropy;
|
||||
void *script_space;
|
||||
int script_space_size;
|
||||
};
|
||||
|
||||
struct jpeg_destination_mgr
|
||||
{
|
||||
byte* next_output_byte;
|
||||
size_t free_in_buffer;
|
||||
|
||||
void (*init_destination) (j_compress_ptr cinfo);
|
||||
jboolean (*empty_output_buffer) (j_compress_ptr cinfo);
|
||||
void (*term_destination) (j_compress_ptr cinfo);
|
||||
};
|
||||
|
||||
|
||||
#define jpeg_create_compress(cinfo) jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, (size_t) sizeof(struct jpeg_compress_struct))
|
||||
#define jpeg_create_decompress(cinfo) jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, (size_t) sizeof(struct jpeg_decompress_struct))
|
||||
|
||||
extern void jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize);
|
||||
extern void jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize);
|
||||
extern void jpeg_destroy_compress (j_compress_ptr cinfo);
|
||||
extern void jpeg_destroy_decompress (j_decompress_ptr cinfo);
|
||||
extern void jpeg_finish_compress (j_compress_ptr cinfo);
|
||||
extern jboolean jpeg_finish_decompress (j_decompress_ptr cinfo);
|
||||
extern jboolean jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired);
|
||||
extern int jpeg_read_header (j_decompress_ptr cinfo, jboolean require_image);
|
||||
extern JDIMENSION jpeg_read_scanlines (j_decompress_ptr cinfo, unsigned char** scanlines, JDIMENSION max_lines);
|
||||
extern void jpeg_set_defaults (j_compress_ptr cinfo);
|
||||
extern void jpeg_set_quality (j_compress_ptr cinfo, int quality, jboolean force_baseline);
|
||||
extern jboolean jpeg_start_compress (j_compress_ptr cinfo, jboolean write_all_tables);
|
||||
extern jboolean jpeg_start_decompress (j_decompress_ptr cinfo);
|
||||
extern struct jpeg_error_mgr* jpeg_std_error (struct jpeg_error_mgr *err);
|
||||
extern JDIMENSION jpeg_write_scanlines (j_compress_ptr cinfo, unsigned char** scanlines, JDIMENSION num_lines);
|
||||
static jpg_t jpg_file;
|
||||
|
||||
#endif//IMAGE_H
|
Binary file not shown.
Binary file not shown.
1253
platform/imglib.c
1253
platform/imglib.c
File diff suppressed because it is too large
Load Diff
|
@ -1,18 +0,0 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// image.h - tga, pcx image headers
|
||||
//=======================================================================
|
||||
|
||||
#ifndef IMGLIB_H
|
||||
#define IMGLIB_H
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
bool LoadBMP( char *name, char *buffer, int filesize );
|
||||
bool LoadPCX( char *name, char *buffer, int filesize );
|
||||
bool LoadTGA( char *name, char *buffer, int filesize );
|
||||
bool LoadDDS( char *name, char *buffer, int filesize );
|
||||
bool LoadPNG( char *name, char *buffer, int filesize );
|
||||
bool LoadJPG( char *name, char *buffer, int filesize );
|
||||
|
||||
#endif//IMGLIB_H
|
|
@ -249,10 +249,6 @@ SOURCE=.\image.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\imglib.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mdllib.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -36,19 +36,14 @@ typedef struct file_s file_t;
|
|||
typedef struct edict_s edict_t;
|
||||
typedef struct gclient_s gclient_t;
|
||||
typedef float vec_t;
|
||||
typedef byte jboolean;
|
||||
typedef vec_t vec3_t[3];
|
||||
typedef vec_t vec4_t[4];
|
||||
typedef long fs_offset_t;
|
||||
typedef vec_t matrix3x4[3][4];
|
||||
typedef struct { int fileofs; int filelen; }lump_t;
|
||||
|
||||
|
||||
#define BigShort(l) ShortSwap(l)
|
||||
#define BigLong(l) LongSwap(l)
|
||||
#define LittleShort(l) (l)
|
||||
#define LittleLong(l) (l)
|
||||
#define LittleFloat(l) (l)
|
||||
typedef struct { byte r; byte g; byte b; } color24;
|
||||
typedef struct { uint b:5; uint g:6; uint r:5; } color16;
|
||||
typedef struct { byte r; byte g; byte b; byte a; } color32;
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
|
@ -59,12 +54,7 @@ typedef struct { int fileofs; int filelen; }lump_t;
|
|||
#define O_NONBLOCK 0
|
||||
#endif
|
||||
|
||||
_inline short ShortSwap (short l) { byte b1,b2; b1 = l&255; b2 = (l>>8)&255; return (b1<<8) + b2; }
|
||||
_inline int LongSwap (int l)
|
||||
{
|
||||
byte b1,b2,b3,b4; b1 = l&255; b2 = (l>>8)&255; b3 = (l>>16)&255; b4 = (l>>24)&255;
|
||||
return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;
|
||||
}
|
||||
#include "byteorder.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#define strcasecmp stricmp
|
||||
|
|
|
@ -0,0 +1,153 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// byteorder.h - byte order functions
|
||||
//=======================================================================
|
||||
#ifndef BYTEORDER_H
|
||||
#define BYTEORDER_H
|
||||
|
||||
#include "basetypes.h"
|
||||
|
||||
//byte order swap functions
|
||||
_inline word WordSwap( word swap )
|
||||
{
|
||||
word *s = &swap;
|
||||
|
||||
__asm {
|
||||
mov ebx, s
|
||||
mov al, [ebx+1]
|
||||
mov ah, [ebx ]
|
||||
mov [ebx], ax
|
||||
}
|
||||
return *s;
|
||||
}
|
||||
|
||||
#define ShortSwap(x) WordSwap((short)x)
|
||||
|
||||
_inline uint UintSwap( uint swap )
|
||||
{
|
||||
uint *i = &swap;
|
||||
|
||||
__asm {
|
||||
mov ebx, i
|
||||
mov eax, [ebx]
|
||||
bswap eax
|
||||
mov [ebx], eax
|
||||
}
|
||||
return *i;
|
||||
}
|
||||
|
||||
#define LongSwap(x) UintSwap((uint)x)
|
||||
|
||||
#define FloatSwap(x) UintSwap((uint)x)
|
||||
|
||||
_inline double DoubleSwap( double swap )
|
||||
{
|
||||
#define dswap(x, y) t=b[x];b[x]=b[y];b[y]=b[x];
|
||||
|
||||
byte t, *b = ((byte *)&swap);
|
||||
dswap(0,7);
|
||||
dswap(1,6);
|
||||
dswap(2,5);
|
||||
dswap(3,4);
|
||||
|
||||
return swap;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
// Endianess handling
|
||||
//============================================================================
|
||||
// We use BSD-style defines: BYTE_ORDER is defined to either BIG_ENDIAN or LITTLE_ENDIAN
|
||||
|
||||
// Initializations
|
||||
#if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
|
||||
#undef BYTE_ORDER
|
||||
#undef LITTLE_ENDIAN
|
||||
#undef BIG_ENDIAN
|
||||
#define LITTLE_ENDIAN 1234
|
||||
#define BIG_ENDIAN 4321
|
||||
#endif
|
||||
|
||||
// If we still don't know the CPU endianess at this point, we try to guess
|
||||
#ifndef BYTE_ORDER
|
||||
#if defined(WIN32)
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#else
|
||||
#if defined(SUNOS)
|
||||
#if defined(__i386) || defined(__amd64)
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#else
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#endif
|
||||
#else
|
||||
#warning "Unable to determine the CPU endianess. Defaulting to little endian"
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
// little endian
|
||||
#define BigShort(l) ShortSwap(l)
|
||||
#define LittleShort(l) (l)
|
||||
#define BigLong(l) LongSwap(l)
|
||||
#define LittleLong(l) (l)
|
||||
#define BigFloat(l) FloatSwap(l)
|
||||
#define LittleFloat(l) (l)
|
||||
#define BigDouble(l) DoubleSwap(l)
|
||||
#define LittleDouble(l) (l)
|
||||
#else
|
||||
// big endian
|
||||
#define BigShort(l) (l)
|
||||
#define LittleShort(l) ShortSwap(l)
|
||||
#define BigLong(l) (l)
|
||||
#define LittleLong(l) LongSwap(l)
|
||||
#define BigFloat(l) (l)
|
||||
#define LittleFloat(l) FloatSwap(l)
|
||||
#define BigDouble(l) (l)
|
||||
#define LittleDouble(l) DoubleSwap(l)
|
||||
#endif
|
||||
|
||||
//extract from buffer
|
||||
_inline dword BuffBigLong (const byte *buffer)
|
||||
{
|
||||
return (buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3];
|
||||
}
|
||||
|
||||
_inline word BuffBigShort (const byte *buffer)
|
||||
{
|
||||
return (buffer[0] << 8) | buffer[1];
|
||||
}
|
||||
|
||||
_inline float BuffBigFloat (const byte *buffer)
|
||||
{
|
||||
return BuffBigLong( buffer );//same as integer
|
||||
}
|
||||
|
||||
_inline double BuffBigDouble (const byte *buffer)
|
||||
{
|
||||
return (buffer[0] << 64) | (buffer[1] << 56) | (buffer[2] << 40) | (buffer[3] << 32)
|
||||
| (buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7];
|
||||
}
|
||||
|
||||
_inline dword BuffLittleLong (const byte *buffer)
|
||||
{
|
||||
return (buffer[3] << 24) | (buffer[2] << 16) | (buffer[1] << 8) | buffer[0];
|
||||
}
|
||||
|
||||
_inline word BuffLittleShort (const byte *buffer)
|
||||
{
|
||||
return (buffer[1] << 8) | buffer[0];
|
||||
}
|
||||
|
||||
_inline float BuffLittleFloat (const byte *buffer)
|
||||
{
|
||||
return BuffLittleLong( buffer );
|
||||
}
|
||||
|
||||
_inline double BuffLittleDouble (const byte *buffer)
|
||||
{
|
||||
return (buffer[7] << 64) | (buffer[6] << 56) | (buffer[5] << 40) | (buffer[4] << 32)
|
||||
| (buffer[3] << 24) | (buffer[2] << 16) | (buffer[1] << 8) | buffer[0];
|
||||
}
|
||||
|
||||
#endif//BYTEORDER_H
|
|
@ -11,6 +11,82 @@
|
|||
#define BSP_ONLYRAD 0x04
|
||||
#define BSP_FULLCOMPILE 0x08
|
||||
|
||||
enum comp_format
|
||||
{
|
||||
PF_UNKNOWN = 0,
|
||||
PF_INDEXED_8, // pcx or wal images with transparent color in palette
|
||||
PF_INDEXED_24, // studio model skins
|
||||
PF_INDEXED_32, // sprite 32-bit palette
|
||||
PF_RGBA_32, // already prepared ".bmp", ".tga" or ".jpg" image
|
||||
PF_ARGB_32, // uncompressed dds image
|
||||
PF_RGB_24, // uncompressed dds or another 24-bit image
|
||||
PF_DXT1, // nvidia DXT5 format
|
||||
PF_DXT2, // nvidia DXT5 format
|
||||
PF_DXT3, // nvidia DXT5 format
|
||||
PF_DXT4, // nvidia DXT5 format
|
||||
PF_DXT5, // nvidia DXT5 format
|
||||
PF_3DC,
|
||||
PF_ATI1N, // ati 1D texture
|
||||
PF_LUMINANCE, // b&w dds image
|
||||
PF_LUMINANCE_16, // b&w hi-res image
|
||||
PF_LUMINANCE_ALPHA, // b&w dds image with alpha channel
|
||||
PF_RXGB, // doom3 normal maps
|
||||
PF_ABGR_64,
|
||||
PF_R_16F,
|
||||
PF_GR_32F,
|
||||
PF_ABGR_64F,
|
||||
PF_R_32F,
|
||||
PF_GR_64F,
|
||||
PF_ABGR_128F, // super-texture
|
||||
PF_PROCEDURE_TEX, // internal special texture
|
||||
PF_TOTALCOUNT, // must be last
|
||||
};
|
||||
|
||||
//format info table
|
||||
typedef struct
|
||||
{
|
||||
int format; // pixelformat
|
||||
char name[8]; // used for debug
|
||||
int bpp; // channels (e.g. rgb = 3, rgba = 4)
|
||||
int bpc; // sizebytes (byte, short, float)
|
||||
int block; // blocksize > 0 needs alternate calc
|
||||
} bpc_desc_t;
|
||||
|
||||
static bpc_desc_t PixelFormatDescription[] =
|
||||
{
|
||||
{PF_INDEXED_8, "pal 8", 4, 1, 0 },
|
||||
{PF_INDEXED_24, "pal 24", 3, 1, -3 },
|
||||
{PF_INDEXED_32, "pal 32", 4, 1, -4 },
|
||||
{PF_RGBA_32, "RGBA", 4, 1, -4 },
|
||||
{PF_ARGB_32, "ARGB", 4, 1, -4 },
|
||||
{PF_RGB_24, "RGB", 3, 1, -3 },
|
||||
{PF_DXT1, "DXT1", 4, 1, 8 },
|
||||
{PF_DXT2, "DXT2", 4, 1, 16 },
|
||||
{PF_DXT3, "DXT3", 4, 1, 16 },
|
||||
{PF_DXT4, "DXT4", 4, 1, 16 },
|
||||
{PF_DXT5, "DXT5", 4, 1, 16 },
|
||||
{PF_3DC, "3DC", 3, 1, 16 },
|
||||
{PF_ATI1N, "ATI1N", 1, 1, 8 },
|
||||
{PF_LUMINANCE, "LUM 8", 1, 1, -1 },
|
||||
{PF_LUMINANCE_16, "LUM 16", 2, 2, -2 },
|
||||
{PF_LUMINANCE_ALPHA,"LUM A", 2, 1, -2 },
|
||||
{PF_RXGB, "RXGB", 3, 1, 16 },
|
||||
{PF_ABGR_64, "ABGR", 4, 2, -8 },
|
||||
{PF_R_16F, "R_16", 1, 4, -2 },
|
||||
{PF_GR_32F, "GR_32", 2, 4, -4 },
|
||||
{PF_ABGR_64F, "ABGR64", 4, 2, -8 },
|
||||
{PF_R_32F, "R_32", 1, 4, -4 },
|
||||
{PF_GR_64F, "GR_64", 2, 4, -8 },
|
||||
{PF_ABGR_128F, "ABGR128",4, 4, -16},
|
||||
{PF_PROCEDURE_TEX, "system", 4, 1, -32},
|
||||
{PF_UNKNOWN, "", 0, 0, 0 },
|
||||
};
|
||||
|
||||
#define IMAGE_CUBEMAP 0x00000001
|
||||
#define IMAGE_HAS_ALPHA 0x00000002
|
||||
#define IMAGE_PREMULT 0x00000004 // indices who need in additional premultiply
|
||||
#define IMAGE_GEN_MIPS 0x00000008 // must generate mips
|
||||
|
||||
typedef struct search_s
|
||||
{
|
||||
int numfilenames;
|
||||
|
@ -22,9 +98,10 @@ typedef struct rgbdata_s
|
|||
{
|
||||
word width; // image width
|
||||
word height; // image height
|
||||
byte bitsperpixel; // 8-16-24-32 bits
|
||||
word alpha; // has alpha pixels
|
||||
uint compression; // DXT compression
|
||||
byte numLayers; // multi-layer volume
|
||||
byte numMips; // mipmap count
|
||||
uint type; // compression type
|
||||
uint flags; // misc image flags
|
||||
byte *palette; // palette if present
|
||||
byte *buffer; // image buffer
|
||||
} rgbdata_t;
|
||||
|
|
|
@ -324,6 +324,7 @@ void GL_MBind( GLenum target, int texnum );
|
|||
void GL_TexEnv( GLenum value );
|
||||
void GL_EnableMultitexture( bool enable );
|
||||
void GL_SelectTexture( GLenum );
|
||||
void GL_TexFilter( GLboolean mipmap );
|
||||
|
||||
void R_LightPoint (vec3_t p, vec3_t color);
|
||||
void R_PushDlights (void);
|
||||
|
@ -450,6 +451,7 @@ typedef struct
|
|||
|
||||
bool allow_cds;
|
||||
bool sgis_generate_mipmap;
|
||||
bool arb_compressed_teximage;
|
||||
} glconfig_t;
|
||||
|
||||
typedef struct
|
||||
|
@ -564,4 +566,9 @@ void AngleQuaternion( float *angles, vec4_t quaternion );
|
|||
void QuaternionMatrix( vec4_t quaternion, float (*matrix)[4] );
|
||||
void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt );
|
||||
void AngleMatrix (const float *angles, float (*matrix)[4] );
|
||||
void MatrixCopy( matrix3x4 in, matrix3x4 out );
|
||||
void MatrixCopy( matrix3x4 in, matrix3x4 out );
|
||||
|
||||
uint ShortToFloat( word y );
|
||||
void R_DXTReadColor(word data, color32* out);
|
||||
void R_DXTReadColors(const byte* data, color32* out);
|
||||
void R_GetBitsFromMask(uint Mask, uint *ShiftLeft, uint *ShiftRight);
|
|
@ -1146,14 +1146,15 @@ int R_Init( void *hinstance, void *hWnd )
|
|||
|
||||
if (strstr( gl_config.extensions_string, "GL_ARB_texture_compression" ))
|
||||
{
|
||||
qglCompressedTexImage2DARB = ( void *) qwglGetProcAddress("glCompressedTexImage2DARB");
|
||||
qglGetCompressedTexImageARB = ( void *) qwglGetProcAddress("glGetCompressedTexImageARB");
|
||||
|
||||
if (!qglCompressedTexImage2DARB || !qglGetCompressedTexImageARB)
|
||||
if (strstr( gl_config.extensions_string, "GL_EXT_texture_compression_s3tc" ))
|
||||
{
|
||||
qglCompressedTexImage2DARB = NULL;
|
||||
qglGetCompressedTexImageARB = NULL;
|
||||
qglCompressedTexImage2D = ( void *)qwglGetProcAddress("glCompressedTexImage2DARB");
|
||||
qglGetCompressedTexImage = ( void *)qwglGetProcAddress("glGetCompressedTexImageARB");
|
||||
}
|
||||
|
||||
if (qglCompressedTexImage2D && qglGetCompressedTexImage)
|
||||
gl_config.arb_compressed_teximage = true;
|
||||
else gl_config.arb_compressed_teximage = false;
|
||||
}
|
||||
|
||||
if ( strstr( gl_config.extensions_string, "GL_EXT_point_parameters" ) )
|
||||
|
|
|
@ -60,9 +60,9 @@ void R_InitParticleTexture (void)
|
|||
}
|
||||
r_tex.width = 8;
|
||||
r_tex.height = 8;
|
||||
r_tex.bitsperpixel = 32;
|
||||
r_tex.compression = 0;
|
||||
r_tex.alpha = true;
|
||||
r_tex.type = PF_PROCEDURE_TEX;
|
||||
r_tex.flags |= IMAGE_HAS_ALPHA;
|
||||
r_tex.numMips = 4;
|
||||
r_tex.palette = NULL;
|
||||
r_tex.buffer = (byte *)data;
|
||||
|
||||
|
@ -81,7 +81,7 @@ void R_InitParticleTexture (void)
|
|||
data[y][x][3] = 255;
|
||||
}
|
||||
}
|
||||
r_tex.alpha = false;//notexture don't have alpha
|
||||
r_tex.flags &= ~IMAGE_HAS_ALPHA;//notexture don't have alpha
|
||||
r_notexture = R_LoadImage("***r_notexture***", &r_tex, it_wall );
|
||||
|
||||
R_Bloom_InitTextures();
|
||||
|
|
|
@ -399,8 +399,8 @@ void ( APIENTRY * qglViewport )(GLint x, GLint y, GLsizei width, GLsizei height)
|
|||
void ( APIENTRY * qglLockArraysEXT)( int, int);
|
||||
void ( APIENTRY * qglUnlockArraysEXT) ( void );
|
||||
|
||||
void (APIENTRY *qglCompressedTexImage2DARB)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
|
||||
void ( APIENTRY *qglGetCompressedTexImageARB) (GLenum target, GLint lod, const GLvoid* img);
|
||||
void (APIENTRY *qglCompressedTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
|
||||
void ( APIENTRY *qglGetCompressedTexImage) (GLenum target, GLint lod, const GLvoid* img);
|
||||
|
||||
BOOL ( WINAPI * qwglSwapIntervalEXT)( int interval );
|
||||
BOOL ( WINAPI * qwglGetDeviceGammaRampEXT)( unsigned char *, unsigned char *, unsigned char * );
|
||||
|
|
|
@ -331,6 +331,25 @@ void GL_TexEnv( GLenum mode )
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
GL_TexFilter
|
||||
===============
|
||||
*/
|
||||
void GL_TexFilter( GLboolean mipmap )
|
||||
{
|
||||
if (mipmap)
|
||||
{
|
||||
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
|
||||
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
|
||||
}
|
||||
else
|
||||
{
|
||||
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max);
|
||||
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
GL_Bind
|
||||
|
|
|
@ -106,9 +106,9 @@ void R_Bloom_InitBackUpTexture( int width, int height )
|
|||
memset( data, 0, width * height * 4 );
|
||||
r_bloom.width = width;
|
||||
r_bloom.height = height;
|
||||
r_bloom.bitsperpixel = 3;
|
||||
r_bloom.compression = 0;
|
||||
r_bloom.alpha = false;
|
||||
r_bloom.type = PF_PROCEDURE_TEX;
|
||||
r_bloom.flags = 0;
|
||||
r_bloom.numMips = 4;
|
||||
r_bloom.palette = NULL;
|
||||
r_bloom.buffer = data;
|
||||
|
||||
|
@ -155,9 +155,9 @@ void R_Bloom_InitEffectTexture( void )
|
|||
|
||||
r_bloomfx.width = BLOOM_SIZE;
|
||||
r_bloomfx.height = BLOOM_SIZE;
|
||||
r_bloomfx.bitsperpixel = 3;
|
||||
r_bloomfx.compression = 0;
|
||||
r_bloomfx.alpha = false;
|
||||
r_bloomfx.type = PF_PROCEDURE_TEX;
|
||||
r_bloomfx.flags = 0;
|
||||
r_bloomfx.numMips = 4;
|
||||
r_bloomfx.palette = NULL;
|
||||
r_bloomfx.buffer = data;
|
||||
r_bloomeffecttexture = R_LoadImage( "***r_bloomeffecttexture***", &r_bloomfx, it_pic );
|
||||
|
@ -195,11 +195,11 @@ void R_Bloom_InitTextures( void )
|
|||
memset( data, 255, size );
|
||||
r_bloomscr.width = screen_texture_width;
|
||||
r_bloomscr.height = screen_texture_height;
|
||||
r_bloomscr.bitsperpixel = 3;
|
||||
r_bloomscr.compression = 0;
|
||||
r_bloomscr.alpha = 0;
|
||||
r_bloomscr.type = 0;
|
||||
r_bloomscr.flags = 0;
|
||||
r_bloomscr.palette = NULL;
|
||||
r_bloomscr.buffer = (byte *)data;
|
||||
r_bloomscr.numMips = 4;
|
||||
r_bloomscreentexture = R_LoadImage( "***r_bloomscreentexture***", &r_bloomscr, it_pic );
|
||||
free ( data );
|
||||
|
||||
|
@ -216,11 +216,11 @@ void R_Bloom_InitTextures( void )
|
|||
memset( data, 0, r_screendownsamplingtexture_size * r_screendownsamplingtexture_size * 4 );
|
||||
r_downsample.width = r_screendownsamplingtexture_size;
|
||||
r_downsample.height = r_screendownsamplingtexture_size;
|
||||
r_downsample.bitsperpixel = 3;
|
||||
r_downsample.compression = 0;
|
||||
r_downsample.alpha = false;
|
||||
r_downsample.type = PF_PROCEDURE_TEX;
|
||||
r_downsample.flags = 0;
|
||||
r_downsample.palette = NULL;
|
||||
r_downsample.buffer = (byte *)data;
|
||||
r_downsample.numMips = 4;
|
||||
r_bloomdownsamplingtexture = R_LoadImage( "***r_bloomdownsampetexture***", &r_downsample, it_pic );
|
||||
free ( data );
|
||||
}
|
||||
|
|
|
@ -447,20 +447,25 @@ extern BOOL ( WINAPI * qwglSetDeviceGammaRampEXT ) ( const unsigned char *pRed,
|
|||
#ifndef GL_ARB_texture_compression
|
||||
#define GL_ARB_texture_compression 1
|
||||
|
||||
#define GL_COMPRESSED_ALPHA_ARB 0x84E9
|
||||
#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA
|
||||
#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB
|
||||
#define GL_COMPRESSED_INTENSITY_ARB 0x84EC
|
||||
#define GL_COMPRESSED_RGB_ARB 0x84ED
|
||||
#define GL_COMPRESSED_RGBA_ARB 0x84EE
|
||||
#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF
|
||||
#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0
|
||||
#define GL_TEXTURE_COMPRESSED_ARB 0x86A1
|
||||
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2
|
||||
#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3
|
||||
#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
|
||||
|
||||
extern void (APIENTRY *qglCompressedTexImage2DARB)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
|
||||
extern void ( APIENTRY *qglGetCompressedTexImageARB) (GLenum target, GLint lod, const GLvoid* img);
|
||||
#define GL_COMPRESSED_ALPHA_ARB 0x84E9
|
||||
#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA
|
||||
#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB
|
||||
#define GL_COMPRESSED_INTENSITY_ARB 0x84EC
|
||||
#define GL_COMPRESSED_RGB_ARB 0x84ED
|
||||
#define GL_COMPRESSED_RGBA_ARB 0x84EE
|
||||
#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF
|
||||
#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0
|
||||
#define GL_TEXTURE_COMPRESSED_ARB 0x86A1
|
||||
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2
|
||||
#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3
|
||||
|
||||
extern void (APIENTRY *qglCompressedTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
|
||||
extern void ( APIENTRY *qglGetCompressedTexImage) (GLenum target, GLint lod, const GLvoid* img);
|
||||
|
||||
#endif /* GL_ARB_texture_compression */
|
||||
|
||||
|
|
|
@ -48,9 +48,9 @@ void *R_SpriteLoadFrame (model_t *mod, void *pin, mspriteframe_t **ppframe, int
|
|||
pspriteframe->left = origin[0];
|
||||
pspriteframe->right = width + origin[0];
|
||||
pspriteframe->texnum = 0;
|
||||
r_frame.compression = 0;
|
||||
r_frame.bitsperpixel = 32;
|
||||
r_frame.alpha = true;
|
||||
r_frame.type = PF_INDEXED_32;
|
||||
r_frame.numMips = 4;
|
||||
r_frame.flags |= IMAGE_HAS_ALPHA;
|
||||
|
||||
//extract sprite name from path
|
||||
ri.FS_FileBase( mod->name, name );
|
||||
|
|
|
@ -90,9 +90,9 @@ image_t *R_StudioLoadTexture( model_t *mod, mstudiotexture_t *ptexture, byte *pi
|
|||
|
||||
r_skin.width = ptexture->width;
|
||||
r_skin.height = ptexture->height;
|
||||
r_skin.alpha = (ptexture->flags & STUDIO_NF_TRANSPARENT) ? true : false;
|
||||
r_skin.bitsperpixel = 24;
|
||||
r_skin.compression = 0;
|
||||
r_skin.flags |= (ptexture->flags & STUDIO_NF_TRANSPARENT) ? IMAGE_HAS_ALPHA : 0;
|
||||
r_skin.type = PF_INDEXED_24;
|
||||
r_skin.numMips = 4;
|
||||
r_skin.palette = pin + ptexture->width * ptexture->height + ptexture->index;
|
||||
r_skin.buffer = pin + ptexture->index; //texdata
|
||||
|
||||
|
|
1294
render/r_texture.c
1294
render/r_texture.c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
146
render/r_utils.c
146
render/r_utils.c
|
@ -137,24 +137,15 @@ R_ConcatRotations
|
|||
*/
|
||||
void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3])
|
||||
{
|
||||
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +
|
||||
in1[0][2] * in2[2][0];
|
||||
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +
|
||||
in1[0][2] * in2[2][1];
|
||||
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +
|
||||
in1[0][2] * in2[2][2];
|
||||
out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +
|
||||
in1[1][2] * in2[2][0];
|
||||
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +
|
||||
in1[1][2] * in2[2][1];
|
||||
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +
|
||||
in1[1][2] * in2[2][2];
|
||||
out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +
|
||||
in1[2][2] * in2[2][0];
|
||||
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +
|
||||
in1[2][2] * in2[2][1];
|
||||
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +
|
||||
in1[2][2] * in2[2][2];
|
||||
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] + in1[0][2] * in2[2][0];
|
||||
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] + in1[0][2] * in2[2][1];
|
||||
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] + in1[0][2] * in2[2][2];
|
||||
out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] + in1[1][2] * in2[2][0];
|
||||
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] + in1[1][2] * in2[2][1];
|
||||
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] + in1[1][2] * in2[2][2];
|
||||
out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] + in1[2][2] * in2[2][0];
|
||||
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] + in1[2][2] * in2[2][1];
|
||||
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + in1[2][2] * in2[2][2];
|
||||
}
|
||||
|
||||
|
||||
|
@ -352,4 +343,123 @@ MatrixCopy
|
|||
void MatrixCopy( matrix3x4 in, matrix3x4 out )
|
||||
{
|
||||
memcpy( out, in, sizeof( matrix3x4 ));
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
Image Decompress
|
||||
|
||||
ShortToFloat
|
||||
====================
|
||||
*/
|
||||
uint ShortToFloat( word y )
|
||||
{
|
||||
int s = (y >> 15) & 0x00000001;
|
||||
int e = (y >> 10) & 0x0000001f;
|
||||
int m = y & 0x000003ff;
|
||||
|
||||
if (e == 0)
|
||||
{
|
||||
if (m == 0) return s << 31; // Plus or minus zero
|
||||
else // Denormalized number -- renormalize it
|
||||
{
|
||||
while (!(m & 0x00000400))
|
||||
{
|
||||
m <<= 1;
|
||||
e -= 1;
|
||||
}
|
||||
e += 1;
|
||||
m &= ~0x00000400;
|
||||
}
|
||||
}
|
||||
else if (e == 31)
|
||||
{
|
||||
if (m == 0) return (s << 31) | 0x7f800000; // Positive or negative infinity
|
||||
else return (s << 31) | 0x7f800000 | (m << 13); // Nan -- preserve sign and significand bits
|
||||
}
|
||||
|
||||
// Normalized number
|
||||
e = e + (127 - 15);
|
||||
m = m << 13;
|
||||
return (s << 31) | (e << 23) | m; // Assemble s, e and m.
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
Image Decompress
|
||||
|
||||
read colors from dxt image
|
||||
====================
|
||||
*/
|
||||
void R_DXTReadColors(const byte* data, color32* out)
|
||||
{
|
||||
byte r0, g0, b0, r1, g1, b1;
|
||||
|
||||
b0 = data[0] & 0x1F;
|
||||
g0 = ((data[0] & 0xE0) >> 5) | ((data[1] & 0x7) << 3);
|
||||
r0 = (data[1] & 0xF8) >> 3;
|
||||
|
||||
b1 = data[2] & 0x1F;
|
||||
g1 = ((data[2] & 0xE0) >> 5) | ((data[3] & 0x7) << 3);
|
||||
r1 = (data[3] & 0xF8) >> 3;
|
||||
|
||||
out[0].r = r0 << 3;
|
||||
out[0].g = g0 << 2;
|
||||
out[0].b = b0 << 3;
|
||||
|
||||
out[1].r = r1 << 3;
|
||||
out[1].g = g1 << 2;
|
||||
out[1].b = b1 << 3;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
Image Decompress
|
||||
|
||||
read one color from dxt image
|
||||
====================
|
||||
*/
|
||||
void R_DXTReadColor(word data, color32* out)
|
||||
{
|
||||
byte r, g, b;
|
||||
|
||||
b = data & 0x1f;
|
||||
g = (data & 0x7E0) >>5;
|
||||
r = (data & 0xF800)>>11;
|
||||
|
||||
out->r = r << 3;
|
||||
out->g = g << 2;
|
||||
out->b = b << 3;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
R_GetBitsFromMask
|
||||
|
||||
====================
|
||||
*/
|
||||
void R_GetBitsFromMask(uint Mask, uint *ShiftLeft, uint *ShiftRight)
|
||||
{
|
||||
uint Temp, i;
|
||||
|
||||
if (Mask == 0)
|
||||
{
|
||||
*ShiftLeft = *ShiftRight = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
Temp = Mask;
|
||||
for (i = 0; i < 32; i++, Temp >>= 1)
|
||||
{
|
||||
if (Temp & 1) break;
|
||||
}
|
||||
*ShiftRight = i;
|
||||
|
||||
// Temp is preserved, so use it again:
|
||||
for (i = 0; i < 8; i++, Temp >>= 1)
|
||||
{
|
||||
if (!(Temp & 1)) break;
|
||||
}
|
||||
*ShiftLeft = 8 - i;
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: render - Win32 Debug--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
Creating temporary file "C:\Temp\RSPD57.tmp" with contents
|
||||
[
|
||||
/nologo /MTd /W3 /Gm /Gi /GX /ZI /Od /I "../public" /I "../platform/formats" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR"..\temp\render\!debug/" /Fo"..\temp\render\!debug/" /Fd"..\temp\render\!debug/" /FD /c
|
||||
"D:\XASH3D\src_main\!source\render\r_texture.c"
|
||||
]
|
||||
Creating command line "cl.exe @C:\Temp\RSPD57.tmp"
|
||||
Creating temporary file "C:\Temp\RSPD58.tmp" with contents
|
||||
[
|
||||
kernel32.lib user32.lib gdi32.lib /nologo /subsystem:windows /dll /incremental:yes /pdb:"..\temp\render\!debug/render.pdb" /debug /machine:I386 /nodefaultlib:"libc.lib" /out:"..\temp\render\!debug/render.dll" /implib:"..\temp\render\!debug/render.lib" /pdbtype:sept /libpath:"../public/libs/"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\gl_draw.obj"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\gl_light.obj"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\gl_mesh.obj"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\gl_model.obj"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\gl_rmain.obj"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\gl_rmisc.obj"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\gl_rsurf.obj"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\gl_warp.obj"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\gl_widnt.obj"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\glw_imp.obj"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\r_backend.obj"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\r_bloom.obj"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\r_bspmod.obj"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\r_sprite.obj"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\r_studio.obj"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\r_texture.obj"
|
||||
"\XASH3D\src_main\!source\temp\render\!debug\r_utils.obj"
|
||||
]
|
||||
Creating command line "link.exe @C:\Temp\RSPD58.tmp"
|
||||
Creating temporary file "C:\Temp\RSPD59.bat" with contents
|
||||
[
|
||||
@echo off
|
||||
copy \XASH3D\src_main\!source\temp\render\!debug\render.dll "D:\Xash3D\bin\render.dll"
|
||||
]
|
||||
Creating command line "C:\Temp\RSPD59.bat"
|
||||
Compiling...
|
||||
r_texture.c
|
||||
Linking...
|
||||
<h3>Output Window</h3>
|
||||
Performing Custom Build Step on \XASH3D\src_main\!source\temp\render\!debug\render.dll
|
||||
‘ª®¯¨à®¢ ® ä ©«®¢: 1.
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
render.dll - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue