Improve memory safety.
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m44s

Also fixed a case where we didn't reset the GL state correctly 🤷
This commit is contained in:
2024-10-06 23:03:50 -04:00
parent 5f367efc28
commit 308b0dc854
3 changed files with 16 additions and 8 deletions

View File

@@ -23,8 +23,6 @@ namespace JGL {
CLAMP_TO_BORDER = 3 //Effectively the same as clamp_to_edge
};
//TODO copy constructor for this. Copying this as it is and then that copy going out of scope will crash the program as it sits.
/// Represents texture data loaded on the GPU. Contains a handle that can be passed to OpenGL draw calls.
class Texture {
private:
@@ -38,7 +36,6 @@ namespace JGL {
TextureWrappingMode texture_wrapping_mode;
void load(SoftwareTexture* software_texture, const Vector2& size, const TextureFormat& format, TextureFilteringMode filtering_mode, TextureWrappingMode wrapping_mode);
public:
Texture() = default;
/// Load a texture from a file,
explicit Texture(const std::string& file, TextureFilteringMode filtering_mode = TextureFilteringMode::BILINEAR, TextureWrappingMode wrapping_mode = TextureWrappingMode::CLAMP_TO_EDGE);
Texture(const std::string& file, const TextureFlag& flags, TextureFilteringMode filtering_mode = TextureFilteringMode::BILINEAR, TextureWrappingMode wrapping_mode = TextureWrappingMode::CLAMP_TO_EDGE);
@@ -46,6 +43,7 @@ namespace JGL {
/* Initialize a texture filled with trash data
this is primarily for the RenderTarget */
explicit Texture(const Vector2& size);
Texture(const Texture& rhs);
~Texture();
public:
[[nodiscard]] GLuint GetGLTextureHandle() const;
@@ -55,7 +53,6 @@ namespace JGL {
[[nodiscard]] TextureFlag GetFlags() const;
[[nodiscard]] TextureFormat GetFormat() const;
[[nodiscard]] std::vector<Color4> GetPixelData() const;
void SetTextureHandle(GLuint handle);
};