List of usage examples for org.lwjgl.opengl GL11 glVertex2f
public static native void glVertex2f(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y);
From source file:com.damagedearth.Utilities.Components.TrueTypeFont.java
License:Open Source License
private void drawQuad(float drawX, float drawY, float drawX2, float drawY2, float srcX, float srcY, float srcX2, float srcY2) { float DrawWidth = drawX2 - drawX; float DrawHeight = drawY2 - drawY; float TextureSrcX = srcX / textureWidth; float TextureSrcY = srcY / textureHeight; float SrcWidth = srcX2 - srcX; float SrcHeight = srcY2 - srcY; float RenderWidth = (SrcWidth / textureWidth); float RenderHeight = (SrcHeight / textureHeight); GL11.glTexCoord2f(TextureSrcX, TextureSrcY); GL11.glVertex2f(drawX, drawY); GL11.glTexCoord2f(TextureSrcX, TextureSrcY + RenderHeight); GL11.glVertex2f(drawX, drawY + DrawHeight); GL11.glTexCoord2f(TextureSrcX + RenderWidth, TextureSrcY + RenderHeight); GL11.glVertex2f(drawX + DrawWidth, drawY + DrawHeight); GL11.glTexCoord2f(TextureSrcX + RenderWidth, TextureSrcY); GL11.glVertex2f(drawX + DrawWidth, drawY); }
From source file:com.darkcart.xdolf.util.RenderUtils.java
License:Open Source License
public static void drawStrip(int x, int y, float width, double angle, float points, float radius, int color) { GL11.glPushMatrix();// ww w .j a v a2 s . c o m float f1 = (float) (color >> 24 & 255) / 255.0F; float f2 = (float) (color >> 16 & 255) / 255.0F; float f3 = (float) (color >> 8 & 255) / 255.0F; float f4 = (float) (color & 255) / 255.0F; GL11.glTranslatef(x, y, 0); GL11.glColor4f(f2, f3, f4, f1); GL11.glLineWidth(width); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); GL11.glEnable(GL13.GL_MULTISAMPLE); if (angle > 0) { GL11.glBegin(GL11.GL_LINE_STRIP); for (int i = 0; i < angle; i++) { float a = (float) (i * (angle * Math.PI / points)); float xc = (float) (Math.cos(a) * radius); float yc = (float) (Math.sin(a) * radius); GL11.glVertex2f(xc, yc); } GL11.glEnd(); } if (angle < 0) { GL11.glBegin(GL11.GL_LINE_STRIP); for (int i = 0; i > angle; i--) { float a = (float) (i * (angle * Math.PI / points)); float xc = (float) (Math.cos(a) * -radius); float yc = (float) (Math.sin(a) * -radius); GL11.glVertex2f(xc, yc); } GL11.glEnd(); } GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_LINE_SMOOTH); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL13.GL_MULTISAMPLE); GL11.glDisable(GL11.GL_MAP1_VERTEX_3); GL11.glPopMatrix(); }
From source file:com.darkcart.xdolf.util.RenderUtils.java
License:Open Source License
public static void drawCircle(float cx, float cy, float r, int num_segments, int c) { GL11.glScalef(0.5F, 0.5F, 0.5F);//from w w w . j av a2 s . com r *= 2; cx *= 2; cy *= 2; float f = (float) (c >> 24 & 0xff) / 255F; float f1 = (float) (c >> 16 & 0xff) / 255F; float f2 = (float) (c >> 8 & 0xff) / 255F; float f3 = (float) (c & 0xff) / 255F; float theta = (float) (2 * 3.1415926 / (num_segments)); float p = (float) Math.cos(theta);//calculate the sine and cosine float s = (float) Math.sin(theta); float t; GL11.glColor4f(f1, f2, f3, f); float x = r; float y = 0;//start at angle = 0 GL11.glEnable(3042); GL11.glDisable(3553); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glBlendFunc(770, 771); GL11.glBegin(GL11.GL_LINE_LOOP); for (int ii = 0; ii < num_segments; ii++) { GL11.glVertex2f(x + cx, y + cy);//final vertex vertex //rotate the stuff t = x; x = p * x - s * y; y = s * t + p * y; } GL11.glEnd(); GL11.glEnable(3553); GL11.glDisable(3042); GL11.glDisable(GL11.GL_LINE_SMOOTH); GL11.glScalef(2F, 2F, 2F); }
From source file:com.dbi.games.fortress.engine.graphics.Sprite.java
public void draw(int x, int y) { if (tex == null) return;//from w w w .ja va2 s .com GL11.glPushMatrix(); tex.bind(); GL11.glTranslatef(x, y, 0); GL11.glBegin(GL11.GL_QUADS); { GL11.glTexCoord2f(0, 0); GL11.glVertex2f(0, 0); GL11.glTexCoord2f(0, 1f); GL11.glVertex2f(0, getHeight()); GL11.glTexCoord2f(1f, 1f); GL11.glVertex2f(getWidth(), getHeight()); GL11.glTexCoord2f(1f, 0); GL11.glVertex2f(getWidth(), 0); } GL11.glEnd(); GL11.glPopMatrix(); }
From source file:com.gameminers.mav.render.Rendering.java
License:Open Source License
public static void drawRectangle(float x, float y, float width, float height, float r, float g, float b, float a, float z) { GL11.glPushMatrix();/*from w w w . ja v a2 s . c om*/ GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glTranslatef(0, 0, z); GL11.glColor4f(r, g, b, a); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(x, y); GL11.glVertex2f(x + width, y); GL11.glVertex2f(x + width, y + height); GL11.glVertex2f(x, y + height); GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glPopMatrix(); }
From source file:com.golden.gamedev.engine.lwjgl.LWJGLGraphics.java
License:Open Source License
/** ************************************************************************* */ public boolean drawImage(Image img, int x, int y, ImageObserver observer) { this.startPainting(); // store the current model matrix GL11.glPushMatrix();/*from w w w. j a va2 s . c o m*/ // bind to the appropriate texture for this sprite Texture texture = this.textureLoader.getTexture((BufferedImage) img); texture.bind(); // translate to the right location and prepare to draw GL11.glTranslatef(x, y, 0); // draw a quad textured to match the sprite GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(0, 0); GL11.glTexCoord2f(0, texture.getHeight()); GL11.glVertex2f(0, texture.getImageHeight()); GL11.glTexCoord2f(texture.getWidth(), texture.getHeight()); GL11.glVertex2f(texture.getImageWidth(), texture.getImageHeight()); GL11.glTexCoord2f(texture.getWidth(), 0); GL11.glVertex2f(texture.getImageWidth(), 0); GL11.glEnd(); // restore the model view matrix to prevent contamination GL11.glPopMatrix(); this.endPainting(); return true; }
From source file:com.golden.gamedev.engine.lwjgl.LWJGLGraphics.java
License:Open Source License
public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) { this.startPainting(); GL11.glPushMatrix();//w w w.j a va2s. co m Texture texture = this.textureLoader.getTexture((BufferedImage) img); texture.bind(); GL11.glTranslatef(x, y, 0); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(0, 0); GL11.glTexCoord2f(0, texture.getHeight()); GL11.glVertex2f(0, height); GL11.glTexCoord2f(texture.getWidth(), texture.getHeight()); GL11.glVertex2f(width, height); GL11.glTexCoord2f(texture.getWidth(), 0); GL11.glVertex2f(width, 0); GL11.glEnd(); GL11.glPopMatrix(); this.endPainting(); return true; }
From source file:com.golden.gamedev.engine.lwjgl.LWJGLGraphics.java
License:Open Source License
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) { this.startPainting(); Texture texture = this.textureLoader.getTexture((BufferedImage) img); texture.bind();//from w w w . j a va2s .c o m float tx0 = ((float) sx1 / texture.getTextureWidth()); float tx1 = ((float) sx2 / texture.getTextureWidth()); float ty0 = ((float) sy1 / texture.getTextureHeight()); float ty1 = ((float) sy2 / texture.getTextureHeight()); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(tx0, ty0); GL11.glVertex2f(dx1, dy1); GL11.glTexCoord2f(tx1, ty0); GL11.glVertex2f(dx2, dy1); GL11.glTexCoord2f(tx1, ty1); GL11.glVertex2f(dx2, dy2); GL11.glTexCoord2f(tx0, ty1); GL11.glVertex2f(dx1, dy2); GL11.glEnd(); this.endPainting(); return true; }
From source file:com.golden.gamedev.engine.lwjgl.LWJGLGraphics.java
License:Open Source License
public void drawLine(int x1, int y1, int x2, int y2) { GL11.glDisable(GL11.GL_TEXTURE_2D);/*w ww . j ava2s .c om*/ GL11.glColor4f((float) this.color.getRed() / 255f, (float) this.color.getGreen() / 255f, (float) this.color.getBlue() / 255f, (float) this.color.getAlpha() / 255f); GL11.glLineWidth(1.0f); GL11.glBegin(GL11.GL_LINES); GL11.glVertex2f(x1, y1); GL11.glVertex2f(x2, y2); GL11.glEnd(); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glEnable(GL11.GL_TEXTURE_2D); }
From source file:com.golden.gamedev.engine.lwjgl.LWJGLGraphics.java
License:Open Source License
private void drawRect(int x, int y, int width, int height, int type, Color col) { GL11.glDisable(GL11.GL_TEXTURE_2D);/* w w w . j a va 2s .co m*/ GL11.glColor4f((float) col.getRed() / 255f, (float) col.getGreen() / 255f, (float) col.getBlue() / 255f, (float) col.getAlpha() / 255f); GL11.glLineWidth(1.0f); GL11.glBegin(type); GL11.glVertex2f(x, y); GL11.glVertex2f(x + width, y); GL11.glVertex2f(x + width, y + height); GL11.glVertex2f(x, y + height); GL11.glEnd(); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glEnable(GL11.GL_TEXTURE_2D); }