MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _store_pfm

Method _store_pfm

modules/lightmapper_rd/lightmapper_rd.cpp:857–877  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

855}
856
857Error LightmapperRD::_store_pfm(RenderingDevice *p_rd, RID p_atlas_tex, int p_index, const Size2i &p_atlas_size, const String &p_name, bool p_shadowmask) {
858 Vector<uint8_t> data = p_rd->texture_get_data(p_atlas_tex, p_index);
859 Ref<Image> img = Image::create_from_data(p_atlas_size.width, p_atlas_size.height, false, p_shadowmask ? Image::FORMAT_RGBA8 : Image::FORMAT_RGBAH, data);
860 img->convert(Image::FORMAT_RGBF);
861 Vector<uint8_t> data_float = img->get_data();
862
863 Error err = OK;
864 Ref<FileAccess> file = FileAccess::open(p_name, FileAccess::WRITE, &err);
865 ERR_FAIL_COND_V_MSG(err, err, vformat("Can't save PFN at path: '%s'.", p_name));
866 file->store_line("PF");
867 file->store_line(vformat("%d %d", img->get_width(), img->get_height()));
868#ifdef BIG_ENDIAN_ENABLED
869 file->store_line("1.0");
870#else
871 file->store_line("-1.0");
872#endif
873 file->store_buffer(data_float);
874 file->close();
875
876 return OK;
877}
878
879Ref<Image> LightmapperRD::_read_pfm(const String &p_name, bool p_shadowmask) {
880 Error err = OK;

Callers

nothing calls this directly

Calls 9

vformatFunction · 0.85
texture_get_dataMethod · 0.80
store_lineMethod · 0.80
closeMethod · 0.65
convertMethod · 0.45
get_dataMethod · 0.45
get_widthMethod · 0.45
get_heightMethod · 0.45
store_bufferMethod · 0.45

Tested by

no test coverage detected