mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-21 04:42:17 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75617a5456 | ||
|
|
e158faada0 |
No files matched your search
@@ -236,6 +236,9 @@ public class GLStateManager {
|
||||
|
||||
}
|
||||
|
||||
public static boolean isMainThread() {
|
||||
return Thread.currentThread() == MainThread;
|
||||
}
|
||||
|
||||
public static void assertMainThread() {
|
||||
if (Thread.currentThread() != CurrentThread && !runningSplash) {
|
||||
@@ -1259,6 +1262,9 @@ public class GLStateManager {
|
||||
return true;
|
||||
}
|
||||
final TextureInfo info = TextureInfoCache.INSTANCE.getInfo(texture);
|
||||
if (info == null) {
|
||||
return true;
|
||||
}
|
||||
switch (pname) {
|
||||
case GL11.GL_TEXTURE_MIN_FILTER -> {
|
||||
if(info.getMinFilter() == param && !shouldBypassCache()) return false;
|
||||
@@ -1330,6 +1336,9 @@ public class GLStateManager {
|
||||
return true;
|
||||
}
|
||||
final TextureInfo info = TextureInfoCache.INSTANCE.getInfo(texture);
|
||||
if (info == null) {
|
||||
return true;
|
||||
}
|
||||
switch (pname) {
|
||||
case EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT -> {
|
||||
if(info.getMaxAnisotropy() == param && !shouldBypassCache()) return false;
|
||||
@@ -1355,7 +1364,9 @@ public class GLStateManager {
|
||||
|
||||
public static int getTexParameterOrDefault(int texture, int pname, IntSupplier defaultSupplier) {
|
||||
final TextureInfo info = TextureInfoCache.INSTANCE.getInfo(texture);
|
||||
|
||||
if (info == null) {
|
||||
return defaultSupplier.getAsInt();
|
||||
}
|
||||
return switch (pname) {
|
||||
case GL11.GL_TEXTURE_MIN_FILTER -> info.getMinFilter();
|
||||
case GL11.GL_TEXTURE_MAG_FILTER -> info.getMagFilter();
|
||||
@@ -1379,6 +1390,9 @@ public class GLStateManager {
|
||||
return GL11.glGetTexParameterf(target, pname);
|
||||
}
|
||||
final TextureInfo info = TextureInfoCache.INSTANCE.getInfo(getBoundTexture());
|
||||
if(info == null) {
|
||||
return GL11.glGetTexParameterf(target, pname);
|
||||
}
|
||||
|
||||
return switch (pname) {
|
||||
case EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT -> info.getMaxAnisotropy();
|
||||
@@ -1392,7 +1406,9 @@ public class GLStateManager {
|
||||
return GL11.glGetTexLevelParameteri(target, level, pname);
|
||||
}
|
||||
final TextureInfo info = TextureInfoCache.INSTANCE.getInfo(getBoundTexture());
|
||||
|
||||
if (info == null) {
|
||||
return GL11.glGetTexLevelParameteri(target, level, pname);
|
||||
}
|
||||
return switch (pname) {
|
||||
case GL11.GL_TEXTURE_WIDTH -> info.getWidth();
|
||||
case GL11.GL_TEXTURE_HEIGHT -> info.getHeight();
|
||||
|
||||
@@ -21,7 +21,7 @@ public class TextureInfoCache {
|
||||
}
|
||||
|
||||
public TextureInfo getInfo(int id) {
|
||||
if(id < 0) return null;
|
||||
if(id < 0 || !GLStateManager.isMainThread()) return null;
|
||||
return cache.computeIfAbsent(id, TextureInfo::new);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class TextureInfoCache {
|
||||
}
|
||||
|
||||
public void onDeleteTexture(int id) {
|
||||
if(id >= 0) cache.remove(id);
|
||||
if(id >= 0 && GLStateManager.isMainThread()) cache.remove(id);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user