Skip to content

Commit 750cf41

Browse files
author
Benjamin Yap
committed
Make NVGTexture loading method only require context ID
1 parent ef98115 commit 750cf41

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/com/bwyap/enginedriver/resource/Resource.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.bwyap.engine.input.InputMapping;
99
import com.bwyap.enginedriver.resource.jsonwrapper.Settings;
1010
import com.bwyap.lwjgl.engine.gui.nanovg.NVGFont;
11-
import com.bwyap.lwjgl.engine.gui.nanovg.NVGRenderer;
1211
import com.bwyap.lwjgl.engine.gui.nanovg.NVGTexture;
1312
import com.bwyap.lwjgl.engine.render3d.LWJGLTexture;
1413
import com.bwyap.lwjgl.mesh.OBJLoader;
@@ -171,11 +170,11 @@ public static void loadMeshes() {
171170
/**
172171
* Load NVG textures for GUI rendering into the current NanoVG context
173172
*/
174-
public static void loadNVGTextures(NVGRenderer renderer) {
173+
public static void loadNVGTextures(long ctx) {
175174
try {
176-
testButton = NVGTexture.loadTexture("testButton", TEX_TEST_BUTTON, renderer);
177-
testButtonMouseover = NVGTexture.loadTexture("testButtonMouseover", TEX_TEST_BUTTON_MOUSEOVER, renderer);
178-
testButtonPressed = NVGTexture.loadTexture("testButtonPressed", TEX_TEST_BUTTON_PRESSED, renderer);
175+
testButton = NVGTexture.loadTexture("testButton", TEX_TEST_BUTTON, ctx);
176+
testButtonMouseover = NVGTexture.loadTexture("testButtonMouseover", TEX_TEST_BUTTON_MOUSEOVER, ctx);
177+
testButtonPressed = NVGTexture.loadTexture("testButtonPressed", TEX_TEST_BUTTON_PRESSED, ctx);
179178
} catch (IOException e) {
180179
e.printStackTrace();
181180
}

src/com/bwyap/lwjgl/engine/gui/nanovg/NVGRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public NVGRenderer() throws Exception {
110110
throw new Exception("Could not initialise NanoVG");
111111

112112
// TODO clean this up
113-
Resource.loadNVGTextures(this);
113+
Resource.loadNVGTextures(getContext());
114114

115115
loadedFonts = new HashSet<String>();
116116
}

src/com/bwyap/lwjgl/engine/gui/nanovg/NVGTexture.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public NVGTexture(int textureID, int rows, int cols) {
4545
* @return
4646
* @throws IOException
4747
*/
48-
public static NVGTexture loadTexture(String name, String path, NVGRenderer renderer) throws IOException {
48+
public static NVGTexture loadTexture(String name, String path, long ctx) throws IOException {
4949
ByteBuffer img = ioResourceToByteBuffer(path, 64*64);
50-
int textureID = nvgCreateImageMem(renderer.getContext(), 0, img);
50+
int textureID = nvgCreateImageMem(ctx, 0, img);
5151
loadedTextures.put(name, textureID);
5252
return new NVGTexture(textureID);
5353
}
@@ -61,8 +61,8 @@ public static NVGTexture loadTexture(String name, String path, NVGRenderer rende
6161
* @return
6262
* @throws IOException
6363
*/
64-
public static NVGTexture loadTexture(String name, String path, NVGRenderer renderer, int row, int col) throws IOException {
65-
return new NVGTexture(loadTexture(name, path, renderer).getID(), row, col);
64+
public static NVGTexture loadTexture(String name, String path, long ctx, int row, int col) throws IOException {
65+
return new NVGTexture(loadTexture(name, path, ctx).getID(), row, col);
6666
}
6767

6868

0 commit comments

Comments
 (0)