Skip to content

Commit

Permalink
Drop PVRTC texture support
Browse files Browse the repository at this point in the history
Compressed image format that used to be used for iOS.
  • Loading branch information
rollerozxa committed Feb 25, 2024
1 parent 175160b commit d565ff4
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 129 deletions.
42 changes: 0 additions & 42 deletions src/src/material.cc
Original file line number Diff line number Diff line change
Expand Up @@ -624,14 +624,6 @@ material_factory::load_bg_texture(bool soft)
tms_warnf("Loading backup bg, 0. %s was not available.", bgname);
}

tex_bg->wrap = GL_REPEAT;
tms_texture_set_filtering(tex_bg, GL_LINEAR);
#elif defined TMS_BACKEND_IOS
sprintf(bgname, "data-ios/bg/%d.pvr", material_factory::background_id);

if (tex_bg->load_pvrtc(bgname) != T_OK)
tex_bg->load_pvrtc("data-ios/bg/0.pvr");

tex_bg->wrap = GL_REPEAT;
tms_texture_set_filtering(tex_bg, GL_LINEAR);
#else
Expand Down Expand Up @@ -664,8 +656,6 @@ material_factory::load_bg_texture(bool soft)
TEX_LAZYLOAD_FN(tpixel,
#ifdef TMS_BACKEND_ANDROID
tex_tpixel->load_etc1("data-mobile/textures/tpixel.pkm");
#elif defined TMS_BACKEND_IOS
tex_tpixel->load_pvrtc("data-ios/textures/tpixel.pvr");
#else
tms_texture_load(tex_tpixel,"data-pc/textures/tpixel.jpg");
tex_tpixel->format = GL_RGB;
Expand All @@ -679,8 +669,6 @@ TEX_LAZYLOAD_FN(tpixel,
TEX_LAZYLOAD_FN(decoration,
#ifdef TMS_BACKEND_ANDROID
tex_decoration->load_etc1("data-mobile/textures/decorations.pkm");
#elif defined TMS_BACKEND_IOS
tex_decoration->load_pvrtc("data-ios/textures/decorations.pvr");
#else
tms_texture_load(tex_decoration,"data-pc/textures/decorations.jpg");
tex_decoration->format = GL_RGB;
Expand Down Expand Up @@ -722,9 +710,6 @@ TEX_LAZYLOAD_FN(wood,
#ifdef TMS_BACKEND_ANDROID
tex_wood->load_etc1("data-mobile/textures/wood.pkm");
tms_texture_set_filtering(tex_wood, GL_NEAREST);
#elif defined TMS_BACKEND_IOS
tex_wood->load_pvrtc("data-ios/textures/wood.pvr");
tms_texture_set_filtering(tex_wood, GL_LINEAR);
#else
tex_wood->load("data-pc/textures/wood.jpg");
tex_wood->format = GL_RGB;
Expand All @@ -739,9 +724,6 @@ TEX_LAZYLOAD_FN(bark,
#ifdef TMS_BACKEND_ANDROID
tex_bark->load_etc1("data-mobile/textures/bark-2.pkm");
tms_texture_set_filtering(tex_bark, GL_LINEAR);
#elif defined TMS_BACKEND_IOS
tex_bark->load_pvrtc("data-ios/textures/bark-2.pvr");
tms_texture_set_filtering(tex_bark, GL_LINEAR);
#else
tex_bark->load("data-pc/textures/bark-2.jpg");
tex_bark->format = GL_RGB;
Expand All @@ -756,9 +738,6 @@ TEX_LAZYLOAD_FN(rubber,
#ifdef TMS_BACKEND_ANDROID
tex_rubber->load_etc1("data-mobile/textures/rubber.pkm");
tms_texture_set_filtering(tex_rubber, GL_LINEAR);
#elif defined TMS_BACKEND_IOS
tex_rubber->load_pvrtc("data-ios/textures/rubber.pvr");
tms_texture_set_filtering(tex_rubber, GL_LINEAR);
#else
tex_rubber->load("data-pc/textures/rubber.jpg");
tex_rubber->format = GL_RGB;
Expand All @@ -773,9 +752,6 @@ TEX_LAZYLOAD_FN(bedrock,
#ifdef TMS_BACKEND_ANDROID
tex_bedrock->load_etc1("data-mobile/textures/bedrock.pkm");
tms_texture_set_filtering(tex_bedrock, GL_LINEAR);
#elif defined TMS_BACKEND_IOS
tex_bedrock->load_pvrtc("data-ios/textures/bedrock.pvr");
tms_texture_set_filtering(tex_bedrock, GL_LINEAR);
#else
tex_bedrock->load("data-pc/textures/bedrock.jpg");
tex_bedrock->format = GL_RGB;
Expand All @@ -790,9 +766,6 @@ TEX_LAZYLOAD_FN(reflection,
#ifdef TMS_BACKEND_ANDROID
tex_reflection->load_etc1("data-mobile/textures/reflection.pkm");
tms_texture_set_filtering(tex_reflection, GL_LINEAR);
#elif defined TMS_BACKEND_IOS
tex_reflection->load_pvrtc("data-ios/textures/reflection.pvr");
tms_texture_set_filtering(tex_reflection, GL_LINEAR);
#else
tex_reflection->load("data-pc/textures/reflection.jpg");
tex_reflection->format = GL_RGB;
Expand Down Expand Up @@ -906,9 +879,6 @@ TEX_LAZYLOAD_FN(wmotor,
#ifdef TMS_BACKEND_ANDROID
tex_wmotor->load_etc1("data-mobile/textures/wmotor.pkm");
tms_texture_set_filtering(tex_wmotor, GL_LINEAR);
#elif defined(TMS_BACKEND_IOS)
tex_wmotor->load_pvrtc("data-ios/textures/wmotor.pvr");
tms_texture_set_filtering(tex_wmotor, GL_LINEAR);
#else
tex_wmotor->gamma_correction = settings["gamma_correct"]->v.b;
tex_wmotor->format = GL_RGB;
Expand All @@ -922,9 +892,6 @@ TEX_LAZYLOAD_FN(metal,
#ifdef TMS_BACKEND_ANDROID
tex_metal->load_etc1("data-mobile/textures/metal.pkm");
tms_texture_set_filtering(tex_metal, GL_LINEAR);
#elif defined TMS_BACKEND_IOS
tex_metal->load_pvrtc("data-ios/textures/metal.pvr");
tms_texture_set_filtering(tex_metal, GL_LINEAR);
#else
tex_metal->load("data-pc/textures/metal.jpg");
tex_metal->format = GL_RGB;
Expand Down Expand Up @@ -990,9 +957,6 @@ TEX_LAZYLOAD_FN(rackhouse,
#if (defined TMS_BACKEND_ANDROID)
tex_rackhouse->load_etc1("data-mobile/textures/rackhouse.pkm");
tms_texture_set_filtering(tex_rackhouse, GL_LINEAR);
#elif defined TMS_BACKEND_IOS
tex_rackhouse->load_pvrtc("data-ios/textures/rackhouse.pvr");
tms_texture_set_filtering(tex_rackhouse, GL_LINEAR);
#else
tex_rackhouse->load("data-pc/textures/rackhouse.jpg");
tex_rackhouse->format = GL_RGB;
Expand Down Expand Up @@ -1039,9 +1003,6 @@ TEX_LAZYLOAD_FN(breadboard,
#ifdef TMS_BACKEND_ANDROID
tex_breadboard->load_etc1("data-mobile/textures/breadboard.pkm");
tms_texture_set_filtering(tex_breadboard, GL_LINEAR);
#elif defined(TMS_BACKEND_IOS)
tex_breadboard->load_pvrtc("data-ios/textures/breadboard.pvr");
tms_texture_set_filtering(tex_breadboard, GL_LINEAR);
#else
tex_breadboard->gamma_correction = settings["gamma_correct"]->v.b;
tex_breadboard->format = GL_RGB;
Expand All @@ -1063,9 +1024,6 @@ TEX_LAZYLOAD_FN(border,
#ifdef TMS_BACKEND_ANDROID
tex_border->load_etc1("data-mobile/textures/border.pkm");
tms_texture_set_filtering(tex_border, GL_LINEAR);
#elif defined TMS_BACKEND_IOS
tex_border->load_pvrtc("data-ios/textures/border.pvr");
tms_texture_set_filtering(tex_border, GL_LINEAR);
#else
tex_border->load("data-pc/textures/border.jpg");
tex_border->format = GL_RGB;
Expand Down
5 changes: 1 addition & 4 deletions src/src/menu_pkg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,14 @@ menu_pkg::set_pkg(int type, uint32_t id)
int
menu_pkg::resume(void)
{
tms_infof("RESUMEE MENUPK");
tms_infof("Resume menu_pkg");
if (_tex_bg) tms_texture_free(_tex_bg);
if (tex_overlay) tms_texture_free(tex_overlay);

_tex_bg = tms_texture_alloc();
#ifdef TMS_BACKEND_ANDROID
tms_texture_load_etc1(_tex_bg, "data-mobile/textures/pkgmenubg.pkm");
tms_texture_set_filtering(_tex_bg, GL_LINEAR);
#elif defined TMS_BACKEND_IOS
tms_texture_load_pvrtc_4bpp(_tex_bg, "data-ios/textures/pkgmenubg.pvr");
tms_texture_set_filtering(_tex_bg, GL_LINEAR);
#else
tms_texture_load(_tex_bg, "data-pc/textures/pkgmenubg.png");
_tex_bg->format = GL_RGBA;
Expand Down
2 changes: 0 additions & 2 deletions src/src/menu_shared.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ menu_shared::init()

#ifdef TMS_BACKEND_ANDROID
tex->load_etc1("data-mobile/textures/menu/menu_bg.pkm");
#elif defined(TMS_BACKEND_IOS)
tex->load_pvrtc("data-ios/textures/menu_bg.pvr");
#else
tex->gamma_correction = 0;
tex->load("data-pc/textures/menu/menu_bg.jpg");
Expand Down
5 changes: 0 additions & 5 deletions src/tms/bindings/cpp/cpp.hh
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ namespace tms
return tms_texture_load_etc1(this, filename);
}

inline int load_pvrtc(const char *filename)
{
return tms_texture_load_pvrtc_4bpp(this, filename);
}

inline int load(const char *filename)
{
return tms_texture_load(this, filename);
Expand Down
74 changes: 0 additions & 74 deletions src/tms/core/texture.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,6 @@ struct etc1_header {
} __attribute__ ((__packed__));
#endif

#ifdef TMS_BACKEND_IOS
struct pvrtc_header {
uint32_t header_length;
uint32_t height;
uint32_t width;
uint32_t num_mipmaps;
uint32_t flags;
uint32_t datalength;
uint32_t bpp;
uint32_t bitmask_r;
uint32_t bitmask_g;
uint32_t bitmask_b;
uint32_t bitmask_a;
uint32_t pvrtag;
uint32_t numsurfs;
} __attribute__ ((__packed__));
#endif

struct tms_texture*
tms_texture_alloc(void)
{
Expand Down Expand Up @@ -155,56 +137,6 @@ int tms_texture_free_buffer(struct tms_texture *tex)
return T_OK;
}

/**
* Load pvrtc 4bbp image
**/
int
tms_texture_load_pvrtc_4bpp(struct tms_texture *tex, const char *filename)
{
#ifdef TMS_BACKEND_IOS
SDL_RWops *rw = SDL_RWFromFile(filename, "rb");

tms_infof("Load PVRTC 4BPP: %s", filename);

if (rw) {
long size;
SDL_RWseek(rw, 0, SEEK_END);
size = SDL_RWtell(rw);
SDL_RWseek(rw, 0, SEEK_SET);

/* XXX free previous? */
if (size > 4*1024*1024 || size < sizeof(struct etc1_header) + 20)
tms_fatalf("invalid file size");

struct pvrtc_header header;
SDL_RWread(rw, &header, sizeof(struct pvrtc_header), 1);
tex->data = malloc(size - sizeof(struct pvrtc_header));
SDL_RWread(rw, tex->data, 1, size-sizeof(struct pvrtc_header));

//tex->width = ntohs(header.width);
//tex->height = ntohs(header.height);
tex->width = header.width;
tex->height = header.height;
tex->num_channels = 3;
tex->is_buffered = 1;
tex->gamma_correction = 0;
tex->format = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG_OES;
tex->buf_size = size-sizeof(struct pvrtc_header);

if (tex->width <= 0 || tex->height <= 0)
tms_fatalf("invalid pvrtc texture dimensions");

SDL_RWclose(rw);

return T_OK;
} else
tms_errorf("Unable to open texture: '%s'", SDL_GetError());

#endif

return T_COULD_NOT_OPEN;
}

/**
* Load a compressed image
**/
Expand Down Expand Up @@ -604,12 +536,6 @@ tms_texture_upload(struct tms_texture *tex)
GL_ETC1_RGB8_OES,
tex->width, tex->height,
0, tex->buf_size, tex->data);
} else if (tex->format == GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG_OES) {
//tms_infof("uploading compressed image");
glCompressedTexImage2D(GL_TEXTURE_2D, 0,
GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG_OES,
tex->width, tex->height,
0, tex->buf_size, tex->data);
} else {
glTexImage2D(GL_TEXTURE_2D, 0, format,
tex->width, tex->height,
Expand Down
2 changes: 0 additions & 2 deletions src/tms/core/texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#define TMS_MIPMAP -1

#define GL_ETC1_RGB8_OES 0x8D64
#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG_OES 0x8c00

struct tms_context;

Expand Down Expand Up @@ -48,7 +47,6 @@ int tms_texture_clear_buffer(struct tms_texture *tex, unsigned char clear_value)
int tms_texture_free_buffer(struct tms_texture *tex);
int tms_texture_load(struct tms_texture *tex, const char *filename);
int tms_texture_load_etc1(struct tms_texture *tex, const char *filename);
int tms_texture_load_pvrtc_4bpp(struct tms_texture *tex, const char *filename);
int tms_texture_load_mem(struct tms_texture *tex, const char *buf, int width, int height, int num_channels);
int tms_texture_load_mem2(struct tms_texture *tex, const char *buf, size_t size, int freesrc);
int tms_texture_upload(struct tms_texture *tex);
Expand Down

0 comments on commit d565ff4

Please sign in to comment.