Skip to content
This repository has been archived by the owner on Jan 1, 2022. It is now read-only.

Commit

Permalink
Merge branch 'wiki'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobata committed Jul 9, 2013
2 parents 23e0165 + b6046de commit 6d43321
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 57 deletions.
Binary file removed SpecialSource-1.5-SNAPSHOT-shaded.jar
Binary file not shown.
26 changes: 0 additions & 26 deletions SpecialSource-License.txt

This file was deleted.

54 changes: 41 additions & 13 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<property name="mod.name" value="ItemRender"/>
<property name="mod.modid" value="itemrender"/>

<property name="minecraft.version" value="1.5.1"/>
<property name="minecraft.version" value="1.6.2"/>

<property name="forge.build" value="682"/>
<property name="forge.version" value="7.7.2"/>
<property name="forge.build" value="784"/>
<property name="forge.version" value="9.10.0"/>
<property name="forge.filename" value="minecraftforge-src-${minecraft.version}-${forge.version}.${forge.build}.zip"/>

<property name="forge.download" value="http://files.minecraftforge.net/minecraftforge/${forge.filename}"/>
Expand All @@ -29,7 +29,7 @@
<property name="mcp.mappings.dir" value="${forge.dir}/mcp/conf"/>
<property name="class.dir" value="${build.dir}/classes"/>

<property name="specialsource.jar" value="SpecialSource-1.5-SNAPSHOT-shaded.jar"/>
<property name="specialsource.jar" value="${mcp.dir}/runtime/bin/specialsource.jar"/>

<property name="minecraft.inheritance" value="${temp.dir}/Minecraft-${minecraft.version}-mcp.inheritance"/>

Expand All @@ -49,13 +49,27 @@

<path id="mod.classpath">
<pathelement location="${mcp.dir}/bin/minecraft"/>
<pathelement location="${mcp.dir}/lib/argo-3.2.jar"/>
<pathelement location="${mcp.dir}/lib/asm-all-4.1.jar"/>
<pathelement location="${mcp.dir}/lib/bcprov-jdk15on-148.jar"/>
<pathelement location="${mcp.dir}/lib/guava-14.0-rc3.jar"/>
<pathelement location="${mcp.dir}/jars/bin/jinput.jar"/>
<pathelement location="${mcp.dir}/jars/bin/lwjgl.jar"/>
<pathelement location="${mcp.dir}/jars/bin/lwjgl_util.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\argo\argo\2.25_fixed\argo-2.25_fixed.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\com\google\code\gson\gson\2.2.2\gson-2.2.2.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\com\google\guava\guava\14.0\guava-14.0.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\com\paulscode\codecjorbis\20101023\codecjorbis-20101023.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\com\paulscode\codecwav\20101023\codecwav-20101023.jar"/>
<pathelement
location="${mcp.dir}\jars\libraries\com\paulscode\libraryjavasound\20101123\libraryjavasound-20101123.jar"/>
<pathelement
location="${mcp.dir}\jars\libraries\com\paulscode\librarylwjglopenal\20100824\librarylwjglopenal-20100824.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\com\paulscode\soundsystem\20120107\soundsystem-20120107.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\commons-io\commons-io\2.4\commons-io-2.4.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\lzma\lzma\0.0.1\lzma-0.0.1.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\net\java\jinput\jinput\2.0.5\jinput-2.0.5.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\net\java\jutils\jutils\1.0.0\jutils-1.0.0.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\net\minecraft\launchwrapper\1.3\launchwrapper-1.3.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\net\sf\jopt-simple\jopt-simple\4.5\jopt-simple-4.5.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\org\apache\commons\commons-lang3\3.1\commons-lang3-3.1.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\org\bouncycastle\bcprov-jdk15on\1.47\bcprov-jdk15on-1.47.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\org\lwjgl\lwjgl\lwjgl\2.9.0\lwjgl-2.9.0.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\org\lwjgl\lwjgl\lwjgl_util\2.9.0\lwjgl_util-2.9.0.jar"/>
<pathelement location="${mcp.dir}\jars\libraries\org\ow2\asm\asm-all\4.1\asm-all-4.1.jar"/>
</path>

