[API] Remove lazy-created sructs and add methods to verify struct pointer

This commit is contained in:
SpaiR committed 2021-02-27 16:15:11 +02:00
1 parent c33331e13b
commit 91d636a659
8 files changed
+60 -75

No files matched your search

+5 -15
View File
@@ -7,8 +7,8 @@ import imgui.binding.ImGuiStructDestroyable;
* ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32().
*/
public final class ImFont extends ImGuiStructDestroyable {
private ImFontGlyph fallbackGlyph = null;
private ImFontGlyph foundGlyph = new ImFontGlyph(0);
private final ImFontGlyph fallbackGlyph = new ImFontGlyph(0);
private final ImFontGlyph foundGlyph = new ImFontGlyph(0);
public ImFont() {
}
@@ -64,9 +64,7 @@ public final class ImFont extends ImGuiStructDestroyable {
* = FindGlyph(FontFallbackChar)
*/
public ImFontGlyph getFallbackGlyph() {
if (fallbackGlyph == null) {
fallbackGlyph = new ImFontGlyph(nGetFallbackGlyphPtr());
}
fallbackGlyph.ptr = nGetFallbackGlyphPtr();
return fallbackGlyph;
}
@@ -172,11 +170,7 @@ public final class ImFont extends ImGuiStructDestroyable {
// Methods
public ImFontGlyph findGlyph(final int c) {
final long ptr = nFindGlyph(c);
if (ptr == 0) {
return null;
}
foundGlyph.ptr = ptr;
foundGlyph.ptr = nFindGlyph(c);
return foundGlyph;
}
@@ -185,11 +179,7 @@ public final class ImFont extends ImGuiStructDestroyable {
*/
public ImFontGlyph findGlyphNoFallback(final int c) {
final long ptr = nFindGlyphNoFallback(c);
if (ptr == 0) {
return null;
}
foundGlyph.ptr = ptr;
foundGlyph.ptr = nFindGlyphNoFallback(c);
return foundGlyph;
}