List of usage examples for org.lwjgl.opengl GL11 glEnd
public static native void glEnd();
From source file:de.keyle.dungeoncraft.editor.editors.world.render.Renderer.java
License:Open Source License
/** * Renders a somewhat-arbitrary vertical rectangle. Pass in (x, z) pairs for the endpoints, * and information about the height. The texture variables given are in terms of 1/16ths of * the texture square, which means that for the default Minecraft 16x16 texture, they're in * pixels.// w w w . j a v a 2 s.c om * * @param x1 * @param z1 * @param x2 * @param z2 * @param y The lower part of the rectangle * @param height Height of the rectangle. */ public static void renderVertical(float tx, float ty, float tdx, float tdy, float x1, float z1, float x2, float z2, float y, float height) { GL11.glBegin(GL11.GL_TRIANGLE_STRIP); GL11.glTexCoord2f(tx, ty); GL11.glVertex3f(x1, y + height, z1); GL11.glTexCoord2f(tx + tdx, ty); GL11.glVertex3f(x2, y + height, z2); GL11.glTexCoord2f(tx, ty + tdy); GL11.glVertex3f(x1, y, z1); GL11.glTexCoord2f(tx + tdx, ty + tdy); GL11.glVertex3f(x2, y, z2); GL11.glEnd(); }
From source file:de.keyle.dungeoncraft.editor.editors.world.render.Renderer.java
License:Open Source License
/** * Renders an arbitrary horizontal rectangle (will be orthogonal). The texture parameters * are specified in terms of 1/16ths of the texture (which equates to one pixel, when using * the default 16x16 Minecraft texture.//from w ww . ja v a 2 s . c o m * * @param x1 * @param z1 * @param x2 * @param z2 * @param y */ public static void renderHorizontal(float x1, float z1, float x2, float z2, float y, float tex_start_x, float tex_start_y, float tex_width, float tex_height, boolean flip_tex) { GL11.glBegin(GL11.GL_TRIANGLE_STRIP); if (flip_tex) { GL11.glTexCoord2f(tex_start_x, tex_start_y); GL11.glVertex3f(x1, y, z2); GL11.glTexCoord2f(tex_start_x + tex_width, tex_start_y); GL11.glVertex3f(x2, y, z2); GL11.glTexCoord2f(tex_start_x, tex_start_y + tex_height); GL11.glVertex3f(x1, y, z1); GL11.glTexCoord2f(tex_start_x + tex_width, tex_start_y + tex_height); GL11.glVertex3f(x2, y, z1); } else { GL11.glTexCoord2f(tex_start_x, tex_start_y); GL11.glVertex3f(x1, y, z1); GL11.glTexCoord2f(tex_start_x + tex_width, tex_start_y); GL11.glVertex3f(x1, y, z2); GL11.glTexCoord2f(tex_start_x, tex_start_y + tex_height); GL11.glVertex3f(x2, y, z1); GL11.glTexCoord2f(tex_start_x + tex_width, tex_start_y + tex_height); GL11.glVertex3f(x2, y, z2); } GL11.glEnd(); }
From source file:de.keyle.dungeoncraft.editor.editors.world.render.Renderer.java
License:Open Source License
/** * Renders a nonstandard horizontal rectangle (nonstandard referring primarily to * the texture size (ie: when we're not pulling a single element out of a 16x16 * grid)./* w w w . ja v a 2 s. c o m*/ * * @param tx X index within the texture * @param ty Y index within the texture * @param tdx Width of texture * @param tdy Height of texture * @param x1 * @param z1 * @param x2 * @param z2 * @param y */ public static void renderNonstandardHorizontal(float tx, float ty, float tdx, float tdy, float x1, float z1, float x2, float z2, float y) { GL11.glBegin(GL11.GL_TRIANGLE_STRIP); GL11.glTexCoord2f(tx, ty); GL11.glVertex3f(x1, y, z1); GL11.glTexCoord2f(tx + tdx, ty); GL11.glVertex3f(x1, y, z2); GL11.glTexCoord2f(tx, ty + tdy); GL11.glVertex3f(x2, y, z1); GL11.glTexCoord2f(tx + tdx, ty + tdy); GL11.glVertex3f(x2, y, z2); GL11.glEnd(); }
From source file:de.keyle.dungeoncraft.editor.editors.world.render.Renderer.java
License:Open Source License
/** * Render a surface on a horizontal plane; pass in all four verticies. This can result, * obviously, in non-rectangular and non-orthogonal shapes. * * @param tx/*from w ww . j a v a 2s. c o m*/ * @param ty * @param tdx * @param tdy * @param x1 * @param z1 * @param x2 * @param z2 * @param x3 * @param z3 * @param x4 * @param z4 * @param y */ public static void renderHorizontalAskew(float tx, float ty, float tdx, float tdy, float x1, float z1, float x2, float z2, float x3, float z3, float x4, float z4, float y) { GL11.glBegin(GL11.GL_TRIANGLE_STRIP); GL11.glTexCoord2f(tx, ty); GL11.glVertex3f(x1, y, z1); GL11.glTexCoord2f(tx + tdx, ty); GL11.glVertex3f(x2, y, z2); GL11.glTexCoord2f(tx, ty + tdy); GL11.glVertex3f(x3, y, z3); GL11.glTexCoord2f(tx + tdx, ty + tdy); GL11.glVertex3f(x4, y, z4); GL11.glEnd(); }
From source file:de.keyle.dungeoncraft.editor.editors.world.render.Renderer.java
License:Open Source License
/** * Renders a block sized face with the given facing. * * @param dimensions Texture dimensions/* w w w. j a v a2s .c om*/ * @param x * @param y * @param z * @param facing The face that should be drawn */ public static void renderBlockFace(TextureDimensions dimensions, float x, float y, float z, Facing facing) { float curFace[][]; switch (facing) { case UP: curFace = new float[][] { { 0f, 1f, 1f }, { 0f, 1f, 0f }, { 1f, 1f, 1f }, { 1f, 1f, 0f } }; break; case DOWN: curFace = new float[][] { { 0f, 0f, 1f }, { 0f, 0f, 0f }, { 1f, 0f, 1f }, { 1f, 0f, 0f } }; break; case NORTH: curFace = new float[][] { { 0f, 1f, 0f }, { 1f, 1f, 0f }, { 0f, 0f, 0f }, { 1f, 0f, 0f } }; break; case SOUTH: curFace = new float[][] { { 0f, 1f, 1f }, { 1f, 1f, 1f }, { 0f, 0f, 1f }, { 1f, 0f, 1f } }; break; case WEST: curFace = new float[][] { { 0f, 1f, 1f }, { 0f, 1f, 0f }, { 0f, 0f, 1f }, { 0f, 0f, 0f } }; break; case EAST: curFace = new float[][] { { 1f, 1f, 1f }, { 1f, 1f, 0f }, { 1f, 0f, 1f }, { 1f, 0f, 0f } }; break; default: return; } GL11.glBegin(GL11.GL_TRIANGLE_STRIP); GL11.glTexCoord2f(dimensions.getTexLeft(), dimensions.getTexTop()); GL11.glVertex3f(x + curFace[0][0], y + curFace[0][1], z + curFace[0][2]); GL11.glTexCoord2f(dimensions.getTexLeft() + dimensions.getTexWidth(), dimensions.getTexTop()); GL11.glVertex3f(x + curFace[1][0], y + curFace[1][1], z + curFace[1][2]); GL11.glTexCoord2f(dimensions.getTexLeft(), dimensions.getTexTop() + dimensions.getTexHeight()); GL11.glVertex3f(x + curFace[2][0], y + curFace[2][1], z + curFace[2][2]); GL11.glTexCoord2f(dimensions.getTexLeft() + dimensions.getTexWidth(), dimensions.getTexTop() + dimensions.getTexHeight()); GL11.glVertex3f(x + curFace[3][0], y + curFace[3][1], z + curFace[3][2]); GL11.glEnd(); }
From source file:de.kitsunealex.projectx.client.render.RenderTruncatedIcosahedron.java
License:Open Source License
private void generate() { int[] s = { 1, -1 }; for (int i = 0; i < 4; i++) { VERTS[i] = new Vector3(0D, s[(i / 2)], s[(i % 2)] * 3 * MathHelper.phi); }//from w ww.j a v a 2s . c o m for (int i = 0; i < 8; i++) { VERTS[(i + 4)] = new Vector3(s[(i / 4)] * 2, s[(i / 2 % 2)] * 4.2360679999999995D, s[(i % 2)] * MathHelper.phi); VERTS[(i + 12)] = new Vector3(s[(i / 4)], s[(i / 2 % 2)] * 3.6180339999999998D, s[(i % 2)] * 2 * MathHelper.phi); } for (int i = 0; i < 20; i++) { VERTS[(i + 20)] = new Vector3(VERTS[i].y, VERTS[i].z, VERTS[i].x); VERTS[(i + 40)] = new Vector3(VERTS[i].z, VERTS[i].x, VERTS[i].y); } LIST_INDEX = GL11.glGenLists(2); GL11.glNewList(LIST_INDEX, GL11.GL_COMPILE); GL11.glBegin(GL11.GL_LINE_BIT); for (int rot = 0; rot < 3; rot++) { for (int i = 0; i < 4; i++) { pentagon(rot, i); } } GL11.glEnd(); GL11.glEndList(); GL11.glNewList(LIST_INDEX + 1, GL11.GL_COMPILE); GL11.glBegin(GL11.GL_LINE_BIT); for (int rot = 0; rot < 3; rot++) { for (int i = 0; i < 4; i++) { hexagon1(rot, i); } } for (int i = 0; i < 8; i++) { hexagon2(i); } GL11.glEnd(); GL11.glEndList(); }
From source file:displayexample.Entities.Box2D.java
@Override public void draw() { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // set the color of the quad (R,G,B,A) GL11.glColor3f(0.5f, 0.5f, 1.0f);// ww w . ja v a2 s . c o m // draw quad GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(x, y); GL11.glVertex2f(x + size, y); GL11.glVertex2f(x + size, y + size); GL11.glVertex2f(x, y + size); GL11.glEnd(); }
From source file:dripdisplay.DripDisplayLWJGL.java
private void drawTile(Rectangle bounds, Rectangle2D.Float r) { GL11.glBegin(GL11.GL_QUADS);/*www . j a v a 2s.co m*/ GL11.glTexCoord2f(r.x, r.y + r.height); GL11.glVertex2f(bounds.getX(), bounds.getY() + bounds.getHeight()); GL11.glTexCoord2f(r.x + r.width, r.y + r.height); GL11.glVertex2f(bounds.getX() + bounds.getWidth(), bounds.getY() + bounds.getHeight()); GL11.glTexCoord2f(r.x + r.width, r.y); GL11.glVertex2f(bounds.getX() + bounds.getWidth(), bounds.getY()); GL11.glTexCoord2f(r.x, r.y); GL11.glVertex2f(bounds.getX(), bounds.getY()); GL11.glEnd(); }
From source file:eb.core.gui.GuiHelper.java
License:LGPL
public static void drawTexturedRect(int x, int y, int width, int height, int textureSize, int[] u, int[] v) { float uf[] = new float[] { (float) u[0] / (float) textureSize, (float) u[1] / (float) textureSize }; float vf[] = new float[] { (float) v[0] / (float) textureSize, (float) v[1] / (float) textureSize }; GL11.glBegin(GL11.GL_QUADS);//from ww w .j a v a 2 s .c om GL11.glTexCoord2f(uf[0], vf[0]); GL11.glVertex2i(x, y); GL11.glTexCoord2f(uf[0], vf[1]); GL11.glVertex2i(x, y + height); GL11.glTexCoord2f(uf[1], vf[1]); GL11.glVertex2i(x + width, y + height); GL11.glTexCoord2f(uf[1], vf[0]); GL11.glVertex2i(x + width, y); GL11.glEnd(); }
From source file:edu.csun.ecs.cs.multitouchj.ui.control.FramedControl.java
License:Apache License
public void render() { // render with no texture Texture texture = getTexture();//from w w w .j a v a2s . c om setTexture((Texture) null); GL11.glPushMatrix(); GL11.glLoadIdentity(); super.render(); GL11.glPopMatrix(); setTexture(texture); // rendering texture if ((!isVisible()) || (texture == null)) { return; } Size controlSize = getSize(); Size imageSize = texture.getImage().getSize(); float margin = getMargin(); if ((margin >= controlSize.getWidth()) || (margin >= controlSize.getHeight())) { margin = 0.0f; } Color color = getColor(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(((float) color.getRed() / 255.0f), ((float) color.getGreen() / 255.0f), ((float) color.getBlue() / 255.0f), getOpacity()); Point position = getOpenGlPosition(); float halfWidth = (controlSize.getWidth() / 2.0f); float halfHeight = (controlSize.getHeight() / 2.0f); GL11.glTranslatef(position.getX(), position.getY(), 0.0f); float rotation = OpenGlUtility.getOpenGlRotation(getRotation()); GL11.glRotatef(rotation, 0.0f, 0.0f, 1.0f); // render texture GL11.glEnable(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT); GL11.glBindTexture(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT, texture.getId().intValue()); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(((-1 * halfWidth) + margin), ((-1 * halfHeight) + margin), 0.0f); GL11.glTexCoord2f(imageSize.getWidth(), 0.0f); GL11.glVertex3f((halfWidth - margin), ((-1 * halfHeight) + margin), 0.0f); GL11.glTexCoord2f(imageSize.getWidth(), imageSize.getHeight()); GL11.glVertex3f((halfWidth - margin), (halfHeight - margin), 0.0f); GL11.glTexCoord2f(0.0f, imageSize.getHeight()); GL11.glVertex3f(((-1 * halfWidth) + margin), (halfHeight - margin), 0.0f); GL11.glEnd(); }