List of usage examples for org.lwjgl.opengl GL11 glBegin
public static native void glBegin(@NativeType("GLenum") int mode);
From source file:org.free.jake2.render.lwjgl.Main.java
License:Open Source License
/** * R_DrawBeam//from www . j a v a2 s. c o m */ void R_DrawBeam(entity_t e) { oldorigin[0] = e.oldorigin[0]; oldorigin[1] = e.oldorigin[1]; oldorigin[2] = e.oldorigin[2]; origin[0] = e.origin[0]; origin[1] = e.origin[1]; origin[2] = e.origin[2]; normalized_direction[0] = direction[0] = oldorigin[0] - origin[0]; normalized_direction[1] = direction[1] = oldorigin[1] - origin[1]; normalized_direction[2] = direction[2] = oldorigin[2] - origin[2]; if (Math3D.VectorNormalize(normalized_direction) == 0.0f) { return; } Math3D.PerpendicularVector(perpvec, normalized_direction); Math3D.VectorScale(perpvec, e.frame / 2, perpvec); for (int i = 0; i < 6; i++) { Math3D.RotatePointAroundVector(start_points[i], normalized_direction, perpvec, (360.0f / NUM_BEAM_SEGS) * i); Math3D.VectorAdd(start_points[i], origin, start_points[i]); Math3D.VectorAdd(start_points[i], direction, end_points[i]); } GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glDepthMask(false); float r = (d_8to24table[e.skinnum & 0xFF]) & 0xFF; float g = (d_8to24table[e.skinnum & 0xFF] >> 8) & 0xFF; float b = (d_8to24table[e.skinnum & 0xFF] >> 16) & 0xFF; r *= 1 / 255.0f; g *= 1 / 255.0f; b *= 1 / 255.0f; GL11.glColor4f(r, g, b, e.alpha); GL11.glBegin(GL11.GL_TRIANGLE_STRIP); float[] v; for (int i = 0; i < NUM_BEAM_SEGS; i++) { v = start_points[i]; GL11.glVertex3f(v[0], v[1], v[2]); v = end_points[i]; GL11.glVertex3f(v[0], v[1], v[2]); v = start_points[(i + 1) % NUM_BEAM_SEGS]; GL11.glVertex3f(v[0], v[1], v[2]); v = end_points[(i + 1) % NUM_BEAM_SEGS]; GL11.glVertex3f(v[0], v[1], v[2]); } GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDepthMask(true); }
From source file:org.free.jake2.render.lwjgl.Mesh.java
License:Open Source License
/** * GL_DrawAliasShadow// w w w. ja va 2 s . co m */ void GL_DrawAliasShadow(qfiles.dmdl_t paliashdr, int posenum) { float lheight = currententity.origin[2] - lightspot[2]; qfiles.daliasframe_t frame = paliashdr.aliasFrames[currententity.frame]; int[] order = paliashdr.glCmds; float height = -lheight + 1.0f; int orderIndex = 0; int index = 0; // TODO shadow drawing with vertex arrays int count; while (true) { // get the vertex count and primitive type count = order[orderIndex++]; if (count == 0) { break; // done } if (count < 0) { count = -count; GL11.glBegin(GL11.GL_TRIANGLE_FAN); } else { GL11.glBegin(GL11.GL_TRIANGLE_STRIP); } do { index = order[orderIndex + 2] * 3; point[0] = vertexArrayBuf.get(index); point[1] = vertexArrayBuf.get(index + 1); point[2] = vertexArrayBuf.get(index + 2); point[0] -= shadevector[0] * (point[2] + lheight); point[1] -= shadevector[1] * (point[2] + lheight); point[2] = height; GL11.glVertex3f(point[0], point[1], point[2]); orderIndex += 3; } while (--count != 0); GL11.glEnd(); } }
From source file:org.free.jake2.render.lwjgl.Surf.java
License:Open Source License
/** * R_DrawTriangleOutlines// w w w. j a va2 s . c o m */ void R_DrawTriangleOutlines() { if (gl_showtris.value == 0) { return; } GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glColor4f(1, 1, 1, 1); msurface_t surf; glpoly_t p; int j; for (int i = 0; i < MAX_LIGHTMAPS; i++) { for (surf = gl_lms.lightmap_surfaces[i]; surf != null; surf = surf.lightmapchain) { for (p = surf.polys; p != null; p = p.chain) { for (j = 2; j < p.numverts; j++) { GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glVertex3f(p.x(0), p.y(0), p.z(0)); GL11.glVertex3f(p.x(j - 1), p.y(j - 1), p.z(j - 1)); GL11.glVertex3f(p.x(j), p.y(j), p.z(j)); GL11.glVertex3f(p.x(0), p.y(0), p.z(0)); GL11.glEnd(); } } } } GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); }
From source file:org.free.jake2.render.lwjgl.Warp.java
License:Open Source License
/** * EmitWaterPolys/*w w w . java 2 s.c om*/ * 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
/** * R_DrawSkyBox/*w w w . j a va 2 s . c o m*/ */ void R_DrawSkyBox() { int i; if (skyrotate != 0) { // check for no sky at all for (i = 0; i < 6; i++) { if (skymins[0][i] < skymaxs[0][i] && skymins[1][i] < skymaxs[1][i]) { break; } } if (i == 6) { return; // nothing visible } } GL11.glPushMatrix(); GL11.glTranslatef(r_origin[0], r_origin[1], r_origin[2]); GL11.glRotatef(r_newrefdef.time * skyrotate, skyaxis[0], skyaxis[1], skyaxis[2]); for (i = 0; i < 6; i++) { if (skyrotate != 0) { // hack, forces full sky to draw when rotating skymins[0][i] = -1; skymins[1][i] = -1; skymaxs[0][i] = 1; skymaxs[1][i] = 1; } if (skymins[0][i] >= skymaxs[0][i] || skymins[1][i] >= skymaxs[1][i]) { continue; } GL_Bind(sky_images[skytexorder[i]].texnum); GL11.glBegin(GL11.GL_QUADS); MakeSkyVec(skymins[0][i], skymins[1][i], i); MakeSkyVec(skymins[0][i], skymaxs[1][i], i); MakeSkyVec(skymaxs[0][i], skymaxs[1][i], i); MakeSkyVec(skymaxs[0][i], skymins[1][i], i); GL11.glEnd(); } GL11.glPopMatrix(); }
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 v a 2 s .co 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.javateerz.EasyGL.GLRect.java
License:Open Source License
/** * Draws the OpenGL rectangle on the display *///from w w w .j a v a2s . co m public void draw() { GL11.glPushMatrix(); // disable textures GL11.glDisable(TEXTURE_TARGET); // move to selected location GL11.glTranslatef(x, y, 0); // set color for drawing GL11.glColor4f((float) color.getRed() / 255, (float) color.getGreen() / 255, (float) color.getBlue() / 255, (float) color.getAlpha() / 255); // draw a quadrilateral GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(0, 0); GL11.glVertex2f(0, height); GL11.glVertex2f(width, height); GL11.glVertex2f(width, 0); 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();//from w w w. j a v a 2 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); // SW/*from w w w . ja va 2 s .co m*/ 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(); }
From source file:org.joge.core.draw.font.Font.java
License:Open Source License
public void render(String text, Color color, float xpos, float ypos) { Texture tex;//w ww . j a v a 2s. c o m char[] chars = text.toCharArray(); float textWidth = 0; for (int i = 0; i < chars.length; i++) { tex = charArray[(int) chars[i]]; width = tex.getImageWidth(); height = tex.getImageHeight(); tWidth = tex.getWidth(); tHeight = tex.getHeight(); tex.bind(); GL11.glTranslatef(xpos + textWidth, ypos, 0); GL11.glColor3f(color.r, color.g, color.b); GL11.glBegin(GL11.GL_QUADS); { 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(); GL11.glLoadIdentity(); textWidth += tex.getWidth() * fontSize; } }