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:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

void drawSprite(float x, float y, int flipmode, SpriteGL sprite) {

    flipmode = getflipMode(flipmode);/*w  w  w  . j  av  a 2 s  .  c  o m*/

    float x2 = x + sprite.width;
    float y2 = y + sprite.height;

    float u1 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u1 : sprite.u2;
    float v1 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v1 : sprite.v2;
    float u2 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u2 : sprite.u1;
    float v2 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v2 : sprite.v1;

    if (sprite.textureID != currentTexture) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID);
        currentTexture = sprite.textureID;
    }

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(u1, v1);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(u1, v2);
    GL11.glVertex2f(x, y2);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex2f(x2, y2);
    GL11.glTexCoord2f(u2, v1);
    GL11.glVertex2f(x2, y);

    GL11.glEnd();

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

private void drawSprite(float x, float y, float r, float g, float b, float a, int flipmode, SpriteGL sprite) {

    flipmode = getflipMode(flipmode);//  ww  w  .  ja  va2s. c  om

    float x2 = x + sprite.width;
    float y2 = y + sprite.height;

    float u1 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u1 : sprite.u2;
    float v1 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v1 : sprite.v2;
    float u2 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u2 : sprite.u1;
    float v2 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v2 : sprite.v1;

    if (sprite.textureID != currentTexture) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID);
        currentTexture = sprite.textureID;
    }

    GL11.glColor4f(r, g, b, a);

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(u1, v1);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(u1, v2);
    GL11.glVertex2f(x, y2);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex2f(x2, y2);
    GL11.glTexCoord2f(u2, v1);
    GL11.glVertex2f(x2, y);

    GL11.glEnd();

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

private void drawTransformedSprite(float x, float y, float angle, float scaleX, float scaleY, int flipmode,
        SpriteGL sprite) {//from  w  w w  .  j  a v a 2s.c o  m

    flipmode = getflipMode(flipmode);

    float s_half_x = sprite.width / 2.0f;
    float s_half_y = sprite.height / 2.0f;

    float x1 = -s_half_x;
    float y1 = -s_half_y;

    float u1 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u1 : sprite.u2;
    float v1 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v1 : sprite.v2;
    float u2 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u2 : sprite.u1;
    float v2 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v2 : sprite.v1;

    if (sprite.textureID != currentTexture) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID);
        currentTexture = sprite.textureID;
    }

    GL11.glPushMatrix();

    GL11.glTranslatef(x, y, 0.0f);
    GL11.glScalef(scaleX, scaleY, 1.0f);
    GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f);

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(u1, v1);
    GL11.glVertex2f(x1, y1);
    GL11.glTexCoord2f(u1, v2);
    GL11.glVertex2f(x1, s_half_y);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex2f(s_half_x, s_half_y);
    GL11.glTexCoord2f(u2, v1);
    GL11.glVertex2f(s_half_x, y1);

    GL11.glEnd();

    GL11.glPopMatrix();

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

private void drawTransformedSprite(float x, float y, float angle, float scaleX, float scaleY, float r, float g,
        float b, float a, int flipmode, SpriteGL sprite) {

    flipmode = getflipMode(flipmode);/*from   ww w  .j a v  a2  s .co  m*/

    float s_half_x = sprite.width / 2.0f;
    float s_half_y = sprite.height / 2.0f;

    float x1 = -s_half_x;
    float y1 = -s_half_y;

    float u1 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u1 : sprite.u2;
    float v1 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v1 : sprite.v2;
    float u2 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u2 : sprite.u1;
    float v2 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v2 : sprite.v1;

    if (sprite.textureID != currentTexture) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID);
        currentTexture = sprite.textureID;
    }

    GL11.glColor4f(r, g, b, a);

    GL11.glPushMatrix();

    GL11.glTranslatef(x, y, 0.0f);
    GL11.glScalef(scaleX, scaleY, 1.0f);
    GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f);

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(u1, v1);
    GL11.glVertex2f(x1, y1);
    GL11.glTexCoord2f(u1, v2);
    GL11.glVertex2f(x1, s_half_y);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex2f(s_half_x, s_half_y);
    GL11.glTexCoord2f(u2, v1);
    GL11.glVertex2f(s_half_x, y1);

    GL11.glEnd();

    GL11.glPopMatrix();

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

