Example usage for org.lwjgl.opengl GL11 glBlendFunc

List of usage examples for org.lwjgl.opengl GL11 glBlendFunc

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glBlendFunc.

Prototype

public static void glBlendFunc(@NativeType("GLenum") int sfactor, @NativeType("GLenum") int dfactor) 

Source Link

Document

Specifies the weighting factors used by the blend equation, for both RGB and alpha functions and for all draw buffers.

Usage

From source file:com.yogpc.qp.client.RenderRefinery.java

License:Open Source License

private void render(final TileRefinery tile, final double x, final double y, final double z) {
    float anim = 0;
    int angle = 0;
    ModelRenderer theMagnet = this.magnet[0];
    if (tile != null) {
        anim = tile.getAnimationStage();
        angle = 0;//from   w w w  . j a v a  2  s.c o  m
        switch (tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord)) {
        case 2:
            angle = 90;
            break;
        case 3:
            angle = 270;
            break;
        case 4:
            angle = 180;
            break;
        case 5:
            angle = 0;
            break;
        }

        if (tile.animationSpeed <= 1)
            theMagnet = this.magnet[0];
        else if (tile.animationSpeed <= 2.5)
            theMagnet = this.magnet[1];
        else if (tile.animationSpeed <= 4.5)
            theMagnet = this.magnet[2];
        else
            theMagnet = this.magnet[3];
    }

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
    GL11.glScalef(0.99F, 0.99F, 0.99F);

    GL11.glRotatef(angle, 0, 1, 0);

    bindTexture(TEXTURE);

    GL11.glPushMatrix();
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    GL11.glTranslatef(-4F * pixel, 0, -4F * pixel);
    this.tank.render(pixel);
    GL11.glTranslatef(4F * pixel, 0, 4F * pixel);

    GL11.glTranslatef(-4F * pixel, 0, 4F * pixel);
    this.tank.render(pixel);
    GL11.glTranslatef(4F * pixel, 0, -4F * pixel);

    GL11.glTranslatef(4F * pixel, 0, 0);
    this.tank.render(pixel);
    GL11.glTranslatef(-4F * pixel, 0, 0);
    GL11.glPopMatrix();

    float trans1, trans2;

    if (anim <= 100) {
        trans1 = 12F * pixel * anim / 100F;
        trans2 = 0;
    } else if (anim <= 200) {
        trans1 = 12F * pixel - 12F * pixel * (anim - 100F) / 100F;
        trans2 = 12F * pixel * (anim - 100F) / 100F;
    } else {
        trans1 = 12F * pixel * (anim - 200F) / 100F;
        trans2 = 12F * pixel - 12F * pixel * (anim - 200F) / 100F;
    }

    renderMagnet(trans1, theMagnet, 0);
    renderMagnet(trans2, theMagnet, 12 * pixel);

    if (tile != null) {
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
        GL11.glScalef(0.5F, 1, 0.5F);
        renderFluid(tile.src[0], 0, 0, 0, tile.buf);
        renderFluid(tile.src[1], 0, 0, 1, tile.buf);
        renderFluid(tile.res, 1, 0, 0.5F, tile.buf);
        GL11.glPopAttrib();
    }
    GL11.glPopAttrib();
    GL11.glPopMatrix();
}

From source file:cpw.mods.fml.client.config.GuiUtils.java

License:Open Source License

/**
 * Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders
 * and filler. It is assumed that the desired texture ResourceLocation object has been bound using
 * Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
 * //from ww w  . ja  v a  2  s.  c o m
 * @param x x axis offset
 * @param y y axis offset
 * @param u bound resource location image x offset
 * @param v bound resource location image y offset
 * @param width the desired box width
 * @param height the desired box height
 * @param textureWidth the width of the box texture in the resource location image
 * @param textureHeight the height of the box texture in the resource location image
 * @param topBorder the size of the box's top border
 * @param bottomBorder the size of the box's bottom border
 * @param leftBorder the size of the box's left border
 * @param rightBorder the size of the box's right border
 * @param zLevel the zLevel to draw at
 */
