本文整理匯總了Java中javax.media.opengl.GL.glLightfv方法的典型用法代碼示例。如果您正苦於以下問題:Java GL.glLightfv方法的具體用法?Java GL.glLightfv怎麽用?Java GL.glLightfv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL
的用法示例。
在下文中一共展示了GL.glLightfv方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: configureGLLighting
import javax.media.opengl.GL; //導入方法依賴的package包/類
private void configureGLLighting(GL gl)
{
float global_ambient[] = { 0.5f, 0.5f, 0.5f, 1.0f };
gl.glLightModelfv(GL.GL_LIGHT_MODEL_AMBIENT, global_ambient, 0);
// Create light components
float ambientLight[] = { 0.0f, 0.0f, 0.0f, 1.0f };
float diffuseLight[] = { 0.8f, 0.8f, 0.8f, 1.0f };
float specularLight[] = { 0.5f, 0.5f, 0.5f, 1.0f };
float position[] = { -50.0f, 50.0f, 50.0f, 0.0f };
float direction[] = { 50.0f, -50.0f, -50.0f, 0.0f };
// Assign created components to GL_LIGHT0
gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambientLight, 0);
gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuseLight, 0);
gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, specularLight, 0);
gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, position, 0);
gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPOT_DIRECTION, direction, 0);
gl.glLightf(GL.GL_LIGHT0, GL.GL_SPOT_CUTOFF, 30);
gl.glEnable(GL.GL_COLOR_MATERIAL);
gl.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE);
// now all subsequent glColor commands will also effect the lighting colors.
/*
//light attenuation in function of the vertex distance
float constantAttenuation = 1.0f;
float linearAttenuation = 0.2f;
float quadraticAttenuation = 0.08f;
gl.glLightf(GL.GL_LIGHT0, GL.GL_CONSTANT_ATTENUATION, constantAttenuation);
gl.glLightf(GL.GL_LIGHT0, GL.GL_LINEAR_ATTENUATION, linearAttenuation);
gl.glLightf(GL.GL_LIGHT0, GL.GL_QUADRATIC_ATTENUATION, quadraticAttenuation);
*/
gl.glLightf(GL.GL_LIGHT0, GL.GL_QUADRATIC_ATTENUATION, 0.08f);
}