public void drawSpriteOnLine(int x1, int y1, int x2, int y2, int width, int type) {

    SpriteGL sprite = glowImages.getSprite(type % glowImages.getNumImages());

    // Only change active texture when there is a need
    // Speeds up the rendering by batching textures

    if (sprite.textureID != currentTexture) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID);
        currentTexture = sprite.textureID;
    }/*from  w w  w . ja  v  a  2 s . co m*/

    float u1 = sprite.u1;
    float v1 = sprite.v1;
    float u2 = sprite.u2;
    float v2 = sprite.v2;
    float uh = (u1 + u2) / 2.0f;

    float nx, ny;
    nx = -(y2 - y1);
    ny = (x2 - x1);

    float leng;
    leng = (float) Math.sqrt(nx * nx + ny * ny);
    nx = nx / leng;
    ny = ny / leng;

    nx *= width / 2.0;
    ny *= width / 2.0;

    float lx1, ly1, lx2, ly2, lx3, ly3, lx4, ly4;

    lx1 = x2 + nx;
    ly1 = y2 + ny;
    lx2 = x2 - nx;
    ly2 = y2 - ny;
    lx3 = x1 - nx;
    ly3 = y1 - ny;
    lx4 = x1 + nx;
    ly4 = y1 + ny;

    // MAIN
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(uh, v1);
    GL11.glVertex3f(lx1, ly1, 0.0f);
    GL11.glTexCoord2f(uh, v2);
    GL11.glVertex3f(lx2, ly2, 0.0f);
    GL11.glTexCoord2f(uh, v2);
    GL11.glVertex3f(lx3, ly3, 0.0f);
    GL11.glTexCoord2f(uh, v1);
    GL11.glVertex3f(lx4, ly4, 0.0f);
    GL11.glEnd();

    //RIGHT
    float lx5, ly5, lx6, ly6, vx, vy;
    vx = (x2 - x1);
    vy = (y2 - y1);
    leng = (float) Math.sqrt(vx * vx + vy * vy);
    vx = vx / leng;
    vy = vy / leng;
    vx *= width / 2.0;
    vy *= width / 2.0;

    lx5 = lx1 + vx;
    ly5 = ly1 + vy;
    lx6 = lx2 + vx;
    ly6 = ly2 + vy;

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(uh, v1);
    GL11.glVertex3f(lx1, ly1, 0.0f);
    GL11.glTexCoord2f(u2, v1);
    GL11.glVertex3f(lx5, ly5, 0.0f);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex3f(lx6, ly6, 0.0f);
    GL11.glTexCoord2f(uh, v2);
    GL11.glVertex3f(lx2, ly2, 0.0f);
    GL11.glEnd();

    // LEFT
    lx5 = lx4 - vx;
    ly5 = ly4 - vy;
    lx6 = lx3 - vx;
    ly6 = ly3 - vy;

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(uh, v1);
    GL11.glVertex3f(lx4, ly4, 0.0f);
    GL11.glTexCoord2f(uh, v2);
    GL11.glVertex3f(lx3, ly3, 0.0f);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex3f(lx6, ly6, 0.0f);
    GL11.glTexCoord2f(u2, v1);
    GL11.glVertex3f(lx5, ly5, 0.0f);
    GL11.glEnd();

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

