當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。