<target name="dist" depends="reobf-mod, sign-mod, jar-src"/>
Expand Down Expand Up @@ -104,7 +118,7 @@
</jar>
</target>

<target name="build-mod" depends="install-forge, filter-src">
<target name="build-mod" depends="install-forge, cache-resources, filter-src">
<delete dir="${class.dir}" failonerror="no"/>
<mkdir dir="${class.dir}"/>
<javac srcdir="${src.dir}" destdir="${class.dir}" target="1.6" source="1.6"
Expand Down Expand Up @@ -144,12 +158,22 @@
</java>
</target>

<target name="jar-minecraft" depends="install-forge" unless="minecraft.jar.exists">
<target name="jar-minecraft" depends="install-forge, cache-resources" unless="minecraft.jar.exists">
<jar destfile="${minecraft.mcp.jar}">
<fileset dir="${mcp.dir}/bin/minecraft"/>
</jar>
</target>


<target name="cache-resources" depends="install-forge">
<copy todir="${temp.dir}/mcp_data">
<fileset dir="${mcp.dir}">
<include name="jars/libraries/"/>
<include name="jars/assets/"/>
</fileset>
</copy>
</target>

<target name="install-forge" depends="download-forge" unless="forge.installed">
<delete dir="${forge.dir}" failonerror="no"/>
<delete file="${minecraft.inheritance}" failonerror="no"/>
Expand All @@ -159,6 +183,10 @@
<cutdirsmapper dirs="1"/>
</unzip>

<copy todir="${forge.dir}/fml/mcp_data" failonerror="no">
<fileset dir="${temp.dir}/mcp_data"/>
</copy>

<exec dir="${forge.dir}" executable="${forge.dir}/fml/python/python_fml" osfamily="windows" inputstring="Yes\n">
<arg value="install.py"/>
</exec>
Expand Down
14 changes: 10 additions & 4 deletions src/itemrender/ItemRenderMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,27 @@ public class ItemRenderMod {

public static boolean gl32_enabled = false;

@Mod.PreInit
public static final int DEFAULT_TEXTURE_SIZE = 128;
public static final int GRID_TEXTURE_SIZE = 32;

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent e) {
gl32_enabled = GLContext.getCapabilities().OpenGL32;
}

@Mod.Init
@Mod.EventHandler
public void init(FMLInitializationEvent e) {
if(gl32_enabled) {
TickRegistry.registerTickHandler(new RenderTickHandler(), Side.CLIENT);
KeyBindingRegistry.registerKeyBinding(new KeybindRenderInventoryBlock());
KeybindRenderInventoryBlock defaultRender = new KeybindRenderInventoryBlock(DEFAULT_TEXTURE_SIZE, "");
RenderTickHandler.keybindToRender = defaultRender;
KeyBindingRegistry.registerKeyBinding(defaultRender);
KeyBindingRegistry.registerKeyBinding(new KeybindRenderInventoryBlock(GRID_TEXTURE_SIZE, "_grid"));
KeyBindingRegistry.registerKeyBinding(new KeybindToggleRender());
}
}

@Mod.PostInit
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent e) {
}
}
Expand Down
45 changes: 33 additions & 12 deletions src/itemrender/client/KeybindRenderInventoryBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,26 @@ public class KeybindRenderInventoryBlock extends KeyBindingRegistry.KeyHandler {
new KeyBinding[]{new KeyBinding("Render Inventory Block", Keyboard.KEY_P)};
private static boolean[] repeatings = new boolean[]{false};

private static final int RENDER_TEXTURE_SIZE = 128;
private int renderTextureSize = 128;

public static int framebufferID = -1;
public static int depthbufferID = -1;
public static int textureID = -1;
public int framebufferID = -1;
public int depthbufferID = -1;
public int textureID = -1;

private String filenameSuffix = "";

private RenderItem itemRenderer = new RenderItem();

public KeybindRenderInventoryBlock() {
public KeybindRenderInventoryBlock(int textureSize, String filename_suffix) {
super(keyBindings, repeatings);

renderTextureSize = textureSize;
filenameSuffix = filename_suffix;

createFramebuffer();
}

private void createFramebuffer() {
framebufferID = GL30.glGenFramebuffers();
textureID = GL11.glGenTextures();
int currentTexture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
Expand All @@ -57,7 +66,7 @@ public KeybindRenderInventoryBlock() {
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, RENDER_TEXTURE_SIZE, RENDER_TEXTURE_SIZE, 0, GL12.GL_BGRA,
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, renderTextureSize, renderTextureSize, 0, GL12.GL_BGRA,
GL11.GL_UNSIGNED_BYTE, (java.nio.ByteBuffer) null);

// Restore old texture
Expand All @@ -66,7 +75,7 @@ public KeybindRenderInventoryBlock() {
// Create depth buffer
depthbufferID = GL30.glGenRenderbuffers();
GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, depthbufferID);
GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL11.GL_DEPTH_COMPONENT, RENDER_TEXTURE_SIZE, RENDER_TEXTURE_SIZE);
GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL11.GL_DEPTH_COMPONENT, renderTextureSize, renderTextureSize);

// Bind depth buffer to the framebuffer
GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER, depthbufferID);
Expand All @@ -78,6 +87,18 @@ public KeybindRenderInventoryBlock() {
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
}

