net.minecraft.client.shader.Framebuffer Java Examples

The following examples show how to use net.minecraft.client.shader.Framebuffer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OutlineUtils.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets up the FBO with depth and stencil
 *
 * @param fbo Framebuffer
 */
private static void setupFBO(final Framebuffer fbo) {
    // Deletes old render buffer extensions such as depth
    // Args: Render Buffer ID
    EXTFramebufferObject.glDeleteRenderbuffersEXT(fbo.depthBuffer);
    // Generates a new render buffer ID for the depth and stencil extension
    final int stencil_depth_buffer_ID = EXTFramebufferObject.glGenRenderbuffersEXT();
    // Binds new render buffer by ID
    // Args: Target (GL_RENDERBUFFER_EXT), ID
    EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, stencil_depth_buffer_ID);
    // Adds the depth and stencil extension
    // Args: Target (GL_RENDERBUFFER_EXT), Extension (GL_DEPTH_STENCIL_EXT),
    // Width, Height
    EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, EXTPackedDepthStencil.GL_DEPTH_STENCIL_EXT, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
    // Adds the stencil attachment
    // Args: Target (GL_FRAMEBUFFER_EXT), Attachment
    // (GL_STENCIL_ATTACHMENT_EXT), Target (GL_RENDERBUFFER_EXT), ID
    EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_STENCIL_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, stencil_depth_buffer_ID);
    // Adds the depth attachment
    // Args: Target (GL_FRAMEBUFFER_EXT), Attachment
    // (GL_DEPTH_ATTACHMENT_EXT), Target (GL_RENDERBUFFER_EXT), ID
    EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, stencil_depth_buffer_ID);
}
 
Example #2
Source File: FramebufferShader.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @author TheSlowly
 */
public void drawFramebuffer(final Framebuffer framebuffer) {
    final ScaledResolution scaledResolution = new ScaledResolution(mc);
    glBindTexture(GL_TEXTURE_2D, framebuffer.framebufferTexture);
    glBegin(GL_QUADS);
    glTexCoord2d(0, 1);
    glVertex2d(0, 0);
    glTexCoord2d(0, 0);
    glVertex2d(0, scaledResolution.getScaledHeight());
    glTexCoord2d(1, 0);
    glVertex2d(scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight());
    glTexCoord2d(1, 1);
    glVertex2d(scaledResolution.getScaledWidth(), 0);
    glEnd();
    glUseProgram(0);
}
 
Example #3
Source File: OutlineUtils.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
public static void checkSetupFBO() {
    // Gets the FBO of Minecraft
    final Framebuffer fbo = Minecraft.getMinecraft().getFramebuffer();

    // Check if FBO isn't null
    if(fbo != null) {
        // Checks if screen has been resized or new FBO has been created
        if(fbo.depthBuffer > -1) {
            // Sets up the FBO with depth and stencil extensions (24/8 bit)
            setupFBO(fbo);
            // Reset the ID to prevent multiple FBO's
            fbo.depthBuffer = -1;
        }
    }
}
 
Example #4
Source File: FramebufferBlitter.java    From OpenModsLib with MIT License 5 votes vote down vote up
public void blitFramebuffer(Framebuffer in, Framebuffer out) {
	OpenGlHelper.glBindFramebuffer(getReadConst(), in.framebufferObject);
	OpenGlHelper.glBindFramebuffer(getDrawConst(), out.framebufferObject);

	blitFramebufferOp(in, out);

	OpenGlHelper.glBindFramebuffer(getReadConst(), 0);
	OpenGlHelper.glBindFramebuffer(getDrawConst(), 0);
}
 
Example #5
Source File: FramebufferBlitter.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
public void blitFramebufferOp(Framebuffer in, Framebuffer out) {
	EXTFramebufferBlit.glBlitFramebufferEXT(
			0, 0, in.framebufferWidth, in.framebufferHeight,
			0, 0, out.framebufferWidth, out.framebufferHeight,
			GL11.GL_COLOR_BUFFER_BIT,
			GL11.GL_NEAREST);
}
 
