Skip to content

Commit

Permalink
Start to implement use of createSwapTextureSet
Browse files Browse the repository at this point in the history
  • Loading branch information
StellaArtois committed Nov 16, 2015
1 parent af91d6c commit 5e34ca7
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ patchsrc/
src/JRift
bin/intelij_prod
optionsvrprofiles.txt
crash-reports/
2 changes: 1 addition & 1 deletion JRift
3 changes: 3 additions & 0 deletions normalisePatchLineEndings.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off
python normalisePatchLineEndings.py %*

18 changes: 18 additions & 0 deletions normalisePatchLineEndings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import sys, os

def normalisePatchLineEndings():

base_dir = os.path.dirname(os.path.abspath(__file__))
patchDir = os.path.join(base_dir, 'patches')
for root, dirs, files in os.walk(patchDir):
for file in files:
if file.endswith(".java.patch"):
fileContent = ''
patchFile = os.path.join(root, file)
with open( patchFile, 'rb') as input:
fileContent = input.read()
with open( patchFile, 'wb') as out:
out.write( fileContent.replace('\r\n','\n').replace('\r','\n') )

if __name__ == '__main__':
normalisePatchLineEndings()
50 changes: 38 additions & 12 deletions patches/net/minecraft/client/Minecraft.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
+ public int currentDisplayWidth = 0;
+ public int currentDisplayHeight = 0;
+
+ public final String minecriftVerString = "Minecrift 1.7.10 R1b";
+ public final String minecriftVerString = "Minecrift 1.7.10 R1c";
+ /** END MINECRIFT */
+
public Minecraft(Session sessionIn, int displayWidth, int displayHeight, boolean fullscreen, boolean isDemo, File dataDir, File assetsDir, File resourcePackDir, Proxy proxy, String version, Multimap twitchDetails, String assetsJsonVersion)
Expand Down Expand Up @@ -320,6 +320,15 @@
}
catch (LWJGLException var7)
{
@@ -539,7 +684,7 @@
logger.error("Couldn\'t initialize twitch stream");
}

- this.framebufferMc = new Framebuffer(this.displayWidth, this.displayHeight, true);
+ this.framebufferMc = new Framebuffer(this.displayWidth, this.displayHeight, true); // TODO: Need to set this to the guiFramebuffer instead?
this.framebufferMc.setFramebufferColor(0.0F, 0.0F, 0.0F, 0.0F);
this.guiAchievement = new GuiAchievement(this);
this.metadataSerializer_.registerMetadataSectionType(new TextureMetadataSectionSerializer(), TextureMetadataSection.class);
@@ -552,11 +697,33 @@
this.mcResourceManager = new SimpleReloadableResourceManager(this.metadataSerializer_);
this.mcLanguageManager = new LanguageManager(this.metadataSerializer_, this.gameSettings.language);
Expand Down Expand Up @@ -1622,7 +1631,7 @@

