From d43850e80438b7b8e0cacbb5a2e7ae9d14baa02d Mon Sep 17 00:00:00 2001 From: MachineMuse Date: Thu, 16 May 2013 10:58:09 -0600 Subject: [PATCH] behold the future of glowy shit in minecraft --- .../shaders/depthapplicator.frag | 8 + .../mmmPowersuits/shaders/depthocclusion.frag | 20 ++ .../mmmPowersuits/shaders/depthocclusion.vert | 4 + mods/mmmPowersuits/shaders/gaussianblur.frag | 22 +- mods/mmmPowersuits/shaders/gaussianblur.vert | 4 + .../general/geometry/DrawableMuseCircle.java | 2 +- .../general/geometry/DrawableMuseRect.java | 2 +- .../general/geometry/RadialIndicator.java | 2 +- .../general/geometry/SwirlyMuseCircle.java | 2 +- .../machinemuse/general/gui/EnergyMeter.java | 2 +- .../general/gui/GuiFieldTinker.java | 2 +- .../general/gui/GuiTinkerTable.java | 3 +- .../machinemuse/general/gui/HeatMeter.java | 2 +- .../net/machinemuse/general/gui/MuseGui.java | 2 +- .../gui/clickable/ClickableButton.java | 2 +- .../general/gui/clickable/ClickableItem.java | 3 +- .../gui/clickable/ClickableKeybinding.java | 2 +- .../general/gui/clickable/ClickableLabel.java | 2 +- .../gui/clickable/ClickableModule.scala | 4 +- .../gui/clickable/ClickableSlider.scala | 3 +- .../general/gui/frame/ColourPickerFrame.scala | 3 +- .../gui/frame/InstallSalvageFrame.java | 2 +- .../general/gui/frame/ItemInfoFrame.java | 2 +- .../general/gui/frame/ItemSelectionFrame.java | 2 +- .../general/gui/frame/KeybindConfigFrame.java | 2 +- .../gui/frame/ModuleSelectionFrame.java | 2 +- .../gui/frame/ModuleSelectionSubFrame.java | 2 +- .../general/gui/frame/ModuleTweakFrame.java | 2 +- .../general/gui/frame/PartManipSubFrame.scala | 3 +- .../general/gui/frame/ScrollableFrame.java | 2 +- .../general/gui/frame/StatsFrame.java | 2 +- .../powersuits/client/ClientProxy.java | 4 +- .../render/block/RenderLuxCapacitorTESR.java | 2 +- .../client/render/block/TinkerTableModel.java | 2 +- .../entity/RenderLuxCapacitorEntity.java | 2 +- .../render/entity/RenderPlasmaBolt.java | 2 +- .../render/entity/RenderSpinningBlade.java | 2 +- .../client/render/item/ToolModel.java | 2 +- .../client/render/item/ToolRenderer.java | 2 +- .../client/render/modelspec/RenderPart.scala | 2 +- .../event/TextureStitchHandler.java | 2 +- .../powersuits/item/ItemPowerArmorBoots.scala | 2 +- .../item/ItemPowerArmorChestplate.scala | 2 +- .../item/ItemPowerArmorHelmet.scala | 3 +- .../item/ItemPowerArmorLeggings.scala | 2 +- .../powersuits/tick/RenderTickHandler.java | 2 + .../net/machinemuse/utils/GlowBuffer.scala | 75 ------- .../net/machinemuse/utils/MuseShader.scala | 85 -------- .../utils/{ => render}/BufferMapper.scala | 3 +- .../utils/render/DepthBuffer.scala | 41 ++++ .../machinemuse/utils/render/GlowBuffer.scala | 206 ++++++++++++++++++ .../utils/{ => render}/GuiIcons.scala | 8 +- .../utils/{ => render}/MuseRenderer.java | 8 +- .../utils/render/MuseShaders.scala | 22 ++ .../{ => render}/MuseStencilManager.scala | 2 +- .../utils/{ => render}/MuseTexture.scala | 2 +- .../net/machinemuse/utils/render/RMonad.scala | 120 ++++++++++ .../utils/render/ShaderProgram.scala | 75 +++++++ .../utils/{ => render}/SlickFont.scala | 2 +- .../utils/{ => render}/TextureBuffer.scala | 43 ++-- 60 files changed, 587 insertions(+), 255 deletions(-) create mode 100644 mods/mmmPowersuits/shaders/depthapplicator.frag create mode 100644 mods/mmmPowersuits/shaders/depthocclusion.frag create mode 100644 mods/mmmPowersuits/shaders/depthocclusion.vert create mode 100644 mods/mmmPowersuits/shaders/gaussianblur.vert delete mode 100644 src/minecraft/net/machinemuse/utils/GlowBuffer.scala delete mode 100644 src/minecraft/net/machinemuse/utils/MuseShader.scala rename src/minecraft/net/machinemuse/utils/{ => render}/BufferMapper.scala (73%) create mode 100644 src/minecraft/net/machinemuse/utils/render/DepthBuffer.scala create mode 100644 src/minecraft/net/machinemuse/utils/render/GlowBuffer.scala rename src/minecraft/net/machinemuse/utils/{ => render}/GuiIcons.scala (95%) rename src/minecraft/net/machinemuse/utils/{ => render}/MuseRenderer.java (99%) create mode 100644 src/minecraft/net/machinemuse/utils/render/MuseShaders.scala rename src/minecraft/net/machinemuse/utils/{ => render}/MuseStencilManager.scala (88%) rename src/minecraft/net/machinemuse/utils/{ => render}/MuseTexture.scala (72%) create mode 100644 src/minecraft/net/machinemuse/utils/render/RMonad.scala create mode 100644 src/minecraft/net/machinemuse/utils/render/ShaderProgram.scala rename src/minecraft/net/machinemuse/utils/{ => render}/SlickFont.scala (99%) rename src/minecraft/net/machinemuse/utils/{ => render}/TextureBuffer.scala (71%) diff --git a/mods/mmmPowersuits/shaders/depthapplicator.frag b/mods/mmmPowersuits/shaders/depthapplicator.frag new file mode 100644 index 0000000..5514ef2 --- /dev/null +++ b/mods/mmmPowersuits/shaders/depthapplicator.frag @@ -0,0 +1,8 @@ +#version 400 +uniform sampler2D depth; + +void main() { + vec2 coords = vec2(gl_TexCoord[0].x, gl_TexCoord[0].y); + gl_FragDepth = texture2D(depth, coords).r; + gl_FragColor = vec4(0.0); +} \ No newline at end of file diff --git a/mods/mmmPowersuits/shaders/depthocclusion.frag b/mods/mmmPowersuits/shaders/depthocclusion.frag new file mode 100644 index 0000000..1c60230 --- /dev/null +++ b/mods/mmmPowersuits/shaders/depthocclusion.frag @@ -0,0 +1,20 @@ +#version 400 +uniform sampler2D depth; +uniform sampler2D occlusion; +uniform sampler2D texture; + +void main() { + vec2 coords = vec2(gl_TexCoord[0].x, gl_TexCoord[0].y); + float depth = texture2D(depth, coords).r - 0.001; + float occlusion = texture2D(occlusion, coords).r; + vec4 color = vec4(0.0); + float writedepth = occlusion; + if(depth <= occlusion) { + color = texture2D(texture, coords); +// color = vec4(1.0); + writedepth = depth; + } +// color = vec4(vec3(occlusion - depth),1); + gl_FragDepth = writedepth; + gl_FragColor = color; +} \ No newline at end of file diff --git a/mods/mmmPowersuits/shaders/depthocclusion.vert b/mods/mmmPowersuits/shaders/depthocclusion.vert new file mode 100644 index 0000000..5d02387 --- /dev/null +++ b/mods/mmmPowersuits/shaders/depthocclusion.vert @@ -0,0 +1,4 @@ +void main(){ + gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; +} \ No newline at end of file diff --git a/mods/mmmPowersuits/shaders/gaussianblur.frag b/mods/mmmPowersuits/shaders/gaussianblur.frag index 03edba8..bea2690 100644 --- a/mods/mmmPowersuits/shaders/gaussianblur.frag +++ b/mods/mmmPowersuits/shaders/gaussianblur.frag @@ -1,28 +1,26 @@ -varying vec2 v_Coordinates; - +#version 400 uniform vec2 u_Scale; uniform sampler2D u_Texture0; -const vec2 gaussFilter[7] = { - -3.0, 0.015625, +const float gaussFilter[14] = float[14]( + -3.0, 0.015625, -2.0, 0.09375, -1.0, 0.234375, 0.0, 0.3125, 1.0, 0.234375, 2.0, 0.09375, 3.0, 0.015625 -}; +); void main() { - vec4 color = 0.0; + vec4 color = vec4(0.0); + float wt = 0.0; for( int i = 0; i < 7; i++ ) { - color += texture2D( u_Texture0, - vec2( - v_Coordinates.x+gaussFilter[i].x*u_Scale.x, - v_Coordinates.y+gaussFilter[i].x*u_Scale.y ) - )*gaussFilter[i].y; + vec4 pix = texture2D( u_Texture0, + vec2(gl_TexCoord[0].x+gaussFilter[i*2]*u_Scale.x, gl_TexCoord[0].y+gaussFilter[i*2]*u_Scale.y ) + ); + color += pix*gaussFilter[i*2+1] * pix.w*1.5; } - gl_FragColor = color; } \ No newline at end of file diff --git a/mods/mmmPowersuits/shaders/gaussianblur.vert b/mods/mmmPowersuits/shaders/gaussianblur.vert new file mode 100644 index 0000000..5d02387 --- /dev/null +++ b/mods/mmmPowersuits/shaders/gaussianblur.vert @@ -0,0 +1,4 @@ +void main(){ + gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; +} \ No newline at end of file diff --git a/src/minecraft/net/machinemuse/general/geometry/DrawableMuseCircle.java b/src/minecraft/net/machinemuse/general/geometry/DrawableMuseCircle.java index 8c3945e..3d737a6 100644 --- a/src/minecraft/net/machinemuse/general/geometry/DrawableMuseCircle.java +++ b/src/minecraft/net/machinemuse/general/geometry/DrawableMuseCircle.java @@ -1,6 +1,6 @@ package net.machinemuse.general.geometry; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; diff --git a/src/minecraft/net/machinemuse/general/geometry/DrawableMuseRect.java b/src/minecraft/net/machinemuse/general/geometry/DrawableMuseRect.java index 7f43fdb..fc29c94 100644 --- a/src/minecraft/net/machinemuse/general/geometry/DrawableMuseRect.java +++ b/src/minecraft/net/machinemuse/general/geometry/DrawableMuseRect.java @@ -1,6 +1,6 @@ package net.machinemuse.general.geometry; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; diff --git a/src/minecraft/net/machinemuse/general/geometry/RadialIndicator.java b/src/minecraft/net/machinemuse/general/geometry/RadialIndicator.java index efa03df..5712936 100644 --- a/src/minecraft/net/machinemuse/general/geometry/RadialIndicator.java +++ b/src/minecraft/net/machinemuse/general/geometry/RadialIndicator.java @@ -1,6 +1,6 @@ package net.machinemuse.general.geometry; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.util.Icon; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; diff --git a/src/minecraft/net/machinemuse/general/geometry/SwirlyMuseCircle.java b/src/minecraft/net/machinemuse/general/geometry/SwirlyMuseCircle.java index ebc5abc..4b3a879 100644 --- a/src/minecraft/net/machinemuse/general/geometry/SwirlyMuseCircle.java +++ b/src/minecraft/net/machinemuse/general/geometry/SwirlyMuseCircle.java @@ -1,6 +1,6 @@ package net.machinemuse.general.geometry; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import org.lwjgl.opengl.GL11; import java.nio.DoubleBuffer; diff --git a/src/minecraft/net/machinemuse/general/gui/EnergyMeter.java b/src/minecraft/net/machinemuse/general/gui/EnergyMeter.java index daeb4a6..8c356a8 100644 --- a/src/minecraft/net/machinemuse/general/gui/EnergyMeter.java +++ b/src/minecraft/net/machinemuse/general/gui/EnergyMeter.java @@ -1,7 +1,7 @@ package net.machinemuse.general.gui; import net.machinemuse.general.geometry.Colour; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.block.Block; import net.minecraft.util.Icon; import org.lwjgl.opengl.GL11; diff --git a/src/minecraft/net/machinemuse/general/gui/GuiFieldTinker.java b/src/minecraft/net/machinemuse/general/gui/GuiFieldTinker.java index 0fb5f45..88bc3a1 100644 --- a/src/minecraft/net/machinemuse/general/gui/GuiFieldTinker.java +++ b/src/minecraft/net/machinemuse/general/gui/GuiFieldTinker.java @@ -3,7 +3,7 @@ package net.machinemuse.general.gui; import net.machinemuse.general.geometry.Colour; import net.machinemuse.general.geometry.MusePoint2D; import net.machinemuse.general.gui.frame.*; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/minecraft/net/machinemuse/general/gui/GuiTinkerTable.java b/src/minecraft/net/machinemuse/general/gui/GuiTinkerTable.java index 03cf5e2..a43c9b8 100644 --- a/src/minecraft/net/machinemuse/general/gui/GuiTinkerTable.java +++ b/src/minecraft/net/machinemuse/general/gui/GuiTinkerTable.java @@ -2,9 +2,8 @@ package net.machinemuse.general.gui; import net.machinemuse.general.geometry.Colour; import net.machinemuse.general.geometry.MusePoint2D; -import net.machinemuse.general.gui.MuseGui; import net.machinemuse.general.gui.frame.*; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/minecraft/net/machinemuse/general/gui/HeatMeter.java b/src/minecraft/net/machinemuse/general/gui/HeatMeter.java index e9904f9..b128457 100644 --- a/src/minecraft/net/machinemuse/general/gui/HeatMeter.java +++ b/src/minecraft/net/machinemuse/general/gui/HeatMeter.java @@ -2,7 +2,7 @@ package net.machinemuse.general.gui; import net.machinemuse.general.geometry.Colour; import net.machinemuse.powersuits.common.Config; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.util.Icon; diff --git a/src/minecraft/net/machinemuse/general/gui/MuseGui.java b/src/minecraft/net/machinemuse/general/gui/MuseGui.java index 63ef941..87b4049 100644 --- a/src/minecraft/net/machinemuse/general/gui/MuseGui.java +++ b/src/minecraft/net/machinemuse/general/gui/MuseGui.java @@ -4,7 +4,7 @@ import net.machinemuse.general.geometry.Colour; import net.machinemuse.general.geometry.DrawableMuseRect; import net.machinemuse.general.gui.clickable.IClickable; import net.machinemuse.general.gui.frame.IGuiFrame; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.client.gui.GuiScreen; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; diff --git a/src/minecraft/net/machinemuse/general/gui/clickable/ClickableButton.java b/src/minecraft/net/machinemuse/general/gui/clickable/ClickableButton.java index d2c6686..0546fd0 100644 --- a/src/minecraft/net/machinemuse/general/gui/clickable/ClickableButton.java +++ b/src/minecraft/net/machinemuse/general/gui/clickable/ClickableButton.java @@ -6,7 +6,7 @@ package net.machinemuse.general.gui.clickable; import net.machinemuse.general.geometry.Colour; import net.machinemuse.general.geometry.DrawableMuseRect; import net.machinemuse.general.geometry.MusePoint2D; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import java.util.List; diff --git a/src/minecraft/net/machinemuse/general/gui/clickable/ClickableItem.java b/src/minecraft/net/machinemuse/general/gui/clickable/ClickableItem.java index faabb12..ef8c512 100644 --- a/src/minecraft/net/machinemuse/general/gui/clickable/ClickableItem.java +++ b/src/minecraft/net/machinemuse/general/gui/clickable/ClickableItem.java @@ -2,8 +2,7 @@ package net.machinemuse.general.gui.clickable; import net.machinemuse.general.geometry.Colour; import net.machinemuse.general.geometry.MusePoint2D; -import net.machinemuse.utils.MuseRenderer; -import net.machinemuse.utils.MuseStringUtils; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.item.ItemStack; diff --git a/src/minecraft/net/machinemuse/general/gui/clickable/ClickableKeybinding.java b/src/minecraft/net/machinemuse/general/gui/clickable/ClickableKeybinding.java index fa3c8c8..5ae8343 100644 --- a/src/minecraft/net/machinemuse/general/gui/clickable/ClickableKeybinding.java +++ b/src/minecraft/net/machinemuse/general/gui/clickable/ClickableKeybinding.java @@ -7,7 +7,7 @@ import net.machinemuse.general.geometry.Colour; import net.machinemuse.general.geometry.MusePoint2D; import net.machinemuse.powersuits.network.packets.MusePacketToggleRequest; import net.machinemuse.utils.MuseItemUtils; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.settings.KeyBinding; diff --git a/src/minecraft/net/machinemuse/general/gui/clickable/ClickableLabel.java b/src/minecraft/net/machinemuse/general/gui/clickable/ClickableLabel.java index 72af1b3..98465a6 100644 --- a/src/minecraft/net/machinemuse/general/gui/clickable/ClickableLabel.java +++ b/src/minecraft/net/machinemuse/general/gui/clickable/ClickableLabel.java @@ -1,7 +1,7 @@ package net.machinemuse.general.gui.clickable; import net.machinemuse.general.geometry.MusePoint2D; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import java.util.List; diff --git a/src/minecraft/net/machinemuse/general/gui/clickable/ClickableModule.scala b/src/minecraft/net/machinemuse/general/gui/clickable/ClickableModule.scala index 0393bc1..9f0bedc 100644 --- a/src/minecraft/net/machinemuse/general/gui/clickable/ClickableModule.scala +++ b/src/minecraft/net/machinemuse/general/gui/clickable/ClickableModule.scala @@ -3,8 +3,8 @@ package net.machinemuse.general.gui.clickable import net.machinemuse.api.IPowerModule import net.machinemuse.general.geometry.Colour import net.machinemuse.general.geometry.MusePoint2D -import net.machinemuse.utils.GuiIcons.Checkmark -import net.machinemuse.utils.MuseRenderer +import net.machinemuse.utils.render.{MuseRenderer, GuiIcons} +import GuiIcons.Checkmark import net.machinemuse.utils.MuseStringUtils import java.util.ArrayList import java.util.List diff --git a/src/minecraft/net/machinemuse/general/gui/clickable/ClickableSlider.scala b/src/minecraft/net/machinemuse/general/gui/clickable/ClickableSlider.scala index ab0fc55..84d58ec 100644 --- a/src/minecraft/net/machinemuse/general/gui/clickable/ClickableSlider.scala +++ b/src/minecraft/net/machinemuse/general/gui/clickable/ClickableSlider.scala @@ -2,7 +2,8 @@ package net.machinemuse.general.gui.clickable import java.lang.String import net.machinemuse.general.geometry.{MusePoint2D, Colour, DrawableMuseRect} -import net.machinemuse.utils.{MuseMathUtils, MuseRenderer} +import net.machinemuse.utils.{MuseMathUtils} +import net.machinemuse.utils.render.MuseRenderer /** * Author: MachineMuse (Claire Semple) diff --git a/src/minecraft/net/machinemuse/general/gui/frame/ColourPickerFrame.scala b/src/minecraft/net/machinemuse/general/gui/frame/ColourPickerFrame.scala index e3d4839..b1b6732 100644 --- a/src/minecraft/net/machinemuse/general/gui/frame/ColourPickerFrame.scala +++ b/src/minecraft/net/machinemuse/general/gui/frame/ColourPickerFrame.scala @@ -7,7 +7,8 @@ import net.machinemuse.general.{MuseLogger, NBTTagAccessor} import net.machinemuse.utils.{MuseMathUtils, MuseItemUtils} import scala.collection.mutable.ArrayBuffer import scala.collection.immutable.HashSet -import net.machinemuse.utils.GuiIcons._ +import net.machinemuse.utils.render.GuiIcons +import GuiIcons._ import scala.collection.mutable import scala.{Array, Some} import net.machinemuse.powersuits.item.ItemPowerArmor diff --git a/src/minecraft/net/machinemuse/general/gui/frame/InstallSalvageFrame.java b/src/minecraft/net/machinemuse/general/gui/frame/InstallSalvageFrame.java index dbeea61..42c9226 100644 --- a/src/minecraft/net/machinemuse/general/gui/frame/InstallSalvageFrame.java +++ b/src/minecraft/net/machinemuse/general/gui/frame/InstallSalvageFrame.java @@ -15,7 +15,7 @@ import net.machinemuse.powersuits.network.MusePacket; import net.machinemuse.powersuits.network.packets.MusePacketInstallModuleRequest; import net.machinemuse.powersuits.network.packets.MusePacketSalvageModuleRequest; import net.machinemuse.utils.MuseItemUtils; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.item.ItemStack; diff --git a/src/minecraft/net/machinemuse/general/gui/frame/ItemInfoFrame.java b/src/minecraft/net/machinemuse/general/gui/frame/ItemInfoFrame.java index 8b6a1ec..eb4c88f 100644 --- a/src/minecraft/net/machinemuse/general/gui/frame/ItemInfoFrame.java +++ b/src/minecraft/net/machinemuse/general/gui/frame/ItemInfoFrame.java @@ -5,7 +5,7 @@ import net.machinemuse.general.geometry.Colour; import net.machinemuse.general.geometry.MusePoint2D; import net.machinemuse.general.gui.clickable.ClickableItem; import net.machinemuse.utils.MuseItemUtils; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.entity.player.EntityPlayer; import org.lwjgl.opengl.GL11; diff --git a/src/minecraft/net/machinemuse/general/gui/frame/ItemSelectionFrame.java b/src/minecraft/net/machinemuse/general/gui/frame/ItemSelectionFrame.java index b0c9b4d..9ddb535 100644 --- a/src/minecraft/net/machinemuse/general/gui/frame/ItemSelectionFrame.java +++ b/src/minecraft/net/machinemuse/general/gui/frame/ItemSelectionFrame.java @@ -7,7 +7,7 @@ import net.machinemuse.general.gui.clickable.ClickableItem; import net.machinemuse.general.sound.Musique; import net.machinemuse.general.sound.SoundLoader; import net.machinemuse.utils.MuseItemUtils; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.entity.player.EntityPlayer; import java.util.ArrayList; diff --git a/src/minecraft/net/machinemuse/general/gui/frame/KeybindConfigFrame.java b/src/minecraft/net/machinemuse/general/gui/frame/KeybindConfigFrame.java index 2401f73..44b1d95 100644 --- a/src/minecraft/net/machinemuse/general/gui/frame/KeybindConfigFrame.java +++ b/src/minecraft/net/machinemuse/general/gui/frame/KeybindConfigFrame.java @@ -12,7 +12,7 @@ import net.machinemuse.general.gui.clickable.IClickable; import net.machinemuse.powersuits.common.Config; import net.machinemuse.powersuits.control.KeybindManager; import net.machinemuse.utils.MuseItemUtils; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.EntityPlayer; import org.lwjgl.input.Keyboard; diff --git a/src/minecraft/net/machinemuse/general/gui/frame/ModuleSelectionFrame.java b/src/minecraft/net/machinemuse/general/gui/frame/ModuleSelectionFrame.java index 165e20d..4a8fee0 100644 --- a/src/minecraft/net/machinemuse/general/gui/frame/ModuleSelectionFrame.java +++ b/src/minecraft/net/machinemuse/general/gui/frame/ModuleSelectionFrame.java @@ -10,7 +10,7 @@ import net.machinemuse.general.gui.clickable.ClickableModule; import net.machinemuse.general.sound.Musique; import net.machinemuse.general.sound.SoundLoader; import net.machinemuse.utils.MuseItemUtils; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import org.lwjgl.opengl.GL11; import java.util.*; diff --git a/src/minecraft/net/machinemuse/general/gui/frame/ModuleSelectionSubFrame.java b/src/minecraft/net/machinemuse/general/gui/frame/ModuleSelectionSubFrame.java index 468b88b..d83c044 100644 --- a/src/minecraft/net/machinemuse/general/gui/frame/ModuleSelectionSubFrame.java +++ b/src/minecraft/net/machinemuse/general/gui/frame/ModuleSelectionSubFrame.java @@ -5,7 +5,7 @@ import net.machinemuse.general.geometry.MusePoint2D; import net.machinemuse.general.geometry.MuseRect; import net.machinemuse.general.geometry.MuseRelativeRect; import net.machinemuse.general.gui.clickable.ClickableModule; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import java.util.ArrayList; import java.util.List; diff --git a/src/minecraft/net/machinemuse/general/gui/frame/ModuleTweakFrame.java b/src/minecraft/net/machinemuse/general/gui/frame/ModuleTweakFrame.java index c1c3f4f..30d042b 100644 --- a/src/minecraft/net/machinemuse/general/gui/frame/ModuleTweakFrame.java +++ b/src/minecraft/net/machinemuse/general/gui/frame/ModuleTweakFrame.java @@ -12,7 +12,7 @@ import net.machinemuse.powersuits.network.packets.MusePacketTweakRequest; import net.machinemuse.powersuits.powermodule.PowerModule; import net.machinemuse.powersuits.powermodule.PropertyModifierLinearAdditive; import net.machinemuse.utils.MuseItemUtils; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.machinemuse.utils.MuseStringUtils; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.item.ItemStack; diff --git a/src/minecraft/net/machinemuse/general/gui/frame/PartManipSubFrame.scala b/src/minecraft/net/machinemuse/general/gui/frame/PartManipSubFrame.scala index 4540fa8..53c75d4 100644 --- a/src/minecraft/net/machinemuse/general/gui/frame/PartManipSubFrame.scala +++ b/src/minecraft/net/machinemuse/general/gui/frame/PartManipSubFrame.scala @@ -2,7 +2,7 @@ package net.machinemuse.general.gui.frame import net.machinemuse.powersuits.client.render.modelspec.{ModelRegistry, ModelPartSpec, ModelSpec} import net.machinemuse.general.geometry.{Colour, MuseRect, MuseRelativeRect} -import net.machinemuse.utils.{MuseItemUtils, MuseMathUtils, GuiIcons, MuseRenderer} +import net.machinemuse.utils.{MuseItemUtils, MuseMathUtils} import org.lwjgl.opengl.GL11._ import net.machinemuse.general.gui.clickable.ClickableItem import net.minecraft.nbt.NBTTagCompound @@ -11,6 +11,7 @@ import net.machinemuse.powersuits.network.packets.MusePacketCosmeticInfo import net.minecraft.client.Minecraft import cpw.mods.fml.common.network.Player import net.minecraft.item.ItemArmor +import net.machinemuse.utils.render.{MuseRenderer, GuiIcons} /** * Author: MachineMuse (Claire Semple) diff --git a/src/minecraft/net/machinemuse/general/gui/frame/ScrollableFrame.java b/src/minecraft/net/machinemuse/general/gui/frame/ScrollableFrame.java index a0418b3..7fdcff0 100644 --- a/src/minecraft/net/machinemuse/general/gui/frame/ScrollableFrame.java +++ b/src/minecraft/net/machinemuse/general/gui/frame/ScrollableFrame.java @@ -4,7 +4,7 @@ import net.machinemuse.general.geometry.Colour; import net.machinemuse.general.geometry.DrawableMuseRect; import net.machinemuse.general.geometry.MusePoint2D; import net.machinemuse.utils.MuseMathUtils; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; diff --git a/src/minecraft/net/machinemuse/general/gui/frame/StatsFrame.java b/src/minecraft/net/machinemuse/general/gui/frame/StatsFrame.java index 2f5dd1f..a59e81e 100644 --- a/src/minecraft/net/machinemuse/general/gui/frame/StatsFrame.java +++ b/src/minecraft/net/machinemuse/general/gui/frame/StatsFrame.java @@ -4,7 +4,7 @@ import net.machinemuse.general.NBTTagAccessor; import net.machinemuse.general.geometry.Colour; import net.machinemuse.general.geometry.MusePoint2D; import net.machinemuse.utils.MuseItemUtils; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import org.lwjgl.opengl.GL11; diff --git a/src/minecraft/net/machinemuse/powersuits/client/ClientProxy.java b/src/minecraft/net/machinemuse/powersuits/client/ClientProxy.java index 05afe84..3714160 100644 --- a/src/minecraft/net/machinemuse/powersuits/client/ClientProxy.java +++ b/src/minecraft/net/machinemuse/powersuits/client/ClientProxy.java @@ -31,7 +31,7 @@ import net.machinemuse.powersuits.network.MusePacketHandler; import net.machinemuse.powersuits.tick.ClientTickHandler; import net.machinemuse.powersuits.tick.PlayerTickHandler; import net.machinemuse.powersuits.tick.RenderTickHandler; -import net.machinemuse.utils.MuseShaders; +import net.machinemuse.utils.render.MuseShaders; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.common.MinecraftForge; @@ -89,7 +89,7 @@ public class ClientProxy extends CommonProxy { URL otherResource = ClientProxy.class.getResource(Config.RESOURCE_PREFIX + "models/armor2.xml"); ModelSpecXMLReader.parseFile(otherResource); - if(MuseShaders.gaussBlurProgram().program() == 0) { + if (MuseShaders.hBlurProgram().program() == 0) { MuseLogger.logDebug("Hi"); } // DefaultModelSpec.loadDefaultModel(); diff --git a/src/minecraft/net/machinemuse/powersuits/client/render/block/RenderLuxCapacitorTESR.java b/src/minecraft/net/machinemuse/powersuits/client/render/block/RenderLuxCapacitorTESR.java index 067a6e5..2c80e16 100644 --- a/src/minecraft/net/machinemuse/powersuits/client/render/block/RenderLuxCapacitorTESR.java +++ b/src/minecraft/net/machinemuse/powersuits/client/render/block/RenderLuxCapacitorTESR.java @@ -3,7 +3,7 @@ package net.machinemuse.powersuits.client.render.block; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.machinemuse.powersuits.block.TileEntityLuxCapacitor; import net.machinemuse.powersuits.common.Config; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; diff --git a/src/minecraft/net/machinemuse/powersuits/client/render/block/TinkerTableModel.java b/src/minecraft/net/machinemuse/powersuits/client/render/block/TinkerTableModel.java index 2f91340..0abba78 100644 --- a/src/minecraft/net/machinemuse/powersuits/client/render/block/TinkerTableModel.java +++ b/src/minecraft/net/machinemuse/powersuits/client/render/block/TinkerTableModel.java @@ -1,6 +1,6 @@ package net.machinemuse.powersuits.client.render.block; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; diff --git a/src/minecraft/net/machinemuse/powersuits/client/render/entity/RenderLuxCapacitorEntity.java b/src/minecraft/net/machinemuse/powersuits/client/render/entity/RenderLuxCapacitorEntity.java index 51ef399..170ceda 100644 --- a/src/minecraft/net/machinemuse/powersuits/client/render/entity/RenderLuxCapacitorEntity.java +++ b/src/minecraft/net/machinemuse/powersuits/client/render/entity/RenderLuxCapacitorEntity.java @@ -1,7 +1,7 @@ package net.machinemuse.powersuits.client.render.entity; import net.machinemuse.powersuits.common.Config; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.Entity; import net.minecraftforge.client.model.AdvancedModelLoader; diff --git a/src/minecraft/net/machinemuse/powersuits/client/render/entity/RenderPlasmaBolt.java b/src/minecraft/net/machinemuse/powersuits/client/render/entity/RenderPlasmaBolt.java index cca1a86..1cfe043 100644 --- a/src/minecraft/net/machinemuse/powersuits/client/render/entity/RenderPlasmaBolt.java +++ b/src/minecraft/net/machinemuse/powersuits/client/render/entity/RenderPlasmaBolt.java @@ -3,7 +3,7 @@ package net.machinemuse.powersuits.client.render.entity; import net.machinemuse.general.geometry.Colour; import net.machinemuse.general.geometry.DrawableMuseCircle; import net.machinemuse.powersuits.entity.EntityPlasmaBolt; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.Entity; import org.lwjgl.opengl.GL11; diff --git a/src/minecraft/net/machinemuse/powersuits/client/render/entity/RenderSpinningBlade.java b/src/minecraft/net/machinemuse/powersuits/client/render/entity/RenderSpinningBlade.java index d17970f..820de65 100644 --- a/src/minecraft/net/machinemuse/powersuits/client/render/entity/RenderSpinningBlade.java +++ b/src/minecraft/net/machinemuse/powersuits/client/render/entity/RenderSpinningBlade.java @@ -1,7 +1,7 @@ package net.machinemuse.powersuits.client.render.entity; import net.machinemuse.powersuits.common.Config; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.Entity; diff --git a/src/minecraft/net/machinemuse/powersuits/client/render/item/ToolModel.java b/src/minecraft/net/machinemuse/powersuits/client/render/item/ToolModel.java index b7e6083..58d08f5 100644 --- a/src/minecraft/net/machinemuse/powersuits/client/render/item/ToolModel.java +++ b/src/minecraft/net/machinemuse/powersuits/client/render/item/ToolModel.java @@ -12,7 +12,7 @@ import net.machinemuse.powersuits.client.render.entity.RenderPlasmaBolt; import net.machinemuse.powersuits.common.Config; import net.machinemuse.powersuits.powermodule.weapon.PlasmaCannonModule; import net.machinemuse.utils.MuseItemUtils; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainerCreative; import net.minecraft.client.gui.inventory.GuiInventory; diff --git a/src/minecraft/net/machinemuse/powersuits/client/render/item/ToolRenderer.java b/src/minecraft/net/machinemuse/powersuits/client/render/item/ToolRenderer.java index 859eda6..a51b4eb 100644 --- a/src/minecraft/net/machinemuse/powersuits/client/render/item/ToolRenderer.java +++ b/src/minecraft/net/machinemuse/powersuits/client/render/item/ToolRenderer.java @@ -3,7 +3,7 @@ package net.machinemuse.powersuits.client.render.item; import net.machinemuse.general.geometry.Colour; import net.machinemuse.powersuits.common.ModularPowersuits; import net.machinemuse.powersuits.item.ItemPowerGauntlet; -import net.machinemuse.utils.MuseRenderer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderEngine; import net.minecraft.client.renderer.entity.Render; diff --git a/src/minecraft/net/machinemuse/powersuits/client/render/modelspec/RenderPart.scala b/src/minecraft/net/machinemuse/powersuits/client/render/modelspec/RenderPart.scala index 5594c70..283436c 100644 --- a/src/minecraft/net/machinemuse/powersuits/client/render/modelspec/RenderPart.scala +++ b/src/minecraft/net/machinemuse/powersuits/client/render/modelspec/RenderPart.scala @@ -1,11 +1,11 @@ package net.machinemuse.powersuits.client.render.modelspec import org.lwjgl.opengl.GL11._ -import net.machinemuse.utils.{GlowBuffer, MuseRenderer} import net.machinemuse.general.geometry.Colour import net.minecraft.client.Minecraft import net.machinemuse.powersuits.client.render.item.ArmorModel import net.minecraft.nbt.NBTTagCompound +import net.machinemuse.utils.render.{MuseRenderer, GlowBuffer} /** * Author: MachineMuse (Claire Semple) diff --git a/src/minecraft/net/machinemuse/powersuits/event/TextureStitchHandler.java b/src/minecraft/net/machinemuse/powersuits/event/TextureStitchHandler.java index 468ed0a..50870ff 100644 --- a/src/minecraft/net/machinemuse/powersuits/event/TextureStitchHandler.java +++ b/src/minecraft/net/machinemuse/powersuits/event/TextureStitchHandler.java @@ -2,7 +2,7 @@ package net.machinemuse.powersuits.event; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.machinemuse.utils.GlowBuffer; +import net.machinemuse.utils.render.GlowBuffer; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraftforge.client.event.RenderWorldLastEvent; diff --git a/src/minecraft/net/machinemuse/powersuits/item/ItemPowerArmorBoots.scala b/src/minecraft/net/machinemuse/powersuits/item/ItemPowerArmorBoots.scala index 68c8445..53186c3 100644 --- a/src/minecraft/net/machinemuse/powersuits/item/ItemPowerArmorBoots.scala +++ b/src/minecraft/net/machinemuse/powersuits/item/ItemPowerArmorBoots.scala @@ -6,7 +6,7 @@ import cpw.mods.fml.common.registry.LanguageRegistry import cpw.mods.fml.relauncher.Side import cpw.mods.fml.relauncher.SideOnly import atomicscience.api.poison.Poison -import net.machinemuse.utils.MuseRenderer +import net.machinemuse.utils.render.MuseRenderer class ItemPowerArmorBoots(id: Int) extends ItemPowerArmor(id, 0, 3) { val iconpath = MuseRenderer.ICON_PREFIX + "armorfeet" diff --git a/src/minecraft/net/machinemuse/powersuits/item/ItemPowerArmorChestplate.scala b/src/minecraft/net/machinemuse/powersuits/item/ItemPowerArmorChestplate.scala index d69e70a..4a8720b 100644 --- a/src/minecraft/net/machinemuse/powersuits/item/ItemPowerArmorChestplate.scala +++ b/src/minecraft/net/machinemuse/powersuits/item/ItemPowerArmorChestplate.scala @@ -6,7 +6,7 @@ import cpw.mods.fml.common.registry.LanguageRegistry import cpw.mods.fml.relauncher.Side import cpw.mods.fml.relauncher.SideOnly import atomicscience.api.poison.Poison -import net.machinemuse.utils.MuseRenderer +import net.machinemuse.utils.render.MuseRenderer class ItemPowerArmorChestplate(id: Int) extends ItemPowerArmor(id, 0, 1) { val iconpath = MuseRenderer.ICON_PREFIX + "armortorso" diff --git a/src/minecraft/net/machinemuse/powersuits/item/ItemPowerArmorHelmet.scala b/src/minecraft/net/machinemuse/powersuits/item/ItemPowerArmorHelmet.scala index 8f024cb..f640480 100644 --- a/src/minecraft/net/machinemuse/powersuits/item/ItemPowerArmorHelmet.scala +++ b/src/minecraft/net/machinemuse/powersuits/item/ItemPowerArmorHelmet.scala @@ -11,7 +11,8 @@ import cpw.mods.fml.common.registry.LanguageRegistry import cpw.mods.fml.relauncher.Side import cpw.mods.fml.relauncher.SideOnly import atomicscience.api.poison.Poison -import net.machinemuse.utils.{MuseItemUtils, MuseRenderer} +import net.machinemuse.utils.{MuseItemUtils} +import net.machinemuse.utils.render.MuseRenderer class ItemPowerArmorHelmet(id: Int) extends ItemPowerArmor(id, 0, 0) with IBreathableArmor { val iconpath = MuseRenderer.ICON_PREFIX + "armorhead" diff --git a/src/minecraft/net/machinemuse/powersuits/item/ItemPowerArmorLeggings.scala b/src/minecraft/net/machinemuse/powersuits/item/ItemPowerArmorLeggings.scala index af6b63b..6b790c0 100644 --- a/src/minecraft/net/machinemuse/powersuits/item/ItemPowerArmorLeggings.scala +++ b/src/minecraft/net/machinemuse/powersuits/item/ItemPowerArmorLeggings.scala @@ -6,7 +6,7 @@ import cpw.mods.fml.common.registry.LanguageRegistry import cpw.mods.fml.relauncher.Side import cpw.mods.fml.relauncher.SideOnly import atomicscience.api.poison.Poison -import net.machinemuse.utils.MuseRenderer +import net.machinemuse.utils.render.MuseRenderer class ItemPowerArmorLeggings(id: Int) extends ItemPowerArmor(id, 0, 2) { val iconpath = MuseRenderer.ICON_PREFIX + "armorlegs" diff --git a/src/minecraft/net/machinemuse/powersuits/tick/RenderTickHandler.java b/src/minecraft/net/machinemuse/powersuits/tick/RenderTickHandler.java index cec4e24..7de5fb9 100644 --- a/src/minecraft/net/machinemuse/powersuits/tick/RenderTickHandler.java +++ b/src/minecraft/net/machinemuse/powersuits/tick/RenderTickHandler.java @@ -13,6 +13,8 @@ import net.machinemuse.powersuits.common.Config; import net.machinemuse.powersuits.common.ModCompatability; import net.machinemuse.powersuits.event.ThaumRenderEventHandler; import net.machinemuse.utils.*; +import net.machinemuse.utils.render.GlowBuffer; +import net.machinemuse.utils.render.MuseRenderer; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.gui.ScaledResolution; diff --git a/src/minecraft/net/machinemuse/utils/GlowBuffer.scala b/src/minecraft/net/machinemuse/utils/GlowBuffer.scala deleted file mode 100644 index 2891ab1..0000000 --- a/src/minecraft/net/machinemuse/utils/GlowBuffer.scala +++ /dev/null @@ -1,75 +0,0 @@ -package net.machinemuse.utils - -import org.lwjgl.opengl.{ARBShaderObjects, GL14, GLContext} -import org.lwjgl.opengl.EXTFramebufferObject._ -import org.lwjgl.opengl.GL11._ -import java.nio.{ByteBuffer, ByteOrder} -import net.minecraft.client.gui.ScaledResolution - -/** - * Author: MachineMuse (Claire Semple) - * Created: 6:02 PM, 5/15/13 - */ -object GlowBuffer { - // Texture dimension. Maybe make this configurable later - val texDimension = 512 - - val glowBuffer:TextureBuffer = new TextureBuffer(texDimension) - val secondBuffer:TextureBuffer = new TextureBuffer(texDimension) - - def draw[A](f: () => A): A = { - glowBuffer.bindWrite() - val a = f() - glowBuffer.unbindWrite() - a - } - - def drawFullScreen(screen:ScaledResolution) { - pushDualIdentityMatrix() - glowBuffer.bindRead() - MuseShaders.gaussBlurProgram.bind() - if (MuseShaders.gaussBlurProgram.compiled) - glDisable(GL_DEPTH_TEST) - - - val sw = screen.getScaledWidth - val sh = screen.getScaledHeight - glBegin(GL_QUADS) - vertUV(0, 0, 0, 1) - vertUV(0, texDimension, 0, 0) - vertUV(texDimension, texDimension, 1, 0) - vertUV(texDimension, 0, 1, 1) - glEnd() - - MuseShaders.gaussBlurProgram.unbind() - glowBuffer.unbindRead() - popDualIdentityMatrix() - } - private def pushDualIdentityMatrix() { - glMatrixMode(GL_MODELVIEW) - glPushMatrix() - glLoadIdentity() - glOrtho(0.0f, texDimension, texDimension, 0.0f, -1.0f, 1.0f) - - glMatrixMode(GL_PROJECTION) - glPushMatrix() - glLoadIdentity() - } - - private def popDualIdentityMatrix() { - glMatrixMode(GL_MODELVIEW) - glPopMatrix() - - glMatrixMode(GL_PROJECTION) - glPopMatrix() - } - - private def vertUV(x: Double, y: Double, u:Double, v:Double) { - glTexCoord2d(u, v) - glVertex2d(x, y) - } - def clear() { - glowBuffer.clear() - } - -} diff --git a/src/minecraft/net/machinemuse/utils/MuseShader.scala b/src/minecraft/net/machinemuse/utils/MuseShader.scala deleted file mode 100644 index 24739a4..0000000 --- a/src/minecraft/net/machinemuse/utils/MuseShader.scala +++ /dev/null @@ -1,85 +0,0 @@ -package net.machinemuse.utils - -import scala.Predef.String -import org.lwjgl.opengl.ARBShaderObjects._ -import org.lwjgl.opengl._ -import net.machinemuse.general.MuseLogger -import scala.io.Source -import java.net.URL -import net.machinemuse.powersuits.common.{CommonProxy, Config} - -/** - * Author: MachineMuse (Claire Semple) - * Created: 8:57 PM, 5/15/13 - */ - -object MuseShaders { - //val gaussianVertices = new MuseVertexShader(Config.RESOURCE_PREFIX + "shaders/gaussianblur.frag") - //val gaussianBlur = new MuseFragmentShader(Config.RESOURCE_PREFIX + "shaders/gaussianblur.frag") - val testv = new MuseVertexShader(Config.RESOURCE_PREFIX + "shaders/test.vert") - val testf = new MuseFragmentShader(Config.RESOURCE_PREFIX + "shaders/test.frag") - val gaussBlurProgram = new ShaderProgram - gaussBlurProgram.attachShader(testv) - gaussBlurProgram.attachShader(testf) - // gaussBlurProgram.attachShader(gaussianBlur) - gaussBlurProgram.compile() - -} - -class ShaderProgram { - val program: Int = ARBShaderObjects.glCreateProgramObjectARB - var compiled: Boolean = false - if (program == 0) MuseLogger.logError("No shader program ID") - - def attachShader(shader: ShaderPart) { - glAttachObjectARB(program, shader.id) - } - - def compile() { - glLinkProgramARB(program) - if (glGetObjectParameteriARB(program, GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) { - MuseLogger.logError(Shader.getLogInfo(program)) - } - glValidateProgramARB(program) - if (glGetObjectParameteriARB(program, GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) { - MuseLogger.logError(Shader.getLogInfo(program)) - } - compiled = true - } - - def bind() { - ARBShaderObjects.glUseProgramObjectARB(program) - } - - def unbind() { - ARBShaderObjects.glUseProgramObjectARB(0) - } -} - -abstract class ShaderPart(source: String, shaderType: Int) { - var id: Int = Shader.createShader(source, shaderType) - if (id == 0) MuseLogger.logError("No shader buffer ID") - -} - -class MuseVertexShader(source: String) extends ShaderPart(source, ARBVertexShader.GL_VERTEX_SHADER_ARB) {} - -class MuseFragmentShader(source: String) extends ShaderPart(source, ARBFragmentShader.GL_FRAGMENT_SHADER_ARB) {} - - -object Shader { - def createShader(filename: String, shaderType: Int): Int = { - val resource: URL = CommonProxy.getResource(filename) - val shader = glCreateShaderObjectARB(shaderType) - val shaderProg = Source.fromURL(resource).mkString - MuseLogger.logDebug("Created shader object with ID " + shader + " and text: \n" + shaderProg) - glShaderSourceARB(shader, shaderProg) - glCompileShaderARB(shader) - if (ARBShaderObjects.glGetObjectParameteriARB(shader, GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE) throw new RuntimeException("Error creating shader: " + getLogInfo(shader)) - shader - } - - def getLogInfo(obj: Int): String = { - glGetInfoLogARB(obj, glGetObjectParameteriARB(obj, GL_OBJECT_INFO_LOG_LENGTH_ARB)) - } -} \ No newline at end of file diff --git a/src/minecraft/net/machinemuse/utils/BufferMapper.scala b/src/minecraft/net/machinemuse/utils/render/BufferMapper.scala similarity index 73% rename from src/minecraft/net/machinemuse/utils/BufferMapper.scala rename to src/minecraft/net/machinemuse/utils/render/BufferMapper.scala index 16e35a5..9d50024 100644 --- a/src/minecraft/net/machinemuse/utils/BufferMapper.scala +++ b/src/minecraft/net/machinemuse/utils/render/BufferMapper.scala @@ -1,5 +1,4 @@ -package net.machinemuse.utils - +package net.machinemuse.utils.render /** * Author: MachineMuse (Claire Semple) diff --git a/src/minecraft/net/machinemuse/utils/render/DepthBuffer.scala b/src/minecraft/net/machinemuse/utils/render/DepthBuffer.scala new file mode 100644 index 0000000..a08be80 --- /dev/null +++ b/src/minecraft/net/machinemuse/utils/render/DepthBuffer.scala @@ -0,0 +1,41 @@ +package net.machinemuse.utils.render + +import java.nio.ByteBuffer +import org.lwjgl.opengl.GL11._ + +/** + * Author: MachineMuse (Claire Semple) + * Created: 3:29 AM, 5/16/13 + */ +class DepthBuffer(val texDimension: Int) { + + // Allocate IDs for a depth buffer + val textureID = glGenTextures() + + // Bind each of the new buvfer IDs + glBindTexture(GL_TEXTURE_2D, textureID) + + // Set up texture parameters + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) + + // Allocate space in gpu for the depth buffer + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, texDimension, texDimension, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, null: ByteBuffer) + glBindTexture(GL_TEXTURE_2D, 0) + + def bindRead() { + glPushAttrib(GL_TEXTURE_BIT) + glBindTexture(GL_TEXTURE_2D, textureID) + } + + def unbindRead() { + glPopAttrib() + } + + def copyWrite() { + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texDimension, texDimension) + } + + def clear() { + glClear(GL_DEPTH_BUFFER_BIT) + } +} diff --git a/src/minecraft/net/machinemuse/utils/render/GlowBuffer.scala b/src/minecraft/net/machinemuse/utils/render/GlowBuffer.scala new file mode 100644 index 0000000..3fa6f24 --- /dev/null +++ b/src/minecraft/net/machinemuse/utils/render/GlowBuffer.scala @@ -0,0 +1,206 @@ +package net.machinemuse.utils.render + +import org.lwjgl.opengl.GL11._ +import net.minecraft.client.gui.ScaledResolution +import net.machinemuse.general.geometry.Colour +import org.lwjgl.opengl.GL13._ +import net.minecraft.client.Minecraft + +/** + * Author: MachineMuse (Claire Semple) + * Created: 6:02 PM, 5/15/13 + */ +object GlowBuffer { + // Texture dimension. Maybe make this configurable later + val texDimension = 1024 + + val glowBuffer = new TextureBuffer(texDimension) + val secondBuffer = new TextureBuffer(texDimension) + val depthBuffer = new TextureBuffer(texDimension) + + def draw[A](f: () => A): A = { + glowBuffer.bindWrite() + val a = f() + glowBuffer.unbindWrite() + a + } + + def drawFullScreen(screen: ScaledResolution) { + import Render._ + pushDualIdentityMatrix() + MuseRenderer.glowOn() + MuseRenderer.blendingOn() + glPushAttrib(GL_ENABLE_BIT) + glDisable(GL_CULL_FACE) + glDisable(GL_ALPHA_TEST) + Colour.WHITE.doGL() + glActiveTexture(GL_TEXTURE0) + + glBindTexture(GL_TEXTURE_2D, depthBuffer.depthRenderBufferID) + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texDimension, texDimension) + glBindTexture(GL_TEXTURE_2D, 0) + + fromBuffer(depthBuffer) { + toBuffer(secondBuffer) { + withShaderProgram(MuseShaders.depthApplicatorProgram) { + Render pure { + glActiveTexture(GL_TEXTURE1) + glBindTexture(GL_TEXTURE_2D, depthBuffer.depthRenderBufferID) + MuseShaders.depthProgram.setTexUnit("depth", 1) + glBegin(GL_QUADS) + val t = texDimension + val w = Minecraft.getMinecraft.displayWidth.toDouble + val h = Minecraft.getMinecraft.displayHeight.toDouble + val u = w / texDimension.toDouble + val v = h / texDimension.toDouble + vertUV(0, 0, 0, v) + vertUV(0, t, 0, 0) + vertUV(t, t, u, 0) + vertUV(t, 0, u, v) + glEnd() + } + } + } + }.run() + + + fromBuffer(glowBuffer) { + toBuffer(secondBuffer) { + withShaderProgram(MuseShaders.depthProgram) { + Render pure { + glActiveTexture(GL_TEXTURE1) + glBindTexture(GL_TEXTURE_2D, secondBuffer.depthRenderBufferID) + glActiveTexture(GL_TEXTURE2) + glBindTexture(GL_TEXTURE_2D, glowBuffer.depthRenderBufferID) + glActiveTexture(GL_TEXTURE0) + glBindTexture(GL_TEXTURE_2D, glowBuffer.colorTextureID) + MuseShaders.depthProgram.setTexUnit("depth", 2) + MuseShaders.depthProgram.setTexUnit("occlusion", 1) + MuseShaders.depthProgram.setTexUnit("texture", 0) + drawTexSquare(texDimension) + } + } + } + }.run() + + glActiveTexture(GL_TEXTURE1) + glBindTexture(GL_TEXTURE_2D, 0) + glActiveTexture(GL_TEXTURE2) + glBindTexture(GL_TEXTURE_2D, 0) + glActiveTexture(GL_TEXTURE0) + glDisable(GL_DEPTH_TEST) + + // Vertical Pass + fromBuffer(secondBuffer) { + toBuffer(glowBuffer) { + withShaderProgram(MuseShaders.vBlurProgram) { + Render pure { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) + MuseShaders.vBlurProgram.setUniform2f("u_Scale", 0, 2.0f / texDimension) + MuseShaders.vBlurProgram.setTexUnit("u_Texture0", 0) + drawTexSquare(texDimension) + } + } + } + }.run() + + + // Horizontal Pass + fromBuffer(glowBuffer) { + toBuffer(secondBuffer) { + withShaderProgram(MuseShaders.hBlurProgram) { + Render.pure { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) + MuseShaders.hBlurProgram.setUniform2f("u_Scale", 2.0f / texDimension, 0) + MuseShaders.hBlurProgram.setTexUnit("u_Texture0", 0) + drawTexSquare(texDimension) + } + } + } + }.run() + + + // Vertical Pass + fromBuffer(secondBuffer) { + toBuffer(glowBuffer) { + withShaderProgram(MuseShaders.vBlurProgram) { + Render pure { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) + MuseShaders.vBlurProgram.setUniform2f("u_Scale", 0, 2.0f / texDimension) + MuseShaders.vBlurProgram.setTexUnit("u_Texture0", 0) + drawTexSquare(texDimension) + } + } + } + }.run() + + + // Horizontal Pass + fromBuffer(glowBuffer) { + toBuffer(secondBuffer) { + withShaderProgram(MuseShaders.hBlurProgram) { + Render.pure { + MuseShaders.hBlurProgram.setUniform2f("u_Scale", 2.0f / texDimension, 0) + MuseShaders.hBlurProgram.setTexUnit("u_Texture0", 0) + drawTexSquare(texDimension) + } + } + } + }.run() + + // To Main display + fromBuffer(secondBuffer) { + Render.pure { + drawTexSquare(texDimension) + } + }.run() + + + glPopAttrib() + MuseRenderer.blendingOff() + MuseRenderer.glowOff() + popDualIdentityMatrix() + } + + def drawTexSquare(td: Int) { + // MuseLogger.logDebug("Begin rendering") + glBegin(GL_QUADS) + vertUV(0, 0, 0, 1) + vertUV(0, td, 0, 0) + vertUV(td, td, 1, 0) + vertUV(td, 0, 1, 1) + glEnd() + // MuseLogger.logDebug("Done rendering") + } + + private def vertUV(x: Double, y: Double, u: Double, v: Double) { + glTexCoord2d(u, v) + glVertex2d(x, y) + } + + private def pushDualIdentityMatrix() { + glMatrixMode(GL_MODELVIEW) + glPushMatrix() + glLoadIdentity() + glOrtho(0.0f, texDimension, texDimension, 0.0f, -1.0f, 1.0f) + + glMatrixMode(GL_PROJECTION) + glPushMatrix() + glLoadIdentity() + } + + private def popDualIdentityMatrix() { + glMatrixMode(GL_MODELVIEW) + glPopMatrix() + + glMatrixMode(GL_PROJECTION) + glPopMatrix() + } + + + def clear() { + glowBuffer.clear() + secondBuffer.clear() + } + +} diff --git a/src/minecraft/net/machinemuse/utils/GuiIcons.scala b/src/minecraft/net/machinemuse/utils/render/GuiIcons.scala similarity index 95% rename from src/minecraft/net/machinemuse/utils/GuiIcons.scala rename to src/minecraft/net/machinemuse/utils/render/GuiIcons.scala index 85653f3..24cad70 100644 --- a/src/minecraft/net/machinemuse/utils/GuiIcons.scala +++ b/src/minecraft/net/machinemuse/utils/render/GuiIcons.scala @@ -1,4 +1,4 @@ -package net.machinemuse.utils +package net.machinemuse.utils.render import net.minecraft.util.Icon import net.machinemuse.general.geometry.Colour @@ -17,14 +17,14 @@ object GuiIcons { def apply(x: Double, y: Double, c: Colour = Colour.WHITE, xmin: Double = Integer.MIN_VALUE, ymin: Double = Integer.MIN_VALUE, xmax: Double = Integer.MAX_VALUE, ymax: Double = Integer.MAX_VALUE) { MuseRenderer.pushTexture(filepath) - glPushMatrix + glPushMatrix() MuseRenderer.blendingOn() val s = size / 16.0 glScaled(s, s, s) MuseRenderer.drawIconPartialOccluded(x / s, y / s, GuiIconDrawer, c, xmin / s, ymin / s, xmax / s, ymax / s) MuseRenderer.blendingOff() - glPopMatrix - MuseRenderer.popTexture + glPopMatrix() + MuseRenderer.popTexture() } } diff --git a/src/minecraft/net/machinemuse/utils/MuseRenderer.java b/src/minecraft/net/machinemuse/utils/render/MuseRenderer.java similarity index 99% rename from src/minecraft/net/machinemuse/utils/MuseRenderer.java rename to src/minecraft/net/machinemuse/utils/render/MuseRenderer.java index 6d105bd..bd5ce69 100644 --- a/src/minecraft/net/machinemuse/utils/MuseRenderer.java +++ b/src/minecraft/net/machinemuse/utils/render/MuseRenderer.java @@ -1,4 +1,4 @@ -package net.machinemuse.utils; +package net.machinemuse.utils.render; import net.machinemuse.general.MuseLogger; import net.machinemuse.general.geometry.Colour; @@ -7,6 +7,8 @@ import net.machinemuse.general.geometry.SwirlyMuseCircle; import net.machinemuse.general.gui.MuseGui; import net.machinemuse.general.gui.clickable.IClickable; import net.machinemuse.powersuits.common.Config; +import net.machinemuse.utils.MuseMathUtils; +import net.machinemuse.utils.render.SlickFont; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; @@ -223,8 +225,7 @@ public abstract class MuseRenderer { * Call before doing anything with alpha blending */ public static void blendingOn() { - GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT); - GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); + GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LIGHTING_BIT); if (Minecraft.isFancyGraphicsEnabled()) { GL11.glShadeModel(GL11.GL_SMOOTH); // GL11.glEnable(GL11.GL_LINE_SMOOTH); @@ -238,7 +239,6 @@ public abstract class MuseRenderer { * Call after doing anything with alpha blending */ public static void blendingOff() { - GL11.glPopAttrib(); GL11.glPopAttrib(); // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } diff --git a/src/minecraft/net/machinemuse/utils/render/MuseShaders.scala b/src/minecraft/net/machinemuse/utils/render/MuseShaders.scala new file mode 100644 index 0000000..920c502 --- /dev/null +++ b/src/minecraft/net/machinemuse/utils/render/MuseShaders.scala @@ -0,0 +1,22 @@ +package net.machinemuse.utils.render + +import net.machinemuse.powersuits.common.Config + +/** + * Author: MachineMuse (Claire Semple) + * Created: 8:57 PM, 5/15/13 + */ +object MuseShaders { + //val gaussianVertices = new MuseVertexShader(Config.RESOURCE_PREFIX + "shaders/gaussianblur.frag") + val blurVertex = Config.RESOURCE_PREFIX + "shaders/gaussianblur.vert" + val blurFragment = Config.RESOURCE_PREFIX + "shaders/gaussianblur.frag" + val hBlurProgram = new ShaderProgram(blurVertex, blurFragment) + val vBlurProgram = new ShaderProgram(blurVertex, blurFragment) + + val depthVertex = Config.RESOURCE_PREFIX + "shaders/depthocclusion.vert" + val depthFragment = Config.RESOURCE_PREFIX + "shaders/depthocclusion.frag" + val depthProgram = new ShaderProgram(depthVertex, depthFragment) + + val depthApplicatorFragment = Config.RESOURCE_PREFIX + "shaders/depthapplicator.frag" + val depthApplicatorProgram = new ShaderProgram(depthVertex, depthApplicatorFragment) +} diff --git a/src/minecraft/net/machinemuse/utils/MuseStencilManager.scala b/src/minecraft/net/machinemuse/utils/render/MuseStencilManager.scala similarity index 88% rename from src/minecraft/net/machinemuse/utils/MuseStencilManager.scala rename to src/minecraft/net/machinemuse/utils/render/MuseStencilManager.scala index 53b2494..c10041f 100644 --- a/src/minecraft/net/machinemuse/utils/MuseStencilManager.scala +++ b/src/minecraft/net/machinemuse/utils/render/MuseStencilManager.scala @@ -1,4 +1,4 @@ -package net.machinemuse.utils +package net.machinemuse.utils.render import org.lwjgl.opengl.GL11._ diff --git a/src/minecraft/net/machinemuse/utils/MuseTexture.scala b/src/minecraft/net/machinemuse/utils/render/MuseTexture.scala similarity index 72% rename from src/minecraft/net/machinemuse/utils/MuseTexture.scala rename to src/minecraft/net/machinemuse/utils/render/MuseTexture.scala index fe35dcd..a472af6 100644 --- a/src/minecraft/net/machinemuse/utils/MuseTexture.scala +++ b/src/minecraft/net/machinemuse/utils/render/MuseTexture.scala @@ -1,4 +1,4 @@ -package net.machinemuse.utils +package net.machinemuse.utils.render /** * Author: MachineMuse (Claire Semple) diff --git a/src/minecraft/net/machinemuse/utils/render/RMonad.scala b/src/minecraft/net/machinemuse/utils/render/RMonad.scala new file mode 100644 index 0000000..5235cf6 --- /dev/null +++ b/src/minecraft/net/machinemuse/utils/render/RMonad.scala @@ -0,0 +1,120 @@ +package net.machinemuse.utils.render + +import org.lwjgl.opengl.GL11 +import net.minecraft.client.renderer.{GLAllocation, RenderHelper, OpenGlHelper} +import org.lwjgl.opengl.GL11._ +import net.machinemuse.general.MuseLogger + +/** + * Library for working with rendering. + * + * (c) 2013 Byron Shelden + * See COPYING for details + */ +trait Render[A] { + def run(): A + + import Render._ + + def compile(): Render[A] = Render.compile(this) + + def map[B](f: A => B) = mk { + f(run()) + } + + def flatMap[B](f: A => Render[B]) = mk { + f(run()).run() + } +} + +object Render { + private def mk[A](act: => A): Render[A] = new Render[A] { + def run() = act + } + + def apply[A](act: => A): Render[A] = mk(act) + + def liftIO[A](act: => A): Render[A] = mk(act) + + def pure[A](a: => A): Render[A] = mk(a) + + def withPushedMatrix[A](r: Render[A]): Render[A] = mk { + GL11.glPushMatrix() + val a = r.run() + GL11.glPopMatrix() + a + } + + def withShaderProgram[A](prog: ShaderProgram)(r: Render[A]): Render[A] = mk { + prog.bind() +// MuseLogger.logDebug("Bound shader program") + val a = r.run() +// MuseLogger.logDebug("Unbound shader program") + prog.unbind() + a + } + + def fromBuffer[A](buf: TextureBuffer)(r: Render[A]): Render[A] = mk { + buf.bindRead() +// MuseLogger.logDebug("Bound buffer for reading") + val a = r.run() +// MuseLogger.logDebug("Unbound buffer for reading") + buf.unbindRead() + a + } + + def toBuffer[A](buf: TextureBuffer)(r: Render[A]): Render[A] = mk { + buf.bindWrite() +// MuseLogger.logDebug("Bound buffer for writing") + val a = r.run() +// MuseLogger.logDebug("Unbound buffer for writing") + buf.unbindWrite() + a + } + + def withPushedAttrib[A](mask: Int)(r: Render[A]): Render[A] = mk { + GL11.glPushAttrib(mask) + val a = r.run() + GL11.glPopAttrib() + a + } + + + + /** + * Compiles the given render into a display list. + * + * Note that the yield from the compiled render is captured and used as the yield of the call action. + * + * @return a render action that invokes the compiled display list. + */ + def compile[A](r: Render[A]): Render[A] = { + val listIndex = GLAllocation.generateDisplayLists(1) + GL11.glNewList(listIndex, GL11.GL_COMPILE) + val a = r.run() + GL11.glEndList() + + mk { + GL11.glCallList(listIndex) + a + } + } + + def withGlow[A](r: Render[A]): Render[A] = { + for { + saved <- Render.liftIO { + (OpenGlHelper.lastBrightnessX, OpenGlHelper.lastBrightnessY) + } + _ <- Render { + GL11.glPushAttrib(GL11.GL_LIGHTING_BIT) + RenderHelper.disableStandardItemLighting() + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F) + } + a <- r + _ <- Render { + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, saved._1, saved._2) + GL11.glPopAttrib() + } + } yield (a) + } +} \ No newline at end of file diff --git a/src/minecraft/net/machinemuse/utils/render/ShaderProgram.scala b/src/minecraft/net/machinemuse/utils/render/ShaderProgram.scala new file mode 100644 index 0000000..f8c5cb2 --- /dev/null +++ b/src/minecraft/net/machinemuse/utils/render/ShaderProgram.scala @@ -0,0 +1,75 @@ +package net.machinemuse.utils.render + +import org.lwjgl.opengl._ +import net.machinemuse.general.MuseLogger +import org.lwjgl.opengl.ARBShaderObjects._ +import java.net.URL +import net.machinemuse.powersuits.common.CommonProxy +import scala.io.Source + +/** + * Author: MachineMuse (Claire Semple) + * Created: 3:31 AM, 5/16/13 + */ +class ShaderProgram(vertSource: String, fragSource: String) { + var compiled: Boolean = false + val program: Int = ARBShaderObjects.glCreateProgramObjectARB + if (program == 0) MuseLogger.logError("No shader program ID") + val vert = mk(vertSource, ARBVertexShader.GL_VERTEX_SHADER_ARB) + val frag = mk(fragSource, ARBFragmentShader.GL_FRAGMENT_SHADER_ARB) + glAttachObjectARB(program, vert) + glAttachObjectARB(program, frag) + compile() + + + def compile() { + glLinkProgramARB(program) + if (glGetObjectParameteriARB(program, GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) { + MuseLogger.logError(getLogInfo(program)) + } + glValidateProgramARB(program) + if (glGetObjectParameteriARB(program, GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) { + MuseLogger.logError(getLogInfo(program)) + } + compiled = true + } + + def bind() { + if (compiled) { + ARBShaderObjects.glUseProgramObjectARB(program) + } + } + + def unbind() { + if (compiled) { + ARBShaderObjects.glUseProgramObjectARB(0) + } + } + + def setUniform2f(name: String, f1: Float, f2: Float) { + val pointer = GL20.glGetUniformLocation(program, name) + if (pointer < 1) MuseLogger.logError("UNABLE TO ACCESS FLOATS!!!") + GL20.glUniform2f(pointer, f1, f2) + } + + def setTexUnit(name: String, i: Int) { + val pointer = GL20.glGetUniformLocation(program, name) + if (pointer < 1) MuseLogger.logError("UNABLE TO ACCESS TEX UNIT!!!") + GL20.glUniform1i(pointer, i) + } + + def getLogInfo(obj: Int): String = { + glGetInfoLogARB(obj, glGetObjectParameteriARB(obj, GL_OBJECT_INFO_LOG_LENGTH_ARB)) + } + + def mk(filename: String, shaderType: Int): Int = { + val resource: URL = CommonProxy.getResource(filename) + val shader = glCreateShaderObjectARB(shaderType) + val shaderProg = Source.fromURL(resource).mkString + MuseLogger.logDebug("Created shader object with ID " + shader + " and text: \n" + shaderProg) + glShaderSourceARB(shader, shaderProg) + glCompileShaderARB(shader) + if (ARBShaderObjects.glGetObjectParameteriARB(shader, GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE) throw new RuntimeException("Error creating shader: " + getLogInfo(shader)) + shader + } +} diff --git a/src/minecraft/net/machinemuse/utils/SlickFont.scala b/src/minecraft/net/machinemuse/utils/render/SlickFont.scala similarity index 99% rename from src/minecraft/net/machinemuse/utils/SlickFont.scala rename to src/minecraft/net/machinemuse/utils/render/SlickFont.scala index 5dd8120..633262e 100644 --- a/src/minecraft/net/machinemuse/utils/SlickFont.scala +++ b/src/minecraft/net/machinemuse/utils/render/SlickFont.scala @@ -1,4 +1,4 @@ -package net.machinemuse.utils +package net.machinemuse.utils.render import java.awt.Font import org.newdawn.slick.{Color, TrueTypeFont} diff --git a/src/minecraft/net/machinemuse/utils/TextureBuffer.scala b/src/minecraft/net/machinemuse/utils/render/TextureBuffer.scala similarity index 71% rename from src/minecraft/net/machinemuse/utils/TextureBuffer.scala rename to src/minecraft/net/machinemuse/utils/render/TextureBuffer.scala index c21c607..3703083 100644 --- a/src/minecraft/net/machinemuse/utils/TextureBuffer.scala +++ b/src/minecraft/net/machinemuse/utils/render/TextureBuffer.scala @@ -1,47 +1,39 @@ -package net.machinemuse.utils +package net.machinemuse.utils.render -import org.lwjgl.opengl.{GL14, GLContext} +import org.lwjgl.opengl.GLContext import java.nio.{ByteOrder, ByteBuffer} import org.lwjgl.opengl.EXTFramebufferObject._ import org.lwjgl.opengl.GL11._ +import org.lwjgl.opengl.GL13._ +import org.lwjgl.opengl.GL14._ /** * Author: MachineMuse (Claire Semple) * Created: 8:18 PM, 5/15/13 */ -class TextureBuffer(val texDimension:Int) { +class TextureBuffer(val texDimension: Int) { // check if FBO is enabled if (!GLContext.getCapabilities.GL_EXT_framebuffer_object) { throw new RuntimeException("Framebuffers not supported!") } - - // Compress for readability - private def genFrameBuffer() = { - val idBuffer = ByteBuffer.allocateDirect(1 * 4).order(ByteOrder.nativeOrder).asIntBuffer - glGenFramebuffersEXT(idBuffer) // generate - idBuffer.get - } // Allocate IDs for a FBO, colour buffer, and depth buffer - val framebufferID = genFrameBuffer() + val framebufferID = glGenFramebuffersEXT() val colorTextureID = glGenTextures() - val depthRenderBufferID = glGenRenderbuffersEXT() + val depthRenderBufferID = glGenTextures() - // Bind each of the new buvfer IDs glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebufferID) + glBindTexture(GL_TEXTURE_2D, colorTextureID) - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthRenderBufferID) - - // Set up texture parameters glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) - - // Allocate space in gpu for the texture and depth buffers glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texDimension, texDimension, 0, GL_RGBA, GL_INT, null: ByteBuffer) - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL14.GL_DEPTH_COMPONENT24, 512, 512) - - // Associate the FBO with the memory space allocated to the new buffers glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, colorTextureID, 0) - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthRenderBufferID) + + glBindTexture(GL_TEXTURE_2D, depthRenderBufferID) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, texDimension, texDimension, 0, GL_DEPTH_COMPONENT, GL_INT, null: ByteBuffer) + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, depthRenderBufferID, 0) + // Check the status and throw an exception if it didn't initialize properly glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) match { @@ -59,7 +51,7 @@ class TextureBuffer(val texDimension:Int) { glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0) def bindRead() { - glPushAttrib(GL_TEXTURE_BIT | GL_ENABLE_BIT) + glPushAttrib(GL_TEXTURE_BIT) glBindTexture(GL_TEXTURE_2D, colorTextureID) } @@ -68,8 +60,7 @@ class TextureBuffer(val texDimension:Int) { } def bindWrite() { - glPushAttrib(GL_TEXTURE_BIT | GL_VIEWPORT_BIT) - glBindTexture(GL_TEXTURE_2D, 0) + glPushAttrib(GL_VIEWPORT_BIT) glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebufferID) glViewport(0, 0, texDimension, texDimension) } @@ -82,7 +73,7 @@ class TextureBuffer(val texDimension:Int) { def clear() { bindWrite() - glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) unbindWrite() } }