Example #6
Source File: FramebufferBlitter.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
public void blitFramebufferOp(Framebuffer in, Framebuffer out) {
	GL30.glBlitFramebuffer(
			0, 0, in.framebufferWidth, in.framebufferHeight,
			0, 0, out.framebufferWidth, out.framebufferHeight,
			GL11.GL_COLOR_BUFFER_BIT,
			GL11.GL_NEAREST);

}
 
Example #7
Source File: RenderUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Renders items and blocks in the world at 0,0,0 with transformations that size them appropriately
 *
 * @param spin The spin angle of the item around the y axis in degrees
 */
/*public static void renderItemUniform(ItemStack item, double spin)
{
    IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(item, ENTITY);
    boolean is3D = customRenderer != null && customRenderer.shouldUseRenderHelper(ENTITY, item, BLOCK_3D);

    boolean larger = false;
    if (item.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(item.getItem()).getRenderType()))
    {
        int renderType = Block.getBlockFromItem(item.getItem()).getRenderType();
        larger = !(renderType == 1 || renderType == 19 || renderType == 12 || renderType == 2);
    }
    else if(is3D)
    {
        larger = true;
    }
    
    double d = 2;
    double d1 = 1/d;
    if(larger)
        GLStateManager.scale(d, d, d);

    GLStateManager.color(1, 1, 1, 1);
    
    entityItem.setEntityItemStack(item);
    uniformRenderItem.doRender(entityItem, 0, larger ? 0.09 : 0.06, 0, 0, (float)(spin*9/Math.PI));
    
    if(larger)
        GLStateManager.scale(d1, d1, d1);
}/*

/**
 * Checks if stencil buffer is supported and attempts to enable it if so.
 */
public static boolean checkEnableStencil() {
    Framebuffer fb = Minecraft.getMinecraft().getFramebuffer();
    return fb.isStencilEnabled() || fb.enableStencil();
}
 
Example #8
Source File: GuiItemIconDumper.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private BufferedImage screenshot() {
    Framebuffer fb = Minecraft.getMinecraft().getFramebuffer();
    Dimension mcSize = GuiDraw.displayRes();
    Dimension texSize = mcSize;

    if (OpenGlHelper.isFramebufferEnabled())
        texSize = new Dimension(fb.framebufferTextureWidth, fb.framebufferTextureHeight);

    int k = texSize.width * texSize.height;
    if (pixelBuffer == null || pixelBuffer.capacity() < k) {
        pixelBuffer = BufferUtils.createIntBuffer(k);
        pixelValues = new int[k];
    }

    GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1);
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
    pixelBuffer.clear();

    if (OpenGlHelper.isFramebufferEnabled()) {
        GlStateManager.bindTexture(fb.framebufferTexture);
        GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
    } else {
        GL11.glReadPixels(0, 0, texSize.width, texSize.height, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
    }

    pixelBuffer.get(pixelValues);
    TextureUtil.processPixelValues(pixelValues, texSize.width, texSize.height);

    BufferedImage img = new BufferedImage(mcSize.width, mcSize.height, BufferedImage.TYPE_INT_ARGB);
    if (OpenGlHelper.isFramebufferEnabled()) {
        int yOff = texSize.height - mcSize.height;
        for (int y = 0; y < mcSize.height; ++y)
            for (int x = 0; x < mcSize.width; ++x)
                img.setRGB(x, y, pixelValues[(y + yOff) * texSize.width + x]);
    } else {
        img.setRGB(0, 0, texSize.width, height, pixelValues, 0, texSize.width);
    }

    return img;
}
 
