List of usage examples for org.lwjgl.opengl GL11 glBegin
public static native void glBegin(@NativeType("GLenum") int mode);
From source file:kuake2.render.lwjgl.Mesh.java
License:Open Source License
/** * GL_DrawAliasShadow/* w w w .j a v a 2s . c o 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:kuake2.render.lwjgl.Surf.java
License:Open Source License
/** * R_DrawTriangleOutlines/* w ww .j av a 2 s .c om*/ */ 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:kuake2.render.lwjgl.Warp.java
License:Open Source License
/** * EmitWaterPolys/*from w w w .jav a 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:kuake2.render.lwjgl.Warp.java
License:Open Source License
/** * R_DrawSkyBox/*from ww w.j a v a 2 s. c om*/ */ 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:launcher.Main.java
private void drawWorld() { final int widthFit = (SCREEN_WIDTH / world.getBlockWidth()) + 1; final int heightFit = (SCREEN_HEIGHT / world.getBlockWidth()) + 1; final int cX = Math.min(widthFit, world.getSizeX()); final int cY = Math.min(heightFit, world.getSizeY());//assuming the world is not a jagged grid... // Clear the screen and depth buffer Point playerPoint = world.getPlayerLocationInGrid(player); final int startX = playerPoint.getX() - (int) Math.floor(widthFit / 2); final int startY = playerPoint.getY() - (int) Math.floor(heightFit / 2); final int w = world.getBlockWidth(); final int maxDamage = 500; final double damageProportion = w * 0.5 / maxDamage; for (int i = 0; i < cX + 1; i++) { for (int j = 0; j < cY + 1; j++) { Block block = world.getBlock(i + startX, j + startY); byte[] c = block.getColor(); GL11.glColor3ub(c[0], c[1], c[2]); int left = i * w - (w / 2); int top = j * w - (w / 2); int right = left + w; int bottom = top + w; // draw quad block thing GL11.glBegin(GL11.GL_QUADS); {/*w w w .j a v a2s. c om*/ GL11.glVertex2f(left, top); GL11.glVertex2f(right, top); GL11.glVertex2f(right, bottom); GL11.glVertex2f(left, bottom); } GL11.glEnd(); final int damage = block.getDamage(); if (damage < maxDamage && !(block instanceof AirBlock)) { //wtf is dit? int tmp = (int) Math.ceil((maxDamage / (damage + 1)) * 0.1f) + 2; int centerX = (int) (left + w * 0.5); int centerY = (int) (top + w * 0.5); int visibleDamage = (int) Math.ceil(damage * damageProportion); //gray GL11.glColor3ub((byte) 80, (byte) 80, (byte) 80); GL11.glBegin(GL11.GL_QUADS); { GL11.glVertex2f(left, top); GL11.glVertex2f(left + tmp, top); GL11.glVertex2f(centerX - visibleDamage, centerY - visibleDamage); GL11.glVertex2f(left, top + tmp); } GL11.glEnd(); GL11.glBegin(GL11.GL_QUADS); { GL11.glVertex2f(right, top); GL11.glVertex2f(right, top + tmp); GL11.glVertex2f(centerX + visibleDamage, centerY - visibleDamage); GL11.glVertex2f(right - tmp, top); } GL11.glEnd(); GL11.glBegin(GL11.GL_QUADS); { GL11.glVertex2f(right, bottom); GL11.glVertex2f(right - tmp, bottom); GL11.glVertex2f(centerX + visibleDamage, centerY + visibleDamage); GL11.glVertex2f(right, bottom - tmp); } GL11.glEnd(); GL11.glBegin(GL11.GL_QUADS); { GL11.glVertex2f(left, bottom); GL11.glVertex2f(left, bottom - tmp); GL11.glVertex2f(centerX - visibleDamage, centerY + visibleDamage); GL11.glVertex2f(left + tmp, bottom); } GL11.glEnd(); } } } }
From source file:launcher.Main.java
private void drawPlayer() { //orangered, why not? GL11.glColor3ub((byte) 255, (byte) 69, (byte) 0); final int w = player.getWidth() / 2; GL11.glBegin(GL11.GL_QUADS); {/* w w w.ja v a 2 s . com*/ GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y - w); GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y - w); GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y + w); GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y + w); } GL11.glEnd(); //draw drill switch (player.getDirection()) { case IDLE: break; case LEFT: GL11.glBegin(GL11.GL_TRIANGLES); { GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y - w); GL11.glVertex2f(SCREEN_CENTER_X - w * 1.5f, SCREEN_CENTER_Y); GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y + w); } GL11.glEnd(); break; case RIGHT: GL11.glBegin(GL11.GL_TRIANGLES); { GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y - w); GL11.glVertex2f(SCREEN_CENTER_X + w * 1.5f, SCREEN_CENTER_Y); GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y + w); } GL11.glEnd(); break; case DOWN: GL11.glBegin(GL11.GL_TRIANGLES); { GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y + w); GL11.glVertex2f(SCREEN_CENTER_X, SCREEN_CENTER_Y + w * 1.5f); GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y + w); } GL11.glEnd(); break; case UP: GL11.glBegin(GL11.GL_TRIANGLES); { GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y - w); GL11.glVertex2f(SCREEN_CENTER_X, SCREEN_CENTER_Y - w * 1.5f); GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y - w); } GL11.glEnd(); break; default: break; } }
From source file:lwjgl29.GlobalClass.Quad.java
@Override public void draw() { GL11.glColor3f(this.r, this.g, this.b); GL11.glBegin(GL11.GL_POLYGON); //position de dpart GL11.glVertex2f(this.x, this.y); //dessin des 3 cots GL11.glVertex2f(this.x + this.width, this.y); GL11.glVertex2f(this.x + this.width, this.y + this.height); GL11.glVertex2f(this.x, this.y + this.height); GL11.glEnd();/*from w w w . j a v a 2 s .com*/ this.move(); }
From source file:Main.Graphics.GameObject.java
public static void RenderGL() { float x = GameWorld.x; float y = GameWorld.y; float rotation = GameWorld.rotation; GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glColor3f(0.5f, 0.5f, 1.0f);//www.java2 s .c om GL11.glPushMatrix(); GL11.glTranslatef(x, y, 0); GL11.glRotatef(rotation, 0f, 0f, 1f); GL11.glTranslatef(-x, -y, 0); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(x - 50, y - 50); GL11.glVertex2f(x + 50, y - 50); GL11.glVertex2f(x + 50, y + 50); GL11.glVertex2f(x - 50, y + 50); GL11.glEnd(); GL11.glPopMatrix(); }
From source file:map.GameMap.java
License:Open Source License
public void draw(Camera cam) { Vector3f camTarget = null;// w w w. java 2 s .c om if (cam != null) { camTarget = cam.getTarget().getPos(); } groundMaterial.bind(); GL11.glBegin(GL11.GL_TRIANGLES); for (int i = 0; i < tiles.length; i++) { for (int j = 0; j < tiles[0].length; j++) { if (cam == null || Math.abs(camTarget.x - i) < 25 && Math.abs(camTarget.y - j) < 25) { tiles[i][j].draw(); } } } GL11.glEnd(); for (int i = 0; i < tiles.length; i++) { for (int j = 0; j < tiles[0].length; j++) { if (cam == null || Math.abs(camTarget.x - i) < 16 && Math.abs(camTarget.y - j) < 16) { if (tiles[i][j].hasFeatures()) { tiles[i][j].drawFeatures(); } } } } drawWater(); }
From source file:map.GameMap.java
License:Open Source License
public void drawWater() { GL11.glEnable(GL11.GL_BLEND);// ww w . j av a 2 s .c o m GL11.glDepthMask(false); waterMaterial.bind(); GL11.glBegin(GL11.GL_QUADS); GL11.glNormal3f(0, 0, 1.0f); GL11.glTexCoord2f(0, 0); GL11.glVertex3f(0, 0, WATER_HEIGHT); GL11.glTexCoord2f(size, 0); GL11.glVertex3f(size, 0, WATER_HEIGHT); GL11.glTexCoord2f(size, size); GL11.glVertex3f(size, size, WATER_HEIGHT); GL11.glTexCoord2f(0, size); GL11.glVertex3f(0, size, WATER_HEIGHT); GL11.glEnd(); GL11.glDepthMask(true); GL11.glDisable(GL11.GL_BLEND); }