本文整理匯總了Java中javax.media.opengl.GL2.glLightfv方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glLightfv方法的具體用法?Java GL2.glLightfv怎麽用?Java GL2.glLightfv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glLightfv方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: useCamera
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
*
* @param openGl
*/
public void useCamera(final GL2 openGl) {
if (resetProjection) {
resetProjection = false;
setProjection(openGl);
}
openGl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, new float[]{1000.f,1000.f,1000.f}, 0);
openGl.glEnable(GL2.GL_LIGHT0);
openGl.glMatrixMode(GL2.GL_MODELVIEW);
openGl.glLoadIdentity();
position.translateBy(openGl);
product.rotateAround(openGl);
upVector.rotateAround(openGl);
}
示例2: setLights
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void setLights(GL2 gl) {
// prepare light parameters
float SHINE_ALL_DIRECTIONS = 1;
float[] lightPos = { -40, 0, 20, SHINE_ALL_DIRECTIONS };
// 'weak' light which is everywhere
float[] lightColorAmbient = { 0.2f, 0.2f, 0.2f, 1f };
// 'strong' light from a particular spot which creates a 3d-effect
float[] lightColorSpecular = { 0.8f, 0.8f, 0.8f, 1f };
// set light parameters
gl.glLightfv(GL2.GL_LIGHT1, GL2.GL_POSITION, lightPos, 0);
gl.glLightfv(GL2.GL_LIGHT1, GL2.GL_AMBIENT, lightColorAmbient, 0);
gl.glLightfv(GL2.GL_LIGHT1, GL2.GL_SPECULAR, lightColorSpecular, 0);
// enable lights
gl.glEnable(GL2.GL_LIGHT1);
gl.glEnable(GL2.GL_LIGHTING);
}
示例3: initialize
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Called during openGL initialisation. This enables the necessary settings
* and sets up the light source.
*
* @param gl The GL2 instance responsible for drawing the scene.
* @param gs The GlobalState.
*/
public void initialize(GL2 gl, GlobalState gs) {
gl.glEnable(GL_LIGHTING);
gl.glEnable(GL_LIGHT0);
calculatePosition(gs);
gl.glLightfv(GL_LIGHT0, GL_POSITION, lightPos, 0);
gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight, 0);
gl.glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight, 0);
gl.glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight, 0);
}
示例4: setupLighting
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void setupLighting(GLAutoDrawable drawable, GL2 gl) {
int paramsOffset = 0;
float pos[] = { 2.0f, -2.0f, 10.0f, 0.0f };
float ambient[] = {0.5f, 0.5f, 0.5f, 1.0f};
float diffuse[] = {0.9f, 0.9f, 0.9f, 1.0f};
float specular[] = {0.05f, 0.05f, 0.99f, 1.0f};
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, pos, 0);
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0);
gl.glEnable(GL2.GL_DEPTH_TEST);
gl.glEnable(GL2.GL_AUTO_NORMAL);
gl.glEnable(GL2.GL_NORMALIZE);
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, ambient, paramsOffset);
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, diffuse, paramsOffset);
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, specular, paramsOffset);
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, pos, paramsOffset);
gl.glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, GL2.GL_TRUE);
gl.glClearColor(1f, 1f, 1f, 1f);
gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
if (gl instanceof GLLightingFunc) {
((GLLightingFunc) gl).glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_AMBIENT_AND_DIFFUSE, blue, 0);
((GLLightingFunc) gl).glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_SPECULAR, white, 0);
float[] medHiShiny = new float[] {80.0f};
((GLLightingFunc) gl).glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_SHININESS, medHiShiny, 0);
((GLLightingFunc) gl).glShadeModel(GLLightingFunc.GL_FLAT);
}
}
示例5: display
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*
* @see javax.media.opengl.GLEventListener#display(javax.media.opengl.GLAutoDrawable)
*/
@Override
public void display( final GLAutoDrawable drawable )
{
this.updateVis();
final GL2 gl = drawable.getGL().getGL2();
gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW );
gl.glLoadIdentity();
if( this.cameraPosition != null )
{
final float[] pos = this.cameraPosition.getCameraPosition();
this.glu.gluLookAt( pos[0], pos[1], pos[2], pos[3], pos[4], pos[5], pos[6], pos[7], pos[8] );
}
// Prepare light parameters.
if( this.enableLights )
{
final float SHINE_ALL_DIRECTIONS = 1;
final float[] lightPos = {-30, 0, 0, SHINE_ALL_DIRECTIONS};
final float[] lightColorAmbient = {0.2f, 0.2f, 0.2f, 1f};
final float[] lightColorSpecular = {0.5f, 0.5f, 0.5f, 1f};
// Set light parameters.
gl.glLightfv( GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_POSITION, lightPos, 0 );
gl.glLightfv( GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_AMBIENT, lightColorAmbient, 0 );
gl.glLightfv( GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_SPECULAR, lightColorSpecular, 0 );
// Enable lighting in GL.
gl.glEnable( GLLightingFunc.GL_LIGHT1 );
gl.glEnable( GLLightingFunc.GL_LIGHTING );
}
gl.glClear( GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
this.renderVis( drawable );
}
示例6: setView
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Called during the setView part of the loop. Reset the position of the
* light source here, otherwise it will move with the camera.
*
* @param gl The GL2 instance responsible for drawing the scene.
*/
public void setView(GL2 gl) {
gl.glLightfv(GL_LIGHT0, GL_POSITION, lightPos, 0);
}