[cleanup] Use lazy init for integrated graphics check

This commit is contained in:
Xiaro 2020-11-29 18:04:51 -05:00
parent c9bdd7d004
commit 6850761a79
No known key found for this signature in database
GPG Key ID: 996D265D6E155377
2 changed files with 5 additions and 10 deletions

View File

@ -100,7 +100,7 @@ object Search : Module() {
}
override fun onEnable() {
if (!overrideWarning.value && ShaderHelper.isIntegratedGraphics()) {
if (!overrideWarning.value && ShaderHelper.isIntegratedGraphics) {
MessageSendHelper.sendErrorMessage("$chatName Warning: Running Search with an Intel Integrated GPU is not recommended, as it has a &llarge&r impact on performance.")
MessageSendHelper.sendWarningMessage("$chatName If you're sure you want to try, run the &7 ${Command.getCommandPrefix()}search override&f command")
disable()

View File

@ -12,7 +12,7 @@ import net.minecraft.client.shader.ShaderGroup
import net.minecraft.client.shader.ShaderLinkHelper
import net.minecraft.util.ResourceLocation
import net.minecraftforge.fml.common.gameevent.TickEvent
import org.lwjgl.opengl.GL11
import org.lwjgl.opengl.GL11.GL_VENDOR
class ShaderHelper(shaderIn: ResourceLocation, vararg frameBufferNames: String) {
private val mc = Wrapper.minecraft
@ -28,7 +28,7 @@ class ShaderHelper(shaderIn: ResourceLocation, vararg frameBufferNames: String)
null
}
isIntegratedGraphics() -> {
isIntegratedGraphics -> {
KamiMod.LOG.warn("Running on Intel Integrated Graphics!")
null
}
@ -72,13 +72,8 @@ class ShaderHelper(shaderIn: ResourceLocation, vararg frameBufferNames: String)
fun getFrameBuffer(name: String) = frameBufferMap[name]
companion object {
private var cachedIsIntegratedGraphics: Boolean? = null
fun isIntegratedGraphics() = cachedIsIntegratedGraphics ?: run {
GlStateManager.glGetString(GL11.GL_VENDOR).contains("Intel").apply {
cachedIsIntegratedGraphics = this
return this
}
val isIntegratedGraphics by lazy {
GlStateManager.glGetString(GL_VENDOR).contains("Intel")
}
}
}