Merge data-pc into data

Android now uses the JPEG textures that the PC version used, instead of the ETC1 encoded images in `data-mobile`. ETC1 texture loading is also removed as it is now unused.
This commit is contained in:
ROllerozxa 2025-03-04 22:50:32 +01:00
commit 7e7aca613f
59 changed files with 25 additions and 173 deletions

View file

@ -301,7 +301,7 @@ endif()
# ------------
if(EMSCRIPTEN)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "--preload-file ../data-pc/ --preload-file ../data/")
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "--preload-file ../data/")
target_link_libraries(${PROJECT_NAME} -lemsocket -lssl -lcrypto)
endif()
@ -312,7 +312,6 @@ if(APPLE)
set(BINDIR ${BUNDLE_NAME}/Contents/MacOS)
set(SHAREDIR ${BUNDLE_NAME}/Contents/Resources)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data-pc" DESTINATION "${SHAREDIR}")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data" DESTINATION "${SHAREDIR}")
install(FILES "packaging/principia.icns" DESTINATION "${SHAREDIR}")
@ -323,7 +322,6 @@ else()
set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}")
set(BINDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data-pc" DESTINATION "${SHAREDIR}/principia")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data" DESTINATION "${SHAREDIR}/principia")
install(FILES "packaging/principia.desktop" DESTINATION "${SHAREDIR}/applications")

View file

@ -1 +0,0 @@
../../../../data-mobile

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

Before

Width:  |  Height:  |  Size: 759 KiB

After

Width:  |  Height:  |  Size: 759 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 592 KiB

After

Width:  |  Height:  |  Size: 592 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 236 KiB

After

Width:  |  Height:  |  Size: 236 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 401 KiB

After

Width:  |  Height:  |  Size: 401 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 260 KiB

After

Width:  |  Height:  |  Size: 260 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 260 KiB

After

Width:  |  Height:  |  Size: 260 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 268 KiB

After

Width:  |  Height:  |  Size: 268 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 669 KiB

After

Width:  |  Height:  |  Size: 669 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 584 KiB

After

Width:  |  Height:  |  Size: 584 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 376 KiB

After

Width:  |  Height:  |  Size: 376 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 503 KiB

After

Width:  |  Height:  |  Size: 503 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 139 KiB

After

Width:  |  Height:  |  Size: 139 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 110 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 179 KiB

After

Width:  |  Height:  |  Size: 179 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 407 KiB

After

Width:  |  Height:  |  Size: 407 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before After
Before After

View file

@ -71,7 +71,6 @@ Section "Core Files (required)" SecCore
File /r "release\lib"
File /r "release\share"
File /r /x build-android "..\data-pc"
File /r /x build-android "..\data"
WriteRegStr HKCR "principia" "" "URL:Principia"

View file

@ -3900,7 +3900,7 @@ game::render_controls_help()
if (!this->tex_controls) {
this->tex_controls = new tms::texture();
this->tex_controls->format = GL_RGBA;
this->tex_controls->load("data-pc/textures/controls.png");
this->tex_controls->load("data/textures/controls.png");
this->tex_controls->upload();
}

View file

