Skip to content

Commit

Permalink
[Render/Texture2D] Made all recoverImage() calls available with GL ES
Browse files Browse the repository at this point in the history
- This is following its availability in commit 1643846
  • Loading branch information
Razakhel committed Apr 8, 2024
1 parent 70ec6c1 commit 2d9e7ee
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 47 deletions.
2 changes: 0 additions & 2 deletions src/RaZ/Data/ObjSave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ inline void writeAttribute(std::ofstream& file, std::string_view tag, const Rend
file << '\n';
}

#if !defined(USE_OPENGL_ES) // Texture::recoverImage() is unavailable with OpenGL ES
inline void writeTexture(std::ofstream& file, std::string_view tag, const std::string& materialName, std::string_view suffix,
const RenderShaderProgram& program, std::string_view uniformName) {
ZoneScopedN("[ObjSave]::writeTexture");
Expand All @@ -50,7 +49,6 @@ inline void writeTexture(std::ofstream& file, std::string_view tag, const std::s
file << '\t' << tag << ' ' << texturePath << '\n';
ImageFormat::save(texturePath, texture->recoverImage(), true);
}
#endif

void saveMtl(const FilePath& mtlFilePath, const std::vector<Material>& materials) {
ZoneScopedN("[ObjSave]::saveMtl");
Expand Down
2 changes: 0 additions & 2 deletions src/RaZ/Script/LuaTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ void LuaWrapper::registerTextureTypes() {
texture2D["load"] = sol::overload([] (Texture2D& t, const Image& img) { t.load(img); },
PickOverload<const Image&, bool>(&Texture2D::load));
texture2D["fill"] = &Texture2D::fill;
#if !defined(USE_OPENGL_ES)
texture2D["recoverImage"] = &Texture2D::recoverImage;
#endif
}

{
Expand Down
14 changes: 0 additions & 14 deletions tests/src/RaZ/Data/GltfFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ TEST_CASE("GltfFormat load glTF", "[data]") {
REQUIRE(baseColorMap.getColorspace() == Raz::TextureColorspace::RGBA);
REQUIRE(baseColorMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image baseColorImg = baseColorMap.recoverImage();
REQUIRE_FALSE(baseColorImg.isEmpty());

Expand All @@ -75,7 +74,6 @@ TEST_CASE("GltfFormat load glTF", "[data]") {
CHECK(baseColorImg.recoverPixel<uint8_t, 4>(1, 0) == Raz::Vec4b(Raz::Vec3b(Raz::ColorPreset::Green), 127));
CHECK(baseColorImg.recoverPixel<uint8_t, 4>(0, 1) == Raz::Vec4b(Raz::Vec3b(Raz::ColorPreset::Blue), 127));
CHECK(baseColorImg.recoverPixel<uint8_t, 4>(1, 1) == Raz::Vec4b(Raz::Vec3b(Raz::ColorPreset::Red), 127));
#endif
}

{
Expand All @@ -88,7 +86,6 @@ TEST_CASE("GltfFormat load glTF", "[data]") {
REQUIRE(emissiveMap.getColorspace() == Raz::TextureColorspace::RGB);
REQUIRE(emissiveMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image emissiveImg = emissiveMap.recoverImage();
REQUIRE_FALSE(emissiveImg.isEmpty());

Expand All @@ -102,7 +99,6 @@ TEST_CASE("GltfFormat load glTF", "[data]") {
CHECK(emissiveImg.recoverPixel<uint8_t, 3>(1, 0) == Raz::Vec3b(Raz::ColorPreset::Red));
CHECK(emissiveImg.recoverPixel<uint8_t, 3>(0, 1) == Raz::Vec3b(Raz::ColorPreset::Red));
CHECK(emissiveImg.recoverPixel<uint8_t, 3>(1, 1) == Raz::Vec3b(Raz::ColorPreset::Red));
#endif
}

{
Expand All @@ -115,7 +111,6 @@ TEST_CASE("GltfFormat load glTF", "[data]") {
REQUIRE(normalMap.getColorspace() == Raz::TextureColorspace::RGB);
REQUIRE(normalMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image normalImg = normalMap.recoverImage();
REQUIRE_FALSE(normalImg.isEmpty());

Expand All @@ -129,7 +124,6 @@ TEST_CASE("GltfFormat load glTF", "[data]") {
CHECK(normalImg.recoverPixel<uint8_t, 3>(1, 0) == Raz::Vec3b(Raz::ColorPreset::Green));
CHECK(normalImg.recoverPixel<uint8_t, 3>(0, 1) == Raz::Vec3b(Raz::ColorPreset::Green));
CHECK(normalImg.recoverPixel<uint8_t, 3>(1, 1) == Raz::Vec3b(Raz::ColorPreset::Green));
#endif
}

{
Expand All @@ -142,7 +136,6 @@ TEST_CASE("GltfFormat load glTF", "[data]") {
REQUIRE(metallicMap.getColorspace() == Raz::TextureColorspace::GRAY);
REQUIRE(metallicMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image metallicImg = metallicMap.recoverImage();
REQUIRE_FALSE(metallicImg.isEmpty());

Expand All @@ -163,7 +156,6 @@ TEST_CASE("GltfFormat load glTF", "[data]") {
CHECK(metallicImg.recoverPixel<uint8_t>(1, 0) == 0);
CHECK(metallicImg.recoverPixel<uint8_t>(0, 1) == 255);
CHECK(metallicImg.recoverPixel<uint8_t>(1, 1) == 0);
#endif
}

{
Expand All @@ -176,7 +168,6 @@ TEST_CASE("GltfFormat load glTF", "[data]") {
REQUIRE(roughnessMap.getColorspace() == Raz::TextureColorspace::GRAY);
REQUIRE(roughnessMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image roughnessImg = roughnessMap.recoverImage();
REQUIRE_FALSE(roughnessImg.isEmpty());

Expand All @@ -197,7 +188,6 @@ TEST_CASE("GltfFormat load glTF", "[data]") {
CHECK(roughnessImg.recoverPixel<uint8_t>(1, 0) == 255);
CHECK(roughnessImg.recoverPixel<uint8_t>(0, 1) == 0);
CHECK(roughnessImg.recoverPixel<uint8_t>(1, 1) == 0);
#endif
}

{
Expand All @@ -210,7 +200,6 @@ TEST_CASE("GltfFormat load glTF", "[data]") {
REQUIRE(ambientOcclusionMap.getColorspace() == Raz::TextureColorspace::GRAY);
REQUIRE(ambientOcclusionMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image ambientOcclusionImg = ambientOcclusionMap.recoverImage();
REQUIRE_FALSE(ambientOcclusionImg.isEmpty());

Expand All @@ -231,7 +220,6 @@ TEST_CASE("GltfFormat load glTF", "[data]") {
CHECK(ambientOcclusionImg.recoverPixel<uint8_t>(1, 0) == 0);
CHECK(ambientOcclusionImg.recoverPixel<uint8_t>(0, 1) == 0);
CHECK(ambientOcclusionImg.recoverPixel<uint8_t>(1, 1) == 255);
#endif
}
}

Expand Down Expand Up @@ -300,7 +288,6 @@ TEST_CASE("GltfFormat load GLB textured", "[data]") {
REQUIRE(baseColorMap.getColorspace() == Raz::TextureColorspace::RGB);
REQUIRE(baseColorMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image baseColorImg = baseColorMap.recoverImage();
REQUIRE_FALSE(baseColorImg.isEmpty());

Expand All @@ -310,6 +297,5 @@ TEST_CASE("GltfFormat load GLB textured", "[data]") {
CHECK(baseColorImg.recoverPixel<uint8_t, 3>(167, 71) == Raz::Vec3b(255));
CHECK(baseColorImg.recoverPixel<uint8_t, 3>(192, 192) == Raz::Vec3b(92, 135, 39));
CHECK(baseColorImg.recoverPixel<uint8_t, 3>(255, 255) == Raz::Vec3b(220));
#endif
}
}
24 changes: 0 additions & 24 deletions tests/src/RaZ/Data/ObjFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ TEST_CASE("ObjFormat load Blinn-Phong", "[data]") {
CHECK(diffuseMap.getColorspace() == Raz::TextureColorspace::RGBA);
REQUIRE(diffuseMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image diffuseImg = diffuseMap.recoverImage();
REQUIRE_FALSE(diffuseImg.isEmpty());

Expand Down Expand Up @@ -174,7 +173,6 @@ TEST_CASE("ObjFormat load Blinn-Phong", "[data]") {
CHECK(diffuseImg.recoverByteValue(1, 1, 1) == 255);
CHECK(diffuseImg.recoverByteValue(1, 1, 2) == 0);
CHECK(diffuseImg.recoverByteValue(1, 1, 3) == 127);
#endif
}

// Emissive map
Expand All @@ -186,7 +184,6 @@ TEST_CASE("ObjFormat load Blinn-Phong", "[data]") {
CHECK(emissiveMap.getColorspace() == Raz::TextureColorspace::RGB);
REQUIRE(emissiveMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image emissiveImg = emissiveMap.recoverImage();
REQUIRE_FALSE(emissiveImg.isEmpty());

Expand All @@ -211,7 +208,6 @@ TEST_CASE("ObjFormat load Blinn-Phong", "[data]") {
CHECK(emissiveImg.recoverByteValue(1, 1, 0) == 255);
CHECK(emissiveImg.recoverByteValue(1, 1, 1) == 0);
CHECK(emissiveImg.recoverByteValue(1, 1, 2) == 0);
#endif
}

// Ambient map
Expand All @@ -223,7 +219,6 @@ TEST_CASE("ObjFormat load Blinn-Phong", "[data]") {
CHECK(ambientMap.getColorspace() == Raz::TextureColorspace::RGB);
REQUIRE(ambientMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image ambientImg = ambientMap.recoverImage();
REQUIRE_FALSE(ambientImg.isEmpty());

Expand All @@ -248,7 +243,6 @@ TEST_CASE("ObjFormat load Blinn-Phong", "[data]") {
CHECK(ambientImg.recoverByteValue(1, 1, 0) == 0);
CHECK(ambientImg.recoverByteValue(1, 1, 1) == 0);
CHECK(ambientImg.recoverByteValue(1, 1, 2) == 255);
#endif
}

// Specular map
Expand All @@ -260,7 +254,6 @@ TEST_CASE("ObjFormat load Blinn-Phong", "[data]") {
CHECK(specularMap.getColorspace() == Raz::TextureColorspace::GRAY);
REQUIRE(specularMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image specularImg = specularMap.recoverImage();
REQUIRE_FALSE(specularImg.isEmpty());

Expand All @@ -274,7 +267,6 @@ TEST_CASE("ObjFormat load Blinn-Phong", "[data]") {
CHECK(specularImg.recoverByteValue(1, 0, 0) == 255);
CHECK(specularImg.recoverByteValue(0, 1, 0) == 255);
CHECK(specularImg.recoverByteValue(1, 1, 0) == 0);
#endif
}

// Transparency map
Expand All @@ -286,7 +278,6 @@ TEST_CASE("ObjFormat load Blinn-Phong", "[data]") {
CHECK(transparencyMap.getColorspace() == Raz::TextureColorspace::GRAY);
REQUIRE(transparencyMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image transparencyImg = transparencyMap.recoverImage();
REQUIRE_FALSE(transparencyImg.isEmpty());

Expand All @@ -300,7 +291,6 @@ TEST_CASE("ObjFormat load Blinn-Phong", "[data]") {
CHECK(transparencyImg.recoverByteValue(1, 0, 0) == 255);
CHECK(transparencyImg.recoverByteValue(0, 1, 0) == 255);
CHECK(transparencyImg.recoverByteValue(1, 1, 0) == 255);
#endif
}

// Bump map
Expand All @@ -312,7 +302,6 @@ TEST_CASE("ObjFormat load Blinn-Phong", "[data]") {
CHECK(bumpMap.getColorspace() == Raz::TextureColorspace::GRAY);
REQUIRE(bumpMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image bumpImg = bumpMap.recoverImage();
REQUIRE_FALSE(bumpImg.isEmpty());

Expand All @@ -326,7 +315,6 @@ TEST_CASE("ObjFormat load Blinn-Phong", "[data]") {
CHECK(bumpImg.recoverByteValue(1, 0, 0) == 0);
CHECK(bumpImg.recoverByteValue(0, 1, 0) == 0);
CHECK(bumpImg.recoverByteValue(1, 1, 0) == 0);
#endif
}
}

Expand Down Expand Up @@ -392,7 +380,6 @@ TEST_CASE("ObjFormat load Cook-Torrance", "[data]") {
CHECK(albedoMap.getColorspace() == Raz::TextureColorspace::RGBA);
REQUIRE(albedoMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image albedoImg = albedoMap.recoverImage();
REQUIRE_FALSE(albedoImg.isEmpty());

Expand Down Expand Up @@ -423,7 +410,6 @@ TEST_CASE("ObjFormat load Cook-Torrance", "[data]") {
CHECK(albedoImg.recoverByteValue(1, 1, 1) == 255);
CHECK(albedoImg.recoverByteValue(1, 1, 2) == 0);
CHECK(albedoImg.recoverByteValue(1, 1, 3) == 127);
#endif
}

// Emissive map
Expand All @@ -435,7 +421,6 @@ TEST_CASE("ObjFormat load Cook-Torrance", "[data]") {
CHECK(emissiveMap.getColorspace() == Raz::TextureColorspace::RGB);
REQUIRE(emissiveMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image emissiveImg = emissiveMap.recoverImage();
REQUIRE_FALSE(emissiveImg.isEmpty());

Expand All @@ -460,7 +445,6 @@ TEST_CASE("ObjFormat load Cook-Torrance", "[data]") {
CHECK(emissiveImg.recoverByteValue(1, 1, 0) == 255);
CHECK(emissiveImg.recoverByteValue(1, 1, 1) == 0);
CHECK(emissiveImg.recoverByteValue(1, 1, 2) == 0);
#endif
}

// Normal map
Expand All @@ -472,7 +456,6 @@ TEST_CASE("ObjFormat load Cook-Torrance", "[data]") {
CHECK(normalMap.getColorspace() == Raz::TextureColorspace::RGB);
REQUIRE(normalMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image normalImg = normalMap.recoverImage();
REQUIRE_FALSE(normalImg.isEmpty());

Expand All @@ -497,7 +480,6 @@ TEST_CASE("ObjFormat load Cook-Torrance", "[data]") {
CHECK(normalImg.recoverByteValue(1, 1, 0) == 0);
CHECK(normalImg.recoverByteValue(1, 1, 1) == 0);
CHECK(normalImg.recoverByteValue(1, 1, 2) == 255);
#endif
}

// Metallic map
Expand All @@ -509,7 +491,6 @@ TEST_CASE("ObjFormat load Cook-Torrance", "[data]") {
CHECK(metallicMap.getColorspace() == Raz::TextureColorspace::GRAY);
REQUIRE(metallicMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image metallicImg = metallicMap.recoverImage();
REQUIRE_FALSE(metallicImg.isEmpty());

Expand All @@ -523,7 +504,6 @@ TEST_CASE("ObjFormat load Cook-Torrance", "[data]") {
CHECK(metallicImg.recoverByteValue(1, 0, 0) == 255);
CHECK(metallicImg.recoverByteValue(0, 1, 0) == 255);
CHECK(metallicImg.recoverByteValue(1, 1, 0) == 255);
#endif
}

// Roughness map
Expand All @@ -535,7 +515,6 @@ TEST_CASE("ObjFormat load Cook-Torrance", "[data]") {
CHECK(roughnessMap.getColorspace() == Raz::TextureColorspace::GRAY);
REQUIRE(roughnessMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image roughnessImg = roughnessMap.recoverImage();
REQUIRE_FALSE(roughnessImg.isEmpty());

Expand All @@ -549,7 +528,6 @@ TEST_CASE("ObjFormat load Cook-Torrance", "[data]") {
CHECK(roughnessImg.recoverByteValue(1, 0, 0) == 0);
CHECK(roughnessImg.recoverByteValue(0, 1, 0) == 0);
CHECK(roughnessImg.recoverByteValue(1, 1, 0) == 0);
#endif
}

// Ambient occlusion map
Expand All @@ -561,7 +539,6 @@ TEST_CASE("ObjFormat load Cook-Torrance", "[data]") {
CHECK(ambientOcclusionMap.getColorspace() == Raz::TextureColorspace::GRAY);
REQUIRE(ambientOcclusionMap.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image ambientOcclusionImg = ambientOcclusionMap.recoverImage();
REQUIRE_FALSE(ambientOcclusionImg.isEmpty());

Expand All @@ -575,7 +552,6 @@ TEST_CASE("ObjFormat load Cook-Torrance", "[data]") {
CHECK(ambientOcclusionImg.recoverByteValue(1, 0, 0) == 255);
CHECK(ambientOcclusionImg.recoverByteValue(0, 1, 0) == 255);
CHECK(ambientOcclusionImg.recoverByteValue(1, 1, 0) == 0);
#endif
}
}

Expand Down
2 changes: 0 additions & 2 deletions tests/src/RaZ/Render/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ TEST_CASE("Texture2D load image") {
CHECK(texture2D.getColorspace() == Raz::TextureColorspace::GRAY);
CHECK(texture2D.getDataType() == Raz::TextureDataType::BYTE);

#if !defined(USE_OPENGL_ES)
const Raz::Image textureImg = texture2D.recoverImage();
REQUIRE_FALSE(textureImg.isEmpty());
REQUIRE(textureImg.getWidth() == 2);
Expand All @@ -191,7 +190,6 @@ TEST_CASE("Texture2D load image") {
CHECK(textureImg.recoverPixel<uint8_t>(1, 0) == 1);
CHECK(textureImg.recoverPixel<uint8_t>(0, 1) == 2);
CHECK(textureImg.recoverPixel<uint8_t>(1, 1) == 3);
#endif
}

TEST_CASE("Texture3D load image slices") {
Expand Down
4 changes: 1 addition & 3 deletions tests/src/RaZ/Script/LuaRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,9 +946,6 @@ TEST_CASE("LuaRender Texture", "[script][lua][render]") {
tex1D:resize(2)
tex1D:fill(ColorPreset.Red)
assert(tex1D:getWidth() == 2)
local tex2D = Texture2D.new(1, 1, TextureColorspace.RGB)
assert(tex2D:recoverImage():getChannelCount() == 3)
)"));
#endif

Expand Down Expand Up @@ -990,6 +987,7 @@ TEST_CASE("LuaRender Texture", "[script][lua][render]") {
tex2D:fill(ColorPreset.Green)
assert(tex2D:getWidth() == 2)
assert(tex2D:getHeight() == 2)
assert(tex2D:recoverImage():getChannelCount() == 3)
local tex3D = Texture3D.new(TextureColorspace.INVALID)
tex3D = Texture3D.new(TextureColorspace.RGBA, TextureDataType.BYTE)
Expand Down

0 comments on commit 2d9e7ee

Please sign in to comment.