summaryrefslogtreecommitdiffhomepage
path: root/src/texture.cpp
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2022-11-26 16:46:01 -0500
committerrealtradam <[email protected]>2022-11-26 16:46:01 -0500
commit368269070f851ff78a1bce35c1d993d5f02cc5f9 (patch)
tree83292448b320f561148f16efdbb456c85ab00f87 /src/texture.cpp
parent68486053b032fd3313c887ea7d73064e59dce570 (diff)
downloadOgle-368269070f851ff78a1bce35c1d993d5f02cc5f9.tar.gz
Ogle-368269070f851ff78a1bce35c1d993d5f02cc5f9.zip
namespace it all
Diffstat (limited to 'src/texture.cpp')
-rw-r--r--src/texture.cpp39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/texture.cpp b/src/texture.cpp
index 6322ce7..9360369 100644
--- a/src/texture.cpp
+++ b/src/texture.cpp
@@ -10,25 +10,28 @@
// std libs
#include <iostream>
-Texture::Texture(const char* texture_path)
+namespace Ogle
{
- glGenTextures(1, &id);
- glBindTexture(GL_TEXTURE_2D, id);
- // set the texture wrapping/filtering options (on the currently bound texture object)
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- int width, height, nrChannels;
- unsigned char *data = stbi_load(texture_path, &width, &height, &nrChannels, 0);
- if (data)
+ Texture::Texture(const char* texture_path)
{
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
- glGenerateMipmap(GL_TEXTURE_2D);
+ glGenTextures(1, &id);
+ glBindTexture(GL_TEXTURE_2D, id);
+ // set the texture wrapping/filtering options (on the currently bound texture object)
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ int width, height, nrChannels;
+ unsigned char *data = stbi_load(texture_path, &width, &height, &nrChannels, 0);
+ if (data)
+ {
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
+ glGenerateMipmap(GL_TEXTURE_2D);
+ }
+ else
+ {
+ std::cout << "Failed to load texture" << std::endl;
+ }
+ stbi_image_free(data);
}
- else
- {
- std::cout << "Failed to load texture" << std::endl;
- }
- stbi_image_free(data);
}