Example usage for com.badlogic.gdx.graphics GL10 GL_BLEND

List of usage examples for com.badlogic.gdx.graphics GL10 GL_BLEND

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics GL10 GL_BLEND.

Prototype

int GL_BLEND

To view the source code for com.badlogic.gdx.graphics GL10 GL_BLEND.

Click Source Link

Usage

From source file:com.mrljdx.llk.HelpScreen.java

License:Apache License

public void draw(float deltaTime) {
    GLCommon gl = Gdx.gl;/*  ww w . j  av  a  2  s  .c o m*/
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    guiCam.update();
    batcher.setProjectionMatrix(guiCam.combined);
    batcher.disableBlending();
    batcher.begin();
    batcher.draw(helpRegion, 0, 0, 480, 800);
    batcher.end();

    batcher.enableBlending();
    batcher.begin();
    switch (helppage) {
    case 1:
        batcher.draw(Assets.helpscreen[0], 40, 800 - 680, 400, 600);
        break;
    case 2:
        batcher.draw(Assets.helpscreen[1], 40, 800 - 680, 400, 600);
        break;
    case 3:
        batcher.draw(Assets.helpscreen[2], 40, 800 - 680, 400, 600);
        break;
    }
    batcher.end();
    gl.glDisable(GL10.GL_BLEND);
}

From source file:com.weimingtom.iteye.simplerpg.tiled.TileMapRenderer.java

License:Apache License

/** Renders specific layers between the given bounding box in map units.
 * @param x The x coordinate to start drawing
 * @param y the y coordinate to start drawing
 * @param width the width of the tiles to draw
 * @param height the width of the tiles to draw
 * @param layers The list of layers to draw, 0 being the lowest layer. You will get an IndexOutOfBoundsException if a layer
 *           number is too high. */
public void render(float x, float y, float width, float height, int[] layers) {
    lastRow = (int) ((mapHeightUnits - (y - height + overdrawY)) / (unitsPerBlockY));
    initialRow = (int) ((mapHeightUnits - (y - overdrawY)) / (unitsPerBlockY));
    initialRow = (initialRow > 0) ? initialRow : 0; // Clamp initial Row > 0

    lastCol = (int) ((x + width + overdrawX) / (unitsPerBlockX));
    initialCol = (int) ((x - overdrawX) / (unitsPerBlockX));
    initialCol = (initialCol > 0) ? initialCol : 0; // Clamp initial Col > 0

    Gdx.gl.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    cache.begin();//  w  w w. j a  va 2 s .c  om
    if (isSimpleTileAtlas) {
        // Without this special case the top left corner doesn't work properly on mutilayered maps
        Gdx.gl.glEnable(GL10.GL_BLEND);
        for (currentLayer = 0; currentLayer < layers.length; currentLayer++) {
            for (currentRow = initialRow; currentRow <= lastRow
                    && currentRow < getLayerHeightInBlocks(currentLayer); currentRow++) {
                for (currentCol = initialCol; currentCol <= lastCol
                        && currentCol < getLayerWidthInBlocks(currentLayer, currentRow); currentCol++) {
                    cache.draw(blendedCacheId[layers[currentLayer]][currentRow][currentCol]);
                }
            }
        }
    } else {
        for (currentLayer = 0; currentLayer < layers.length; currentLayer++) {
            for (currentRow = initialRow; currentRow <= lastRow
                    && currentRow < getLayerHeightInBlocks(currentLayer); currentRow++) {
                for (currentCol = initialCol; currentCol <= lastCol
                        && currentCol < getLayerWidthInBlocks(currentLayer, currentRow); currentCol++) {
                    Gdx.gl.glDisable(GL10.GL_BLEND);
                    cache.draw(normalCacheId[layers[currentLayer]][currentRow][currentCol]);
                    Gdx.gl.glEnable(GL10.GL_BLEND);
                    cache.draw(blendedCacheId[layers[currentLayer]][currentRow][currentCol]);
                }
            }
        }
    }
    cache.end();
    Gdx.gl.glDisable(GL10.GL_BLEND);
}

