This commit is contained in:
Shinovon 2026-05-12 09:01:52 +05:00
parent dfdd037ed3
commit 6c644421fd
2 changed files with 6 additions and 6 deletions

View file

@ -630,7 +630,7 @@ rasterUnlock(Raster *raster, int32 level)
#endif #endif
) { ) {
// convert to 16-bit // convert to 16-bit
uint16_t* pixels16 = (uint16_t*)rwMalloc(raster->width * raster->height * sizeof(uint16_t)); uint16_t* pixels16 = (uint16_t*)rwMalloc(raster->width * raster->height * sizeof(uint16_t), MEMDUR_FUNCTION | ID_DRIVER);
uint8_t* pixels8 = (uint8_t*)raster->pixels; uint8_t* pixels8 = (uint8_t*)raster->pixels;
for (int i = 0; i < raster->width * raster->height; i++) { for (int i = 0; i < raster->width * raster->height; i++) {
@ -642,7 +642,7 @@ rasterUnlock(Raster *raster, int32 level)
pixels16[i] = ((r >> 4) << 12) | ((g >> 4) << 8) | ((b >> 4) << 4) | (a >> 4); pixels16[i] = ((r >> 4) << 12) | ((g >> 4) << 8) | ((b >> 4) << 4) | (a >> 4);
} }
glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, raster->width, raster->height, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, pixels16); glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, raster->width, raster->height, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, pixels16);
free(pixels16); rwFree(pixels16);
CHECK_GL_ERROR("glTexImage2D 1"); CHECK_GL_ERROR("glTexImage2D 1");
} else } else
{ {

View file

@ -453,7 +453,7 @@ void rasterUnlock(Raster *raster, int32 level){
// flip vertical (igual que antes) // flip vertical (igual que antes)
{ {
int stride = raster->width * natras->bpp; int stride = raster->width * natras->bpp;
uint8_t *tmp = (uint8_t*)rwMalloc(stride); uint8_t *tmp = (uint8_t*)rwMalloc(stride, MEMDUR_FUNCTION | ID_DRIVER);
for(int y = 0; y < raster->height / 2; y++){ for(int y = 0; y < raster->height / 2; y++){
uint8_t *a = (uint8_t*)raster->pixels + y * stride; uint8_t *a = (uint8_t*)raster->pixels + y * stride;
uint8_t *b = (uint8_t*)raster->pixels + (raster->height - 1 - y) * stride; uint8_t *b = (uint8_t*)raster->pixels + (raster->height - 1 - y) * stride;
@ -461,13 +461,13 @@ void rasterUnlock(Raster *raster, int32 level){
memcpy(a, b, stride); memcpy(a, b, stride);
memcpy(b, tmp, stride); memcpy(b, tmp, stride);
} }
free(tmp); rwFree(tmp);
} }
if(!natras->isCompressed){ if(!natras->isCompressed){
if(natras->format == GL_RGBA && natras->type == GL_UNSIGNED_BYTE){ if(natras->format == GL_RGBA && natras->type == GL_UNSIGNED_BYTE){
// convertir RGBA8888 → RGBA4444 // convertir RGBA8888 → RGBA4444
uint16_t *pixels16 = (uint16_t*)rwMalloc(raster->width * raster->height * 2); uint16_t *pixels16 = (uint16_t*)rwMalloc(raster->width * raster->height * 2, MEMDUR_FUNCTION | ID_DRIVER);
uint8_t *pixels8 = (uint8_t*)raster->pixels; uint8_t *pixels8 = (uint8_t*)raster->pixels;
for(int i = 0; i < raster->width * raster->height; i++){ for(int i = 0; i < raster->width * raster->height; i++){
uint8_t r = pixels8[i*4+0]; uint8_t r = pixels8[i*4+0];
@ -479,7 +479,7 @@ void rasterUnlock(Raster *raster, int32 level){
glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA,
raster->width, raster->height, 0, raster->width, raster->height, 0,
GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, pixels16); GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, pixels16);
free(pixels16); rwFree(pixels16);
} else { } else {
glTexImage2D(GL_TEXTURE_2D, level, natras->internalFormat, glTexImage2D(GL_TEXTURE_2D, level, natras->internalFormat,
raster->width, raster->height, 0, raster->width, raster->height, 0,