public static void drawContinuousTexturedBox(int x, int y, int u, int v, int width, int height,
        int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder,
        float zLevel) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glEnable(GL11.GL_BLEND);
    OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    int fillerWidth = textureWidth - leftBorder - rightBorder;
    int fillerHeight = textureHeight - topBorder - bottomBorder;
    int canvasWidth = width - leftBorder - rightBorder;
    int canvasHeight = height - topBorder - bottomBorder;
    int xPasses = canvasWidth / fillerWidth;
    int remainderWidth = canvasWidth % fillerWidth;
    int yPasses = canvasHeight / fillerHeight;
    int remainderHeight = canvasHeight % fillerHeight;

    // Draw Border
    // Top Left
    drawTexturedModalRect(x, y, u, v, leftBorder, topBorder, zLevel);
    // Top Right
    drawTexturedModalRect(x + leftBorder + canvasWidth, y, u + leftBorder + fillerWidth, v, rightBorder,
            topBorder, zLevel);
    // Bottom Left
    drawTexturedModalRect(x, y + topBorder + canvasHeight, u, v + topBorder + fillerHeight, leftBorder,
            bottomBorder, zLevel);
    // Bottom Right
    drawTexturedModalRect(x + leftBorder + canvasWidth, y + topBorder + canvasHeight,
            u + leftBorder + fillerWidth, v + topBorder + fillerHeight, rightBorder, bottomBorder, zLevel);

    for (int i = 0; i < xPasses + (remainderWidth > 0 ? 1 : 0); i++) {
        // Top Border
        drawTexturedModalRect(x + leftBorder + (i * fillerWidth), y, u + leftBorder, v,
                (i == xPasses ? remainderWidth : fillerWidth), topBorder, zLevel);
        // Bottom Border
        drawTexturedModalRect(x + leftBorder + (i * fillerWidth), y + topBorder + canvasHeight, u + leftBorder,
                v + topBorder + fillerHeight, (i == xPasses ? remainderWidth : fillerWidth), bottomBorder,
                zLevel);

        // Throw in some filler for good measure
        for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++)
            drawTexturedModalRect(x + leftBorder + (i * fillerWidth), y + topBorder + (j * fillerHeight),
                    u + leftBorder, v + topBorder, (i == xPasses ? remainderWidth : fillerWidth),
                    (j == yPasses ? remainderHeight : fillerHeight), zLevel);
    }

    // Side Borders
    for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++) {
        // Left Border
        drawTexturedModalRect(x, y + topBorder + (j * fillerHeight), u, v + topBorder, leftBorder,
                (j == yPasses ? remainderHeight : fillerHeight), zLevel);
        // Right Border
        drawTexturedModalRect(x + leftBorder + canvasWidth, y + topBorder + (j * fillerHeight),
                u + leftBorder + fillerWidth, v + topBorder, rightBorder,
                (j == yPasses ? remainderHeight : fillerHeight), zLevel);
    }
}

From source file:cpw.mods.fml.client.GuiScrollingList.java

License:Open Source License

