Example usage for org.lwjgl.opengl GL11 glBegin

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

Introduction

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

Prototype

public static native void glBegin(@NativeType("GLenum") int mode);

Source Link

Document

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

Usage

From source file:org.joge.core.draw.Graphics.java

License:Open Source License

public void drawLine(float x1, float y1, float x2, float y2) {
    setColor();/*w  w w .  ja  va2  s .  c om*/
    disableGl();
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2f(x1, y1);
    GL11.glVertex2f(x2, y2);
    GL11.glEnd();
    enableGl();
}

From source file:org.joge.core.draw.Graphics.java

License:Open Source License

public void drawRect(float x1, float y1, float width, float height) {
    setColor();/*from w w  w . j a va 2s. c o m*/
    disableGl();
    GL11.glBegin(GL11.GL_LINE_STRIP);
    GL11.glVertex2f(x1, y1);
    GL11.glVertex2f(x1 + width, y1);
    GL11.glVertex2f(x1 + width, y1 + height);
    GL11.glVertex2f(x1, y1 + height);
    GL11.glVertex2f(x1, y1);
    GL11.glEnd();
    enableGl();
}

From source file:org.joge.core.draw.Graphics.java

License:Open Source License

public void fillRect(float x, float y, float width, float height) {
    setColor();/* w  w w. j a  v a  2  s  . co m*/
    disableGl();
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(x, y);
    GL11.glVertex2f(x + width, y);
    GL11.glVertex2f(x + width, y + height);
    GL11.glVertex2f(x, y + height);
    GL11.glEnd();
    enableGl();
}

From source file:org.joge.core.draw.Graphics.java

License:Open Source License

public void fillMultiColoredRect(float x, float y, float width, float height, Color c1, Color c2, Color c3,
        Color c4) {/*  w  ww .j a  v  a 2s . c o  m*/
    setColor();
    disableGl();
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glColor4f(c1.r, c1.g, c1.b, c1.a);
    GL11.glVertex2f(x, y);
    GL11.glColor4f(c2.r, c2.g, c2.b, c2.a);
    GL11.glVertex2f(x + width, y);
    GL11.glColor4f(c3.r, c3.g, c3.b, c3.a);
    GL11.glVertex2f(x + width, y + height);
    GL11.glColor4f(c4.r, c4.g, c4.b, c4.a);
    GL11.glVertex2f(x, y + height);
    GL11.glEnd();
    enableGl();
}

From source file:org.joge.core.draw.Graphics.java

License:Open Source License

public void fillRect2(float x, float y, float x2, float y2) {
    setColor();/*from  w w w . ja  v a 2s  . co m*/
    disableGl();
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(x, y);
    GL11.glVertex2f(x2, y);
    GL11.glVertex2f(x2, y2);
    GL11.glVertex2f(x, y2);
    GL11.glEnd();
    enableGl();
}

From source file:org.joge.core.draw.Graphics.java

License:Open Source License

public void fillTriangle(float x, float y, float x1, float y1, float x2, float y2) {
    setColor();// w  w  w  . j  a  va  2  s  .c  o m
    disableGl();
    GL11.glBegin(GL11.GL_TRIANGLES);
    GL11.glVertex2f(x, y);
    GL11.glVertex2f(x1, y1);
    GL11.glVertex2f(x2, y2);
    GL11.glEnd();
    enableGl();
}

From source file:org.joge.core.draw.Graphics.java

License:Open Source License

public void drawOvall(float x_center, float y_center, float w, float h, int n) {
    double pheta, angle_increment;
    float x, y;//from  w ww . j  a v  a  2  s.co  m
    if (n <= 0) {
        n = 1;
    }
    angle_increment = 2 * PI / n;
    setColor();
    disableGl();
    GL11.glPushMatrix();
    GL11.glTranslatef(x_center, y_center, 0);
    GL11.glBegin(GL11.GL_LINE_LOOP);
    for (pheta = 0.0f; pheta < 2 * PI; pheta += angle_increment) {
        x = w / 2 * (float) Math.cos(pheta);
        y = h / 2 * (float) Math.sin(pheta);

        GL11.glVertex2f(x, y);
    }
    GL11.glEnd();
    GL11.glPopMatrix();
    enableGl();
}