public void drawSpriteOnLine(int x1, int y1, int x2, int y2, int width, int type, float r, float g, float b,
        float a) {

    SpriteGL sprite = glowImages.getSprite(type % glowImages.getNumImages());

    // Only change active texture when there is a need
    // Speeds up the rendering by batching textures

    if (sprite.textureID != currentTexture) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID);
        currentTexture = sprite.textureID;
    }/*from w  ww  . j av a 2  s.  c o m*/

    GL11.glColor4f(r, g, b, a);

    float u1 = sprite.u1;
    float v1 = sprite.v1;
    float u2 = sprite.u2;
    float v2 = sprite.v2;
    float uh = (u1 + u2) / 2.0f;

    float nx, ny;
    nx = -(y2 - y1);
    ny = (x2 - x1);

    float leng;
    leng = (float) Math.sqrt(nx * nx + ny * ny);
    nx = nx / leng;
    ny = ny / leng;

    nx *= width / 2.0;
    ny *= width / 2.0;

    float lx1, ly1, lx2, ly2, lx3, ly3, lx4, ly4;

    lx1 = x2 + nx;
    ly1 = y2 + ny;
    lx2 = x2 - nx;
    ly2 = y2 - ny;
    lx3 = x1 - nx;
    ly3 = y1 - ny;
    lx4 = x1 + nx;
    ly4 = y1 + ny;

    // MAIN
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(uh, v1);
    GL11.glVertex3f(lx1, ly1, 0.0f);
    GL11.glTexCoord2f(uh, v2);
    GL11.glVertex3f(lx2, ly2, 0.0f);
    GL11.glTexCoord2f(uh, v2);
    GL11.glVertex3f(lx3, ly3, 0.0f);
    GL11.glTexCoord2f(uh, v1);
    GL11.glVertex3f(lx4, ly4, 0.0f);
    GL11.glEnd();

    //RIGHT
    float lx5, ly5, lx6, ly6, vx, vy;
    vx = (x2 - x1);
    vy = (y2 - y1);
    leng = (float) Math.sqrt(vx * vx + vy * vy);
    vx = vx / leng;
    vy = vy / leng;
    vx *= width / 2.0;
    vy *= width / 2.0;

    lx5 = lx1 + vx;
    ly5 = ly1 + vy;
    lx6 = lx2 + vx;
    ly6 = ly2 + vy;

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(uh, v1);
    GL11.glVertex3f(lx1, ly1, 0.0f);
    GL11.glTexCoord2f(u2, v1);
    GL11.glVertex3f(lx5, ly5, 0.0f);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex3f(lx6, ly6, 0.0f);
    GL11.glTexCoord2f(uh, v2);
    GL11.glVertex3f(lx2, ly2, 0.0f);
    GL11.glEnd();

    // LEFT
    lx5 = lx4 - vx;
    ly5 = ly4 - vy;
    lx6 = lx3 - vx;
    ly6 = ly3 - vy;

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(uh, v1);
    GL11.glVertex3f(lx4, ly4, 0.0f);
    GL11.glTexCoord2f(uh, v2);
    GL11.glVertex3f(lx3, ly3, 0.0f);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex3f(lx6, ly6, 0.0f);
    GL11.glTexCoord2f(u2, v1);
    GL11.glVertex3f(lx5, ly5, 0.0f);
    GL11.glEnd();

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

private void drawScrolledSprite(float x, float y, float scaleX, float scaleY, float u, float v, int flipmode,
        SpriteGL sprite) {/* w w w  . j  a v  a  2  s.c om*/

    flipmode = getflipMode(flipmode);

    float x2 = x + sprite.width;
    float y2 = y + sprite.height;

    float u1 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u1 : sprite.u2;
    float v1 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v1 : sprite.v2;
    float u2 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u2 : sprite.u1;
    float v2 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v2 : sprite.v1;

    if (sprite.textureID != currentTexture) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID);
        currentTexture = sprite.textureID;
    }

    GL11.glPushMatrix();

    GL11.glScalef(scaleX, scaleY, 1.0f);

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(u1 + u, v1 + v);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(u1 + u, v2 + v);
    GL11.glVertex2f(x, y2);
    GL11.glTexCoord2f(u2 + u, v2 + v);
    GL11.glVertex2f(x2, y2);
    GL11.glTexCoord2f(u2 + u, v1 + v);
    GL11.glVertex2f(x2, y);

    GL11.glEnd();

    GL11.glPopMatrix();

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

private void drawScrolledSprite(float x, float y, float scaleX, float scaleY, float u, float v, float r,
        float g, float b, float a, int flipmode, SpriteGL sprite) {

    flipmode = getflipMode(flipmode);/*from ww  w .  j  ava 2 s. com*/

    float x2 = x + sprite.width;
    float y2 = y + sprite.height;

    float u1 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u1 : sprite.u2;
    float v1 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v1 : sprite.v2;
    float u2 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u2 : sprite.u1;
    float v2 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v2 : sprite.v1;

    if (sprite.textureID != currentTexture) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID);
        currentTexture = sprite.textureID;
    }

    GL11.glColor4f(r, g, b, a);

    GL11.glPushMatrix();

    GL11.glScalef(scaleX, scaleY, 1.0f);

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(u1 + u, v1 + v);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(u1 + u, v2 + v);
    GL11.glVertex2f(x, y2);
    GL11.glTexCoord2f(u2 + u, v2 + v);
    GL11.glVertex2f(x2, y2);
    GL11.glTexCoord2f(u2 + u, v1 + v);
    GL11.glVertex2f(x2, y);

    GL11.glEnd();

    GL11.glPopMatrix();

}