public void drawScreen(int mouseX, int mouseY, float p_22243_3_) {
    this.mouseX = mouseX;
    this.mouseY = mouseY;
    this.drawBackground();
    int listLength = this.getSize();
    int scrollBarXStart = this.left + this.listWidth - 6;
    int scrollBarXEnd = scrollBarXStart + 6;
    int boxLeft = this.left;
    int boxRight = scrollBarXStart - 1;
    int var10;
    int var11;
    int var13;
    int var19;

    if (Mouse.isButtonDown(0)) {
        if (this.initialMouseClickY == -1.0F) {
            boolean var7 = true;

            if (mouseY >= this.top && mouseY <= this.bottom) {
                var10 = mouseY - this.top - this.field_27261_r + (int) this.scrollDistance - 4;
                var11 = var10 / this.slotHeight;

                if (mouseX >= boxLeft && mouseX <= boxRight && var11 >= 0 && var10 >= 0 && var11 < listLength) {
                    boolean var12 = var11 == this.selectedIndex
                            && System.currentTimeMillis() - this.lastClickTime < 250L;
                    this.elementClicked(var11, var12);
                    this.selectedIndex = var11;
                    this.lastClickTime = System.currentTimeMillis();
                } else if (mouseX >= boxLeft && mouseX <= boxRight && var10 < 0) {
                    this.func_27255_a(mouseX - boxLeft, mouseY - this.top + (int) this.scrollDistance - 4);
                    var7 = false;
                }/*w  ww  .j a v a  2 s.  c om*/

                if (mouseX >= scrollBarXStart && mouseX <= scrollBarXEnd) {
                    this.scrollFactor = -1.0F;
                    var19 = this.getContentHeight() - (this.bottom - this.top - 4);

                    if (var19 < 1) {
                        var19 = 1;
                    }

                    var13 = (int) ((float) ((this.bottom - this.top) * (this.bottom - this.top))
                            / (float) this.getContentHeight());

                    if (var13 < 32) {
                        var13 = 32;
                    }

                    if (var13 > this.bottom - this.top - 8) {
                        var13 = this.bottom - this.top - 8;
                    }

                    this.scrollFactor /= (float) (this.bottom - this.top - var13) / (float) var19;
                } else {
                    this.scrollFactor = 1.0F;
                }

                if (var7) {
                    this.initialMouseClickY = (float) mouseY;
                } else {
                    this.initialMouseClickY = -2.0F;
                }
            } else {
                this.initialMouseClickY = -2.0F;
            }
        } else if (this.initialMouseClickY >= 0.0F) {
            this.scrollDistance -= ((float) mouseY - this.initialMouseClickY) * this.scrollFactor;
            this.initialMouseClickY = (float) mouseY;
        }
    } else {
        while (Mouse.next()) {
            int var16 = Mouse.getEventDWheel();

            if (var16 != 0) {
                if (var16 > 0) {
                    var16 = -1;
                } else if (var16 < 0) {
                    var16 = 1;
                }

                this.scrollDistance += (float) (var16 * this.slotHeight / 2);
            }
        }

        this.initialMouseClickY = -1.0F;
    }

    this.applyScrollLimits();
    Tessellator var18 = Tessellator.instance;
    if (this.client.theWorld != null) {
        this.drawGradientRect(this.left, this.top, this.right, this.bottom, -1072689136, -804253680);
    } else {
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_FOG);
        this.client.renderEngine.bindTexture(Gui.optionsBackground);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        float var17 = 32.0F;
        var18.startDrawingQuads();
        var18.setColorOpaque_I(2105376);
        var18.addVertexWithUV((double) this.left, (double) this.bottom, 0.0D,
                (double) ((float) this.left / var17),
                (double) ((float) (this.bottom + (int) this.scrollDistance) / var17));
        var18.addVertexWithUV((double) this.right, (double) this.bottom, 0.0D,
                (double) ((float) this.right / var17),
                (double) ((float) (this.bottom + (int) this.scrollDistance) / var17));
        var18.addVertexWithUV((double) this.right, (double) this.top, 0.0D,
                (double) ((float) this.right / var17),
                (double) ((float) (this.top + (int) this.scrollDistance) / var17));
        var18.addVertexWithUV((double) this.left, (double) this.top, 0.0D, (double) ((float) this.left / var17),
                (double) ((float) (this.top + (int) this.scrollDistance) / var17));
        var18.draw();
    }
    //        boxRight = this.listWidth / 2 - 92 - 16;
    var10 = this.top + 4 - (int) this.scrollDistance;

    if (this.field_27262_q) {
        this.func_27260_a(boxRight, var10, var18);
    }

    int var14;

    for (var11 = 0; var11 < listLength; ++var11) {
        var19 = var10 + var11 * this.slotHeight + this.field_27261_r;
        var13 = this.slotHeight - 4;

        if (var19 <= this.bottom && var19 + var13 >= this.top) {
            if (this.field_25123_p && this.isSelected(var11)) {
                var14 = boxLeft;
                int var15 = boxRight;
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                GL11.glDisable(GL11.GL_TEXTURE_2D);
                var18.startDrawingQuads();
                var18.setColorOpaque_I(8421504);
                var18.addVertexWithUV((double) var14, (double) (var19 + var13 + 2), 0.0D, 0.0D, 1.0D);
                var18.addVertexWithUV((double) var15, (double) (var19 + var13 + 2), 0.0D, 1.0D, 1.0D);
                var18.addVertexWithUV((double) var15, (double) (var19 - 2), 0.0D, 1.0D, 0.0D);
                var18.addVertexWithUV((double) var14, (double) (var19 - 2), 0.0D, 0.0D, 0.0D);
                var18.setColorOpaque_I(0);
                var18.addVertexWithUV((double) (var14 + 1), (double) (var19 + var13 + 1), 0.0D, 0.0D, 1.0D);
                var18.addVertexWithUV((double) (var15 - 1), (double) (var19 + var13 + 1), 0.0D, 1.0D, 1.0D);
                var18.addVertexWithUV((double) (var15 - 1), (double) (var19 - 1), 0.0D, 1.0D, 0.0D);
                var18.addVertexWithUV((double) (var14 + 1), (double) (var19 - 1), 0.0D, 0.0D, 0.0D);
                var18.draw();
                GL11.glEnable(GL11.GL_TEXTURE_2D);
            }

            this.drawSlot(var11, boxRight, var19, var13, var18);
        }
    }

    GL11.glDisable(GL11.GL_DEPTH_TEST);
    byte var20 = 4;
    if (this.client.theWorld == null) {
        this.overlayBackground(0, this.top, 255, 255);
        this.overlayBackground(this.bottom, this.listHeight, 255, 255);
    }
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    var18.startDrawingQuads();
    var18.setColorRGBA_I(0, 0);
    var18.addVertexWithUV((double) this.left, (double) (this.top + var20), 0.0D, 0.0D, 1.0D);
    var18.addVertexWithUV((double) this.right, (double) (this.top + var20), 0.0D, 1.0D, 1.0D);
    var18.setColorRGBA_I(0, 255);
    var18.addVertexWithUV((double) this.right, (double) this.top, 0.0D, 1.0D, 0.0D);
    var18.addVertexWithUV((double) this.left, (double) this.top, 0.0D, 0.0D, 0.0D);
    var18.draw();
    var18.startDrawingQuads();
    var18.setColorRGBA_I(0, 255);
    var18.addVertexWithUV((double) this.left, (double) this.bottom, 0.0D, 0.0D, 1.0D);
    var18.addVertexWithUV((double) this.right, (double) this.bottom, 0.0D, 1.0D, 1.0D);
    var18.setColorRGBA_I(0, 0);
    var18.addVertexWithUV((double) this.right, (double) (this.bottom - var20), 0.0D, 1.0D, 0.0D);
    var18.addVertexWithUV((double) this.left, (double) (this.bottom - var20), 0.0D, 0.0D, 0.0D);
    var18.draw();
    var19 = this.getContentHeight() - (this.bottom - this.top - 4);

    if (var19 > 0) {
        var13 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();

        if (var13 < 32) {
            var13 = 32;
        }

        if (var13 > this.bottom - this.top - 8) {
            var13 = this.bottom - this.top - 8;
        }

        var14 = (int) this.scrollDistance * (this.bottom - this.top - var13) / var19 + this.top;

        if (var14 < this.top) {
            var14 = this.top;
        }

        var18.startDrawingQuads();
        var18.setColorRGBA_I(0, 255);
        var18.addVertexWithUV((double) scrollBarXStart, (double) this.bottom, 0.0D, 0.0D, 1.0D);
        var18.addVertexWithUV((double) scrollBarXEnd, (double) this.bottom, 0.0D, 1.0D, 1.0D);
        var18.addVertexWithUV((double) scrollBarXEnd, (double) this.top, 0.0D, 1.0D, 0.0D);
        var18.addVertexWithUV((double) scrollBarXStart, (double) this.top, 0.0D, 0.0D, 0.0D);
        var18.draw();
        var18.startDrawingQuads();
        var18.setColorRGBA_I(8421504, 255);
        var18.addVertexWithUV((double) scrollBarXStart, (double) (var14 + var13), 0.0D, 0.0D, 1.0D);
        var18.addVertexWithUV((double) scrollBarXEnd, (double) (var14 + var13), 0.0D, 1.0D, 1.0D);
        var18.addVertexWithUV((double) scrollBarXEnd, (double) var14, 0.0D, 1.0D, 0.0D);
        var18.addVertexWithUV((double) scrollBarXStart, (double) var14, 0.0D, 0.0D, 0.0D);
        var18.draw();
        var18.startDrawingQuads();
        var18.setColorRGBA_I(12632256, 255);
        var18.addVertexWithUV((double) scrollBarXStart, (double) (var14 + var13 - 1), 0.0D, 0.0D, 1.0D);
        var18.addVertexWithUV((double) (scrollBarXEnd - 1), (double) (var14 + var13 - 1), 0.0D, 1.0D, 1.0D);
        var18.addVertexWithUV((double) (scrollBarXEnd - 1), (double) var14, 0.0D, 1.0D, 0.0D);
        var18.addVertexWithUV((double) scrollBarXStart, (double) var14, 0.0D, 0.0D, 0.0D);
        var18.draw();
    }

    this.func_27257_b(mouseX, mouseY);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:cuchaz.jfxgl.glass.JFXGLWindow.java

