mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
fixed non-quality textures
This commit is contained in:
parent
24397335be
commit
7a6e10d87b
|
@ -240,7 +240,7 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer::
|
|||
{
|
||||
int Width = pCommand->m_Width;
|
||||
int Height = pCommand->m_Height;
|
||||
int Depth = pCommand->m_Depth;
|
||||
int Depth = 1;
|
||||
void *pTexData = pCommand->m_pData;
|
||||
|
||||
// resample if needed
|
||||
|
@ -271,6 +271,34 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer::
|
|||
pTexData = pTmpData;
|
||||
}
|
||||
}
|
||||
|
||||
// 3d texture?
|
||||
if(pCommand->m_Flags&CCommandBuffer::TEXFLAG_TEXTURE3D)
|
||||
{
|
||||
Width /= 16;
|
||||
Height /= 16;
|
||||
Depth = 256;
|
||||
|
||||
// copy and reorder texture data
|
||||
int MemSize = Width*Height*Depth*pCommand->m_PixelSize;
|
||||
char *pTmpData = (char *)mem_alloc(MemSize, sizeof(void*));
|
||||
|
||||
const int TileSize = (Height * Width) * pCommand->m_PixelSize;
|
||||
const int TileRowSize = Width * pCommand->m_PixelSize;
|
||||
const int ImagePitch = Width*16 * pCommand->m_PixelSize;
|
||||
mem_zero(pTmpData, MemSize);
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
const int px = (i%16) * Width;
|
||||
const int py = (i/16) * Height;
|
||||
const char *pTileData = (const char *)pTexData + (py * Width*16 + px) * pCommand->m_PixelSize;
|
||||
for(int y = 0; y < Height; y++)
|
||||
mem_copy(pTmpData + i*TileSize + y*TileRowSize, pTileData + y * ImagePitch, TileRowSize);
|
||||
}
|
||||
|
||||
mem_free(pTexData);
|
||||
pTexData = pTmpData;
|
||||
}
|
||||
|
||||
int Oglformat = TexFormatToOpenGLFormat(pCommand->m_Format);
|
||||
int StoreOglformat = TexFormatToOpenGLFormat(pCommand->m_StoreFormat);
|
||||
|
|
|
@ -332,7 +332,6 @@ IGraphics::CTextureHandle CGraphics_Threaded::LoadTextureRaw(int Width, int Heig
|
|||
Cmd.m_PixelSize = ImageFormatToPixelSize(Format);
|
||||
Cmd.m_Format = ImageFormatToTexFormat(Format);
|
||||
Cmd.m_StoreFormat = ImageFormatToTexFormat(StoreFormat);
|
||||
Cmd.m_Depth = 1;
|
||||
|
||||
|
||||
// flags
|
||||
|
@ -343,43 +342,16 @@ IGraphics::CTextureHandle CGraphics_Threaded::LoadTextureRaw(int Width, int Heig
|
|||
Cmd.m_Flags |= CCommandBuffer::TEXFLAG_COMPRESSED;
|
||||
if(g_Config.m_GfxTextureQuality || Flags&TEXLOAD_NORESAMPLE)
|
||||
Cmd.m_Flags |= CCommandBuffer::TEXFLAG_QUALITY;
|
||||
|
||||
|
||||
// 3d texture?
|
||||
if(Flags&IGraphics::TEXLOAD_ARRAY_256)
|
||||
{
|
||||
Cmd.m_Width /= 16;
|
||||
Cmd.m_Height /= 16;
|
||||
Cmd.m_Depth = 256;
|
||||
|
||||
// copy and reorder texture data
|
||||
int MemSize = Width*Height*Cmd.m_PixelSize;
|
||||
char *pTmpData = (char *)mem_alloc(MemSize, sizeof(void*));
|
||||
|
||||
const int TileSize = (Cmd.m_Height * Cmd.m_Width) * Cmd.m_PixelSize;
|
||||
const int TileRowSize = Cmd.m_Width * Cmd.m_PixelSize;
|
||||
const int ImagePitch = Width * Cmd.m_PixelSize;
|
||||
mem_zero(pTmpData, MemSize);
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
const int px = (i%16) * Cmd.m_Width;
|
||||
const int py = (i/16) * Cmd.m_Height;
|
||||
const char *pTileData = (const char *)pData + (py * Width + px) * Cmd.m_PixelSize;
|
||||
for(int y = 0; y < Cmd.m_Height; y++)
|
||||
mem_copy(pTmpData + i*TileSize + y*TileRowSize, pTileData + y * ImagePitch, TileRowSize);
|
||||
}
|
||||
|
||||
Cmd.m_pData = pTmpData;
|
||||
}
|
||||
else
|
||||
{
|
||||
// copy texture data
|
||||
int MemSize = Width*Height*Cmd.m_PixelSize;
|
||||
void *pTmpData = mem_alloc(MemSize, sizeof(void*));
|
||||
mem_copy(pTmpData, pData, MemSize);
|
||||
Cmd.m_pData = pTmpData;
|
||||
}
|
||||
Cmd.m_Flags |= CCommandBuffer::TEXFLAG_TEXTURE3D;
|
||||
|
||||
|
||||
// copy texture data
|
||||
int MemSize = Width*Height*Cmd.m_PixelSize;
|
||||
void *pTmpData = mem_alloc(MemSize, sizeof(void*));
|
||||
mem_copy(pTmpData, pData, MemSize);
|
||||
Cmd.m_pData = pTmpData;
|
||||
|
||||
|
||||
//
|
||||
m_pCommandBuffer->AddCommand(Cmd);
|
||||
|
|
|
@ -97,6 +97,7 @@ public:
|
|||
TEXFLAG_NOMIPMAPS = 1,
|
||||
TEXFLAG_COMPRESSED = 2,
|
||||
TEXFLAG_QUALITY = 4,
|
||||
TEXFLAG_TEXTURE3D = 8,
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -213,7 +214,6 @@ public:
|
|||
|
||||
int m_Width;
|
||||
int m_Height;
|
||||
int m_Depth;
|
||||
int m_PixelSize;
|
||||
int m_Format;
|
||||
int m_StoreFormat;
|
||||
|
|
Loading…
Reference in a new issue