private void deleteFramebuffer() {
GL30.glDeleteFramebuffers(framebufferID);
GL11.glDeleteTextures(textureID);
GL30.glDeleteRenderbuffers(depthbufferID);
}

public void resizeFramebuffer(int newSize) {
deleteFramebuffer();
renderTextureSize = newSize;
createFramebuffer();
}

@Override
public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) {
if(!tickEnd) return;
Expand All @@ -91,7 +112,7 @@ public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boo
// Remember viewport info.
IntBuffer viewportInfo = GLAllocation.createDirectIntBuffer(16);
GL11.glGetInteger(GL11.GL_VIEWPORT, viewportInfo);
GL11.glViewport(0, 0, RENDER_TEXTURE_SIZE, RENDER_TEXTURE_SIZE);
GL11.glViewport(0, 0, renderTextureSize, renderTextureSize);

GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glPushMatrix();
Expand Down Expand Up @@ -149,16 +170,16 @@ public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boo

IntBuffer texture = BufferUtils.createIntBuffer(width * height);
GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, texture);
//GL11.glReadPixels(0, 0, RENDER_TEXTURE_SIZE, RENDER_TEXTURE_SIZE, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, texture);
//GL11.glReadPixels(0, 0, renderTextureSize, renderTextureSize, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, texture);
int[] texture_array = new int[width * height];
texture.get(texture_array);

BufferedImage image =
new BufferedImage(RENDER_TEXTURE_SIZE, RENDER_TEXTURE_SIZE, BufferedImage.TYPE_INT_ARGB);
image.setRGB(0, 0, RENDER_TEXTURE_SIZE, RENDER_TEXTURE_SIZE, texture_array, 0, width);
new BufferedImage(renderTextureSize, renderTextureSize, BufferedImage.TYPE_INT_ARGB);
image.setRGB(0, 0, renderTextureSize, renderTextureSize, texture_array, 0, width);

File file = new File(minecraft.mcDataDir,
String.format("rendered/item_%d_%d.png", current.getItem().itemID, current.getItemDamage()));
String.format("rendered/item_%d_%d%s.png", current.getItem().itemID, current.getItemDamage(), filenameSuffix));
file.mkdirs();
try {
ImageIO.write(image, "png", file);
Expand Down
5 changes: 3 additions & 2 deletions src/itemrender/client/RenderTickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@SideOnly(Side.CLIENT)
public class RenderTickHandler implements ITickHandler {
public static boolean renderPreview = false;
public static KeybindRenderInventoryBlock keybindToRender;

public RenderTickHandler() {
}
Expand All @@ -21,11 +22,11 @@ public void tickStart(EnumSet<TickType> type, Object... tickData) {

@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
if(renderPreview) {
if(keybindToRender != null && renderPreview) {
int originalTexture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);

// Bind framebuffer texture
GL11.glBindTexture(GL11.GL_TEXTURE_2D, KeybindRenderInventoryBlock.textureID);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, keybindToRender.textureID);
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0, 0);
GL11.glVertex2i(0, 0);
Expand Down

0 comments on commit 6d43321

Please sign in to comment.