資源簡介
基于java的opengl計算機圖形學學習資料源碼,包含各種小例子,如機器人,3D模型,鏡面等,深入淺出,適合初學者學習

代碼片段和文件信息
package?A1;
import?com.sun.opengl.util.Animator;
import?java.awt.Color;
import?java.awt.frame;
import?java.awt.event.WindowAdapter;
import?java.awt.event.WindowEvent;
import?javax.media.opengl.GL;
import?javax.media.opengl.GLAutoDrawable;
import?javax.media.opengl.GLCanvas;
import?javax.media.opengl.GLEventListener;
/**
?*?A?class?to?demonstrate?a?simple?JOGL-powered?button?class?and?scene?alternation.
?*?Please?READ?the?code?LEARN?underlying?techniques?and?APPLY?them?to?your?work?of?Assignment?1.
?*
?*?DO?NOT?BLINDLY?COPY?AND?PASTE?THE?SAMPLE?CODE!!
?*?
?*?@author?Johnny?Chien
?*/
public?class?A1?implements?GLEventListener?{
SimpleButton?button;
Renderables?day;
Renderables?night;
????public?static?void?main(String[]?args)?{
????????frame?frame?=?new?frame(“Button?DEMO?for?A1“);
????????GLCanvas?canvas?=?new?GLCanvas();
????????canvas.addGLEventListener(new?A1());??????
????????frame.add(canvas);?
????????frame.setSize(640?640);
????????final?Animator?animator?=?new?Animator(canvas);
????????frame.addWindowListener(new?WindowAdapter()?{
????????????@Override
????????????public?void?windowClosing(WindowEvent?e)?{
????????????????new?Thread(new?Runnable()?{
????????????????????public?void?run()?{
????????????????????????animator.stop();
????????????????????????System.exit(0);
????????????????????}
????????????????}).start();
????????????}
????????});
????????
????????frame.setLocationRelativeTo(null);
????????frame.setVisible(true);
????????animator.start();
????}
????public?void?init(GLAutoDrawable?drawable)?{
????????GL?gl?=?drawable.getGL();
????????gl.setSwapInterval(1);
????????gl.glClearColor(0.0f?0.0f?0.0f?0.0f);
????????gl.glShadeModel(GL.GL_SMOOTH);
????????
????????button?=?new?SimpleButton();
????????drawable.addMouseListener(button);
????????
????????//?compose?the?Day?scene
????????day?=?new?Renderables();??????
????????day.Add(new?GradientSky(Color.BLUE?Color.CYAN));
????????
????????//?compose?the?Night?scene
????????night?=?new?Renderables();
????????night.Add(new?GradientSky(Color.BLACK?Color.GRAY));
????????
????????//?WARNING:?Doing?scene?composition?like?this?hazards?your?code?readability.
????????//??????????It?will?be?a?mess?as?you?put?more?and?more?objects?into?the?scene.
????????//??????????Leave?these?to?each?subclass‘s?constructor!!
????}
????public?void?reshape(GLAutoDrawable?drawable?int?x?int?y?int?width?int?height)?{
????????GL?gl?=?drawable.getGL();
?????? button.UpdateCanvasSize(width?height);?//?tell?buttons?the?new?dimensions?of?the?canvas
????}
????
????public?void?display(GLAutoDrawable?drawable)?{
????????GL?gl?=?drawable.getGL();
????????gl.glClear(GL.GL_COLOR_BUFFER_BIT?|?GL.GL_DEPTH_BUFFER_BIT);
????????gl.glLoadIdentity();
????????if?(button.IsChecked())?{
???????? day.Render(gl);
????????}?else?{
???????? night.Render(gl);
????????}
???
????????button.Render(gl);
????????
????????//?Flush?all?d
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????332??2016-04-15?10:26??opengl\opengl\.classpath
?????文件????????378??2016-04-15?10:21??opengl\opengl\.project
?????文件????????749??2016-12-24?10:41??opengl\opengl\bin\A1\A1$1$1.class
?????文件????????807??2016-12-24?10:41??opengl\opengl\bin\A1\A1$1.class
?????文件???????3144??2016-12-24?10:41??opengl\opengl\bin\A1\A1.class
?????文件????????957??2016-12-24?10:41??opengl\opengl\bin\A1\GradientSky.class
?????文件????????150??2016-12-24?10:41??opengl\opengl\bin\A1\Renderable.class
?????文件???????1030??2016-12-24?10:41??opengl\opengl\bin\A1\Renderables.class
?????文件???????3100??2016-12-24?10:41??opengl\opengl\bin\A1\SimpleButton.class
?????文件????????818??2016-12-24?10:41??opengl\opengl\bin\A2\Heli16Flight$1$1.class
?????文件????????876??2016-12-24?10:41??opengl\opengl\bin\A2\Heli16Flight$1.class
?????文件???????2921??2016-12-24?10:41??opengl\opengl\bin\A2\Heli16Flight.class
?????文件???????1177??2016-12-24?10:41??opengl\opengl\bin\A2\Scene\Camera.class
?????文件???????2157??2016-12-24?10:41??opengl\opengl\bin\A2\Scene\Lighting.class
?????文件???????1053??2016-12-24?10:41??opengl\opengl\bin\autumnground.class
?????文件???????1336??2016-12-24?10:41??opengl\opengl\bin\ForestSystem.class
?????文件???????1035??2016-12-24?10:41??opengl\opengl\bin\ground.class
?????文件???????2310??2016-12-24?10:41??opengl\opengl\bin\human.class
?????文件????????923??2016-12-24?10:41??opengl\opengl\bin\Particle.class
?????文件???????2400??2016-12-24?10:41??opengl\opengl\bin\ParticleSystem.class
?????文件???????3092??2016-12-24?10:41??opengl\opengl\bin\plane.class
?????文件???????1277??2016-12-24?10:41??opengl\opengl\bin\ratatedflower.class
?????文件???????1461??2016-12-24?10:41??opengl\opengl\bin\season$1.class
?????文件???????1305??2016-12-24?10:41??opengl\opengl\bin\season$2.class
?????文件????????758??2016-12-24?10:41??opengl\opengl\bin\season$3$1.class
?????文件????????816??2016-12-24?10:41??opengl\opengl\bin\season$3.class
?????文件???????7375??2016-12-24?10:41??opengl\opengl\bin\season.class
?????文件???????2989??2016-12-24?10:41??opengl\opengl\bin\snowman.class
?????文件???????2053??2016-12-24?10:41??opengl\opengl\bin\SoundPla
?????文件???????1747??2016-12-24?10:41??opengl\opengl\bin\sun.class
............此處省略548個文件信息
評論
共有 條評論