Skip to content

Commit

Permalink
Add some warnings about using non-GL_TEXTURE_2D textures which are un…
Browse files Browse the repository at this point in the history
…supported by ImGui.

Thanks to d3cod3 for reporting this: d3cod3/Mosaic#17
  • Loading branch information
Daandelange committed Feb 14, 2023
1 parent 32cd9c8 commit 5bfb1f4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/BaseEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ namespace ofxImGui

glBindTexture(GL_TEXTURE_2D, last_texture);

return new_texture;
return new_texture; // And who will clean up the garbage ? Seemingly nobody...
};
}
2 changes: 2 additions & 0 deletions src/BaseEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace ofxImGui

virtual bool updateFontsTexture() = 0;

// This is here to keep a compatibility layer with old codebases.
// Not recommended to use, Upload with OF and use the GL_TEXTURE_2D's textureID directly.
virtual GLuint loadTextureImage2D(unsigned char * pixels, int width, int height);

protected:
Expand Down
2 changes: 2 additions & 0 deletions src/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@



// Todo: Texture/Pixel loading functions: Stop using ofDisableArbTex and use appropriate textureSettings instead.

namespace ofxImGui
{
//--------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions src/ImHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ namespace ofxImGui

static ImTextureID GetImTextureID(const ofTexture& texture)
{
if (texture.getTextureData().textureTarget == GL_TEXTURE_RECTANGLE)
{
ofLogWarning("Warning, ImGui only supports drawing textures of type GL_TEXTURE_RECTANGLE.");
}
return (ImTextureID)(uintptr_t)texture.texData.textureID;
}

Expand Down

0 comments on commit 5bfb1f4

Please sign in to comment.