tracy/server/TracyTexture.cpp
2019-07-19 00:51:42 +02:00

36 lines
858 B
C++

#include <GL/gl3w.h>
#include "TracyTexture.hpp"
#ifndef COMPRESSED_RGB_S3TC_DXT1_EXT
# define COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
#endif
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 );
return (void*)(intptr_t)tex;
}
void FreeTexture( void* _tex )
{
auto tex = (GLuint)(intptr_t)_tex;
glDeleteTextures( 1, &tex );
}
void UpdateTexture( void* _tex, const char* data, int w, int h, bool etc )
{
auto tex = (GLuint)(intptr_t)_tex;
glBindTexture( GL_TEXTURE_2D, tex );
glCompressedTexImage2D( GL_TEXTURE_2D, 0, etc ? GL_COMPRESSED_RGB8_ETC2 : COMPRESSED_RGB_S3TC_DXT1_EXT, w, h, 0, w * h / 2, data );
}
}