From source file:de.myreality.parallax.libgdx.PreprocessedTexture.java

License:Open Source License

@Override
public void load() {
    Pixmap map = new Pixmap(width, height, Format.RGBA8888);
    Gdx.gl.glEnable(GL10.GL_BLEND);
    Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    processor.process(map);// ww  w  .  j  a  v a 2s  .c  om
    rawTexture = new Texture(map);
    map.dispose();
    Gdx.gl.glDisable(GL10.GL_BLEND);
    texture = new GdxTexture(rawTexture, batch);
}

From source file:es.eucm.eadmockup.prototypes.camera.postprocessing.effects.CrtMonitor.java

License:Apache License

@Override
public void render(FrameBuffer src, FrameBuffer dest) {
    // the original scene
    Texture in = src.getColorBufferTexture();

    boolean blendingWasEnabled = PostProcessor.isStateEnabled(GL20.GL_BLEND);
    Gdx.gl.glDisable(GL10.GL_BLEND);

    Texture out = null;//w  ww  .  j  a  v a2s . c  om

    if (doblur) {

        pingPongBuffer.begin();
        {
            // crt pass
            crt.setInput(in).setOutput(pingPongBuffer.getSourceBuffer()).render();

            // blur pass
            blur.render(pingPongBuffer);
        }
        pingPongBuffer.end();

        out = pingPongBuffer.getResultTexture();
    } else {
        // crt pass
        crt.setInput(in).setOutput(buffer).render();

        out = buffer.getColorBufferTexture();
    }

    if (blending || blendingWasEnabled) {
        Gdx.gl.glEnable(GL20.GL_BLEND);
    }

    if (blending) {
        Gdx.gl.glBlendFunc(sfactor, dfactor);
    }

    restoreViewport(dest);

    // do combine pass
    combine.setOutput(dest).setInput(in, out).render();
}

From source file:ludowars.gui.widgets.ChatWidget.java

@Override
public void render(SpriteBatch batch, ShapeRenderer sr, float delta) {
    if (inputActive) {
        batch.end();/*from   ww w .  j  a va 2  s . c o  m*/
        Gdx.gl.glEnable(GL10.GL_BLEND);
        Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
        sr.begin(ShapeRenderer.ShapeType.Filled);

        // chat background
        sr.setColor(0f, 0f, 0f, 0.4f);
        sr.rect(bounds.x, bounds.y + 30, getWidth(), getHeight());

        // chat input
        sr.setColor(0f, 0f, 0f, 0.8f);
        sr.rect(bounds.x, bounds.y, getWidth(), 30);

        sr.end();
        Gdx.gl.glDisable(GL10.GL_BLEND);
        batch.begin();
    }

    // chat lines
    int i = 1;
    float offsetY = bounds.y + FONT_SIZE - 4;
    for (String line : lines) {
        font.draw(batch, line, bounds.x + PADDING, offsetY + 24 * i + PADDING);
        i++;
    }

    if (inputActive) {
        font.draw(batch, inputBuffer, bounds.x + PADDING, offsetY + 6);
    }
}

From source file:org.illarion.engine.backend.gdx.GdxGraphics.java

License:Open Source License

private void activateShapeRenderer() {
    if (shapeRenderer.getCurrentType() != null) {
        return;/*from w  ww.  ja  va 2 s.  c o  m*/
    }
    if (spriteBatchActive) {
        spriteBatch.end();
        spriteBatchActive = false;
    }

    gdxGraphics.getGLCommon().glEnable(GL10.GL_BLEND);
    switch (lastBlendingMode) {
    case AlphaBlend:
        gdxGraphics.getGLCommon().glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
        break;
    case Multiply:
        gdxGraphics.getGLCommon().glBlendFunc(GL10.GL_DST_COLOR, GL10.GL_ZERO);
        break;
    }
    shapeRenderer.begin(ShapeRenderer.ShapeType.FilledRectangle);
}

