Problème de "Freeze" avec JOGL (avec display et init vide)

Résolu/Fermé
threadom Messages postés 101 Date d'inscription mardi 8 avril 2003 Statut Membre Dernière intervention 1 novembre 2007 - 30 sept. 2006 à 11:54
threadom Messages postés 101 Date d'inscription mardi 8 avril 2003 Statut Membre Dernière intervention 1 novembre 2007 - 1 oct. 2006 à 12:53
Bonjour, (Vous avez vu j'y pense :p)

    Je vais vous exposé mon problème. J'ai donc créer un simple applet utilisant JOGL, cependant en le lancant via "Eclipse" j'ai un violent "Freeze" qui dure 2 ou 3 seconde voir plus, toute les 4 ou 5 seconde. J'ai essayé de débuger un peu et apparament il semblerais que ce soit le lancement (start) d'animator qui créer ce freeze.

   Plus exactement quand je lance l'applet avec eclipse, la fenetre s'affiche, et la surface opengl ce créer correctement, seulement... des que j'essaye de bouger la fenetre celle ci semble bloqué... mais peu après celle ci va bougé correctement pendant quelque seconde, et ensutie rebloqué, ect.

   Lorsque je dessine un simple carré qui change aléatoirement de couleur, on s'appercois que ce n'est pas que la fenetre qui freeze mais aussi la suface ogl.

   Quelqu'un a t'il une idée pour résoudre le problème, ou alors de ce que j'ai bien pu faire de MAL ? Car je n'en doute pas ca devrais marché, ca marchais quand mon code etais implémenté autrement, donc ma facon doit avoir quelque chose d'incorrect ... mais je ne vois pas quoi.

package pGAME.pGFXE.pOutput;

import java.applet.Applet;
import java.awt.Graphics;

import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;

import com.sun.opengl.util.Animator;
import com.sun.opengl.util.GLUT;

import pGAME.cGAME;
import pGAME.pGFXE.pOutput.pAnimator.cAnimator;
import pGAME.pOther.cDebug;

public class cOutput implements GLEventListener {
    //****************************************************************************************
    GLCapabilities P_oCapabilities = null;
    GLCanvas P_oCanvas = null;
    Animator P_oAnimator = null;
    //****************************************************************************************
    public void init(Applet P_oApplet) {
        try {
            cDebug.print(cOutput.class, "BEG", "init(Applet P_oApplet)");
            cDebug.print(cOutput.class, "BEG", "P_oApplet = " + P_oApplet.toString());
            
            P_oApplet.setSize(640, 480);
            P_oApplet.setLayout(null);
            P_oCapabilities = new GLCapabilities();
            P_oCanvas = new GLCanvas(P_oCapabilities);
            P_oCanvas.setSize(640, 480);
            P_oCanvas.addGLEventListener(this);
            P_oAnimator = new Animator(P_oCanvas);
            P_oAnimator.start();
            P_oApplet.add(P_oCanvas, null);
        }
        catch(Exception e)  {
            cDebug.print(cOutput.class, "ERR", "init() - Exception >> " + e.toString());
        }
        finally {
            cDebug.print(cOutput.class, "END", "init()");
        }
    }
    //****************************************************************************************
    public void start() {
        try {
            cDebug.print(cOutput.class, "BEG", "start()");
        }
        catch(Exception e)  {
            cDebug.print(cOutput.class, "ERR", "start() - Exception >> " + e.toString());
        }
        finally {
            cDebug.print(cOutput.class, "END", "start()");
        }
    }
    //****************************************************************************************
    public void paint(Graphics P_oGraphics) {
        try {
            cDebug.print(cOutput.class, "BEG", "paint(Graphics P_oGraphics)");
            cDebug.print(cOutput.class, "BEG", "P_oGraphics = " + P_oGraphics.toString());
        }
        catch(Exception e)  {
            cDebug.print(cGAME.class, "ERR", "paint(Graphics P_oGraphics) - Exception >> " + e.toString());
        }
        finally {
            cDebug.print(cGAME.class, "END", "paint(Graphics P_oGraphics)");
        }
    }
    //****************************************************************************************
    public void init(GLAutoDrawable P_oDrawable) {
       // J'ai vidé délibérément pour tester
    }
    //****************************************************************************************
    public void display(GLAutoDrawable P_oDrawable) {
       // J'ai vidé délibérément pour tester
    }
    //****************************************************************************************
    public void reshape(GLAutoDrawable P_oDrawable, int P_iX, int P_iY, int P_iW, int P_iH) {
        try {
            cDebug.print(cOutput.class, "BEG", "reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4)");
            cDebug.print(cOutput.class, "BEG", "P_oDrawable = " + P_oDrawable.toString());
        }
        catch(Exception e)  {
            cDebug.print(cOutput.class, "ERR", "reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) - Exception >> " + e.toString());
        }
        finally {
            cDebug.print(cOutput.class, "END", "reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4)");
        }
    }
    //****************************************************************************************
    public void displayChanged(GLAutoDrawable P_oDrawable, boolean arg1, boolean arg2) {
        try {
            cDebug.print(cOutput.class, "BEG", "displayChanged(GLAutoDrawable P_oDrawable, boolean arg1, boolean arg2)");
            cDebug.print(cOutput.class, "BEG", "P_oDrawable = " + P_oDrawable.toString());
        }
        catch(Exception e)  {
            cDebug.print(cOutput.class, "ERR", "displayChanged(GLAutoDrawable P_oDrawable, boolean arg1, boolean arg2) - Exception >> " + e.toString());
        }
        finally {
            cDebug.print(cOutput.class, "END", "displayChanged(GLAutoDrawable P_oDrawable, boolean arg1, boolean arg2)");
        }
    }
    //****************************************************************************************
    public void stop() {
        try {
            cDebug.print(cOutput.class, "BEG", "stop()");
        }
        catch(Exception e)  {
            cDebug.print(cOutput.class, "ERR", "stop() - Exception >> " + e.toString());
        }
        finally {
            cDebug.print(cOutput.class, "END", "stop()");
        }
    }
    //****************************************************************************************
    public void destroy() {
        try {
            cDebug.print(cOutput.class, "BEG", "destroy()");
            P_oAnimator.stop();
            P_oAnimator = null;
            P_oCanvas = null;
            P_oCapabilities = null;
        }
        catch(Exception e)  {
            cDebug.print(cOutput.class, "ERR", "destroy() - Exception >> " + e.toString());
        }
        finally {
            cDebug.print(cOutput.class, "END", "destroy()");
        }
    }
    //****************************************************************************************
}

18 réponses

threadom Messages postés 101 Date d'inscription mardi 8 avril 2003 Statut Membre Dernière intervention 1 novembre 2007
1 oct. 2006 à 12:51
Grosso Modo on a donc ca :

L'applet est devenu un JApplet (désolé pour ceux qui n'aiment pas Swing)
Eternia.java :

