mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-25 23:44:35 +00:00
Detect if hardware supports S3TC.
This commit is contained in:
parent
5b1c1119c5
commit
fdb130651d
@ -221,6 +221,7 @@ int main( int argc, char** argv )
|
||||
|
||||
ImGuiTracyContext imguiContext;
|
||||
Backend backend( title, DrawContents, &mainThreadTasks );
|
||||
tracy::InitTexture();
|
||||
iconTex = tracy::MakeTexture();
|
||||
iconThread.join();
|
||||
backend.SetIcon( iconPx, iconX, iconY );
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
# include <emscripten/html5.h>
|
||||
# include <GLES2/gl2.h>
|
||||
#else
|
||||
# include "../profiler/src/imgui/imgui_impl_opengl3_loader.h"
|
||||
@ -14,6 +15,28 @@
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
static bool s_hardwareS3tc;
|
||||
|
||||
void InitTexture()
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
s_hardwareS3tc = emscripten_webgl_enable_extension( emscripten_webgl_get_current_context(), "WEBGL_compressed_texture_s3tc" );
|
||||
#else
|
||||
s_hardwareS3tc = false;
|
||||
GLint num;
|
||||
glGetIntegerv( GL_NUM_EXTENSIONS, &num );
|
||||
for( GLint i=0; i<num; i++ )
|
||||
{
|
||||
auto ext = (const char*)glGetStringi( GL_EXTENSIONS, GLuint( i ) );
|
||||
if( strcmp( ext, "GL_EXT_texture_compression_s3tc" ) == 0 )
|
||||
{
|
||||
s_hardwareS3tc = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void* MakeTexture()
|
||||
{
|
||||
GLuint tex;
|
||||
@ -36,7 +59,10 @@ void UpdateTexture( void* _tex, const char* data, int w, int h )
|
||||
{
|
||||
auto tex = (GLuint)(intptr_t)_tex;
|
||||
glBindTexture( GL_TEXTURE_2D, tex );
|
||||
glCompressedTexImage2D( GL_TEXTURE_2D, 0, COMPRESSED_RGB_S3TC_DXT1_EXT, w, h, 0, w * h / 2, data );
|
||||
if( s_hardwareS3tc )
|
||||
{
|
||||
glCompressedTexImage2D( GL_TEXTURE_2D, 0, COMPRESSED_RGB_S3TC_DXT1_EXT, w, h, 0, w * h / 2, data );
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateTextureRGBA( void* _tex, void* data, int w, int h )
|
||||
|
@ -6,6 +6,7 @@
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
void InitTexture();
|
||||
void* MakeTexture();
|
||||
void FreeTexture( void* tex, void(*runOnMainThread)(std::function<void()>, bool) );
|
||||
void UpdateTexture( void* tex, const char* data, int w, int h );
|
||||
|
Loading…
Reference in New Issue
Block a user