|
1 | 1 | package imgui;
|
2 | 2 |
|
| 3 | +import imgui.binding.ImGuiStructDestroyable; |
3 | 4 | import imgui.type.ImInt;
|
4 | 5 |
|
5 | 6 | import java.nio.ByteBuffer;
|
|
24 | 25 | * - Even though many functions are suffixed with "TTF", OTF data is supported just as well.
|
25 | 26 | * - This is an old API and it is currently awkward for those and and various other reasons! We will address them in the future!
|
26 | 27 | */
|
27 |
| -public final class ImFontAtlas implements ImGuiDestroyableStruct { |
28 |
| - final long ptr; |
29 |
| - |
| 28 | +public final class ImFontAtlas extends ImGuiStructDestroyable { |
30 | 29 | private ByteBuffer alpha8pixels = null;
|
31 | 30 | private ByteBuffer rgba32pixels = null;
|
32 | 31 |
|
33 |
| - /** |
34 |
| - * This class will create a native structure. |
35 |
| - * Call {@link #destroy()} method to manually free used memory. |
36 |
| - */ |
37 | 32 | public ImFontAtlas() {
|
38 |
| - ImGui.touch(); |
39 |
| - ptr = nCreate(); |
40 | 33 | }
|
41 | 34 |
|
42 |
| - ImFontAtlas(final long ptr) { |
43 |
| - this.ptr = ptr; |
44 |
| - } |
45 |
| - |
46 |
| - @Override |
47 |
| - public void destroy() { |
48 |
| - nDestroy(ptr); |
| 35 | + public ImFontAtlas(final long ptr) { |
| 36 | + super(ptr); |
49 | 37 | }
|
50 | 38 |
|
51 | 39 | /*JNI
|
52 | 40 | #include <stdint.h>
|
53 | 41 | #include <imgui.h>
|
| 42 | + #include "jni_binding_struct.h" |
54 | 43 |
|
55 |
| - jfieldID imFontAtlasPtrID; |
56 |
| -
|
57 |
| - #define IM_FONT_ATLAS ((ImFontAtlas*)env->GetLongField(object, imFontAtlasPtrID)) |
| 44 | + #define IM_FONT_ATLAS ((ImFontAtlas*)STRUCT_PTR) |
58 | 45 |
|
59 | 46 | jmethodID jImFontAtlasCreateAlpha8PixelsMID;
|
60 | 47 | jmethodID jImFontAtlasCreateRgba32PixelsMID;
|
61 | 48 | */
|
62 | 49 |
|
63 | 50 | static native void nInit(); /*
|
64 | 51 | jclass jImFontAtlasClass = env->FindClass("imgui/ImFontAtlas");
|
65 |
| - imFontAtlasPtrID = env->GetFieldID(jImFontAtlasClass, "ptr", "J"); |
66 | 52 |
|
67 | 53 | jImFontAtlasCreateAlpha8PixelsMID = env->GetMethodID(jImFontAtlasClass, "createAlpha8Pixels", "(I)Ljava/nio/ByteBuffer;");
|
68 | 54 | jImFontAtlasCreateRgba32PixelsMID = env->GetMethodID(jImFontAtlasClass, "createRgba32Pixels", "(I)Ljava/nio/ByteBuffer;");
|
69 | 55 | */
|
70 | 56 |
|
71 |
| - private native long nCreate(); /* |
72 |
| - ImFontAtlas* imFontAtlas = new ImFontAtlas(); |
73 |
| - return (intptr_t)imFontAtlas; |
74 |
| - */ |
| 57 | + @Override |
| 58 | + protected long create() { |
| 59 | + return nCreate(); |
| 60 | + } |
75 | 61 |
|
76 |
| - private native void nDestroy(long ptr); /* |
77 |
| - delete (ImFontAtlas*)ptr; |
| 62 | + private native long nCreate(); /* |
| 63 | + return (intptr_t)(new ImFontConfig()); |
78 | 64 | */
|
79 | 65 |
|
80 | 66 | public ImFont addFont(final ImFontConfig imFontConfig) {
|
|
0 commit comments