License:Open Source License

@CalledByMainThread
@InAppGLContext//from   w  w  w . jav a2s .com
public void renderFramebuf() {
    if (buf != null) {

        glstate.backup();

        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glViewport(0, 0, width, height);

        // composite our framebuffer onto the main framebuffer
        buf.render();

        glstate.restore();
    }
}

From source file:cuchaz.jfxgl.JFXGL.java

License:Open Source License

@SuppressWarnings("deprecation")
public static JFXGLContext start(long hwnd, String[] args, Application app) {

    // make sure JavaFX is using the OpenGL prism backend
    System.setProperty("prism.order", "es2");

    // DEBUG: turn on prism logging so we can see pipeline create/init errors
    //System.setProperty("prism.verbose", "true");

    // init the app OpenGL contexts
    JFXGLContexts.app = JFXGLContext.wrapExisting(hwnd);

    // init the JavaFX OpenGL context
    // NOTE: JavaFX requires a backward-compatible context, it uses some old v2 stuff
    GLFW.glfwDefaultWindowHints();//w  w w. jav  a 2  s. c  o m
    JFXGLContexts.javafx = JFXGLContext.makeNewSharedWith(JFXGLContexts.app.hwnd);
    JFXGLContexts.javafx.makeCurrent();

    // init OpenGL state expected by JavaFX rendering
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);

    // install our various pieces into JavaFX
    JFXGLFactory.install();
    JFXGLPlatformFactory.install();
    JFXGLToolkit.install();

    try {

        // start the platform
        CountDownLatch startupLatch = new CountDownLatch(1);
        PlatformImpl.startup(() -> {
            startupLatch.countDown();
        });
        startupLatch.await();

        toolkit = (JFXGLToolkit) Toolkit.getToolkit();

    } catch (InterruptedException ex) {
        throw new Error(ex);
    }

    // go back to main context
    JFXGLContexts.app.makeCurrent();

    // translate the String[] args into JavaFX Parameters
    ParametersImpl.registerParameters(app, new ParametersImpl(args));
    PlatformImpl.setApplicationName(app.getClass());

    // call app init (on this thread)
    // it's basically a second constructor
    try {
        app.init();
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }

    // call app start (on the FX thread)
    runOnEventsThreadAndWait(() -> {

        // make the sage
        Stage primaryStage = new Stage();
        primaryStage.impl_setPrimary(true);

        // start() the app
        app.start(primaryStage);

        // the window is actually already showing, but JavaFX doesn't know that yet
        // so make JavaFX catch up by "showing" the window
        primaryStage.show();
    });

    // the app started. track it so we can stop it later
    JFXGL.app = app;

    // listen for input events from GLFW
    // NOTE: always keep a strong reference to GLFW callbacks, or they get garbage collected
    ourCallbacks = new GLFWCallbacks();
    existingCallbacks = new GLFWCallbacks();

    // TODO: allow main app to disable input forwarding
    // NOTE: callbacks are called on the main thread, so forward to events thread when necessary
    ourCallbacks.key = (long hwndAgain, int key, int scanCode, int action, int mods) -> {
        if (existingCallbacks.key != null) {
            existingCallbacks.key.invoke(hwnd, key, scanCode, action, mods);
        }
        if (JFXGLWindow.mainWindow != null) {
            runOnEventsThread(() -> {
                JFXGLView view = (JFXGLView) JFXGLWindow.mainWindow.getView();
                if (view != null) {
                    view.handleGLFWKey(key, scanCode, action, mods);
                }
            });
        }
    };
    existingCallbacks.key = GLFW.glfwSetKeyCallback(hwnd, ourCallbacks.key);

    ourCallbacks.keyChar = (long hwndAgain, int codepoint, int mods) -> {
        if (existingCallbacks.keyChar != null) {
            existingCallbacks.keyChar.invoke(hwnd, codepoint, mods);
        }
        if (JFXGLWindow.mainWindow != null) {
            runOnEventsThread(() -> {
                JFXGLView view = (JFXGLView) JFXGLWindow.mainWindow.getView();
                if (view != null) {
                    view.handleGLFWKeyChar(codepoint, mods);
                }
            });
        }
    };
    existingCallbacks.keyChar = GLFW.glfwSetCharModsCallback(hwnd, ourCallbacks.keyChar);

    ourCallbacks.cursorPos = (long hwndAgain, double xpos, double ypos) -> {
        if (existingCallbacks.cursorPos != null) {
            existingCallbacks.cursorPos.invoke(hwnd, xpos, ypos);
        }
        if (JFXGLWindow.mainWindow != null) {
            runOnEventsThread(() -> {
                JFXGLView view = (JFXGLView) JFXGLWindow.mainWindow.getView();
                if (view != null) {
                    view.handleGLFWCursorPos(xpos, ypos);
                }
            });
        }
    };
    existingCallbacks.cursorPos = GLFW.glfwSetCursorPosCallback(hwnd, ourCallbacks.cursorPos);

    ourCallbacks.mouseButton = (long hwndAgain, int button, int action, int mods) -> {
        if (existingCallbacks.mouseButton != null) {
            existingCallbacks.mouseButton.invoke(hwnd, button, action, mods);
        }
        if (JFXGLWindow.mainWindow != null) {
            runOnEventsThread(() -> {
                JFXGLView view = (JFXGLView) JFXGLWindow.mainWindow.getView();
                if (view != null) {
                    view.handleGLFWMouseButton(button, action, mods);
                }
            });
        }
    };
    existingCallbacks.mouseButton = GLFW.glfwSetMouseButtonCallback(hwnd, ourCallbacks.mouseButton);

    ourCallbacks.scroll = (long hwndAgain, double dx, double dy) -> {
        if (existingCallbacks.scroll != null) {
            existingCallbacks.scroll.invoke(hwnd, dx, dy);
        }
        if (JFXGLWindow.mainWindow != null) {
            runOnEventsThread(() -> {
                JFXGLView view = (JFXGLView) JFXGLWindow.mainWindow.getView();
                if (view != null) {
                    view.handleGLFWScroll(dx, dy);
                }
            });
        }
    };
    existingCallbacks.scroll = GLFW.glfwSetScrollCallback(hwnd, ourCallbacks.scroll);

    ourCallbacks.windowFocus = (long hwndAgain, boolean isFocused) -> {
        if (existingCallbacks.windowFocus != null) {
            existingCallbacks.windowFocus.invoke(hwnd, isFocused);
        }
        if (JFXGLWindow.mainWindow != null) {
            runOnEventsThread(() -> {
                JFXGLWindow.mainWindow.handleGLFWFocus(isFocused);
            });
        }
    };
    existingCallbacks.windowFocus = GLFW.glfwSetWindowFocusCallback(hwnd, ourCallbacks.windowFocus);

    return JFXGLContexts.app;
}