Example #9
Source File: VideoProducerImplementation.java    From malmo with MIT License 5 votes vote down vote up
@Override
public void prepare(MissionInit missionInit)
{
    this.fbo = new Framebuffer(this.videoParams.getWidth(), this.videoParams.getHeight(), true);
    // Create a buffer for retrieving the depth map, if requested:
    if (this.videoParams.isWantDepth())
        this.depthBuffer = BufferUtils.createFloatBuffer(this.videoParams.getWidth() * this.videoParams.getHeight());
    // Set the requested camera position
    Minecraft.getMinecraft().gameSettings.thirdPersonView = this.videoParams.getViewpoint();
}
 
Example #10
Source File: ColourMapProducerImplementation.java    From malmo with MIT License 5 votes vote down vote up
@Override
public void prepare(MissionInit missionInit)
{
    this.fbo = new Framebuffer(this.getWidth(), this.getHeight(), true);
    TextureHelper.setIsProducingColourMap(true);
    TextureHelper.setMobColours(this.mobColours);
    TextureHelper.setMiscTextureColours(this.miscColours);
    TextureHelper.setSkyRenderer(new TextureHelper.BlankSkyRenderer(this.cmParams.getSkyColour()));
}
 
Example #11
Source File: DepthProducerImplementation.java    From malmo with MIT License 5 votes vote down vote up
@Override
public void prepare(MissionInit missionInit)
{
    this.fbo = new Framebuffer(this.videoParams.getWidth(), this.videoParams.getHeight(), true);
    // Set the requested camera position
    // Minecraft.getMinecraft().gameSettings.thirdPersonView = this.videoParams.getViewpoint();
}
 
Example #12
Source File: Camera.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
public Camera() {
    this.pos = new Vec3d(0, 0, 0);
    this.yaw = 0;
    this.pitch = 0;
    this.frameBuffer = new Framebuffer(WIDTH_RESOLUTION, HEIGHT_RESOLUTION, true);
    this.frameBuffer.createFramebuffer(WIDTH_RESOLUTION, HEIGHT_RESOLUTION);
}
 
Example #13
Source File: GuiItemIconDumper.java    From NotEnoughItems with MIT License 4 votes vote down vote up
private BufferedImage screenshot() {
    Framebuffer fb = Minecraft.getMinecraft().getFramebuffer();
    Dimension mcSize = GuiDraw.getDisplayRes();
    Dimension texSize = mcSize;

    if (OpenGlHelper.isFramebufferEnabled()) {
        texSize = new Dimension(fb.framebufferTextureWidth, fb.framebufferTextureHeight);
    }

    int k = texSize.width * texSize.height;
    if (pixelBuffer == null || pixelBuffer.capacity() < k) {
        pixelBuffer = BufferUtils.createIntBuffer(k);
        pixelValues = new int[k];
    }

    GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1);
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
    pixelBuffer.clear();

    if (OpenGlHelper.isFramebufferEnabled()) {
        GlStateManager.bindTexture(fb.framebufferTexture);
        GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
    } else {
        GL11.glReadPixels(0, 0, texSize.width, texSize.height, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
    }

    pixelBuffer.get(pixelValues);
    TextureUtil.processPixelValues(pixelValues, texSize.width, texSize.height);

    BufferedImage img = new BufferedImage(mcSize.width, mcSize.height, BufferedImage.TYPE_INT_ARGB);
    if (OpenGlHelper.isFramebufferEnabled()) {
        int yOff = texSize.height - mcSize.height;
        for (int y = 0; y < mcSize.height; ++y) {
            for (int x = 0; x < mcSize.width; ++x) {
                img.setRGB(x, y, pixelValues[(y + yOff) * texSize.width + x]);
            }
        }
    } else {
        img.setRGB(0, 0, texSize.width, height, pixelValues, 0, texSize.width);
    }

    return img;
}
 
Example #14
Source File: LuminanceProducerImplementation.java    From malmo with MIT License 4 votes vote down vote up
@Override
public void prepare(MissionInit missionInit)
{
    this.fbo = new Framebuffer(this.getWidth(), this.getHeight(), true);
}
 
