本文整理汇总了Java中net.minecraft.client.shader.Framebuffer类的典型用法代码示例。如果您正苦于以下问题:Java Framebuffer类的具体用法?Java Framebuffer怎么用?Java Framebuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Framebuffer类属于net.minecraft.client.shader包,在下文中一共展示了Framebuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveFrameBufferToFile
import net.minecraft.client.shader.Framebuffer; //导入依赖的package包/类
public int saveFrameBufferToFile(Framebuffer buffer, File f, int width, int height, boolean cut) {
try {
BufferedImage bufferedimage = getImageFromFrameBuffer(buffer, width, height);
if(cut) {
Rectangle bound = getImageBound(bufferedimage);
int compareResult = compareImage(bufferedimage, bound);
if(compareResult == 0) {
bufferedimage = cutPicture(bufferedimage, bound);
} else {
return compareResult;
}
}
ImageIO.write(bufferedimage, "png", f);
} catch(Exception e) {
RenderToMod.logger.error("Cannot save framebuffer to file " + f);
RenderToMod.logger.error(e + ": " + e.getMessage());
RenderToMod.logger.error(Arrays.toString(e.getStackTrace()));
}
return 0;
}
示例2: getImageFromFrameBuffer
import net.minecraft.client.shader.Framebuffer; //导入依赖的package包/类
public BufferedImage getImageFromFrameBuffer(Framebuffer buffer, int width, int height) {
int k = buffer.framebufferTextureWidth * buffer.framebufferTextureHeight;
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();
GlStateManager.bindTexture(buffer.framebufferTexture);
GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
pixelBuffer.get(pixelValues);
TextureUtil.processPixelValues(pixelValues, buffer.framebufferTextureWidth, buffer.framebufferTextureHeight);
BufferedImage bufferedimage = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
int l = buffer.framebufferTextureHeight - buffer.framebufferHeight;
bufferedimage.setRGB(0, 0, width, height, pixelValues, l*buffer.framebufferTextureWidth, buffer.framebufferTextureWidth);
return bufferedimage;
}
示例3: saveBlockPic
import net.minecraft.client.shader.Framebuffer; //导入依赖的package包/类
private void saveBlockPic(String domain, String selected, int outputSize) {
File f = new File(saveDir, domain + "/block/" + outputSize + "x/" + selected.replaceAll("[^0-9a-zA-Z]{1}", "_") + ".png");
f.getParentFile().mkdirs();
Framebuffer mb = mc.getFramebuffer();
int radius = Math.min(mb.framebufferWidth, mb.framebufferHeight);
Framebuffer fb = new Framebuffer(mb.framebufferWidth * outputSize / radius, mb.framebufferHeight * outputSize / radius, true);
fb.framebufferClear();
fb.bindFramebuffer(false);
int r = radius * this.width / mb.framebufferWidth;
setupRenderItemGlState(r, 0, 0);
drawBlockCore(selected);
releaseRenderItemGlState();
FrameBufferUtils.instance.saveFrameBufferToFile(fb, f, outputSize, outputSize, false);
mb.bindFramebuffer(true);
fb.deleteFramebuffer();
}
示例4: saveItemPic
import net.minecraft.client.shader.Framebuffer; //导入依赖的package包/类
private void saveItemPic(String domain, String selected, int outputSize) {
File f = new File(saveDir, domain + "/item/" + outputSize + "x/" + selected.replaceAll("[^0-9a-zA-Z]{1}", "_") + ".png");
f.getParentFile().mkdirs();
Framebuffer mb = mc.getFramebuffer();
int radius = Math.min(mb.framebufferWidth, mb.framebufferHeight);
Framebuffer fb = new Framebuffer(mb.framebufferWidth * outputSize / radius, mb.framebufferHeight * outputSize / radius, true);
fb.framebufferClear();
fb.bindFramebuffer(false);
int r = radius * this.width / mb.framebufferWidth;
setupRenderItemGlState(r, 0, 0);
drawItemCore(selected);
releaseRenderItemGlState();
FrameBufferUtils.instance.saveFrameBufferToFile(fb, f, outputSize, outputSize, false);
mb.bindFramebuffer(true);
fb.deleteFramebuffer();
}
示例5: readPixels
import net.minecraft.client.shader.Framebuffer; //导入依赖的package包/类
public void readPixels(boolean fbo, boolean pbo) {
buffer.rewind();
// set alignment flags
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
// read texture from framebuffer if enabled, otherwise use slower
// glReadPixels
if (fbo) {
Framebuffer fb = MC.getFramebuffer();
fb.bindFramebufferTexture();
if (pbo) {
glGetTexImage(GL_TEXTURE_2D, 0, FORMAT, TYPE, 0);
} else {
glGetTexImage(GL_TEXTURE_2D, 0, FORMAT, TYPE, buffer);
}
fb.unbindFramebufferTexture();
} else {
if (pbo) {
glReadPixels(0, 0, width, height, FORMAT, TYPE, 0);
} else {
glReadPixels(0, 0, width, height, FORMAT, TYPE, buffer);
}
}
}
示例6: FrameBufferShim
import net.minecraft.client.shader.Framebuffer; //导入依赖的package包/类
public FrameBufferShim(Framebuffer buf ) {
super(32,32,false); //just dummy values. We'll delete it anyway
deleteFramebuffer();
framebufferTextureWidth = buf.framebufferTextureWidth;
framebufferTextureHeight = buf.framebufferTextureHeight;
framebufferWidth = buf.framebufferWidth;
framebufferHeight = buf.framebufferHeight;
framebufferObject = buf.framebufferObject;
framebufferTexture = buf.framebufferTexture;
useDepth = buf.useDepth;
depthBuffer = buf.depthBuffer;
framebufferColor = buf.framebufferColor;
framebufferFilter = buf.framebufferFilter;
}
示例7: Camera
import net.minecraft.client.shader.Framebuffer; //导入依赖的package包/类
public Camera(CameraHandle handle) {
this.handle = handle;
this.reflected = handle.reflected();
this.framebuffer = new Framebuffer(handle.width(), handle.height(), true);
CameraManager.getInstance().register(this);
}
示例8: LoadingScreenRenderer
import net.minecraft.client.shader.Framebuffer; //导入依赖的package包/类
public LoadingScreenRenderer(Minecraft mcIn)
{
this.mc = mcIn;
this.scaledResolution = new ScaledResolution(mcIn);
this.framebuffer = new Framebuffer(mcIn.displayWidth, mcIn.displayHeight, false);
this.framebuffer.setFramebufferFilter(9728);
}
示例9: prepare
import net.minecraft.client.shader.Framebuffer; //导入依赖的package包/类
@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();
}
示例10: renderWorld
import net.minecraft.client.shader.Framebuffer; //导入依赖的package包/类
@Override
public void renderWorld(EntityRenderer er, Minecraft mc, Framebuffer framebuffer, Shader shader,
int[] framebufferTextures, float partialTicks, long finishTimeNano, int width, int height, float sizeIncrease) {
RenderUtil.render360 = false;
RenderUtil.partialWidth = mc.displayWidth;
RenderUtil.partialHeight = mc.displayHeight;
er.renderWorldPass(2, partialTicks, finishTimeNano);
}
示例11: createScreenshot
import net.minecraft.client.shader.Framebuffer; //导入依赖的package包/类
public static BufferedImage createScreenshot(int width, int height, Framebuffer framebufferIn)
{
if (OpenGlHelper.isFramebufferEnabled())
{
width = framebufferIn.framebufferTextureWidth;
height = framebufferIn.framebufferTextureHeight;
}
int i = width * height;
if (pixelBuffer == null || pixelBuffer.capacity() < i)
{
pixelBuffer = BufferUtils.createIntBuffer(i);
pixelValues = new int[i];
}
GlStateManager.glPixelStorei(3333, 1);
GlStateManager.glPixelStorei(3317, 1);
pixelBuffer.clear();
if (OpenGlHelper.isFramebufferEnabled())
{
GlStateManager.bindTexture(framebufferIn.framebufferTexture);
GlStateManager.glGetTexImage(3553, 0, 32993, 33639, pixelBuffer);
}
else
{
GlStateManager.glReadPixels(0, 0, width, height, 32993, 33639, pixelBuffer);
}
pixelBuffer.get(pixelValues);
TextureUtil.processPixelValues(pixelValues, width, height);
BufferedImage bufferedimage = new BufferedImage(width, height, 1);
bufferedimage.setRGB(0, 0, width, height, pixelValues, 0, width);
return bufferedimage;
}
示例12: saveScreenshot
import net.minecraft.client.shader.Framebuffer; //导入依赖的package包/类
/**
* Saves a screenshot in the game directory with a time-stamped filename.
* Returns an ITextComponent indicating the success/failure of the saving.
*/
public static ITextComponent saveScreenshot(File gameDirectory, int width, int height, Framebuffer buffer)
{
/**
* Saves a screenshot in the game directory with the given file name (or null to generate a time-stamped name).
* Returns an ITextComponent indicating the success/failure of the saving.
*/
return saveScreenshot(gameDirectory, (String)null, width, height, buffer);
}
示例13: AetherLoadingScreen
import net.minecraft.client.shader.Framebuffer; //导入依赖的package包/类
public AetherLoadingScreen(Minecraft mcIn)
{
super(mcIn);
this.mc = mcIn;
this.framebuffer = new Framebuffer(mcIn.displayWidth, mcIn.displayHeight, false);
this.framebuffer.setFramebufferFilter(9728);
}
示例14: setSize
import net.minecraft.client.shader.Framebuffer; //导入依赖的package包/类
public void setSize(final int width, final int height) {
if (this.blit != null && (this.blit.framebufferWidth != width || this.blit.framebufferHeight != height)) {
this.release();
}
if (this.blit == null) {
this.blit = new Framebuffer(width, height, false);
this.blit.setFramebufferColor(0F, 0F, 0F, 0F);
}
}
示例15: screenshot
import net.minecraft.client.shader.Framebuffer; //导入依赖的package包/类
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;
}