List of usage examples for org.lwjgl.opengl GL11 glTranslatef
public static native void glTranslatef(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y, @NativeType("GLfloat") float z);
From source file:com.gameminers.ethereal.architect.ModelCanvas.java
License:Open Source License
@Override protected void paintGL() { try {//from www.j a v a 2s . c om if (getWidth() != current_width || getHeight() != current_height) { current_width = getWidth(); current_height = getHeight(); GL11.glViewport(0, 0, current_width, current_height); } GL11.glClearColor(0.0f, 0.6f, 0.5f, 1.0f); GL11.glClearDepth(1.0); GL11.glColor3f(1, 1, 1); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glLoadIdentity(); GLU.gluPerspective(45.0f, (float) getWidth() / (float) getHeight(), 0.1f, 1000.0f); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glTranslatef(0, 0, zoom); GL11.glRotatef(angle, 0f, 1f, 0f); GL11.glRotatef(tilt, 1f, 0f, 0f); GL11.glTranslatef(-16, -16, -16); if (lit) { GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, lightPosition); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, lightAmbient); } else { GL11.glDisable(GL11.GL_LIGHTING); } if (textured) { GL11.glEnable(GL11.GL_TEXTURE_2D); } else { GL11.glDisable(GL11.GL_TEXTURE_2D); } if (model != null) { if (model.isAmbientOcclusionEnabled()) { GL11.glShadeModel(GL11.GL_SMOOTH); } else { GL11.glShadeModel(GL11.GL_FLAT); } for (ModelElement ele : model.getElements()) { GL11.glPushMatrix(); if (ele.isShade()) { GL11.glEnable(GL11.GL_LIGHTING); } else { GL11.glDisable(GL11.GL_LIGHTING); } float fromX = ele.getFrom()[0]; float fromY = ele.getFrom()[1]; float fromZ = ele.getFrom()[2]; float toX = ele.getTo()[0]; float toY = ele.getTo()[1]; float toZ = ele.getTo()[2]; float fX = (fromX > toX ? fromX : toX); float fY = (fromY > toY ? fromY : toY); float fZ = (fromZ > toZ ? fromZ : toZ); float tX = (fromX > toX ? toX : fromX); float tY = (fromY > toY ? toY : fromY); float tZ = (fromZ > toZ ? toZ : fromZ); GL11.glTranslatef(fX, fY, fZ); float scaleX = tX - fX; float scaleY = tY - fY; float scaleZ = tZ - fZ; GL11.glBegin(GL11.GL_QUADS); GL11.glNormal3f(0, 0, -1f); for (int i = 0; i < vertices.length / 3; i++) { int faceIdx = i / 4; ModelFace face; switch (faceIdx) { case 0: face = ele.getFaces().getNorth(); break; case 1: face = ele.getFaces().getSouth(); break; case 2: face = ele.getFaces().getUp(); break; case 3: face = ele.getFaces().getDown(); break; case 4: face = ele.getFaces().getWest(); break; case 5: face = ele.getFaces().getEast(); break; default: face = null; break; } int idx = i * 3; float vX = vertices[idx] * scaleX; float vY = vertices[idx + 1] * scaleY; float vZ = vertices[idx + 2] * scaleZ; /*float u; float v; GL11.glTexCoord2f(u, v);*/ GL11.glVertex3f(vX, vY, vZ); } GL11.glEnd(); GL11.glPopMatrix(); } } GL11.glPopMatrix(); swapBuffers(); repaint(); } catch (LWJGLException e) { throw new RuntimeException(e); } }
From source file:com.gameminers.mav.component.Component.java
License:Open Source License
public final void render() { GL11.glPushMatrix(); GL11.glTranslatef(x, y, z); doRender(); GL11.glPopMatrix(); }
From source file:com.gameminers.mav.personality.poly.PolygonPersonality.java
License:Open Source License
@Override public void renderForeground(float diameter) { GL11.glTranslatef(0, (0.3f - bgLum) * ((Display.getHeight() / 2f) - 10), 0); diameter *= Math.max(1.0f, ((0.3f - bgLum) * 3f) + 1); setup();/* w w w . ja v a2 s . co m*/ float radius = diameter / 2f; float[] bg = RenderState.getColor(bgLum); float[] fg = RenderState.getColor(0.8f); Rendering.drawPolygon(0, 0, radius * (0.85f + (pulse * 0.15f)), fg[0], fg[1], fg[2], 0.5f, sideCount, 0); Rendering.drawPolygon(0, 0, radius * 0.8f, fg[0], fg[1], fg[2], 1, sideCount, 5f); Rendering.drawPolygon(0, 0, radius * 0.7f, bg[0], bg[1], bg[2], 1, sideCount, 10f); Rendering.drawPolygon(0, 0, radius * 0.7f, fg[0], fg[1], fg[2], 0.5f, sideCount, 15f); Rendering.drawPolygon(0, 0, radius * (0.7f - (innerPulse * 0.15f)), bg[0], bg[1], bg[2], 1, sideCount, 20f); }
From source file:com.gameminers.mav.personality.poly.PolygonPersonality.java
License:Open Source License
@Override public void renderIconForeground(int size) { if (sideCount < 4) { GL11.glTranslatef(0, -8, 0); }//from w ww . j a va 2 s.co m float radius = size / 2f; float[] bg = RenderState.getColor(bgLum); float[] fg = RenderState.getColor(0.8f); Rendering.drawPolygon(0, 0, radius * 1.1f, fg[0], fg[1], fg[2], 0.5f, sideCount, 0); Rendering.drawPolygon(0, 0, radius * 0.7f, fg[0], fg[1], fg[2], 1, sideCount, 0.5f); Rendering.drawPolygon(0, 0, radius * 0.4f, bg[0], bg[1], bg[2], 1, sideCount, 1f); }
From source file:com.gameminers.mav.render.IconRenderer.java
License:Open Source License
@Override public void run() { try {//from ww w. j a v a2 s . c om init(); } catch (Exception e) { return; } try { final ByteBuffer icon = BufferUtils.createByteBuffer(SIZE * SIZE * 4); while (run) { // LWJGL makes a deep copy of our ByteBuffer, so skip frames we don't need to render if (!ArrayUtils.isEquals(RenderState.lagRGB, previousRGB)) { previousRGB = RenderState.lagRGB.clone(); Rendering.beforeFrame(SIZE, SIZE); GL11.glPushMatrix(); Mav.personality.renderIconBackground(SIZE); GL11.glTranslatef(SIZE / 2f, SIZE / 2f, 0); Mav.personality.renderIconForeground(SIZE); GL11.glPopMatrix(); GL11.glReadBuffer(GL11.GL_FRONT); GL11.glReadPixels(0, 0, SIZE, SIZE, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, icon); Display.setIcon(new ByteBuffer[] { icon }); } sleep(33L); // We don't care very much about accuracy, and using LWJGL's sync() method screws up the main context } } catch (InterruptedException e) { } }
From source file:com.gameminers.mav.render.PersonalityRenderer.java
License:Open Source License
public void render() { float w = Display.getWidth() / 2f; GL11.glPushMatrix();// w w w .j a va 2s. c om Mav.personality.renderBackground(); //// This code was originally a test to see how bad the overdraw was, but it looks pretty damn cool. //// TODO, implement //GL11.glRotatef(30f, 0.5f, 1.0f, 0f); GL11.glTranslatef(Display.getWidth() / 2f, 10 + (w / 2f), 50); Mav.personality.renderForeground(w * 0.9f); GL11.glPopMatrix(); if (Mav.personality.renderScreen()) { int y = (int) w; String[] split = RenderState.getLines(); for (String s : split) { TrueTypeFont font = Fonts.light[1]; if (s.startsWith("\u00A7l")) { font = Fonts.base[1]; s = s.substring(2); } else if (s.startsWith("\u00A7L")) { font = Fonts.light[2]; s = s.substring(2); } else if (s.startsWith("\u00A7s")) { font = Fonts.light[0]; s = s.substring(2); } font.drawString((Display.getWidth() / 2) - (font.getWidth(s) / 2), y, s, Color.white); y += font.getHeight(); } } }
From source file:com.gameminers.mav.render.Rendering.java
License:Open Source License
public static void drawPolygon(float x, float y, float radius, float r, float g, float b, float a, int count, float z) { GL11.glPushMatrix();/*from ww w . j av a2 s.c o m*/ GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glTranslatef(x, y, z); GL11.glColor4f(r, g, b, a); GL11.glBegin(GL11.GL_POLYGON); for (int i = 0; i < count; ++i) { GL11.glVertex2d(Math.sin(i / ((double) count) * 2 * Math.PI) * (radius), Math.cos(i / ((double) count) * 2 * Math.PI) * (radius)); } GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glPopMatrix(); }
From source file:com.gameminers.mav.render.Rendering.java
License:Open Source License
public static void drawTriangle(float x, float y, float radius, float r, float g, float b, float a, float z) { GL11.glPushMatrix();/* w w w .j av a2 s.c om*/ GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glTranslatef(x, y, z); GL11.glColor4f(r, g, b, a); GL11.glBegin(GL11.GL_TRIANGLES); for (int i = 0; i < 3; ++i) { GL11.glVertex2d(Math.sin(i / ((double) 3) * 2 * Math.PI) * (radius), Math.cos(i / 3D * 2 * Math.PI) * (radius)); } GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); 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();/*www. jav a2 s .c o m*/ 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.github.begla.blockmania.game.blueprints.BlockGrid.java
License:Apache License
public void render() { glEnable(GL_BLEND);// www . jav a2 s. co m glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); for (int i = 0; i < 2; i++) { if (i == 0) { glColorMask(false, false, false, false); } else { glColorMask(true, true, true, true); } for (BlockPosition gp : _gridPositions) { GL11.glPushMatrix(); Vector3f r = _parent.getWorldProvider().getRenderingReferencePoint(); GL11.glTranslatef(gp.x - r.x, gp.y - r.y, gp.z - r.z); GL11.glCallList(_blockDisplayList); GL11.glPopMatrix(); } } glDisable(GL11.GL_BLEND); }