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.Gdx; 20 import com.badlogic.gdx.graphics.GL20; 21 import com.badlogic.gdx.graphics.Texture; 22 import com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer; 23 import com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20; 24 import com.badlogic.gdx.math.Matrix4; 25 import com.badlogic.gdx.tests.utils.GdxTest; 26 27 public class ImmediateModeRendererTest extends GdxTest { 28 Matrix4 projMatrix = new Matrix4(); 29 ImmediateModeRenderer renderer; 30 Texture texture; 31 32 @Override dispose()33 public void dispose () { 34 texture.dispose(); 35 } 36 37 @Override render()38 public void render () { 39 Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 40 Gdx.gl.glEnable(GL20.GL_TEXTURE_2D); 41 texture.bind(); 42 renderer.begin(projMatrix, GL20.GL_TRIANGLES); 43 renderer.texCoord(0, 0); 44 renderer.color(1, 0, 0, 1); 45 renderer.vertex(-0.5f, -0.5f, 0); 46 renderer.texCoord(1, 0); 47 renderer.color(0, 1, 0, 1); 48 renderer.vertex(0.5f, -0.5f, 0); 49 renderer.texCoord(0.5f, 1); 50 renderer.color(0, 0, 1, 1); 51 renderer.vertex(0f, 0.5f, 0); 52 renderer.end(); 53 } 54 55 @Override create()56 public void create () { 57 renderer = new ImmediateModeRenderer20(false, true, 1); 58 texture = new Texture(Gdx.files.internal("data/badlogic.jpg")); 59 } 60 } 61