protected void initGLState() { System.err.println("GL_VENDOR: " + glGetString(GL_VENDOR)); System.err.println("GL_RENDERER: " + glGetString(GL_RENDERER)); System.err.println("GL_VERSION: " + glGetString(GL_VERSION)); // setup ogl FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] {5.0f, 5.0f, 10.0f, 0.0f}); FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] {0.8f, 0.1f, 0.0f, 1.0f}); FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] {0.0f, 0.8f, 0.2f, 1.0f}); FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] {0.2f, 0.2f, 1.0f, 1.0f}); pos.flip(); red.flip(); green.flip(); blue.flip(); glLightfv(GL_LIGHT0, GL_POSITION, pos); glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); /* make the gears */ gear1 = glGenLists(1); glNewList(gear1, GL_COMPILE); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); gear(1.0f, 4.0f, 1.0f, 20, 0.7f); glEndList(); gear2 = glGenLists(1); glNewList(gear2, GL_COMPILE); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); gear(0.5f, 2.0f, 2.0f, 10, 0.7f); glEndList(); gear3 = glGenLists(1); glNewList(gear3, GL_COMPILE); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); gear(1.3f, 2.0f, 0.5f, 10, 0.7f); glEndList(); glEnable(GL_NORMALIZE); glMatrixMode(GL_PROJECTION); float h = (float) 300 / (float) 300; glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0f, 0.0f, -40.0f); }
private static void initialize() { if (!initialized) { initialized = true; starGLCallList = GLAllocation.generateDisplayLists(3); GL11.glPushMatrix(); GL11.glNewList(starGLCallList, GL11.GL_COMPILE); renderStars(); GL11.glEndList(); GL11.glPopMatrix(); Tessellator tessellator = Tessellator.instance; glSkyList = starGLCallList + 1; GL11.glNewList(glSkyList, GL11.GL_COMPILE); byte b2 = 64; int i = 256 / b2 + 2; float f = 16.0F; int j; int k; for (j = -b2 * i; j <= b2 * i; j += b2) { for (k = -b2 * i; k <= b2 * i; k += b2) { tessellator.startDrawingQuads(); tessellator.addVertex((j + 0), f, (k + 0)); tessellator.addVertex((j + b2), f, (k + 0)); tessellator.addVertex((j + b2), f, (k + b2)); tessellator.addVertex((j + 0), f, (k + b2)); tessellator.draw(); } } GL11.glEndList(); glSkyList2 = starGLCallList + 2; GL11.glNewList(glSkyList2, GL11.GL_COMPILE); f = -16.0F; tessellator.startDrawingQuads(); for (j = -b2 * i; j <= b2 * i; j += b2) { for (k = -b2 * i; k <= b2 * i; k += b2) { tessellator.addVertex((j + b2), f, (k + 0)); tessellator.addVertex((j + 0), f, (k + 0)); tessellator.addVertex((j + 0), f, (k + b2)); tessellator.addVertex((j + b2), f, (k + b2)); } } tessellator.draw(); GL11.glEndList(); } }
@Override protected void doFlush() { // TODO: Use fallback material modes for this if (!(activeMaterial.getShader() instanceof BasicShader)) { throw new IllegalStateException("Need Basic Shader in 1.1 mode"); } GL11.glNewList(displayList, GL11.GL_COMPILE); ((BasicShader) activeMaterial.getShader()).assign(true); GL11.glPushMatrix(); GL11.glBegin(renderMode); for (int i = 0; i < numVerticies; i += 1) { int index = i * 4; if (useColors) { GL11.glColor3f( colorBuffer.get(index), colorBuffer.get(index + 1), colorBuffer.get(index + 2)); } if (useNormals) { GL11.glNormal3f( normalBuffer.get(index), normalBuffer.get(index + 1), normalBuffer.get(index + 2)); } if (useTextures) { GL11.glTexCoord2f(uvBuffer.get((i * 2)), uvBuffer.get((i * 2) + 1)); } GL11.glVertex4f( vertexBuffer.get(index), vertexBuffer.get(index + 1), vertexBuffer.get(index + 2), vertexBuffer.get(index + 3)); } GL11.glEnd(); GL11.glPopMatrix(); GL11.glEndList(); }
/** * <code>buildDisplayList</code> sets up the 256 display lists that are used to render each font * character. Each list quad is 16x16, as defined by the font image size. */ public void buildDisplayList() { float cx; float cy; base = GL11.glGenLists(256); for (int loop = 0; loop < 256; loop++) { cx = (loop % 16) / 16.0f; cy = (loop / 16) / 16.0f; GL11.glNewList(base + loop, GL11.GL_COMPILE); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(cx, 1 - cy - 0.0625f); GL11.glVertex2i(0, 0); GL11.glTexCoord2f(cx + 0.0625f, 1 - cy - 0.0625f); GL11.glVertex2i(16, 0); GL11.glTexCoord2f(cx + 0.0625f, 1 - cy); GL11.glVertex2i(16, 16); GL11.glTexCoord2f(cx, 1 - cy); GL11.glVertex2i(0, 16); GL11.glEnd(); GL11.glTranslatef(10, 0, 0); GL11.glEndList(); } }
// TODO: replace with a proper resident buffer with interleaved vertex and uv coordinates private void renderQuad() { if (displayListQuad == -1) { displayListQuad = glGenLists(1); glNewList(displayListQuad, GL11.GL_COMPILE); glBegin(GL_QUADS); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glTexCoord2d(0.0, 0.0); glVertex3i(-1, -1, -1); glTexCoord2d(1.0, 0.0); glVertex3i(1, -1, -1); glTexCoord2d(1.0, 1.0); glVertex3i(1, 1, -1); glTexCoord2d(0.0, 1.0); glVertex3i(-1, 1, -1); glEnd(); glEndList(); } glCallList(displayListQuad); }
public final void update() { chunkUpdates++; this.setAllDirty(); Tesselator t = Tesselator.instance; for (int i = 0; i < 3; i++) { glNewList(this.glRenderList + i, GL_COMPILE); t.begin(); for (int x = x0; x < x1; x++) { for (int y = y0; y < y1; y++) { for (int z = z0; z < z1; z++) { int type = this.level.getTile(x, y, z); if (type > 0) { Tile tile = Tile.tiles[type]; tile.render(i, x, y, z); } } } } t.end(); glEndList(); this.isDirty = false; } }
private int[] getDisplayLists(int liquidId, World world) { if (stage.containsKey(liquidId)) return stage.get(liquidId); int[] d = new int[displayStages]; stage.put(liquidId, d); BlockInterface block = new BlockInterface(); // Retrieve the texture depending on type of item. if (liquidId < Block.blocksList.length && Block.blocksList[liquidId] != null) block.texture = Block.blocksList[liquidId].blockIndexInTexture; else if (Item.itemsList[liquidId] != null) block.texture = Item.itemsList[liquidId].getIconFromDamage(0); else return null; for (int s = 0; s < displayStages; ++s) { d[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d[s], 4864 /* GL_COMPILE */); block.minX = 0.5 - 4F * factor + 0.01; block.minY = 0; block.minZ = 0.5 - 4F * factor + 0.01; block.maxX = 0.5 + 4F * factor - 0.01; block.maxY = (float) s / (float) displayStages; block.maxZ = 0.5 + 4F * factor - 0.01; RenderEntityBlock.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); } return d; }
private void generateDisplayListWire() { float offset = 0.001f; displayListWire = glGenLists(1); glNewList(displayListWire, GL11.GL_COMPILE); glColor4f(0.0f, 0.0f, 0.0f, 1.0f); Vector3f dimensions = aabb.getExtents(); // FRONT glBegin(GL_LINE_LOOP); glVertex3f(-dimensions.x - offset, -dimensions.y - offset, -dimensions.z - offset); glVertex3f(+dimensions.x + offset, -dimensions.y - offset, -dimensions.z - offset); glVertex3f(+dimensions.x + offset, +dimensions.y + offset, -dimensions.z - offset); glVertex3f(-dimensions.x - offset, +dimensions.y + offset, -dimensions.z - offset); glEnd(); // BACK glBegin(GL_LINE_LOOP); glVertex3f(-dimensions.x - offset, -dimensions.y - offset, +dimensions.z + offset); glVertex3f(+dimensions.x + offset, -dimensions.y - offset, +dimensions.z + offset); glVertex3f(+dimensions.x + offset, +dimensions.y + offset, +dimensions.z + offset); glVertex3f(-dimensions.x - offset, +dimensions.y + offset, +dimensions.z + offset); glEnd(); // TOP glBegin(GL_LINE_LOOP); glVertex3f(-dimensions.x - offset, -dimensions.y - offset, -dimensions.z - offset); glVertex3f(+dimensions.x + offset, -dimensions.y - offset, -dimensions.z - offset); glVertex3f(+dimensions.x + offset, -dimensions.y - offset, +dimensions.z + offset); glVertex3f(-dimensions.x - offset, -dimensions.y - offset, +dimensions.z + offset); glEnd(); // BOTTOM glBegin(GL_LINE_LOOP); glVertex3f(-dimensions.x - offset, +dimensions.y + offset, -dimensions.z - offset); glVertex3f(+dimensions.x + offset, +dimensions.y + offset, -dimensions.z - offset); glVertex3f(+dimensions.x + offset, +dimensions.y + offset, +dimensions.z + offset); glVertex3f(-dimensions.x - offset, +dimensions.y + offset, +dimensions.z + offset); glEnd(); // LEFT glBegin(GL_LINE_LOOP); glVertex3f(-dimensions.x - offset, -dimensions.y - offset, -dimensions.z - offset); glVertex3f(-dimensions.x - offset, -dimensions.y - offset, +dimensions.z + offset); glVertex3f(-dimensions.x - offset, +dimensions.y + offset, +dimensions.z + offset); glVertex3f(-dimensions.x - offset, +dimensions.y + offset, -dimensions.z - offset); glEnd(); // RIGHT glBegin(GL_LINE_LOOP); glVertex3f(+dimensions.x + offset, -dimensions.y - offset, -dimensions.z - offset); glVertex3f(+dimensions.x + offset, -dimensions.y - offset, +dimensions.z + offset); glVertex3f(+dimensions.x + offset, +dimensions.y + offset, +dimensions.z + offset); glVertex3f(+dimensions.x + offset, +dimensions.y + offset, -dimensions.z - offset); glEnd(); glEndList(); }
public static int prepareSphere(int texId, float size) { int list = glGenLists(1); glNewList(list, GL_COMPILE); glBindTexture(GL_TEXTURE_2D, texId); sphere.draw(size, Config.details, Config.details); glEndList(); return list; }
public void initGLState() { System.err.println("GL_VENDOR: " + glGetString(GL_VENDOR)); System.err.println("GL_RENDERER: " + glGetString(GL_RENDERER)); System.err.println("GL_VERSION: " + glGetString(GL_VERSION)); MemoryStack s = stackPush(); // setup ogl glLightfv(GL_LIGHT0, GL_POSITION, s.floats(5.0f, 5.0f, 10.0f, 0.0f)); glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); /* make the gears */ gear1 = glGenLists(1); glNewList(gear1, GL_COMPILE); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, s.floats(0.8f, 0.1f, 0.0f, 1.0f)); gear(1.0f, 4.0f, 1.0f, 20, 0.7f); glEndList(); gear2 = glGenLists(1); glNewList(gear2, GL_COMPILE); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, s.floats(0.0f, 0.8f, 0.2f, 1.0f)); gear(0.5f, 2.0f, 2.0f, 10, 0.7f); glEndList(); gear3 = glGenLists(1); glNewList(gear3, GL_COMPILE); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, s.floats(0.2f, 0.2f, 1.0f, 1.0f)); gear(1.3f, 2.0f, 0.5f, 10, 0.7f); glEndList(); s.pop(); glEnable(GL_NORMALIZE); glMatrixMode(GL_PROJECTION); float h = (float) 300 / (float) 300; glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0f, 0.0f, -40.0f); }
private void generateDisplayListWire() { double offset = 0.001; _displayListWire = glGenLists(1); glNewList(_displayListWire, GL11.GL_COMPILE); glColor4f(0.0f, 0.0f, 0.0f, 1.0f); // FRONT glBegin(GL_LINE_LOOP); glVertex3d(-_dimensions.x - offset, -_dimensions.y - offset, -_dimensions.z - offset); glVertex3d(+_dimensions.x + offset, -_dimensions.y - offset, -_dimensions.z - offset); glVertex3d(+_dimensions.x + offset, +_dimensions.y + offset, -_dimensions.z - offset); glVertex3d(-_dimensions.x - offset, +_dimensions.y + offset, -_dimensions.z - offset); glEnd(); // BACK glBegin(GL_LINE_LOOP); glVertex3d(-_dimensions.x - offset, -_dimensions.y - offset, +_dimensions.z + offset); glVertex3d(+_dimensions.x + offset, -_dimensions.y - offset, +_dimensions.z + offset); glVertex3d(+_dimensions.x + offset, +_dimensions.y + offset, +_dimensions.z + offset); glVertex3d(-_dimensions.x - offset, +_dimensions.y + offset, +_dimensions.z + offset); glEnd(); // TOP glBegin(GL_LINE_LOOP); glVertex3d(-_dimensions.x - offset, -_dimensions.y - offset, -_dimensions.z - offset); glVertex3d(+_dimensions.x + offset, -_dimensions.y - offset, -_dimensions.z - offset); glVertex3d(+_dimensions.x + offset, -_dimensions.y - offset, +_dimensions.z + offset); glVertex3d(-_dimensions.x - offset, -_dimensions.y - offset, +_dimensions.z + offset); glEnd(); // BOTTOM glBegin(GL_LINE_LOOP); glVertex3d(-_dimensions.x - offset, +_dimensions.y + offset, -_dimensions.z - offset); glVertex3d(+_dimensions.x + offset, +_dimensions.y + offset, -_dimensions.z - offset); glVertex3d(+_dimensions.x + offset, +_dimensions.y + offset, +_dimensions.z + offset); glVertex3d(-_dimensions.x - offset, +_dimensions.y + offset, +_dimensions.z + offset); glEnd(); // LEFT glBegin(GL_LINE_LOOP); glVertex3d(-_dimensions.x - offset, -_dimensions.y - offset, -_dimensions.z - offset); glVertex3d(-_dimensions.x - offset, -_dimensions.y - offset, +_dimensions.z + offset); glVertex3d(-_dimensions.x - offset, +_dimensions.y + offset, +_dimensions.z + offset); glVertex3d(-_dimensions.x - offset, +_dimensions.y + offset, -_dimensions.z - offset); glEnd(); // RIGHT glBegin(GL_LINE_LOOP); glVertex3d(+_dimensions.x + offset, -_dimensions.y - offset, -_dimensions.z - offset); glVertex3d(+_dimensions.x + offset, -_dimensions.y - offset, +_dimensions.z + offset); glVertex3d(+_dimensions.x + offset, +_dimensions.y + offset, +_dimensions.z + offset); glVertex3d(+_dimensions.x + offset, +_dimensions.y + offset, -_dimensions.z - offset); glEnd(); glEndList(); }
public void initializeDisplayList() { list = glGenLists(1); glNewList(list, GL_COMPILE); { glBegin(GL_TRIANGLES); { // glColor3f(1.0f, 1.0f, 0.0f); for (int i = 0; i < triFaces.size(); i++) { // glColor3f(1.0f, 0.0f, 0.0f); Vector3f n1 = normals.get((int) (triFaces.get(i).normal.x - 1)); glNormal3f(n1.x, n1.y, n1.z); Vector3f v1 = verticies.get((int) (triFaces.get(i).vertex.x - 1)); glVertex3f(v1.x, v1.y, v1.z); // glColor3f(0.0f, 1.0f, 0.0f); Vector3f n2 = normals.get((int) (triFaces.get(i).normal.y - 1)); glNormal3f(n2.x, n2.y, n2.z); Vector3f v2 = verticies.get((int) (triFaces.get(i).vertex.y - 1)); glVertex3f(v2.x, v2.y, v2.z); // glColor3f(0.0f, 0.0f, 1.0f); Vector3f n3 = normals.get((int) (triFaces.get(i).normal.z - 1)); glNormal3f(n3.x, n3.y, n3.z); Vector3f v3 = verticies.get((int) (triFaces.get(i).vertex.z - 1)); glVertex3f(v3.x, v3.y, v3.z); } } glEnd(); glBegin(GL_QUADS); { // glColor3f(1.0f, 0.0f, 0.0f); for (int i = 0; i < quadFaces.size(); i++) { // glColor3f(1.0f, 0.0f, 0.0f); Vector3f n1 = normals.get((int) (quadFaces.get(i).normal.x - 1)); glNormal3f(n1.x, n1.y, n1.z); Vector3f v1 = verticies.get((int) (quadFaces.get(i).vertex.x - 1)); glVertex3f(v1.x, v1.y, v1.z); // glColor3f(0.0f, 1.0f, 0.0f); Vector3f n2 = normals.get((int) (quadFaces.get(i).normal.y - 1)); glNormal3f(n2.x, n2.y, n2.z); Vector3f v2 = verticies.get((int) (quadFaces.get(i).vertex.y - 1)); glVertex3f(v2.x, v2.y, v2.z); // glColor3f(0.0f, 0.0f, 1.0f); Vector3f n3 = normals.get((int) (quadFaces.get(i).normal.z - 1)); glNormal3f(n3.x, n3.y, n3.z); Vector3f v3 = verticies.get((int) (quadFaces.get(i).vertex.z - 1)); glVertex3f(v3.x, v3.y, v3.z); Vector3f n4 = normals.get((int) (quadFaces.get(i).normal.w - 1)); glNormal3f(n4.x, n4.y, n4.z); Vector3f v4 = verticies.get((int) (quadFaces.get(i).vertex.w - 1)); glVertex3f(v4.x, v4.y, v4.z); } } glEnd(); } glEndList(); }
public GCPlutoSkyProvider() { GL11.glPushMatrix(); GL11.glNewList(this.starGLCallList, GL11.GL_COMPILE); this.renderStars(); GL11.glEndList(); GL11.glPopMatrix(); final Tessellator tessellator = Tessellator.instance; this.glSkyList = this.starGLCallList + 1; GL11.glNewList(this.glSkyList, GL11.GL_COMPILE); final byte byte2 = 64; final int i = 256 / byte2 + 2; float f = 16F; for (int j = -byte2 * i; j <= byte2 * i; j += byte2) { for (int l = -byte2 * i; l <= byte2 * i; l += byte2) { tessellator.startDrawingQuads(); tessellator.addVertex(j + 0, f, l + 0); tessellator.addVertex(j + byte2, f, l + 0); tessellator.addVertex(j + byte2, f, l + byte2); tessellator.addVertex(j + 0, f, l + byte2); tessellator.draw(); } } GL11.glEndList(); this.glSkyList2 = this.starGLCallList + 2; GL11.glNewList(this.glSkyList2, GL11.GL_COMPILE); f = -16F; tessellator.startDrawingQuads(); for (int k = -byte2 * i; k <= byte2 * i; k += byte2) { for (int i1 = -byte2 * i; i1 <= byte2 * i; i1 += byte2) { tessellator.addVertex(k + byte2, f, i1 + 0); tessellator.addVertex(k + 0, f, i1 + 0); tessellator.addVertex(k + 0, f, i1 + byte2); tessellator.addVertex(k + byte2, f, i1 + byte2); } } tessellator.draw(); GL11.glEndList(); }
private void compileDisplayList(float f) { displayList = GLAllocation.generateDisplayLists(1); GL11.glNewList(displayList, 4864 /*GL_COMPILE*/); Tessellator tessellator = Tessellator.instance; for (int i = 0; i < faces.length; i++) { faces[i].draw(tessellator, f); } GL11.glEndList(); compiled = true; }
private void preRenderBlocks(int p_147890_1_) { GL11.glNewList(this.glRenderList + p_147890_1_, GL11.GL_COMPILE); GL11.glPushMatrix(); this.setupGLTranslation(); float var2 = 1.000001F; GL11.glTranslatef(-8.0F, -8.0F, -8.0F); GL11.glScalef(var2, var2, var2); GL11.glTranslatef(8.0F, 8.0F, 8.0F); tessellator.startDrawingQuads(); tessellator.setTranslation((double) (-this.posX), (double) (-this.posY), (double) (-this.posZ)); }
/** * Build the character set display list from the given texture. Creates one quad for each * character, with one letter textured onto each quad. Assumes the texture is a 256x256 image * containing every character of the charset arranged in a 16x16 grid. Each character is 16x16 * pixels. Call destroyFont() to release the display list memory. * * <p>Should be in ORTHO (2D) mode to render text (see setOrtho()). * * <p>Special thanks to NeHe and Giuseppe D'Agata for the "2D Texture Font" tutorial * (http://nehe.gamedev.net). * * @param charSetImage texture image containing 100 characters in a 10x10 grid * @param fontWidth how many pixels to allow per character on screen * @see destroyFont() */ public void buildFont(int fontTxtrHandle, int textureSize, int fontSize) { int unitSize = fontSize; // pixel size of one block in 10x10 grid float usize = (float) unitSize / (float) (textureSize); // UV size of // one block in // grid float chU, chV; // character UV position // Create 100 Display Lists fontListBase = GL11.glGenLists(100); // make a quad for each character in texture for (int i = 0; i < 100; i++) { int x = (i % 10); // column int y = (i / 10); // row // make character UV coordinate // the character V position is tricky because we have to invert the // V coord // (char # 0 is at top of texture image, but V 0 is at bottom) chU = (float) (x * unitSize) / (float) textureSize; chV = (float) (y * unitSize) / (float) textureSize; // chV = (float) (textureSize - (y * unitSize) - unitSize) / (float) // textureSize; GL11.glNewList(fontListBase + i, GL11.GL_COMPILE); // start display // list { GL11.glBegin(GL11.GL_QUADS); // Make A unitSize square quad { GL11.glTexCoord2f(chU, chV); // Texture Coord (Bottom Left) GL11.glVertex2i(0, unitSize); GL11.glTexCoord2f(chU + usize, chV); // Texture Coord // (Bottom Right) GL11.glVertex2i(unitSize, unitSize); GL11.glTexCoord2f(chU + usize, chV + usize); // Texture // Coord // (Top // Right) GL11.glVertex2i(unitSize, 0); GL11.glTexCoord2f(chU, chV + usize); // Texture Coord (Top // Left) GL11.glVertex2i(0, 0); } GL11.glEnd(); GL11.glTranslatef(charwidths[i], 0, 0); // shift right the width // of the character } GL11.glEndList(); // done display list } }
public static void initDisplayLists() throws IOException { Main.dl_zombiebody = glGenLists(1); glNewList(Main.dl_zombiebody, GL_COMPILE); zombiebody(); glEndList(); Main.dl_zombiehead = glGenLists(1); glNewList(Main.dl_zombiehead, GL_COMPILE); zombiehead(); glEndList(); Main.dl_bullet = Model.getDL(System.getProperty("user.dir") + "/res/obj/bullet.obj"); Main.dl_grenade = Model.getDL(System.getProperty("user.dir") + "/res/obj/grenade.obj"); Main.dl_cexplosive = Model.getDL(System.getProperty("user.dir") + "/res/obj/item2.obj"); Main.dl_gun = new int[3]; Main.dl_gun[0] = Model.getDL(System.getProperty("user.dir") + "/res/obj/gun0.obj"); Main.dl_gun[1] = Model.getDL(System.getProperty("user.dir") + "/res/obj/gun1.obj"); Main.dl_gun[2] = Model.getDL(System.getProperty("user.dir") + "/res/obj/gun2.obj"); Main.dl_floorandmap = glGenLists(1); glNewList(Main.dl_floorandmap, GL_COMPILE); floor(); new Model(System.getProperty("user.dir") + "/res/map/map.obj").render(); glEndList(); }
public void finishUpdate() { int var1; int var2; int var3; for (var1 = 0; var1 < 2; ++var1) { if (!this.skipRenderPass[var1]) { GL11.glNewList(this.glRenderList + var1, GL11.GL_COMPILE); for (var2 = 0; var2 <= this.activeListIndex[var1]; ++var2) { var3 = this.glWorkLists[this.activeSet][var1][var2]; GL11.glCallList(var3); } GL11.glEndList(); } } if (this.activeSet == 0) { this.activeSet = 1; } else { this.activeSet = 0; } for (var1 = 0; var1 < 2; ++var1) { if (!this.skipRenderPass[var1]) { for (var2 = 0; var2 <= this.activeListIndex[var1]; ++var2) { var3 = this.glWorkLists[this.activeSet][var1][var2]; GL11.glNewList(var3, GL11.GL_COMPILE); GL11.glEndList(); } } } for (var1 = 0; var1 < 2; ++var1) { this.activeListIndex[var1] = 0; } }
public void opengldrawtolist() { this.objectlist = GL11.glGenLists(1); GL11.glNewList(objectlist, GL11.GL_COMPILE); for (int i = 0; i < faces.size(); i++) { int[] tempfaces = (int[]) (faces.get(i)); // TODO magic int[] tempfacesnorms = (int[]) (facesnorms.get(i)); int[] tempfacestexs = (int[]) (facestexs.get(i)); //// Quad Begin Header //// int polytype; if (tempfaces.length == 3) { polytype = GL11.GL_TRIANGLES; } else if (tempfaces.length == 4) { polytype = GL11.GL_QUADS; } else { polytype = GL11.GL_POLYGON; } GL11.glBegin(polytype); //////////////////////////// for (int w = 0; w < tempfaces.length; w++) { if (tempfacesnorms[w] != 0) { float normtempx = ((float[]) vertexsetsnorms.get(tempfacesnorms[w] - 1))[0]; float normtempy = ((float[]) vertexsetsnorms.get(tempfacesnorms[w] - 1))[1]; float normtempz = ((float[]) vertexsetsnorms.get(tempfacesnorms[w] - 1))[2]; GL11.glNormal3f(normtempx, normtempy, normtempz); } if (tempfacestexs[w] != 0) { float textempx = ((float[]) vertexsetstexs.get(tempfacestexs[w] - 1))[0]; float textempy = ((float[]) vertexsetstexs.get(tempfacestexs[w] - 1))[1]; float textempz = ((float[]) vertexsetstexs.get(tempfacestexs[w] - 1))[2]; GL11.glTexCoord3f(textempx, 1f - textempy, textempz); } float tempx = ((float[]) vertexsets.get(tempfaces[w] - 1))[0]; float tempy = ((float[]) vertexsets.get(tempfaces[w] - 1))[1]; float tempz = ((float[]) vertexsets.get(tempfaces[w] - 1))[2]; GL11.glVertex3f(tempx, tempy, tempz); } //// Quad End Footer ///// GL11.glEnd(); /////////////////////////// } GL11.glEndList(); }
static { logger.config("fbo: supported=%s", fboSupported); logger.config("GL13: supported=%s, enabled=%s", gl13Supported, useGL13); int bits = GL11.GL_VIEWPORT_BIT | GL11.GL_SCISSOR_BIT | GL11.GL_DEPTH_BITS | GL11.GL_LIGHTING_BIT; if (useGL13) { bits |= GL13.GL_MULTISAMPLE_BIT; } glAttributes = bits; GL11.glNewList(drawList, GL11.GL_COMPILE); drawBox(); GL11.glEndList(); }
public static void renderSphereGeometry() { if (displayListSphere == -1) { displayListSphere = glGenLists(1); Sphere sphere = new Sphere(); glNewList(displayListSphere, GL11.GL_COMPILE); sphere.draw(1, 8, 8); glEndList(); } glCallList(displayListSphere); }
private void buildList() { glList = GL11.glGenLists(1); GL11.glNewList(glList, GL11.GL_COMPILE); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(0, 0); GL11.glTexCoord2f(texture.getWidth(), 0); GL11.glVertex2f(texture.getImageWidth(), 0); GL11.glTexCoord2f(texture.getWidth(), texture.getHeight()); GL11.glVertex2f(texture.getImageWidth(), texture.getImageHeight()); GL11.glTexCoord2f(0, texture.getHeight()); GL11.glVertex2f(0, texture.getImageHeight()); GL11.glEnd(); GL11.glEndList(); }
/** * @param path Path of the .obj file * @param index GLUint */ public static void name(String path, int index) { int list = glGenLists(index); glNewList(list, GL_COMPILE); { Model m = null; try { m = OBJLoader.loadModel(new File(path)); } catch (FileNotFoundException e) { e.printStackTrace(); Display.destroy(); System.exit(1); } catch (IOException e) { e.printStackTrace(); Display.destroy(); System.exit(1); } float b; // glColor3f(0.3f, 0.20f, 0.13f); b = (float) Math.random(); glColor3f(b, 0, 0); int count = 0; glBegin(GL_TRIANGLES); for (Face face : m.faces) { count++; Vector3f n1 = m.normals.get((int) face.normal.x - 1); glNormal3f(n1.x, n1.y, n1.z); Vector3f v1 = m.vertices.get((int) face.vertex.x - 1); glVertex3f(v1.x, v1.y, v1.z); Vector3f n2 = m.normals.get((int) face.normal.y - 1); glNormal3f(n2.x, n2.y, n2.z); Vector3f v2 = m.vertices.get((int) face.vertex.y - 1); glVertex3f(v2.x, v2.y, v2.z); Vector3f n3 = m.normals.get((int) face.normal.z - 1); glNormal3f(n3.x, n3.y, n3.z); Vector3f v3 = m.vertices.get((int) face.vertex.z - 1); glVertex3f(v3.x, v3.y, v3.z); } glEnd(); System.out.println(count); } glEndList(); }
private void generateDisplayListSolid() { displayListSolid = glGenLists(1); glNewList(displayListSolid, GL11.GL_COMPILE); glBegin(GL_QUADS); glColor4f(solidColor.x, solidColor.y, solidColor.z, solidColor.w); Vector3f dimensions = aabb.getExtents(); GL11.glVertex3f(-dimensions.x, dimensions.y, dimensions.z); GL11.glVertex3f(dimensions.x, dimensions.y, dimensions.z); GL11.glVertex3f(dimensions.x, dimensions.y, -dimensions.z); GL11.glVertex3f(-dimensions.x, dimensions.y, -dimensions.z); GL11.glVertex3f(-dimensions.x, -dimensions.y, -dimensions.z); GL11.glVertex3f(-dimensions.x, -dimensions.y, dimensions.z); GL11.glVertex3f(-dimensions.x, dimensions.y, dimensions.z); GL11.glVertex3f(-dimensions.x, dimensions.y, -dimensions.z); GL11.glVertex3f(-dimensions.x, -dimensions.y, dimensions.z); GL11.glVertex3f(dimensions.x, -dimensions.y, dimensions.z); GL11.glVertex3f(dimensions.x, dimensions.y, dimensions.z); GL11.glVertex3f(-dimensions.x, dimensions.y, dimensions.z); GL11.glVertex3f(dimensions.x, dimensions.y, -dimensions.z); GL11.glVertex3f(dimensions.x, dimensions.y, dimensions.z); GL11.glVertex3f(dimensions.x, -dimensions.y, dimensions.z); GL11.glVertex3f(dimensions.x, -dimensions.y, -dimensions.z); GL11.glVertex3f(-dimensions.x, dimensions.y, -dimensions.z); GL11.glVertex3f(dimensions.x, dimensions.y, -dimensions.z); GL11.glVertex3f(dimensions.x, -dimensions.y, -dimensions.z); GL11.glVertex3f(-dimensions.x, -dimensions.y, -dimensions.z); GL11.glVertex3f(-dimensions.x, -dimensions.y, -dimensions.z); GL11.glVertex3f(dimensions.x, -dimensions.y, -dimensions.z); GL11.glVertex3f(dimensions.x, -dimensions.y, dimensions.z); GL11.glVertex3f(-dimensions.x, -dimensions.y, dimensions.z); glEnd(); glEndList(); }
public static int prepareSquare(int texId, float size) { int list = glGenLists(1); glNewList(list, GL_COMPILE); glDisable(GL_CULL_FACE); glBindTexture(GL_TEXTURE_2D, texId); glTranslatef(-size / 2, -size / 2, 0); // glRotatef(180.0f, 0.0f, 0.0f, 0.0f); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex2f(size, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex2f(size, size); glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, size); glEnd(); glEnable(GL_CULL_FACE); glEndList(); return list; }
public void func_1197_a(int i, int j, int k) { if (i == field_1761_c && j == field_1760_d && k == field_1759_e) { return; } else { func_1195_b(); field_1761_c = i; field_1760_d = j; field_1759_e = k; field_1746_q = i + field_1758_f / 2; field_1743_r = j + field_1757_g / 2; field_1741_s = k + field_1756_h / 2; field_1752_l = i & 0x3ff; field_1751_m = j; field_1750_n = k & 0x3ff; field_1755_i = i - field_1752_l; field_1754_j = j - field_1751_m; field_1753_k = k - field_1750_n; float f = 6F; field_1736_v = AxisAlignedBB.func_1168_a( (float) i - f, (float) j - f, (float) k - f, (float) (i + field_1758_f) + f, (float) (j + field_1757_g) + f, (float) (k + field_1756_h) + f); GL11.glNewList(field_1744_C + 2, 4864); RenderItem.func_142_a( AxisAlignedBB.func_1161_b( (float) field_1752_l - f, (float) field_1751_m - f, (float) field_1750_n - f, (float) (field_1752_l + field_1758_f) + f, (float) (field_1751_m + field_1757_g) + f, (float) (field_1750_n + field_1756_h) + f)); GL11.glEndList(); func_1194_f(); return; } }
private void generateDisplayListSolid() { _displayListSolid = glGenLists(1); glNewList(_displayListSolid, GL11.GL_COMPILE); glBegin(GL_QUADS); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); GL11.glVertex3d(-_dimensions.x, _dimensions.y, _dimensions.z); GL11.glVertex3d(_dimensions.x, _dimensions.y, _dimensions.z); GL11.glVertex3d(_dimensions.x, _dimensions.y, -_dimensions.z); GL11.glVertex3d(-_dimensions.x, _dimensions.y, -_dimensions.z); GL11.glVertex3d(-_dimensions.x, -_dimensions.y, -_dimensions.z); GL11.glVertex3d(-_dimensions.x, -_dimensions.y, _dimensions.z); GL11.glVertex3d(-_dimensions.x, _dimensions.y, _dimensions.z); GL11.glVertex3d(-_dimensions.x, _dimensions.y, -_dimensions.z); GL11.glVertex3d(-_dimensions.x, -_dimensions.y, _dimensions.z); GL11.glVertex3d(_dimensions.x, -_dimensions.y, _dimensions.z); GL11.glVertex3d(_dimensions.x, _dimensions.y, _dimensions.z); GL11.glVertex3d(-_dimensions.x, _dimensions.y, _dimensions.z); GL11.glVertex3d(_dimensions.x, _dimensions.y, -_dimensions.z); GL11.glVertex3d(_dimensions.x, _dimensions.y, _dimensions.z); GL11.glVertex3d(_dimensions.x, -_dimensions.y, _dimensions.z); GL11.glVertex3d(_dimensions.x, -_dimensions.y, -_dimensions.z); GL11.glVertex3d(-_dimensions.x, _dimensions.y, -_dimensions.z); GL11.glVertex3d(_dimensions.x, _dimensions.y, -_dimensions.z); GL11.glVertex3d(_dimensions.x, -_dimensions.y, -_dimensions.z); GL11.glVertex3d(-_dimensions.x, -_dimensions.y, -_dimensions.z); GL11.glVertex3d(-_dimensions.x, -_dimensions.y, -_dimensions.z); GL11.glVertex3d(_dimensions.x, -_dimensions.y, -_dimensions.z); GL11.glVertex3d(_dimensions.x, -_dimensions.y, _dimensions.z); GL11.glVertex3d(-_dimensions.x, -_dimensions.y, _dimensions.z); glEnd(); glEndList(); }
/** * Sets a new position for the renderer and setting it up so it can be reloaded with the new data * for that position */ public void setPosition(int par1, int par2, int par3) { if (par1 != this.posX || par2 != this.posY || par3 != this.posZ) { this.setDontDraw(); this.posX = par1; this.posY = par2; this.posZ = par3; this.posXPlus = par1 + 8; this.posYPlus = par2 + 8; this.posZPlus = par3 + 8; this.posXClip = par1 & 1023; this.posYClip = par2; this.posZClip = par3 & 1023; this.posXMinus = par1 - this.posXClip; this.posYMinus = par2 - this.posYClip; this.posZMinus = par3 - this.posZClip; float var4 = 6.0F; this.rendererBoundingBox = AxisAlignedBB.getBoundingBox( (double) ((float) par1 - var4), (double) ((float) par2 - var4), (double) ((float) par3 - var4), (double) ((float) (par1 + 16) + var4), (double) ((float) (par2 + 16) + var4), (double) ((float) (par3 + 16) + var4)); GL11.glNewList(this.glRenderList + 2, GL11.GL_COMPILE); RenderItem.renderAABB( AxisAlignedBB.getAABBPool() .getAABB( (double) ((float) this.posXClip - var4), (double) ((float) this.posYClip - var4), (double) ((float) this.posZClip - var4), (double) ((float) (this.posXClip + 16) + var4), (double) ((float) (this.posYClip + 16) + var4), (double) ((float) (this.posZClip + 16) + var4))); GL11.glEndList(); this.markDirty(); } }
private static void setUpDisplayLists() { bunnyDisplayList = glGenLists(1); glNewList(bunnyDisplayList, GL_COMPILE); { Model m = null; try { m = OBJLoader.loadModel(new File(MODEL_LOCATION)); } catch (FileNotFoundException e) { e.printStackTrace(); Display.destroy(); System.exit(1); } catch (IOException e) { e.printStackTrace(); Display.destroy(); System.exit(1); } glColor3f(0.4f, 0.27f, 0.17f); glBegin(GL_TRIANGLES); for (Face face : m.faces) { Vector3f n1 = m.normals.get((int) face.normal.x - 1); glNormal3f(n1.x, n1.y, n1.z); Vector3f v1 = m.vertices.get((int) face.vertex.x - 1); glVertex3f(v1.x, v1.y, v1.z); Vector3f n2 = m.normals.get((int) face.normal.y - 1); glNormal3f(n2.x, n2.y, n2.z); Vector3f v2 = m.vertices.get((int) face.vertex.y - 1); glVertex3f(v2.x, v2.y, v2.z); Vector3f n3 = m.normals.get((int) face.normal.z - 1); glNormal3f(n3.x, n3.y, n3.z); Vector3f v3 = m.vertices.get((int) face.vertex.z - 1); glVertex3f(v3.x, v3.y, v3.z); } glEnd(); } glEndList(); }
public void func_1198_a() { if (!field_1738_u) { return; } field_1762_b++; int i = field_1761_c; int j = field_1760_d; int k = field_1759_e; int l = field_1761_c + field_1758_f; int i1 = field_1760_d + field_1757_g; int j1 = field_1759_e + field_1756_h; for (int k1 = 0; k1 < 2; k1++) { field_1748_p[k1] = true; } Chunk.field_1540_a = false; HashSet hashset = new HashSet(); hashset.addAll(field_1745_B); field_1745_B.clear(); int l1 = 1; ChunkCache chunkcache = new ChunkCache(field_1763_a, i - l1, j - l1, k - l1, l + l1, i1 + l1, j1 + l1); RenderBlocks renderblocks = new RenderBlocks(chunkcache); field_40590_G = 0; int i2 = 0; do { if (i2 >= 2) { break; } boolean flag = false; boolean flag1 = false; boolean flag2 = false; for (int j2 = j; j2 < i1; j2++) { for (int k2 = k; k2 < j1; k2++) { for (int l2 = i; l2 < l; l2++) { int i3 = chunkcache.func_600_a(l2, j2, k2); if (i3 <= 0) { continue; } if (!flag2) { flag2 = true; GL11.glNewList(field_1744_C + i2, 4864); GL11.glPushMatrix(); func_1203_g(); float f = 1.000001F; GL11.glTranslatef( (float) (-field_1756_h) / 2.0F, (float) (-field_1757_g) / 2.0F, (float) (-field_1756_h) / 2.0F); GL11.glScalef(f, f, f); GL11.glTranslatef( (float) field_1756_h / 2.0F, (float) field_1757_g / 2.0F, (float) field_1756_h / 2.0F); field_1742_D.func_977_b(); field_1742_D.func_984_b(-field_1761_c, -field_1760_d, -field_1759_e); } if (i2 == 0 && Block.field_342_q[i3]) { TileEntity tileentity = chunkcache.func_603_b(l2, j2, k2); if (TileEntityRenderer.field_1554_a.func_1028_a(tileentity)) { field_1745_B.add(tileentity); } } Block block = Block.field_345_n[i3]; int j3 = block.func_234_g(); if (i2 == 0 && renderblocks.func_35927_a(l2, j2, k2, i2)) { flag1 = true; } if (j3 != i2) { flag = true; continue; } if (j3 == i2) { flag1 |= renderblocks.func_1234_a(block, l2, j2, k2); } } } } if (flag2) { field_40590_G += field_1742_D.func_982_a(); GL11.glPopMatrix(); GL11.glEndList(); field_1742_D.func_984_b(0.0D, 0.0D, 0.0D); } else { flag1 = false; } if (flag1) { field_1748_p[i2] = false; } if (!flag) { break; } i2++; } while (true); HashSet hashset1 = new HashSet(); hashset1.addAll(field_1745_B); hashset1.removeAll(hashset); field_1737_F.addAll(hashset1); hashset.removeAll(field_1745_B); field_1737_F.removeAll(hashset); field_1747_A = Chunk.field_1540_a; field_1739_E = true; }