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:tileengine.MenuItem.java
public void drawText() { String sana = text.toLowerCase(); String aakkoset = "abcdefghijklmnopqrstuvwxyz .-_,"; int index = 0; for (int x = 0; x < 37; x++) { int selectedTexture = 0, selectedColumn = 0, selectedRow = 0; if (index < sana.length()) { selectedTexture = 160 + aakkoset.indexOf(sana.charAt(index)); } else {/* w w w . ja v a 2 s. co m*/ selectedTexture = 128; } index++; //pieni hksi for loopin avulla valitun texturen selvittmiseksi for (selectedColumn = selectedTexture; selectedColumn >= GameHandler.spriteSheetX / GameHandler.spriteSheetScale; selectedColumn -= 32) { selectedRow++; } float textureXOffSet = ((float) 1 / GameHandler.spriteSheetScale) * selectedColumn; float textureYOffSet = ((float) 1 / GameHandler.spriteSheetScale) * selectedRow; GL11.glTexCoord2f(textureXOffSet + (float) 1 / GameHandler.spriteSheetScale, textureYOffSet + (float) 1 / GameHandler.spriteSheetScale); GL11.glVertex2f(posX + 111 + x * 16 - sana.length() / 2 * 16, posY + 20 - textOffSet); GL11.glTexCoord2f(textureXOffSet, textureYOffSet + (float) 1 / GameHandler.spriteSheetScale); GL11.glVertex2f(posX + 95 + x * 16 - sana.length() / 2 * 16, posY + 20 - textOffSet); GL11.glTexCoord2f(textureXOffSet, textureYOffSet); GL11.glVertex2f(posX + 95 + x * 16 - sana.length() / 2 * 16, posY + 36 - textOffSet); GL11.glTexCoord2f(textureXOffSet + (float) 1 / GameHandler.spriteSheetScale, textureYOffSet); GL11.glVertex2f(posX + 111 + x * 16 - sana.length() / 2 * 16, posY + 36 - textOffSet); } }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glTexCoord2f(float a, float b) { GL11.glTexCoord2f(a, b); }
From source file:view.Menu.java
public void drawImage() { loadImage();//from w w w. ja va2s . c om Color.white.bind(); texture.bind(); // or GL11.glBind(texture.getTextureID()); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(400, 200); GL11.glTexCoord2f(1, 0); GL11.glVertex2f(1200, 220); GL11.glTexCoord2f(1, 1); GL11.glVertex2f(100 + texture.getTextureWidth(), 80 + texture.getTextureHeight()); GL11.glTexCoord2f(0, 1); GL11.glVertex2f(350, 100 + texture.getTextureHeight()); GL11.glEnd(); }
From source file:wrath.client.graphics.graphics2D.Background.java
License:Open Source License
@Override public void render(boolean consolidated) { if (consolidated) renderSetup();//from ww w . jav a 2 s .co m //Top Left GL11.glTexCoord2f(0, 0); GL11.glVertex3f(-1.0f, 1.0f, 0.0f); //Top Right GL11.glTexCoord2f(1, 0); GL11.glVertex3f(1.0f, 1.0f, 0.0f); //Bottom Right GL11.glTexCoord2f(1, 1); GL11.glVertex3f(1.0f, -1.0f, 0.0f); //Bottom Left GL11.glTexCoord2f(0, 1); GL11.glVertex3f(-1.0f, -1.0f, 0.0f); if (consolidated) renderStop(); }
From source file:wrath.client.graphics.gui.GuiElement.java
License:Open Source License
@Override public void render(boolean consolidated) { if (consolidated) renderSetup();/*from w w w .ja v a 2s . c o m*/ color.bindColor(); GL11.glTexCoord2f(0, 1); GL11.glVertex3f(x, y - h, 0); GL11.glTexCoord2f(1, 1); GL11.glVertex3f(x + w, y - h, 0); GL11.glTexCoord2f(1, 0); GL11.glVertex3f(x + w, y, 0); GL11.glTexCoord2f(0, 0); GL11.glVertex3f(x, y, 0); if (consolidated) renderStop(); }
From source file:wrath.client.graphics.TextRenderer.java
License:Open Source License
/** * Draws the specified string onto the screen at the specified points independent of variables set in this object. * The only variable taken from the object in this method is the font itself. * @param string The {@link java.lang.String} to write to the screen. * @param x The X-coordinate of the top left of the message. * @param y The Y-coordinate of the top left of the message. * @param fontSize The size of the font. This is a NON standardized unit! * @param color The {@link wrath.client.graphics.Color} to make the rendered text. *///w w w.jav a2 s.c o m public void renderString(String string, float x, float y, float fontSize, Color color) { if (string.length() == 0) return; final int gridSize = 16; final float characterWidth = fontSize * 0.1f; final float characterHeight = characterWidth * 0.75f; GL11.glDisable(GL11.GL_DEPTH_TEST); fontTex.bindTexture(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR); float curPos = x; float charWidth; GL11.glBegin(GL11.GL_QUADS); for (int i = 0; i < string.length(); i++) { int ascii = (int) string.charAt(i); final float cellSize = 1.0f / gridSize; float cellX = ((int) ascii % gridSize) * cellSize; float cellY = ((int) ascii / gridSize) * cellSize; color.bindColor(); //(0, 1) bottom left GL11.glTexCoord2f(cellX, cellY + cellSize); GL11.glVertex3f(curPos, y - characterHeight, 0); //(1, 1) bottom right GL11.glTexCoord2f(cellX + cellSize, cellY + cellSize); GL11.glVertex3f(curPos + characterWidth / 2, y - characterHeight, 0); //(1, 0) top right GL11.glTexCoord2f(cellX + cellSize, cellY); GL11.glVertex3f(curPos + characterWidth / 2, y, 0); //(0, 0) top left GL11.glTexCoord2f(cellX, cellY); GL11.glVertex3f(curPos, y, 0); if (spaceMap.containsKey(string.charAt(i))) charWidth = spaceMap.get(string.charAt(i)); else charWidth = 1.0f; curPos = curPos + (charWidth * (fontSize / 48f)); if ((i + 1) < string.length()) { if (spaceMap.containsKey(string.charAt(i + 1))) curPos = curPos + ((spaceMap.get(string.charAt(i + 1)) * (fontSize / 48f)) / 1.6f); else curPos = curPos + (fontSize / 48f) / 3.5f; } } GL11.glEnd(); color.unbindColor(); Texture.unbindTextures(); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_DEPTH_TEST); }
From source file:yk.myengine.optiseq.states.LWJGLFont.java
/** * <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./*from ww w . j a va2 s.c o m*/ */ public void buildDisplayList() { final int displacement = 10; final int symbolWidth = 16; final int symbolHeight = 16; final int symbolNumX = 16; final int symbolNumY = 16; final int symbolNumber = 256; float cx; float cy; final float texSymSizeX = (float) 1 / symbolNumX; final float texSymSizeY = (float) 1 / symbolNumY; base = GL11.glGenLists(symbolNumber); final float addDisY = texSymSizeY / 100; for (int loop = 0; loop < symbolNumber; loop++) { cx = (loop % symbolNumX) * texSymSizeX; cy = (loop / symbolNumY) * texSymSizeX; GL11.glNewList(base + loop, GL11.GL_COMPILE); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(cx, 1 - cy - addDisY); GL11.glVertex2i(0, symbolHeight); GL11.glTexCoord2f(cx, 1 - cy - texSymSizeY + addDisY); GL11.glVertex2i(0, 0); GL11.glTexCoord2f(cx + texSymSizeX, 1 - cy - texSymSizeY + addDisY); GL11.glVertex2i(symbolWidth, 0); GL11.glTexCoord2f(cx + texSymSizeX, 1 - cy - addDisY); GL11.glVertex2i(symbolWidth, symbolHeight); GL11.glEnd(); GL11.glTranslatef(displacement, 0, 0); GL11.glEndList(); } }
From source file:zildo.fwk.gfx.Ortho.java
License:Open Source License
/** * Just draw a textured box, without managing glBegin/glEnd * /*from ww w .j a v a 2 s . c om*/ * @param x * @param y * @param w * @param h * @param u * @param v * @param uw * @param vh */ public void boxTexturedOpti(int x, int y, int p_w, int p_h, float u, float v, float uw, float vh) { GL11.glTexCoord2f(u, v); GL11.glVertex2d(x, y); GL11.glTexCoord2f(u + uw, v); GL11.glVertex2d(x + p_w, y); GL11.glTexCoord2f(u + uw, v + vh); GL11.glVertex2d(x + p_w, y + p_h); GL11.glTexCoord2f(u, v + vh); GL11.glVertex2d(x, y + p_h); }
From source file:zildo.platform.opengl.LwjglOrtho.java
License:Open Source License
/** * Just draw a textured box, without managing glBegin/glEnd * //from w ww.j a v a 2 s . co m * @param x * @param y * @param w * @param h * @param u * @param v * @param uw * @param vh */ @Override public void boxTexturedOpti(int x, int y, int p_w, int p_h, float u, float v, float uw, float vh) { GL11.glTexCoord2f(u, v); GL11.glVertex2d(x, y); GL11.glTexCoord2f(u + uw, v); GL11.glVertex2d(x + p_w, y); GL11.glTexCoord2f(u + uw, v + vh); GL11.glVertex2d(x + p_w, y + p_h); GL11.glTexCoord2f(u, v + vh); GL11.glVertex2d(x, y + p_h); }