Example usage for org.lwjgl.opengl GL11 glEnd

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

Introduction

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

Prototype

public static native void glEnd();

Source Link

Document

Ends the definition of vertex attributes of a sequence of primitives to be transferred to the GL.

Usage

From source file:io.github.minecraftgui.controllers.Render.java

License:Open Source License

public void drawCustomPolygon(int[] x, int[] y, Color color) {
    if (color.getAlpha() != 0 && x.length == y.length) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);/*from  ww w.ja va 2  s.c o m*/
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor4f((color.getRed() / 255.0f), (color.getGreen() / 255.0f), (color.getBlue() / 255.0f),
                (color.getAlpha() / 255.0f));

        GL11.glBegin(GL11.GL_LINES);
        {
            for (int i = 0; i < x.length; i++) {
                if (i < x.length - 1) {
                    GL11.glVertex2f(x[i], y[i]);
                    GL11.glVertex2f(x[i + 1], y[i + 1]);
                } else {
                    GL11.glVertex2f(x[i], y[i]);
                    GL11.glVertex2f(x[0], y[0]);
                }
            }
        }
        GL11.glEnd();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }
}

From source file:io.github.minecraftgui.controllers.Render.java

License:Open Source License

public void fillCustomPolygon(double x, double y, double[][] positions, Color color) {
    if (color.getAlpha() != 0) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);//from w w w .  j a v  a 2s.c  o m
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor4f((color.getRed() / 255.0f), (color.getGreen() / 255.0f), (color.getBlue() / 255.0f),
                (color.getAlpha() / 255.0f));

        GL11.glBegin(GL11.GL_POLYGON);
        {
            for (int i = 0; i < positions.length; i++)
                GL11.glVertex2d(x + positions[i][0], y + positions[i][1]);
        }
        GL11.glEnd();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }
}

From source file:io.github.minecraftgui.controllers.Render.java

License:Open Source License

public void drawLine(int x0, int y0, int x1, int y1, Color color) {
    if (color.getAlpha() != 0) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);//from   w  ww.j  av  a2  s.  co  m
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor4f((color.getRed() / 255.0f), (color.getGreen() / 255.0f), (color.getBlue() / 255.0f),
                (color.getAlpha() / 255.0f));

        GL11.glBegin(GL11.GL_LINES);
        {
            GL11.glVertex2f(x0, y0);

            GL11.glVertex2f(x1, y1);
        }
        GL11.glEnd();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }
}

From source file:io.github.minecraftgui.controllers.Render.java

License:Open Source License

public void fillRectangle(double x, double y, double width, double height, Color color) {
    if (color.getAlpha() != 0) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);//  w ww.j ava 2s . c  om
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor4f((color.getRed() / 255.0f), (color.getGreen() / 255.0f), (color.getBlue() / 255.0f),
                (color.getAlpha() / 255.0f));

        GL11.glBegin(GL11.GL_QUADS);
        {
            GL11.glVertex2d(x, y);

            GL11.glVertex2d(x, y + height);

            GL11.glVertex2d(x + width, y + height);

            GL11.glVertex2d(x + width, y);
        }
        GL11.glEnd();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }
}

From source file:io.github.minecraftgui.controllers.Render.java

License:Open Source License

public void drawRectangle(double x, double y, double width, double height, Color color) {
    if (color.getAlpha() != 0) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);//w  w w  . j  av a 2  s .  c o  m
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

        GL11.glColor4f((color.getRed() / 255.0f), (color.getGreen() / 255.0f), (color.getBlue() / 255.0f),
                (color.getAlpha() / 255.0f));

        GL11.glBegin(GL11.GL_LINES);
        {
            GL11.glVertex2d(x, y);
            GL11.glVertex2d(x, y + height);

            GL11.glVertex2d(x, y + height);
            GL11.glVertex2d(x + width, y + height);

            GL11.glVertex2d(x + width, y + height);
            GL11.glVertex2d(x + width, y);

            GL11.glVertex2d(x + width, y);
            GL11.glVertex2d(x, y);
        }
        GL11.glEnd();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }
}

From source file:io.github.minecraftgui.controllers.Render.java

License:Open Source License

