Skip to content

Commit

Permalink
corrected texture for code requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
DM8AT committed Aug 20, 2024
1 parent f62e76f commit b2cf900
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ObjectGL/OGL_Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,14 @@ void OGL_Texture::createMipmap()
this->bind(0);
//create the mip chain
glGenerateMipmap(this->format);
}

void OGL_Texture::onDestroy()
{
//make sure to bind the correct instance
correctInstanceBinding()
//delete the texture
glDeleteTextures(1, &this->texture);
//set the texture to 0
this->texture = 0;
}
75 changes: 75 additions & 0 deletions src/ObjectGL/ObjectGL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,24 +1337,92 @@ class OGL_Texture : OGL_BindableBase
{
public:

/**
* @brief Construct a new texture
*/
OGL_Texture() = default;

/**
* @brief Construct a new texture
*
* @param type the type of the texture
* @param width the width of the texture
* @param height the height of the texture
* @param layers the amount of layers for 3D textures
* @param internalFormat the internal format of the texture
*/
OGL_Texture(OGL_TextureType type, uint32_t width, uint32_t height, uint32_t layers, GLenum internalFormat = GL_RGBA32F);

/**
* @brief Construct a new texture
*
* @param texFile the path to the texture
* @param internalFormat the internal format for the texture
*/
OGL_Texture(const char* texFile, GLenum internalFormat = GL_RGBA32F);

/**
* @brief Construct a new texture
*
* @param texFiles the texture files for the textures
* @param type the type of the texture
* @param internalFormat the internal format for the texture
*/
OGL_Texture(std::vector<const char*> texFiles, OGL_TextureType type, GLenum internalFormat = GL_RGBA32F);

/**
* @brief Construct a new texture
*
* @param data the data for the texture
* @param width the width of the texture
* @param height the height of the texture
* @param format the format of the data
* @param type the type of the data
* @param internalFormat the internal format for the texture
*/
OGL_Texture(void* data, uint32_t width, uint32_t height, GLenum format, GLenum type, GLenum internalFormat = GL_RGBA32F);

/**
* @brief update the texture
*
* @param texFile the texture file to read
* @param internalFormat the internal format of the texture
*/
void setTexture(const char* texFile, GLenum internalFormat = GL_RGBA32F);

/**
* @brief update the texture
*
* @param texFiles the texture files to read from
* @param type the type of the texture
* @param internalFormat the internal format of the texture
*/
void setTexture(std::vector<const char*> texFiles, OGL_TextureType type, GLenum internalFormat = GL_RGBA32F);

/**
* @brief update the texture
*
* @param data the data for the texture
* @param width the width of the texture
* @param height the height of the texture
* @param format the format of the data
* @param type the type of the data
* @param internalFormat the internal format for the texture
*/
void setTexture(void* data, uint32_t width, uint32_t height, GLenum format, GLenum type, GLenum internalFormat = GL_RGBA32F);

/**
* @brief bind the texture to a specific unit
*
* @param unit the unit to unbind from
*/
void bind(uint8_t unit);

/**
* @brief unbind the texture from a specific unit
*
* @param unit the unit to unbind from
*/
void unbind(uint8_t unit);

/**
Expand All @@ -1365,9 +1433,16 @@ class OGL_Texture : OGL_BindableBase
*/
void setTexParameter(GLenum parameter, GLenum value);

/**
* @brief Create a mipmap for the texture
*/
void createMipmap();

private:
/**
* @brief delete the object
*/
virtual void onDestroy() override;
/**
* @brief store the type of the texture
*/
Expand Down

0 comments on commit b2cf900

Please sign in to comment.