• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright 2011 See AUTHORS file.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 
17 package com.badlogic.gdx.tests;
18 
19 import com.badlogic.gdx.Files;
20 import com.badlogic.gdx.Gdx;
21 import com.badlogic.gdx.InputProcessor;
22 import com.badlogic.gdx.graphics.GL20;
23 import com.badlogic.gdx.graphics.Pixmap;
24 import com.badlogic.gdx.graphics.Texture;
25 import com.badlogic.gdx.graphics.g2d.Sprite;
26 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
27 import com.badlogic.gdx.math.Matrix4;
28 import com.badlogic.gdx.tests.utils.GdxTest;
29 
30 public class PixmapBlendingTest extends GdxTest {
31 	private SpriteBatch spriteBatch;
32 	private Texture text;
33 	private Sprite logoSprite, test3, test4;
34 	private Pixmap pixD, pixS1, pixS2;
35 
36 	InputProcessor inputProcessor;
37 
38 	@Override
create()39 	public void create () {
40 		if (spriteBatch != null) return;
41 		spriteBatch = new SpriteBatch();
42 
43 		Matrix4 transform = new Matrix4();
44 		transform.setToTranslation(0, Gdx.graphics.getHeight(), 0);
45 		transform.mul(new Matrix4().setToScaling(1, -1, 1));
46 		spriteBatch.setTransformMatrix(transform);
47 
48 		pixS1 = new Pixmap(Gdx.files.getFileHandle("data/test4.png", Files.FileType.Internal));
49 		pixS2 = new Pixmap(Gdx.files.getFileHandle("data/test3.png", Files.FileType.Internal));
50 		pixD = new Pixmap(64, 128, Pixmap.Format.RGBA8888);
51 
52 		pixD.drawPixmap(pixS1, 0, 0, 0, 0, 76, 76);
53 		pixD.drawPixmap(pixS2, 0, 0, 0, 0, 76, 76);
54 
55 		logoSprite = new Sprite(new Texture(pixD));
56 		logoSprite.flip(false, true);
57 
58 		pixS1.dispose();
59 		pixS2.dispose();
60 		pixD.dispose();
61 	}
62 
63 	@Override
render()64 	public void render () {
65 
66 		Gdx.gl.glClearColor(0, 1, 0, 1);
67 		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
68 
69 		spriteBatch.begin();
70 		logoSprite.draw(spriteBatch);
71 		spriteBatch.end();
72 
73 	}
74 
needsGL20()75 	public boolean needsGL20 () {
76 		return false;
77 	}
78 }
79