本文整理汇总了Java中com.badlogic.gdx.graphics.glutils.FrameBuffer.dispose方法的典型用法代码示例。如果您正苦于以下问题:Java FrameBuffer.dispose方法的具体用法?Java FrameBuffer.dispose怎么用?Java FrameBuffer.dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.glutils.FrameBuffer
的用法示例。
在下文中一共展示了FrameBuffer.dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resize
import com.badlogic.gdx.graphics.glutils.FrameBuffer; //导入方法依赖的package包/类
/** Resizes internal RavCamera for framebuffer use, call this in you ApplicationListener's resize.
*
* @param width - new screen width
* @param height - new screen height
* @param resizeFramebuffers - whether all of the framebuffers should be recreated to match new screen size */
public void resize (int width, int height, boolean resizeFramebuffers) {
// ?????
if (resizeFramebuffers) {
Keys<String> keys = frameBuffers.keys();
while (keys.hasNext) {
String key = keys.next();
FrameBuffer fb = frameBuffers.get(key);
int oldWidth = fb.getWidth();
int oldHeight = fb.getHeight();
Format format = fb.getColorBufferTexture().getTextureData().getFormat();
fb.dispose();
frameBuffers.put(key, null);
float factorX = 1f * width / screenCamera.viewportWidth;
float factorY = 1f * height / screenCamera.viewportHeight;
createFB(key, format, (int)(factorX * oldWidth), (int)(factorY * oldHeight));
// System.out.println("Recreated FB '" + key + "' from " +
// oldWidth + "x" + oldHeight + " to " +
// frameBuffers.get(key).getWidth() + "x" +
// frameBuffers.get(key).getHeight());
}
}
screenCamera = new OrthographicCamera(width, height);
createScreenQuad();
}
示例2: dispose
import com.badlogic.gdx.graphics.glutils.FrameBuffer; //导入方法依赖的package包/类
@Override
public void dispose() {
for (FrameBuffer buffer : abilityBuffers) {
buffer.dispose();
}
healthBuffer.dispose();
xpBuffer.dispose();
resourceBuffer.dispose();
shaderBatch.dispose();
shader.dispose();
for (Sprite s : abilityOverlaySprites)
s.getTexture().dispose();
}
示例3: dispose
import com.badlogic.gdx.graphics.glutils.FrameBuffer; //导入方法依赖的package包/类
/** Dispose this ShaderManager with all shaders and framebuffers */
public void dispose () {
for (ShaderProgram sp : shaders.values())
sp.dispose();
for (FrameBuffer fb : frameBuffers.values())
fb.dispose();
shaders.clear();
frameBuffers.clear();
}
示例4: disposeFB
import com.badlogic.gdx.graphics.glutils.FrameBuffer; //导入方法依赖的package包/类
public void disposeFB (String fbIdn) {
FrameBuffer fb = frameBuffers.get(fbIdn);
if (fb != null) {
fb.dispose();
frameBuffers.remove(fbIdn);
}
}
示例5: buildShadowMapData
import com.badlogic.gdx.graphics.glutils.FrameBuffer; //导入方法依赖的package包/类
/**
* Builds the shadow map data; frame buffers, arrays, etc.
*/
private void buildShadowMapData() {
if (shadowMapFb != null) {
for (FrameBuffer fb : shadowMapFb)
fb.dispose();
shadowMapFb = null;
}
shadowMapCombined = null;
// Shadow map frame buffer
shadowMapFb = new FrameBuffer[GlobalConf.scene.SHADOW_MAPPING_N_SHADOWS];
// Shadow map combined matrices
shadowMapCombined = new Matrix4[GlobalConf.scene.SHADOW_MAPPING_N_SHADOWS];
// Init
for (int i = 0; i < GlobalConf.scene.SHADOW_MAPPING_N_SHADOWS; i++) {
shadowMapFb[i] = new FrameBuffer(Format.RGBA8888, GlobalConf.scene.SHADOW_MAPPING_RESOLUTION, GlobalConf.scene.SHADOW_MAPPING_RESOLUTION, true);
shadowMapCombined[i] = new Matrix4();
}
if (smTexMap == null)
smTexMap = new HashMap<ModelBody, Texture>();
smTexMap.clear();
if (smCombinedMap == null)
smCombinedMap = new HashMap<ModelBody, Matrix4>();
smCombinedMap.clear();
if (candidates == null)
candidates = new Array<ModelBody>(GlobalConf.scene.SHADOW_MAPPING_N_SHADOWS);
candidates.clear();
}
示例6: clearFrameBufferMap
import com.badlogic.gdx.graphics.glutils.FrameBuffer; //导入方法依赖的package包/类
private void clearFrameBufferMap() {
Set<Integer> keySet = fb3D.keySet();
for (Integer key : keySet) {
FrameBuffer fb = fb3D.get(key);
fb.dispose();
}
fb3D.clear();
}
示例7: dispose
import com.badlogic.gdx.graphics.glutils.FrameBuffer; //导入方法依赖的package包/类
@Override
public void dispose() {
Set<Integer> keySet = fbcm.keySet();
for (Integer key : keySet) {
FrameBuffer fb = fbcm.get(key);
fb.dispose();
}
}
示例8: clearFrameBufferMap
import com.badlogic.gdx.graphics.glutils.FrameBuffer; //导入方法依赖的package包/类
public void clearFrameBufferMap() {
Set<String> keySet = fbmap.keySet();
for (String key : keySet) {
FrameBuffer fb = fbmap.get(key);
fb.dispose();
}
fbmap.clear();
}
示例9: takeScreenshot
import com.badlogic.gdx.graphics.glutils.FrameBuffer; //导入方法依赖的package包/类
public void takeScreenshot(String filename, int w) {
int h = (int) (w * getSceneCamera().viewportHeight / getSceneCamera().viewportWidth);
FrameBuffer fbo = new FrameBuffer(Format.RGB565, w, h, false);
fbo.begin();
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
draw();
Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, w, h);
fbo.end();
// Flip the pixmap upside down
ByteBuffer pixels = pixmap.getPixels();
int numBytes = w * h * 4;
byte[] lines = new byte[numBytes];
int numBytesPerLine = w * 4;
for (int i = 0; i < h; i++) {
pixels.position((h - i - 1) * numBytesPerLine);
pixels.get(lines, i * numBytesPerLine, numBytesPerLine);
}
pixels.clear();
pixels.put(lines);
PixmapIO.writePNG(EngineAssetManager.getInstance().getUserFile(filename), pixmap);
fbo.dispose();
}
示例10: createBgIcon
import com.badlogic.gdx.graphics.glutils.FrameBuffer; //导入方法依赖的package包/类
private TextureRegion createBgIcon(String atlas, String region) {
TextureAtlas a = new TextureAtlas(
Gdx.files.absolute(Ctx.project.getAssetPath() + Project.ATLASES_PATH + "/1/" + atlas + ".atlas"));
AtlasRegion r = a.findRegion(region);
if (r == null) {
a.dispose();
return null;
}
GLFrameBuffer.FrameBufferBuilder frameBufferBuilder = new GLFrameBuffer.FrameBufferBuilder(200,
(int) (r.getRegionHeight() * 200f / r.getRegionWidth()));
frameBufferBuilder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE);
FrameBuffer fbo = frameBufferBuilder.build();
SpriteBatch fboBatch = new SpriteBatch();
fboBatch.setColor(Color.WHITE);
OrthographicCamera camera = new OrthographicCamera();
camera.setToOrtho(false, fbo.getWidth(), fbo.getHeight());
fboBatch.setProjectionMatrix(camera.combined);
Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST);
fbo.begin();
fboBatch.begin();
fboBatch.draw(r, 0, 0, fbo.getWidth(), fbo.getHeight());
fboBatch.end();
TextureRegion tex = ScreenUtils.getFrameBufferTexture(0, 0, fbo.getWidth(), fbo.getHeight());
// tex.flip(false, true);
fbo.end();
Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);
fbo.dispose();
a.dispose();
fboBatch.dispose();
return tex;
}
示例11: dispose
import com.badlogic.gdx.graphics.glutils.FrameBuffer; //导入方法依赖的package包/类
@Override
public void dispose() {
for (FrameBuffer fb : frameBuffers.values())
fb.dispose();
frameBuffers.clear();
}
示例12: generate
import com.badlogic.gdx.graphics.glutils.FrameBuffer; //导入方法依赖的package包/类
/**
* Returns an UNMANAGED texture that of the supplied size that
* contains a map of the supplied game map.
*
* @param map
* @param gameState
* @param width
* @param height
* @return
*/
public static Texture generate(GameMap map, GameState gameState, int width, int height) {
boolean isIsometric = map.isIsometric();
GameMapRenderer renderer = isIsometric ? new IsometricMinimapRenderer(gameState, map) : new OrthogonalMinimapRenderer(gameState, map);
FrameBuffer fb = new FrameBuffer(Format.RGB565, width, height, false);
float cameraWidth = map.getWidth();
float cameraHeight = map.getHeight();
if (isIsometric) {
cameraWidth = cameraHeight = (float)(Math.sqrt(cameraWidth*cameraWidth + cameraHeight*cameraHeight) * Math.sqrt(2));
cameraHeight /= 2;
}
float cameraPositionX = cameraWidth / 2;
float cameraPositionY = isIsometric ? 0 : cameraHeight / 2;
int tileSizeX = (int) map.getTileSizeX();
int tileSizeY = (int) map.getTileSizeY();
if (cameraWidth * tileSizeX < width || cameraHeight * tileSizeY < height) {
cameraWidth = (float) width / tileSizeX;
cameraHeight = (float) height / tileSizeY;
}
OrthographicCamera camera = new OrthographicCamera(cameraWidth, cameraHeight);
camera.position.x = cameraPositionX;
camera.position.y = cameraPositionY;
camera.update();
fb.begin();
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT);
renderer.render(0, camera);
byte[] bytes = ScreenUtils.getFrameBufferPixels(0, 0, width, height, true);
fb.end();
fb.dispose();
renderer.dispose();
Pixmap pixmap = new Pixmap(width, height, Format.RGBA8888);
ByteBuffer pixels = pixmap.getPixels();
pixels.clear();
pixels.put(bytes);
pixels.position(0);
Texture returnValue = new Texture(pixmap);
pixmap.dispose();
return returnValue;
}
示例13: textureToPixmap
import com.badlogic.gdx.graphics.glutils.FrameBuffer; //导入方法依赖的package包/类
/**
* Converts a texture to a pixmap by drawing it to a frame buffer and
* getting the data
*
* @param tex
* The texture to convert
* @return The resulting pixmap
*/
public static Pixmap textureToPixmap(TextureRegion tex) {
//width and height in pixels
int width = tex.getRegionWidth();
int height = tex.getRegionWidth();
//Create a SpriteBatch to handle the drawing.
SpriteBatch sb = new SpriteBatch();
//Set the projection matrix for the SpriteBatch.
Matrix4 projectionMatrix = new Matrix4();
//because Pixmap has its origin on the topleft and everything else in LibGDX has the origin left bottom
//we flip the projection matrix on y and move it -height. So it will end up side up in the .png
projectionMatrix.setToOrtho2D(0, -height, width, height).scale(1, -1, 1);
//Set the projection matrix on the SpriteBatch
sb.setProjectionMatrix(projectionMatrix);
//Create a frame buffer.
FrameBuffer fb = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, false);
//Call begin(). So all next drawing will go to the new FrameBuffer.
fb.begin();
//Set up the SpriteBatch for drawing.
sb.begin();
//Draw all the tiles.
sb.draw(tex, 0, 0, width, height);
//End drawing on the SpriteBatch. This will flush() any sprites remaining to be drawn as well.
sb.end();
//Then retrieve the Pixmap from the buffer.
Pixmap pm = ScreenUtils.getFrameBufferPixmap(0, 0, width, height);
//Close the FrameBuffer. Rendering will resume to the normal buffer.
fb.end();
//Dispose of the resources.
fb.dispose();
sb.dispose();
return pm;
}
示例14: readCustom
import com.badlogic.gdx.graphics.glutils.FrameBuffer; //导入方法依赖的package包/类
private static boolean readCustom(String file, int size, int r, int g, int b)
{
assets.load(file, Model.class);
assets.finishLoading();
Model model = assets.get(file, Model.class);
if (model == null) {
LogHandler.log("Failed loading model.");
return false;
}
ModelInstance instance = new ModelInstance(model);
ModelBatch modelBatch = new ModelBatch();
BoundingBox box = new BoundingBox();
model.calculateBoundingBox(box);
FrameBuffer fbo = new FrameBuffer(Pixmap.Format.RGBA8888, size, size, false);
IntBuffer buffer = BufferUtils.newIntBuffer(size * size);
OrthographicCamera camera = new OrthographicCamera(box.getDimensions().z, box.getDimensions().y);
// Test screenshot
// camera.direction.set(1,0,0);
// camera.up.set(0,1,0);
//
// float slice = box.getDimensions().x / (float)size;
// camera.near = slice;
// camera.far = 100f;
//
// camera.position.set(box.getCenter());
// camera.position.x = box.getMin().x - slice;
//
// camera.update(true);
//
// fbo.begin();
// Gdx.graphics.getGL20().glColorMask(true, true, true, true);
// Gdx.graphics.getGL20().glClearColor(0, 0, 0, 1);
// Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
//
// Gdx.graphics.getGL20().glDisable(GL_DEPTH_TEST);
// Gdx.graphics.getGL20().glDisable(GL_BLEND);
//
// Gdx.graphics.getGL20().glDisable(GL_CULL_FACE);
//
// modelBatch.begin(camera);
// modelBatch.render(instance);
// modelBatch.end();
//
// buffer buffer = ScreenUtils.getFrameBufferbuffer(0, 0, fbo.getWidth(), fbo.getHeight());
// bufferIO.writePNG(Gdx.files.external("TinyVoxel/test.png"), buffer);
//
// fbo.end();
voxels = new int[size][size][size];
for (int x = 0; x < size; x++)
for (int y = 0; y < size; y++)
for (int z = 0; z < size; z++) {
voxels[x][y][z] = 0xff000000;
}
for (int z = 0; z < size; z++)
readSliceX(buffer, fbo, modelBatch, instance, camera, box, z, size);
camera = new OrthographicCamera(box.getDimensions().x, box.getDimensions().z);
for (int z = 0; z < size; z++)
readSliceY(buffer, fbo, modelBatch, instance, camera, box, z, size);
camera = new OrthographicCamera(box.getDimensions().x, box.getDimensions().y);
for (int z = 0; z < size; z++)
readSliceZ(buffer, fbo, modelBatch, instance, camera, box, z, size);
shift(size, 1);
floodFill(size, r, g, b);
model.dispose();
modelBatch.dispose();
fbo.dispose();
return true;
}
示例15: free
import com.badlogic.gdx.graphics.glutils.FrameBuffer; //导入方法依赖的package包/类
/**
* Releases the FrameBuffer indexed by given name. It will be removed from
* this pool then disposed.
*
* @param name
* the FrameBuffer's name
*/
public void free(String name) {
FrameBuffer fb = frameBuffers.remove(name);
if (fb != null)
fb.dispose();
}