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:
parent
bae705ef18
commit
48ba6f6176
|
@ -1 +1 @@
|
|||
u12
|
||||
u13
|
|
@ -14,17 +14,20 @@
|
|||
+ import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
|
||||
+
|
||||
|
||||
> CHANGE 3 : 6 @ 3 : 6
|
||||
> CHANGE 3 : 7 @ 3 : 6
|
||||
|
||||
~
|
||||
~ import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
||||
~ import net.lax1dude.eaglercraft.v1_8.opengl.OpenGlHelper;
|
||||
~ import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
|
||||
|
||||
> DELETE 2 @ 2 : 11
|
||||
|
||||
> DELETE 2 @ 2 : 3
|
||||
|
||||
> DELETE 1 @ 1 : 2
|
||||
> CHANGE 1 : 2 @ 1 : 2
|
||||
|
||||
~ import net.minecraft.client.renderer.entity.RenderManager;
|
||||
|
||||
> CHANGE 32 : 33 @ 32 : 33
|
||||
|
||||
|
@ -34,9 +37,15 @@
|
|||
|
||||
> DELETE 27 @ 27 : 28
|
||||
|
||||
> CHANGE 95 : 96 @ 95 : 98
|
||||
> CHANGE 16 : 17 @ 16 : 21
|
||||
|
||||
~ this.overlayDebug.renderDebugInfo(scaledresolution, partialTicks);
|
||||
~ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
|
||||
> DELETE 21 @ 21 : 30
|
||||
|
||||
> CHANGE 44 : 45 @ 44 : 47
|
||||
|
||||
~ this.overlayDebug.renderDebugInfo(scaledresolution);
|
||||
|
||||
> INSERT 87 : 90 @ 87
|
||||
|
||||
|
@ -44,7 +53,21 @@
|
|||
+ j -= 10;
|
||||
+ }
|
||||
|
||||
> DELETE 166 @ 166 : 170
|
||||
> INSERT 19 : 30 @ 19
|
||||
|
||||
+ public void renderGameOverlayCrosshairs(int scaledResWidth, int scaledResHeight) {
|
||||
+ if (this.showCrosshair()) {
|
||||
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
+ this.mc.getTextureManager().bindTexture(icons);
|
||||
+ GlStateManager.enableBlend();
|
||||
+ GlStateManager.tryBlendFuncSeparate(775, 769, 1, 0);
|
||||
+ GlStateManager.enableAlpha();
|
||||
+ this.drawTexturedModalRect(scaledResWidth / 2 - 7, scaledResHeight / 2 - 7, 0, 0, 16, 16);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
|
||||
> DELETE 147 @ 147 : 151
|
||||
|
||||
> CHANGE 17 : 18 @ 17 : 18
|
||||
|
||||
|
@ -54,10 +77,80 @@
|
|||
|
||||
~ for (Score score1 : (List<Score>) arraylist1) {
|
||||
|
||||
> CHANGE 343 : 344 @ 343 : 344
|
||||
> INSERT 64 : 65 @ 64
|
||||
|
||||
+ this.mc.getTextureManager().bindTexture(icons);
|
||||
|
||||
> CHANGE 224 : 225 @ 224 : 225
|
||||
|
||||
~ public void renderVignette(float parFloat1, int scaledWidth, int scaledHeight) {
|
||||
|
||||
> CHANGE 29 : 32 @ 29 : 33
|
||||
|
||||
~ worldrenderer.pos(0.0D, (double) scaledHeight, -90.0D).tex(0.0D, 1.0D).endVertex();
|
||||
~ worldrenderer.pos((double) scaledWidth, scaledHeight, -90.0D).tex(1.0D, 1.0D).endVertex();
|
||||
~ worldrenderer.pos((double) scaledWidth, 0.0D, -90.0D).tex(1.0D, 0.0D).endVertex();
|
||||
|
||||
> CHANGE 21 : 22 @ 21 : 22
|
||||
|
||||
~ EaglerTextureAtlasSprite textureatlassprite = this.mc.getBlockRendererDispatcher().getBlockModelShapes()
|
||||
|
||||
> DELETE 57 @ 57 : 58
|
||||
|
||||
> INSERT 60 : 113 @ 60
|
||||
|
||||
+ public void drawEaglerPlayerOverlay(int x, int y, float partialTicks) {
|
||||
+ Entity e = mc.getRenderViewEntity();
|
||||
+ if (e != null && e instanceof EntityLivingBase) {
|
||||
+ EntityLivingBase ent = (EntityLivingBase) e;
|
||||
+ GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
+ GlStateManager.enableDepth();
|
||||
+ GlStateManager.enableColorMaterial();
|
||||
+ GlStateManager.pushMatrix();
|
||||
+ GlStateManager.translate((float) x - 10, (float) y + 36, 50.0F);
|
||||
+ GlStateManager.scale(-17.0F, 17.0F, 17.0F);
|
||||
+ GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
|
||||
+ float f = ent.renderYawOffset;
|
||||
+ float f1 = ent.rotationYaw;
|
||||
+ float f2 = ent.prevRotationYaw;
|
||||
+ float f3 = ent.prevRotationYawHead;
|
||||
+ float f4 = ent.rotationYawHead;
|
||||
+ float f5 = ent.prevRenderYawOffset;
|
||||
+ GlStateManager.rotate(115.0F, 0.0F, 1.0F, 0.0F);
|
||||
+ RenderHelper.enableStandardItemLighting();
|
||||
+ float f6 = ent.prevRenderYawOffset + (ent.renderYawOffset - ent.prevRenderYawOffset) * partialTicks;
|
||||
+ ent.rotationYawHead -= f6;
|
||||
+ ent.prevRotationYawHead -= f6;
|
||||
+ ent.rotationYawHead *= 0.5f;
|
||||
+ ent.prevRotationYawHead *= 0.5f;
|
||||
+ ent.renderYawOffset = 0.0f;
|
||||
+ ent.prevRenderYawOffset = 0.0f;
|
||||
+ ent.prevRotationYaw = 0.0f;
|
||||
+ ent.rotationYaw = 0.0f;
|
||||
+ GlStateManager.rotate(-135.0F
|
||||
+ - (ent.prevRotationYawHead + (ent.rotationYawHead - ent.prevRotationYawHead) * partialTicks) * 0.5F,
|
||||
+ 0.0F, 1.0F, 0.0F);
|
||||
+ GlStateManager.rotate(ent.rotationPitch * 0.2f, 1.0F, 0.0F, 0.0F);
|
||||
+ RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
|
||||
+ rendermanager.setPlayerViewY(180.0F);
|
||||
+ rendermanager.setRenderShadow(false);
|
||||
+ rendermanager.renderEntityWithPosYaw(ent, 0.0D, 0.0D, 0.0D, 0.0F, partialTicks);
|
||||
+ rendermanager.setRenderShadow(true);
|
||||
+ ent.renderYawOffset = f;
|
||||
+ ent.rotationYaw = f1;
|
||||
+ ent.prevRotationYaw = f2;
|
||||
+ ent.prevRotationYawHead = f3;
|
||||
+ ent.rotationYawHead = f4;
|
||||
+ ent.prevRenderYawOffset = f5;
|
||||
+ GlStateManager.popMatrix();
|
||||
+ RenderHelper.disableStandardItemLighting();
|
||||
+ GlStateManager.disableDepth();
|
||||
+ GlStateManager.disableRescaleNormal();
|
||||
+ GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
+ GlStateManager.disableTexture2D();
|
||||
+ GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
|
||||
> EOF
|
||||
|
|
|
@ -50,13 +50,12 @@
|
|||
|
||||
> DELETE 1 @ 1 : 3
|
||||
|
||||
> CHANGE 10 : 13 @ 10 : 11
|
||||
> INSERT 11 : 13 @ 11
|
||||
|
||||
~ public void renderDebugInfo(ScaledResolution scaledResolutionIn, float partialTicks) {
|
||||
~ int ww = scaledResolutionIn.getScaledWidth();
|
||||
~ int hh = scaledResolutionIn.getScaledHeight();
|
||||
+ int ww = scaledResolutionIn.getScaledWidth();
|
||||
+ int hh = scaledResolutionIn.getScaledHeight();
|
||||
|
||||
> CHANGE 1 : 24 @ 1 : 7
|
||||
> CHANGE 1 : 20 @ 1 : 7
|
||||
|
||||
~ if (this.mc.gameSettings.showDebugInfo) {
|
||||
~ GlStateManager.pushMatrix();
|
||||
|
@ -77,10 +76,6 @@
|
|||
~ if (this.mc.gameSettings.hudCoords) {
|
||||
~ drawXYZ(2, i);
|
||||
~ }
|
||||
~
|
||||
~ if (this.mc.gameSettings.hudPlayer) {
|
||||
~ drawPlayer(ww - 3, 3, partialTicks);
|
||||
~ }
|
||||
|
||||
> INSERT 2 : 26 @ 2
|
||||
|
||||
|
@ -109,7 +104,7 @@
|
|||
+ }
|
||||
+
|
||||
|
||||
> INSERT 3 : 195 @ 3
|
||||
> INSERT 3 : 142 @ 3
|
||||
|
||||
+ private void drawFPS(int x, int y) {
|
||||
+ this.fontRenderer.drawStringWithShadow(this.mc.renderGlobal.getDebugInfoShort(), x, y, 0xFFFFFF);
|
||||
|
@ -246,59 +241,6 @@
|
|||
+ this.fontRenderer.drawStringWithShadow(lightString + " " + tempString, x, y - 8, 0xFFFFFF);
|
||||
+ }
|
||||
+
|
||||
+ private void drawPlayer(int x, int y, float partialTicks) {
|
||||
+ Entity e = mc.getRenderViewEntity();
|
||||
+ if (e != null && e instanceof EntityLivingBase) {
|
||||
+ EntityLivingBase ent = (EntityLivingBase) e;
|
||||
+ GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
+ GlStateManager.enableDepth();
|
||||
+ GlStateManager.enableColorMaterial();
|
||||
+ GlStateManager.pushMatrix();
|
||||
+ GlStateManager.translate((float) x - 10, (float) y + 36, 50.0F);
|
||||
+ GlStateManager.scale(-17.0F, 17.0F, 17.0F);
|
||||
+ GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
|
||||
+ float f = ent.renderYawOffset;
|
||||
+ float f1 = ent.rotationYaw;
|
||||
+ float f2 = ent.prevRotationYaw;
|
||||
+ float f3 = ent.prevRotationYawHead;
|
||||
+ float f4 = ent.rotationYawHead;
|
||||
+ float f5 = ent.prevRenderYawOffset;
|
||||
+ GlStateManager.rotate(115.0F, 0.0F, 1.0F, 0.0F);
|
||||
+ RenderHelper.enableStandardItemLighting();
|
||||
+ float f6 = ent.prevRenderYawOffset + (ent.renderYawOffset - ent.prevRenderYawOffset) * partialTicks;
|
||||
+ ent.rotationYawHead -= f6;
|
||||
+ ent.prevRotationYawHead -= f6;
|
||||
+ ent.rotationYawHead *= 0.5f;
|
||||
+ ent.prevRotationYawHead *= 0.5f;
|
||||
+ ent.renderYawOffset = 0.0f;
|
||||
+ ent.prevRenderYawOffset = 0.0f;
|
||||
+ ent.prevRotationYaw = 0.0f;
|
||||
+ ent.rotationYaw = 0.0f;
|
||||
+ GlStateManager.rotate(-135.0F
|
||||
+ - (ent.prevRotationYawHead + (ent.rotationYawHead - ent.prevRotationYawHead) * partialTicks) * 0.5F,
|
||||
+ 0.0F, 1.0F, 0.0F);
|
||||
+ GlStateManager.rotate(ent.rotationPitch * 0.2f, 1.0F, 0.0F, 0.0F);
|
||||
+ RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
|
||||
+ rendermanager.setPlayerViewY(180.0F);
|
||||
+ rendermanager.setRenderShadow(false);
|
||||
+ rendermanager.renderEntityWithPosYaw(ent, 0.0D, 0.0D, 0.0D, 0.0F, partialTicks);
|
||||
+ rendermanager.setRenderShadow(true);
|
||||
+ ent.renderYawOffset = f;
|
||||
+ ent.rotationYaw = f1;
|
||||
+ ent.prevRotationYaw = f2;
|
||||
+ ent.prevRotationYawHead = f3;
|
||||
+ ent.rotationYawHead = f4;
|
||||
+ ent.prevRenderYawOffset = f5;
|
||||
+ GlStateManager.popMatrix();
|
||||
+ RenderHelper.disableStandardItemLighting();
|
||||
+ GlStateManager.disableDepth();
|
||||
+ GlStateManager.disableRescaleNormal();
|
||||
+ GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
+ GlStateManager.disableTexture2D();
|
||||
+ GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void drawHideHUD(int x, int y, int fade) {
|
||||
+ drawCenteredString(fontRenderer, I18n.format("options.hud.note"), x, y, 0xEECC00 | (fade << 24));
|
||||
+ }
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
~ import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
||||
~ import net.lax1dude.eaglercraft.v1_8.HString;
|
||||
|
||||
> INSERT 1 : 14 @ 1
|
||||
> INSERT 1 : 15 @ 1
|
||||
|
||||
+
|
||||
+ import com.google.common.base.Predicate;
|
||||
|
@ -26,6 +26,7 @@
|
|||
+ import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
||||
+ import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
|
||||
+ import net.lax1dude.eaglercraft.v1_8.opengl.EffectPipelineFXAA;
|
||||
+ import net.lax1dude.eaglercraft.v1_8.opengl.GameOverlayFramebuffer;
|
||||
+ import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
||||
+ import net.lax1dude.eaglercraft.v1_8.opengl.OpenGlHelper;
|
||||
+ import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
|
||||
|
@ -42,9 +43,17 @@
|
|||
|
||||
~ private EaglercraftRandom random = new EaglercraftRandom();
|
||||
|
||||
> DELETE 43 @ 43 : 44
|
||||
> DELETE 43 @ 43 : 61
|
||||
|
||||
> DELETE 30 @ 30 : 31
|
||||
> INSERT 1 : 2 @ 1
|
||||
|
||||
+ private GameOverlayFramebuffer overlayFramebuffer;
|
||||
|
||||
> DELETE 2 @ 2 : 4
|
||||
|
||||
> CHANGE 8 : 9 @ 8 : 9
|
||||
|
||||
~ this.overlayFramebuffer = new GameOverlayFramebuffer();
|
||||
|
||||
> INSERT 1 : 10 @ 1
|
||||
|
||||
|
@ -64,13 +73,13 @@
|
|||
|
||||
> DELETE 3 @ 3 : 9
|
||||
|
||||
> DELETE 7 @ 7 : 22
|
||||
> DELETE 3 @ 3 : 4
|
||||
|
||||
> DELETE 3 @ 3 : 18
|
||||
|
||||
> CHANGE 3 : 4 @ 3 : 18
|
||||
> DELETE 3 @ 3 : 18
|
||||
|
||||
~ this.useShader = false;
|
||||
> DELETE 3 @ 3 : 18
|
||||
|
||||
> DELETE 3 @ 3 : 14
|
||||
|
||||
|
@ -129,7 +138,47 @@
|
|||
|
||||
> DELETE 39 @ 39 : 52
|
||||
|
||||
> CHANGE 28 : 29 @ 28 : 29
|
||||
> CHANGE 4 : 41 @ 4 : 5
|
||||
|
||||
~ long framebufferAge = this.overlayFramebuffer.getAge();
|
||||
~ if (framebufferAge == -1l || framebufferAge > (Minecraft.getDebugFPS() < 25 ? 125l : 75l)) {
|
||||
~ this.overlayFramebuffer.beginRender(mc.displayWidth, mc.displayHeight);
|
||||
~ GlStateManager.colorMask(true, true, true, true);
|
||||
~ GlStateManager.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
~ GlStateManager.clear(16640);
|
||||
~ this.mc.ingameGUI.renderGameOverlay(parFloat1);
|
||||
~ this.overlayFramebuffer.endRender();
|
||||
~ }
|
||||
~ this.setupOverlayRendering();
|
||||
~ GlStateManager.enableBlend();
|
||||
~ if (Minecraft.isFancyGraphicsEnabled()) {
|
||||
~ this.mc.ingameGUI.renderVignette(parFloat1, l, i1);
|
||||
~ }
|
||||
~ this.mc.ingameGUI.renderGameOverlayCrosshairs(l, i1);
|
||||
~ GlStateManager.bindTexture(this.overlayFramebuffer.getTexture());
|
||||
~ GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
~ GlStateManager.enableBlend();
|
||||
~ GlStateManager.blendFunc(770, 771);
|
||||
~ GlStateManager.disableAlpha();
|
||||
~ GlStateManager.disableDepth();
|
||||
~ GlStateManager.depthMask(false);
|
||||
~ Tessellator tessellator = Tessellator.getInstance();
|
||||
~ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
||||
~ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
~ worldrenderer.pos(0.0D, (double) i1, -90.0D).tex(0.0D, 0.0D).endVertex();
|
||||
~ worldrenderer.pos((double) l, (double) i1, -90.0D).tex(1.0D, 0.0D).endVertex();
|
||||
~ worldrenderer.pos((double) l, 0.0D, -90.0D).tex(1.0D, 1.0D).endVertex();
|
||||
~ worldrenderer.pos(0.0D, 0.0D, -90.0D).tex(0.0D, 1.0D).endVertex();
|
||||
~ tessellator.draw();
|
||||
~ GlStateManager.depthMask(true);
|
||||
~ GlStateManager.enableDepth();
|
||||
~ GlStateManager.enableAlpha();
|
||||
~ GlStateManager.disableBlend();
|
||||
~ if (this.mc.gameSettings.hudPlayer) { // give the player model HUD good fps
|
||||
~ this.mc.ingameGUI.drawEaglerPlayerOverlay(l - 3, 3, parFloat1);
|
||||
~ }
|
||||
|
||||
> CHANGE 23 : 24 @ 23 : 24
|
||||
|
||||
~ return EntityRenderer.this.mc.currentScreen.getClass().getName();
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
|
||||
+ public boolean hudFps = true;
|
||||
+ public boolean hudCoords = true;
|
||||
+ public boolean hudPlayer = true;
|
||||
+ public boolean hudPlayer = false;
|
||||
+ public boolean hudWorld = false;
|
||||
+ public boolean hudStats = false;
|
||||
+ public boolean hud24h = false;
|
||||
|
|
|
@ -8,7 +8,7 @@ public class EaglercraftVersion {
|
|||
/// Customize these to fit your fork:
|
||||
|
||||
public static final String projectForkName = "EaglercraftX";
|
||||
public static final String projectForkVersion = "u12";
|
||||
public static final String projectForkVersion = "u13";
|
||||
public static final String projectForkVendor = "lax1dude";
|
||||
|
||||
public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8";
|
||||
|
@ -23,7 +23,7 @@ public class EaglercraftVersion {
|
|||
public static final String projectOriginName = "EaglercraftX";
|
||||
public static final String projectOriginAuthor = "lax1dude";
|
||||
public static final String projectOriginRevision = "1.8";
|
||||
public static final String projectOriginVersion = "u12";
|
||||
public static final String projectOriginVersion = "u13";
|
||||
|
||||
public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8";
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class EaglercraftVersion {
|
|||
public static final String mainMenuStringA = "Minecraft 1.8.8";
|
||||
public static final String mainMenuStringB = projectOriginName + " " +
|
||||
projectOriginRevision + "-" + projectOriginVersion;
|
||||
public static final String mainMenuStringC = "Rewritten by " + projectOriginAuthor;
|
||||
public static final String mainMenuStringC = null;
|
||||
public static final String mainMenuStringD = "Resources Copyright Mojang AB";
|
||||
|
||||
public static final String mainMenuStringE = projectForkName + " " + projectForkVersion;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
*/
|
||||
|
||||
precision lowp int;
|
||||
precision highp float;
|
||||
precision lowp float;
|
||||
precision lowp sampler2D;
|
||||
|
||||
in vec2 v_texCoord2f;
|
||||
in vec4 v_color4f;
|
||||
|
||||
out vec4 output4f;
|
||||
layout(location = 0) out vec4 output4f;
|
||||
|
||||
uniform sampler2D u_inputTexture;
|
||||
uniform vec4 u_colorBias4f;
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
*/
|
||||
|
||||
precision lowp int;
|
||||
precision highp float;
|
||||
precision lowp float;
|
||||
precision lowp sampler2D;
|
||||
|
||||
in vec3 a_position3f;
|
||||
layout(location = 0) in vec3 a_position3f;
|
||||
|
||||
in vec2 c_position2i;
|
||||
in vec2 c_coords2i;
|
||||
in vec4 c_color4f;
|
||||
layout(location = 1) in vec2 c_position2i;
|
||||
layout(location = 2) in vec2 c_coords2i;
|
||||
layout(location = 3) in vec4 c_color4f;
|
||||
|
||||
out vec2 v_texCoord2f;
|
||||
out vec4 v_color4f;
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
*/
|
||||
|
||||
precision lowp int;
|
||||
precision highp float;
|
||||
precision highp sampler2D;
|
||||
precision lowp float;
|
||||
precision lowp sampler2D;
|
||||
|
||||
in vec2 v_texCoord2f;
|
||||
in vec4 v_color4f;
|
||||
|
||||
out vec4 output4f;
|
||||
layout(location = 0) out vec4 output4f;
|
||||
|
||||
uniform sampler2D u_inputTexture;
|
||||
|
||||
|
|
|
@ -15,16 +15,16 @@
|
|||
*/
|
||||
|
||||
precision lowp int;
|
||||
precision highp float;
|
||||
precision lowp float;
|
||||
precision lowp sampler2D;
|
||||
|
||||
in vec2 a_position2f;
|
||||
layout(location = 0) in vec2 a_position2f;
|
||||
|
||||
in vec3 p_position3f;
|
||||
in vec2 p_texCoords2i;
|
||||
in vec2 p_lightMap2f;
|
||||
in vec2 p_particleSize_texCoordsSize_2i;
|
||||
in vec4 p_color4f;
|
||||
layout(location = 1) in vec3 p_position3f;
|
||||
layout(location = 2) in vec2 p_texCoords2i;
|
||||
layout(location = 3) in vec2 p_lightMap2f;
|
||||
layout(location = 4) in vec2 p_particleSize_texCoordsSize_2i;
|
||||
layout(location = 5) in vec4 p_color4f;
|
||||
|
||||
out vec2 v_texCoord2f;
|
||||
out vec4 v_color4f;
|
||||
|
|
|
@ -87,7 +87,7 @@ uniform mat4 u_textureMat4f01;
|
|||
uniform vec2 u_textureAnisotropicFix;
|
||||
#endif
|
||||
|
||||
out vec4 output4f;
|
||||
layout(location = 0) out vec4 output4f;
|
||||
|
||||
void main() {
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ precision lowp int;
|
|||
precision lowp float;
|
||||
precision lowp sampler2D;
|
||||
|
||||
in vec2 a_position2f;
|
||||
layout(location = 0) in vec2 a_position2f;
|
||||
|
||||
out vec2 v_position2f;
|
||||
|
||||
|
|
|
@ -47,12 +47,12 @@
|
|||
*/
|
||||
|
||||
precision lowp int;
|
||||
precision highp float;
|
||||
precision highp sampler2D;
|
||||
precision mediump float;
|
||||
precision lowp sampler2D;
|
||||
|
||||
in vec2 v_position2f;
|
||||
|
||||
out vec4 output4f;
|
||||
layout(location = 0) out vec4 output4f;
|
||||
|
||||
uniform sampler2D u_screenTexture;
|
||||
uniform vec2 u_screenSize2f;
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
*/
|
||||
|
||||
precision lowp int;
|
||||
precision highp float;
|
||||
precision lowp float;
|
||||
precision lowp sampler2D;
|
||||
|
||||
in vec2 v_position2f;
|
||||
|
||||
out vec4 output4f;
|
||||
layout(location = 0) out vec4 output4f;
|
||||
|
||||
uniform sampler2D u_inputTexture;
|
||||
uniform float u_textureLod1f;
|
||||
|
|
Loading…
Reference in New Issue
Block a user