diff --git a/changelog.log b/changelog.log index e4530cd4..b8098360 100644 --- a/changelog.log +++ b/changelog.log @@ -6,7 +6,11 @@ SV_MoveBounds SV_TraceBounds SV_Move SV_Trace SV_ClipMoveToEntity CM_BoxTrace SV_ClipToLinks SV_ClipMoveToEntities +Глобальные задачи: +1. Полная отладка приложения в release +2. Пофиксить зависание bsplib при работе +Текущие задачи: 1. Перенести основные части gamed.dll в движок OK 2. Попытка полностью отказаться от gamed.dll OK 3. Перенести физику в движок OK @@ -23,8 +27,7 @@ SV_ClipToLinks SV_ClipMoveToEntities 14. Переименовать renderer.dll в render.dll OK 15. Упорядочить файлы и код в common.dll OK 16. Пофиксить вылет при загрузке модели игрока в меню -17. Переписать bsplib для работы в цикле -18. Полная имплементация PRVM +17. Полная имплементация PRVM { перенести параметры из sv_edict_t в sv_fields_t OK упорядочить FL_ флаги OK @@ -40,19 +43,26 @@ SV_ClipToLinks SV_ClipMoveToEntities отладка физики избавиться от папки source2 } -19. Написать конвертор PCX в TGA OK -20. Пофиксить проигрывание .cin и .pcx файлов -21. overflow message при компилировании в release -22. создать отдельный mempool для изображений OK -23. разобраться с порядком загрузки сторон кубемапы -24. создать загрузку: *.wal, *.lmp, *.pic OK -25. переписать загрузку pcx OK - - +18. Написать конвертор PCX в TGA OK +19. Пофиксить проигрывание .cin и .pcx файлов +20. создать отдельный mempool для изображений OK +21. разобраться с порядком загрузки сторон кубемапы OK +22. создать загрузку: *.wal, *.lmp, *.pic OK +23. переписать загрузку pcx OK +24. Создать error.jpg и встроить в движок OK +25. ввести ресэмплинг для dds форматов(тормозит падла) +26. исправить загрузку: +{ + -u1555 (грузить при помощи LoadImageRGBA, ввести отдельный тип) + +} //================================================== // то, что уже готово //================================================== ++исправлен баг с загрузкой BGRA_32 текстур ++добавлено два паттерна для отрисовки сторон кубемапы( выбираются автоматически ) ++исправлен критичный баг с загрузкой скайбоксов\кубемапов +Добавлена загрузка lmp и wal +при ненайденной стороне кубемапы или скайбокса она заменяется на сгенерированную текстуру +xash теперь способен загружать текстуры только с указанным расширением diff --git a/common/common.plg b/common/common.plg deleted file mode 100644 index 3faeb17f..00000000 --- a/common/common.plg +++ /dev/null @@ -1,73 +0,0 @@ - - -
-

Build Log

-

---------------------Configuration: common - Win32 Debug-------------------- -

-

Command Lines

-Creating temporary file "C:\Temp\RSP13E.tmp" with contents -[ -/nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "../public" /I "./bsplib/" /I "./qcclib" /I "./common" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR"..\temp\common\!debug/" /Fo"..\temp\common\!debug/" /Fd"..\temp\common\!debug/" /FD /GZ /c -"D:\XASH3D\src_main\!source\common\common\image.c" -] -Creating command line "cl.exe @C:\Temp\RSP13E.tmp" -Creating temporary file "C:\Temp\RSP13F.tmp" with contents -[ -msvcrt.lib winmm.lib user32.lib /nologo /dll /incremental:yes /pdb:"..\temp\common\!debug/common.pdb" /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /out:"..\temp\common\!debug/common.dll" /implib:"..\temp\common\!debug/common.lib" /pdbtype:sept -"\XASH3D\src_main\!source\temp\common\!debug\brushbsp.obj" -"\XASH3D\src_main\!source\temp\common\!debug\bspfile.obj" -"\XASH3D\src_main\!source\temp\common\!debug\csg.obj" -"\XASH3D\src_main\!source\temp\common\!debug\faces.obj" -"\XASH3D\src_main\!source\temp\common\!debug\filesystem.obj" -"\XASH3D\src_main\!source\temp\common\!debug\flow.obj" -"\XASH3D\src_main\!source\temp\common\!debug\image.obj" -"\XASH3D\src_main\!source\temp\common\!debug\imglib.obj" -"\XASH3D\src_main\!source\temp\common\!debug\leakfile.obj" -"\XASH3D\src_main\!source\temp\common\!debug\lightmap.obj" -"\XASH3D\src_main\!source\temp\common\!debug\map.obj" -"\XASH3D\src_main\!source\temp\common\!debug\memory.obj" -"\XASH3D\src_main\!source\temp\common\!debug\patches.obj" -"\XASH3D\src_main\!source\temp\common\!debug\platform.obj" -"\XASH3D\src_main\!source\temp\common\!debug\portals.obj" -"\XASH3D\src_main\!source\temp\common\!debug\pr_comp.obj" -"\XASH3D\src_main\!source\temp\common\!debug\pr_lex.obj" -"\XASH3D\src_main\!source\temp\common\!debug\prtfile.obj" -"\XASH3D\src_main\!source\temp\common\!debug\qbsp3.obj" -"\XASH3D\src_main\!source\temp\common\!debug\qcc_utils.obj" -"\XASH3D\src_main\!source\temp\common\!debug\qccmain.obj" -"\XASH3D\src_main\!source\temp\common\!debug\qrad3.obj" -"\XASH3D\src_main\!source\temp\common\!debug\qvis3.obj" -"\XASH3D\src_main\!source\temp\common\!debug\shaders.obj" -"\XASH3D\src_main\!source\temp\common\!debug\spritegen.obj" -"\XASH3D\src_main\!source\temp\common\!debug\studio.obj" -"\XASH3D\src_main\!source\temp\common\!debug\studio_utils.obj" -"\XASH3D\src_main\!source\temp\common\!debug\textures.obj" -"\XASH3D\src_main\!source\temp\common\!debug\trace.obj" -"\XASH3D\src_main\!source\temp\common\!debug\tree.obj" -"\XASH3D\src_main\!source\temp\common\!debug\utils.obj" -"\XASH3D\src_main\!source\temp\common\!debug\winding.obj" -"\XASH3D\src_main\!source\temp\common\!debug\writebsp.obj" -"\XASH3D\src_main\!source\temp\common\!debug\ziplib.obj" -] -Creating command line "link.exe @C:\Temp\RSP13F.tmp" -Creating temporary file "C:\Temp\RSP140.bat" with contents -[ -@echo off -copy \XASH3D\src_main\!source\temp\common\!debug\common.dll "D:\Xash3D\bin\common.dll" -] -Creating command line "C:\Temp\RSP140.bat" -Compiling... -image.c -Linking... -