/**
* Returns whether snooping is enabled or not.
@@ -3134,4 +3710,961 @@
@@ -3134,4 +3710,978 @@
}
}
}
Expand Down Expand Up @@ -1749,16 +1758,22 @@
+ if (this.framebuffers[0] != null) {
+ this.framebuffers[0].deleteFramebuffer();
+ this.framebuffers[0] = null;
+
+ // TODO: Delete swap texture set
+ }
+
+ if (this.framebuffers[1] != null) {
+ this.framebuffers[1].deleteFramebuffer();
+ this.framebuffers[1] = null;
+
+ // TODO: Delete swap texture set
+ }
+
+ if (this.guiFramebuffer != null) {
+ this.guiFramebuffer.deleteFramebuffer();
+ this.guiFramebuffer = null;
+
+ // TODO: Delete mirror texture
+ }
+
+ if (this.fsaaFirstPassResultFBO[0] != null) {
Expand All @@ -1782,25 +1797,36 @@
+ _LanczosShader_texelHeightOffsetUniform = -1;
+ _LanczosShader_inputImageTextureUniform = -1;
+
+ int multiSampleCount = 0; // TODO: The SDK (0.3.2 preview) doesn't like anything other than 0 currently AFAICT
+ int multiSampleCount = 0;
+ boolean multiSample = (multiSampleCount > 0 ? true : false);
+ boolean genMipMaps = true;
+ this.entityRenderer.generatedIconMipmaps[0] = false;
+ this.entityRenderer.generatedIconMipmaps[1] = false;
+
+ this.framebuffers[0] = new Framebuffer(this.EyeTextureSize[0].w, this.EyeTextureSize[0].h, true, genMipMaps, multiSample, multiSampleCount);
+ glConfig.TexId = this.framebuffers[0].framebufferTexture;
+ this.checkGLError("Viewport 1 framebuffer setup");
+ this.framebuffers[1] = new Framebuffer(this.EyeTextureSize[1].w, this.EyeTextureSize[1].h, true, genMipMaps, multiSample, multiSampleCount);
+ glConfig.TexId2 = this.framebuffers[1].framebufferTexture;
+ this.checkGLError("Viewport 2 framebuffer setup");
+ SwapTextureSet renderTextures = this.stereoProvider.createSwapTextureSet(this.EyeTextureSize[0].w, this.EyeTextureSize[0].h); // TODO: Support differing buffer sizes for each eye?
+ if (renderTextures == null)
+ {
+ this.framebuffers[0] = new Framebuffer(this.EyeTextureSize[0].w, this.EyeTextureSize[0].h, true, genMipMaps, multiSample, multiSampleCount, Framebuffer.NO_TEXTURE_ID);
+ glConfig.TexId = this.framebuffers[0].framebufferTexture;
+ this.checkGLError("Viewport 1 framebuffer setup");
+ this.framebuffers[1] = new Framebuffer(this.EyeTextureSize[1].w, this.EyeTextureSize[1].h, true, genMipMaps, multiSample, multiSampleCount, Framebuffer.NO_TEXTURE_ID);
+ glConfig.TexId2 = this.framebuffers[1].framebufferTexture;
+ this.checkGLError("Viewport 2 framebuffer setup");
+ this.framebuffers[0].setFramebufferColor(RED_COLOUR_COMPONENT, GREEN_COLOUR_COMPONENT, BLUE_COLOUR_COMPONENT, 0.0F);
+ this.framebuffers[1].setFramebufferColor(RED_COLOUR_COMPONENT, GREEN_COLOUR_COMPONENT, BLUE_COLOUR_COMPONENT, 0.0F);
+ }
+ else
+ {
+ // TODO: Initialise framebuffer sets...
+ }
+
+ // TODO: How to initialise mirror texture?
+
+ this.guiFramebuffer = new Framebuffer(this.displayFBWidth, this.displayFBHeight, true, genMipMaps);
+ this.checkGLError("GUI framebuffer setup");
+
+ this.framebuffers[0].setFramebufferColor(RED_COLOUR_COMPONENT, GREEN_COLOUR_COMPONENT, BLUE_COLOUR_COMPONENT, 0.0F);
+ this.framebuffers[1].setFramebufferColor(RED_COLOUR_COMPONENT, GREEN_COLOUR_COMPONENT, BLUE_COLOUR_COMPONENT, 0.0F);
+ this.guiFramebuffer.setFramebufferColor(RED_COLOUR_COMPONENT, GREEN_COLOUR_COMPONENT, BLUE_COLOUR_COMPONENT, 0.0F);
+
+
+ try
+ {
+ if (this.vrSettings.useFsaa)
Expand Down
100 changes: 79 additions & 21 deletions patches/net/minecraft/client/shader/Framebuffer.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class Framebuffer
{
@@ -20,8 +28,28 @@
@@ -20,22 +28,62 @@
public int framebufferFilter;
private static final String __OBFID = "CL_00000959";

Expand All @@ -29,60 +29,118 @@
+ public boolean multiSample = false;
+ public int multiSampleCount = 0;
+ public int textureType = GL11.GL_TEXTURE_2D;
+ public static final int NO_TEXTURE_ID = -1;
+ public boolean generatedFramebufferTexture = true;
+ /** END MINECRIFT */
+
public Framebuffer(int p_i45078_1_, int p_i45078_2_, boolean p_i45078_3_)
{
+ /** MINECRIFT */
+ this(p_i45078_1_, p_i45078_2_, p_i45078_3_, false, false, 0);
+ this(p_i45078_1_, p_i45078_2_, p_i45078_3_, false, false, 0, NO_TEXTURE_ID);
+ }
+
+ public Framebuffer(int p_i45078_1_, int p_i45078_2_, boolean p_i45078_3_, boolean generateMipMaps)
+ {
+ this(p_i45078_1_, p_i45078_2_, p_i45078_3_, generateMipMaps, false, 0);
+ this(p_i45078_1_, p_i45078_2_, p_i45078_3_, generateMipMaps, false, 0, NO_TEXTURE_ID);
+ }
+
+ public Framebuffer(int p_i45078_1_, int p_i45078_2_, boolean p_i45078_3_, boolean generateMipMaps, boolean multisample, int multisamplecount)
+ public Framebuffer(int p_i45078_1_, int p_i45078_2_, boolean p_i45078_3_, boolean generateMipMaps, boolean multisample, int multisamplecount, int textureId)
+ {
+ /** END MINECRIFT */
+ /** MINECRIFT */
this.useDepth = p_i45078_3_;
this.framebufferObject = -1;
this.framebufferTexture = -1;
@@ -31,6 +59,15 @@
- this.framebufferTexture = -1;
+ this.framebufferTexture = NO_TEXTURE_ID;
+ this.generatedFramebufferTexture = true;
this.depthBuffer = -1;
this.framebufferColor = new float[4];
this.framebufferColor[0] = 1.0F;
this.framebufferColor[1] = 1.0F;
this.framebufferColor[2] = 1.0F;
this.framebufferColor[3] = 0.0F;
- this.createBindFramebuffer(p_i45078_1_, p_i45078_2_);
+
+ /** MINECRIFT */
+ this.genMipMaps = generateMipMaps;
+ this.multiSample = multisample;
+ if (this.multiSample) {
+ this.multiSampleCount = multisamplecount;
+ this.textureType = GL32.GL_TEXTURE_2D_MULTISAMPLE;
+ }
+
+ /** END MINECRIFT */
this.createBindFramebuffer(p_i45078_1_, p_i45078_2_);
+ this.createBindFramebuffer(p_i45078_1_, p_i45078_2_, textureId);
}

