glEnable(GL_BLEND);glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
But now I haven't got the time for doing this because I have to go to school
package the_wormhole;import static org.lwjgl.opengl.GL11.*;import static org.lwjgl.opengl.GL15.*;import static org.lwjgl.opengl.GL20.*;import static org.lwjgl.util.glu.GLU.gluPerspective;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.nio.FloatBuffer;import org.lwjgl.*;import org.lwjgl.opengl.*;import org.lwjgl.util.vector.Vector3f;import org.newdawn.slick.opengl.Texture;import org.newdawn.slick.opengl.TextureLoader;public class Wormhole { int lightEmittingEdge; Texture brightEdge; public Wormhole() { try { brightEdge = TextureLoader.getTexture("PNG", new FileInputStream(new File("res/bright_edge.png"))); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } lightEmittingEdge = glGenLists(1); glNewList(lightEmittingEdge, GL_COMPILE); glBegin(GL_QUADS); glColor4f(1f, 1f, 1f, 0f); glTexCoord2f(0, 0); glNormal3f(0, 0, 1); glVertex3f(-1, 1, -3.620420f); glTexCoord2f(1, 0); glNormal3f(0, 0, 1); glVertex3f(1, 1, -3.620420f); glTexCoord2f(1, 1); glNormal3f(0, 0, 1); glVertex3f(1, -1, -3.620420f); glTexCoord2f(0, 1); glNormal3f(0, 0, 1); glVertex3f(-1, -1, -3.620420f); glEnd(); glEndList(); } public void draw() { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); brightEdge.bind(); glCallList(lightEmittingEdge); glDisable(GL_BLEND); } public void cleanUp() { glDeleteLists(lightEmittingEdge, 1); brightEdge.release(); }}
package the_wormhole;import static org.lwjgl.opengl.GL11.*;import static org.lwjgl.opengl.GL15.*;import static org.lwjgl.opengl.GL20.*;import static org.lwjgl.util.glu.GLU.gluPerspective;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.nio.FloatBuffer;import org.lwjgl.*;import org.lwjgl.input.Keyboard;import org.lwjgl.opengl.*;import org.newdawn.slick.opengl.Texture;import org.newdawn.slick.opengl.TextureLoader;public class WormholeMain { private Wormhole wormhole; private float rotationX; private float translationX; private float translationY; private float translationZ; private float rotationY; private Vector3 walk; private FloatBuffer fb2 = BufferUtils.createFloatBuffer(4); public WormholeMain() { fb2.put(new float[] { -2, -2, 0, 0}); fb2.flip(); setUpDisplay(); setUp3dWorld(); walk = new Vector3(0, 0, -1); wormhole = new Wormhole(); mainLoop(); cleanUp(); } private void cleanUp() { wormhole.cleanUp(); Display.destroy(); } private void mainLoop() { while(!Display.isCloseRequested()){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(0.8f, 0.8f, 0.8f, 1); glLight(GL_LIGHT0, GL_POSITION, fb2); applyCamera(); wormhole.draw(); Display.update(); Display.sync(60); } } private void applyCamera() { if (Keyboard.isKeyDown(Keyboard.KEY_D)) { rotationX += 0.3f; glLoadIdentity(); walk.rotate(Vector3.Y_AXIS, Math.toRadians(-0.3)); glRotatef(rotationX, 0, 1, 0); glRotatef(rotationY, 1, 0, 0); glTranslatef(translationX, translationY, translationZ); } if (Keyboard.isKeyDown(Keyboard.KEY_A)) { rotationX -= 0.3f; glLoadIdentity(); walk.rotate(Vector3.Y_AXIS, Math.toRadians(0.3)); glRotatef(rotationX, 0, 1, 0); glRotatef(rotationY, 1, 0, 0); glTranslatef(translationX, translationY, translationZ); } if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { rotationY -= 0.3f; glLoadIdentity(); walk.rotate(Vector3.X_AXIS, Math.toRadians(0.3)); glRotatef(rotationY, 1, 0, 0); glRotatef(rotationX, 0, 1, 0); glTranslatef(translationX, translationY, translationZ); } if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { rotationY += 0.3f; glLoadIdentity(); walk.rotate(Vector3.X_AXIS, Math.toRadians(-0.3)); glRotatef(rotationY, 1, 0, 0); glRotatef(rotationX, 0, 1, 0); glTranslatef(translationX, translationY, translationZ); } if (Keyboard.isKeyDown(Keyboard.KEY_W)) { glTranslated(-0.02f * walk.x, -0.02f * walk.y, -0.02f * walk.z); translationX += -0.02f * walk.x; translationY += -0.02f * walk.y; translationZ += -0.02f * walk.z; } if (Keyboard.isKeyDown(Keyboard.KEY_S)) { glTranslated(0.02f * walk.x, 0.02f * walk.y, 0.02f * walk.z); translationX += 0.02f * walk.x; translationY += 0.02f * walk.y; translationZ += 0.02f * walk.z; } } private void setUp3dWorld() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(30, 800f/600f, 0.001f, 100); glMatrixMode(GL_MODELVIEW); glEnable(GL_TRIANGLE_FAN); glEnable(GL_DEPTH_TEST); glShadeModel(GL_SMOOTH); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); FloatBuffer fb1 = BufferUtils.createFloatBuffer(4); fb1.put(new float[] { 0.05f, 0.05f, 0.05f, 1 }); fb1.flip(); glLightModel(GL_LIGHT_MODEL_AMBIENT, fb1); glLight(GL_LIGHT0, GL_POSITION, fb2); glRotatef(-25f, 0, 1, 0); glRotatef(30f, 1, 0, 0); glTranslatef(-1.5f, -2.1f, -0.55f); } private void setUpDisplay() { try { Display.setDisplayMode(new DisplayMode(800, 600)); Display.setTitle("The Wormhole"); Display.setVSyncEnabled(true); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); } } public static void main(String[] args) { new WormholeMain(); } private class Vector3 { public float x, y, z; public static final int X_AXIS = 0, Y_AXIS = 1, Z_AXIS = 2; public Vector3(float x, float y, float z) { this.z = z; this.y = y; this.x = x; } public void rotate(int axis, double angle) { float oldX = x, oldY = y, oldZ = z; switch (axis) { case X_AXIS: x = oldX; y = (float) (Math.cos(angle) * oldY + (-Math.sin(angle)) * oldZ); z = (float) (Math.sin(angle) * oldY + Math.cos(angle) * oldZ); break; case Y_AXIS: x = (float) (Math.cos(angle) * oldX + Math.sin(angle) * oldZ); y = oldY; z = (float) ((-Math.sin(angle)) * oldX + Math.cos(angle) * oldZ); break; case Z_AXIS: x = (float) (Math.cos(angle) * oldX + (-Math.sin(angle)) * oldY); y = (float) (Math.sin(angle) * oldX + Math.cos(angle) * oldY); z = oldZ; break; default: break; } } }}