From source file:org.illarion.engine.backend.gdx.GdxGraphics.java

License:Open Source License

@Override
public void drawRectangle(final int x, final int y, final int width, final int height,
        @Nonnull final Color topLeftColor, @Nonnull final Color topRightColor,
        @Nonnull final Color bottomLeftColor, @Nonnull final Color bottomRightColor) {
    activateShapeRenderer();//from   w w  w .j av a 2  s  .  c om
    transferColor(topLeftColor, tempColor1);
    transferColor(topRightColor, tempColor2);
    transferColor(bottomLeftColor, tempColor3);
    transferColor(bottomRightColor, tempColor4);
    shapeRenderer.filledRect(x, y, width, height, tempColor3, tempColor4, tempColor2, tempColor1);
    shapeRenderer.end();
    gdxGraphics.getGLCommon().glDisable(GL10.GL_BLEND);
}

From source file:org.interreg.docexplore.reader.ReaderApp.java

License:Open Source License

public void create() {
    try {//from   www  .  ja v a  2s.co m
        Gdx.graphics.setVSync(true);
        this.renderThread = Thread.currentThread();
        renderThread.setName("Render Thread");
        this.client = new ReaderClient(this, startup);
        client.start("127.0.0.1", 8787);
        this.renderTasks = new LinkedList<Runnable>();
        //this.sound = new SoundManager();

        client.registerStreamType(StreamedImage.class, StreamedImage.allocator);
        client.registerStreamType(StreamedTexture.class, StreamedTexture.allocator);
        //client.registerStreamType(StreamedSound.class, StreamedSound.allocator);
        client.registerStreamType(StreamedXML.class, StreamedXML.allocator);

        Gdx.gl10.glEnable(GL10.GL_BLEND);
        Gdx.gl10.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
        Gdx.gl10.glEnable(GL10.GL_COLOR_MATERIAL);
        Gdx.gl10.glEnable(GL10.GL_DEPTH_TEST);
        Gdx.gl10.glEnable(GL10.GL_MULTISAMPLE);
        Gdx.gl10.glCullFace(GL10.GL_BACK);

        this.modules = new LinkedList<Module>();
        modules.add(shelf = new ShelfEngine(this));
        modules.add(bookEngine = new BookEngine(this, 1, .7f));
        modules.add(parchmentEngine = new ParchmentEngine(this));
        modules.add(gui = new GuiLayer(this));
        modules.add(input = new InputManager(this));
        modules.add(debugGfx = new DebugGraphics(this));
        input.addListenerFirst(gui);

        bookEngine.addRoiLayoutListener(new BookEngine.ROILayoutListener() {
            public void roiLayoutChanged(ROISpecification[] rois) {
                input.notifyLayoutChange(rois);
            }
        });

        List<PluginConfig> plugins = startup.filterPlugins(InputPlugin.class);
        for (PluginConfig config : plugins) {
            InputPlugin plugin = (InputPlugin) config.clazz.newInstance();
            plugin.setHost(input);
        }

        if (!startup.nativeCursor)
            try {
                Mouse.setNativeCursor(
                        new Cursor(1, 1, 0, 0, 1, BufferUtils.createIntBuffer(1).put(0, 0), null));
            } catch (Exception e) {
                e.printStackTrace();
            }

        emptyTex = new Texture(ImageUtils.read(Thread.currentThread().getContextClassLoader().getResource(
                BookSpecification.class.getPackage().getName().replace('.', '/') + "/emptyPageTex.png")),
                false);

        waitDialog = new Dialog(this);
        waitDialog.set(XMLResourceBundle.getBundledString("waitLabel"),
                XMLResourceBundle.getBundledString("imagesLabel"));
        gui.addWidget(waitDialog);

        this.logger = new ActivityLogger(new File(DocExploreTool.getHomeDir(), "activity.log"), 10000);
        logger.addEntry("Startup");

        this.mainTask = new ReaderMainTask(this);
        mainTask.start();
    } catch (Exception e) {
        ErrorHandler.defaultHandler.submit(e, false);
        System.exit(0);
    }
}

