mirror of
https://github.com/Eaglercraft-Archive/Eaglercraftx-1.8.8-src.git
synced 2025-06-27 18:38:14 -05:00
Update #13 - Big FPS boost for most players
The hotbar, chat, and debug overlays in the game have been optimized and now only require a fraction as much CPU/GPU usage to be displayed on screen
This commit is contained in:
@ -78,8 +78,6 @@ public class EffectPipelineFXAA {
|
||||
_wglAttachShader(shaderProgram, SpriteLevelMixer.vshLocal);
|
||||
_wglAttachShader(shaderProgram, frag);
|
||||
|
||||
_wglBindAttribLocation(shaderProgram, 0, "a_position2f");
|
||||
|
||||
_wglLinkProgram(shaderProgram);
|
||||
|
||||
_wglDetachShader(shaderProgram, SpriteLevelMixer.vshLocal);
|
||||
|
@ -22,7 +22,7 @@ class FixedFunctionShader {
|
||||
static final String FILENAME_FSH = "/assets/eagler/glsl/core.fsh";
|
||||
|
||||
static final String PRECISION_INT = "lowp";
|
||||
static final String PRECISION_FLOAT = "highp";
|
||||
static final String PRECISION_FLOAT = "mediump";
|
||||
static final String PRECISION_SAMPLER = "lowp";
|
||||
|
||||
static final String MACRO_ATTRIB_TEXTURE = "COMPILE_TEXTURE_ATTRIB";
|
||||
|
@ -0,0 +1,95 @@
|
||||
package net.lax1dude.eaglercraft.v1_8.opengl;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IFramebufferGL;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IRenderbufferGL;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
|
||||
|
||||
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
|
||||
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2023 LAX1DUDE. All Rights Reserved.
|
||||
*
|
||||
* WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES
|
||||
* NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED
|
||||
* TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE
|
||||
* SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR.
|
||||
*
|
||||
* NOT FOR COMMERCIAL OR MALICIOUS USE
|
||||
*
|
||||
* (please read the 'LICENSE' file this repo's root directory for more info)
|
||||
*
|
||||
*/
|
||||
public class GameOverlayFramebuffer {
|
||||
|
||||
private static final int _GL_FRAMEBUFFER = 0x8D40;
|
||||
private static final int _GL_RENDERBUFFER = 0x8D41;
|
||||
private static final int _GL_COLOR_ATTACHMENT0 = 0x8CE0;
|
||||
private static final int _GL_DEPTH_ATTACHMENT = 0x8D00;
|
||||
private static final int _GL_DEPTH_COMPONENT16 = 0x81A5;
|
||||
|
||||
private long age = -1l;
|
||||
|
||||
private int currentWidth = -1;
|
||||
private int currentHeight = -1;
|
||||
|
||||
private IFramebufferGL framebuffer = null;
|
||||
private IRenderbufferGL depthBuffer = null;
|
||||
|
||||
private int framebufferColor = -1;
|
||||
|
||||
public void beginRender(int width, int height) {
|
||||
if(framebuffer == null) {
|
||||
framebuffer = _wglCreateFramebuffer();
|
||||
depthBuffer = _wglCreateRenderbuffer();
|
||||
framebufferColor = GlStateManager.generateTexture();
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, framebuffer);
|
||||
GlStateManager.bindTexture(framebufferColor);
|
||||
_wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
_wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
_wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
_wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
_wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(framebufferColor), 0);
|
||||
_wglBindRenderbuffer(_GL_RENDERBUFFER, depthBuffer);
|
||||
_wglFramebufferRenderbuffer(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, _GL_RENDERBUFFER, depthBuffer);
|
||||
}
|
||||
|
||||
if(currentWidth != width || currentHeight != height) {
|
||||
currentWidth = width;
|
||||
currentHeight = height;
|
||||
GlStateManager.bindTexture(framebufferColor);
|
||||
_wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer)null);
|
||||
_wglBindRenderbuffer(_GL_RENDERBUFFER, depthBuffer);
|
||||
_wglRenderbufferStorage(_GL_RENDERBUFFER, _GL_DEPTH_COMPONENT16, width, height);
|
||||
}
|
||||
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, framebuffer);
|
||||
}
|
||||
|
||||
public void endRender() {
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, null);
|
||||
age = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public long getAge() {
|
||||
return age == -1l ? -1l : (System.currentTimeMillis() - age);
|
||||
}
|
||||
|
||||
public int getTexture() {
|
||||
return framebufferColor;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
if(framebuffer != null) {
|
||||
_wglDeleteFramebuffer(framebuffer);
|
||||
_wglDeleteRenderbuffer(depthBuffer);
|
||||
GlStateManager.deleteTexture(framebufferColor);
|
||||
framebuffer = null;
|
||||
depthBuffer = null;
|
||||
framebufferColor = -1;
|
||||
age = -1l;
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -124,11 +124,6 @@ public class InstancedFontRenderer {
|
||||
_wglAttachShader(shaderProgram, vert);
|
||||
_wglAttachShader(shaderProgram, frag);
|
||||
|
||||
_wglBindAttribLocation(shaderProgram, 0, "a_position2f");
|
||||
_wglBindAttribLocation(shaderProgram, 1, "c_position2i");
|
||||
_wglBindAttribLocation(shaderProgram, 2, "c_coords2i");
|
||||
_wglBindAttribLocation(shaderProgram, 3, "c_color4f");
|
||||
|
||||
_wglLinkProgram(shaderProgram);
|
||||
|
||||
_wglDetachShader(shaderProgram, vert);
|
||||
|
@ -125,13 +125,6 @@ public class InstancedParticleRenderer {
|
||||
_wglAttachShader(shaderProgram, vert);
|
||||
_wglAttachShader(shaderProgram, frag);
|
||||
|
||||
_wglBindAttribLocation(shaderProgram, 0, "a_position2f");
|
||||
_wglBindAttribLocation(shaderProgram, 1, "p_position3f");
|
||||
_wglBindAttribLocation(shaderProgram, 2, "p_texCoords2i");
|
||||
_wglBindAttribLocation(shaderProgram, 3, "p_lightMap2f");
|
||||
_wglBindAttribLocation(shaderProgram, 4, "p_particleSize_texCoordsSize_2i");
|
||||
_wglBindAttribLocation(shaderProgram, 5, "p_color4f");
|
||||
|
||||
_wglLinkProgram(shaderProgram);
|
||||
|
||||
_wglDetachShader(shaderProgram, vert);
|
||||
|
@ -115,8 +115,6 @@ public class SpriteLevelMixer {
|
||||
_wglAttachShader(shaderProgram, vshLocal);
|
||||
_wglAttachShader(shaderProgram, frag);
|
||||
|
||||
_wglBindAttribLocation(shaderProgram, 0, "a_position2f");
|
||||
|
||||
_wglLinkProgram(shaderProgram);
|
||||
|
||||
_wglDetachShader(shaderProgram, vshLocal);
|
||||
|
Reference in New Issue
Block a user