@ -596,28 +596,16 @@ material_factory::load_bg_texture(bool soft)
default:
{
#ifdef TMS_BACKEND_ANDROID
sprintf(bgname, "data-mobile/bg/%d.pkm", material_factory::background_id);
if (tex_bg->load_etc1(bgname) != T_OK) {
tex_bg->load_etc1("data-mobile/bg/0.pkm");
tms_warnf("Loading backup bg, 0. %s was not available.", bgname);
}
tex_bg->wrap = GL_REPEAT;
tms_texture_set_filtering(tex_bg, GL_LINEAR);
#else
sprintf(bgname, "data-pc/bg/%d.jpg", material_factory::background_id);
sprintf(bgname, "data/bg/%d.jpg", material_factory::background_id);
if (tex_bg->load(bgname) != T_OK)
tex_bg->load("data-pc/bg/0.jpg");
tex_bg->load("data/bg/0.jpg");
tex_bg->format = GL_RGB;
tex_bg->wrap = GL_REPEAT;
tms_texture_set_filtering(tex_bg, GL_LINEAR);
tex_bg->gamma_correction = settings["gamma_correct"]->v.b;
#endif
}
break;
}
@ -634,26 +622,18 @@ material_factory::load_bg_texture(bool soft)
body }
TEX_LAZYLOAD_FN(tpixel,
#ifdef TMS_BACKEND_ANDROID
tex_tpixel->load_etc1("data-mobile/textures/tpixel.pkm");
#else
tms_texture_load(tex_tpixel,"data-pc/textures/tpixel.jpg");
tms_texture_load(tex_tpixel,"data/textures/tpixel.jpg");
tex_tpixel->format = GL_RGB;
tex_tpixel->gamma_correction = settings["gamma_correct"]->v.b;
#endif
tms_texture_set_filtering(tex_tpixel, GL_LINEAR);
tms_texture_upload(tex_tpixel);
tms_texture_free_buffer(tex_tpixel);
)
TEX_LAZYLOAD_FN(decoration,
#ifdef TMS_BACKEND_ANDROID
tex_decoration->load_etc1("data-mobile/textures/decorations.pkm");
#else
tms_texture_load(tex_decoration,"data-pc/textures/decorations.jpg");
tms_texture_load(tex_decoration,"data/textures/decorations.jpg");
tex_decoration->format = GL_RGB;
tex_decoration->gamma_correction = settings["gamma_correct"]->v.b;
#endif
tms_texture_set_filtering(tex_decoration, GL_LINEAR);
tms_texture_upload(tex_decoration);
tms_texture_free_buffer(tex_decoration);
@ -687,71 +667,46 @@ TEX_LAZYLOAD_FN(animal,
)
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);
#else
tex_wood->load("data-pc/textures/wood.jpg");
tex_wood->load("data/textures/wood.jpg");
tex_wood->format = GL_RGB;
tms_texture_set_filtering(tex_wood, TMS_MIPMAP);
tex_wood->gamma_correction = settings["gamma_correct"]->v.b;
#endif
tex_wood->upload();
tms_texture_free_buffer(tex_wood);
)
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);
#else
tex_bark->load("data-pc/textures/bark-2.jpg");
tex_bark->load("data/textures/bark-2.jpg");
tex_bark->format = GL_RGB;
tms_texture_set_filtering(tex_bark, TMS_MIPMAP);
tex_bark->gamma_correction = settings["gamma_correct"]->v.b;
#endif
tex_bark->upload();
tms_texture_free_buffer(tex_bark);
)
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);
#else
tex_rubber->load("data-pc/textures/rubber.jpg");
tex_rubber->load("data/textures/rubber.jpg");
tex_rubber->format = GL_RGB;
tms_texture_set_filtering(tex_rubber, TMS_MIPMAP);
tex_rubber->gamma_correction = settings["gamma_correct"]->v.b;
#endif
tex_rubber->upload();
tms_texture_free_buffer(tex_rubber);
)
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);
#else
tex_bedrock->load("data-pc/textures/bedrock.jpg");
tex_bedrock->load("data/textures/bedrock.jpg");
tex_bedrock->format = GL_RGB;
tms_texture_set_filtering(tex_bedrock, TMS_MIPMAP);
tex_bedrock->gamma_correction = settings["gamma_correct"]->v.b;
#endif
tex_bedrock->upload();
tms_texture_free_buffer(tex_bedrock);
)
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);
#else
tex_reflection->load("data-pc/textures/reflection.jpg");
tex_reflection->load("data/textures/reflection.jpg");
tex_reflection->format = GL_RGB;
tms_texture_set_filtering(tex_reflection, GL_LINEAR);
tex_reflection->gamma_correction = settings["gamma_correct"]->v.b;
#endif
tex_reflection->upload();
tms_texture_free_buffer(tex_reflection);
)
@ -856,28 +811,18 @@ TEX_LAZYLOAD_FN(misc,
)
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);
#else
tex_wmotor->gamma_correction = settings["gamma_correct"]->v.b;
tex_wmotor->format = GL_RGB;
tex_wmotor->load("data-pc/textures/wmotor.png");
#endif
tex_wmotor->load("data/textures/wmotor.png");
tex_wmotor->upload();
tms_texture_free_buffer(tex_wmotor);
)
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);
#else
tex_metal->load("data-pc/textures/metal.jpg");
tex_metal->load("data/textures/metal.jpg");
tex_metal->format = GL_RGB;
tms_texture_set_filtering(tex_metal, TMS_MIPMAP);
tex_metal->gamma_correction = settings["gamma_correct"]->v.b;
#endif
tex_metal->upload();
tms_texture_free_buffer(tex_metal);
)
@ -934,15 +879,10 @@ TEX_LAZYLOAD_FN(smallpanel,
)
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);
#else
tex_rackhouse->load("data-pc/textures/rackhouse.jpg");
tex_rackhouse->load("data/textures/rackhouse.jpg");
tex_rackhouse->format = GL_RGB;
tms_texture_set_filtering(tex_rackhouse, TMS_MIPMAP);
tex_rackhouse->gamma_correction = settings["gamma_correct"]->v.b;
#endif
tex_rackhouse->upload();
tms_texture_free_buffer(tex_rackhouse);
)
@ -980,14 +920,9 @@ TEX_LAZYLOAD_FN(cpad,
)
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);
#else
tex_breadboard->gamma_correction = settings["gamma_correct"]->v.b;
tex_breadboard->format = GL_RGB;
tex_breadboard->load("data-pc/textures/breadboard.jpg");
#endif
tex_breadboard->load("data/textures/breadboard.jpg");
tex_breadboard->upload();
tms_texture_free_buffer(tex_breadboard);
)
@ -1001,15 +936,10 @@ TEX_LAZYLOAD_FN(cup_ao,
)
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);
#else
tex_border->load("data-pc/textures/border.jpg");
tex_border->load("data/textures/border.jpg");
tex_border->format = GL_RGB;
tms_texture_set_filtering(tex_border, TMS_MIPMAP);
tex_border->gamma_correction = settings["gamma_correct"]->v.b;
#endif
tex_border->upload();
tms_texture_free_buffer(tex_border);
)