From source file:pl.kotcrab.jdialogue.editor.RectangularSelection.java

License:Open Source License

public void render(ShapeRenderer shapeRenderer) {
    if (rectToDraw != null) {
        Gdx.graphics.getGL20().glEnable(GL10.GL_BLEND);

        shapeRenderer.setColor(Color.RED);
        shapeRenderer.begin(ShapeType.Line);
        shapeRenderer.rect(rectToDraw.getX(), rectToDraw.getY(), rectToDraw.getWidth(), rectToDraw.getHeight());
        shapeRenderer.end();/*from  w  w w .  java2 s. co m*/

        shapeRenderer.setColor(0.7f, 0, 0, 0.3f);
        shapeRenderer.begin(ShapeType.Filled);
        shapeRenderer.rect(rectToDraw.getX(), rectToDraw.getY(), rectToDraw.getWidth(), rectToDraw.getHeight());
        shapeRenderer.end();

    }
}

From source file:sg.atom2d.game2d.graphics.anim.spine.skeleton.SkeletonRendererDebug.java

License:Open Source License

public void draw(Skeleton skeleton) {
    float skeletonX = skeleton.getX();
    float skeletonY = skeleton.getY();

    Gdx.gl.glEnable(GL10.GL_BLEND);
    ShapeRenderer renderer = this.renderer;
    renderer.begin(ShapeType.Line);

    Array<Bone> bones = skeleton.getBones();
    if (drawBones) {
        renderer.setColor(boneLineColor);
        for (int i = 0, n = bones.size; i < n; i++) {
            Bone bone = bones.get(i);//from   w  w w . ja  v  a2s. c  o m
            if (bone.parent == null)
                continue;
            float x = skeletonX + bone.data.length * bone.m00 + bone.worldX;
            float y = skeletonY + bone.data.length * bone.m10 + bone.worldY;
            renderer.line(skeletonX + bone.worldX, skeletonY + bone.worldY, x, y);
        }
    }

    if (drawRegionAttachments) {
        renderer.setColor(regionAttachmentLineColor);
        Array<Slot> slots = skeleton.getSlots();
        for (int i = 0, n = slots.size; i < n; i++) {
            Slot slot = slots.get(i);
            Attachment attachment = slot.attachment;
            if (attachment instanceof RegionAttachment) {
                RegionAttachment regionAttachment = (RegionAttachment) attachment;
                regionAttachment.updateWorldVertices(slot, false);
                float[] vertices = regionAttachment.getWorldVertices();
                renderer.line(vertices[X1], vertices[Y1], vertices[X2], vertices[Y2]);
                renderer.line(vertices[X2], vertices[Y2], vertices[X3], vertices[Y3]);
                renderer.line(vertices[X3], vertices[Y3], vertices[X4], vertices[Y4]);
                renderer.line(vertices[X4], vertices[Y4], vertices[X1], vertices[Y1]);
            }
        }
    }

    if (drawBoundingBoxes) {
        SkeletonBounds bounds = this.bounds;
        bounds.update(skeleton, true);
        renderer.setColor(aabbColor);
        renderer.rect(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight());
        renderer.setColor(boundingBoxColor);
        Array<FloatArray> polygons = bounds.getPolygons();
        for (int i = 0, n = polygons.size; i < n; i++) {
            FloatArray polygon = polygons.get(i);
            renderer.polygon(polygon.items, 0, polygon.size);
        }
    }

    renderer.end();
    renderer.begin(ShapeType.Filled);

    if (drawBones) {
        renderer.setColor(boneOriginColor);
        for (int i = 0, n = bones.size; i < n; i++) {
            Bone bone = bones.get(i);
            renderer.setColor(ColorRGBA.GREEN);
            renderer.circle(skeletonX + bone.worldX, skeletonY + bone.worldY, 3 * scale);
        }
    }

    renderer.end();
}