import java.awt.Graphics;




import javax.swing.JApplet;





import pGAME.cGAME;
import pGAME.pOther.cDebug;





public class Eternia extends JApplet {
 //****************************************************************************************
 private static final long serialVersionUID = 1L;
 public cGAME M_oGAME = new cGAME();
 //****************************************************************************************
 public void init() {
  try {
   cDebug.print(Eternia.class, "BEG", "init()");
   M_oGAME.init(this);
  }
  catch(Exception e)  {
   cDebug.print(Eternia.class, "ERR", "init() - Exception >> " + e.toString());
  }
  finally {
   cDebug.print(Eternia.class, "END", "init()");
  }
 }
 //****************************************************************************************
 public void start() {
  try {
   cDebug.print(Eternia.class, "BEG", "start()");
   M_oGAME.start();
  }
  catch(Exception e)  {
   cDebug.print(Eternia.class, "ERR", "start() - Exception >> " + e.toString());
  }
  finally {
   cDebug.print(Eternia.class, "END", "start()");
  }
 }
 //****************************************************************************************
 public void paint(Graphics P_oGraphics) {
  try {
   cDebug.print(Eternia.class, "BEG", "paint(Graphics P_oGraphics)");
   cDebug.print(Eternia.class, "BEG", "P_oGraphics = " + P_oGraphics.toString());
   M_oGAME.paint(P_oGraphics);
  }
  catch(Exception e) {
   cDebug.print(Eternia.class, "ERR", "paint(Graphics P_oGraphics) - Exception >> " + e.toString());
  }
  finally {
   cDebug.print(Eternia.class, "END", "paint(Graphics P_oGraphics)");
  }
 }
 //****************************************************************************************
 public void stop() {
  try {
   cDebug.print(Eternia.class, "BEG", "stop()");
   M_oGAME.stop();
  }
  catch(Exception e)  {
   cDebug.print(Eternia.class, "ERR", "stop() - Exception >> " + e.toString());
  }
  finally {
   cDebug.print(Eternia.class, "END", "stop()");
  }
 }
 //****************************************************************************************
 public void destroy() {
  try {
   cDebug.print(Eternia.class, "BEG", "destroy()");
   M_oGAME.destroy();
  }
  catch(Exception e)  {
   cDebug.print(Eternia.class, "ERR", "destroy() - Exception >> " + e.toString());
  }
  finally {
   cDebug.print(Eternia.class, "END", "destroy()");
  }
 }
 //****************************************************************************************
}


