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:org.joge.core.draw.Graphics.java
License:Open Source License
public void drawOvall(float x_center, float y_center, float w, float h, int n) { double pheta, angle_increment; float x, y;//w w w .ja va2s. c om if (n <= 0) { n = 1; } angle_increment = 2 * PI / n; setColor(); disableGl(); GL11.glPushMatrix(); GL11.glTranslatef(x_center, y_center, 0); GL11.glBegin(GL11.GL_LINE_LOOP); for (pheta = 0.0f; pheta < 2 * PI; pheta += angle_increment) { x = w / 2 * (float) Math.cos(pheta); y = h / 2 * (float) Math.sin(pheta); GL11.glVertex2f(x, y); } GL11.glEnd(); GL11.glPopMatrix(); enableGl(); }
From source file:org.joge.core.draw.Graphics.java
License:Open Source License
public void fillOvall(float x_center, float y_center, float w, float h, int n) { double pheta, angle_increment; float x, y;//from ww w.j av a2 s . co m if (n <= 0) { n = 1; } angle_increment = 2 * PI / n; setColor(); disableGl(); GL11.glPushMatrix(); GL11.glTranslatef(x_center, y_center, 0); GL11.glBegin(GL11.GL_TRIANGLE_FAN); for (pheta = 0.0f; pheta < 2 * PI; pheta += angle_increment) { x = w / 2 * (float) Math.cos(pheta); y = h / 2 * (float) Math.sin(pheta); GL11.glVertex2f(x, y); } GL11.glEnd(); GL11.glPopMatrix(); enableGl(); }
From source file:org.joge.core.draw.Image.java
License:Open Source License
public void drawWithOutLoadIdentity(float xpos, float ypos) { GL11.glTranslatef(x + xpos, y + ypos, 0); GL11.glBegin(GL11.GL_QUADS);//from w w w .ja v a 2s .co m { GL11.glTexCoord2f(tOffsetX, tOffsetY); GL11.glVertex2f(0, 0); GL11.glTexCoord2f(tOffsetX, tHeight + tOffsetY); GL11.glVertex2f(0, height); GL11.glTexCoord2f(tWidth + tOffsetX, tHeight + tOffsetY); GL11.glVertex2f(width, height); GL11.glTexCoord2f(tWidth + tOffsetX, tOffsetY); GL11.glVertex2f(width, 0); } GL11.glEnd(); }
From source file:org.meanworks.engine.gui.impl.PerformanceGraph.java
License:Open Source License
public static void line(int x1, int y1, int x2, int y2) { GL11.glVertex2f(x1, y1); GL11.glVertex2f(x2, y2);//from w w w.java2 s .c o m }
From source file:org.minetweak.world.World.java
License:Apache License
private void renderOverlay() { Configuration conf = Game.getInstance().getConfiguration(); Game.getInstance().initOverlayRendering(); GL11.glColor3f(1, 1, 1);// ww w . j a v a2s. c o m if (Game.RENDER_INFORMATION_OVERLAY) { GLFont infoFont = FontStorage.getFont("Monospaced_20"); /* Down Left Info */ infoFont.print(4, 4, "CraftMania"); infoFont.print(4, 30, _player.coordinatesToString()); infoFont.print(4, 45, "Visible Chunks: " + _visibleChunks.size()); infoFont.print(4, 60, "Updading Blocks: " + _updatingBlocks); infoFont.print(4, 75, "Total Chunks in RAM: " + _chunkManager.getTotalChunkCount()); infoFont.print(4, 90, "Local Chunks: " + _localChunks.size()); infoFont.print(4, 105, "Total Local Blocks: " + _localBlockCount); infoFont.print(4, 120, "Time: " + _time); infoFont.print(4, 135, "Sunlight: " + _sunlight); } /** RENDER **/ if (currentGui != null) { Game.getInstance().renderTransculentOverlayLayer(); currentGui.render(); } else { int width = conf.getWidth(); int height = conf.getHeight(); // Center Cross GL11.glDisable(GL11.GL_TEXTURE_2D); if (CENTER_CROSS_CALL_LIST == 0) { CENTER_CROSS_CALL_LIST = GL11.glGenLists(1); GL11.glNewList(CENTER_CROSS_CALL_LIST, GL11.GL_COMPILE_AND_EXECUTE); int crossSize = 10; int crossHole = 5; GL11.glLineWidth(2.5f); GL11.glColor3f(0, 0, 0); GL11.glBegin(GL11.GL_LINES); GL11.glVertex3f(width / 2f - crossSize - crossHole, height / 2f, 0); GL11.glVertex3f(width / 2f - crossHole, height / 2f, 0); GL11.glVertex3f(width / 2f + crossSize + crossHole, height / 2f, 0); GL11.glVertex3f(width / 2f + crossHole, height / 2f, 0); GL11.glVertex3f(width / 2f, height / 2f - crossSize - crossHole, 0); GL11.glVertex3f(width / 2f, height / 2f - crossHole, 0); GL11.glVertex3f(width / 2f, height / 2f + crossSize + crossHole, 0); GL11.glVertex3f(width / 2f, height / 2f + crossHole, 0); GL11.glEnd(); GL11.glEndList(); } else { GL11.glCallList(CENTER_CROSS_CALL_LIST); } GL11.glEnable(GL11.GL_TEXTURE_2D); // Inventory bar GL11.glPushMatrix(); Texture texGui = TextureStorage.getTexture("gui.gui"); texGui.bind(); float tileSize = 20.0f / texGui.getImageWidth(); if (INVENTORY_BAR_CALL_LIST == 0) { INVENTORY_BAR_CALL_LIST = GL11.glGenLists(2); /* Bar */ GL11.glNewList(INVENTORY_BAR_CALL_LIST, GL11.GL_COMPILE_AND_EXECUTE); GL11.glTranslatef(width / 2.0f - 9 * 20, 10, 0); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(0, 40); GL11.glTexCoord2f(tileSize * 9, 0); GL11.glVertex2f(9 * 40, 40); GL11.glTexCoord2f(tileSize * 9, tileSize); GL11.glVertex2f(9 * 40, 0); GL11.glTexCoord2f(0, tileSize); GL11.glVertex2f(0, 0); GL11.glEnd(); GL11.glEndList(); /* Little frame around selected item */ float frameTileSize = 24.0f / texGui.getImageWidth(); float frameTileY = 22.0f / texGui.getImageHeight(); GL11.glNewList(INVENTORY_BAR_CALL_LIST + 1, GL11.GL_COMPILE); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, frameTileY); GL11.glVertex2f(0, 48); GL11.glTexCoord2f(frameTileSize, frameTileY); GL11.glVertex2f(48, 48); GL11.glTexCoord2f(frameTileSize, frameTileY + frameTileSize); GL11.glVertex2f(48, 0); GL11.glTexCoord2f(0, frameTileY + frameTileSize); GL11.glVertex2f(0, 0); GL11.glEnd(); GL11.glEndList(); } else { GL11.glCallList(INVENTORY_BAR_CALL_LIST); } /* Content */ GL11.glPushMatrix(); GL11.glTranslatef(20, 20, 0); for (int i = 0; i < 9; ++i) { Inventory.InventoryPlace place = getActivePlayer().getInventory().getInventoryPlace(i); if (place != null) { place.render(); } GL11.glTranslatef(40, 0, 0); } texGui.bind(); GL11.glPopMatrix(); GL11.glTranslatef(getActivePlayer().getSelectedInventoryItemIndex() * 40.0f - 4, -4, 0); GL11.glCallList(INVENTORY_BAR_CALL_LIST + 1); GL11.glPopMatrix(); } }
From source file:org.mkdev.ai.langton3d.core.App.java
License:GNU General Public License
private void drawBackground() { GL11.glDisable(GL11.GL_DEPTH_TEST);// w w w .ja v a 2s .c o m GL11.glDisable(GL11.GL_LIGHTING); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glClearColor(Settings.BKG_COLOR_RED, Settings.BKG_COLOR_GREEN, Settings.BKG_COLOR_BLUE, Settings.BKG_COLOR_ALPHA); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glDisable(GL_LIGHTING); GL11.glBegin(GL11.GL_QUADS); GL11.glColor4f(Settings.BKG_COLOR_RED, Settings.BKG_COLOR_GREEN, Settings.BKG_COLOR_BLUE, Settings.BKG_COLOR_ALPHA); GL11.glVertex2f(-1.0f, -1.0f); GL11.glVertex2f(1.0f, -1.0f); GL11.glColor4f(Settings.BKG_COLOR_RED / 2, Settings.BKG_COLOR_GREEN / 2, Settings.BKG_COLOR_BLUE / 2, Settings.BKG_COLOR_ALPHA); GL11.glVertex2f(1.0f, 1.0f); GL11.glVertex2f(-1.0f, 1.0f); GL11.glEnd(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); }
From source file:org.spoutcraft.api.gui.RenderUtil.java
License:Open Source License
/** * Draws a symmetrical polygon. Large values of segments (>50) approximate a circle. * @param cx x coordinate or the center of the circle * @param cy y coordinate for the center of the circle * @param r radius of the circle// ww w . j a v a 2 s . c om * @param numSegments to draw (number of sides to the polygon. Large values > 50 approximate a circle) */ public static void drawSymmetricalPolygon(float cx, float cy, float r, int numSegments) { float theta = 2 * 3.1415926F / ((float) numSegments); float c = (float) Math.cos(theta); // Precalculate the sine and cosine float s = (float) Math.sin(theta); float t; float x = r; // We start at angle = 0 float y = 0; GL11.glBegin(GL11.GL_LINE_LOOP); for (int ii = 0; ii < numSegments; ii++) { GL11.glVertex2f(x + cx, y + cy); // Output vertex // Apply the rotation matrix t = x; x = c * x - s * y; y = s * t + c * y; } GL11.glEnd(); }
From source file:org.spoutcraft.spoutcraftapi.gui.RenderUtil.java
License:Open Source License
/** * Draws a symmetrical polygon. Large values of segments (>50) approximate a circle. * @param cx x coordinate or the center of the circle * @param cy y coordinate for the center of the circle * @param r radius of the circle/* w w w .ja va 2 s. c om*/ * @param numSegments to draw (number of sides to the polygon. Large values > 50 approximate a circle) */ public static void drawSymmetricalPolygon(float cx, float cy, float r, int numSegments) { float theta = 2 * 3.1415926F / ((float) numSegments); float c = (float) Math.cos(theta);//precalculate the sine and cosine float s = (float) Math.sin(theta); float t; float x = r;//we start at angle = 0 float y = 0; GL11.glBegin(GL11.GL_LINE_LOOP); for (int ii = 0; ii < numSegments; ii++) { GL11.glVertex2f(x + cx, y + cy);//output vertex //apply the rotation matrix t = x; x = c * x - s * y; y = s * t + c * y; } GL11.glEnd(); }
From source file:org.terasology.rendering.gui.components.UIPieChart.java
License:Apache License
public void render() { super.render(); if (_data.size() == 0) return;/*from w w w . jav a 2 s. c o m*/ ArrayList<String> sortedKeys = new ArrayList<String>(_data.keySet()); Collections.sort(sortedKeys); glPushMatrix(); glTranslatef(getSize().x / 2, getSize().y / 2, 0.0f); GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glVertex3f(0f, 0f, 0f); double stepSize = (Math.PI * 2.0) / SEGMENTS; int segment = 0; double prevValueSum = 0.0f; for (int i = 0; i <= SEGMENTS; i++) { double value = _data.get(sortedKeys.get(segment)); if (((double) i / SEGMENTS) >= value + prevValueSum) { segment++; prevValueSum += value; Vector3f segmentColor = new Vector3f((segment * 0.1f) % 1.0f, (segment * 0.2f) % 1.0f, (segment * 0.4f) % 1.0f); glColor3f(segmentColor.x, segmentColor.y, segmentColor.z); } GL11.glVertex2f((float) Math.sin(stepSize * i) * (getSize().x / 2), (float) Math.cos(stepSize * i) * (getSize().x / 2)); } GL11.glEnd(); glPopMatrix(); }
From source file:pso.Surface.java
License:Open Source License
public static void assemble(float[][] val, float minc, float maxc, int rezx, int rezy) { int i, j;//from w w w . ja v a 2s.c o m float px, py; float tmp; Color col; float spx = -rezx / 2; float spy = -rezy / 2; handle = GL11.glGenLists(1); GL11.glNewList(handle, GL11.GL_COMPILE); GL11.glBegin(GL11.GL_QUADS); px = spx; for (i = 0; i < rezx - 1; i++) { py = spy; for (j = 0; j < rezy - 1; j++) { tmp = (float) (1 - ((val[i][j] - minc) / (maxc - minc))); tmp = tmp * 66 / 100 + 34 / 100; col = new Color(Color.HSBtoRGB(tmp, 0.7f, 0.85f)); GL11.glColor3f((float) (col.getRed() / 255f), (float) (col.getGreen() / 255f), (float) (col.getBlue() / 255f)); GL11.glVertex2f(px, py); tmp = (float) (1 - ((val[i][j + 1] - minc) / (maxc - minc))); tmp = tmp * 66 / 100 + 34 / 100; col = new Color(Color.HSBtoRGB(tmp, 0.7f, 0.85f)); GL11.glColor3f((float) (col.getRed() / 255f), (float) (col.getGreen() / 255f), (float) (col.getBlue() / 255f)); GL11.glVertex2f(px, py + 1); tmp = (float) (1 - ((val[i + 1][j + 1] - minc) / (maxc - minc))); tmp = tmp * 66 / 100 + 34 / 100; col = new Color(Color.HSBtoRGB(tmp, 0.7f, 0.85f)); GL11.glColor3f((float) (col.getRed() / 255f), (float) (col.getGreen() / 255f), (float) (col.getBlue() / 255f)); GL11.glVertex2f(px + 1, py + 1); tmp = (float) (1 - ((val[i + 1][j] - minc) / (maxc - minc))); tmp = tmp * 66 / 100 + 34 / 100; col = new Color(Color.HSBtoRGB(tmp, 0.7f, 0.85f)); GL11.glColor3f((float) (col.getRed() / 255f), (float) (col.getGreen() / 255f), (float) (col.getBlue() / 255f)); GL11.glVertex2f(px + 1, py); py += 1; } px += 1; } GL11.glEnd(); GL11.glEndList(); }