diff --git a/src/lsystem/Main.java b/src/lsystem/Main.java index cd222ba..562da5c 100644 --- a/src/lsystem/Main.java +++ b/src/lsystem/Main.java @@ -1,14 +1,14 @@ package lsystem; -import lsystem.screen.MainFrame; -import lsystem.screen.SwingGLCanvas; +import lsystem.screen.gl3d.GLCanvas; +import lsystem.screen.main.MainFrame; public class Main { public static void main(String[] args) { MainFrame frame = new MainFrame(); frame.setVisible(true); - SwingGLCanvas canvas = new SwingGLCanvas(); + GLCanvas canvas = new GLCanvas(); canvas.setVisible(true); } diff --git a/src/lsystem/Main2D.java b/src/lsystem/Main2D.java index 5ff480a..c5ffde3 100644 --- a/src/lsystem/Main2D.java +++ b/src/lsystem/Main2D.java @@ -1,8 +1,7 @@ package lsystem; -import lsystem.screen.MainFrame; -import lsystem.screen.SwingGLCanvas; -import lsystem.screen.SwingGLCanvas2D; +import lsystem.screen.gl2d.SwingGLCanvas2D; +import lsystem.screen.main.MainFrame; public class Main2D { @@ -11,6 +10,7 @@ public class Main2D { MainFrame frame = new MainFrame(); frame.setVisible(true); SwingGLCanvas2D canvas = new SwingGLCanvas2D(); + canvas.setVisible(true); } diff --git a/src/lsystem/screen/SwingGLCanvas.java b/src/lsystem/screen/AbstractCanvas.java similarity index 71% rename from src/lsystem/screen/SwingGLCanvas.java rename to src/lsystem/screen/AbstractCanvas.java index 0a073cc..b370263 100644 --- a/src/lsystem/screen/SwingGLCanvas.java +++ b/src/lsystem/screen/AbstractCanvas.java @@ -6,34 +6,27 @@ import com.jogamp.opengl.awt.GLCanvas; import com.jogamp.opengl.glu.GLU; import com.jogamp.opengl.util.FPSAnimator; import com.jogamp.opengl.util.gl2.GLUT; -import lsystem.screen.listener.JoglEventListener; -import lsystem.screen.listener.JoglMouseListener; -import lsystem.screen.listener.KeyboardListener; import javax.swing.*; import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -public class SwingGLCanvas { + +public abstract class AbstractCanvas { public JFrame frame; - FPSAnimator animator; + protected FPSAnimator animator; public final GLCanvas glCanvas; - public float[] camera = {0f, 1f, 5f, // camera pos x,y, z - 0f, 0f, 0f}; // camera rotation yaw(x-axis), pitch(y-axis), roll(z-axis) public GLU glu = new GLU(); public GLUT glut = new GLUT(); + public float[] camera = {0f, 1f, 5f, // camera pos x,y, z + 0f, 0f, 0f}; // camera rotation yaw(x-axis), pitch(y-axis), roll(z-axis) - public SwingGLCanvas() { + + protected AbstractCanvas() { GLProfile glProfile = GLProfile.getDefault(); GLCapabilities glCapabilities = new GLCapabilities(glProfile); this.glCanvas = new GLCanvas(glCapabilities); - glCanvas.addGLEventListener(new JoglEventListener(this)); - JoglMouseListener mouse = new JoglMouseListener(this); - glCanvas.addMouseListener(mouse); - glCanvas.addMouseMotionListener(mouse); - glCanvas.addMouseWheelListener(mouse); - glCanvas.addKeyListener(new KeyboardListener(this)); frame = new JFrame("L-System"); animator = new FPSAnimator(glCanvas, 60); frame.addWindowListener(new WindowAdapter() { @@ -42,11 +35,13 @@ public class SwingGLCanvas { frame.dispose(); } }); - frame.getContentPane().add(glCanvas, BorderLayout.CENTER); frame.setSize(Constants.WIDTH, Constants.HEIGHT); + addEventsListeners(); } + protected abstract void addEventsListeners(); + public void setVisible(boolean bl) { if(bl) animator.start(); diff --git a/src/lsystem/screen/Jogl.java b/src/lsystem/screen/Jogl.java deleted file mode 100644 index 8c06df1..0000000 --- a/src/lsystem/screen/Jogl.java +++ /dev/null @@ -1,116 +0,0 @@ -package lsystem.screen; - -import com.jogamp.opengl.GL; -import com.jogamp.opengl.GL2; -import com.jogamp.opengl.GLAutoDrawable; -import com.jogamp.opengl.GLEventListener; -import com.jogamp.opengl.awt.GLCanvas; -import com.jogamp.opengl.util.Animator; - -import lsystem.screen.listener.JoglEventListener2D; - -import java.awt.*; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - -/** - * Article1.java author: InfoRital - * - * Code source du premier article. Article1 implémente {@link GLEventListener} - * pour obtenir le mécanisme de callback - * - */ - -public class Jogl implements GLEventListener { - - public static void initialize(String[] args) { - // Création de la fenêtre - Frame frame = new Frame("L-système 3D"); - - // Création du canvas pour dessiner dessus - GLCanvas canvas = new GLCanvas(); - - // Nous attachons ensuite le méchanisme de callback à notre surface dessinable - canvas.addGLEventListener((GLEventListener) new Jogl()); - - // dessin -> fenêtre - frame.add(canvas); - - // Création de l'animator - final Animator animator = new Animator(canvas); - - // croix rouge = fermeture de la fenêtre - frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - // Thread pour arrêter l'animator avant la fenêtre - new Thread(animator::stop).start(); - } - }); - - // Taille de la fenêtre - frame.setSize(800, 800); - frame.setVisible(true); - - // Démarrage de l'animator qui va se charger de faire des appels à la méthode - animator.start(); - } - - // init() sera appelée une fois au début de l'animation. C'est dans cette méthode - // que nous nous chargerons de toutes les opérations d'initialisation - public void init(GLAutoDrawable drawable) { - // GLEventListener renvoie un contexte (drawable) - // que nous allons utiliser pour instancier un objet de type GL - // qui nous permettra d'utiliser les fonctions OpenGL - GL gl = drawable.getGL(); - // désactiver la synchronisation verticale indépendamment de la plateforme utilisée - gl.setSwapInterval(1); - } - - // Appelée que si la fenêtre d'affichage est redimensionnée - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - - - } - - // display() sera appelée en boucle tout au long de l'application par la classe Animator. - // C'est dans cette fonction qu'on fera tout ce qui doit être affiché - public void display(GLAutoDrawable drawable) { - GL2 gl = drawable.getGL().getGL2(); - - float xDefault = -1.0f, yDefault = -1.0f; - - /*gl.glBegin(GL2.GL_LINES); - gl.glVertex2f(xDefault, yDefault); - gl.glVertex2f(xDefault + (0.1f * 1), yDefault + (0.1f * 1)); - gl.glEnd(); - - gl.glBegin(GL2.GL_LINES); - gl.glVertex2f(xDefault + (0.1f * 1), -1.1f); - gl.glVertex2f(xDefault + (0.1f * 1) + (0.2f*1), yDefault + (0.1f * 1) + (0.2f*-1)); - gl.glEnd();*/ - DrawHelper.drawStick(gl, 0.1f, xDefault, yDefault, 0); - DrawHelper.drawStick(gl, 0.2f, -0.9f, -0.9f, 90); - } - - /** - * displayChanged() est appelée si le mode d'affichage par exemple est modifié. - */ - /* - * public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, - * boolean deviceChanged) { } - */ - - @Override - public void dispose(GLAutoDrawable arg0) { - // TODO Auto-generated method stub - - } - - public static void main(String[] args) { - //Jogl jogl = new Jogl(); - //jogl.initialize(args); - SwingGLCanvas2D canvas = new SwingGLCanvas2D(); - JoglEventListener2D a = new JoglEventListener2D(canvas); - } - -} diff --git a/src/lsystem/screen/SwingGLCanvas2D.java b/src/lsystem/screen/SwingGLCanvas2D.java deleted file mode 100644 index 0c23d46..0000000 --- a/src/lsystem/screen/SwingGLCanvas2D.java +++ /dev/null @@ -1,53 +0,0 @@ -package lsystem.screen; - -import com.jogamp.opengl.GLCapabilities; -import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.awt.GLCanvas; -import com.jogamp.opengl.glu.GLU; -import com.jogamp.opengl.util.FPSAnimator; -import com.jogamp.opengl.util.gl2.GLUT; -import lsystem.screen.listener.JoglEventListener; -import lsystem.screen.listener.JoglEventListener2D; -import lsystem.screen.listener.JoglMouseListener; -import lsystem.screen.listener.JoglMouseListener2D; -import lsystem.screen.listener.KeyboardListener; -import lsystem.screen.listener.KeyboardListener2D; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -public class SwingGLCanvas2D { - - public final GLCanvas glCanvas; - public float[] camera = {0f, 1f, 5f, // camera pos x,y, z - 0f, 0f, 0f}; // camera rotation yaw(x-axis), pitch(y-axis), roll(z-axis) - public GLU glu = new GLU(); - public GLUT glut = new GLUT(); - - public SwingGLCanvas2D() { - GLProfile glProfile = GLProfile.getDefault(); - GLCapabilities glCapabilities = new GLCapabilities(glProfile); - this.glCanvas = new GLCanvas(glCapabilities); - glCanvas.addGLEventListener(new JoglEventListener2D(this)); - JoglMouseListener2D mouse = new JoglMouseListener2D(this); - glCanvas.addMouseListener(mouse); - glCanvas.addMouseMotionListener(mouse); - glCanvas.addMouseWheelListener(mouse); - glCanvas.addKeyListener(new KeyboardListener2D(this)); - final JFrame jframe = new JFrame("L-System"); - final FPSAnimator animator = new FPSAnimator(glCanvas, 60); - jframe.addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - jframe.dispose(); - } - }); - - jframe.getContentPane().add(glCanvas, BorderLayout.CENTER); - jframe.setSize(Constants.WIDTH, Constants.HEIGHT); - - animator.start(); - jframe.setVisible(true); - } -} diff --git a/src/lsystem/screen/gl2d/JoglEventListener2D.java b/src/lsystem/screen/gl2d/JoglEventListener2D.java new file mode 100644 index 0000000..547a5c3 --- /dev/null +++ b/src/lsystem/screen/gl2d/JoglEventListener2D.java @@ -0,0 +1,61 @@ +package lsystem.screen.gl2d; + +import com.jogamp.opengl.GL2; +import com.jogamp.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLEventListener; +import com.jogamp.opengl.glu.GLU; +import com.jogamp.opengl.util.gl2.GLUT; +import lsystem.screen.gl3d.DrawHelper; + +public class JoglEventListener2D implements GLEventListener { + + private final SwingGLCanvas2D canvas; + + private final GLU glu; + private final GLUT glut; + private int fps; + + public JoglEventListener2D(SwingGLCanvas2D swingGLCanvas) { + this.canvas = swingGLCanvas; + this.glu = canvas.glu; + this.glut = canvas.glut; + } + + @Override + public void init(GLAutoDrawable glAutoDrawable) { + GL2 gl = glAutoDrawable.getGL().getGL2(); + + gl.glClearColor(0f, 0f, 0f, 1.0f); + + new Thread(() -> { + while (canvas.frame.isVisible()) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + System.out.println(fps); + fps = 0; + } + }).start(); + } + + @Override + public void dispose(GLAutoDrawable glAutoDrawable) { + } + + @Override + public void display (GLAutoDrawable glAutoDrawable) { + GL2 gl = glAutoDrawable.getGL().getGL2(); + + float xDefault = -1.0f, yDefault = -1.0f; + + DrawHelper.drawStick(gl, 0.1f, xDefault, yDefault, 0); + DrawHelper.drawStick(gl, 0.2f, -0.9f, -0.9f, 90); + } + + @Override + public void reshape(GLAutoDrawable glAutoDrawable, int x, int y, int width, int height) { + + } +} diff --git a/src/lsystem/screen/listener/JoglMouseListener2D.java b/src/lsystem/screen/gl2d/JoglMouseListener2D.java similarity index 96% rename from src/lsystem/screen/listener/JoglMouseListener2D.java rename to src/lsystem/screen/gl2d/JoglMouseListener2D.java index a1111b0..b11cfff 100644 --- a/src/lsystem/screen/listener/JoglMouseListener2D.java +++ b/src/lsystem/screen/gl2d/JoglMouseListener2D.java @@ -1,8 +1,6 @@ -package lsystem.screen.listener; +package lsystem.screen.gl2d; import com.jogamp.opengl.glu.GLU; -import lsystem.screen.SwingGLCanvas; -import lsystem.screen.SwingGLCanvas2D; import java.awt.*; import java.awt.event.*; diff --git a/src/lsystem/screen/listener/KeyboardListener2D.java b/src/lsystem/screen/gl2d/KeyboardListener2D.java similarity index 91% rename from src/lsystem/screen/listener/KeyboardListener2D.java rename to src/lsystem/screen/gl2d/KeyboardListener2D.java index 7a42ca2..7989eb9 100644 --- a/src/lsystem/screen/listener/KeyboardListener2D.java +++ b/src/lsystem/screen/gl2d/KeyboardListener2D.java @@ -1,7 +1,4 @@ -package lsystem.screen.listener; - -import lsystem.screen.SwingGLCanvas; -import lsystem.screen.SwingGLCanvas2D; +package lsystem.screen.gl2d; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; diff --git a/src/lsystem/screen/gl2d/SwingGLCanvas2D.java b/src/lsystem/screen/gl2d/SwingGLCanvas2D.java new file mode 100644 index 0000000..7a2e068 --- /dev/null +++ b/src/lsystem/screen/gl2d/SwingGLCanvas2D.java @@ -0,0 +1,21 @@ +package lsystem.screen.gl2d; + +import lsystem.screen.AbstractCanvas; + + +public class SwingGLCanvas2D extends AbstractCanvas { + + public SwingGLCanvas2D() { + super(); + } + + @Override + protected void addEventsListeners() { + glCanvas.addGLEventListener(new JoglEventListener2D(this)); + JoglMouseListener2D mouse = new JoglMouseListener2D(this); + glCanvas.addMouseListener(mouse); + glCanvas.addMouseMotionListener(mouse); + glCanvas.addMouseWheelListener(mouse); + glCanvas.addKeyListener(new KeyboardListener2D(this)); + } +} diff --git a/src/lsystem/screen/DrawHelper.java b/src/lsystem/screen/gl3d/DrawHelper.java similarity index 95% rename from src/lsystem/screen/DrawHelper.java rename to src/lsystem/screen/gl3d/DrawHelper.java index fbfac5b..77a268e 100644 --- a/src/lsystem/screen/DrawHelper.java +++ b/src/lsystem/screen/gl3d/DrawHelper.java @@ -1,11 +1,12 @@ -package lsystem.screen; +package lsystem.screen.gl3d; import com.jogamp.opengl.GL2; import com.jogamp.opengl.util.gl2.GLUT; +import lsystem.screen.gl2d.SwingGLCanvas2D; public class DrawHelper { - public static void placeCamera(GL2 gl, SwingGLCanvas canvas) { + public static void placeCamera(GL2 gl, GLCanvas canvas) { gl.glRotatef(canvas.camera[4], 1f, 0f, 0f); gl.glRotatef(canvas.camera[3], 0f, 1f, 0f); gl.glRotatef(canvas.camera[5], 0f, 0f, 1f); @@ -74,7 +75,7 @@ public class DrawHelper { gl.glPopMatrix(); } - public static void drawDebugInformation(GL2 gl, GLUT glut, SwingGLCanvas canvas) { + public static void drawDebugInformation(GL2 gl, GLUT glut, GLCanvas canvas) { gl.glRasterPos3f(canvas.camera[0], canvas.camera[1], canvas.camera[2] - 1); gl.glColor3f(1f, 1f, 1f); glut.glutBitmapString(GLUT.BITMAP_HELVETICA_18, diff --git a/src/lsystem/screen/gl3d/GLCanvas.java b/src/lsystem/screen/gl3d/GLCanvas.java new file mode 100644 index 0000000..97b5ccc --- /dev/null +++ b/src/lsystem/screen/gl3d/GLCanvas.java @@ -0,0 +1,22 @@ +package lsystem.screen.gl3d; + +import lsystem.screen.AbstractCanvas; + + +public class GLCanvas extends AbstractCanvas { + + public GLCanvas() { + super(); + } + + @Override + protected void addEventsListeners() { + glCanvas.addGLEventListener(new GLEventListener(this)); + GLMouseListener mouse = new GLMouseListener(this); + glCanvas.addMouseListener(mouse); + glCanvas.addMouseMotionListener(mouse); + glCanvas.addMouseWheelListener(mouse); + glCanvas.addKeyListener(new GLKeyboardListener(this)); + } + +} diff --git a/src/lsystem/screen/listener/JoglEventListener.java b/src/lsystem/screen/gl3d/GLEventListener.java similarity index 93% rename from src/lsystem/screen/listener/JoglEventListener.java rename to src/lsystem/screen/gl3d/GLEventListener.java index d558c59..0f7dd54 100644 --- a/src/lsystem/screen/listener/JoglEventListener.java +++ b/src/lsystem/screen/gl3d/GLEventListener.java @@ -1,18 +1,17 @@ -package lsystem.screen.listener; +package lsystem.screen.gl3d; -import com.jogamp.opengl.*; +import com.jogamp.opengl.GL2; +import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.glu.GLU; import com.jogamp.opengl.util.gl2.GLUT; -import lsystem.screen.DrawHelper; -import lsystem.screen.SwingGLCanvas; import lsystem.utils.Pair; import java.util.LinkedList; import java.util.Random; -public class JoglEventListener implements GLEventListener { +public class GLEventListener implements com.jogamp.opengl.GLEventListener { - private final SwingGLCanvas canvas; + private final GLCanvas canvas; private final float[] light_0_ambient = {0.01f, 0.01f, 0.01f, 0.01f}; private final float[] light_0_diffuse = {1.0f, 1.0f, 1.0f, 1.0f}; private final float[] light_0_specular = {1.0f,1.0f, 1.0f, 1.0f}; @@ -27,7 +26,7 @@ public class JoglEventListener implements GLEventListener { private final GLUT glut; private int fps; - public JoglEventListener(SwingGLCanvas swingGLCanvas) { + public GLEventListener(GLCanvas swingGLCanvas) { this.canvas = swingGLCanvas; this.glu = canvas.glu; this.glut = canvas.glut; diff --git a/src/lsystem/screen/listener/KeyboardListener.java b/src/lsystem/screen/gl3d/GLKeyboardListener.java similarity index 91% rename from src/lsystem/screen/listener/KeyboardListener.java rename to src/lsystem/screen/gl3d/GLKeyboardListener.java index 07ebda9..4c25d22 100644 --- a/src/lsystem/screen/listener/KeyboardListener.java +++ b/src/lsystem/screen/gl3d/GLKeyboardListener.java @@ -1,16 +1,14 @@ -package lsystem.screen.listener; - -import lsystem.screen.SwingGLCanvas; +package lsystem.screen.gl3d; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; -public class KeyboardListener implements KeyListener { +public class GLKeyboardListener implements KeyListener { - private final SwingGLCanvas canvas; + private final GLCanvas canvas; - public KeyboardListener(SwingGLCanvas swingGLCanvas) { + public GLKeyboardListener(GLCanvas swingGLCanvas) { this.canvas = swingGLCanvas; } diff --git a/src/lsystem/screen/listener/JoglMouseListener.java b/src/lsystem/screen/gl3d/GLMouseListener.java similarity index 92% rename from src/lsystem/screen/listener/JoglMouseListener.java rename to src/lsystem/screen/gl3d/GLMouseListener.java index 90a6d3d..2e72fb1 100644 --- a/src/lsystem/screen/listener/JoglMouseListener.java +++ b/src/lsystem/screen/gl3d/GLMouseListener.java @@ -1,19 +1,18 @@ -package lsystem.screen.listener; +package lsystem.screen.gl3d; import com.jogamp.opengl.glu.GLU; -import lsystem.screen.SwingGLCanvas; import java.awt.*; import java.awt.event.*; -public class JoglMouseListener implements MouseListener, MouseMotionListener, MouseWheelListener { +public class GLMouseListener implements MouseListener, MouseMotionListener, MouseWheelListener { private final GLU glu; - private final SwingGLCanvas canvas; + private final GLCanvas canvas; private int button = 0; private Point origine; - public JoglMouseListener(SwingGLCanvas canvas) { + public GLMouseListener(GLCanvas canvas) { this.canvas = canvas; this.glu = canvas.glu; } diff --git a/src/lsystem/screen/listener/JoglEventListener2D.java b/src/lsystem/screen/listener/JoglEventListener2D.java deleted file mode 100644 index 476124d..0000000 --- a/src/lsystem/screen/listener/JoglEventListener2D.java +++ /dev/null @@ -1,113 +0,0 @@ -package lsystem.screen.listener; - -import com.jogamp.opengl.*; -import com.jogamp.opengl.glu.GLU; -import com.jogamp.opengl.util.gl2.GLUT; -import lsystem.screen.DrawHelper; -import lsystem.screen.SwingGLCanvas; -import lsystem.screen.SwingGLCanvas2D; -import lsystem.utils.Pair; - -import java.util.LinkedList; -import java.util.Random; - -public class JoglEventListener2D implements GLEventListener { - - private final SwingGLCanvas2D canvas; - private final float[] light_0_ambient = {0.01f, 0.01f, 0.01f, 0.01f}; - private final float[] light_0_diffuse = {1.0f, 1.0f, 1.0f, 1.0f}; - private final float[] light_0_specular = {1.0f,1.0f, 1.0f, 1.0f}; - private final float[] light_0_position = {1000f, 1000f, 1000f, 1f}; - - private final float[] material_specular = {0.8f, 0.8f, 0.8f, 0.8f}; - - private float angle = 0f; - private final LinkedList> prismPosition = new LinkedList<>(); - - private final GLU glu; - private final GLUT glut; - private int fps; - - public JoglEventListener2D(SwingGLCanvas2D swingGLCanvas) { - this.canvas = swingGLCanvas; - this.glu = canvas.glu; - this.glut = canvas.glut; - } - - - @Override - public void init(GLAutoDrawable glAutoDrawable) { - GL2 gl = glAutoDrawable.getGL().getGL2(); - - gl.glClearColor(0f, 0f, 0f, 1.0f); - gl.glEnable(GL2.GL_DEPTH_TEST); - gl.glEnable(GL2.GL_LIGHT0); - gl.glEnable(GL2.GL_LIGHTING); - gl.glEnable(GL2.GL_NORMALIZE); - gl.glEnable(GL2.GL_COLOR_MATERIAL); - - gl.glClearDepth(1.0f); - gl.glShadeModel(GL2.GL_SMOOTH); - - gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, light_0_ambient, 0); - gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, light_0_diffuse, 0); - gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, light_0_specular, 0); - - gl.glDepthFunc(GL2.GL_LEQUAL); - gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST); - for(int i = -50; i < 51; ++i) { - for(int j = -50; j < 51; ++j) { - if(new Random().nextFloat() < 0.05) { - prismPosition.add(new Pair<>(i, j)); - } - } - } - System.out.println(prismPosition.size() * 8); - new Thread(() -> { - while (true) { - synchronized (this){ - try { - wait(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - System.out.println(fps); - fps = 0; - } - } - }).start(); - } - - @Override - public void dispose(GLAutoDrawable glAutoDrawable) { - - } - - @Override - public void display (GLAutoDrawable glAutoDrawable) { - GL2 gl = glAutoDrawable.getGL().getGL2(); - - float xDefault = -1.0f, yDefault = -1.0f; - - - DrawHelper.drawStick(gl, 0.1f, xDefault, yDefault, 0); - DrawHelper.drawStick(gl, 0.2f, -0.9f, -0.9f, 90); - } - - @Override - public void reshape(GLAutoDrawable glAutoDrawable, int x, int y, int width, int height) { - GL2 gl = glAutoDrawable.getGL().getGL2(); - gl.glViewport(x, y, width, height); - - gl.glMatrixMode(GL2.GL_PROJECTION); - gl.glLoadIdentity(); - glu.gluPerspective(60.0f, (float) width / height, 0.1f, 1000.0f); - - gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, light_0_position, 0); - gl.glColorMaterial(GL2.GL_FRONT_AND_BACK, GL2.GL_AMBIENT_AND_DIFFUSE); - gl.glMateriali(GL2.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 90); - gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_SPECULAR, material_specular, 0); - - gl.glMatrixMode(GL2.GL_MODELVIEW); - } -} diff --git a/src/lsystem/screen/listener/Listener.java b/src/lsystem/screen/main/Listener.java similarity index 97% rename from src/lsystem/screen/listener/Listener.java rename to src/lsystem/screen/main/Listener.java index 96127fd..b016e17 100644 --- a/src/lsystem/screen/listener/Listener.java +++ b/src/lsystem/screen/main/Listener.java @@ -1,10 +1,8 @@ -package lsystem.screen.listener; +package lsystem.screen.main; import lsystem.engine.Element; import lsystem.engine.Parser; import lsystem.engine.Rewrite; -import lsystem.screen.MainFrame; -import lsystem.screen.Tab; import javax.swing.*; import java.awt.event.ActionEvent; diff --git a/src/lsystem/screen/MainFrame.java b/src/lsystem/screen/main/MainFrame.java similarity index 97% rename from src/lsystem/screen/MainFrame.java rename to src/lsystem/screen/main/MainFrame.java index 4cedf87..7bf8d54 100644 --- a/src/lsystem/screen/MainFrame.java +++ b/src/lsystem/screen/main/MainFrame.java @@ -1,7 +1,7 @@ -package lsystem.screen; +package lsystem.screen.main; -import lsystem.screen.listener.Listener; +import lsystem.screen.Constants; import javax.swing.*; import java.awt.*; diff --git a/src/lsystem/screen/Tab.java b/src/lsystem/screen/main/Tab.java similarity index 98% rename from src/lsystem/screen/Tab.java rename to src/lsystem/screen/main/Tab.java index d320d07..6c62f09 100644 --- a/src/lsystem/screen/Tab.java +++ b/src/lsystem/screen/main/Tab.java @@ -1,6 +1,4 @@ -package lsystem.screen; - -import lsystem.screen.listener.Listener; +package lsystem.screen.main; import javax.swing.*; import java.awt.*;