Ensuite pour le fichier cOutput c'est la que la différence est vraiment notable :
L'applet est devenu un extends GLJPanel et le canvas a été retirer, pour palier au problème de freeze du canvas.
Disparition de la methode paint (Celle ci court circuite la methode Display de JOGL)
Après le reste des changements sont seulement pour moi).


package pGAME.pGFXE.pOutput;





import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLJPanel;
import javax.swing.JApplet;





import pGAME.pOther.cDebug;





import com.sun.opengl.util.Animator;
import com.sun.opengl.util.FPSAnimator;





public class cOutput extends GLJPanel implements GLEventListener {
 // ****************************************************************************************
 private static final long serialVersionUID = 1L;
 Animator M_oAnimator = null;
 // ****************************************************************************************

 public void init(JApplet P_oApplet) {

  try {
   cDebug.print(cOutput.class, "BEG", "init(JApplet P_oApplet)");
   cDebug.print(cOutput.class, "BEG", "P_oApplet = " + P_oApplet.toString());







   P_oApplet.setSize(640, 480);
   P_oApplet.setLayout(null);
   this.setSize(P_oApplet.getSize());
   this.addGLEventListener(this);
   P_oApplet.add(this, null);
   M_oAnimator = new FPSAnimator(this, 60);


   M_oAnimator.start();
  } catch (Exception e) {
   cDebug.print(cOutput.class, "ERR", "init(JApplet P_oApplet) - Exception >> " + e.toString());
  } finally {
   cDebug.print(cOutput.class, "END", "init(JApplet P_oApplet)");
  }
 }





 // ****************************************************************************************
 public void start() {
  try {
   cDebug.print(cOutput.class, "BEG", "start()");
  } catch (Exception e) {
   cDebug.print(cOutput.class, "ERR", "start() - Exception >> " + e.toString());
  } finally {
   cDebug.print(cOutput.class, "END", "start()");
  }
 }
 // ****************************************************************************************
 // public void paint(Graphics P_oGraphics) {
 // try {
 // cDebug.print(cOutput.class, "BEG", "paint(Graphics P_oGraphics)");
 // cDebug.print(cOutput.class, "BEG", "P_oGraphics = " +
 // P_oGraphics.toString());
 // }
 // catch(Exception e) {
 // cDebug.print(cOutput.class, "ERR", "paint(Graphics P_oGraphics) -
 // Exception >> " + e.toString());
 // }
 // finally {
 // cDebug.print(cOutput.class, "END", "paint(Graphics P_oGraphics)");
 // }
 // }
 // ****************************************************************************************
 public void init(GLAutoDrawable P_oDrawable) {
  try {
   cDebug.print(cOutput.class, "BEG", "init(GLAutoDrawable P_oDrawable)");
   cDebug.print(cOutput.class, "BEG", "P_oDrawable = " + P_oDrawable.toString());





   GL L_oGL = P_oDrawable.getGL();





   L_oGL.glClearColor(0, 0, 0, 0);
   L_oGL.glShadeModel(GL.GL_FLAT);
   
   double L_oW = 80;
   double L_oH = 60;
   double L_oD = 100;





   double L_oL = -(Math.abs(L_oW) / 2);
   double L_oR = +(Math.abs(L_oW) / 2);
   double L_oT = -(Math.abs(L_oH) / 2);
   double L_oB = +(Math.abs(L_oH) / 2);
   L_oGL.glOrtho(L_oL, L_oR, L_oT, L_oB, 1, L_oD);
  } catch (Exception e) {
   cDebug.print(cOutput.class, "ERR", "init(GLAutoDrawable P_oDrawable) - Exception >> " + e.toString());
  } finally {
   cDebug.print(cOutput.class, "END", "init(GLAutoDrawable P_oDrawable)");
  }
 }
 // ****************************************************************************************
 public void display(GLAutoDrawable P_oDrawable) {
  try {
   cDebug.print(cOutput.class, "BEG", "display(GLAutoDrawable P_oDrawable)");
   cDebug.print(cOutput.class, "BEG", "P_oDrawable = " + P_oDrawable.toString());





   GL L_oGL = P_oDrawable.getGL();
   
   L_oGL.glClear(GL.GL_COLOR_BUFFER_BIT);
   
   for (float y = -30; y < 30; y++) {
    for (float x = -40; x < 40; x++) {
     L_oGL.glColor3d(Math.random(), Math.random(), Math.random());
     L_oGL.glBegin(GL.GL_QUADS);
     L_oGL.glVertex3f(x, y, -5);
     L_oGL.glVertex3f(x, y + 1, -5);
     L_oGL.glVertex3f(x + 1, y + 1, -5);
     L_oGL.glVertex3f(x + 1, y, -5);
     L_oGL.glEnd();
    }
   }
  } catch (Exception e) {
   cDebug.print(cOutput.class, "ERR", "display(GLAutoDrawable P_oDrawable) - Exception >> " + e.toString());
  } finally {
   cDebug.print(cOutput.class, "END", "display(GLAutoDrawable P_oDrawable)");
  }
 }





