当前位置: 首页>>代码示例>>Java>>正文


Java SpriteBatch.setShader方法代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.SpriteBatch.setShader方法的典型用法代码示例。如果您正苦于以下问题:Java SpriteBatch.setShader方法的具体用法?Java SpriteBatch.setShader怎么用?Java SpriteBatch.setShader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.graphics.g2d.SpriteBatch的用法示例。


在下文中一共展示了SpriteBatch.setShader方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: render

import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
@Override
public void render(SpriteBatch spriteBatch) {
    spriteBatch.disableBlending();
    spriteBatch.setShader(null);
    spriteBatch.draw(menuBackgroundTexture, menuBottomLeftX, menuBottomLeftY);
    bitmapFont.setColor(Color.WHITE);
    bitmapFont.draw(spriteBatch,
            text,
            menuBottomLeftX + 16, menuBottomLeftY + menuHeight - 16);
}
 
开发者ID:gradualgames,项目名称:ggvm,代码行数:11,代码来源:PCMenu.java

示例2: render

import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
public void render(SpriteBatch batch, OrthographicCamera screenCamera) {
    batch.setShader(null);
    batch.setProjectionMatrix(screenCamera.combined);
    batch.begin();
    batch.draw(pixelBufferRegion, 0, 0, screenCamera.viewportWidth, screenCamera.viewportHeight);
    batch.end();
}
 
开发者ID:ZKasica,项目名称:Planet-Generator,代码行数:8,代码来源:PixelBuffer.java

示例3: draw

import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
@Override
public void draw(GameTime time, SpriteBatch batch) {
    // draw skybox
    this.skyBox.draw(time, game.getCamera(), batch);

    // set camera projection matrix
    batch.setProjectionMatrix(game.getCamera().getCombined());

    // draw entities
    this.ecs.draw(time, game.getCamera(), batch);

    // reset shader
    batch.setShader(null);
    batch.setProjectionMatrix(game.getCamera().getCombined());

    // draw abilities and so on
    this.ecs.drawUILayer(time, game.getCamera(), batch);

    batch.flush();

    // reset shader, so default shader is used
    batch.setShader(null);

    batch.end();

    this.shapeRenderer.setProjectionMatrix(game.getCamera().getCombined());
    this.shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
    this.shapeRenderer.setColor(Color.BLACK);

    // draw collision boxes
    if (debug) {
        this.collisionManager.drawCollisionBoxes(time, game.getCamera(), shapeRenderer, COLLISION_BOX_COLOR,
                IN_COLLISION_COLOR);
    }

    this.shapeRenderer.end();

    batch.begin();
}
 
开发者ID:opensourcegamedev,项目名称:SpaceChaos,代码行数:40,代码来源:GameScreen.java

示例4: render

import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
public void render(SpriteBatch spriteBatch) {
    generatePalettes();
    paletteTexture.bind(1);

    //Clear main framebuffer.
    Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
    Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    //Fill just the 256x240 viewport area with the current bg color
    shapeRenderer.setProjectionMatrix(camera.combined);
    shapeRenderer.begin();
    shapeRenderer.set(ShapeRenderer.ShapeType.Filled);
    shapeRenderer.setColor(bgColor);
    shapeRenderer.rect(0f, 0f, 256f, 240f);
    shapeRenderer.end();

    if (ggvm.isBackgroundVisible()) {

        sortSprites();
        //Draw foreground sprites to a separate framebuffer, where they can be
        //optionally clipped by background sprites.
        foregroundSpritesFrameBuffer.begin();
            Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
            Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
            Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
            spriteBatch.setShader(shaderProgram);
            spriteBatch.setProjectionMatrix(camera.combined);
            spriteBatch.begin();
                shaderProgram.setUniformi("u_paletteTexture", 1);
                spriteBatch.disableBlending();
                drawSprites(spriteBatch, foregroundSprites, isSprTransparentMask, foregroundSpritesCount);
            spriteBatch.end();
        foregroundSpritesFrameBuffer.end();

        viewPort.apply();
        mainFrameBuffer.begin();
            Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
            Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
            Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
            //Draw background sprites, nametable, then blend
            //the foreground sprites framebuffer to the main framebuffer.
            spriteBatch.begin();
                spriteBatch.enableBlending();
                drawSprites(spriteBatch, backgroundSprites, isBgTransparentMask, backgroundSpritesCount);
                drawNametable(ggvm, spriteBatch);
                spriteBatch.setShader(null);
                spriteBatch.draw(foregroundSpritesTextureRegion, 0, 0);
                rasterEffectManager.render(spriteBatch);
            spriteBatch.end();
        mainFrameBuffer.end();

        viewPort.apply();
        spriteBatch.begin();
            spriteBatch.draw(mainTextureRegion, 0, 0);
        spriteBatch.end();

        if (ggvm.isBackgroundClipping()) {
            shapeRenderer.setProjectionMatrix(camera.combined);
            shapeRenderer.begin();
            shapeRenderer.set(ShapeRenderer.ShapeType.Filled);
            shapeRenderer.setColor(bgColor);
            shapeRenderer.rect(0f, 0f, 8f, 240f);
            shapeRenderer.end();
        }
    }
    fpsLogger.log();
}
 
开发者ID:gradualgames,项目名称:ggvm,代码行数:69,代码来源:RenderManager.java

示例5: render

import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
@Override
public void render(SpriteBatch batch) {
    batch.setShader(planetShader);
    super.render(batch);
    batch.setShader(null);
}
 
开发者ID:ZKasica,项目名称:Planet-Generator,代码行数:7,代码来源:Planet.java


注:本文中的com.badlogic.gdx.graphics.g2d.SpriteBatch.setShader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。