List of usage examples for org.lwjgl.opengl GL11 glVertex3f
public static native void glVertex3f(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y, @NativeType("GLfloat") float z);
From source file:org.craftmania.world.Sky.java
License:Apache License
private void drawShpere(float x, float y, float z) { GL11.glPushMatrix();//from w w w .j a va2s .co m GL11.glTranslatef(x, y, z); GL11.glColor3f(_color.x(), _color.y(), _color.z()); if (_sphereCallList == 0) { _sphereCallList = GL11.glGenLists(1); GL11.glNewList(_sphereCallList, GL11.GL_COMPILE_AND_EXECUTE); GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glVertex3f(0, 0, 0); for (int i = 0; i <= _vertices; ++i) { float angle = MathHelper.f_2PI / _vertices * i; float xx = MathHelper.cos(angle) * _radius; float zz = MathHelper.sin(angle) * _radius; GL11.glVertex3f(xx, -_bend, zz); } GL11.glEnd(); GL11.glEndList(); } else { GL11.glCallList(_sphereCallList); } GL11.glPopMatrix(); }
From source file:org.craftmania.world.Sky.java
License:Apache License
private void drawClouds(float x, float y, float z) { GL11.glPushMatrix();/*from w w w .j a va2 s. c om*/ GL11.glTranslatef(x, y, z); if (_cloudsCallList == 0) { _cloudsCallList = GL11.glGenLists(1); GL11.glNewList(_cloudsCallList, GL11.GL_COMPILE_AND_EXECUTE); float hw = _cloudsTexWidth / 2.0f; float hh = _cloudsTexHeight / 2.0f; hw *= _cloudsScale; hh *= _cloudsScale; GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 0); GL11.glVertex3f(-hw, 0, -hh); GL11.glTexCoord2f(1, 0); GL11.glVertex3f(+hw, 0, -hh); GL11.glTexCoord2f(1, 1); GL11.glVertex3f(+hw, 0, +hh); GL11.glTexCoord2f(0, 1); GL11.glVertex3f(-hw, 0, +hh); GL11.glEnd(); GL11.glEndList(); } else { GL11.glCallList(_cloudsCallList); } GL11.glPopMatrix(); }
From source file:org.craftmania.world.World.java
License:Apache License
private void renderOverlay() { Configuration conf = Game.getInstance().getConfiguration(); Game.getInstance().initOverlayRendering(); GL11.glColor3f(1, 1, 1);//from ww w .jav a 2 s . c o m if (Game.RENDER_INFORMATION_OVERLAY) { GLFont infoFont = FontStorage.getFont("Monospaced_20"); /* Down Left Info */ infoFont.print(4, 4, "CraftMania"); infoFont.print(4, 30, _player.coordinatesToString()); infoFont.print(4, 45, "Visible Chunks: " + _visibleChunks.size()); infoFont.print(4, 60, "Updading Blocks: " + _updatingBlocks); infoFont.print(4, 75, "Total Chunks in RAM: " + _chunkManager.getTotalChunkCount()); infoFont.print(4, 90, "Local Chunks: " + _localChunks.size()); infoFont.print(4, 105, "Total Local Blocks: " + _localBlockCount); infoFont.print(4, 120, "Time: " + _time); infoFont.print(4, 135, "Sunlight: " + _sunlight); } /** RENDER **/ if (_activatedInventory != null) { Game.getInstance().renderTransculentOverlayLayer(); _activatedInventory.renderInventory(); } else { int width = conf.getWidth(); int height = conf.getHeight(); // Center Cross GL11.glDisable(GL11.GL_TEXTURE_2D); if (CENTER_CROSS_CALL_LIST == 0) { CENTER_CROSS_CALL_LIST = GL11.glGenLists(1); GL11.glNewList(CENTER_CROSS_CALL_LIST, GL11.GL_COMPILE_AND_EXECUTE); int crossSize = 10; int crossHole = 5; GL11.glLineWidth(2.5f); GL11.glColor3f(0, 0, 0); GL11.glBegin(GL11.GL_LINES); GL11.glVertex3f(width / 2f - crossSize - crossHole, height / 2f, 0); GL11.glVertex3f(width / 2f - crossHole, height / 2f, 0); GL11.glVertex3f(width / 2f + crossSize + crossHole, height / 2f, 0); GL11.glVertex3f(width / 2f + crossHole, height / 2f, 0); GL11.glVertex3f(width / 2f, height / 2f - crossSize - crossHole, 0); GL11.glVertex3f(width / 2f, height / 2f - crossHole, 0); GL11.glVertex3f(width / 2f, height / 2f + crossSize + crossHole, 0); GL11.glVertex3f(width / 2f, height / 2f + crossHole, 0); GL11.glEnd(); GL11.glEndList(); } else { GL11.glCallList(CENTER_CROSS_CALL_LIST); } GL11.glEnable(GL11.GL_TEXTURE_2D); // Inventory bar GL11.glPushMatrix(); Texture texGui = TextureStorage.getTexture("gui.gui"); texGui.bind(); float tileSize = 20.0f / texGui.getImageWidth(); if (INVENTORY_BAR_CALL_LIST == 0) { INVENTORY_BAR_CALL_LIST = GL11.glGenLists(2); /* Bar */ GL11.glNewList(INVENTORY_BAR_CALL_LIST, GL11.GL_COMPILE_AND_EXECUTE); GL11.glTranslatef(width / 2.0f - 9 * 20, 10, 0); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(0, 40); GL11.glTexCoord2f(tileSize * 9, 0); GL11.glVertex2f(9 * 40, 40); GL11.glTexCoord2f(tileSize * 9, tileSize); GL11.glVertex2f(9 * 40, 0); GL11.glTexCoord2f(0, tileSize); GL11.glVertex2f(0, 0); GL11.glEnd(); GL11.glEndList(); /* Little frame around selected item */ float frameTileSize = 24.0f / texGui.getImageWidth(); float frameTileY = 22.0f / texGui.getImageHeight(); GL11.glNewList(INVENTORY_BAR_CALL_LIST + 1, GL11.GL_COMPILE); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, frameTileY); GL11.glVertex2f(0, 48); GL11.glTexCoord2f(frameTileSize, frameTileY); GL11.glVertex2f(48, 48); GL11.glTexCoord2f(frameTileSize, frameTileY + frameTileSize); GL11.glVertex2f(48, 0); GL11.glTexCoord2f(0, frameTileY + frameTileSize); GL11.glVertex2f(0, 0); GL11.glEnd(); GL11.glEndList(); } else { GL11.glCallList(INVENTORY_BAR_CALL_LIST); } /* Content */ GL11.glPushMatrix(); GL11.glTranslatef(20, 20, 0); for (int i = 0; i < 9; ++i) { InventoryPlace place = getActivePlayer().getInventory().getInventoryPlace(i); if (place != null) place.render(); GL11.glTranslatef(40, 0, 0); } texGui.bind(); GL11.glPopMatrix(); GL11.glTranslatef(getActivePlayer().getSelectedInventoryItemIndex() * 40.0f - 4, -4, 0); GL11.glCallList(INVENTORY_BAR_CALL_LIST + 1); GL11.glPopMatrix(); } }
From source file:org.eclipse.swt.opengl.examples.LWJGLExample.java
License:Open Source License
static void drawTorus(float r, float R, int nsides, int rings) { float ringDelta = 2.0f * (float) Math.PI / rings; float sideDelta = 2.0f * (float) Math.PI / nsides; float theta = 0.0f, cosTheta = 1.0f, sinTheta = 0.0f; for (int i = rings - 1; i >= 0; i--) { float theta1 = theta + ringDelta; float cosTheta1 = (float) Math.cos(theta1); float sinTheta1 = (float) Math.sin(theta1); GL11.glBegin(GL11.GL_QUAD_STRIP); float phi = 0.0f; for (int j = nsides; j >= 0; j--) { phi += sideDelta;/*from w ww . j av a 2 s .c om*/ float cosPhi = (float) Math.cos(phi); float sinPhi = (float) Math.sin(phi); float dist = R + r * cosPhi; GL11.glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi); GL11.glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi); GL11.glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi); GL11.glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi); } GL11.glEnd(); theta = theta1; cosTheta = cosTheta1; sinTheta = sinTheta1; } }
From source file:org.free.jake2.render.lwjgl.Light.java
License:Open Source License
/** * R_RenderDlight/*from ww w .j av a 2 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// ww w . j av a 2s .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/*ww w . java2 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); }
From source file:org.free.jake2.render.lwjgl.Main.java
License:Open Source License
/** * R_DrawBeam//w ww . jav a 2s. co 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/*from w w w . ja v a 2 s.c om*/ */ 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/* ww w .j a v a2 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); }