 // ****************************************************************************************
 public void reshape(GLAutoDrawable P_oDrawable, int P_iX, int P_iY, int P_iW, int P_iH) {
  try {
   cDebug.print(cOutput.class, "BEG", "reshape(GLAutoDrawable P_oDrawable, int P_iX, int P_iY, int P_iW, int P_iH)");
   cDebug.print(cOutput.class, "BEG", "P_oDrawable = " + P_oDrawable.toString());
  } catch (Exception e) {
   cDebug.print(cOutput.class, "ERR", "reshape(GLAutoDrawable P_oDrawable, int P_iX, int P_iY, int P_iW, int P_iH) - Exception >> " + e.toString());
  } finally {
   cDebug.print(cOutput.class, "END", "reshape(GLAutoDrawable P_oDrawable, int P_iX, int P_iY, int P_iW, int P_iH)");
  }
 }





 // ****************************************************************************************
 public void displayChanged(GLAutoDrawable P_oDrawable, boolean P_iW, boolean P_iH) {
  try {
   cDebug.print(cOutput.class, "BEG", "displayChanged(GLAutoDrawable P_oDrawable, boolean P_iW, boolean P_iH)");
   cDebug.print(cOutput.class, "BEG", "P_oDrawable = " + P_oDrawable.toString());
  } catch (Exception e) {
   cDebug.print(cOutput.class, "ERR", "displayChanged(GLAutoDrawable P_oDrawable, boolean P_iW, boolean P_iH) - Exception >> " + e.toString());
  } finally {
   cDebug.print(cOutput.class, "END", "displayChanged(GLAutoDrawable P_oDrawable, boolean P_iW, boolean P_iH)");
  }
 }






 // ****************************************************************************************
 public void stop() {
  try {
   cDebug.print(cOutput.class, "BEG", "stop()");
  } catch (Exception e) {
   cDebug.print(cOutput.class, "ERR", "stop() - Exception >> " + e.toString());
  } finally {
   cDebug.print(cOutput.class, "END", "stop()");
  }
 }
 // ****************************************************************************************
 public void destroy() {
  try {
   cDebug.print(cOutput.class, "BEG", "destroy()");
   M_oAnimator.stop();
  } catch (Exception e) {
   cDebug.print(cOutput.class, "ERR", "destroy() - Exception >> " + e.toString());
  } finally {
   cDebug.print(cOutput.class, "END", "destroy()");
  }
 }
 // ****************************************************************************************
}
3
Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 111
30 sept. 2006 à 12:22
Salut,

tu n'a pas de methode init pour ton applet :

la methode init d'un applet doit correspondre à public void init(); et non autre chose

------------------------------------
"On n'est pas au resto : ici on ne fait pas dans les plats tout cuits ..."

WORA
0
threadom Messages postés 101 Date d'inscription mardi 8 avril 2003 Statut Membre Dernière intervention 1 novembre 2007
30 sept. 2006 à 12:33
Salut Twinuts :)




public class cOutput implements GLEventListener {  << L'applet n'est pas implémenté ici. ;)




