diff options
author | Bartosz Taudul <wolf.pld@gmail.com> | 2019-06-06 23:07:56 +0300 |
---|---|---|
committer | Bartosz Taudul <wolf.pld@gmail.com> | 2019-06-06 23:14:51 +0300 |
commit | 82d4fe7236a9a8129bb388e50b5225004508868c (patch) | |
tree | 77c45eb5de06b638930647889a4a4a8a0da4fcc3 /server/TracyTexture.cpp | |
parent | af56f41e3224e7df54afaa516946d518b695c7a2 (diff) |
Add texture wrapper.
Diffstat (limited to 'server/TracyTexture.cpp')
-rw-r--r-- | server/TracyTexture.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/server/TracyTexture.cpp b/server/TracyTexture.cpp new file mode 100644 index 00000000..9743381b --- /dev/null +++ b/server/TracyTexture.cpp @@ -0,0 +1,31 @@ +#include <gl/gl3w.h> + +#include "TracyTexture.hpp" + +namespace tracy +{ + +void* MakeTexture() +{ + GLuint tex; + glGenTextures( 1, &tex ); + glBindTexture( GL_TEXTURE_2D, tex ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + return (void*)tex; +} + +void FreeTexture( void* _tex ) +{ + auto tex = (GLuint)_tex; + glDeleteTextures( 1, &tex ); +} + +void UpdateTexture( void* _tex, const char* data, int w, int h ) +{ + auto tex = (GLuint)_tex; + glBindTexture( GL_TEXTURE_2D, tex ); + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data ); +} + +} |