当前位置: 首页>>代码示例>>Java>>正文


Java BufferUtils.copy方法代码示例

本文整理汇总了Java中com.badlogic.gdx.utils.BufferUtils.copy方法的典型用法代码示例。如果您正苦于以下问题:Java BufferUtils.copy方法的具体用法?Java BufferUtils.copy怎么用?Java BufferUtils.copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.utils.BufferUtils的用法示例。


在下文中一共展示了BufferUtils.copy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: takeScreenshot

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
public static void takeScreenshot() {
	byte[] pixels = ScreenUtils.getFrameBufferPixels(0, 0,
			Gdx.graphics.getBackBufferWidth(),
			Gdx.graphics.getBackBufferHeight(), true);

	Pixmap pixmap = new Pixmap(Gdx.graphics.getBackBufferWidth(),
			Gdx.graphics.getBackBufferHeight(), Pixmap.Format.RGBA8888);
	BufferUtils.copy(pixels, 0, pixmap.getPixels(), pixels.length);

	SimpleDateFormat dateFormat = new SimpleDateFormat(
			"yyyy-MM-dd HH-mm-ss");

	PixmapIO.writePNG(
			Gdx.files.external(dateFormat.format(new Date()) + ".png"),
			pixmap);
	pixmap.dispose();
}
 
开发者ID:eskalon,项目名称:ProjektGG,代码行数:18,代码来源:ScreenshotUtils.java

示例2: getFrameBufferPixmap

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
public Pixmap getFrameBufferPixmap(Viewport viewport) {
    int w = viewport.getScreenWidth();
    int h = viewport.getScreenHeight();
    int x = viewport.getScreenX();
    int y = viewport.getScreenY();
    final ByteBuffer pixelBuffer = BufferUtils.newByteBuffer(w * h * 4);

    Gdx.gl.glBindFramebuffer(GL20.GL_FRAMEBUFFER, fbo.getFramebufferHandle());
    Gdx.gl.glReadPixels(x, y, w, h, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE, pixelBuffer);
    Gdx.gl.glBindFramebuffer(GL20.GL_FRAMEBUFFER, 0);

    final int numBytes = w * h * 4;
    byte[] imgLines = new byte[numBytes];
    final int numBytesPerLine = w * 4;
    for (int i = 0; i < h; i++) {
        pixelBuffer.position((h - i - 1) * numBytesPerLine);
        pixelBuffer.get(imgLines, i * numBytesPerLine, numBytesPerLine);
    }

    Pixmap pixmap = new Pixmap(w, h, Pixmap.Format.RGBA8888);
    BufferUtils.copy(imgLines, 0, pixmap.getPixels(), imgLines.length);

    return pixmap;
}
 
开发者ID:mbrlabs,项目名称:Mundus,代码行数:25,代码来源:BasePicker.java

示例3: copy

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
/**
 * Copies the contents of {@code src} to {@code dst}.
 *
 * @throws IllegalArgumentException If the pixmaps are different sizes or different formats.
 */
public static void copy(Pixmap src, Pixmap dst) {
    Format srcFmt = src.getFormat();
    Format dstFmt = dst.getFormat();
    Checks.checkArgument(srcFmt == dstFmt, "Formats not equal: src=" + srcFmt + ", dst=" + dstFmt);

    int srcW = src.getWidth();
    int dstW = dst.getWidth();
    Checks.checkArgument(srcW == dstW, "Widths not equal: src.w=" + srcW + ", dst.w=" + dstW);

    int srcH = src.getHeight();
    int dstH = src.getHeight();
    Checks.checkArgument(srcH == dstH, "Heights not equal: src.h=" + srcH + ", dst.h=" + dstH);

    ByteBuffer srcPixels = src.getPixels();
    ByteBuffer dstPixels = dst.getPixels();
    BufferUtils.copy(srcPixels, dstPixels, srcPixels.limit());
    srcPixels.clear();
    dstPixels.clear();
}
 
开发者ID:anonl,项目名称:nvlist,代码行数:25,代码来源:PixmapUtil.java

