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.ajgl.graphics.Immediate.java
License:Open Source License
/** * Draws a shape using glBegin / Primitive mode. Adds color and texture to it. * Note that {@code colorValues} should have four values per vertex. * @param beginMode - OpenGL begin mode/* ww w . j a v a2s . c o m*/ * @param textureID - The texture id to be used * @param vertexValues - Array of vertices * @param colorValues - Array of color vertices * @param textureValues - Array of local texture vertices */ @OpenGLInfo(fwdCompatible = false, openGLVersion = "1.1", status = "Deprecated") public static void twoPointdraw(@BeginMode int beginMode, int textureID, float[] vertexValues, float[] colorValues, float[] textureValues) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glBegin(beginMode); for (int i = 0, j = 0; i < vertexValues.length - 1; i += 2, j += 4) { GL11.glColor4f(colorValues[j], colorValues[j + 1], colorValues[j + 2], colorValues[j + 3]); GL11.glTexCoord2f(textureValues[i], textureValues[i + 1]); GL11.glVertex2f(vertexValues[i], vertexValues[i + 1]); } GL11.glEnd(); }
From source file:org.ajgl.graphics.Immediate.java
License:Open Source License
/** * Draws a shape using glBegin / Primitive mode. Adds color and texture to it. * Note that {@code colorValues} should have four values per vertex. * @param beginMode - OpenGL begin mode//from ww w. j a v a2s . com * @param textureID - The texture id to be used * @param vertexValues - Array of vertices * @param colorValues - Array of color vertices * @param textureValues - Array of local texture vertices */ @OpenGLInfo(fwdCompatible = false, openGLVersion = "1.1", status = "Deprecated") public static void threePointdraw(@BeginMode int beginMode, int textureID, float[] vertexValues, float[] colorValues, float[] textureValues) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glBegin(beginMode); for (int i = 0, j = 0, k = 0; i < vertexValues.length - 2; i += 3, j += 4, k += 2) { GL11.glColor4f(colorValues[j], colorValues[j + 1], colorValues[j + 2], colorValues[j + 3]); GL11.glTexCoord2f(textureValues[k], textureValues[k + 1]); GL11.glVertex3f(vertexValues[i], vertexValues[i + 1], vertexValues[i + 2]); } GL11.glEnd(); }
From source file:org.ajgl.graphics.Immediate.java
License:Open Source License
/** * Draws a shape using glBegin / Primitive mode. Adds color and texture to it. * Note that {@code colorValues} should have four values per vertex. * @param beginMode - OpenGL begin mode//from w w w . ja v a 2 s .c o m * @param textureID - The texture id to be used * @param vertexValues - Array of vertices * @param colorValues - Array of color vertices * @param textureValues - Array of local texture vertices */ @OpenGLInfo(fwdCompatible = false, openGLVersion = "1.1", status = "Deprecated") public static void fourPointdraw(@BeginMode int beginMode, int textureID, float[] vertexValues, float[] colorValues, float[] textureValues) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glBegin(beginMode); for (int i = 0, j = 0, k = 0; i < vertexValues.length - 3; i += 4, j += 4, k += 2) { GL11.glColor4f(colorValues[j], colorValues[j + 1], colorValues[j + 2], colorValues[j + 3]); GL11.glTexCoord2f(textureValues[k], textureValues[k + 1]); GL11.glVertex4f(vertexValues[i], vertexValues[i + 1], vertexValues[i + 2], vertexValues[i + 3]); } GL11.glEnd(); }
From source file:org.cogaen.lwjgl.scene.SpriteFxVisual.java
License:Open Source License
@Override public void render() { if (this.flipVertical) { GL11.glScaled(1, -1, 1);/*from www .j a va 2 s . co m*/ } if (this.shadow) { double dx = this.halfWidth * getScale() * 0.02; double dy = this.halfWidth * getScale() * 0.02; GL11.glColor4d(getColor().getRed() * 0.1, getColor().getGreen() * 0.1, getColor().getBlue() * 0.1, 0.7); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0.0f, this.texture.getHeight()); GL11.glVertex2d(-this.halfWidth * getScale() + dx, -this.halfHeight * getScale() - dy); GL11.glTexCoord2f(this.texture.getWidth(), this.texture.getHeight()); GL11.glVertex2d(this.halfWidth * getScale() + dx, -this.halfHeight * getScale() - dy); GL11.glTexCoord2f(this.texture.getWidth(), 0); GL11.glVertex2d(this.halfWidth * getScale() + dx, this.halfHeight * getScale() - dy); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex2d(-this.halfWidth * getScale() + dx, this.halfHeight * getScale() - dy); } getColor().apply(); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0.0f, this.texture.getHeight()); GL11.glVertex2d(-this.halfWidth * getScale(), -this.halfHeight * getScale()); GL11.glTexCoord2f(this.texture.getWidth(), this.texture.getHeight()); GL11.glVertex2d(this.halfWidth * getScale(), -this.halfHeight * getScale()); GL11.glTexCoord2f(this.texture.getWidth(), 0); GL11.glVertex2d(this.halfWidth * getScale(), this.halfHeight * getScale()); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex2d(-this.halfWidth * getScale(), this.halfHeight * getScale()); if (this.mirror) { GL11.glColor4d(getColor().getRed() * 0.7, getColor().getGreen() * 0.7, getColor().getBlue() * 0.7, 0.7); GL11.glTexCoord2f(0.0f, this.texture.getHeight()); GL11.glVertex2d(-this.halfWidth * getScale(), -this.halfHeight * getScale()); GL11.glTexCoord2f(this.texture.getWidth(), this.texture.getHeight()); GL11.glVertex2d(this.halfWidth * getScale(), -this.halfHeight * getScale()); GL11.glColor4d(getColor().getRed(), getColor().getGreen(), getColor().getBlue(), 0); GL11.glTexCoord2f(this.texture.getWidth(), this.texture.getHeight() / 2); GL11.glVertex2d(this.halfWidth * getScale(), -this.halfHeight * 2 * getScale()); GL11.glTexCoord2f(0.0f, this.texture.getHeight() / 2); GL11.glVertex2d(-this.halfWidth * getScale(), -this.halfHeight * 2 * getScale()); } GL11.glEnd(); }
From source file:org.cogaen.lwjgl.scene.SpriteVisual.java
License:Open Source License
@Override public void render() { getColor().apply();// w w w .ja v a 2 s.com if (this.flipVertical) { GL11.glScaled(1, -1, 1); } GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0.0f, this.texture.getHeight()); GL11.glVertex2d(-this.halfWidth * getScale(), -this.halfHeight * getScale()); GL11.glTexCoord2f(this.texture.getWidth(), this.texture.getHeight()); GL11.glVertex2d(this.halfWidth * getScale(), -this.halfHeight * getScale()); GL11.glTexCoord2f(this.texture.getWidth(), 0); GL11.glVertex2d(this.halfWidth * getScale(), this.halfHeight * getScale()); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex2d(-this.halfWidth * getScale(), this.halfHeight * getScale()); GL11.glEnd(); }
From source file:org.craftmania.blocks.CrossedBlockBrush.java
License:Apache License
@Override public void create() { _callList = GL11.glGenLists(1);/* ww w. ja v a 2 s. c o m*/ GL11.glNewList(_callList, GL11.GL_COMPILE); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(_texturePosition.x(), _texturePosition.y()); GL11.glVertex3f(-0.5f, 0.5f, -0.5f); GL11.glTexCoord2f(_texturePosition.x() + _textureSize.x(), _texturePosition.y()); GL11.glVertex3f(0.5f, 0.5f, 0.5f); GL11.glTexCoord2f(_texturePosition.x() + _textureSize.x(), _texturePosition.y() + _textureSize.y()); GL11.glVertex3f(0.5f, -0.5f, 0.5f); GL11.glTexCoord2f(_texturePosition.x(), _texturePosition.y() + _textureSize.y()); GL11.glVertex3f(-0.5f, -0.5f, -0.5f); GL11.glTexCoord2f(_texturePosition.x(), _texturePosition.y()); GL11.glVertex3f(0.5f, 0.5f, -0.5f); GL11.glTexCoord2f(_texturePosition.x() + _textureSize.x(), _texturePosition.y()); GL11.glVertex3f(-0.5f, 0.5f, 0.5f); GL11.glTexCoord2f(_texturePosition.x() + _textureSize.x(), _texturePosition.y() + _textureSize.y()); GL11.glVertex3f(-0.5f, -0.5f, 0.5f); GL11.glTexCoord2f(_texturePosition.x(), _texturePosition.y() + _textureSize.y()); GL11.glVertex3f(0.5f, -0.5f, -0.5f); GL11.glEnd(); GL11.glEndList(); }
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 v a2s .c o m 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 w ww . j a v a 2 s .c om 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.fenggui.binding.render.lwjgl.LWJGLOpenGL.java
License:Open Source License
public void texCoord(float x, float y) { GL11.glTexCoord2f(x, y); }
From source file:org.free.jake2.render.lwjgl.Draw.java
License:Open Source License
protected void Draw_Char(int x, int y, int num) { num &= 255;/* w ww . ja va 2 s. co m*/ if ((num & 127) == 32) { return; // space } if (y <= -8) { return; // totally off screen } int row = num >> 4; int col = num & 15; float frow = row * 0.0625f; float fcol = col * 0.0625f; float size = 0.0625f; GL_Bind(draw_chars.texnum); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(fcol, frow); GL11.glVertex2f(x, y); GL11.glTexCoord2f(fcol + size, frow); GL11.glVertex2f(x + 8, y); GL11.glTexCoord2f(fcol + size, frow + size); GL11.glVertex2f(x + 8, y + 8); GL11.glTexCoord2f(fcol, frow + size); GL11.glVertex2f(x, y + 8); GL11.glEnd(); }