Mes méthodes init & co, de l'applet sont crées en amont dans une class que l'on nomera Eternia (pour pas m'embété) comme ceci :

import java.applet.Applet;
import java.awt.Graphics;



import pGAME.cGAME;
import pGAME.pOther.cDebug;



public class Eternia extends Applet {
 //****************************************************************************************
 private static final long serialVersionUID = 1L;
 public cGAME M_oGAME = new cGAME();
 //****************************************************************************************
 public void init() {
  try {
   cDebug.print(Eternia.class, "BEG", "init()");
   M_oGAME.init(this);
  }
  catch(Exception e)  {
   cDebug.print(Eternia.class, "ERR", "init() - Exception >> " + e.toString());
  }
  finally {
   cDebug.print(Eternia.class, "END", "init()");
  }
 }
 //****************************************************************************************
 public void start() {
  try {
   cDebug.print(Eternia.class, "BEG", "start()");
   M_oGAME.start();
  }
  catch(Exception e)  {
   cDebug.print(Eternia.class, "ERR", "start() - Exception >> " + e.toString());
  }
  finally {
   cDebug.print(Eternia.class, "END", "start()");
  }
 }
 //****************************************************************************************
 public void paint(Graphics P_oGraphics) {
  try {
   cDebug.print(Eternia.class, "BEG", "paint(Graphics P_oGraphics)");
   cDebug.print(Eternia.class, "BEG", "P_oGraphics = " + P_oGraphics.toString());
   
   M_oGAME.paint(P_oGraphics);
  }
  catch(Exception e) {
   cDebug.print(Eternia.class, "ERR", "paint(Graphics g) - Exception >> " + e.toString());
  }
  finally {
   cDebug.print(Eternia.class, "END", "paint(Graphics g)");
  }
 }
 //****************************************************************************************
 public void stop() {
  try {
   cDebug.print(Eternia.class, "BEG", "stop()");
   M_oGAME.stop();
  }
  catch(Exception e)  {
   cDebug.print(Eternia.class, "ERR", "stop() - Exception >> " + e.toString());
  }
  finally {
   cDebug.print(Eternia.class, "END", "stop()");
  }
 }
 //****************************************************************************************
 public void destroy() {
  try {
   cDebug.print(Eternia.class, "BEG", "destroy()");
   M_oGAME.destroy();
  }
  catch(Exception e)  {
   cDebug.print(Eternia.class, "ERR", "destroy() - Exception >> " + e.toString());
  }
  finally {
   cDebug.print(Eternia.class, "END", "destroy()");
  }
 }
 //****************************************************************************************
}


Ensuite on tombe dans ma class cGame qui elle réutilise les fonctions pour repassé tout dans cGFXE, et dans cSFXE, qui refont la meme chose avec leur cOutput, cInput, cMixer, cStream, et peut être cAnimator si ma seule solution sera de personnalisé :'(

Je sais j'aurais du faire autrement pour ca mais je verais ca qu'en dernier recourt car ca impliquerais une modification trop conséquente du code. Heu en faite ptet pas mais bon ... on vera après.
0
Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 111
30 sept. 2006 à 12:46
Salut,

tu as cerné le problème? il vient d''ou? Eternia, cGAME, cGFXE ou cSFXE

------------------------------------
"On n'est pas au resto : ici on ne fait pas dans les plats tout cuits ..."

WORA
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
threadom Messages postés 101 Date d'inscription mardi 8 avril 2003 Statut Membre Dernière intervention 1 novembre 2007
30 sept. 2006 à 12:54
Il vient de la class cOutput plus exactement de Animator.start(), si je ne lance pas la thread de l'objet ca passe. C'est elle qui créer l'acces a public void display(GLAutoDrawable P_oDrawable);

Si je ne la lance pas alors pas de problème mais dans ce cas pas d'animation ...

J'ai esayé l'autre jour en créeant moi même une thread qui lance la fonction ... tant que je lancais display toute les 100ms sleep(100) ca allais mais quand j'ai mis un sleep(50) rebelote. et pourtant mon Display est vide.

La je suis en train de regardé si il n'y aura pas un mini conflit entre Paint() de l'applet (cEternia) et le Display JOGL de cOutput. Mais apparament ca ne semble pas être ca non plus ...
0
threadom Messages postés 101 Date d'inscription mardi 8 avril 2003 Statut Membre Dernière intervention 1 novembre 2007
30 sept. 2006 à 13:03
Je vais essayé d'en savoir encore plus ... je viens de retester et la seule idée qui me vienne c'est que ca ce produit essentiellement lorsque je passe sur la surface avec le curseurs, que j'essaye de bougé la fenetre, bref lorsqu'il y'a un evenement que l'applet ou jogl doit détecté que le problème intervient....

Bref pour être sur je vais lancé l'applet et regardé pendant 5 minute, curseur en dehors de l'applet et du canvas jogl, sans rien touché voir si ca freeze .... super le test ....
0
threadom Messages postés 101 Date d'inscription mardi 8 avril 2003 Statut Membre Dernière intervention 1 novembre 2007
30 sept. 2006 à 13:16
Bilan du test ... tant que je touche pas a l'applet, et au canvas, pas de problème ca tourne du feu de dieu, mème en me baladant sur les autres fenetre superposé ou pas.


J'ai essayé d'implémenté KeyListener,MouseListener,MouseMotionListener sur cOutput ajouté a mon canvas ... nada ca résoud rien ...
0
Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 111
30 sept. 2006 à 13:37
Salut,

tu fais quoi dans Animator (un bout de code pour voir ce que tu ferais de mal)

------------------------------------
"On n'est pas au resto : ici on ne fait pas dans les plats tout cuits ..."

WORA
0
threadom Messages postés 101 Date d'inscription mardi 8 avril 2003 Statut Membre Dernière intervention 1 novembre 2007
30 sept. 2006 à 13:37
Voila bon bein j'ai retapé un peu le Code histoire que tout sois clair et que d'autre personne puisse essayé ... peut etre que ca ne le fais que chez moi ...

import java.applet.Applet;
import java.awt.Graphics;


import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;


import com.sun.opengl.util.Animator;


public class Eternia extends Applet implements GLEventListener {
 //****************************************************************************************
 private static final long serialVersionUID = 1L;
 Animator M_oAnimator = null;
 //****************************************************************************************
 public void init() {
  try {
   this.setSize(640, 480);
   this.setLayout(null);
   GLCapabilities L_oCapabilities = new GLCapabilities();
   GLCanvas L_oCanvas = new GLCanvas(L_oCapabilities);
   L_oCanvas.setSize(640, 480);
   M_oAnimator = new Animator(L_oCanvas);
   M_oAnimator.start();
   L_oCanvas.addGLEventListener(this);
   this.add(L_oCanvas, null);
  }
  catch(Exception e)  {
  }
  finally {
  }
 }
 //****************************************************************************************
 public void start() {
  try {
  }
  catch(Exception e)  {
  }
  finally {
  }
 }
 //****************************************************************************************
 public void paint(Graphics P_oGraphics) {
 }
 //****************************************************************************************
 public void stop() {
  try {
  }
  catch(Exception e)  {
  }
  finally {
  }
 }
 //****************************************************************************************
 public void destroy() {
  try {
   M_oAnimator.stop();
  }
  catch(Exception e)  {
  }
  finally {
  }
 }
 //****************************************************************************************


 //****************************************************************************************
 public void init(GLAutoDrawable P_oDrawable) {
  try {
   GL L_oGL = P_oDrawable.getGL();


   L_oGL.glClearColor(0, 0, 0, 0);
   L_oGL.glShadeModel(GL.GL_FLAT);
//   L_oGL.setSwapInterval(1);
   double L_oW = 40;
   double L_oH = 30;
   double L_oD = 100;
   
   double L_oL = -(Math.abs(L_oW) / 2);
   double L_oR = +(Math.abs(L_oW) / 2);
   double L_oT = -(Math.abs(L_oH) / 2);
   double L_oB = +(Math.abs(L_oH) / 2);
   L_oGL.glOrtho(L_oL, L_oR, L_oT, L_oB, 1, L_oD);
  }
  catch(Exception e)  {
  }
  finally {
  }
 }
 //****************************************************************************************
 public void display(GLAutoDrawable P_oDrawable) {
  try {
   GL L_oGL = P_oDrawable.getGL();
   //GLU L_oGLU = new GLU();
   //GLUT L_oGLUT = new GLUT();
   
   L_oGL.glClear(GL.GL_COLOR_BUFFER_BIT);
   
   for (float y = -15; y < 15; y++) {
    for (float x = -20; x < 20; x++) {
     L_oGL.glColor3d(Math.random(), Math.random(), Math.random());
     L_oGL.glBegin(GL.GL_QUADS);
      L_oGL.glVertex3f(x, y, -5);
      L_oGL.glVertex3f(x, y+1, -5);
      L_oGL.glVertex3f(x+1, y+1, -5);
      L_oGL.glVertex3f(x+1, y, -5);
     L_oGL.glEnd();
    }
   }
  }
  catch(Exception e)  {
  }
  finally {
  }
 }
 //****************************************************************************************
 public void reshape(GLAutoDrawable P_oDrawable, int P_iX, int P_iY, int P_iW, int P_iH) {
  try {
  }
  catch(Exception e)  {
  }
  finally {
  }
 }
 //****************************************************************************************
 public void displayChanged(GLAutoDrawable P_oDrawable, boolean arg1, boolean arg2) {
  try {
   GL L_oGL = P_oDrawable.getGL();


   L_oGL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
   L_oGL.glShadeModel(GL.GL_FLAT);
  }
  catch(Exception e)  {
  }
  finally {
  }
 }
}


 
0
threadom Messages postés 101 Date d'inscription mardi 8 avril 2003 Statut Membre Dernière intervention 1 novembre 2007
30 sept. 2006 à 13:40
Dans mon cAnimator (qui n'est pas Animator de JOGL) je fais :

package pGAME.pGFXE.pOutput.pAnimator;




import javax.media.opengl.GLCanvas;





import pGAME.pOther.cDebug;





public class cAnimator implements Runnable {
 private Thread M_oThread = null;
 private boolean M_bState = false;
 private GLCanvas M_oCanvas = null;
 
 public cAnimator(GLCanvas P_oCanvas) {
  M_oThread = new Thread(this);
  M_oCanvas = P_oCanvas;
 }
 public void start() {
  M_bState = true;
  M_oThread.start();
 }
 public void run() {
  try {
   cDebug.print(cAnimator.class, "BEG", "write()");
   while (M_bState) {
    M_oCanvas.display();
    //cDebug.print(cAnimator.class, "DO", "run()");
    Thread.sleep(100);
   }
  }
  catch(Exception e)  {
   cDebug.print(cAnimator.class, "ERR", "write() - Exception >> " + e.toString());
  }
  finally {
   cDebug.print(cAnimator.class, "END", "write()");
  }
 }
 public void stop() {
  M_bState = false;
  M_oThread = null;
 }
}


Mais bon je l'utilise plus vu que ca reviens au même que Animator de JOGL
0
Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 111
30 sept. 2006 à 13:43
Salut,

oki j'ai rien dis pour Animator je pensai que c'etait une classe a toi

pour la souris et les mouvements de la fenetre c'est normale cu qu tu vas déclancher un repaint donc 2 choses :

1 pourquoi tu redef public void paint(Graphics P_oGraphics) ???? vu que tu utilise celui de jogl
2 peux tu mettres cette methode de ton applet à true : setIgnoreRepaint(true); pour voir si jogl gere vraiment le repaint tout seul et dans ce cas cela risque plus de poser des probs de l'aisser la jvm le gérer aussi.

------------------------------------
"On n'est pas au resto : ici on ne fait pas dans les plats tout cuits ..."

WORA
0
threadom Messages postés 101 Date d'inscription mardi 8 avril 2003 Statut Membre Dernière intervention 1 novembre 2007
30 sept. 2006 à 14:14
En faite le redef de paint c'est pour que mon package cGFXE detecte si JOGL est installé et sinon dans un premier temps affcihe un  message comme quoi il faut installé JOGL et sinon pour passé par une methode plus basic de dessins le jour ou je m'y pencherais.

Repaint .... mince j'ai oublier .... c'est pas celui dont tu parle auquel je pense mais faut que j'essaye 

Pour ce qui est du setIgnoreRepaint ca ne change rien.
0
threadom Messages postés 101 Date d'inscription mardi 8 avril 2003 Statut Membre Dernière intervention 1 novembre 2007
30 sept. 2006 à 15:01
Bim bim bim bim ! *Bruit de ma tête contre l'écran*

... Ca ca marche :

import java.awt.*;
import java.awt.event.*;




import javax.media.opengl.*;





import pGAME.pGFXE.pOutput.cOutput;
import pGAME.pOther.cDebug;





import com.sun.opengl.util.*;





public class Eternia implements GLEventListener {





 public static void main(String[] args) {
  Frame frame = new Frame("Article1");
  GLCanvas canvas = new GLCanvas();
  canvas.addGLEventListener(new Eternia());
  frame.add(canvas);
  final Animator animator = new Animator(canvas);
  frame.addWindowListener(new WindowAdapter() {
   public void windowClosing(WindowEvent e) {
    new Thread(new Runnable() {
     public void run() {
      animator.stop();
      System.exit(0);
     }
    }).start();
   }
  });
  
  frame.setSize(640, 480);
  frame.setVisible(true);
  frame.setResizable(false);
  animator.start();
 }





 public void init(GLAutoDrawable P_oDrawable) {
  try {
   cDebug.print(cOutput.class, "BEG", "init(GLAutoDrawable P_oDrawable)");
   cDebug.print(cOutput.class, "BEG", "P_oDrawable = " + P_oDrawable.toString());





   GL L_oGL = P_oDrawable.getGL();





   L_oGL.glClearColor(0, 0, 0, 0);
   L_oGL.glShadeModel(GL.GL_FLAT);
//   L_oGL.setSwapInterval(1);
   double L_oW = 40;
   double L_oH = 30;
   double L_oD = 100;
   
   double L_oL = -(Math.abs(L_oW) / 2);
   double L_oR = +(Math.abs(L_oW) / 2);
   double L_oT = -(Math.abs(L_oH) / 2);
   double L_oB = +(Math.abs(L_oH) / 2);
   L_oGL.glOrtho(L_oL, L_oR, L_oT, L_oB, 1, L_oD);
  }
  catch(Exception e)  {
   cDebug.print(cOutput.class, "ERR", "init(GLAutoDrawable P_oDrawable) - Exception >> " + e.toString());
  }
  finally {
   cDebug.print(cOutput.class, "END", "init(GLAutoDrawable P_oDrawable)");
  }
 }





 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {





 }





 public void display(GLAutoDrawable P_oDrawable) {
  try {
   cDebug.print(cOutput.class, "BEG", "display(GLAutoDrawable P_oDrawable)");
   cDebug.print(cOutput.class, "BEG", "P_oDrawable = " + P_oDrawable.toString());





   GL L_oGL = P_oDrawable.getGL();
   //GLU L_oGLU = new GLU();
   //GLUT L_oGLUT = new GLUT();
   
   L_oGL.glClear(GL.GL_COLOR_BUFFER_BIT);
   
   for (float y = -15; y < 15; y++) {
    for (float x = -20; x < 20; x++) {
     L_oGL.glColor3d(Math.random(), Math.random(), Math.random());
     L_oGL.glBegin(GL.GL_QUADS);
      L_oGL.glVertex3f(x, y, -5);
      L_oGL.glVertex3f(x, y+1, -5);
      L_oGL.glVertex3f(x+1, y+1, -5);
      L_oGL.glVertex3f(x+1, y, -5);
     L_oGL.glEnd();
    }
   }
  }
  catch(Exception e)  {
   cDebug.print(cOutput.class, "ERR", "display(GLAutoDrawable P_oDrawable) - Exception >> " + e.toString());
  }
  finally {
   cDebug.print(cOutput.class, "END", "display(GLAutoDrawable P_oDrawable)");
  }
 }
 
 public void displayChanged(GLAutoDrawable drawable, boolean modeChanged,
   boolean deviceChanged) {
 }
}

alors pourquoi pas l'autre .... :'( y'a une si grosse différence que ca entre applet et frame ... mais m.... je l'ai fais marché dans un applet sans probleme l'autre fois ... grrrr
0
Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 111
30 sept. 2006 à 15:09
Salut,

perso je n'utilise plus les applets depuis un moment donc........ mais ce que je peux te conseiller c'est d'aller sur le site de jogl et regarder dans la FAQ pour voir.... ou encore dans le forum de sun...

------------------------------------
"On n'est pas au resto : ici on ne fait pas dans les plats tout cuits ..."

WORA
0
threadom Messages postés 101 Date d'inscription mardi 8 avril 2003 Statut Membre Dernière intervention 1 novembre 2007
30 sept. 2006 à 15:11
C'est ce que je suis en train de faire ;) merci !

Je vais désinstallé la version 1.5 que j'ai et remettre une version qui n'est plus beta ... avec du bol ca viendra de la.
0
threadom Messages postés 101 Date d'inscription mardi 8 avril 2003 Statut Membre Dernière intervention 1 novembre 2007
1 oct. 2006 à 11:41
Je me suis pris la tête toute la soirée ... et bilan ... dès que je met un Animator.start(); je suis sur de me chopper le freeze. Par contre en Java Application avec un GLJPanel pas de problème ....
0
threadom Messages postés 101 Date d'inscription mardi 8 avril 2003 Statut Membre Dernière intervention 1 novembre 2007
1 oct. 2006 à 12:06
Yessss !! J'ai trouvé :) je vous met une solution au propre avec code et tout le tintouin :) et je vous le post !
0
threadom Messages postés 101 Date d'inscription mardi 8 avril 2003 Statut Membre Dernière intervention 1 novembre 2007
1 oct. 2006 à 12:53
Ha dernière petite chose merci a Twinuts ^^ c'est un peu la piste du repaint qui ma poussé a me rapellé de cette saloperie de problème de repaint d'un composant swing dans un Applet au lieu d'un JApplet
0
Rejoignez-nous