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.fenggui.binding.render.lwjgl.LWJGLOpenGL.java

License:Open Source License

public void startPoints() {
    GL11.glBegin(GL11.GL_POINTS);
}

From source file:org.free.jake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_Char(int x, int y, int num) {

    num &= 255;// ww  w .j  a  va2  s.  c  o m

    if ((num & 127) == 32) {
        return; // space
    }
    if (y <= -8) {
        return; // totally off screen
    }
    int row = num >> 4;
    int col = num & 15;

    float frow = row * 0.0625f;
    float fcol = col * 0.0625f;
    float size = 0.0625f;

    GL_Bind(draw_chars.texnum);

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(fcol, frow);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(fcol + size, frow);
    GL11.glVertex2f(x + 8, y);
    GL11.glTexCoord2f(fcol + size, frow + size);
    GL11.glVertex2f(x + 8, y + 8);
    GL11.glTexCoord2f(fcol, frow + size);
    GL11.glVertex2f(x, y + 8);
    GL11.glEnd();
}

From source file:org.free.jake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_StretchPic(int x, int y, int w, int h, String pic) {

    image_t image;/*from ww  w.ja v  a2s. c o  m*/

    image = Draw_FindPic(pic);
    if (image == null) {
        VID.Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n');
        return;
    }

    if (scrap_dirty) {
        Scrap_Upload();
    }

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }

    GL_Bind(image.texnum);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(image.sl, image.tl);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(image.sh, image.tl);
    GL11.glVertex2f(x + w, y);
    GL11.glTexCoord2f(image.sh, image.th);
    GL11.glVertex2f(x + w, y + h);
    GL11.glTexCoord2f(image.sl, image.th);
    GL11.glVertex2f(x, y + h);
    GL11.glEnd();

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    }
}

From source file:org.free.jake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_Pic(int x, int y, String pic) {
    image_t image;/*from w w w . j  av  a 2s .c  o m*/

    image = Draw_FindPic(pic);
    if (image == null) {
        VID.Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n');
        return;
    }
    if (scrap_dirty) {
        Scrap_Upload();
    }

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }

    GL_Bind(image.texnum);

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(image.sl, image.tl);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(image.sh, image.tl);
    GL11.glVertex2f(x + image.width, y);
    GL11.glTexCoord2f(image.sh, image.th);
    GL11.glVertex2f(x + image.width, y + image.height);
    GL11.glTexCoord2f(image.sl, image.th);
    GL11.glVertex2f(x, y + image.height);
    GL11.glEnd();

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    }
}

From source file:org.free.jake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_TileClear(int x, int y, int w, int h, String pic) {
    image_t image;/*  w w  w .java  2s.  c o  m*/

    image = Draw_FindPic(pic);
    if (image == null) {
        VID.Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n');
        return;
    }

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }

    GL_Bind(image.texnum);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(x / 64.0f, y / 64.0f);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f((x + w) / 64.0f, y / 64.0f);
    GL11.glVertex2f(x + w, y);
    GL11.glTexCoord2f((x + w) / 64.0f, (y + h) / 64.0f);
    GL11.glVertex2f(x + w, y + h);
    GL11.glTexCoord2f(x / 64.0f, (y + h) / 64.0f);
    GL11.glVertex2f(x, y + h);
    GL11.glEnd();

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    }
}

From source file:org.free.jake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_Fill(int x, int y, int w, int h, int colorIndex) {

    if (colorIndex > 255) {
        Com.Error(Defines.ERR_FATAL, "Draw_Fill: bad color");
    }/*  w w w .j av  a2s  .  co  m*/

    GL11.glDisable(GL11.GL_TEXTURE_2D);

    int color = d_8to24table[colorIndex];

    GL11.glColor3ub((byte) ((color) & 0xff), // r
            (byte) ((color >> 8) & 0xff), // g
            (byte) ((color >> 16) & 0xff) // b
    );

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glVertex2f(x, y);
    GL11.glVertex2f(x + w, y);
    GL11.glVertex2f(x + w, y + h);
    GL11.glVertex2f(x, y + h);

    GL11.glEnd();
    GL11.glColor3f(1, 1, 1);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:org.free.jake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte[] data) {
    int i, j, trows;
    int sourceIndex;
    int frac, fracstep;
    float hscale;
    int row;/*from w  ww. j  a  v  a 2s.  c  om*/
    float t;

    GL_Bind(0);

    if (rows <= 256) {
        hscale = 1;
        trows = rows;
    } else {
        hscale = rows / 256.0f;
        trows = 256;
    }
    t = rows * hscale / 256;

    if (!qglColorTableEXT) {
        //int[] image32 = new int[256*256];
        image32.clear();
        int destIndex = 0;

        for (i = 0; i < trows; i++) {
            row = (int) (i * hscale);
            if (row > rows) {
                break;
            }
            sourceIndex = cols * row;
            destIndex = i * 256;
            fracstep = cols * 0x10000 / 256;
            frac = fracstep >> 1;
            for (j = 0; j < 256; j++) {
                image32.put(destIndex + j, r_rawpalette[data[sourceIndex + (frac >> 16)] & 0xff]);
                frac += fracstep;
            }
        }
        GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, gl_tex_solid_format, 256, 256, 0, GL11.GL_RGBA,
                GL11.GL_UNSIGNED_BYTE, image32);
    } else {
        //byte[] image8 = new byte[256*256];
        image8.clear();
        int destIndex = 0;

        for (i = 0; i < trows; i++) {
            row = (int) (i * hscale);
            if (row > rows) {
                break;
            }
            sourceIndex = cols * row;
            destIndex = i * 256;
            fracstep = cols * 0x10000 / 256;
            frac = fracstep >> 1;
            for (j = 0; j < 256; j++) {
                image8.put(destIndex + j, data[sourceIndex + (frac >> 16)]);
                frac += fracstep;
            }
        }

        GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, 256, 256, 0, GL11.GL_COLOR_INDEX,
                GL11.GL_UNSIGNED_BYTE, image8);
    }
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);

    if ((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0)) {
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex2f(x + w, y);
    GL11.glTexCoord2f(1, t);
    GL11.glVertex2f(x + w, y + h);
    GL11.glTexCoord2f(0, t);
    GL11.glVertex2f(x, y + h);
    GL11.glEnd();

    if ((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0)) {
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    }
}