From source file:org.joge.core.draw.Graphics.java

License:Open Source License

public void fillOvall(float x_center, float y_center, float w, float h, int n) {
    double pheta, angle_increment;
    float x, y;/*w w  w .  j  ava 2s  .com*/
    if (n <= 0) {
        n = 1;
    }
    angle_increment = 2 * PI / n;
    setColor();
    disableGl();
    GL11.glPushMatrix();
    GL11.glTranslatef(x_center, y_center, 0);
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    for (pheta = 0.0f; pheta < 2 * PI; pheta += angle_increment) {
        x = w / 2 * (float) Math.cos(pheta);
        y = h / 2 * (float) Math.sin(pheta);

        GL11.glVertex2f(x, y);
    }
    GL11.glEnd();
    GL11.glPopMatrix();
    enableGl();
}

From source file:org.joge.core.draw.Image.java

License:Open Source License

public void drawWithOutLoadIdentity(float xpos, float ypos) {
    GL11.glTranslatef(x + xpos, y + ypos, 0);
    GL11.glBegin(GL11.GL_QUADS);
    {//from ww  w. j a v a2 s .  c  o  m
        GL11.glTexCoord2f(tOffsetX, tOffsetY);
        GL11.glVertex2f(0, 0);
        GL11.glTexCoord2f(tOffsetX, tHeight + tOffsetY);
        GL11.glVertex2f(0, height);
        GL11.glTexCoord2f(tWidth + tOffsetX, tHeight + tOffsetY);
        GL11.glVertex2f(width, height);
        GL11.glTexCoord2f(tWidth + tOffsetX, tOffsetY);
        GL11.glVertex2f(width, 0);
    }
    GL11.glEnd();
}

From source file:org.jtrfp.mtmx.draw.ModelDrawer.java

License:Open Source License

public void draw() {
    IBinData binData = model.getBinData();
    IBinVertex[] vertexes = binData.getVertexes();
    IBinFace[] faces = binData.getFaces();

    GL11.glPushMatrix();//from   w  w  w.ja v a 2 s.  c  om

    if (translation != null) {
        GL11.glTranslatef(translation.getX(), translation.getY(), translation.getZ());
    }
    if (scale != null) {
        GL11.glScalef(scale.getX(), scale.getY(), scale.getZ());
    }
    if (rotationAxis != null) {
        GL11.glRotatef(rotationAngle, rotationAxis.getX(), rotationAxis.getY(), rotationAxis.getZ());
    }

    float n = 1.0f / 65536;
    for (int i = 0; i < faces.length; i++) {
        IBinFace face = faces[i];

        ITextureManager textureManager = engine.getResourceManager().getTextureManager();
        ITexture texture = textureManager.get(face.getTextureName());
        texture.bind();

        IBinVertex normal = face.getNormal();

        GL11.glBegin(renderMode);
        IBinTexCoord[] coords = face.getTexCoords();

        for (int j = coords.length - 1; j >= 0; j--) {
            IBinTexCoord coord = coords[j];
            IBinVertex vertex = vertexes[coord.getVertexIndex()];

            GL11.glNormal3f(-normal.getX() * n, normal.getY() * n, normal.getZ() * n);
            GL11.glTexCoord2f(coord.getU(), coord.getV());

            GL11.glVertex3f(-vertex.getX() * IDrawer.SCALE, vertex.getY() * IDrawer.SCALE,
                    vertex.getZ() * IDrawer.SCALE);
        }
        GL11.glEnd();
    }

    GL11.glPopMatrix();
}