• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Razakhel / RaZ / 9244753701

26 May 2024 01:22PM UTC coverage: 79.407% (+0.02%) from 79.389%
9244753701

push

github

Razakhel
[Shaders] Removed the manual gamma decoding on texture read

- As the color-purposed textures should now properly be treated as sRGB(A), it is not needed anymore

- Added a temporary gamma encoding after each shader when missing, as now everything is properly computed linearly and needs to be corrected before being displayed
  - This will later be replaced by a final render pass

7959 of 10023 relevant lines covered (79.41%)

2118.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.83
/src/RaZ/Script/LuaTexture.cpp
1
#include "RaZ/Data/Color.hpp"
2
#include "RaZ/Data/Image.hpp"
3
#include "RaZ/Render/Texture.hpp"
4
#include "RaZ/Script/LuaWrapper.hpp"
5
#include "RaZ/Utils/TypeUtils.hpp"
6

7
#define SOL_ALL_SAFETIES_ON 1
8
#include "sol/sol.hpp"
9

10
namespace Raz {
11

12
using namespace TypeUtils;
13

14
void LuaWrapper::registerTextureTypes() {
2✔
15
  sol::state& state = getState();
2✔
16

17
  {
18
    sol::usertype<Texture> texture = state.new_usertype<Texture>("Texture", sol::no_constructor);
2✔
19
    texture["getIndex"]      = &Texture::getIndex;
2✔
20
    texture["getColorspace"] = &Texture::getColorspace;
2✔
21
    texture["getDataType"]   = &Texture::getDataType;
2✔
22
    texture["bind"]          = &Texture::bind;
2✔
23
    texture["unbind"]        = &Texture::unbind;
2✔
24
    texture["setFilter"]     = sol::overload(PickOverload<TextureFilter>(&Texture::setFilter),
2✔
25
                                             PickOverload<TextureFilter, TextureFilter>(&Texture::setFilter),
2✔
26
                                             PickOverload<TextureFilter, TextureFilter, TextureFilter>(&Texture::setFilter));
4✔
27
    texture["setWrapping"]   = &Texture::setWrapping;
2✔
28
    texture["setColorspace"] = sol::overload(PickOverload<TextureColorspace>(&Texture::setColorspace),
2✔
29
                                             PickOverload<TextureColorspace, TextureDataType>(&Texture::setColorspace));
4✔
30
  }
2✔
31

32
#if !defined(USE_OPENGL_ES)
33
  {
34
    sol::usertype<Texture1D> texture1D = state.new_usertype<Texture1D>("Texture1D",
35
                                                                       sol::constructors<Texture1D(TextureColorspace),
×
36
                                                                                         Texture1D(TextureColorspace, TextureDataType),
37
                                                                                         Texture1D(unsigned int, TextureColorspace),
38
                                                                                         Texture1D(unsigned int, TextureColorspace, TextureDataType),
39
                                                                                         Texture1D(const Color&),
40
                                                                                         Texture1D(const Color&, unsigned int)>(),
41
                                                                       sol::base_classes, sol::bases<Texture>());
2✔
42
    texture1D["getWidth"] = &Texture1D::getWidth;
2✔
43
    texture1D["create"]   = sol::overload(&Texture1D::create<TextureColorspace>,
2✔
44
                                          &Texture1D::create<TextureColorspace, TextureDataType>,
45
                                          &Texture1D::create<unsigned int, TextureColorspace>,
46
                                          &Texture1D::create<unsigned int, TextureColorspace, TextureDataType>,
47
                                          &Texture1D::create<const Color&>,
48
                                          &Texture1D::create<const Color&, unsigned int>);
2✔
49
    texture1D["resize"]   = &Texture1D::resize;
2✔
50
    texture1D["fill"]     = &Texture1D::fill;
2✔
51
  }
2✔
52
#endif
53

54
  {
55
    sol::usertype<Texture2D> texture2D = state.new_usertype<Texture2D>("Texture2D",
56
                                                                       sol::constructors<Texture2D(TextureColorspace),
×
57
                                                                                         Texture2D(TextureColorspace, TextureDataType),
58
                                                                                         Texture2D(unsigned int, unsigned int, TextureColorspace),
59
                                                                                         Texture2D(unsigned int, unsigned int, TextureColorspace,
60
                                                                                                   TextureDataType),
61
                                                                                         Texture2D(const Image&),
62
                                                                                         Texture2D(const Image&, bool),
63
                                                                                         Texture2D(const Image&, bool, bool),
64
                                                                                         Texture2D(const Color&),
65
                                                                                         Texture2D(const Color&, unsigned int),
66
                                                                                         Texture2D(const Color&, unsigned int, unsigned int)>(),
67
                                                                       sol::base_classes, sol::bases<Texture>());
2✔
68
    texture2D["getWidth"]     = &Texture2D::getWidth;
2✔
69
    texture2D["getHeight"]    = &Texture2D::getHeight;
2✔
70
    texture2D["create"]       = sol::overload(&Texture2D::create<TextureColorspace>,
2✔
71
                                              &Texture2D::create<TextureColorspace, TextureDataType>,
72
                                              &Texture2D::create<unsigned int, unsigned int, TextureColorspace>,
73
                                              &Texture2D::create<unsigned int, unsigned int, TextureColorspace, TextureDataType>,
74
                                              &Texture2D::create<const Image&>,
75
                                              &Texture2D::create<const Image&, bool>,
76
                                              &Texture2D::create<const Image&, bool, bool>,
77
                                              &Texture2D::create<const Color&>,
78
                                              &Texture2D::create<const Color&, unsigned int>,
79
                                              &Texture2D::create<const Color&, unsigned int, unsigned int>);
2✔
80
    texture2D["resize"]       = &Texture2D::resize;
2✔
81
    texture2D["load"]         = sol::overload([] (Texture2D& t, const Image& img) { t.load(img); },
3✔
82
                                              [] (Texture2D& t, const Image& img, bool mips) { t.load(img, mips); },
1✔
83
                                              PickOverload<const Image&, bool, bool>(&Texture2D::load));
4✔
84
    texture2D["fill"]         = &Texture2D::fill;
2✔
85
    texture2D["recoverImage"] = &Texture2D::recoverImage;
2✔
86
  }
2✔
87

88
  {
89
    sol::usertype<Texture3D> texture3D = state.new_usertype<Texture3D>("Texture3D",
90
                                                                       sol::constructors<Texture3D(TextureColorspace),
×
91
                                                                                         Texture3D(TextureColorspace, TextureDataType),
92
                                                                                         Texture3D(unsigned int, unsigned int, unsigned int, TextureColorspace),
93
                                                                                         Texture3D(unsigned int, unsigned int, unsigned int, TextureColorspace,
94
                                                                                                   TextureDataType),
95
                                                                                         // Constant references on vectors cannot be bound, and declaring
96
                                                                                         //  constructors requires the exact prototype
97
                                                                                         //Texture3D(const std::vector<Image>&),
98
                                                                                         //Texture3D(const std::vector<Image>&, bool),
99
                                                                                         //Texture3D(const std::vector<Image>&, bool, bool),
100
                                                                                         Texture3D(const Color&),
101
                                                                                         Texture3D(const Color&, unsigned int),
102
                                                                                         Texture3D(const Color&, unsigned int, unsigned int),
103
                                                                                         Texture3D(const Color&, unsigned int, unsigned int, unsigned int)>(),
104
                                                                       sol::base_classes, sol::bases<Texture>());
2✔
105
    texture3D["getWidth"]  = &Texture3D::getWidth;
2✔
106
    texture3D["getHeight"] = &Texture3D::getHeight;
2✔
107
    texture3D["getDepth"]  = &Texture3D::getDepth;
2✔
108
    texture3D["create"]    = sol::overload(&Texture3D::create<TextureColorspace>,
2✔
109
                                           &Texture3D::create<TextureColorspace, TextureDataType>,
110
                                           &Texture3D::create<unsigned int, unsigned int, unsigned int, TextureColorspace>,
111
                                           &Texture3D::create<unsigned int, unsigned int, unsigned int, TextureColorspace, TextureDataType>,
112
                                           [] (std::vector<Image> imgs) { return Texture3D::create(imgs); },
1✔
113
                                           [] (std::vector<Image> imgs, bool mips) { return Texture3D::create(imgs, mips); },
1✔
114
                                           [] (std::vector<Image> imgs, bool mips, bool srgb) { return Texture3D::create(imgs, mips, srgb); },
1✔
115
                                           &Texture3D::create<const Color&>,
116
                                           &Texture3D::create<const Color&, unsigned int>,
117
                                           &Texture3D::create<const Color&, unsigned int, unsigned int>,
118
                                           &Texture3D::create<const Color&, unsigned int, unsigned int, unsigned int>);
2✔
119
    texture3D["resize"]    = &Texture3D::resize;
2✔
120
    texture3D["load"]      = sol::overload([] (Texture3D& t, std::vector<Image> imgs) { t.load(imgs); },
3✔
121
                                           [] (Texture3D& t, std::vector<Image> imgs, bool mips) { t.load(imgs, mips); },
1✔
122
                                           [] (Texture3D& t, std::vector<Image> imgs, bool mips, bool srgb) { t.load(imgs, mips, srgb); });
3✔
123
    texture3D["fill"]      = &Texture3D::fill;
2✔
124
  }
2✔
125

126
  state.new_enum<TextureColorspace>("TextureColorspace", {
2✔
127
    { "INVALID", TextureColorspace::INVALID },
2✔
128
    { "GRAY",    TextureColorspace::GRAY },
2✔
129
    { "RG",      TextureColorspace::RG },
2✔
130
    { "RGB",     TextureColorspace::RGB },
2✔
131
    { "RGBA",    TextureColorspace::RGBA },
2✔
132
    { "SRGB",    TextureColorspace::SRGB },
2✔
133
    { "SRGBA",   TextureColorspace::SRGBA },
2✔
134
    { "DEPTH",   TextureColorspace::DEPTH }
2✔
135
  });
136

137
  state.new_enum<TextureDataType>("TextureDataType", {
2✔
138
    { "BYTE",    TextureDataType::BYTE },
2✔
139
    { "FLOAT16", TextureDataType::FLOAT16 },
2✔
140
    { "FLOAT32", TextureDataType::FLOAT32 }
2✔
141
  });
142

143
  state.new_enum<TextureFilter>("TextureFilter", {
2✔
144
    { "NEAREST", TextureFilter::NEAREST },
2✔
145
    { "LINEAR",  TextureFilter::LINEAR }
2✔
146
  });
147

148
  state.new_enum<TextureWrapping>("TextureWrapping", {
2✔
149
    { "REPEAT", TextureWrapping::REPEAT },
2✔
150
    { "CLAMP",  TextureWrapping::CLAMP }
2✔
151
  });
152
}
2✔
153

154
} // namespace Raz
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc