behold the future of glowy shit in minecraft

This commit is contained in:
MachineMuse 2013-05-16 10:58:09 -06:00
parent ed34f3ae7d
commit d43850e804
60 changed files with 587 additions and 255 deletions

View file

@ -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);
}

View file

@ -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;
}

View file

@ -0,0 +1,4 @@
void main(){
gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
}

View file

@ -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;
}

View file

@ -0,0 +1,4 @@
void main(){
gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
}

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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.*;

View file

@ -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;

View file

@ -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;

View file

@ -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)

View file

@ -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;

View file

@ -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;

View file

@ -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();

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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)

View file

@ -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;

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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;

View file

@ -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()
}
}

View file

@ -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))
}
}

View file

@ -1,5 +1,4 @@
package net.machinemuse.utils
package net.machinemuse.utils.render
/**
* Author: MachineMuse (Claire Semple)

View file

@ -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)
}
}

View file

@ -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()
}
}

View file

@ -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()
}
}

View file

@ -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);
}

View file

@ -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)
}

View file

@ -1,4 +1,4 @@
package net.machinemuse.utils
package net.machinemuse.utils.render
import org.lwjgl.opengl.GL11._

View file

@ -1,4 +1,4 @@
package net.machinemuse.utils
package net.machinemuse.utils.render
/**
* Author: MachineMuse (Claire Semple)

View file

@ -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)
}
}

View file

@ -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
}
}

View file

@ -1,4 +1,4 @@
package net.machinemuse.utils
package net.machinemuse.utils.render
import java.awt.Font
import org.newdawn.slick.{Color, TrueTypeFont}

View file

@ -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()
}
}