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:rntest.Board.java
public void drawUpsideDown() { bgtexflipped.bind();/*ww w .j a va 2s .co m*/ GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(0, 0); GL11.glTexCoord2f(1, 0); GL11.glVertex2f(Display.getWidth(), 0); GL11.glTexCoord2f(1, 1); GL11.glVertex2f(Display.getWidth(), Display.getHeight()); GL11.glTexCoord2f(0, 1); GL11.glVertex2f(0, Display.getHeight()); GL11.glEnd(); for (int i = 0; i < pieces.size(); i++) { for (int j = 0; j < pieces.get(i).size(); j++) { if (pieces.get(i).get(j) != null) ((Piece) pieces.get(i).get(j)).draw(this.sX + (this.bX + this.wX) * ((this.width - 1) - j), this.sY + (this.bY + this.wY) * ((this.height - 1) - i), this.wX, this.wY); } } }
From source file:rntest.Main.java
/** * renders the game/*from w ww . ja v a 2s . c om*/ */ public void render() { Color.white.bind(); gBoard.draw(); // gBoard.drawUpsideDown(); float lx = pointToScale(440), vx = pointToScale(-2), py = pointToScale(934), py2 = pointToScale(4), pwidth = pointToScale(75), pheight = pointToScale(83), pbuff = pointToScale(-13); for (int i = 0; i < 4; i++) { //447, 934 link //5, 934 virus //67 1017 int ind1 = Arrays.binarySearch(sideProgression, SIDE_YELLOW); int ind2 = Arrays.binarySearch(sideProgression, SIDE_BLUE); if (links[ind1][i] != 0) { textureLinks[Arrays.binarySearch(sideProgression, links[ind1][i])].bind(); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(lx + (pwidth + pbuff) * i, py); GL11.glTexCoord2f(1, 0); GL11.glVertex2f(lx + (pwidth + pbuff) * i + pwidth, py); GL11.glTexCoord2f(1, 1); GL11.glVertex2f(lx + (pwidth + pbuff) * i + pwidth, py + pheight); GL11.glTexCoord2f(0, 1); GL11.glVertex2f(lx + (pwidth + pbuff) * i, py + pheight); GL11.glEnd(); } if (viruses[ind1][i] != 0) { textureViruses[Arrays.binarySearch(sideProgression, viruses[ind1][i])].bind(); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(vx + (pwidth + pbuff) * i, py); GL11.glTexCoord2f(1, 0); GL11.glVertex2f(vx + (pwidth + pbuff) * i + pwidth, py); GL11.glTexCoord2f(1, 1); GL11.glVertex2f(vx + (pwidth + pbuff) * i + pwidth, py + pheight); GL11.glTexCoord2f(0, 1); GL11.glVertex2f(vx + (pwidth + pbuff) * i, py + pheight); GL11.glEnd(); } if (links[ind2][i] != 0) { textureLinks[Arrays.binarySearch(sideProgression, links[ind2][i])].bind(); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 1); GL11.glVertex2f(vx + (pwidth + pbuff) * i, py2); GL11.glTexCoord2f(1, 1); GL11.glVertex2f(vx + (pwidth + pbuff) * i + pwidth, py2); GL11.glTexCoord2f(1, 0); GL11.glVertex2f(vx + (pwidth + pbuff) * i + pwidth, py2 + pheight); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(vx + (pwidth + pbuff) * i, py2 + pheight); GL11.glEnd(); } if (viruses[ind2][i] != 0) { textureViruses[Arrays.binarySearch(sideProgression, viruses[ind2][i])].bind(); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 1); GL11.glVertex2f(lx + (pwidth + pbuff) * i, py2); GL11.glTexCoord2f(1, 1); GL11.glVertex2f(lx + (pwidth + pbuff) * i + pwidth, py2); GL11.glTexCoord2f(1, 0); GL11.glVertex2f(lx + (pwidth + pbuff) * i + pwidth, py2 + pheight); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(lx + (pwidth + pbuff) * i, py2 + pheight); GL11.glEnd(); } //lx+=lx; } }
From source file:rntest.Piece.java
public void draw(float x, float y, float width, float height) { (faceUp ? textureF : textureB).bind(); GL11.glBegin(GL11.GL_QUADS);/*w w w . j a v a2s . c o m*/ GL11.glTexCoord2f(0, 0); GL11.glVertex2f(x, y); GL11.glTexCoord2f(1, 0); GL11.glVertex2f(x + width, y); GL11.glTexCoord2f(1, 1); GL11.glVertex2f(x + width, y + height); GL11.glTexCoord2f(0, 1); GL11.glVertex2f(x, y + height); GL11.glEnd(); }
From source file:rtype.entity.Missile.java
License:Open Source License
public void draw() { animationCursor += animationSpeed * tick; animationCursor %= animationTextures.length; GL11.glLoadIdentity();/*from w w w . j a va 2 s . co m*/ GL11.glTranslatef(position.x, position.y, Prototyp.DEFAULT_Z); // Translate Into/Out Of The Screen By z GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.animationTextures[(int) animationCursor].getTextureId()); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glBegin(GL11.GL_QUADS); { GL11.glTexCoord2f(textureRight, textureUp); //Upper right GL11.glVertex2f(width, -height); GL11.glTexCoord2f(textureLeft, textureUp); //Upper left GL11.glVertex2f(-width, -height); GL11.glTexCoord2f(textureLeft, textureDown); //Lower left GL11.glVertex2f(-width, height); GL11.glTexCoord2f(textureRight, textureDown); // Lower right GL11.glVertex2f(width, height); } GL11.glEnd(); }
From source file:rtype.Prototyp.java
License:Open Source License
private void applyDistorsions() { if (player1 == null) return;//from w w w .java 2 s . c o m float chargeP = player1.power / PlayerShip.MAX_POWER; float R_WIDTH = 350 * chargeP; float R_HEIGHT = 200 * chargeP; float MIDDLE_X_ON_SCREEN = R_WIDTH / 2 * chargeP; float R_POSITION_X = player1.position.x + 25; float R_POSITION_Y = player1.position.y - R_HEIGHT / 2; float TEXT_OUT_X_LOW = (R_POSITION_X + (SCREEN_WIDTH / 2f)) / 1024f; float TEXT_OUT_X_HIGH = (R_POSITION_X + R_WIDTH + (SCREEN_WIDTH / 2f)) / 1024; float TEXT_OUT_Y_LOW = (R_POSITION_Y + (SCREEN_HEIGHT / 2f)) / 1024; float TEXT_OUT_Y_HIGH = (R_POSITION_Y + R_HEIGHT + (SCREEN_HEIGHT / 2f)) / 1024; float TEXT_IN_X_LOW = (R_POSITION_X + R_WIDTH / 2 + (SCREEN_WIDTH / 2f)) / 1024f; float TEXT_IN_X_HIGH = (R_POSITION_X + R_WIDTH / 2 + 1 + (SCREEN_WIDTH / 2f)) / 1024; float TEXT_IN_Y_LOW = (R_POSITION_Y + R_HEIGHT / 2 + (SCREEN_HEIGHT / 2f)) / 1024f; float TEXT_IN_Y_HIGH = (R_POSITION_Y + R_HEIGHT / 2 + 1 + (SCREEN_HEIGHT / 2f)) / 1024; float SCR_OUT_X_LOW = R_POSITION_X; float SCR_OUT_X_HIGH = R_POSITION_X + R_WIDTH; float SCR_OUT_Y_LOW = R_POSITION_Y; float SCR_OUT_Y_HIGH = R_POSITION_Y + R_HEIGHT; float SCR_IN_X_LOW = R_POSITION_X + MIDDLE_X_ON_SCREEN; float SCR_IN_X_HIGH = R_POSITION_X + MIDDLE_X_ON_SCREEN + 1; float SCR_IN_Y_LOW = R_POSITION_Y + R_HEIGHT / 2; float SCR_IN_Y_HIGH = R_POSITION_Y + R_HEIGHT / 2 + 1; GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1, 1, 1, 0.75f); GL11.glBegin(GL11.GL_QUADS); { GL11.glTexCoord2f(TEXT_IN_X_HIGH, TEXT_IN_Y_HIGH); GL11.glVertex2f(SCR_IN_X_HIGH, SCR_IN_Y_HIGH); // Lower right GL11.glTexCoord2f(TEXT_OUT_X_HIGH, TEXT_OUT_Y_HIGH); GL11.glVertex2f(SCR_OUT_X_HIGH, SCR_OUT_Y_HIGH); //Lower left GL11.glTexCoord2f(TEXT_OUT_X_HIGH, TEXT_OUT_Y_LOW); GL11.glVertex2f(SCR_OUT_X_HIGH, SCR_OUT_Y_LOW); //upper left GL11.glTexCoord2f(TEXT_IN_X_HIGH, TEXT_IN_Y_LOW); GL11.glVertex2f(SCR_IN_X_HIGH, SCR_IN_Y_LOW); // //upper right } GL11.glEnd(); GL11.glBegin(GL11.GL_QUADS); { GL11.glTexCoord2f(TEXT_IN_X_HIGH, TEXT_IN_Y_LOW); GL11.glVertex2f(SCR_IN_X_HIGH, SCR_IN_Y_LOW); // Lower right GL11.glTexCoord2f(TEXT_OUT_X_HIGH, TEXT_OUT_Y_LOW); GL11.glVertex2f(SCR_OUT_X_HIGH, SCR_OUT_Y_LOW); //Lower left GL11.glTexCoord2f(TEXT_OUT_X_LOW, TEXT_OUT_Y_LOW); GL11.glVertex2f(SCR_OUT_X_LOW, SCR_OUT_Y_LOW); //upper left GL11.glTexCoord2f(TEXT_IN_X_LOW, TEXT_IN_Y_LOW); GL11.glVertex2f(SCR_IN_X_LOW, SCR_IN_Y_LOW); // //upper right } GL11.glEnd(); GL11.glBegin(GL11.GL_QUADS); { GL11.glTexCoord2f(TEXT_IN_X_LOW, TEXT_IN_Y_LOW); GL11.glVertex2f(SCR_IN_X_LOW, SCR_IN_Y_LOW); // Lower right GL11.glTexCoord2f(TEXT_OUT_X_LOW, TEXT_OUT_Y_HIGH); GL11.glVertex2f(SCR_OUT_X_LOW, SCR_OUT_Y_HIGH); //Lower left GL11.glTexCoord2f(TEXT_OUT_X_HIGH, TEXT_OUT_Y_HIGH); GL11.glVertex2f(SCR_OUT_X_HIGH, SCR_OUT_Y_HIGH); //upper left GL11.glTexCoord2f(TEXT_IN_X_HIGH, TEXT_IN_Y_HIGH); GL11.glVertex2f(SCR_IN_X_HIGH, SCR_IN_Y_HIGH); // //upper right } GL11.glEnd(); GL11.glBegin(GL11.GL_QUADS); { GL11.glTexCoord2f(TEXT_IN_X_LOW, TEXT_IN_Y_LOW); GL11.glVertex2f(SCR_IN_X_LOW, SCR_IN_Y_LOW); // Lower right GL11.glTexCoord2f(TEXT_OUT_X_LOW, TEXT_OUT_Y_LOW); GL11.glVertex2f(SCR_OUT_X_LOW, SCR_OUT_Y_LOW); //Lower left GL11.glTexCoord2f(TEXT_OUT_X_LOW, TEXT_OUT_Y_HIGH); GL11.glVertex2f(SCR_OUT_X_LOW, SCR_OUT_Y_HIGH); //upper left GL11.glTexCoord2f(TEXT_IN_X_LOW, TEXT_IN_Y_HIGH); GL11.glVertex2f(SCR_IN_X_LOW, SCR_IN_Y_HIGH); // //upper right } GL11.glEnd(); //GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE); GL11.glColor4f(1, 1, 1, 1); }
From source file:rtype.Prototyp.java
License:Open Source License
private void renderScanLines() { GL11.glLoadIdentity();/*www.ja v a2 s . com*/ GL11.glTranslatef(0, 0, Prototyp.DEFAULT_Z); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureLoader.getTexture(IEntity.SCANLINE).getTextureId()); GL11.glColor4f(1, 1, 1, 1); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(20, 0); //Upper right GL11.glVertex2f(SCREEN_WIDTH / 4, -SCREEN_HEIGHT / 4); GL11.glTexCoord2f(0, 0); //Upper left GL11.glVertex2f(-SCREEN_WIDTH / 4, -SCREEN_HEIGHT / 4); GL11.glTexCoord2f(0, 20); //Lower left GL11.glVertex2f(-SCREEN_WIDTH / 4, SCREEN_HEIGHT / 4); GL11.glTexCoord2f(20, 20); // Lower right GL11.glVertex2f(SCREEN_WIDTH / 4, SCREEN_HEIGHT / 4); GL11.glEnd(); }
From source file:shadowmage.ancient_framework.client.gui.elements.GuiScrollBarSimple.java
License:Open Source License
protected void renderQuad(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float u1, float v1, float u2, float v2, float u3, float v3, float u4, float v4) { GL11.glBegin(GL11.GL_QUADS);/*from w ww. jav a2 s.co m*/ GL11.glTexCoord2f(u1, v1); GL11.glVertex3f(x1, y1, 0); GL11.glTexCoord2f(u2, v2); GL11.glVertex3f(x2, y2, 0); GL11.glTexCoord2f(u3, v3); GL11.glVertex3f(x3, y3, 0); GL11.glTexCoord2f(u4, v4); GL11.glVertex3f(x4, y4, 0); GL11.glEnd(); }
From source file:shadowmage.ancient_framework.client.model.PrimitiveBox.java
License:Open Source License
@Override protected void renderForDisplayList() { float tw = parent.getModel().textureWidth; float th = parent.getModel().textureHeight; float px = 1.f / tw; float py = 1.f / th; float w = (x2 - x1) * 16.f; float h = (y2 - y1) * 16.f; float l = (z2 - z1) * 16.f; float ty = this.ty(); float tx = this.tx(); float tx1, ty1, tx2, ty2; //render the cube. only called a single time when building the display list for a piece if (rx != 0) { GL11.glRotatef(rx, 1, 0, 0);/*from w ww . j a v a2 s . co m*/ } if (ry != 0) { GL11.glRotatef(ry, 0, 1, 0); } if (rz != 0) { GL11.glRotatef(rz, 0, 0, 1); } GL11.glBegin(GL11.GL_QUADS); AWLog.logDebug("tx, ty: " + tx + "," + ty); AWLog.logDebug("w,l,h: " + w + "," + l + "," + h); //front side tx1 = (tx + l) * px; ty1 = (th - (ty + l + h)) * py; tx2 = (tx + l + w) * px; ty2 = (th - (ty + l)) * py; GL11.glNormal3f(0, 0, 1); GL11.glTexCoord2f(tx1, ty1); GL11.glVertex3f(x1, y1, z2); GL11.glTexCoord2f(tx2, ty1); GL11.glVertex3f(x2, y1, z2); GL11.glTexCoord2f(tx2, ty2); GL11.glVertex3f(x2, y2, z2); GL11.glTexCoord2f(tx1, ty2); GL11.glVertex3f(x1, y2, z2); AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2)); ////rear side tx1 = (tx + l + l + w) * px; ty1 = (th - (ty + l + h)) * py; tx2 = (tx + l + w + l + w) * px; ty2 = (th - (ty + l)) * py; GL11.glNormal3f(0, 0, -1); GL11.glTexCoord2f(tx1, ty1); GL11.glVertex3f(x2, y1, z1); GL11.glTexCoord2f(tx2, ty1); GL11.glVertex3f(x1, y1, z1); GL11.glTexCoord2f(tx2, ty2); GL11.glVertex3f(x1, y2, z1); GL11.glTexCoord2f(tx1, ty2); GL11.glVertex3f(x2, y2, z1); AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2)); //right side tx1 = (tx + l + w) * px; ty1 = (th - (ty + l + h)) * py; tx2 = (tx + l + w + l) * px; ty2 = (th - (ty + l)) * py; GL11.glNormal3f(1, 0, 0); GL11.glTexCoord2f(tx1, ty1); GL11.glVertex3f(x1, y1, z1); GL11.glTexCoord2f(tx2, ty1); GL11.glVertex3f(x1, y1, z2); GL11.glTexCoord2f(tx2, ty2); GL11.glVertex3f(x1, y2, z2); GL11.glTexCoord2f(tx1, ty2); GL11.glVertex3f(x1, y2, z1); AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2)); // //left side tx1 = (tx) * px; ty1 = (th - (ty + l + h)) * py; tx2 = (tx + l) * px; ty2 = (th - (ty + l)) * py; GL11.glNormal3f(-1, 0, 0); GL11.glTexCoord2f(tx1, ty1); GL11.glVertex3f(x2, y1, z2); GL11.glTexCoord2f(tx2, ty1); GL11.glVertex3f(x2, y1, z1); GL11.glTexCoord2f(tx2, ty2); GL11.glVertex3f(x2, y2, z1); GL11.glTexCoord2f(tx1, ty2); GL11.glVertex3f(x2, y2, z2); AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2)); // //top side tx1 = (tx + l) * px; ty1 = (th - (ty + l)) * py; tx2 = (tx + l + w) * px; ty2 = (th - (ty)) * py; GL11.glNormal3f(0, 1, 0); GL11.glTexCoord2f(tx1, ty1); GL11.glVertex3f(x2, y2, z1); GL11.glTexCoord2f(tx2, ty1); GL11.glVertex3f(x1, y2, z1); GL11.glTexCoord2f(tx2, ty2); GL11.glVertex3f(x1, y2, z2); GL11.glTexCoord2f(tx1, ty2); GL11.glVertex3f(x2, y2, z2); AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2)); // //bottom side tx1 = (tx + l + w) * px; ty1 = (th - (ty + l)) * py; tx2 = (tx + l + w + w) * px; ty2 = (th - (ty)) * py; GL11.glNormal3f(0, -1, 0); GL11.glTexCoord2f(tx1, ty1); GL11.glVertex3f(x2, y1, z2); GL11.glTexCoord2f(tx2, ty1); GL11.glVertex3f(x1, y1, z2); GL11.glTexCoord2f(tx2, ty2); GL11.glVertex3f(x1, y1, z1); GL11.glTexCoord2f(tx1, ty2); GL11.glVertex3f(x2, y1, z1); AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2)); GL11.glEnd(); }
From source file:shadowmage.ancient_framework.client.model.PrimitiveQuad.java
License:Open Source License
@Override protected void renderForDisplayList() { float tw = parent.getModel().textureWidth; float th = parent.getModel().textureHeight; float px = 1.f / tw; float py = 1.f / th; float w = (x2 - x1) * 16.f; float l = 1.f;//TODO fix this for proper texture handling float h = (y2 - y1) * 16.f; float ty = this.ty(); float tx = this.tx(); float tx1, ty1, tx2, ty2; //render the cube. only called a single time when building the display list for a piece if (rx != 0) { GL11.glRotatef(rx, 1, 0, 0);//from w w w. j a va 2 s .com } if (ry != 0) { GL11.glRotatef(ry, 0, 1, 0); } if (rz != 0) { GL11.glRotatef(rz, 0, 0, 1); } GL11.glBegin(GL11.GL_QUADS); AWLog.logDebug("tx, ty: " + tx + "," + ty); AWLog.logDebug("w,l,h: " + w + "," + h); // AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2)); //front side tx1 = (tx + l) * px; ty1 = (th - (ty + l + h)) * py; tx2 = (tx + l + w) * px; ty2 = (th - (ty + l)) * py; GL11.glNormal3f(0, 0, 1); GL11.glTexCoord2f(tx1, ty1); GL11.glVertex3f(x1, y1, 0.f); GL11.glTexCoord2f(tx2, ty1); GL11.glVertex3f(x2, y1, 0.f); GL11.glTexCoord2f(tx2, ty2); GL11.glVertex3f(x2, y2, 0.f); GL11.glTexCoord2f(tx1, ty2); GL11.glVertex3f(x1, y2, 0.f); GL11.glEnd(); }
From source file:shadowmage.ancient_framework.client.model.PrimitiveTriangle.java
License:Open Source License
@Override protected void renderForDisplayList() { if (rx != 0) { GL11.glRotatef(rx, 1, 0, 0);/* w ww .java 2 s . c om*/ } if (ry != 0) { GL11.glRotatef(ry, 0, 1, 0); } if (rz != 0) { GL11.glRotatef(rz, 0, 0, 1); } float tw = parent.getModel().textureWidth; float th = parent.getModel().textureHeight; float px = 1.f / tw; float py = 1.f / th; float u1, v1, u2, v2, u3, v3; u1 = this.u1 * px + this.tx() * px; u2 = this.u2 * px + this.tx() * px; u3 = this.u3 * px + this.tx() * px; v1 = this.v1 * py + this.ty() * py; v2 = this.v2 * py + this.ty() * py; v3 = this.v3 * py + this.ty() * py; GL11.glBegin(GL11.GL_TRIANGLE_STRIP); GL11.glNormal3f(normalX, normalY, normalZ); GL11.glTexCoord2f(u1, v1); GL11.glVertex3f(x1, y1, z1); GL11.glTexCoord2f(u2, v2); GL11.glVertex3f(x2, y2, z2); GL11.glTexCoord2f(u3, v3); GL11.glVertex3f(x3, y3, z3); GL11.glEnd(); }