View file

@ -99,11 +99,6 @@ namespace tms
}
}
inline int load_etc1(const char *filename)
{
return tms_texture_load_etc1(this, filename);
}
inline int load(const char *filename)
{
return tms_texture_load(this, filename);
@ -477,7 +472,7 @@ namespace tms
return reinterpret_cast<varray*>(static_cast<tms_mesh*>(this)->vertex_array);
}
inline void set_primitive_type(int type)
inline void set_primitive_type(int type)
{
tms_mesh_set_primitive_type(static_cast<tms_mesh*>(this), type);
}

View file

@ -9,17 +9,6 @@
#include "SDL_image.h"
#ifdef TMS_BACKEND_ANDROID
struct etc1_header {
char tag[6];
uint16_t format;
uint16_t width;
uint16_t height;
uint16_t original_width;
uint16_t original_height;
} __attribute__ ((__packed__));
#endif
struct tms_texture*
tms_texture_alloc(void)
{
@ -136,55 +125,6 @@ int tms_texture_free_buffer(struct tms_texture *tex)
return T_OK;
}
/**
* Load a compressed image
**/
int
tms_texture_load_etc1(struct tms_texture *tex,
const char *filename)
{
#ifdef TMS_BACKEND_ANDROID
SDL_RWops *rw = SDL_RWFromFile(filename,"rb");
tms_infof("Load ETC1: %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 etc1_header header;
SDL_RWread(rw, &header, sizeof(struct etc1_header), 1);
tex->data = malloc(size - sizeof(struct etc1_header));
SDL_RWread(rw, tex->data, 1, size-sizeof(struct etc1_header));
tex->width = ntohs(header.width);
tex->height = ntohs(header.height);
tex->num_channels = 3;
tex->is_buffered = 1;
tex->gamma_correction = 0;
tex->format = GL_ETC1_RGB8_OES;
tex->buf_size = size-sizeof(struct etc1_header);
if (tex->width <= 0 || tex->height <= 0)
tms_fatalf("invalid etc1 texture dimensions");
SDL_RWclose(rw);
return T_OK;
} else
tms_errorf("Unable to open texture: '%s'", SDL_GetError());
#endif
return T_COULD_NOT_OPEN;
}
/**
* Read texture from the given file.
* @relates tms_texture
@ -496,16 +436,10 @@ tms_texture_upload(struct tms_texture *tex)
}
#endif
if (tex->format == GL_ETC1_RGB8_OES) {
glCompressedTexImage2D(GL_TEXTURE_2D, 0,
GL_ETC1_RGB8_OES,
tex->width, tex->height,
0, tex->buf_size, tex->data);
} else {
glTexImage2D(GL_TEXTURE_2D, 0, format,
tex->width, tex->height,
0, colors, GL_UNSIGNED_BYTE, tex->data);
}
glTexImage2D(GL_TEXTURE_2D, 0, format,
tex->width, tex->height,
0, colors, GL_UNSIGNED_BYTE, tex->data);
#ifdef DEBUG_TEXTURES
tms_debugf("tex upload: %d: (%dx%d), f:%d, c:%d (%s)", glGetError(), tex->width, tex->height, tex->format, colors, tex->filename?tex->filename:"");
#endif

View file

@ -7,8 +7,6 @@
#define TMS_MIPMAP -1
#define GL_ETC1_RGB8_OES 0x8D64
struct tms_texture {
char *filename;
unsigned char *data;
@ -45,7 +43,6 @@ unsigned char* tms_texture_get_buffer(struct tms_texture *tex);
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_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);

View file

@ -11,7 +11,7 @@ for ((i = 0; i < $NUM_TEXTURES; i ++)); do
convert tmp_alpha.png tmp_shadow.png -compose DstOver +repage -gravity center +repage -composite tmp_composite.png
convert tmp_composite.png -background 'rgb(54,54,54)' -flatten -alpha Off ../data/textures/sandbox-menu-$i.png
#gimp ../data-pc/textures/sandbox-menu-$i.jpg
#gimp ../data/textures/sandbox-menu-$i.jpg
rm tmp.png mask.png tmp_alpha.png tmp_shadow.png
rm tmp_composite.png
@ -26,14 +26,14 @@ done
#convert tmp_alpha.png -background black -shadow 80x3+0+0 tmp_shadow.png
#convert tmp_alpha.png tmp_shadow.png -compose DstOver +repage -gravity center +repage -composite tmp_composite.png
#convert tmp_composite.png -background 'rgb(54,54,54)' -flatten -alpha Off ../data-pc/textures/items.jpg
#cp tmp_composite.png ../data-pc/textures/items.png
#convert tmp_composite.png -background 'rgb(54,54,54)' -flatten -alpha Off ../data/textures/items.jpg
#cp tmp_composite.png ../data/textures/items.png
convert items.png +clone -background black -shadow 100x3+0+0 -composite test.png
convert items.png test.png -compose DstOver +repage -gravity center +repage -composite ../data/textures/menu_items.png
#convert items.png \( +clone -background black -shadow 100x3+0+0 \)\
# -compose DstOver +swap -background none -layers merge -gravity center +repage ../data-pc/textures/items.png
# -compose DstOver +swap -background none -layers merge -gravity center +repage ../data/textures/items.png
#rm tmp.png mask.png tmp_alpha.png tmp_shadow.png
#rm tmp_composite.png