List of usage examples for org.lwjgl.opengl GL11 glBegin
public static native void glBegin(@NativeType("GLenum") int mode);
From source file:org.cogaen.lwjgl.scene.CircleVisual.java
License:Open Source License
@Override public void render() { //TODO use display list getColor().apply();/* ww w . ja va 2s. co m*/ GL11.glBegin(this.glMode); double r = this.radius * getScale(); for (int i = 0; i < 360; i += 10) { double degInRad = i * DEG2RAD; GL11.glVertex2d(Math.cos(degInRad) * r, Math.sin(degInRad) * r); } GL11.glEnd(); }
From source file:org.cogaen.lwjgl.scene.PointVisual.java
License:Open Source License
@Override public void render() { getColor().apply(); GL11.glBegin(GL11.GL_POINTS); GL11.glVertex2f(0f, 0f); GL11.glEnd(); }
From source file:org.cogaen.lwjgl.scene.RectangleVisual.java
License:Open Source License
@Override public void render() { getColor().apply();/*w w w. j av a 2 s .c o m*/ GL11.glBegin(this.glMode); GL11.glVertex2d(-this.halfWidth * getScale(), -this.halfHeight * getScale()); GL11.glVertex2d(this.halfWidth * getScale(), -this.halfHeight * getScale()); GL11.glVertex2d(this.halfWidth * getScale(), this.halfHeight * getScale()); GL11.glVertex2d(-this.halfWidth * getScale(), this.halfHeight * getScale()); 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 w w w . j av a 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();//from www . ja v a 2s.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.cogaen.lwjgl.scene.TextBlockVisual.java
License:Open Source License
@Override public void render() { GL11.glPushMatrix();/* www . j a va 2 s.c o m*/ GL11.glScaled(getScale(), -getScale(), 1); getColor().apply(); org.newdawn.slick.Color utilColor = new org.newdawn.slick.Color((int) (getColor().getRed() * 255), (int) (getColor().getGreen() * 255), (int) (getColor().getBlue() * 255), (int) (getColor().getAlpha() * 255)); if (this.timeStamp < this.timer.getTime()) { this.timeStamp = this.timer.getTime() + BLINK_TIME; this.cursorOn = !this.cursorOn; } for (int i = 0; i < this.lines.length; ++i) { this.ttf.drawString((float) (-this.width / 2), (float) (-this.height / 2 + i * ttf.getHeight() * LINE_SPACE), this.lines[i].toString(), utilColor); } if (this.cursorOn && this.showCursor) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); double offsetX; if (this.curX == 0) { offsetX = 0; } else if (this.curX >= this.lines[this.curY].length()) { offsetX = this.ttf.getWidth(this.lines[this.curY].substring(0, this.lines[this.curY].length())); } else { offsetX = this.ttf.getWidth(this.lines[this.curY].substring(0, this.curX)); } double offsetY = this.curY * this.ttf.getHeight() * LINE_SPACE; double x = -this.width / 2 + offsetX; double y = -this.height / 2 + offsetY + this.ttf.getHeight() / 2; double curHeight = this.ttf.getHeight() / 2 * 0.8; GL11.glBegin(GL11.GL_LINES); GL11.glVertex2d(x, y + curHeight); GL11.glVertex2d(x, y - curHeight); GL11.glEnd(); } GL11.glPopMatrix(); }
From source file:org.craftmania.blocks.CrossedBlockBrush.java
License:Apache License
@Override public void create() { _callList = GL11.glGenLists(1);/*from ww w. ja va 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.inventory.CraftingTableInventory.java
License:Apache License
@Override public void renderInventory() { if (_inventoryDrawList == -1) { return;/*from w ww. j av a 2s. c o m*/ } Configuration conf = Game.getInstance().getConfiguration(); GL11.glPushMatrix(); GL11.glTranslatef(conf.getWidth() / 2.0f, conf.getHeight() / 2.0f, 0.0f); _tex.bind(); GL11.glCallList(_inventoryDrawList); GL11.glPopMatrix(); for (int i = 0; i < _raster.getCellCount(); ++i) { GL11.glPushMatrix(); ReadablePoint r = _raster.getCenterOfCell(i); GL11.glTranslatef(r.getX(), r.getY(), 0); if (Mouse.getX() < r.getX() + 16 && Mouse.getX() > r.getX() - 16 && Mouse.getY() < r.getY() + 16 && Mouse.getY() > r.getY() - 16) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.2f); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2i(-16, -16); GL11.glVertex2i(+16, -16); GL11.glVertex2i(+16, +16); GL11.glVertex2i(-16, +16); GL11.glEnd(); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } InventoryPlace place = getInventoryPlace(i); if (place != null) { place.render(); } GL11.glPopMatrix(); } /* Draggin item */ if (_dragging && _draggingItem != null) { GL11.glPushMatrix(); GL11.glTranslatef(Mouse.getX(), Mouse.getY(), 0); _draggingItem.render(); GL11.glPopMatrix(); } }
From source file:org.craftmania.world.Sky.java
License:Apache License
private void drawShpere(float x, float y, float z) { GL11.glPushMatrix();//from w w w . j av a2 s . co m GL11.glTranslatef(x, y, z); GL11.glColor3f(_color.x(), _color.y(), _color.z()); if (_sphereCallList == 0) { _sphereCallList = GL11.glGenLists(1); GL11.glNewList(_sphereCallList, GL11.GL_COMPILE_AND_EXECUTE); GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glVertex3f(0, 0, 0); for (int i = 0; i <= _vertices; ++i) { float angle = MathHelper.f_2PI / _vertices * i; float xx = MathHelper.cos(angle) * _radius; float zz = MathHelper.sin(angle) * _radius; GL11.glVertex3f(xx, -_bend, zz); } GL11.glEnd(); GL11.glEndList(); } else { GL11.glCallList(_sphereCallList); } GL11.glPopMatrix(); }
From source file:org.craftmania.world.Sky.java
License:Apache License
private void drawClouds(float x, float y, float z) { GL11.glPushMatrix();//from ww w . j av a 2 s .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(); }