Java Code Examples for com.badlogic.gdx.graphics.Pixmap.Format#RGB565

The following examples show how to use com.badlogic.gdx.graphics.Pixmap.Format#RGB565 . 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: TransitionManager.java    From uracer-kotd with Apache License 2.0 6 votes vote down vote up
public TransitionManager (Rectangle viewport, boolean use32Bits, boolean useAlphaChannel, boolean useDepth) {
	this.viewport.set(viewport);
	transition = null;
	paused = false;
	fbFormat = Format.RGB565;
	usedepth = useDepth;

	if (use32Bits) {
		if (useAlphaChannel) {
			fbFormat = Format.RGBA8888;
		} else {
			fbFormat = Format.RGB888;
		}
	} else {
		if (useAlphaChannel) {
			fbFormat = Format.RGBA4444;
		} else {
			fbFormat = Format.RGB565;
		}
	}

	fbFrom = new FrameBuffer(fbFormat, (int)viewport.width, (int)viewport.height, useDepth);
	fbTo = new FrameBuffer(fbFormat, (int)viewport.width, (int)viewport.height, useDepth);
}
 
Example 2
Source File: Renderer.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
public Renderer () {
	try {
		lights = new Environment();
		lights.add(new DirectionalLight().set(Color.WHITE, new Vector3(-1, -0.5f, 0).nor()));

		spriteBatch = new SpriteBatch();
		modelBatch = new ModelBatch();

		backgroundTexture = new Texture(Gdx.files.internal("data/planet.jpg"), Format.RGB565, true);
		backgroundTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);

		font = new BitmapFont(Gdx.files.internal("data/font10.fnt"), Gdx.files.internal("data/font10.png"), false);

		camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	} catch (Exception ex) {
		ex.printStackTrace();
	}
}
 
Example 3
Source File: PostProcessor.java    From RuinsOfRevenge with MIT License 6 votes vote down vote up
public PostProcessor( int fboWidth, int fboHeight, boolean useDepth, boolean useAlphaChannel, boolean use32Bits,
		TextureWrap u, TextureWrap v ) {
	if( use32Bits ) {
		if( useAlphaChannel ) {
			fbFormat = Format.RGBA8888;
		} else {
			fbFormat = Format.RGB888;
		}
	} else {
		if( useAlphaChannel ) {
			fbFormat = Format.RGBA4444;
		} else {
			fbFormat = Format.RGB565;
		}
	}

	composite = newPingPongBuffer( fboWidth, fboHeight, fbFormat, useDepth );
	setBufferTextureWrap( u, v );

	pipelineState = new PipelineState();

	capturing = false;
	hasCaptured = false;
	enabled = true;
	this.useDepth = useDepth;
}
 
Example 4
Source File: PostProcessor.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
/** Construct a new PostProcessor with the given parameters and the specified texture wrap mode */
public PostProcessor (int fboWidth, int fboHeight, boolean useDepth, boolean useAlphaChannel, boolean use32Bits,
	TextureWrap u, TextureWrap v) {
	if (use32Bits) {
		if (useAlphaChannel) {
			fbFormat = Format.RGBA8888;
		} else {
			fbFormat = Format.RGB888;
		}
	} else {
		if (useAlphaChannel) {
			fbFormat = Format.RGBA4444;
		} else {
			fbFormat = Format.RGB565;
		}
	}

	composite = newPingPongBuffer(fboWidth, fboHeight, fbFormat, useDepth);
	setBufferTextureWrap(u, v);

	pipelineState = new PipelineState();

	capturing = false;
	hasCaptured = false;
	enabled = true;
	this.useDepth = useDepth;
	if (useDepth) {
		clearBits |= GL20.GL_DEPTH_BUFFER_BIT;
	}

	setViewport(null);
}
 
Example 5
Source File: World.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
public void takeScreenshot(String filename, int w) {

		// get viewport
		IntBuffer results = BufferUtils.newIntBuffer(16);
		Gdx.gl20.glGetIntegerv(GL20.GL_VIEWPORT, results);

		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);

		// restore viewport
		fbo.end(results.get(0), results.get(1), results.get(2), results.get(3));

		// 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();
	}