示例4: setVertices

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
@Override
public void setVertices (float[] vertices, int offset, int count) {
	isDirty = true;
	if (isDirect) {
		BufferUtils.copy(vertices, byteBuffer, count, offset);
		buffer.position(0);
		buffer.limit(count);
	} else {
		buffer.clear();
		buffer.put(vertices, offset, count);
		buffer.flip();
		byteBuffer.position(0);
		byteBuffer.limit(buffer.limit() << 2);
	}

	bufferChanged();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:18,代码来源:VertexBufferObjectSubData.java

示例5: updateConstantBuffer

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
private void updateConstantBuffer() {
    baseModelViewMatrix.set(viewMatrix).translate(0.0f,  0.0f,  5f).rotate(1, 1, 1, rotation);
    ByteBuffer constant_buffer = dynamicConstantBuffer[constantDataBufferIndex].getContents();
    constant_buffer.order(ByteOrder.nativeOrder());
    for (int i = 0; i < kNumberOfBoxes; i++) {
        int multiplier = ((i % 2) == 0?1: -1);
        modelViewMatrix.set(baseModelViewMatrix).translate(0, 0, multiplier * 1.5f).rotate(1, 1, 1, rotation);

        normalMatrix.set(modelViewMatrix).tra().inv();
        constant_buffer.position((sizeOfConstantT *i) + normalMatrixOffset);
        BufferUtils.copy(normalMatrix.getValues(), 0, 16, constant_buffer);

        combinedMatrix.set(projectionMatrix).mul(modelViewMatrix);
        constant_buffer.position((sizeOfConstantT * i) + modelViewProjectionMatrixOffset);
        BufferUtils.copy(combinedMatrix.getValues(), 0, 16, constant_buffer);
    }
    rotation += 0.01;
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:19,代码来源:MetalBasic3DRenderer.java

示例6: takeScreenshot

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
/**
 * Takes a screenshot of the current game state and saves it in the assets directory
 */
public void takeScreenshot() {
	byte[] pixels = ScreenUtils.getFrameBufferPixels(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight(), true);
	Pixmap pixmap = new Pixmap(Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight(), Pixmap.Format.RGBA8888);
	BufferUtils.copy(pixels, 0, pixmap.getPixels(), pixels.length);
	PixmapIO.writePNG(Gdx.files.local("screenshots/screenshot.png"), pixmap);
	pixmap.dispose();
}
 
开发者ID:johannesmols,项目名称:GangsterSquirrel,代码行数:11,代码来源:MainGameClass.java

示例7: takeScreenShot

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
public static void takeScreenShot(final String filePath) {
    byte[] pixels = ScreenUtils.getFrameBufferPixels(
            0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight(), true
    );

    Pixmap pixmap = new Pixmap(
            Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight(), Pixmap.Format.RGBA8888
    );
    BufferUtils.copy(pixels, 0, pixmap.getPixels(), pixels.length);
    PixmapIO.writePNG(Gdx.files.external(filePath), pixmap);
    pixmap.dispose();
}
 
开发者ID:JayStGelais,项目名称:jrpg-engine,代码行数:13,代码来源:ScreenShotUtil.java

示例8: takeScreenshot

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
public void takeScreenshot() {
    byte[] pixels = ScreenUtils.getFrameBufferPixels(0, 0, Gdx.graphics.getBackBufferWidth(),
            Gdx.graphics.getBackBufferHeight(), true);
    Pixmap pixmap = new Pixmap(Gdx.graphics.getBackBufferWidth(),
            Gdx.graphics.getBackBufferHeight(), Pixmap.Format.RGBA8888);
    BufferUtils.copy(pixels, 0, pixmap.getPixels(), pixels.length);
    PixmapIO.writePNG(Gdx.files.external(UUID.randomUUID().toString() + ".png"), pixmap);
    pixmap.dispose();
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:10,代码来源:MainCamera.java

示例9: FreeTypeFontGenerator

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
/** Creates a new generator from the given font file. Uses {@link FileHandle#length()} to determine the file size. If the file
 * length could not be determined (it was 0), an extra copy of the font bytes is performed. Throws a
 * {@link GdxRuntimeException} if loading did not succeed. */
public FreeTypeFontGenerator (FileHandle fontFile) {
	name = fontFile.pathWithoutExtension();
	int fileSize = (int)fontFile.length();

	library = FreeType.initFreeType();
	if (library == null) throw new GdxRuntimeException("Couldn't initialize FreeType");

	ByteBuffer buffer;
	InputStream input = fontFile.read();
	try {
		if (fileSize == 0) {
			// Copy to a byte[] to get the file size, then copy to the buffer.
			byte[] data = StreamUtils.copyStreamToByteArray(input, fileSize > 0 ? (int)(fileSize * 1.5f) : 1024 * 16);
			buffer = BufferUtils.newByteBuffer(data.length);
			BufferUtils.copy(data, 0, buffer, data.length);
		} else {
			// Trust the specified file size.
			buffer = BufferUtils.newByteBuffer(fileSize);
			StreamUtils.copyStream(input, buffer);
		}
	} catch (IOException ex) {
		throw new GdxRuntimeException(ex);
	} finally {
		StreamUtils.closeQuietly(input);
	}

	face = library.newMemoryFace(buffer, 0);
	if (face == null) throw new GdxRuntimeException("Couldn't create face for font: " + fontFile);

	if (checkForBitmapFont()) return;
	setPixelSizes(0, 15);
}
 
开发者ID:intrigus,项目名称:gdx-freetype-gwt,代码行数:36,代码来源:FreeTypeFontGenerator.java

示例10: setVertices

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
@Override
public void setVertices(float[] vertices, int offset, int count) {
    isDirty = true;
    BufferUtils.copy(vertices, buffer, count, offset);
    buffer.position(0);
    buffer.limit(count);
    bufferChanged();
}
 
开发者ID:konsoletyper,项目名称:teavm-libgdx,代码行数:9,代码来源:VertexArrayEmulator.java

示例11: updateVertices

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
@Override
public void updateVertices(int targetOffset, float[] vertices, int sourceOffset, int count) {
    isDirty = true;
    final int pos = buffer.position();
    buffer.position(targetOffset);
    BufferUtils.copy(vertices, sourceOffset, count, buffer);
    buffer.position(pos);
    bufferChanged();
}
 
开发者ID:konsoletyper,项目名称:teavm-libgdx,代码行数:10,代码来源:VertexArrayEmulator.java

示例12: updateVertices

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
@Override
public void updateVertices (int targetOffset, float[] vertices, int sourceOffset, int count) {
	isDirty = true;
	final int pos = byteBuffer.position();
	byteBuffer.position(targetOffset * 4);
	BufferUtils.copy(vertices, sourceOffset, count, byteBuffer);
	byteBuffer.position(pos);
	buffer.position(0);
	bufferChanged();
}
 
开发者ID:kennux,项目名称:libgdx-opencl,代码行数:11,代码来源:DynamicVertexBufferObject.java

示例13: updateVertices

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
@Override
public void updateVertices (int targetOffset, float[] vertices, int sourceOffset, int count) {
	final int pos = byteBuffer.position();
	byteBuffer.position(targetOffset * 4);
	BufferUtils.copy(vertices, sourceOffset, count, byteBuffer);
	byteBuffer.position(pos);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:8,代码来源:VertexArray.java

示例14: setVertices

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
@Override
public void setVertices (float[] vertices, int offset, int count) {
	isDirty = true;
	BufferUtils.copy(vertices, byteBuffer, count, offset);
	buffer.position(0);
	buffer.limit(count);
	bufferChanged();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:9,代码来源:VertexBufferObject.java

示例15: getPixmap

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
/**
 * @return Pixmap representing the glyph, needs to be disposed manually.
 */
public Pixmap getPixmap(Format format) {
	Pixmap pixmap = new Pixmap(getWidth(), getRows(), Format.Alpha);
	BufferUtils.copy(getBuffer(), pixmap.getPixels(), pixmap.getPixels().capacity());
	Pixmap converted = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), format);
	Blending blending = Pixmap.getBlending();
	Pixmap.setBlending(Blending.None);
	converted.drawPixmap(pixmap, 0, 0);
	Pixmap.setBlending(blending);
	pixmap.dispose();
	return converted;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:15,代码来源:FreeType.java


注:本文中的com.badlogic.gdx.utils.BufferUtils.copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。