List of usage examples for org.lwjgl.opengl GL11 glTexCoord2f
public static native void glTexCoord2f(@NativeType("GLfloat") float s, @NativeType("GLfloat") float t);
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 .j av a 2 s .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 www .ja v a2 s . 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;/*from w ww . j av a2 s . 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_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 w w. j av a2 s. c o m 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.Main.java
License:Open Source License
/** * R_DrawSpriteModel/*from w w w .j a v a2 s . com*/ */ 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.Warp.java
License:Open Source License
/** * EmitWaterPolys//from w ww . j a v a2 s . c o m * Does a water warp on the pre-fragmented glpoly_t chain */ void EmitWaterPolys(msurface_t fa) { float rdt = r_newrefdef.time; float scroll; if ((fa.texinfo.flags & Defines.SURF_FLOWING) != 0) { scroll = -64 * ((r_newrefdef.time * 0.5f) - (int) (r_newrefdef.time * 0.5f)); } else { scroll = 0; } int i; float s, t, os, ot; glpoly_t p, bp; for (bp = fa.polys; bp != null; bp = bp.next) { p = bp; GL11.glBegin(GL11.GL_TRIANGLE_FAN); for (i = 0; i < p.numverts; i++) { os = p.s1(i); ot = p.t1(i); s = os + Warp.SIN[(int) ((ot * 0.125f + r_newrefdef.time) * TURBSCALE) & 255]; s += scroll; s *= (1.0f / 64); t = ot + Warp.SIN[(int) ((os * 0.125f + rdt) * TURBSCALE) & 255]; t *= (1.0f / 64); GL11.glTexCoord2f(s, t); GL11.glVertex3f(p.x(i), p.y(i), p.z(i)); } GL11.glEnd(); } }
From source file:org.free.jake2.render.lwjgl.Warp.java
License:Open Source License
/** * MakeSkyVec/*from w ww. ja va 2 s . co m*/ * @param s * @param t * @param axis */ void MakeSkyVec(float s, float t, int axis) { b[0] = s * 2300; b[1] = t * 2300; b[2] = 2300; int j, k; for (j = 0; j < 3; j++) { k = st_to_vec[axis][j]; if (k < 0) { v1[j] = -b[-k - 1]; } else { v1[j] = b[k - 1]; } } // avoid bilerp seam s = (s + 1) * 0.5f; t = (t + 1) * 0.5f; if (s < sky_min) { s = sky_min; } else if (s > sky_max) { s = sky_max; } if (t < sky_min) { t = sky_min; } else if (t > sky_max) { t = sky_max; } t = 1.0f - t; GL11.glTexCoord2f(s, t); GL11.glVertex3f(v1[0], v1[1], v1[2]); }
From source file:org.geekygoblin.nedetlesmaki.game.systems.DrawSystem.java
License:Open Source License
private void drawLevel(LevelBackground level) { GL11.glPushMatrix();//from w w w . j a va2s .c o m GL11.glLoadIdentity(); IPlay backgroundAnimationPlay = level.getBackground(); backgroundAnimationPlay.update((long) (world.getDelta() * 1000L)); final IAnimationFrame currentFrame = backgroundAnimationPlay.getCurrentFrame(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, (Integer) currentFrame.getImage().getId()); float x1 = -VirtualResolution.WIDTH / 2.0f; float x2 = VirtualResolution.WIDTH / 2.0f; float y1 = VirtualResolution.HEIGHT / 2.0f; float y2 = -VirtualResolution.HEIGHT / 2.0f; float u1 = currentFrame.getU1(); float u2 = currentFrame.getU2(); float v1 = currentFrame.getV2(); float v2 = currentFrame.getV1(); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(u1, v1); GL11.glVertex2f(x1, y2); GL11.glTexCoord2f(u2, v1); GL11.glVertex2f(x2, y2); GL11.glTexCoord2f(u2, v2); GL11.glVertex2f(x2, y1); GL11.glTexCoord2f(u1, v2); GL11.glVertex2f(x1, y1); GL11.glEnd(); GL11.glPopMatrix(); }
From source file:org.jmangos.tools.openGL.FontTT.java
License:Open Source License
private void drawtexture(final Texture texture, final float ratio, final float x, final float y, final Color color, final float rotx, final float roty, final float rotz) { // Get the appropriate measurements from the texture itself final float imgwidth = texture.getImageWidth() * ratio; final float imgheight = -texture.getImageHeight() * ratio; final float texwidth = texture.getWidth(); final float texheight = texture.getHeight(); // Bind the texture texture.bind();/*w w w . j a v a2 s . c o m*/ // translate to the right location GL11.glColor4f(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); // draw a quad with to place the character onto GL11.glBegin(GL11.GL_QUADS); { GL11.glTexCoord2f(0, 0); GL11.glVertex2f(0 + x, 0 - y); GL11.glTexCoord2f(0, texheight); GL11.glVertex2f(0 + x, imgheight - y); GL11.glTexCoord2f(texwidth, texheight); GL11.glVertex2f(imgwidth + x, imgheight - y); GL11.glTexCoord2f(texwidth, 0); GL11.glVertex2f(imgwidth + x, 0 - y); } GL11.glEnd(); }
From source file:org.jogamp.glg2d.impl.gl2.GL2ImageDrawer.java
License:Apache License
@Override protected void applyTexture(Texture texture, float dx1, float dy1, float dx2, float dy2, float sx1, float sy1, float sx2, float sy2) { GL11.glBegin(GL11.GL_QUADS);/*from w w w. ja v a2 s . c o m*/ // SW GL11.glTexCoord2f(sx1, sy2); GL11.glVertex2f(dx1, dy2); // SE GL11.glTexCoord2f(sx2, sy2); GL11.glVertex2f(dx2, dy2); // NE GL11.glTexCoord2f(sx2, sy1); GL11.glVertex2f(dx2, dy1); // NW GL11.glTexCoord2f(sx1, sy1); GL11.glVertex2f(dx1, dy1); GL11.glEnd(); }