From source file:org.free.jake2.render.lwjgl.Light.java

License:Open Source License

/**
 * R_RenderDlight//from   w  w  w. j a v  a2 s. c  o  m
 */
void R_RenderDlight(dlight_t light) {
    float rad = light.intensity * 0.35f;

    Math3D.VectorSubtract(light.origin, r_origin, v);

    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glColor3f(light.color[0] * 0.2f, light.color[1] * 0.2f, light.color[2] * 0.2f);
    int i;
    for (i = 0; i < 3; i++) {
        v[i] = light.origin[i] - vpn[i] * rad;
    }

    GL11.glVertex3f(v[0], v[1], v[2]);
    GL11.glColor3f(0, 0, 0);

    int j;
    float a;
    for (i = 16; i >= 0; i--) {
        a = (float) (i / 16.0f * Math.PI * 2);
        for (j = 0; j < 3; j++) {
            v[j] = (float) (light.origin[j] + vright[j] * Math.cos(a) * rad + vup[j] * Math.sin(a) * rad);
        }
        GL11.glVertex3f(v[0], v[1], v[2]);
    }
    GL11.glEnd();
}

From source file:org.free.jake2.render.lwjgl.Main.java

License:Open Source License

/**
 * R_DrawSpriteModel/*from w w  w .  j  a  v  a2s . co m*/
 */
void R_DrawSpriteModel(entity_t e) {
    float alpha = 1.0F;

    qfiles.dsprframe_t frame;
    qfiles.dsprite_t psprite;

    // don't even bother culling, because it's just a single
    // polygon without a surface cache

    psprite = (qfiles.dsprite_t) currentmodel.extradata;

    e.frame %= psprite.numframes;

    frame = psprite.frames[e.frame];

    if ((e.flags & Defines.RF_TRANSLUCENT) != 0) {
        alpha = e.alpha;
    }

    if (alpha != 1.0F) {
        GL11.glEnable(GL11.GL_BLEND);
    }

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

    GL_Bind(currentmodel.skins[e.frame].texnum);

    GL_TexEnv(GL11.GL_MODULATE);

    if (alpha == 1.0) {
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    } else {
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(0, 1);
    Math3D.VectorMA(e.origin, -frame.origin_y, vup, point);
    Math3D.VectorMA(point, -frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glTexCoord2f(0, 0);
    Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point);
    Math3D.VectorMA(point, -frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glTexCoord2f(1, 0);
    Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point);
    Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glTexCoord2f(1, 1);
    Math3D.VectorMA(e.origin, -frame.origin_y, vup, point);
    Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glEnd();

    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL_TexEnv(GL11.GL_REPLACE);

    if (alpha != 1.0F) {
        GL11.glDisable(GL11.GL_BLEND);
    }

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

From source file:org.free.jake2.render.lwjgl.Main.java

License:Open Source License

/**
 * R_PolyBlend/*from  w  w  w .  jav  a 2  s .  c  o  m*/
 */
void R_PolyBlend() {
    if (gl_polyblend.value == 0.0f) {
        return;
    }

    if (v_blend[3] == 0.0f) {
        return;
    }

    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    GL11.glLoadIdentity();

    // FIXME: get rid of these
    GL11.glRotatef(-90, 1, 0, 0); // put Z going up
    GL11.glRotatef(90, 0, 0, 1); // put Z going up

    GL11.glColor4f(v_blend[0], v_blend[1], v_blend[2], v_blend[3]);

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glVertex3f(10, 100, 100);
    GL11.glVertex3f(10, -100, 100);
    GL11.glVertex3f(10, -100, -100);
    GL11.glVertex3f(10, 100, -100);
    GL11.glEnd();

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_ALPHA_TEST);

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