Jump to content

Dayanto

Members
  • Posts

    6
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Dayanto's Achievements

Tree Puncher

Tree Puncher (2/8)

2

Reputation

  1. Thanks! I got it working by writing my own renderer based on the MapItemRenderer. For future refence, here's (a slightly modified version of) my code. package panoramakit.gui; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import org.lwjgl.opengl.GL11; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; /** * Takes care of loading and drawing previews to the screen. * @author dayanto */ public class PreviewRenderer { private File file; private BufferedImage image; private DynamicTexture previewTexture; private ResourceLocation resourceLocation; private TextureManager textureManager; public PreviewRenderer(TextureManager textureManager, File file) { this.textureManager = textureManager; this.file = file; } /** * Attempts to load the image. Returns whether it was successful or not. */ public boolean loadPreview() { try { image = ImageIO.read(file); previewTexture = new DynamicTexture(image); resourceLocation = textureManager.getDynamicTextureLocation("preivew", previewTexture); return true; } catch (IOException e) { e.printStackTrace(); return false; } } public void drawCenteredImage(int xPos, int yPos, int width, int height) { if(previewTexture == null) { boolean successful = loadPreview(); if(!successful) return; } drawImage(xPos + (width - image.getWidth()) / 2, yPos + (height - image.getHeight()) / 2, image.getWidth(), image.getHeight()); } private void drawImage(int xPos, int yPos, int width, int height) { previewTexture.updateDynamicTexture(); Tessellator tessellator = Tessellator.instance; textureManager.bindTexture(resourceLocation); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_ALPHA_TEST); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(xPos , yPos + height, 0, 0.0, 1.0); tessellator.addVertexWithUV(xPos + width, yPos + height, 0, 1.0, 1.0); tessellator.addVertexWithUV(xPos + width, yPos , 0, 1.0, 0.0); tessellator.addVertexWithUV(xPos , yPos , 0, 0.0, 0.0); tessellator.draw(); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); } }
  2. Hi, I'm having some troubles regarding drawing images. In my mod, I'm creating images at runtime that I want to be able to show in a gui screen. Essentially, I want to be able to load a texture either a) from an external image file directly (probably won't work) or b) via a BufferedImage object. Due to the recent changes introduced with resource packs, it seems to be difficult to find any information about it and with the code almost entirely obfuscated, I've had troubles getting anywhere searching for a solution. It's not valid any more, but what I'm looking for is basically an updated version of this solution: https://gist.github.com/thvortex/2138298 By scanning for references to BufferedImage, I found a few methods related to it in the TextureUtil class, but I don't know if they're what I'm looking for or how I should be using them. I'm thankful for any help.
  3. Sounds great! Thanks to both of you for the help!
  4. Sounds great! Thanks to both of you for the help!
  5. Ok, I'll keep looking. (Is this what you mean by asm?) Out of the three, I was pretty much expecting the hook to exist. (I had to know for sure though) The other two however are my main concern. If you happen to know anything about them, it would help a lot. Edit: I rewrote the original post a bit to make it clearer.
  6. Hello! I'm thinking of porting my mod to Forge but in order to do that, I first need to know if it's possible in the first place. I've done a bit of research and some digging in the JavaDoc but I haven't found the specific things I'm looking for, so I thought it would be better to ask someone with a bit of experience with Forge instead. To give you a bit of background: The mod I'm developing is called PanoramaKit and it is used to create backgrounds for the main menu as well as - you guessed it - panoramas. It does this by rotating the player and capturing a series of images that together make up everything that is around you. (360 x 180 degrees) There are mainly three things that I need for my mod to work properly. * A hook that runs once every frame. This is necessary for the rendering. * Preventing the player from moving the view (while the mod is capturing images). * The ability to offset the camera from the player. (*) As a last thing, if there is a way to roll the camera, that would also be good to know but it's not essential for the mod.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.