From source file:cuchaz.jfxgl.prism.JFXGLContext.java

License:Open Source License

@Override
public void blendFunc(int sFactor, int dFactor) {
    GL11.glBlendFunc(translateScaleFactor(sFactor), translateScaleFactor(dFactor));
}

From source file:dan200.billund.client.BillundProxyClient.java

public static void renderBrick(ItemStack brick, boolean scale, boolean center) {
    Tessellator tessellator = Tessellator.instance;
    int brightness = 15;

    int colour = ItemBrick.getColour(brick);
    int width = ItemBrick.getWidth(brick);
    int height = ItemBrick.getHeight(brick);
    int depth = ItemBrick.getDepth(brick);

    // Setup      
    GL11.glPushMatrix();/*  w  ww.ja  va 2  s  . c o  m*/

    if (scale) {
        float scaleValue = ((float) TileEntityBillund.LAYERS_PER_BLOCK)
                / Math.max(2.0f, (float) Math.max(width, depth) - 0.5f);
        GL11.glScalef(scaleValue, scaleValue, scaleValue);
    }
    if (center) {
        GL11.glTranslatef(-0.5f * ((float) width / (float) TileEntityBillund.ROWS_PER_BLOCK),
                -0.5f * ((float) height / (float) TileEntityBillund.LAYERS_PER_BLOCK),
                -0.5f * ((float) depth / (float) TileEntityBillund.ROWS_PER_BLOCK));
    }

    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

    Minecraft mc = Minecraft.getMinecraft();
    mc.getTextureManager().bindTexture(mc.getTextureManager().getResourceLocation(0)); // bind the terrain texture

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0f, -1.0f, 0.0f);
    renderBrick(null, brightness, colour, 0, 0, 0, width, height, depth);
    tessellator.draw();

    // Teardown
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}

