List of usage examples for org.lwjgl.opengl GL11 glVertex2i
public static native void glVertex2i(@NativeType("GLint") int x, @NativeType("GLint") int y);
From source file:name.martingeisse.stackd.client.gui.element.FillColor.java
License:Open Source License
@Override protected void draw() { GL11.glDisable(GL11.GL_TEXTURE_2D);/* w w w . j av a 2 s .c om*/ GL11.glEnable(GL11.GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); color.glColor(); int x = getAbsoluteX(), y = getAbsoluteY(), w = getWidth(), h = getHeight(); GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glVertex2i(x, y); GL11.glVertex2i(x + w, y); GL11.glVertex2i(x + w, y + h); GL11.glVertex2i(x, y + h); GL11.glEnd(); }
From source file:name.martingeisse.stackd.client.gui.element.FillTexture.java
License:Open Source License
@Override protected void draw() { GL11.glEnable(GL11.GL_TEXTURE_2D);/*from w ww . ja va 2s.c o m*/ GL11.glDisable(GL11.GL_BLEND); texture.glBindTexture(); final int x = getAbsoluteX(), y = getAbsoluteY(), w = getWidth(), h = getHeight(); final Gui gui = getGui(); final float effectiveRepetitionLengthX = (repetitionLengthX < 1 ? gui.pixelsToUnitsInt(texture.getWidth()) : repetitionLengthX); final float effectiveRepetitionLengthY = (repetitionLengthY < 1 ? gui.pixelsToUnitsInt(texture.getHeight()) : repetitionLengthY); final float s = (w / effectiveRepetitionLengthX); final float t = (h / effectiveRepetitionLengthY); GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255); GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex2i(x, y); GL11.glTexCoord2f(s, 0.0f); GL11.glVertex2i(x + w, y); GL11.glTexCoord2f(s, t); GL11.glVertex2i(x + w, y + h); GL11.glTexCoord2f(0.0f, t); GL11.glVertex2i(x, y + h); GL11.glEnd(); }
From source file:name.martingeisse.stackd.client.gui.element.PulseFillColor.java
License:Open Source License
@Override protected void draw() { GL11.glDisable(GL11.GL_TEXTURE_2D);// ww w .j a v a2 s. com GL11.glEnable(GL11.GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); color.glColorWithCombinedAlpha(pulseFunction.evaluate(getGui().getTime(), period)); final int x = getAbsoluteX(), y = getAbsoluteY(), w = getWidth(), h = getHeight(); GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glVertex2i(x, y); GL11.glVertex2i(x + w, y); GL11.glVertex2i(x + w, y + h); GL11.glVertex2i(x, y + h); GL11.glEnd(); }
From source file:name.martingeisse.stackd.client.gui.element.ThickBorder.java
License:Open Source License
@Override public void handleEvent(GuiEvent event) { requireWrappedElement();//from w ww . jav a2s .c o m getWrappedElement().handleEvent(event); if (event == GuiEvent.DRAW) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); color.glColor(); int sizeDelta = getGui().pixelsToUnitsInt(thickness); int borderOffset = sizeDelta / 2; int x = getAbsoluteX() + borderOffset; int y = getAbsoluteY() + borderOffset; int w = getWidth() - sizeDelta; int h = getHeight() - sizeDelta; GL11.glLineWidth(thickness); GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glVertex2i(x, y); GL11.glVertex2i(x + w, y); GL11.glVertex2i(x + w, y + h); GL11.glVertex2i(x, y + h); GL11.glVertex2i(x, y); GL11.glEnd(); } }
From source file:name.martingeisse.stackd.client.gui.element.ThinBorder.java
License:Open Source License
@Override public void handleEvent(GuiEvent event) { requireWrappedElement();//from w w w .j a va 2 s . c o m getWrappedElement().handleEvent(event); if (event == GuiEvent.DRAW) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); color.glColor(); int x = getAbsoluteX(), y = getAbsoluteY(), w = getWidth(), h = getHeight(); GL11.glLineWidth(thickness); GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glVertex2i(x, y); GL11.glVertex2i(x + w, y); GL11.glVertex2i(x + w, y + h); GL11.glVertex2i(x, y + h); GL11.glVertex2i(x, y); GL11.glEnd(); } }
From source file:name.martingeisse.swtlib.canvas.OpenGlImageBlockCanvas.java
License:Open Source License
@Override protected void drawBlock(final int x, final int y) { palette.safeBind(getBlock(x, y));/* w ww . j a v a 2 s.c o m*/ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); // glBegin/glEnd must be called per block because of changing textures GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex2i(x, y); GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex2i(x + 1, y); GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex2i(x + 1, y + 1); GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex2i(x, y + 1); GL11.glEnd(); }
From source file:net.kubin.rendering.GLFont.java
License:Apache License
/** * Build the character set display list from the given texture. Creates one * quad for each character, with one letter textured onto each quad. Assumes * the texture is a 256x256 image containing every character of the charset * arranged in a 16x16 grid. Each character is 16x16 pixels. Call * destroyFont() to release the display list memory. * * Should be in ORTHO (2D) mode to render text (see setOrtho()). * * Special thanks to NeHe and Giuseppe D'Agata for the "2D Texture Font" * tutorial (http://nehe.gamedev.net)./*from w w w .j ava 2 s. c o m*/ * * @param charSetImage * texture image containing 100 characters in a 10x10 grid * @param fontWidth * how many pixels to allow per character on screen * * @see destroyFont() */ public void buildFont(int fontTxtrHandle, int textureSize, int fontSize) { int unitSize = fontSize; // pixel size of one block in 10x10 grid float usize = (float) unitSize / (float) (textureSize); // UV size of // one block in // grid float chU, chV; // character UV position // Create 100 Display Lists fontListBase = GL11.glGenLists(100); // make a quad for each character in texture for (int i = 0; i < 100; i++) { int x = (i % 10); // column int y = (i / 10); // row // make character UV coordinate // the character V position is tricky because we have to invert the // V coord // (char # 0 is at top of texture image, but V 0 is at bottom) chU = (float) (x * unitSize) / (float) textureSize; chV = (float) (y * unitSize) / (float) textureSize; // chV = (float) (textureSize - (y * unitSize) - unitSize) / (float) // textureSize; GL11.glNewList(fontListBase + i, GL11.GL_COMPILE); // start display // list { GL11.glBegin(GL11.GL_QUADS); // Make A unitSize square quad { GL11.glTexCoord2f(chU, chV); // Texture Coord (Bottom Left) GL11.glVertex2i(0, unitSize); GL11.glTexCoord2f(chU + usize, chV); // Texture Coord // (Bottom Right) GL11.glVertex2i(unitSize, unitSize); GL11.glTexCoord2f(chU + usize, chV + usize); // Texture // Coord // (Top // Right) GL11.glVertex2i(unitSize, 0); GL11.glTexCoord2f(chU, chV + usize); // Texture Coord (Top // Left) GL11.glVertex2i(0, 0); } GL11.glEnd(); GL11.glTranslatef(charwidths[i], 0, 0); // shift right the width // of the character } GL11.glEndList(); // done display list } }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
public void drawLine(int x1, int y1, int x2, int y2, float r, float g, float b, float a) { GL11.glDisable(GL11.GL_TEXTURE_2D);//from w w w .ja v a 2s .co m GL11.glColor4f(r, g, b, a); GL11.glBegin(GL11.GL_LINES); GL11.glVertex2i(x1, y1); GL11.glVertex2i(x2, y2); GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glColor4f(1, 1, 1, 1); }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
public void drawLine(int x1, int y1, int x2, int y2) { GL11.glDisable(GL11.GL_TEXTURE_2D);/* www.j a v a 2s.c o m*/ GL11.glBegin(GL11.GL_LINES); GL11.glVertex2i(x1, y1); GL11.glVertex2i(x2, y2); GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
public void drawBox(int x1, int y1, int x2, int y2, float r, float g, float b, float a) { GL11.glDisable(GL11.GL_TEXTURE_2D);/* w w w . j a v a2 s. c o m*/ GL11.glColor4f(r, g, b, a); GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glVertex2i(x1, y1); GL11.glVertex2i(x2, y1); GL11.glVertex2i(x2, y2); GL11.glVertex2i(x1, y2); GL11.glVertex2i(x1, y1); GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glColor4f(1, 1, 1, 1); }