Skip to content

Commit d209f83

Browse files
committed
Fix compilation issue
1 parent 6874617 commit d209f83

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

bookcontents/appendix-02/appendix-02.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,24 @@ public class GuiRender {
157157
}
158158
```
159159

160-
Some things to notice, we will not need to store the fonts texture in the `GuiRender` class, this is managed now in the `FontsMaTextureCachenager` class. Also ww
161-
need to call the new `loadFontsTexture` method in the `Render` class:
160+
Some things to notice, we will not need to store the fonts texture in the `GuiRender` class, this is managed now in the `TextureCacher` class. We will need
161+
a new method in the `TextureCache` class to add textures:
162+
163+
```java
164+
public class TextureCache {
165+
...
166+
public Texture addTexture(String id, Texture texture) {
167+
if (textureMap.size() > MAX_TEXTURES) {
168+
throw new IllegalArgumentException("Texture cache is full");
169+
}
170+
textureMap.put(id, texture);
171+
return texture;
172+
}
173+
...
174+
}
175+
```
176+
177+
Also we need to call the new `loadFontsTexture` method in the `Render` class:
162178

163179
```java
164180
public class Render {

booksamples/appendix-02/src/main/java/org/vulkanb/eng/graph/TextureCache.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ public TextureCache() {
1919
textureMap = new IndexedLinkedHashMap<>();
2020
}
2121

22+
public Texture addTexture(String id, Texture texture) {
23+
if (textureMap.size() > MAX_TEXTURES) {
24+
throw new IllegalArgumentException("Texture cache is full");
25+
}
26+
textureMap.put(id, texture);
27+
return texture;
28+
}
29+
2230
public Texture addTexture(VkCtx vkCtx, String id, ImageSrc srcImage, int format) {
2331
if (textureMap.size() > MAX_TEXTURES) {
2432
throw new IllegalArgumentException("Texture cache is full");

0 commit comments

Comments
 (0)