From source file:dan200.qcraft.client.QCraftProxyClient.java

License:Open Source License

private void renderOverlay(ResourceLocation texture, float width, float height) {
    Minecraft mc = Minecraft.getMinecraft();
    GL11.glDisable(GL11.GL_DEPTH_TEST);/*  w w  w.j  a v  a 2s  . co  m*/
    GL11.glDepthMask(false);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    mc.renderEngine.bindTexture(texture);
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(0.0D, (double) height, -90.0D, 0.0D, 1.0D);
    tessellator.addVertexWithUV((double) width, (double) height, -90.0D, 1.0D, 1.0D);
    tessellator.addVertexWithUV((double) width, 0.0D, -90.0D, 1.0D, 0.0D);
    tessellator.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);
    tessellator.draw();
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}

From source file:de.kitsunealex.projectx.client.render.RenderTruncatedIcosahedron.java

License:Open Source License

public void render(double size, Colour colourPent, Colour colourHex, EnumHedronTexture type) {
    GlStateManager.pushMatrix();/*from  www.ja v a 2  s.c o  m*/
    GlStateManager.pushAttrib();
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_LIGHT0);
    GL11.glDisable(GL11.GL_LIGHT1);
    Minecraft.getMinecraft().getTextureManager().bindTexture(type.getTexture());
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glScaled(size * 0.1D, size * 0.1D, size * 0.1D);
    colourPent.glColour();
    GL11.glCallList(LIST_INDEX);
    colourHex.glColour();
    GL11.glCallList(LIST_INDEX + 1);
    GL11.glScaled(1D / (size * 0.1D), 1D / (size * 0.1D), 1D / (size * 0.1D));
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_LIGHT1);
    GL11.glEnable(GL11.GL_LIGHT0);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glColor4f(1F, 1F, 1F, 1F);
    GlStateManager.popAttrib();
    GlStateManager.popMatrix();
}

