PreferredGraphicsApi .java

net.minecraft.client.PreferredGraphicsApi (enum, 42 lines): members: DEFAULT, OPENGL, VULKAN, getBackendsToTry, serializedName, caption, key, CODEC.

net.minecraft.clientenum42 linesclient1.3 KB

Implements

API Surface (3)

Component caption()
String getSerializedName()
GpuBackend[] getBackendsToTry()

Fields & Constants (3)

CODEC
serializedName
key

String literals (6)

"default"
"options.graphicsApi.default"
"opengl"
"options.graphicsApi.opengl"
"vulkan"
"options.graphicsApi.vulkan"

Code Graph: Dependencies (5)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

PreferredGraphicsApi.java42 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client;
2
3
import com.mojang.renderpearl.api.device.GpuBackend;
4
import com.mojang.renderpearl.backend.opengl.GlBackend;
5
import com.mojang.renderpearl.backend.vulkan.VulkanBackend;
6
import com.mojang.serialization.Codec;
7
import net.fabricmc.api.EnvType;
8
import net.fabricmc.api.Environment;
9
import net.minecraft.network.chat.Component;
10
import net.minecraft.util.StringRepresentable;
11
12
@Environment(EnvType.CLIENT)
13
public enum PreferredGraphicsApi implements StringRepresentable {
14
	DEFAULT("default", "options.graphicsApi.default"),
15
	OPENGL("opengl", "options.graphicsApi.opengl"),
16
	VULKAN("vulkan", "options.graphicsApi.vulkan");
17
18
	public static final Codec<PreferredGraphicsApi> CODEC = StringRepresentable.fromEnum(PreferredGraphicsApi::values);
19
	private final String serializedName;
20
	private final Component key;
21
22
	PreferredGraphicsApi(final String serializedName, final String key) {
23
		this.serializedName = serializedName;
24
		this.key = Component.translatable(key);
25
	}
26
27
	public Component caption() {
28
		return this.key;
29
	}
30
31
	@Override
32
	public String getSerializedName() {
33
		return this.serializedName;
34
	}
35
36
	public GpuBackend[] getBackendsToTry() {
37
		GlBackend gl = new GlBackend();
38
		VulkanBackend vulkan = new VulkanBackend();
39
		return this == VULKAN ? new GpuBackend[]{vulkan, gl} : new GpuBackend[]{gl, vulkan};
40
	}
41
}
42

Decompiled Minecraft 26.3 source of PreferredGraphicsApi (net/minecraft/client/PreferredGraphicsApi.java) with Mojang official mappings, stored verbatim on the site.