当前位置: 首页>>代码示例>>Java>>正文


Java Disk类代码示例

本文整理汇总了Java中org.lwjgl.util.glu.Disk的典型用法代码示例。如果您正苦于以下问题:Java Disk类的具体用法?Java Disk怎么用?Java Disk使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Disk类属于org.lwjgl.util.glu包,在下文中一共展示了Disk类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.lwjgl.util.glu.Disk; //导入依赖的package包/类
/** Initializes the canvas by setting the viewport, lighting, etc. */
       public void init() {
           glShadeModel(GL_SMOOTH);
           glMatrixMode(GL_MODELVIEW);
           glLoadIdentity();
           sphere=new Sphere();
           cylinder=new Cylinder();
           disk=new Disk();
           
           //GL_LIGHT0 is a very dim backlight; with it I can only see silhouetted spheres against oblique walls.
           //GL_LIGHT0 is enabled only in 3D mode.
           floatBuffer = toBuffer(new float[] {0.3f, 0.3f, 0.3f, 1.0f});
           floatBuffer.flip();
           //glLight(GL_LIGHT0, GL_AMBIENT_AND_DIFFUSE, floatBuffer); // RGBA values
           glLight(GL_LIGHT0, GL_AMBIENT, floatBuffer); // RGBA values
           glLight(GL_LIGHT0, GL_DIFFUSE, floatBuffer); // RGBA values
           floatBuffer = toBuffer(new float[] {0.6f, 0.6f, 0.6f, 0.3f});
           floatBuffer.flip();
           glLight(GL_LIGHT0, GL_SPECULAR, floatBuffer);
           floatBuffer = toBuffer(new float[] {0.0f, 0.0f, -1.0f, 0.0f});
           floatBuffer.flip();
           glLight(GL_LIGHT0, GL_POSITION, floatBuffer); // position (directional if last coord is 0)

           //GL_LIGHT1 is enabled only in 3D mode, and its position is set elsewhere
           floatBuffer = toBuffer(new float[] {0.3f, 0.3f, 0.3f, 1.0f});
           floatBuffer.flip();
           glLight(GL_LIGHT1, GL_AMBIENT, floatBuffer); // very dim gray walls; spheres invisible
           floatBuffer = toBuffer(new float[] {0.8f, 0.8f, 0.8f, 1.0f});
           floatBuffer.flip();
           glLight(GL_LIGHT1, GL_DIFFUSE, floatBuffer); // this is most of what we see
           floatBuffer = toBuffer(new float[] {1.0f, 1.0f, 1.0f, 1.0f});
           floatBuffer.flip();
           glLight(GL_LIGHT1, GL_SPECULAR, floatBuffer); // no noticeable contribution - it looks black!

           floatBuffer = toBuffer(new float[] {0.0f, 0.0f, -1.0f, 1.0f});
           floatBuffer.flip();
           glLight(GL_LIGHT1, GL_SPOT_DIRECTION, floatBuffer);
           glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 180);
           glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.5E-5f);
           glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, 64);

           //GL_LIGHT2 is only enabled in 1D and 2D modes.
           floatBuffer = toBuffer(new float[] {0.1f, 0.1f, 0.1f, 1.0f});
           floatBuffer.flip();
           glLight(GL_LIGHT2, GL_AMBIENT, floatBuffer);
           floatBuffer = toBuffer(new float[] {1.0f, 1.0f, 1.0f, 1.0f});
           floatBuffer.flip();
           glLight(GL_LIGHT2, GL_DIFFUSE, floatBuffer);
           floatBuffer = toBuffer(new float[] {0.0f, 0.0f, 0.0f, 1.0f});
           floatBuffer.flip();
           glLight(GL_LIGHT2, GL_SPECULAR, floatBuffer);
           floatBuffer = toBuffer(new float[] {0.0f, 0.0f, 1.0f, 0.0f});
           floatBuffer.flip();
           glLight(GL_LIGHT2, GL_POSITION, floatBuffer);

           glEnable(GL_LIGHTING);
           glColorMaterial(GL_FRONT, GL_DIFFUSE);
           glEnable(GL_COLOR_MATERIAL);
           glEnable(GL_DEPTH_TEST);
           glEnable(GL_NORMALIZE);
           glCullFace(GL_BACK);
           glEnable(GL_CULL_FACE);
           glEnable(GL_POLYGON_SMOOTH);
           glEnable(GL_LINE_SMOOTH);
           glEnable(GL_POINT_SMOOTH);
           glEnable(GL_BLEND);
           glEnable(GL_DITHER);
           glPointSize(tracePointSize);
           curPointSize=tracePointSize;

           //Print valuable OpenGL driver info to the console for debugging.
           System.out.println(glGetString(GL_VENDOR));
           System.out.println(glGetString(GL_RENDERER));
           System.out.println(glGetString(GL_VERSION));
           makeCube();
}
 
开发者ID:derekmanwaring,项目名称:boltzmann-3d,代码行数:77,代码来源:GLPanel.java


注:本文中的org.lwjgl.util.glu.Disk类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。