From source file:de.mineformers.gui.api.component.decorative.UITooltip.java

License:LGPL

@Override
public void draw(int mouseX, int mouseY) {
    int startX = mouseX + 5;
    int startY = mouseY + 5;
    width = mc.fontRenderer.getStringWidth(TextHelper.getLongestString(lines.toArray(new String[lines.size()])))
            + 10;//w w  w .  ja va2 s.c  o  m
    height = lines.size() * (2 + mc.fontRenderer.FONT_HEIGHT) + 8;
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    this.drawRectangle(startX, startY, 1, 50, 5, 5);
    this.drawRectangle(startX, startY + height - 5, 1, 62, 5, 5);
    this.drawRectangle(startX + width - 5, startY, 13, 50, 5, 5);
    this.drawRectangle(startX + width - 5, startY + height - 5, 13, 62, 5, 5);

    this.drawRectangleStretched(startX + 5, startY, 7, 50, width - 10, 5, 5, 5);
    this.drawRectangleStretched(startX + width - 5, startY + 5, 13, 56, 5, height - 10, 5, 5);
    this.drawRectangleStretched(startX + 5, startY + height - 5, 7, 62, width - 9, 5, 5, 5);
    this.drawRectangleStretched(startX, startY + 5, 1, 56, 5, height - 10, 5, 5);

    this.drawRectangleStretched(startX + 5, startY + 5, 7, 56, width - 10, height - 10, 5, 5);

    GL11.glDisable(GL11.GL_BLEND);

    startX += 6;
    startY += 6;
    for (int i = 0; i < lines.size(); i++) {
        String line = lines.get(i);
        this.drawString(line, startX, startY + i * (2 + mc.fontRenderer.FONT_HEIGHT), 0xEEEEEE, false);
    }
}