From source file:net.quetzi.bluepower.part.gate.GateBase.java

License:Open Source License

@Override
public final void renderDynamic(Vector3 loc, int pass, float frame) {

    GL11.glPushMatrix();//from  w  w w. java 2 s .c om
    {
        super.rotateAndTranslateDynamic(loc, pass, frame);

        /* Top */
        renderTop(frame);

        Minecraft.getMinecraft().renderEngine
                .bindTexture(new ResourceLocation(Refs.MODID + ":textures/blocks/gates/bottom.png"));
        GL11.glBegin(GL11.GL_QUADS);
        /* Bottom */
        GL11.glNormal3d(0, -1, 0);
        RenderHelper.addVertexWithTexture(0, 0, 0, 0, 0);
        RenderHelper.addVertexWithTexture(1, 0, 0, 1, 0);
        RenderHelper.addVertexWithTexture(1, 0, 1, 1, 1);
        RenderHelper.addVertexWithTexture(0, 0, 1, 0, 1);
        GL11.glEnd();
        Minecraft.getMinecraft().renderEngine
                .bindTexture(new ResourceLocation(Refs.MODID + ":textures/blocks/gates/side.png"));
        GL11.glBegin(GL11.GL_QUADS);
        /* East */
        GL11.glNormal3d(1, 0, 0);
        RenderHelper.addVertexWithTexture(1, 0, 0, 0, 0);
        RenderHelper.addVertexWithTexture(1, 1D / 8D, 0, 1, 0);
        RenderHelper.addVertexWithTexture(1, 1D / 8D, 1, 1, 1);
        RenderHelper.addVertexWithTexture(1, 0, 1, 0, 1);
        /* West */
        GL11.glNormal3d(-1, 0, 0);
        RenderHelper.addVertexWithTexture(0, 0, 0, 0, 0);
        RenderHelper.addVertexWithTexture(0, 0, 1, 0, 1);
        RenderHelper.addVertexWithTexture(0, 1D / 8D, 1, 1, 1);
        RenderHelper.addVertexWithTexture(0, 1D / 8D, 0, 1, 0);
        /* North */
        GL11.glNormal3d(0, 0, -1);
        RenderHelper.addVertexWithTexture(0, 0, 0, 0, 0);
        RenderHelper.addVertexWithTexture(0, 1D / 8D, 0, 1, 0);
        RenderHelper.addVertexWithTexture(1, 1D / 8D, 0, 1, 1);
        RenderHelper.addVertexWithTexture(1, 0, 0, 0, 1);
        /* South */
        GL11.glNormal3d(0, 0, 1);
        RenderHelper.addVertexWithTexture(0, 0, 1, 0, 0);
        RenderHelper.addVertexWithTexture(1, 0, 1, 0, 1);
        RenderHelper.addVertexWithTexture(1, 1D / 8D, 1, 1, 1);
        RenderHelper.addVertexWithTexture(0, 1D / 8D, 1, 1, 0);
        GL11.glEnd();
    }
    GL11.glPopMatrix();
}

From source file:net.quetzi.bluepower.part.gate.GateBase.java

License:Open Source License

public void renderTopTexture(String texture) {

    Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(texture));
    GL11.glBegin(GL11.GL_QUADS);/*from w  w  w .j  a  v  a 2 s.  c  o  m*/
    GL11.glNormal3d(0, 1, 0);
    RenderHelper.addVertexWithTexture(0, 1D / 8D, 0, 0, 0);
    RenderHelper.addVertexWithTexture(0, 1D / 8D, 1, 0, 1);
    RenderHelper.addVertexWithTexture(1, 1D / 8D, 1, 1, 1);
    RenderHelper.addVertexWithTexture(1, 1D / 8D, 0, 1, 0);
    GL11.glEnd();
}