@@ -51,7 +88,9 @@
public void createBindFramebuffer(int p_147613_1_, int p_147613_2_)
{
+/** MINECRIFT */
+ createBindFramebuffer(p_147613_1_, p_147613_2_, NO_TEXTURE_ID);
+ }
+
+ public void createBindFramebuffer(int p_147613_1_, int p_147613_2_, int textureId)
+ {
+/** END MINECRIFT */
if (!OpenGlHelper.isFramebufferEnabled())
{
this.framebufferWidth = p_147613_1_;
@@ -50,8 +98,10 @@
this.deleteFramebuffer();
}

this.createFramebuffer(p_147613_1_, p_147613_2_);
- this.createFramebuffer(p_147613_1_, p_147613_2_);
- this.checkFramebufferComplete();
+ this.createFramebuffer(p_147613_1_, p_147613_2_, textureId);
+ /** MINECRIFT *
+ this.checkFramebufferComplete();
+ ** END MINECRIFT */
OpenGlHelper.func_153171_g(OpenGlHelper.field_153198_e, 0);
}
}
@@ -97,43 +136,81 @@
@@ -68,8 +118,9 @@
OpenGlHelper.func_153184_g(this.depthBuffer);
this.depthBuffer = -1;
}
-
- if (this.framebufferTexture > -1)
+ /* MINECRIFT */
+ if (this.framebufferTexture > NO_TEXTURE_ID && this.generatedFramebufferTexture == true)
+ /* END MINECRIFT */
{
TextureUtil.deleteTexture(this.framebufferTexture);
this.framebufferTexture = -1;
@@ -86,6 +137,13 @@

public void createFramebuffer(int p_147605_1_, int p_147605_2_)
{
+/** MINECRIFT */
+ createFramebuffer(p_147605_1_, p_147605_2_, NO_TEXTURE_ID);
+ }
+
+ public void createFramebuffer(int p_147605_1_, int p_147605_2_, int textureId)
+ {
+/** END MINECRIFT */
this.framebufferWidth = p_147605_1_;
this.framebufferHeight = p_147605_2_;
this.framebufferTextureWidth = p_147605_1_;
@@ -97,43 +155,90 @@
}
else
{
- this.framebufferObject = OpenGlHelper.func_153165_e();
- this.framebufferTexture = TextureUtil.glGenTextures();
+ /** MINECRIFT */
+ this.framebufferObject = OpenGlHelper.func_153165_e(); // GL30.glGenFramebuffers()
this.framebufferTexture = TextureUtil.glGenTextures();
+ if (textureId != NO_TEXTURE_ID) {
+ // generate texture
+ this.framebufferTexture = TextureUtil.glGenTextures();
+ this.generatedFramebufferTexture = true;
+ }
+ else {
+ // Use supplied texture ID
+ this.framebufferTexture = textureId;
+ this.generatedFramebufferTexture = false;
+ }

if (this.useDepth)
{
Expand Down Expand Up @@ -139,15 +197,15 @@
+ /** END MINECRIFT */
}
+
+ }
+
}
+ /** MINECRIFT */
+ public void genMipMaps()
+ {
+ GL30.glGenerateMipmap(this.textureType); // TODO: Minecrift - Check GLContext capabilities
}
+ }
+ /** END MINECRIFT */
+
public void setFramebufferFilter(int p_147607_1_)
{
if (OpenGlHelper.isFramebufferEnabled())
Expand All @@ -172,7 +230,7 @@
}
}

