List of usage examples for org.lwjgl.opengl GL11 glTexCoord2f
public static native void glTexCoord2f(@NativeType("GLfloat") float s, @NativeType("GLfloat") float t);
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;//from ww w . j ava 2 s .c om 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; } }
From source file:org.joge.core.draw.Image.java
License:Open Source License
public void drawWithOutLoadIdentity(float xpos, float ypos) { GL11.glTranslatef(x + xpos, y + ypos, 0); GL11.glBegin(GL11.GL_QUADS);/* w w w .j a va2 s . c om*/ { 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(); }
From source file:org.jtrfp.mtmx.draw.ModelDrawer.java
License:Open Source License
public void draw() { IBinData binData = model.getBinData(); IBinVertex[] vertexes = binData.getVertexes(); IBinFace[] faces = binData.getFaces(); GL11.glPushMatrix();/*from w w w . j ava2s. co m*/ if (translation != null) { GL11.glTranslatef(translation.getX(), translation.getY(), translation.getZ()); } if (scale != null) { GL11.glScalef(scale.getX(), scale.getY(), scale.getZ()); } if (rotationAxis != null) { GL11.glRotatef(rotationAngle, rotationAxis.getX(), rotationAxis.getY(), rotationAxis.getZ()); } float n = 1.0f / 65536; for (int i = 0; i < faces.length; i++) { IBinFace face = faces[i]; ITextureManager textureManager = engine.getResourceManager().getTextureManager(); ITexture texture = textureManager.get(face.getTextureName()); texture.bind(); IBinVertex normal = face.getNormal(); GL11.glBegin(renderMode); IBinTexCoord[] coords = face.getTexCoords(); for (int j = coords.length - 1; j >= 0; j--) { IBinTexCoord coord = coords[j]; IBinVertex vertex = vertexes[coord.getVertexIndex()]; GL11.glNormal3f(-normal.getX() * n, normal.getY() * n, normal.getZ() * n); GL11.glTexCoord2f(coord.getU(), coord.getV()); GL11.glVertex3f(-vertex.getX() * IDrawer.SCALE, vertex.getY() * IDrawer.SCALE, vertex.getZ() * IDrawer.SCALE); } GL11.glEnd(); } GL11.glPopMatrix(); }
From source file:org.meanworks.engine.scene.Node.java
License:Open Source License
public static void drawCube(float w, float h, float l) { final float minx = -(w / 2); final float miny = -(h / 2); final float minz = -(l / 2); final float maxx = (w / 2); final float maxy = (h / 2); final float maxz = (l / 2); // Quad 1/* ww w . j a va2s.c om*/ GL11.glNormal3f(1, 0, 0); GL11.glTexCoord2f(0, 1); GL11.glVertex3f(maxx, maxy, maxz); // V2 GL11.glTexCoord2f(0, 0); GL11.glVertex3f(maxx, miny, maxz); // V1 GL11.glTexCoord2f(1, 0); GL11.glVertex3f(maxx, miny, minz); // V3 GL11.glTexCoord2f(1, 1); GL11.glVertex3f(maxx, maxy, minz); // V4 // Quad 2 GL11.glNormal3f(0, 0, -1); GL11.glTexCoord2f(0, 1); GL11.glVertex3f(maxx, maxy, minz); // V4 GL11.glTexCoord2f(0, 0); GL11.glVertex3f(maxx, miny, minz); // V3 GL11.glTexCoord2f(1, 0); GL11.glVertex3f(minx, miny, minz); // V5 GL11.glTexCoord2f(1, 1); GL11.glVertex3f(minx, maxy, minz); // V6 // Quad 3 GL11.glNormal3f(-1, 0, 0); GL11.glTexCoord2f(0, 1); GL11.glVertex3f(minx, maxy, minz); // V6 GL11.glTexCoord2f(0, 0); GL11.glVertex3f(minx, miny, minz); // V5 GL11.glTexCoord2f(1, 0); GL11.glVertex3f(minx, miny, maxz); // V7 GL11.glTexCoord2f(1, 1); GL11.glVertex3f(minx, maxy, maxz); // V8 // Quad 4 GL11.glNormal3f(0, 0, 1); GL11.glTexCoord2f(0, 1); GL11.glVertex3f(minx, maxy, maxz); // V8 GL11.glTexCoord2f(0, 0); GL11.glVertex3f(minx, miny, maxz); // V7 GL11.glTexCoord2f(1, 0); GL11.glVertex3f(maxx, miny, maxz); // V1 GL11.glTexCoord2f(1, 1); GL11.glVertex3f(maxx, maxy, maxz); // V2 // Quad 5 GL11.glNormal3f(0, 1, 0); GL11.glTexCoord2f(0, 1); GL11.glVertex3f(minx, maxy, minz); // V6 GL11.glTexCoord2f(0, 0); GL11.glVertex3f(minx, maxy, maxz); // V8 GL11.glTexCoord2f(1, 0); GL11.glVertex3f(maxx, maxy, maxz); // V2 GL11.glTexCoord2f(1, 1); GL11.glVertex3f(maxx, maxy, minz); // V4 // Quad 6 GL11.glNormal3f(0, -1, 0); GL11.glTexCoord2f(0, 1); GL11.glVertex3f(minx, miny, maxz); // V7 GL11.glTexCoord2f(0, 0); GL11.glVertex3f(minx, miny, minz); // V5 GL11.glTexCoord2f(1, 0); GL11.glVertex3f(maxx, miny, minz); // V3 GL11.glTexCoord2f(1, 1); GL11.glVertex3f(maxx, miny, maxz); // V1 }
From source file:org.minetweak.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 (currentGui != null) { Game.getInstance().renderTransculentOverlayLayer(); currentGui.render(); } 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) { Inventory.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.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void drawSphereShadow(float px, float py, float pz, float radius) { // calculate shadow constants based on light vector if (!init) {/*from w ww . j a v a 2 s . c o m*/ len2 = LIGHTX * LIGHTX + LIGHTZ * LIGHTZ; len1 = 1.0f / (float) Math.sqrt(len2); scale = (float) Math.sqrt(len2 + 1); init = true; } // map sphere center to ground plane based on light vector px -= LIGHTX * py; pz -= LIGHTZ * py; final float kx = 0.96592582628907f; final float kz = 0.25881904510252f; float x = radius, z = 0; GL11.glBegin(GL11.GL_TRIANGLE_FAN); for (int i = 0; i < 24; i++) { // for all points on circle, scale to elongated rotated shadow and draw float x2 = (LIGHTX * x * scale - LIGHTZ * z) * len1 + px; float z2 = (LIGHTZ * x * scale + LIGHTX * z) * len1 + pz; GL11.glTexCoord2f(x2 * ground_scale + ground_ofsx, z2 * ground_scale + ground_ofsz); GL11.glVertex3f(x2, 0, z2); // rotate [x,y] vector float xtmp = kx * x - kz * z; z = kz * x + kx * z; x = xtmp; } GL11.glEnd(); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void drawSky(float[] view_xyz) { GL11.glDisable(GL11.GL_LIGHTING);// ww w .j a v a2s.c o m if (use_textures) { GL11.glEnable(GL11.GL_TEXTURE_2D); sky_texture.bind(false); } else { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor3f(0f, 0.5f, 1.0f); } // make sure sky depth is as far back as possible GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDepthRange(1, 1); final float ssize = 1000.0f; float x = ssize * sky_scale; float y = view_xyz[1] + sky_height; GL11.glBegin(GL11.GL_QUADS); GL11.glNormal3f(0, -1, 0); GL11.glTexCoord2f(x + offset, -x + offset); GL11.glVertex3f(ssize + view_xyz[0], y, -ssize + view_xyz[2]); GL11.glTexCoord2f(x + offset, x + offset); GL11.glVertex3f(ssize + view_xyz[0], y, ssize + view_xyz[2]); GL11.glTexCoord2f(-x + offset, x + offset); GL11.glVertex3f(-ssize + view_xyz[0], y, ssize + view_xyz[2]); GL11.glTexCoord2f(-x + offset, -x + offset); GL11.glVertex3f(-ssize + view_xyz[0], y, -ssize + view_xyz[2]); GL11.glEnd(); offset = offset + 0.002f; if (offset > 1) offset -= 1; GL11.glDepthFunc(GL11.GL_LESS); GL11.glDepthRange(0, 1); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void drawGround() { GL11.glDisable(GL11.GL_LIGHTING);/*from w w w . j a v a 2s. co m*/ GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); // GL11.glDepthRange (1,1); if (use_textures) { GL11.glEnable(GL11.GL_TEXTURE_2D); ground_texture.bind(false); } else { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor3f(GROUND_R, GROUND_G, GROUND_B); } // ground fog seems to cause problems with TNT2 under windows /* GLfloat fogColor[4] = {0.5, 0.5, 0.5, 1}; GL11.glEnable (GL_FOG); GL11.glFogi (GL_FOG_MODE, GL_EXP2); GL11.glFogfv (GL_FOG_COLOR, fogColor); GL11.glFogf (GL_FOG_DENSITY, 0.05f); GL11.glHint (GL_FOG_HINT, GL_NICEST); // GL_DONT_CARE); GL11.glFogf (GL_FOG_START, 1.0); GL11.glFogf (GL_FOG_END, 5.0); */ final float gsize = 100.0f; final float offset = 0; // -0.001f; ... polygon offsetting doesn't work well GL11.glBegin(GL11.GL_QUADS); GL11.glNormal3f(0, 1, 0); GL11.glTexCoord2f(-gsize * ground_scale + ground_ofsx, gsize * ground_scale + ground_ofsz); GL11.glVertex3f(-gsize, offset, gsize); GL11.glTexCoord2f(gsize * ground_scale + ground_ofsx, gsize * ground_scale + ground_ofsz); GL11.glVertex3f(gsize, offset, gsize); GL11.glTexCoord2f(gsize * ground_scale + ground_ofsx, -gsize * ground_scale + ground_ofsz); GL11.glVertex3f(gsize, offset, -gsize); GL11.glTexCoord2f(-gsize * ground_scale + ground_ofsx, -gsize * ground_scale + ground_ofsz); GL11.glVertex3f(-gsize, offset, -gsize); GL11.glEnd(); GL11.glDisable(GL11.GL_FOG); }
From source file:org.spout.engine.batcher.GL11SpriteBatch.java
License:Open Source License
public void render() { GL11.glDisable(GL11.GL_DEPTH_TEST);/*from w w w. j a va 2 s . c om*/ for (int i = 0; i < sprites.size(); i++) { RenderPart rect = sprites.get(i); rect.getRenderMaterial().getShader().setUniform("View", this.view); rect.getRenderMaterial().getShader().setUniform("Projection", this.projection); rect.getRenderMaterial().getShader().setUniform("Model", this.view); //View is always an identity matrix. rect.getRenderMaterial().assign(); GL11.glBegin(GL11.GL_TRIANGLES); float r = (float) rect.getColor().getRed() / 255f; float g = (float) rect.getColor().getGreen() / 255f; float b = (float) rect.getColor().getBlue() / 255f; float a = (float) rect.getColor().getAlpha() / 255f; GL11.glColor4f(r, g, b, a); GL11.glTexCoord2f(rect.getSource().getX(), rect.getSource().getY()); GL11.glVertex3f(rect.getSprite().getX(), rect.getSprite().getY() + rect.getSprite().getHeight(), 0.f); GL11.glColor4f(r, g, b, a); GL11.glTexCoord2f(rect.getSource().getX(), rect.getSource().getY() + rect.getSource().getHeight()); GL11.glVertex3f(rect.getSprite().getX(), rect.getSprite().getY(), 0.f); GL11.glColor4f(r, g, b, a); GL11.glTexCoord2f(rect.getSource().getX() + rect.getSource().getWidth(), rect.getSource().getY() + rect.getSource().getHeight()); GL11.glVertex3f(rect.getSprite().getX() + rect.getSprite().getWidth(), rect.getSprite().getY(), 0.f); GL11.glColor4f(r, g, b, a); GL11.glTexCoord2f(rect.getSource().getX(), rect.getSource().getY()); GL11.glVertex3f(rect.getSprite().getX(), rect.getSprite().getY() + rect.getSprite().getHeight(), 0.f); GL11.glColor4f(r, g, b, a); GL11.glTexCoord2f(rect.getSource().getX() + rect.getSource().getWidth(), rect.getSource().getY() + rect.getSource().getHeight()); GL11.glVertex3f(rect.getSprite().getX() + rect.getSprite().getWidth(), rect.getSprite().getY(), 0.f); GL11.glColor4f(r, g, b, a); GL11.glTexCoord2f(rect.getSource().getX() + rect.getSource().getWidth(), rect.getSource().getY()); GL11.glVertex3f(rect.getSprite().getX() + rect.getSprite().getWidth(), rect.getSprite().getY() + rect.getSprite().getHeight(), 0.f); GL11.glEnd(); } GL11.glEnable(GL11.GL_DEPTH_TEST); }
From source file:org.terasology.componentSystem.BlockParticleEmitterSystem.java
License:Apache License
private void drawParticle(byte blockType) { Block b = BlockManager.getInstance().getBlock(blockType); glBegin(GL_QUADS);// w w w . j a v a 2 s . c om GL11.glTexCoord2f(b.getTextureOffsetFor(BlockPart.FRONT).x, b.getTextureOffsetFor(BlockPart.FRONT).y); GL11.glVertex3f(-0.5f, -0.5f, 0.0f); GL11.glTexCoord2f(b.getTextureOffsetFor(BlockPart.FRONT).x + TEX_SIZE, b.getTextureOffsetFor(BlockPart.FRONT).y); GL11.glVertex3f(0.5f, -0.5f, 0.0f); GL11.glTexCoord2f(b.getTextureOffsetFor(BlockPart.FRONT).x + TEX_SIZE, b.getTextureOffsetFor(BlockPart.FRONT).y + TEX_SIZE); GL11.glVertex3f(0.5f, 0.5f, 0.0f); GL11.glTexCoord2f(b.getTextureOffsetFor(BlockPart.FRONT).x, b.getTextureOffsetFor(BlockPart.FRONT).y + TEX_SIZE); GL11.glVertex3f(-0.5f, 0.5f, 0.0f); glEnd(); }