Example #15
Source File: FramebufferBlitter.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
protected void blitFramebufferOp(Framebuffer in, Framebuffer out) {
	throw new UnsupportedOperationException();
}
 
Example #16
Source File: HyperiumScreenshotHelper.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static IChatComponent saveScreenshot(int width, int height, Framebuffer buffer, IntBuffer pixelBuffer, int[] pixelValues) {
    final File file1 = new File(Minecraft.getMinecraft().mcDataDir, "screenshots");
    file1.mkdir();

    if (OpenGlHelper.isFramebufferEnabled()) {
        width = buffer.framebufferTextureWidth;
        height = buffer.framebufferTextureHeight;
    }

    final int i = width * height;

    if (pixelBuffer == null || pixelBuffer.capacity() < i) {
        pixelBuffer = BufferUtils.createIntBuffer(i);
        pixelValues = new int[i];
    }

    GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1);
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
    pixelBuffer.clear();

    if (OpenGlHelper.isFramebufferEnabled()) {
        GlStateManager.bindTexture(buffer.framebufferTexture);
        GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
    } else {
        GL11.glReadPixels(0, 0, width, height, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
    }

    boolean upload = true;
    pixelBuffer.get(pixelValues);

    if (!Settings.DEFAULT_UPLOAD_SS) {
        HyperiumBind uploadBind = Hyperium.INSTANCE.getHandlers().getKeybindHandler().getBinding("Upload Screenshot");
        int keyCode = uploadBind.getKeyCode();
        upload = keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode);
    }

    new Thread(new AsyncScreenshotSaver(width, height, pixelValues, Minecraft.getMinecraft().getFramebuffer(),
        new File(Minecraft.getMinecraft().mcDataDir, "screenshots"), upload)).start();
    if (!upload) {
        return Settings.HYPERIUM_CHAT_PREFIX ? new ChatComponentText(ChatColor.RED + "[Hyperium] " + ChatColor.WHITE + "Capturing...") :
            new ChatComponentText(ChatColor.WHITE + "Capturing...");
    }
    return Settings.HYPERIUM_CHAT_PREFIX ? new ChatComponentText(ChatColor.RED + "[Hyperium] " + ChatColor.WHITE + "Uploading...") :
        new ChatComponentText(ChatColor.WHITE + "Uploading...");
}
 
Example #17
Source File: AsyncScreenshotSaver.java    From Hyperium with GNU Lesser General Public License v3.0 3 votes vote down vote up
/**
 * Create a constructor to initialize all the variables once called
 *
 * @param width         width of the screenshot
 * @param height        height of the screenshot
 * @param pixelValues   pixel values used to determine color
 * @param frameBuffer   binded frames
 * @param screenshotDir screenshot directory
 * @param upload        should it upload to imgur?
 */
public AsyncScreenshotSaver(final int width, final int height, final int[] pixelValues, final Framebuffer frameBuffer, final File screenshotDir, final boolean upload) {
    this.width = width;
    this.height = height;
    this.pixelValues = pixelValues;
    this.frameBuffer = frameBuffer;
    this.screenshotDir = screenshotDir;
    this.upload = upload;
}
 
Example #18
Source File: MixinScreenShotHelper.java    From Hyperium with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * @author Kevin Brewster, Orange Marhsall, Mojang
 * @reason Saves a screenshot in the game directory with the given file name (or null to generate a time-stamped name).
 * Fixes MC-113208 and MC-117793
 */
@Overwrite
public static IChatComponent saveScreenshot(File gameDirectory, String screenshotName, int width, int height, Framebuffer buffer) {
    return HyperiumScreenshotHelper.saveScreenshot(width, height, buffer, pixelBuffer, pixelValues);
}
 
Example #19
Source File: FramebufferBlitter.java    From OpenModsLib with MIT License votes vote down vote up
protected abstract void blitFramebufferOp(Framebuffer in, Framebuffer out);