public void drawTexture(Texture texture, double x, double y, double width, double height) {
    GL11.glEnable(GL11.GL_TEXTURE_2D);/*from   w  ww .ja  v  a 2  s .  c o m*/
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureID());
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glColor4f(1, 1, 1, 1);

    GL11.glBegin(GL11.GL_QUADS);
    {
        GL11.glTexCoord2f(0, 0);
        GL11.glVertex2d(x, y);

        GL11.glTexCoord2f(0, texture.getHeight());
        GL11.glVertex2d(x, y + height);

        GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
        GL11.glVertex2d(x + width, y + height);

        GL11.glTexCoord2f(texture.getWidth(), 0);
        GL11.glVertex2d(x + width, y);
    }
    GL11.glEnd();

    modInterface.bindMinecraftTextures();
}

From source file:io.root.gfx.glutils.GL.java

License:Apache License

public static void glEnd() {
    GL11.glEnd();
}

From source file:itdelatrisu.opsu.render.CurveRenderState.java

License:Open Source License

/**
 * Draw a curve to the screen that's tinted with `color`. The first time
 * this is called this caches the image result of the curve and on subsequent
 * runs it just draws the cached copy to the screen.
 * @param color tint of the curve//  www.  ja va2  s  . co  m
 * @param borderColor the curve border color
 * @param curve the points along the curve to be drawn
 */
public void draw(Color color, Color borderColor, Vec2f[] curve) {
    float alpha = color.a;

    // if this curve hasn't been drawn, draw it and cache the result
    if (fbo == null) {
        FrameBufferCache cache = FrameBufferCache.getInstance();
        Rendertarget mapping = cache.get(hitObject);
        if (mapping == null)
            mapping = cache.insert(hitObject);
        fbo = mapping;

        int oldFb = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT);
        int oldTex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);

        //glGetInteger requires a buffer of size 16, even though just 4
        //values are returned in this specific case
        IntBuffer oldViewport = BufferUtils.createIntBuffer(16);
        GL11.glGetInteger(GL11.GL_VIEWPORT, oldViewport);
        EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, fbo.getID());
        GL11.glViewport(0, 0, fbo.width, fbo.height);
        GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        Colors.WHITE_FADE.a = 1.0f;
        this.draw_curve(color, borderColor, curve);
        color.a = 1f;

        GL11.glBindTexture(GL11.GL_TEXTURE_2D, oldTex);
        EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, oldFb);
        GL11.glViewport(oldViewport.get(0), oldViewport.get(1), oldViewport.get(2), oldViewport.get(3));
        Colors.WHITE_FADE.a = alpha;
    }

    // draw a fullscreen quad with the texture that contains the curve
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_TEXTURE_1D);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.getTextureID());
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glColor4f(1.0f, 1.0f, 1.0f, alpha);
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex2i(fbo.width, 0);
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex2i(0, 0);
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex2i(0, fbo.height);
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex2i(fbo.width, fbo.height);
    GL11.glEnd();
}

From source file:itemrender.client.RenderTickHandler.java

License:MIT License

@SubscribeEvent
public void tick(TickEvent.RenderTickEvent event) {
    if (event.phase == TickEvent.Phase.END)
        if (keybindToRender != null && renderPreview) {
            int originalTexture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);

            // Bind framebuffer texture
            keybindToRender.fbo.bind();//  ww w  .ja va  2 s  . co m
            GL11.glBegin(GL11.GL_QUADS);
            GL11.glTexCoord2f(0, 0);
            GL11.glVertex2i(0, 0);
            GL11.glTexCoord2f(0, 1);
            GL11.glVertex2i(0, 128);
            GL11.glTexCoord2f(1, 1);
            GL11.glVertex2i(128, 128);
            GL11.glTexCoord2f(1, 0);
            GL11.glVertex2i(128, 0);
            GL11.glEnd();

            // Restore old texture
            GlStateManager.bindTexture(originalTexture);
        }
}

From source file:kinect.KinectModule.java

License:Open Source License

/**
 * Mthode de dessin de cercle OPenGL//from   w ww. j  a  v a  2s.  c om
 * @param userID l'ID de l'utilisateur
 * @param joint la position du joint  dessiner
 */
private void drawCircle(int userID, SkeletonJoint joint) {
    SkeletonJointPosition pos = joints.get(userID).get(joint);
    Vec2 position = new Vec2(pos.getPosition().getX(), Display.getHeight() - pos.getPosition().getY());
    float radius = 5;
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glVertex2f(position.x, position.y);
    float angle = 0.0f;
    for (angle = 0; angle < 2.0 * Math.PI + 0.0001;) {
        float xpos = (float) (position.x + Math.cos(angle) * radius);
        float ypos = (float) (position.y + Math.sin(angle) * radius);
        GL11.glVertex2f(xpos, ypos);
        angle += 2.0 * Math.PI / 20;
    }
    GL11.glEnd();

}