GlTexture.java
com.mojang.blaze3d.opengl.GlTexture
信息
- 全限定名:com.mojang.blaze3d.opengl.GlTexture
- 类型:public class
- 包:com.mojang.blaze3d.opengl
- 源码路径:src/main/java/com/mojang/blaze3d/opengl/GlTexture.java
- 起始行号:L12
- 继承:GpuTexture
- 职责:
TODO
字段/常量
-
EMPTY- 类型:
int - 修饰符:
private static final - 源码定位:
L13 - 说明:
TODO
- 类型:
-
id- 类型:
int - 修饰符:
protected final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
firstFboId- 类型:
int - 修饰符:
private - 源码定位:
L15 - 说明:
TODO
- 类型:
-
firstFboDepthId- 类型:
int - 修饰符:
private - 源码定位:
L16 - 说明:
TODO
- 类型:
-
fboCache- 类型:
Int2IntMap - 修饰符:
private - 源码定位:
L17 - 说明:
TODO
- 类型:
-
closed- 类型:
boolean - 修饰符:
protected - 源码定位:
L18 - 说明:
TODO
- 类型:
-
views- 类型:
int - 修饰符:
private - 源码定位:
L19 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
protected GlTexture(int usage, String label, TextureFormat format, int width, int height, int depthOrLayers, int mipLevels, int id) @ L21
- 构造器名:GlTexture
- 源码定位:L21
- 修饰符:protected
参数:
- usage: int
- label: String
- format: TextureFormat
- width: int
- height: int
- depthOrLayers: int
- mipLevels: int
- id: int
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void close() @ L26
- 方法名:close
- 源码定位:L26
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
private void destroyImmediately() @ L36
- 方法名:destroyImmediately
- 源码定位:L36
- 返回类型:void
- 修饰符:private
参数:
- 无
说明:
TODO
public boolean isClosed() @ L49
- 方法名:isClosed
- 源码定位:L49
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public int getFbo(DirectStateAccess dsa, GpuTexture depth) @ L54
- 方法名:getFbo
- 源码定位:L54
- 返回类型:int
- 修饰符:public
参数:
- dsa: DirectStateAccess
- depth: GpuTexture
说明:
TODO
private int createFbo(DirectStateAccess dsa, int depthid) @ L71
- 方法名:createFbo
- 源码定位:L71
- 返回类型:int
- 修饰符:private
参数:
- dsa: DirectStateAccess
- depthid: int
说明:
TODO
public int glId() @ L77
- 方法名:glId
- 源码定位:L77
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public void addViews() @ L81
- 方法名:addViews
- 源码定位:L81
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void removeViews() @ L85
- 方法名:removeViews
- 源码定位:L85
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class GlTexture extends GpuTexture {
private static final int EMPTY = -1;
protected final int id;
private int firstFboId = -1;
private int firstFboDepthId = -1;
private @Nullable Int2IntMap fboCache;
protected boolean closed;
private int views;
protected GlTexture(@GpuTexture.Usage int usage, String label, TextureFormat format, int width, int height, int depthOrLayers, int mipLevels, int id) {
super(usage, label, format, width, height, depthOrLayers, mipLevels);
this.id = id;
}
@Override
public void close() {
if (!this.closed) {
this.closed = true;
if (this.views == 0) {
this.destroyImmediately();
}
}
}
private void destroyImmediately() {
GlStateManager._deleteTexture(this.id);
if (this.firstFboId != -1) {
GlStateManager._glDeleteFramebuffers(this.firstFboId);
}
if (this.fboCache != null) {
for (int fbo : this.fboCache.values()) {
GlStateManager._glDeleteFramebuffers(fbo);
}
}
}
@Override
public boolean isClosed() {
return this.closed;
}
public int getFbo(DirectStateAccess dsa, @Nullable GpuTexture depth) {
int depthId = depth == null ? 0 : ((GlTexture)depth).id;
if (this.firstFboDepthId == depthId) {
return this.firstFboId;
} else if (this.firstFboId == -1) {
this.firstFboId = this.createFbo(dsa, depthId);
this.firstFboDepthId = depthId;
return this.firstFboId;
} else {
if (this.fboCache == null) {
this.fboCache = new Int2IntArrayMap();
}
return this.fboCache.computeIfAbsent(depthId, _depthId -> this.createFbo(dsa, _depthId));
}
}
private int createFbo(DirectStateAccess dsa, int depthid) {
int fbo = dsa.createFrameBufferObject();
dsa.bindFrameBufferTextures(fbo, this.id, depthid, 0, 0);
return fbo;
}
public int glId() {
return this.id;
}
public void addViews() {
this.views++;
}
public void removeViews() {
this.views--;
if (this.closed && this.views == 0) {
this.destroyImmediately();
}
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
GlStateManager._deleteTexture(), GlStateManager._glDeleteFramebuffers()
- 引用位置:
-
- 引用位置:
参数/继承
- 引用位置:
-
- 引用位置:
参数
- 引用位置: