Java Code Examples for com.badlogic.gdx.Gdx#gl()

The following examples show how to use com.badlogic.gdx.Gdx#gl() . 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: HelpScreen2.java    From ashley-superjumper with Apache License 2.0 6 votes vote down vote up
public void draw () {
	GL20 gl = Gdx.gl;
	gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
	guiCam.update();

	game.batcher.setProjectionMatrix(guiCam.combined);
	game.batcher.disableBlending();
	game.batcher.begin();
	game.batcher.draw(helpRegion, 0, 0, 320, 480);
	game.batcher.end();

	game.batcher.enableBlending();
	game.batcher.begin();
	game.batcher.draw(Assets.arrow, 320, 0, -64, 64);
	game.batcher.end();

	gl.glDisable(GL20.GL_BLEND);
}
 
Example 2
Source File: MainMenuScreen.java    From ashley-superjumper with Apache License 2.0 6 votes vote down vote up
public void draw () {
	GL20 gl = Gdx.gl;
	gl.glClearColor(1, 0, 0, 1);
	gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
	guiCam.update();
	game.batcher.setProjectionMatrix(guiCam.combined);

	game.batcher.disableBlending();
	game.batcher.begin();
	game.batcher.draw(Assets.backgroundRegion, 0, 0, 320, 480);
	game.batcher.end();

	game.batcher.enableBlending();
	game.batcher.begin();
	game.batcher.draw(Assets.logo, 160 - 274 / 2, 480 - 10 - 142, 274, 142);
	game.batcher.draw(Assets.mainMenu, 10, 200 - 110 / 2, 300, 110);
	game.batcher.draw(Settings.soundEnabled ? Assets.soundOn : Assets.soundOff, 0, 0, 64, 64);
	game.batcher.end();	
}
 
Example 3
Source File: HighscoresScreen.java    From ashley-superjumper with Apache License 2.0 6 votes vote down vote up
public void draw () {
	GL20 gl = Gdx.gl;
	gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
	guiCam.update();

	game.batcher.setProjectionMatrix(guiCam.combined);
	game.batcher.disableBlending();
	game.batcher.begin();
	game.batcher.draw(Assets.backgroundRegion, 0, 0, 320, 480);
	game.batcher.end();

	game.batcher.enableBlending();
	game.batcher.begin();
	game.batcher.draw(Assets.highScoresRegion, 10, 360 - 16, 300, 33);

	float y = 230;
	for (int i = 4; i >= 0; i--) {
		Assets.font.draw(game.batcher, highScores[i], xOffset, y);
		y += Assets.font.getLineHeight();
	}

	game.batcher.draw(Assets.arrow, 0, 0, 64, 64);
	game.batcher.end();
}
 
Example 4
Source File: HelpScreen3.java    From ashley-superjumper with Apache License 2.0 6 votes vote down vote up
public void draw () {
	GL20 gl = Gdx.gl;
	gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
	guiCam.update();

	game.batcher.setProjectionMatrix(guiCam.combined);
	game.batcher.disableBlending();
	game.batcher.begin();
	game.batcher.draw(helpRegion, 0, 0, 320, 480);
	game.batcher.end();

	game.batcher.enableBlending();
	game.batcher.begin();
	game.batcher.draw(Assets.arrow, 320, 0, -64, 64);
	game.batcher.end();

	gl.glDisable(GL20.GL_BLEND);
}
 
Example 5
Source File: HelpScreen.java    From ashley-superjumper with Apache License 2.0 6 votes vote down vote up
public void draw () {
	GL20 gl = Gdx.gl;
	gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
	gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	
	guiCam.update();
	game.batcher.setProjectionMatrix(guiCam.combined);
	game.batcher.disableBlending();
	game.batcher.begin();
	game.batcher.draw(helpRegion, 0, 0);
	game.batcher.end();

	game.batcher.enableBlending();
	game.batcher.begin();
	game.batcher.draw(Assets.arrow, 320, 0, -64, 64);
	game.batcher.end();
}
 
Example 6
Source File: HelpScreen5.java    From ashley-superjumper with Apache License 2.0 6 votes vote down vote up
public void draw () {
	GL20 gl = Gdx.gl;
	gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
	guiCam.update();

	game.batcher.setProjectionMatrix(guiCam.combined);
	game.batcher.disableBlending();
	game.batcher.begin();
	game.batcher.draw(helpRegion, 0, 0, 320, 480);
	game.batcher.end();

	game.batcher.enableBlending();
	game.batcher.begin();
	game.batcher.draw(Assets.arrow, 320, 0, -64, 64);
	game.batcher.end();

	gl.glDisable(GL20.GL_BLEND);
}
 
Example 7
Source File: HelpScreen4.java    From ashley-superjumper with Apache License 2.0 6 votes vote down vote up
public void draw () {
	GL20 gl = Gdx.gl;
	gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
	guiCam.update();

	game.batcher.setProjectionMatrix(guiCam.combined);
	game.batcher.disableBlending();
	game.batcher.begin();
	game.batcher.draw(helpRegion, 0, 0, 320, 480);
	game.batcher.end();

	game.batcher.enableBlending();
	game.batcher.begin();
	game.batcher.draw(Assets.arrow, 320, 0, -64, 64);
	game.batcher.end();

	gl.glDisable(GL20.GL_BLEND);
}
 
Example 8
Source File: ControllerMappingsTest.java    From gdx-controllerutils with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void init() {
    // Note that we don't need to implement any of the listener's methods
    Gdx.app = new HeadlessApplication(new ApplicationListener() {
        @Override
        public void create() {
        }

        @Override
        public void resize(int width, int height) {
        }

        @Override
        public void render() {
        }

        @Override
        public void pause() {
        }

        @Override
        public void resume() {
        }

        @Override
        public void dispose() {
        }
    });

    // Use Mockito to mock the OpenGL methods since we are running headlessly
    Gdx.gl20 = Mockito.mock(GL20.class);
    Gdx.gl = Gdx.gl20;
}
 
Example 9
Source File: ImageHelperTest.java    From gdx-fireapp with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    PowerMockito.mockStatic(Pixmap.class);
    PowerMockito.mockStatic(Pixmap.Format.class);
    PowerMockito.mockStatic(Gdx2DPixmap.class);
    PowerMockito.mockStatic(TextureRegion.class);
    Gdx.gl = Mockito.mock(GL20.class);
    Gdx2DPixmap gdx2DPixmap = PowerMockito.mock(Gdx2DPixmap.class);
    pixmap = PowerMockito.mock(Pixmap.class);
    Mockito.when(pixmap.getWidth()).thenReturn(10);
    Mockito.when(pixmap.getHeight()).thenReturn(10);
    Mockito.when(pixmap.getFormat()).thenReturn(Pixmap.Format.RGB888);
    PowerMockito.whenNew(Gdx2DPixmap.class).withAnyArguments().thenReturn(gdx2DPixmap);
    PowerMockito.whenNew(Pixmap.class).withAnyArguments().thenReturn(pixmap);
}
 
Example 10
Source File: Renderer.java    From VuforiaLibGDX with MIT License 5 votes vote down vote up
public void render(Display display, float delta) {
    GL20 gl = Gdx.gl;

    gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

    TrackableResult[] results = null;

    if (vuforiaRenderer != null && vuforiaRenderer.isActive()) {
        //render camera background and find targets
        results = vuforiaRenderer.onDrawFrame();
    }

    gl.glEnable(GL20.GL_DEPTH_TEST);
    gl.glEnable(GL20.GL_CULL_FACE);


    double FOV = 1.0;
    if (vuforiaRenderer != null) {
        FOV = Math.toDegrees(vuforiaRenderer.getFieldOfViewRadians());
    }
    setProjectionAndCamera(display, results, (float) FOV);
    modelBatch.begin(camera);

    gl.glDepthMask(true);
    modelBatch.render(display.modelInstance, lights);

    modelBatch.end();

    gl.glDisable(GL20.GL_CULL_FACE);
    gl.glDisable(GL20.GL_DEPTH_TEST);
    gl.glDisable(GL20.GL_BLEND);
}
 
Example 11
Source File: GdxTestRunner.java    From gdx-testing with Apache License 2.0 5 votes vote down vote up
public GdxTestRunner(Class<?> klass) throws InitializationError {
	super(klass);
	HeadlessApplicationConfiguration conf = new HeadlessApplicationConfiguration();

	new HeadlessApplication(this, conf);
	Gdx.gl = mock(GL20.class);
}
 
Example 12
Source File: SuperJumper.java    From ashley-superjumper with Apache License 2.0 5 votes vote down vote up
@Override
public void render() {
	GL20 gl = Gdx.gl;
	gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
	gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
	
	super.render();
}
 
Example 13
Source File: Renderer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
public void render (Simulation simulation, float delta) {
	// We explicitly require GL10, otherwise we could've used the GLCommon
	// interface via Gdx.gl
	GL20 gl = Gdx.gl;
	gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
	renderBackground();
	gl.glEnable(GL20.GL_DEPTH_TEST);
	gl.glEnable(GL20.GL_CULL_FACE);
	setProjectionAndCamera(simulation.ship);

	modelBatch.begin(camera);
	modelBatch.render(simulation.explosions);
	if (!simulation.ship.isExploding) modelBatch.render(simulation.ship, lights);
	modelBatch.render(simulation.invaders, lights);
	modelBatch.render(simulation.blocks);
	modelBatch.render(simulation.shots);
	modelBatch.end();

	gl.glDisable(GL20.GL_CULL_FACE);
	gl.glDisable(GL20.GL_DEPTH_TEST);

	spriteBatch.setProjectionMatrix(viewMatrix);
	spriteBatch.begin();
	if (simulation.ship.lives != lastLives || simulation.score != lastScore || simulation.wave != lastWave) {
		status = "lives: " + simulation.ship.lives + " wave: " + simulation.wave + " score: " + simulation.score;
		lastLives = simulation.ship.lives;
		lastScore = simulation.score;
		lastWave = simulation.wave;
	}
	spriteBatch.enableBlending();
	font.draw(spriteBatch, status, 0, 320);
	spriteBatch.end();

	invaderAngle += delta * 90;
	if (invaderAngle > 360) invaderAngle -= 360;
}
 
Example 14
Source File: IOSMini2DxGraphics.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
public void setGL20 (GL20 gl20) {
	this.gl20 = gl20;
	if (gl30 == null) {
		Gdx.gl = gl20;
		Gdx.gl20 = gl20;
	}
}
 
Example 15
Source File: IOSMini2DxGraphics.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
public void setGL30 (GL30 gl30) {
	this.gl30 = gl30;
	if (gl30 != null) {
		this.gl20 = gl30;

		Gdx.gl = gl20;
		Gdx.gl20 = gl20;
		Gdx.gl30 = gl30;
	}
}
 
Example 16
Source File: Lwjgl3Mini2DxWindow.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
void makeCurrent() {
	Gdx.graphics = graphics;
	Gdx.gl30 = graphics.getGL30();
	Gdx.gl20 = Gdx.gl30 != null ? Gdx.gl30 : graphics.getGL20();
	Gdx.gl = Gdx.gl30 != null ? Gdx.gl30 : Gdx.gl20;
	Gdx.input = input;

	GLFW.glfwMakeContextCurrent(windowHandle);
}