List of usage examples for org.lwjgl.opengl GL11 glMaterialf
public static native void glMaterialf(@NativeType("GLenum") int face, @NativeType("GLenum") int pname, @NativeType("GLfloat") float param);
From source file:com.ardor3d.scene.state.lwjgl.LwjglMaterialStateUtil.java
License:Open Source License
private static void applyShininess(final float frontShininess, final float backShininess, final MaterialStateRecord record) { if (frontShininess == backShininess) { // consolidate to one call if (!record.isValid() || frontShininess != record.frontShininess || record.backShininess != backShininess) { GL11.glMaterialf(getGLMaterialFace(MaterialFace.FrontAndBack), GL11.GL_SHININESS, frontShininess); record.backShininess = record.frontShininess = frontShininess; }/*w w w .j av a2 s .c o m*/ } else { if (!record.isValid() || frontShininess != record.frontShininess) { GL11.glMaterialf(getGLMaterialFace(MaterialFace.Front), GL11.GL_SHININESS, frontShininess); record.frontShininess = frontShininess; } if (!record.isValid() || backShininess != record.backShininess) { GL11.glMaterialf(getGLMaterialFace(MaterialFace.Back), GL11.GL_SHININESS, backShininess); record.backShininess = backShininess; } } }
From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java
License:Apache License
public final void glMaterialf(int face, int pname, float param) { GL11.glMaterialf(face, pname, param); }
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();/*from w w w. j a va 2s .co m*/ 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:engine.obj.OBJLoader.java
License:Open Source License
/** * Renders a given <code>Obj</code> file. * * @param model the <code>Obj</code> file to be rendered *//*w w w. j av a2s . c om*/ public void render(Obj model) { GL11.glMaterialf(GL_FRONT, GL_SHININESS, 120); GL11.glBegin(GL_TRIANGLES); { for (Obj.Face face : model.getFaces()) { Vector3f[] normals = { model.getNormals().get(face.getNormals()[0] - 1), model.getNormals().get(face.getNormals()[1] - 1), model.getNormals().get(face.getNormals()[2] - 1) }; Vector2f[] texCoords = { model.getTextureCoordinates().get(face.getTextureCoords()[0] - 1), model.getTextureCoordinates().get(face.getTextureCoords()[1] - 1), model.getTextureCoordinates().get(face.getTextureCoords()[2] - 1) }; Vector3f[] vertices = { model.getVertices().get(face.getVertices()[0] - 1), model.getVertices().get(face.getVertices()[1] - 1), model.getVertices().get(face.getVertices()[2] - 1) }; { GL11.glNormal3f(normals[0].getX(), normals[0].getY(), normals[0].getZ()); GL11.glTexCoord2f(texCoords[0].getX(), texCoords[0].getY()); GL11.glVertex3f(vertices[0].getX(), vertices[0].getY(), vertices[0].getZ()); GL11.glNormal3f(normals[1].getX(), normals[1].getY(), normals[1].getZ()); GL11.glTexCoord2f(texCoords[1].getX(), texCoords[1].getY()); GL11.glVertex3f(vertices[1].getX(), vertices[1].getY(), vertices[1].getZ()); GL11.glNormal3f(normals[2].getX(), normals[2].getY(), normals[2].getZ()); GL11.glTexCoord2f(texCoords[2].getX(), texCoords[2].getY()); GL11.glVertex3f(vertices[2].getX(), vertices[2].getY(), vertices[2].getZ()); } } } GL11.glEnd(); }
From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java
License:Open Source License
@Override public void setMaterialShininess(float shininess) { GL11.glMaterialf(GL11.GL_FRONT, GL11.GL_SHININESS, shininess); }
From source file:lwjglapp.Lights.java
private void initGL() { GL11.glShadeModel(GL11.GL_SMOOTH);/*from w w w .j a v a 2s . c om*/ GL11.glMaterial(GL11.GL_FRONT, GL11.GL_SPECULAR, matSpecular); // sets specular material color GL11.glMaterialf(GL11.GL_FRONT, GL11.GL_SHININESS, 50.0f); // sets shininess GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, lightPosition); // sets light position GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, whiteLight); // sets specular light to white GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, whiteLight); // sets diffuse light to white GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, lModelAmbient); // global ambient light GL11.glEnable(GL11.GL_LIGHTING); // enables lighting GL11.glEnable(GL11.GL_LIGHT0); // enables light0 GL11.glEnable(GL11.GL_COLOR_MATERIAL); // enables opengl to use glColor3f to define material color GL11.glColorMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE); // tell opengl glColor3f effects the ambient and diffuse properties of material }
From source file:net.smert.frameworkgl.opengl.OpenGL1.java
License:Apache License
public OpenGL1 material(int face, int material, float value) { GL11.glMaterialf(face, material, value); return this; }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void setColor(float r, float g, float b, float alpha) { //GLfloat light_ambient[4],light_diffuse[4],light_specular[4]; light_ambient2.put(new float[] { r * 0.3f, g * 0.3f, b * 0.3f, alpha }).flip(); light_diffuse2.put(new float[] { r * 0.7f, g * 0.7f, b * 0.7f, alpha }).flip(); light_specular2.put(new float[] { r * 0.2f, g * 0.2f, b * 0.2f, alpha }).flip(); GL11.glMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_AMBIENT, light_ambient2); GL11.glMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_DIFFUSE, light_diffuse2); GL11.glMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_SPECULAR, light_specular2); GL11.glMaterialf(GL11.GL_FRONT_AND_BACK, GL11.GL_SHININESS, 5.0f); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glMaterialf(int a, int b, float c) { GL11.glMaterialf(a, b, c); }