Output Window

-Performing Custom Build Step on \XASH3D\src_main\!source\temp\common\!debug\common.dll -‘Є®ЇЁа®ў ­® д ©«®ў: 1. - - - -

Results

-common.dll - 0 error(s), 0 warning(s) -
- - diff --git a/common/common/archive.h b/common/common/archive.h new file mode 100644 index 00000000..a3d756d5 --- /dev/null +++ b/common/common/archive.h @@ -0,0 +1,75 @@ +//======================================================================= +// Copyright XashXT Group 2007 © +// archive.h - store various images +//======================================================================= + +#ifndef ARCHIVE_H +#define ARCHIVE_H + +const byte florr1_2_jpg[] = // quake2 florr1_2.wal image +{ +0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, +0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0xff, 0xdb, +0x00, 0x43, 0x00, 0x0a, 0x07, 0x07, 0x08, 0x07, 0x06, 0x0a, 0x08, +0x08, 0x08, 0x0b, 0x0a, 0x0a, 0x0b, 0x0e, 0x18, 0x10, 0x0e, 0x0d, +0x0d, 0x0e, 0x1d, 0x15, 0x16, 0x11, 0x18, 0x23, 0x1f, 0x25, 0x24, +0x22, 0x1f, 0x22, 0x21, 0x26, 0x2b, 0x37, 0x2f, 0x26, 0x29, 0x34, +0x29, 0x21, 0x22, 0x30, 0x41, 0x31, 0x34, 0x39, 0x3b, 0x3e, 0x3e, +0x3e, 0x25, 0x2e, 0x44, 0x49, 0x43, 0x3c, 0x48, 0x37, 0x3d, 0x3e, +0x3b, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x0a, 0x0b, 0x0b, 0x0e, 0x0d, +0x0e, 0x1c, 0x10, 0x10, 0x1c, 0x3b, 0x28, 0x22, 0x28, 0x3b, 0x3b, +0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, +0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, +0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, +0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, +0x3b, 0x3b, 0x3b, 0x3b, 0xff, 0xc0, 0x00, 0x11, 0x08, 0x00, 0x40, +0x00, 0x40, 0x03, 0x01, 0x11, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, +0x01, 0xff, 0xc4, 0x00, 0x17, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x01, 0x00, 0x02, 0x07, 0xff, 0xc4, 0x00, 0x25, 0x10, 0x00, 0x02, +0x02, 0x02, 0x01, 0x03, 0x05, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x01, 0x11, 0x00, 0x21, 0x31, 0x41, 0x51, 0x02, +0x61, 0x81, 0x12, 0x22, 0x42, 0x71, 0xc1, 0x32, 0x91, 0xb1, 0xff, +0xc4, 0x00, 0x16, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, +0x02, 0xff, 0xc4, 0x00, 0x1b, 0x11, 0x01, 0x00, 0x02, 0x03, 0x01, +0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x01, 0x21, 0x11, 0x31, 0x41, 0x61, 0x71, 0xff, 0xda, 0x00, +0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, +0xe7, 0x43, 0x18, 0xf2, 0x26, 0x22, 0x29, 0xb9, 0x9b, 0x43, 0x1d, +0xde, 0x4c, 0xab, 0x82, 0xfa, 0x93, 0xc9, 0xd6, 0xa3, 0xb5, 0xa0, +0xfb, 0xad, 0xb8, 0x41, 0x91, 0x68, 0xd4, 0x0b, 0x41, 0x0e, 0x98, +0xc0, 0x95, 0xe9, 0xf7, 0x32, 0x63, 0xd1, 0xc0, 0xb6, 0x3c, 0xcb, +0xa0, 0x92, 0x36, 0x05, 0xf0, 0x21, 0x4d, 0x5a, 0x5a, 0x22, 0x84, +0xbc, 0x4c, 0x9c, 0x31, 0x0c, 0x9c, 0x13, 0x80, 0x52, 0x8e, 0x29, +0x9e, 0xa4, 0x05, 0x83, 0x8c, 0x39, 0x46, 0x22, 0xcc, 0xe6, 0x4f, +0xc8, 0x5d, 0xef, 0xb4, 0x66, 0x04, 0x4a, 0xb6, 0x20, 0x90, 0x25, +0xa7, 0x1f, 0x17, 0xa0, 0xe4, 0x2c, 0xfd, 0x66, 0x1f, 0x09, 0x55, +0x79, 0x3c, 0x66, 0x3b, 0x8c, 0x8d, 0x52, 0x40, 0x87, 0xb2, 0x25, +0x16, 0xb4, 0x0b, 0x59, 0x96, 0x73, 0xb5, 0xa6, 0xac, 0x12, 0x09, +0xf3, 0x2e, 0xd2, 0xe5, 0xb2, 0x70, 0xc1, 0x27, 0xf6, 0x08, 0x80, +0xec, 0x15, 0xa8, 0xf2, 0x97, 0x6d, 0x04, 0x4e, 0x6b, 0x89, 0x52, +0xb6, 0x6d, 0x1a, 0x99, 0x69, 0xa0, 0x87, 0x4c, 0x60, 0x4a, 0xf4, +0xfb, 0x99, 0x31, 0xe8, 0xe0, 0x5b, 0x1e, 0x65, 0xd0, 0x49, 0x23, +0xab, 0x5f, 0x70, 0xd1, 0xdb, 0x35, 0xfd, 0xc9, 0x12, 0x91, 0xba, +0x3a, 0x12, 0xc9, 0xc1, 0x26, 0xd2, 0x1c, 0x44, 0x04, 0x05, 0x83, +0x8c, 0x38, 0x46, 0x22, 0xcc, 0xe6, 0x4f, 0xc8, 0x5d, 0xef, 0xb4, +0x66, 0x04, 0x4a, 0xb6, 0x20, 0x90, 0x25, 0xa7, 0x1f, 0x17, 0xa8, +0xb6, 0xf7, 0xfe, 0xcb, 0x52, 0xb6, 0x86, 0x31, 0xe4, 0x42, 0x22, +0x8c, 0xcd, 0xa1, 0xfc, 0x68, 0x5b, 0xb2, 0x65, 0x5c, 0x17, 0xd4, +0x9e, 0x4e, 0xb5, 0x1d, 0xad, 0x1b, 0x04, 0x82, 0x7c, 0xcb, 0xb4, +0xb9, 0x6c, 0x9c, 0x30, 0x49, 0xfd, 0x82, 0x20, 0x3b, 0x05, 0x6a, +0x3c, 0xa5, 0xdb, 0x41, 0x13, 0x9a, 0xe2, 0x54, 0xac, 0x36, 0x8b, +0xbe, 0x25, 0x2a, 0x09, 0x23, 0x60, 0x5f, 0x02, 0x14, 0x6d, 0x2d, +0x11, 0x42, 0x5e, 0x26, 0x4e, 0x18, 0x86, 0x4e, 0x1a, 0x24, 0x8e, +0xad, 0x7d, 0xc7, 0x4c, 0xed, 0x91, 0xdc, 0x67, 0x99, 0x44, 0x19, +0x93, 0xea, 0xae, 0x6e, 0x49, 0x5b, 0xfc, 0x87, 0x6d, 0x70, 0x94, +0xef, 0xb4, 0x67, 0x6b, 0x80, 0xe4, 0x2c, 0xfd, 0x66, 0x5f, 0x11, +0x55, 0x79, 0x3c, 0x66, 0x3b, 0x8c, 0x8d, 0x52, 0x40, 0x87, 0xb2, +0x25, 0x16, 0xb4, 0x8a, 0x77, 0xda, 0x13, 0xb3, 0xc4, 0x50, 0xd5, +0x76, 0x94, 0xec, 0x46, 0x93, 0x42, 0x8a, 0xbd, 0xc9, 0x23, 0x56, +0x01, 0x7c, 0x99, 0x10, 0x6c, 0xbc, 0x99, 0x67, 0x2b, 0x18, 0x16, +0x8d, 0x40, 0xb5, 0x43, 0xa5, 0xf6, 0x8c, 0x09, 0x5e, 0x9f, 0x73, +0x26, 0x3d, 0x1c, 0x7f, 0xff, 0xd9 }; + +#endif//ARCHIVE_H \ No newline at end of file diff --git a/common/common/image.c b/common/common/image.c index ab4e93f4..ef286924 100644 --- a/common/common/image.c +++ b/common/common/image.c @@ -5,6 +5,7 @@ #include "platform.h" #include "utils.h" +#include "archive.h" //global image variables int image_width, image_height; @@ -24,7 +25,8 @@ byte *image_rgba; // image pointer (see image_type for details) int cubemap_width, cubemap_height; int cubemap_num_sides; // how mach sides is loaded byte *image_cubemap; // cubemap pack - +uint cubemap_image_type; // shared image type +char *suf[6] = {"ft", "bk", "rt", "lf", "up", "dn"}; bool ImageValidSize( char *name ) { @@ -345,28 +347,15 @@ bool LoadPCX( char *name, char *buffer, int filesize ) for (i = 0; i < s; i++) { p = pbuf[i]; - trans[i] = d_currentpal[p]; - if (p == 255) { image_flags |= IMAGE_HAS_ALPHA; // found alpha channel - - // transparent, so scan around for another color - // to avoid alpha fringes - // FIXME: do a full flood fill so mips work... - if (i > image_width && pbuf[i - image_width] != 255) - p = pbuf[i - image_width]; - else if (i < s - image_width && pbuf[i + image_width] != 255) - p = pbuf[i + image_width]; - else if (i > 0 && pbuf[i-1] != 255) p = pbuf[i-1]; - else if (i < s-1 && pbuf[i+1] != 255) p = pbuf[i+1]; - else p = 0; - - // copy rgba components - ((byte *)&trans[i])[0] = ((byte *)&d_currentpal[p])[0]; - ((byte *)&trans[i])[1] = ((byte *)&d_currentpal[p])[1]; - ((byte *)&trans[i])[2] = ((byte *)&d_currentpal[p])[2]; + ((byte *)&trans[i])[0] = ((byte *)&d_currentpal[0])[0]; + ((byte *)&trans[i])[1] = ((byte *)&d_currentpal[0])[1]; + ((byte *)&trans[i])[2] = ((byte *)&d_currentpal[0])[2]; + ((byte *)&trans[i])[3] = ((byte *)&d_currentpal[p])[3]; } + else trans[i] = d_currentpal[p]; } Free( pbuf ); // free compressed image @@ -745,10 +734,10 @@ uint dds_get_linear_size( int width, int height, int depth, int rgbcount ) // right calcualte blocksize for(i = 0; i < PF_TOTALCOUNT; i++) { - if(image_type == PixelFormatDescription[i].format) + if(image_type == PFDesc[i].format) { - block = PixelFormatDescription[i].block; - bpp = PixelFormatDescription[i].bpp; + block = PFDesc[i].block; + bpp = PFDesc[i].bpp; break; } } @@ -813,9 +802,9 @@ void dds_get_pixelformat( dds_t *hdr ) } // setup additional flags - if( hdr->dsCaps.dwCaps1 & DDS_COMPLEX ) + if( hdr->dsCaps.dwCaps1 & DDS_COMPLEX && hdr->dsCaps.dwCaps2 & DDS_CUBEMAP) { - image_flags |= (hdr->dsCaps.dwCaps2 & DDS_CUBEMAP) ? IMAGE_CUBEMAP : 0; + image_flags |= IMAGE_CUBEMAP | IMAGE_CUBEMAP_FLIP; } if(hdr->dsPixelFormat.dwFlags & DDS_ALPHAPIXELS) @@ -1476,15 +1465,14 @@ bool LoadJPG(char *name, char *buffer, int filesize ) return true; } -typedef struct imageformat_s +typedef struct loadformat_s { char *formatstring; char *ext; bool (*loadfunc)(char *name, char *buffer, int filesize); -} -imageformat_t; +} loadformat_t; -imageformat_t image_formats[] = +loadformat_t load_formats[] = { {"textures/%s%s.%s", "dds", LoadDDS}, {"textures/%s%s.%s", "tga", LoadTGA}, @@ -1508,7 +1496,7 @@ rgbdata_t *ImagePack( void ) rgbdata_t *pack = Mem_Alloc( imagepool, sizeof(rgbdata_t)); if(image_cubemap && cubemap_num_sides != 6) // this neved be happens, just in case - Sys_Error("ImagePack: inconsistent cubemap pack\n" ); + Sys_Error("ImagePack: inconsistent cubemap pack %d\n", cubemap_num_sides ); if(image_cubemap) { @@ -1516,31 +1504,40 @@ rgbdata_t *ImagePack( void ) pack->buffer = image_cubemap; pack->width = cubemap_width; pack->height = cubemap_height; + pack->type = cubemap_image_type; } else { pack->buffer = image_rgba; pack->width = image_width; pack->height = image_height; + pack->type = image_type; } pack->numLayers = image_num_layers; pack->numMips = image_num_mips; pack->bitsCount = image_bits_count; - pack->type = image_type; pack->flags = image_flags; pack->palette = image_palette; return pack; } -void FS_AddImageToPack( const char *name ) +bool FS_AddImageToPack( const char *name ) { byte *resampled; // first image have suffix "ft" and set average size for all cubemap sides! - if(!image_cubemap){ cubemap_width = image_width, cubemap_height = image_height; } + if(!image_cubemap) + { + cubemap_width = image_width; + cubemap_height = image_height; + cubemap_image_type = image_type; + } image_size = cubemap_width * cubemap_height * 4; // keep constant size, render.dll expecting it + + // mixing dds format with any existing ? + if(image_type != cubemap_image_type) return false; // resampling image if needed resampled = Image_Resample((uint *)image_rgba, image_width, image_height, cubemap_width, cubemap_height); @@ -1556,6 +1553,8 @@ void FS_AddImageToPack( const char *name ) Free( image_rgba ); // memmove aren't help us image_ptr += image_size; // move to next cubemap_num_sides++; // sides counter + + return true; } /* @@ -1567,14 +1566,16 @@ loading and unpack to rgba any known image */ rgbdata_t *FS_LoadImage(const char *filename, char *buffer, int buffsize ) { - imageformat_t *format; + loadformat_t *format; const char *ext = FS_FileExtension( filename ); char path[128], loadname[128], texname[128]; bool anyformat = !stricmp(ext, "") ? true : false; - char *suf[6] = {"ft", "bk", "rt", "lf", "up", "dn"}; int i, filesize = 0; byte *f; +#if 0 // don't try to be very clever + if(!buffer || !buffsize) buffer = (char *)florr1_2_jpg, buffsize = sizeof(florr1_2_jpg); +#endif strncpy( loadname, filename, sizeof(loadname)-1); FS_StripExtension( loadname ); //remove extension if needed @@ -1582,7 +1583,7 @@ rgbdata_t *FS_LoadImage(const char *filename, char *buffer, int buffsize ) if(!anyformat) MsgWarn( "Warning: %s will be loading only with ext .%s\n", loadname, ext ); // now try all the formats in the selected list - for (format = image_formats; format->formatstring; format++) + for (format = load_formats; format->formatstring; format++) { if(anyformat || !stricmp(ext, format->ext )) { @@ -1601,7 +1602,7 @@ rgbdata_t *FS_LoadImage(const char *filename, char *buffer, int buffsize ) // maybe it skybox or cubemap ? for(i = 0; i < 6; i++) { - for (format = image_formats; format->formatstring; format++) + for (format = load_formats; format->formatstring; format++) { if(anyformat || !stricmp(ext, format->ext )) { @@ -1612,24 +1613,24 @@ rgbdata_t *FS_LoadImage(const char *filename, char *buffer, int buffsize ) // this name will be used only for tell user about problems FS_FileBase( path, texname ); if( format->loadfunc(texname, f, filesize )) - FS_AddImageToPack(va("%s%s.%s", loadname, suf[i], format->ext)); + { + if(FS_AddImageToPack(va("%s%s.%s", loadname, suf[i], format->ext))) + break; // loaded + } } } } if(cubemap_num_sides != i + 1) //check side { - if(!image_cubemap) // first side not found - { - // set default dimensions - cubemap_width = cubemap_height = 256; - image_size = cubemap_width * cubemap_height * 4; - } + // first side not found, probably it's not cubemap + // it contain info about image_type and dimensions, don't generate black cubemaps + if(!image_cubemap) break; MsgDev(D_LOAD, "FS_LoadImage: couldn't load (%s%s.%s), create balck image\n",loadname,suf[i],ext ); // Mem_Alloc already filled memblock with 0x00, no need to do it again image_cubemap = Mem_Realloc( imagepool, image_cubemap, image_ptr + image_size ); - image_ptr += image_size; // move to next - cubemap_num_sides++; // merge counter + image_ptr += image_size; // move to next + cubemap_num_sides++; // merge counter } } @@ -1638,7 +1639,7 @@ rgbdata_t *FS_LoadImage(const char *filename, char *buffer, int buffsize ) // try to load image from const buffer (e.g. const byte blank_frame ) strncpy( texname, filename, sizeof(texname) - 1); - for (format = image_formats; format->formatstring; format++) + for (format = load_formats; format->formatstring; format++) { if(anyformat || !stricmp(ext, format->ext )) { @@ -1687,6 +1688,80 @@ void FS_FreeImage( rgbdata_t *pack ) image_size = 0; } +/* +============= +SaveTGA +============= +*/ +bool SaveTGA( const char *filename, byte *data, int width, int height, bool alpha, int imagetype ) +{ + int y, outsize, pixel_size; + const byte *bufend, *in; + byte *buffer, *out; + const char *comment = "Generated by Xash ImageLib\0"; + + if(alpha) outsize = width * height * 4 + 18 + strlen(comment); + else outsize = width * height * 3 + 18 + strlen(comment); + + buffer = (byte *)Z_Malloc( outsize ); + memset (buffer, 0, 18); + + // prepare header + buffer[0] = strlen(comment); // tga comment length + buffer[2] = 2; // uncompressed type + buffer[12] = (width >> 0) & 0xFF; + buffer[13] = (width >> 8) & 0xFF; + buffer[14] = (height >> 0) & 0xFF; + buffer[15] = (height >> 8) & 0xFF; + buffer[16] = alpha ? 32 : 24; + buffer[17] = alpha ? 8 : 0; // 8 bits of alpha + strncpy(buffer + 18, comment, strlen(comment)); + out = buffer + 18 + strlen(comment); + + // get image description + switch( image_type ) + { + case PF_RGB_24: pixel_size = 3; break; + case PF_RGBA_32: pixel_size = 4; break; + default: + MsgWarn("SaveTGA: unsupported image type %s\n", PFDesc[image_type - 1].name ); + return false; + } + + // swap rgba to bgra and flip upside down + for (y = height - 1; y >= 0; y--) + { + in = data + y * width * pixel_size; + bufend = in + width * pixel_size; + for ( ;in < bufend; in += pixel_size) + { + *out++ = in[2]; + *out++ = in[1]; + *out++ = in[0]; + if(alpha) *out++ = in[3]; + } + } + + Msg("Writing %s[%d]\n", filename, alpha ? 32 : 24 ); + FS_WriteFile (filename, buffer, outsize ); + + Free( buffer ); + return true; +} + +typedef struct saveformat_s +{ + char *formatstring; + char *ext; + bool (*savefunc)(char *filename, byte *data, int width, int height, bool alpha, int imagetype ); +} saveformat_t; + +saveformat_t save_formats[] = +{ + {"%s%s.%s", "tga", SaveTGA}, + {NULL, NULL} +}; + /* ================ FS_SaveImage @@ -1696,61 +1771,26 @@ writes image as tga RGBA format */ void FS_SaveImage(const char *filename, rgbdata_t *pix ) { - int y, width, height; - byte *buffer, *out; - const byte *in, *end, *data; - int pixel_size, outsize; bool has_alpha = false; + int i, numsides = 1; + byte *data; + char savename[256]; if(!pix || !pix->buffer) return; - width = pix->width; - height = pix->height; data = pix->buffer; + FS_StripExtension( (char *)filename ); + if(pix->flags & IMAGE_HAS_ALPHA) has_alpha = true; + if(pix->flags & IMAGE_CUBEMAP) numsides = 6; - // detect input parms - if(pix->type == PF_RGB_24) pixel_size = 3; - else if (pix->type == PF_RGBA_32) pixel_size = 4; - else + for(i = 0; i < numsides; i++) { - MsgWarn("FS_SaveImage: %s have unsupported type for write, ignored\n", filename ); - return; + if(numsides > 1) sprintf(savename, "%s%s.tga", filename, suf[i] ); + else sprintf(savename, "%s.tga", filename ); + + SaveTGA( savename, data, pix->width, pix->height, has_alpha, pix->type ); + data += pix->width * pix->height * PFDesc[pix->type - 1].bpp; } - if(pix->flags & IMAGE_HAS_ALPHA) - has_alpha = true; - - if(has_alpha) outsize = width * height * 4 + 18; - else outsize = width * height * 3 + 18; - - buffer = (byte *)Z_Malloc( outsize ); - memset (buffer, 0, 18); - - buffer[2] = 2; // uncompressed type - buffer[12] = (width >> 0) & 0xFF; - buffer[13] = (width >> 8) & 0xFF; - buffer[14] = (height >> 0) & 0xFF; - buffer[15] = (height >> 8) & 0xFF; - buffer[16] = has_alpha ? 32 : 24; - buffer[17] = has_alpha ? 8 : 0; // 8 bits of alpha - out = buffer + 18; - - // swap rgba to bgra and flip upside down - for (y = height - 1; y >= 0; y--) - { - in = data + y * width * pixel_size; - end = in + width * pixel_size; - for ( ;in < end; in += pixel_size) - { - *out++ = in[2]; - *out++ = in[1]; - *out++ = in[0]; - if(has_alpha) - *out++ = in[3]; - } - } - Msg("Writing %s[%d]\n", filename, has_alpha ? 32 : 24 ); - FS_WriteFile (filename, buffer, outsize ); - Free( buffer ); } void FS_InitImagelib( void ) diff --git a/common/common/image.h b/common/common/image.h index 5a0a6d4f..def32b1c 100644 --- a/common/common/image.h +++ b/common/common/image.h @@ -94,7 +94,7 @@ typedef struct lmp_s ======================================================================== */ -typedef struct +typedef struct tga_s { byte id_length; byte colormap_type; diff --git a/common/common/imglib.c b/common/common/imglib.c index b6483fd4..ac78849f 100644 --- a/common/common/imglib.c +++ b/common/common/imglib.c @@ -110,6 +110,7 @@ void Image_GetPalettePCX( byte *pal ) if(pal) { Image_GetPalette( pal, d_8to24table ); + d_8to24table[255] &= LittleLong(0xffffff); d_currentpal = d_8to24table; } else Image_GetQ2Palette(); @@ -190,7 +191,6 @@ byte *Image_Resample(uint *in, int inwidth, int inheight, int outwidth, int outh //check for buffers if(!in) return NULL; - // nothing to resample ? if (inwidth == outwidth && inheight == outheight) return (byte *)in; diff --git a/debug.bat b/debug.bat index 3feb7ac3..ea768d5a 100644 --- a/debug.bat +++ b/debug.bat @@ -55,5 +55,5 @@ if exist server.dat move server.dat D:\Xash3D\xash\server.dat echo Build succeeded! echo Please wait. Xash is now loading cd D:\Xash3D\ -xash.exe +map skytest -log -debug -dev 1 +xash.exe +map skytest -log -debug -dev 4 :done \ No newline at end of file diff --git a/launch/launch.plg b/launch/launch.plg deleted file mode 100644 index 94cad119..00000000 --- a/launch/launch.plg +++ /dev/null @@ -1,43 +0,0 @@ - - -
-

Build Log

-

---------------------Configuration: launch - Win32 Debug-------------------- -

-

Command Lines

-Creating temporary file "C:\Temp\RSP119.tmp" with contents -[ -/nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "../public" /I "../platform/formats" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR"..\temp\launch\!debug/" /Fo"..\temp\launch\!debug/" /Fd"..\temp\launch\!debug/" /FD /GZ /c -"D:\XASH3D\src_main\!source\launch\launcher.c" -] -Creating command line "cl.exe @C:\Temp\RSP119.tmp" -Creating temporary file "C:\Temp\RSP11A.tmp" with contents -[ -msvcrt.lib user32.lib gdi32.lib advapi32.lib /nologo /dll /incremental:yes /pdb:"..\temp\launch\!debug/launch.pdb" /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /out:"..\temp\launch\!debug/launch.dll" /implib:"..\temp\launch\!debug/launch.lib" /pdbtype:sept -"\XASH3D\src_main\!source\temp\launch\!debug\console.obj" -"\XASH3D\src_main\!source\temp\launch\!debug\launcher.obj" -"\XASH3D\src_main\!source\temp\launch\!debug\stdlib.obj" -"\XASH3D\src_main\!source\temp\launch\!debug\utils.obj" -] -Creating command line "link.exe @C:\Temp\RSP11A.tmp" -Creating temporary file "C:\Temp\RSP11B.bat" with contents -[ -@echo off -copy \XASH3D\src_main\!source\temp\launch\!debug\launch.dll "D:\Xash3D\bin\launch.dll" -] -Creating command line "C:\Temp\RSP11B.bat" -Compiling... -launcher.c -Linking... -

Output Window

-Performing Custom Build Step on \XASH3D\src_main\!source\temp\launch\!debug\launch.dll -‘Є®ЇЁа®ў ­® д ©«®ў: 1. - - - -

Results

-launch.dll - 0 error(s), 0 warning(s) -
- - diff --git a/public/ref_system.h b/public/ref_system.h index 8d83db90..43d6488a 100644 --- a/public/ref_system.h +++ b/public/ref_system.h @@ -101,13 +101,13 @@ typedef struct int block; // blocksize < 0 needs alternate calc } bpc_desc_t; -static bpc_desc_t PixelFormatDescription[] = +static bpc_desc_t PFDesc[] = { {PF_INDEXED_24, "pal 24", 3, 1, 0 }, {PF_INDEXED_32, "pal 32", 4, 1, 0 }, -{PF_RGBA_32, "RGBA", 4, 1, -4 }, -{PF_ARGB_32, "ARGB", 4, 1, -4 }, -{PF_RGB_24, "RGB", 3, 1, -3 }, +{PF_RGBA_32, "RGBA 32",4, 1, -4 }, +{PF_ARGB_32, "ARGB 32",4, 1, -4 }, +{PF_RGB_24, "RGB 24", 3, 1, -3 }, {PF_DXT1, "DXT1", 4, 1, 8 }, {PF_DXT2, "DXT2", 4, 1, 16 }, {PF_DXT3, "DXT3", 4, 1, 16 }, @@ -119,7 +119,7 @@ static bpc_desc_t PixelFormatDescription[] = {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_ABGR_64, "ABGR 64",4, 2, -8 }, {PF_ABGR_128F, "ABGR128",4, 4, -16}, {PF_PROCEDURE_TEX, "system", 4, 1, -32}, {PF_UNKNOWN, "", 0, 0, 0 }, @@ -129,6 +129,7 @@ static bpc_desc_t PixelFormatDescription[] = #define IMAGE_HAS_ALPHA 0x00000002 #define IMAGE_PREMULT 0x00000004 // indices who need in additional premultiply #define IMAGE_GEN_MIPS 0x00000008 // must generate mips +#define IMAGE_CUBEMAP_FLIP 0x00000010 // it's a cubemap with flipped sides( dds pack ) #define CUBEMAP_POSITIVEX 0x00000400L #define CUBEMAP_NEGATIVEX 0x00000800L diff --git a/render/gl_local.h b/render/gl_local.h index 8fdf4fef..624a7207 100644 --- a/render/gl_local.h +++ b/render/gl_local.h @@ -182,8 +182,7 @@ typedef struct image_s struct msurface_s *texturechain; // for sort-by-texture world drawing int texnum[6]; // gl texture binding bool paletted; - - //new stuff starts here + int texorder[6]; // drawing order pattern }; #define TEXNUM_LIGHTMAPS 1024 diff --git a/render/gl_rmisc.c b/render/gl_rmisc.c index 2f277772..82d0a30d 100644 --- a/render/gl_rmisc.c +++ b/render/gl_rmisc.c @@ -81,7 +81,7 @@ void R_InitParticleTexture (void) data[y][x][3] = 255; } } - r_tex.flags &= ~IMAGE_HAS_ALPHA;//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(); diff --git a/render/gl_warp.c b/render/gl_warp.c index 2c5d295f..4739d357 100644 --- a/render/gl_warp.c +++ b/render/gl_warp.c @@ -539,14 +539,14 @@ void MakeSkyVec (float s, float t, int axis) R_DrawSkyBox ============== */ -int skytexorder[6] = {4, 5, 1, 0, 2, 3}; //var. 1 + //var. 1 uint RemapSides[6] = { 0, // ft 2, // bk - 4, // rt - 5, // lf + 4, // lf + 5, // rt 1, // up 3, // dn }; @@ -555,12 +555,6 @@ void R_DrawSkyBox (void) { int i; -#if 0 - qglEnable (GL_BLEND); - GL_TexEnv( GL_MODULATE ); - qglColor4f (1,1,1,0.5); - qglDisable (GL_DEPTH_TEST); -#endif if (skyrotate) { // check for no sky at all for (i = 0; i < 6; i++) @@ -587,7 +581,7 @@ void R_DrawSkyBox (void) || skymins[1][i] >= skymaxs[1][i]) continue; - GL_Bind (sky_image->texnum[skytexorder[i]]); + GL_Bind (sky_image->texnum[sky_image->texorder[i]]); qglBegin (GL_QUADS); MakeSkyVec (skymins[0][i], skymins[1][i], i); @@ -597,13 +591,6 @@ void R_DrawSkyBox (void) qglEnd (); } qglPopMatrix (); - -#if 0 - glDisable (GL_BLEND); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glColor4f (1,1,1,0.5); - glEnable (GL_DEPTH_TEST); -#endif } /* diff --git a/render/r_texture.c b/render/r_texture.c index 236cf80e..cdcf1acc 100644 --- a/render/r_texture.c +++ b/render/r_texture.c @@ -126,9 +126,9 @@ void R_SetPixelFormat( int width, int height, int depth ) size_t file_size; int BlockSize; - BlockSize = PixelFormatDescription[image_desc.format].block; - image_desc.bpp = PixelFormatDescription[image_desc.format].bpp; - image_desc.bpc = PixelFormatDescription[image_desc.format].bpc; + BlockSize = PFDesc[image_desc.format].block; + image_desc.bpp = PFDesc[image_desc.format].bpp; + image_desc.bpc = PFDesc[image_desc.format].bpc; image_desc.numLayers = depth; image_desc.width = width; @@ -176,12 +176,12 @@ void R_GetPixelFormat( rgbdata_t *pic, imagetype_t type ) memset( &image_desc, 0, sizeof(image_desc)); for(i = 0; i < PF_TOTALCOUNT; i++) { - if(pic->type == PixelFormatDescription[i].format) + if(pic->type == PFDesc[i].format) { image_desc.format = i;//now correct - BlockSize = PixelFormatDescription[i].block; - image_desc.bpp = PixelFormatDescription[i].bpp; - image_desc.bpc = PixelFormatDescription[i].bpc; + BlockSize = PFDesc[i].block; + image_desc.bpp = PFDesc[i].bpp; + image_desc.bpc = PFDesc[i].bpc; break; } } @@ -971,7 +971,7 @@ bool qrsCompressedTexImage2D( uint target, int level, int internalformat, uint w } break; default: - MsgDev(D_WARN, "qrsCompressedTexImage2D: invalid compression type: %s\n", PixelFormatDescription[internalformat].name ); + MsgDev(D_WARN, "qrsCompressedTexImage2D: invalid compression type: %s\n", PFDesc[internalformat].name ); return false; } @@ -990,7 +990,7 @@ bool CompressedTexImage2D( uint target, int level, int intformat, uint width, ui { bool use_gl_extension = true; uint dxtformat = 0; - uint pixformat = PixelFormatDescription[intformat].format; + uint pixformat = PFDesc[intformat].format; if(gl_config.arb_compressed_teximage) { @@ -1087,7 +1087,7 @@ bool qrsDecompressImageATI( uint target, int level, int internalformat, uint wid w = width; h = height; - switch( PixelFormatDescription[internalformat].format ) + switch( PFDesc[internalformat].format ) { case PF_ATI1N: for (z = 0; z < image_desc.numLayers; z++) @@ -1237,7 +1237,7 @@ bool qrsDecompressImageATI( uint target, int level, int internalformat, uint wid } break; default: - MsgDev(D_WARN, "qrsDecompressImageATI: invalid compression type: %s\n", PixelFormatDescription[internalformat].name ); + MsgDev(D_WARN, "qrsDecompressImageATI: invalid compression type: %s\n", PFDesc[internalformat].name ); return false; } @@ -1423,13 +1423,39 @@ bool R_LoadImageARGB( byte *data ) return true; } +/* +=============== +R_LoadImageBGRA +=============== +*/ +bool R_LoadImageBGRA( byte *data ) +{ + byte *trans = imagebuffer; + int i, s = image_desc.width * image_desc.height; + + if (s&3) + { + MsgDev(D_ERROR, "R_LoadImageBGRA: s&3\n"); + return false; + } + + // swap green and red + for (i = 0; i < s; i++ ) + { + trans[(i<<2)+0] = data[i*4+2]; + trans[(i<<2)+1] = data[i*4+1]; + trans[(i<<2)+2] = data[i*4+0]; + trans[(i<<2)+3] = data[i*4+3]; + } + return R_LoadTexImage((uint*)trans ); +} /* =============== -R_LoadImage32 +R_LoadImageRGBA =============== */ -bool R_LoadImage32 (byte *data ) +bool R_LoadImageRGBA (byte *data ) { byte *trans = imagebuffer; int i, s = image_desc.width * image_desc.height; @@ -1439,7 +1465,7 @@ bool R_LoadImage32 (byte *data ) if (s&3) { - MsgDev(D_ERROR, "R_LoadImage32: s&3\n"); + MsgDev(D_ERROR, "R_LoadImageRGBA: s&3\n"); return false; } for (i = 0; i < s; i++ ) @@ -1454,10 +1480,10 @@ bool R_LoadImage32 (byte *data ) /* =============== -R_LoadImage24 +R_LoadImageRGB =============== */ -bool R_LoadImage24(byte *data ) +bool R_LoadImageRGB(byte *data ) { byte *trans = imagebuffer; int i, s = image_desc.width * image_desc.height; @@ -1466,7 +1492,7 @@ bool R_LoadImage24(byte *data ) if (s&3) { - MsgDev(D_ERROR, "R_LoadImage24: s&3\n"); + MsgDev(D_ERROR, "R_LoadImageRGB: s&3\n"); return false; } @@ -1574,6 +1600,8 @@ image_t *R_LoadImage(char *name, rgbdata_t *pic, imagetype_t type ) bool iResult = true; int i, numsides = 1, width, height; uint offset = 0; + int skyorder_q2[6] = { 2, 3, 1, 0, 4, 5, }; // Quake, Half-Life skybox ordering + int skyorder_ms[6] = { 4, 5, 1, 0, 2, 3 }; // Microsoft DDS ordering (reverse) byte *buf; //nothing to load @@ -1600,7 +1628,14 @@ image_t *R_LoadImage(char *name, rgbdata_t *pic, imagetype_t type ) strncpy (image->name, name, sizeof(image->name)); image->registration_sequence = registration_sequence; - if(pic->flags & IMAGE_CUBEMAP) numsides = 6; + if(pic->flags & IMAGE_CUBEMAP) + { + numsides = 6; + if(pic->flags & IMAGE_CUBEMAP_FLIP) + memcpy(image->texorder, skyorder_ms, sizeof(int) * 6 ); + else memcpy(image->texorder, skyorder_q2, sizeof(int) * 6 ); + } + else memset(image->texorder, 0, sizeof(int) * 6 ); image->width = width = pic->width; image->height = height = pic->height; @@ -1619,16 +1654,16 @@ image_t *R_LoadImage(char *name, rgbdata_t *pic, imagetype_t type ) R_SetPixelFormat( image_desc.width, image_desc.height, image_desc.numLayers ); offset = image_desc.SizeOfFile;// move pointer - MsgDev(D_LOAD, "loading %s [%s] \n", name, PixelFormatDescription[image_desc.format].name ); + MsgDev(D_LOAD, "loading %s [%s] \n", name, PFDesc[image_desc.format].name ); switch(pic->type) { - case PF_INDEXED_24: iResult = R_LoadImage24( buf ); break; - case PF_INDEXED_32: iResult = R_LoadImage32( buf ); break; + case PF_INDEXED_24: iResult = R_LoadImageRGB( buf ); break; + case PF_INDEXED_32: iResult = R_LoadImageRGBA( buf ); break; case PF_PROCEDURE_TEX: - case PF_RGBA_32: - case PF_ABGR_64: iResult = R_LoadTexImage((uint*)buf ); break; - case PF_RGB_24: iResult = R_LoadImage24( buf ); break; + case PF_RGBA_32: iResult = R_LoadTexImage((uint*)buf ); break; + case PF_ABGR_64: iResult = R_LoadImageBGRA( buf ); break; + case PF_RGB_24: iResult = R_LoadImageRGB( buf ); break; case PF_LUMINANCE: case PF_LUMINANCE_16: case PF_LUMINANCE_ALPHA: