GlSampler .java

com.mojang.renderpearl.backend.opengl.GlSampler (class): members: maxLod, getMaxAnisotropy, getAddressModeU, getAddressModeV, getMagFilter, getMinFilter.

com.mojang.renderpearl.backend.openglclass111 linesclient2.5 KB

Implements

API Surface (9)

int getId()
AddressMode getAddressModeU()
AddressMode getAddressModeV()
FilterMode getMinFilter()
FilterMode getMagFilter()
int getMaxAnisotropy()
OptionalDouble getMaxLod()
void close()
boolean isClosed()

Fields & Constants (8)

id
addressModeU
addressModeV
minFilter
magFilter
maxAnisotropy
maxLod
closed

Code Graph: Dependencies (4)

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

Full Source

GlSampler.java111 lines · Minecraft 26.3 · verbatim
1
package com.mojang.renderpearl.backend.opengl;
2
3
import com.mojang.renderpearl.api.textures.AddressMode;
4
import com.mojang.renderpearl.api.textures.FilterMode;
5
import com.mojang.renderpearl.api.textures.GpuSampler;
6
import java.util.OptionalDouble;
7
import net.fabricmc.api.EnvType;
8
import net.fabricmc.api.Environment;
9
import org.lwjgl.opengl.GL33C;
10
11
@Environment(EnvType.CLIENT)
12
public class GlSampler implements GpuSampler {
13
	private final int id;
14
	private final AddressMode addressModeU;
15
	private final AddressMode addressModeV;
16
	private final FilterMode minFilter;
17
	private final FilterMode magFilter;
18
	private final int maxAnisotropy;
19
	private final OptionalDouble maxLod;
20
	private boolean closed;
21
22
	public GlSampler(
23
		final AddressMode addressModeU,
24
		final AddressMode addressModeV,
25
		final FilterMode minFilter,
26
		final FilterMode magFilter,
27
		final int maxAnisotropy,
28
		final OptionalDouble maxLod
29
	) {
30
		this.addressModeU = addressModeU;
31
		this.addressModeV = addressModeV;
32
		this.minFilter = minFilter;
33
		this.magFilter = magFilter;
34
		this.maxAnisotropy = maxAnisotropy;
35
		this.maxLod = maxLod;
36
		this.id = GL33C.glGenSamplers();
37
		GL33C.glSamplerParameteri(this.id, 10242, GlConst.toGl(addressModeU));
38
		GL33C.glSamplerParameteri(this.id, 10243, GlConst.toGl(addressModeV));
39
		if (maxAnisotropy > 1) {
40
			GL33C.glSamplerParameterf(this.id, 34046, maxAnisotropy);
41
		}
42
43
		switch (minFilter) {
44
			case NEAREST:
45
				GL33C.glSamplerParameteri(this.id, 10241, 9986);
46
				break;
47
			case LINEAR:
48
				GL33C.glSamplerParameteri(this.id, 10241, 9987);
49
		}
50
51
		switch (magFilter) {
52
			case NEAREST:
53
				GL33C.glSamplerParameteri(this.id, 10240, 9728);
54
				break;
55
			case LINEAR:
56
				GL33C.glSamplerParameteri(this.id, 10240, 9729);
57
		}
58
59
		if (maxLod.isPresent()) {
60
			GL33C.glSamplerParameterf(this.id, 33083, (float)maxLod.getAsDouble());
61
		}
62
	}
63
64
	public int getId() {
65
		return this.id;
66
	}
67
68
	@Override
69
	public AddressMode getAddressModeU() {
70
		return this.addressModeU;
71
	}
72
73
	@Override
74
	public AddressMode getAddressModeV() {
75
		return this.addressModeV;
76
	}
77
78
	@Override
79
	public FilterMode getMinFilter() {
80
		return this.minFilter;
81
	}
82
83
	@Override
84
	public FilterMode getMagFilter() {
85
		return this.magFilter;
86
	}
87
88
	@Override
89
	public int getMaxAnisotropy() {
90
		return this.maxAnisotropy;
91
	}
92
93
	@Override
94
	public OptionalDouble getMaxLod() {
95
		return this.maxLod;
96
	}
97
98
	@Override
99
	public void close() {
100
		if (!this.closed) {
101
			this.closed = true;
102
			GL33C.glDeleteSamplers(this.id);
103
		}
104
	}
105
106
	@Override
107
	public boolean isClosed() {
108
		return this.closed;
109
	}
110
}
111

Decompiled Minecraft 26.3 source of GlSampler (com/mojang/renderpearl/backend/opengl/GlSampler.java) with Mojang official mappings, stored verbatim on the site.