@@ -159,6 +236,12 @@
@@ -159,6 +264,12 @@
{
throw new RuntimeException("GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER");
}
Expand All @@ -185,7 +243,7 @@
else
{
throw new RuntimeException("glCheckFramebufferStatus returned unknown status:" + var1);
@@ -168,18 +251,22 @@
@@ -168,18 +279,22 @@

public void bindFramebufferTexture()
{
Expand All @@ -210,7 +268,7 @@
}

public void bindFramebuffer(boolean p_147610_1_)
@@ -213,6 +300,13 @@
@@ -213,6 +328,13 @@

public void framebufferRender(int p_147615_1_, int p_147615_2_)
{
Expand All @@ -224,7 +282,7 @@
if (OpenGlHelper.isFramebufferEnabled())
{
GL11.glColorMask(true, true, true, false);
@@ -224,8 +318,10 @@
@@ -224,8 +346,10 @@
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
Expand All @@ -237,7 +295,7 @@
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
@@ -265,4 +361,44 @@
@@ -265,4 +389,44 @@
GL11.glClear(var1);
this.unbindFramebuffer();
}
Expand Down
2 changes: 2 additions & 0 deletions src/com/mtbs3d/minecrift/api/IStereoProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public EyeRenderParams configureRenderingDualTexture(Sizei InTexture1Size,
FovPort RightFov,
float worldScale);

public SwapTextureSet createSwapTextureSet(int width, int height);

public void resetRenderConfig();

public EyeType eyeRenderOrder(int index);
Expand Down
6 changes: 6 additions & 0 deletions src/com/mtbs3d/minecrift/provider/NullStereoRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,10 @@ public double getCurrentTimeSecs()
{
return System.nanoTime() / 1000000000d;
}

@Override
public SwapTextureSet createSwapTextureSet(int width, int height)
{
return null;
}
}

0 comments on commit 5e34ca7

Please sign in to comment.