List of usage examples for org.lwjgl.opengl GL11 GL_LIGHT0
int GL_LIGHT0
To view the source code for org.lwjgl.opengl GL11 GL_LIGHT0.
Click Source Link
From source file:com.ardor3d.scene.state.lwjgl.LwjglLightStateUtil.java
License:Open Source License
private static void setSpotCutoff(final int index, final LightStateRecord record, final float cutoff, final LightRecord lr) { if (!record.isValid() || lr.getSpotCutoff() != cutoff) { GL11.glLightf(GL11.GL_LIGHT0 + index, GL11.GL_SPOT_CUTOFF, cutoff); lr.setSpotCutoff(cutoff);/*w ww .j a v a 2s . c o m*/ } }
From source file:com.gameminers.ethereal.architect.ModelCanvas.java
License:Open Source License
@Override protected void paintGL() { try {//from www . j a v a 2 s .c o m 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.irr310.i3d.scene.I3dScene.java
License:Open Source License
/** * Draw the scene.//from w w w . j av a 2 s. c om * Place 3 lights and draw the root element * @param gl context gl to draw the image * @param camera point of view of the draw */ public void display(I3dCamera camera) { float[] lightAmbient1 = { 0.0f, 0.0f, 0.0f, 1.0f }; float[] lightDiffuse1 = { 0.75f, 0.75f, 0.75f, 1.0f }; float[] lightPosition1 = { 100.0f, 100.0f, -100.0f, 0.0f }; FloatBuffer lightPosition0 = BufferUtils.createFloatBuffer(4); lightPosition0.put(70.0f); lightPosition0.put(50.0f); lightPosition0.put(100.0f); lightPosition0.put(0.0f); lightPosition0.flip(); //GL11.GLLightf(GL11.GL_LIGHT1, GL11.GL_AMBIENT, lightAmbient1); // Setup The Ambient Light //GL11.GLLightf(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, lightDiffuse1); // Setup The Diffuse Light //GL11.GLLightf(GL11.GL_LIGHT1, GL11.GL_POSITION, lightPosition1, 0); // Position The Light GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, lightPosition0); GL11.glEnable(GL11.GL_LIGHT1); // Enable Light One float[] lightAmbient2 = { 0.0f, 0.0f, 0.0f, 1.0f }; float[] lightDiffuse2 = { 0.3f, 0.3f, 0.3f, 1.0f }; float[] lightPosition2 = { 100.0f, -100.0f, -100.0f, 0.0f }; //GL11.GLLightfv(GL11.GL_LIGHT2, GL11.GL_AMBIENT, lightAmbient2, 0); // Setup The Ambient Light //GL11.GLLightfv(GL11.GL_LIGHT2, GL11.GL_DIFFUSE, lightDiffuse2, 0); // Setup The Diffuse Light //GL11.GLLightfv(GL11.GL_LIGHT2, GL11.GL_POSITION, lightPosition2, 0); // Position The Light //GL11.glEnable(GL11.GL_LIGHT2); // Enable Light One float[] lightAmbient3 = { 0.0f, 0.0f, 0.0f, 1.0f }; float[] lightDiffuse3 = { 0.2f, 0.2f, 0.20f, 1.0f }; float[] lightPosition3 = { -100.0f, -100.0f, -100.0f, 0.0f }; //GL11.GLLightfv(GL11.GL_LIGHT3, GL11.GL_AMBIENT, lightAmbient3, 0); // Setup The Ambient Light //GL11.GLLightfv(GL11.GL_LIGHT3, GL11.GL_DIFFUSE, lightDiffuse3, 0); // Setup The Diffuse Light //GL11.GLLightfv(GL11.GL_LIGHT3, GL11.GL_POSITION, lightPosition3, 0); // Position The Light //GL11.glEnable(GL11.GL_LIGHT3); // Enable Light One //GL11.GLLightModeli(GL11.GL_LIGHT_MODEL_TWO_SIDE, GL11.GL_TRUE); float[] globalAmbiant = { 0.0f, 0.0f, 0.0f, 1.0f }; //GL11.GLLightModelfv(GL11.GL_LIGHT_MODEL_AMBIENT, globalAmbiant,0); rootElement.display(camera); //rootElement.select( camera, 0); }
From source file:com.owens.oobjloader.Main.java
License:BSD License
/** * Runs the program (the "main loop")// ww w . j a va 2s . c om */ private static void run(String filename, String defaultTextureMaterial) { DisplayModel scene = null; scene = new DisplayModel(); log.log(INFO, "Parsing WaveFront OBJ file"); Build builder = new Build(); Parse obj = null; try { obj = new Parse(builder, filename); } catch (java.io.FileNotFoundException e) { log.log(SEVERE, "Exception loading object! e=" + e); e.printStackTrace(); } catch (java.io.IOException e) { log.log(SEVERE, "Exception loading object! e=" + e); e.printStackTrace(); } log.log(INFO, "Done parsing WaveFront OBJ file"); log.log(INFO, "Splitting OBJ file faces into list of faces per material"); ArrayList<ArrayList<Face>> facesByTextureList = createFaceListsByMaterial(builder); log.log(INFO, "Done splitting OBJ file faces into list of faces per material, ended up with " + facesByTextureList.size() + " lists of faces."); TextureLoader textureLoader = new TextureLoader(); int defaultTextureID = 0; if (defaultTextureMaterial != null) { log.log(INFO, "Loading default texture =" + defaultTextureMaterial); defaultTextureID = setUpDefaultTexture(textureLoader, defaultTextureMaterial); log.log(INFO, "Done loading default texture =" + defaultTextureMaterial); } if (defaultTextureID == -1) { BufferedImage img = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB); Graphics g = img.getGraphics(); g.setColor(Color.BLUE); g.fillRect(0, 0, 256, 256); g.setColor(Color.RED); for (int loop = 0; loop < 256; loop++) { g.drawLine(loop, 0, loop, 255); g.drawLine(0, loop, 255, loop); } defaultTextureID = textureLoader.convertToTexture(img); } int currentTextureID = -1; for (ArrayList<Face> faceList : facesByTextureList) { if (faceList.isEmpty()) { log.log(INFO, "ERROR: got an empty face list. That shouldn't be possible."); continue; } log.log(INFO, "Getting material " + faceList.get(0).material); currentTextureID = getMaterialID(faceList.get(0).material, defaultTextureID, builder, textureLoader); log.log(INFO, "Splitting any quads and throwing any faces with > 4 vertices."); ArrayList<Face> triangleList = splitQuads(faceList); log.log(INFO, "Calculating any missing vertex normals."); calcMissingVertexNormals(triangleList); log.log(INFO, "Ready to build VBO of " + triangleList.size() + " triangles"); ; if (triangleList.size() <= 0) { continue; } log.log(INFO, "Building VBO"); VBO vbo = VBOFactory.build(currentTextureID, triangleList); log.log(INFO, "Adding VBO with text id " + currentTextureID + ", with " + triangleList.size() + " triangles to scene."); scene.addVBO(vbo); } log.log(INFO, "Finally ready to draw things."); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glEnable(GL11.GL_LIGHT1); float lightAmbient[] = { 1.0f, 1.0f, 1.0f, 1.0f }; float lightDiffuse[] = { 0.5f, 0.5f, 1.0f, 1.0f }; float lightSpecular[] = { 0.0f, 1.0f, 1.0f, 0.0f }; GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, asFloatBuffer(lightAmbient)); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, asFloatBuffer(lightDiffuse)); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, asFloatBuffer(lightSpecular)); GL11.glLight(GL11.GL_LIGHT1, GL11.GL_AMBIENT, asFloatBuffer(lightAmbient)); GL11.glLight(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, asFloatBuffer(lightDiffuse)); GL11.glLight(GL11.GL_LIGHT1, GL11.GL_SPECULAR, asFloatBuffer(lightSpecular)); float lightPosition0[] = { posix, posiy, posiz, 1.0f }; GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, asFloatBuffer(lightPosition0)); float lightPosition1[] = { posix, posiy, posizz, 1.0f }; GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, asFloatBuffer(lightPosition1)); while (!finished) { GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GLU.gluLookAt(orix, oriy, oriz, cenx, ceny, cenz, 0, 1, 0); // rotate(based on camera) GL11.glRotatef(rotateSee, 0, 1, 0); GL11.glRotatef(rotateSeeAnother, 1, 0, 0); // transform GL11.glTranslated(0, -0.75, -2); // rotate(based on model) GL11.glRotatef(rotate, 0, 1, 0); GL11.glRotatef(rotateAnother, 1, 0, 0); // Always call Window.update(), all the time - it does some behind the // scenes work, and also displays the rendered output Display.update(); // Check for close requests if (Display.isCloseRequested()) { finished = true; } // The window is in the foreground, so render! else if (Display.isActive()) { logic(); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT); scene.render(); Display.sync(FRAMERATE); } // The window is not in the foreground, so we can allow other stuff to run and infrequently update else { try { Thread.sleep(100); } catch (InterruptedException e) { } logic(); // Only bother rendering if the window is visible or dirty if (Display.isVisible() || Display.isDirty()) { System.err.print("."); scene.render(); } } } }
From source file:com.runescape.client.revised.editor.modelviewer.Viewport.java
License:Open Source License
public void render() { final Dimension size = this.canvas.getSize(); if ((size.width > 0) && (size.height > 0)) { if ((this.width != size.width) || (this.height != size.height)) { this.width = size.width; this.height = size.height; GL11.glViewport(0, 0, this.width, this.height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();/* ww w. j av a 2 s . com*/ final float c = (float) Math .sqrt((double) (this.width * this.width) + (double) (this.height * this.height)); GL11.glOrtho(0.0F, this.width, 0.0F, this.height, -c, c); GL11.glMatrixMode(GL11.GL_MODELVIEW); final boolean useShader = this.initShader(); if (ModelConstants.ENABLE_VERTEX_SHADER && useShader) { ARBShaderObjects.glUseProgramObjectARB(this.program); } if (ModelConstants.ENABLE_LIGHTING) { GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); final FloatBuffer diffuse = BufferUtils.createFloatBuffer(4) .put(new float[] { 1F, 1F, 1F, 1F }); final FloatBuffer position = BufferUtils.createFloatBuffer(4) .put(new float[] { 3F, 0F, 1F, 0F }); final FloatBuffer ambient = BufferUtils.createFloatBuffer(4) .put(new float[] { .1F, .1F, .2F, .3F }); final FloatBuffer specular = BufferUtils.createFloatBuffer(4) .put(new float[] { 1F, 1F, 1F, 1F }); GL11.glMaterial(GL11.GL_FRONT, GL11.GL_SPECULAR, (FloatBuffer) specular.flip()); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, (FloatBuffer) ambient.flip()); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, (FloatBuffer) diffuse.flip()); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, (FloatBuffer) position.flip()); GL11.glMaterialf(GL11.GL_FRONT, GL11.GL_SHININESS, 50.0f); } } if (Mouse.isButtonDown(0) && !Mouse.isButtonDown(1)) { this.yaw -= Mouse.getDX(); this.pitch -= Mouse.getDY(); } if (Mouse.isButtonDown(0) && Mouse.isButtonDown(1)) { this.offset_z += Mouse.getDY(); } float wheel = Mouse.getDWheel() / 960.0F; if (wheel > 1.0F) { wheel = 1.0F; } else if (wheel < -1.0F) { wheel = -1.0F; } this.scale -= this.scale * wheel; if (this.scale < 0.01F) { this.scale = 0.01F; } for (final Model3D dragonModel : this.getDragonList()) { final float x = this.width / 1.2F; final float y = (-((100.0F * (this.scale))) + (this.offset_z + 0.1F)) + ((this.height - dragonModel.height()) / 2.0F); final float z = 0.0F; dragonModel.calcDimms(false); dragonModel.render(x, y, z, this.pitch, this.yaw, this.roll, this.scale, this.scale, this.scale); } for (final Model3D torvaModel : this.getTorvaList()) { final float x = this.width / 1.7F; final float y = (-((100.0F * (this.scale))) + this.offset_z) + ((this.height - torvaModel.height()) / 2.0F); final float z = 0.0F; torvaModel.calcDimms(false); torvaModel.render(x, y, z, this.pitch, this.yaw, this.roll, this.scale, this.scale, this.scale); } for (final Model3D jadModel : this.getJadList()) { final float x = this.width / 3.2F; final float y = (-((100.0F * (this.scale))) + this.offset_z) + ((this.height - jadModel.height()) / 2.0F); final float z = 0.0F; jadModel.calcDimms(false); jadModel.render(x, y, z, this.pitch, this.yaw, this.roll, this.scale, this.scale, this.scale); } for (final Model3D trollModel : this.getTrollList()) { final float x = this.width / 3.8F; final float y = (-((100.0F * (this.scale))) + this.offset_z) + ((this.height - trollModel.height()) / 2.0F); final float z = 0.0F; trollModel.calcDimms(false); trollModel.render(x, y, z, this.pitch, this.yaw, this.roll, this.scale, this.scale, this.scale); } if (ModelConstants.ENABLE_VERTEX_SHADER && this.initShader()) { ARBShaderObjects.glUseProgramObjectARB(0); } Display.update(); } }
From source file:com.rvantwisk.cnctools.controls.opengl.BeadActor.java
License:Open Source License
@Override public void initialize() { ambient = allocFloats(colorDefaultDiffuse); diffuse = allocFloats(colorDefaultDiffuse); specular = allocFloats(colorDefaultSpecular); shininess = allocFloats(new float[] { 32.0f, 0.0f, 0.0f, 0.0f }); light = allocFloats(colorDefaultLight); lightPos0 = allocFloats(lightDefaultPos0); lightPos1 = allocFloats(lightDefaultPos1); display_list = GL11.glGenLists(1);/* w w w . j a va2s . c o m*/ GL11.glNewList(display_list, GL11.GL_COMPILE); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glEnable(GL11.GL_LIGHT1); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT, ambient); GL11.glMaterial(GL11.GL_FRONT, GL11.GL_DIFFUSE, diffuse); GL11.glMaterial(GL11.GL_FRONT, GL11.GL_SPECULAR, specular); GL11.glMaterial(GL11.GL_FRONT, GL11.GL_SHININESS, shininess); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, light); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, light); GL11.glLight(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, light); GL11.glLight(GL11.GL_LIGHT1, GL11.GL_POSITION, lightPos0); GL11.glLight(GL11.GL_LIGHT1, GL11.GL_POSITION, lightPos1); GL11.glColor3f(1.0f, 0.0f, 0.0f); Sphere s = new Sphere(); s.setDrawStyle(GLU.GLU_FILL); s.setNormals(GLU.GLU_SMOOTH); s.draw(3.8f, 100, 100); GL11.glDisable(GL11.GL_LIGHT1); GL11.glDisable(GL11.GL_LIGHT0); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEndList(); }
From source file:de.kitsunealex.projectx.client.render.RenderTruncatedIcosahedron.java
License:Open Source License
public void render(double size, Colour colourPent, Colour colourHex, EnumHedronTexture type) { GlStateManager.pushMatrix();/*ww w.j a va 2 s. c o m*/ GlStateManager.pushAttrib(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_LIGHT0); GL11.glDisable(GL11.GL_LIGHT1); Minecraft.getMinecraft().getTextureManager().bindTexture(type.getTexture()); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glScaled(size * 0.1D, size * 0.1D, size * 0.1D); colourPent.glColour(); GL11.glCallList(LIST_INDEX); colourHex.glColour(); GL11.glCallList(LIST_INDEX + 1); GL11.glScaled(1D / (size * 0.1D), 1D / (size * 0.1D), 1D / (size * 0.1D)); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT1); GL11.glEnable(GL11.GL_LIGHT0); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1F, 1F, 1F, 1F); GlStateManager.popAttrib(); GlStateManager.popMatrix(); }
From source file:de.sanandrew.core.manpack.util.client.helpers.ItemRenderHelper.java
License:Creative Commons License
private static void renderItemIn2D(Tessellator tess, float minU, float minV, float maxU, float maxV, int scaleX, int scaleY, float negZLevel, boolean isGlowing) { if (isGlowing) { GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_LIGHT0); GL11.glDisable(GL11.GL_LIGHT1);/*from w w w .j a v a 2 s . c o m*/ GL11.glDisable(GL11.GL_COLOR_MATERIAL); float prevLGTX = OpenGlHelper.lastBrightnessX; float prevLGTY = OpenGlHelper.lastBrightnessY; int bright = 0xF0; int brightX = bright % 65536; int brightY = bright / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightX / 1.0F, brightY / 1.0F); ItemRenderer.renderItemIn2D(tess, minU, minV, maxU, maxV, scaleX, scaleY, negZLevel); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, prevLGTX, prevLGTY); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glEnable(GL11.GL_LIGHT1); GL11.glEnable(GL11.GL_COLOR_MATERIAL); } else { ItemRenderer.renderItemIn2D(tess, minU, minV, maxU, maxV, scaleX, scaleY, negZLevel); } }
From source file:fr.def.iss.vd2.lib_v3d.V3DScene.java
License:Open Source License
/** * Draw the scene./*from w w w . ja v a 2s . com*/ * Place 3 lights and draw the root element * @param gl context gl to draw the image * @param camera point of view of the draw */ public void display(V3DCamera camera) { float[] lightAmbient1 = { 0.0f, 0.0f, 0.0f, 1.0f }; float[] lightDiffuse1 = { 0.75f, 0.75f, 0.75f, 1.0f }; float[] lightPosition1 = { 100.0f, 100.0f, -100.0f, 0.0f }; FloatBuffer lightPosition0 = BufferUtils.createFloatBuffer(4); lightPosition0.put(70.0f); lightPosition0.put(50.0f); lightPosition0.put(100.0f); lightPosition0.put(0.0f); lightPosition0.flip(); //GL11.GLLightf(GL11.GL_LIGHT1, GL11.GL_AMBIENT, lightAmbient1); // Setup The Ambient Light //GL11.GLLightf(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, lightDiffuse1); // Setup The Diffuse Light //GL11.GLLightf(GL11.GL_LIGHT1, GL11.GL_POSITION, lightPosition1, 0); // Position The Light GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, lightPosition0); GL11.glEnable(GL11.GL_LIGHT1); // Enable Light One float[] lightAmbient2 = { 0.0f, 0.0f, 0.0f, 1.0f }; float[] lightDiffuse2 = { 0.3f, 0.3f, 0.3f, 1.0f }; float[] lightPosition2 = { 100.0f, -100.0f, -100.0f, 0.0f }; //GL11.GLLightfv(GL11.GL_LIGHT2, GL11.GL_AMBIENT, lightAmbient2, 0); // Setup The Ambient Light //GL11.GLLightfv(GL11.GL_LIGHT2, GL11.GL_DIFFUSE, lightDiffuse2, 0); // Setup The Diffuse Light //GL11.GLLightfv(GL11.GL_LIGHT2, GL11.GL_POSITION, lightPosition2, 0); // Position The Light //GL11.glEnable(GL11.GL_LIGHT2); // Enable Light One float[] lightAmbient3 = { 0.0f, 0.0f, 0.0f, 1.0f }; float[] lightDiffuse3 = { 0.2f, 0.2f, 0.20f, 1.0f }; float[] lightPosition3 = { -100.0f, -100.0f, -100.0f, 0.0f }; //GL11.GLLightfv(GL11.GL_LIGHT3, GL11.GL_AMBIENT, lightAmbient3, 0); // Setup The Ambient Light //GL11.GLLightfv(GL11.GL_LIGHT3, GL11.GL_DIFFUSE, lightDiffuse3, 0); // Setup The Diffuse Light //GL11.GLLightfv(GL11.GL_LIGHT3, GL11.GL_POSITION, lightPosition3, 0); // Position The Light //GL11.glEnable(GL11.GL_LIGHT3); // Enable Light One //GL11.GLLightModeli(GL11.GL_LIGHT_MODEL_TWO_SIDE, GL11.GL_TRUE); float[] globalAmbiant = { 0.0f, 0.0f, 0.0f, 1.0f }; //GL11.GLLightModelfv(GL11.GL_LIGHT_MODEL_AMBIENT, globalAmbiant,0); rootElement.display(camera); //rootElement.select( camera, 0); }
From source file:game.states.State_PREFAB_EDITOR.java
License:Open Source License
@Override protected void Init() { ButtonGUILayer = new GUI_Layer(); ButtonGUILayer.SetEnabled(true);/* w w w.j ava2s .com*/ MenuGUILayer = new GUI_Layer(); MenuGUILayer.SetEnabled(false); int ButtonStartX = 712; int ButtonStartY = 600; float xScale = 1.5f; float yScale = 1.5f; int Spacing = 145; int menuButtonStartX = 640 - 128; int menuButtonStartY = 150; float menuXScale = 1f; float menuYScale = 1f; int menuSpacing = 110; try { GL11.glEnable(GL11.GL_TEXTURE_2D); BackGroundImage = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/GUIPrefab.png")); Texture button1 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/SaveIconButton.png"), false, GL11.GL_NEAREST); ButtonGUILayer.AddButton(ButtonStartX + Spacing * 0, ButtonStartY, (int) (button1.getImageWidth() * xScale), (int) (button1.getImageHeight() * yScale), button1); Texture button2 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/LoadIconButton.png"), false, GL11.GL_NEAREST); ButtonGUILayer.AddButton(ButtonStartX + Spacing * 1, ButtonStartY, (int) (button2.getImageWidth() * xScale), (int) (button2.getImageHeight() * yScale), button2); Texture button3 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/OptionsIconButton.png"), false, GL11.GL_NEAREST); ButtonGUILayer.AddButton(ButtonStartX + Spacing * 2, ButtonStartY, (int) (button3.getImageWidth() * xScale), (int) (button3.getImageHeight() * yScale), button3); Texture button4 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/HelpIconButton.png"), false, GL11.GL_NEAREST); ButtonGUILayer.AddButton(ButtonStartX + Spacing * 3, ButtonStartY, (int) (button4.getImageWidth() * xScale), (int) (button4.getImageHeight() * yScale), button4); Texture mButton0 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/ReturnButton.png"), false, GL11.GL_NEAREST); MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 0, (int) (mButton0.getImageWidth() * menuXScale), (int) (mButton0.getImageHeight() * menuYScale), mButton0); Texture mButton1 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/LoadButton.png"), false, GL11.GL_NEAREST); MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 1, (int) (mButton1.getImageWidth() * menuXScale), (int) (mButton1.getImageHeight() * menuYScale), mButton1); Texture mButton2 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/SaveButton.png"), false, GL11.GL_NEAREST); MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 2, (int) (mButton2.getImageWidth() * menuXScale), (int) (mButton2.getImageHeight() * menuYScale), mButton2); Texture mButton3 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/BackButton.png"), false, GL11.GL_NEAREST); MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 3, (int) (mButton3.getImageWidth() * menuXScale), (int) (mButton3.getImageHeight() * menuYScale), mButton3); } catch (IOException e) { e.printStackTrace(); } GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective(45.0f, (float) Display.getWidth() / (float) Display.getHeight(), 0.1f, 600.0f); GLU.gluLookAt(0, 20, 50, 0, -2, -100, 0, -1, 0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }