tracy/server/TracyTexture.cpp

36 lines
816 B
C++
Raw Normal View History

2019-06-06 23:35:35 +00:00
#include <GL/gl3w.h>
2019-06-06 20:07:56 +00:00
#include "TracyTexture.hpp"
#ifndef COMPRESSED_RGB_S3TC_DXT1_EXT
# define COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
#endif
2019-06-06 20:07:56 +00:00
namespace tracy
{
void* MakeTexture()
{
GLuint tex;
glGenTextures( 1, &tex );
glBindTexture( GL_TEXTURE_2D, tex );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
2019-06-06 23:03:28 +00:00
return (void*)(intptr_t)tex;
2019-06-06 20:07:56 +00:00
}
void FreeTexture( void* _tex )
{
2019-06-06 23:03:28 +00:00
auto tex = (GLuint)(intptr_t)_tex;
2019-06-06 20:07:56 +00:00
glDeleteTextures( 1, &tex );
}
2019-08-15 14:29:50 +00:00
void UpdateTexture( void* _tex, const char* data, int w, int h )
2019-06-06 20:07:56 +00:00
{
2019-06-06 23:03:28 +00:00
auto tex = (GLuint)(intptr_t)_tex;
2019-06-06 20:07:56 +00:00
glBindTexture( GL_TEXTURE_2D, tex );
2019-08-15 14:29:50 +00:00
glCompressedTexImage2D( GL_TEXTURE_2D, 0, COMPRESSED_RGB_S3TC_DXT1_EXT, w, h, 0, w * h / 2, data );
2019-06-06 20:07:56 +00:00
}
}