1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
public class Affichages implements GLEventListener
{
private int TailleZoom = 100 ;
public Affichages()
{
}
/* init() sera appelée une fois au début de l'animation C'est dans cette méthode que nous nous chargerons de toute les opérations d'initialisation */
/* GLEventListener renvoie un contexte (drawable) que nous allons utiliser pour instancier un objet de type GL , qui nous permettra d'utiliser
* les fonctions OpenGL */
public void init(GLAutoDrawable drawable)
{
GL gl = drawable.getGL() ;
gl.setSwapInterval(1) ; /* Cette fonction permet de désactiver la syncronisation verticale, indépendement de la plateforme utilisée */
TailleZoom = 100 ;
}
public void display(GLAutoDrawable drawable)
{
int i, j ;
GL gl = drawable.getGL() ;
short[] titi = new short[MasterSIS.image.getSize()] ;
ShortBuffer toto = null ;
// Le buffer étant à une seule dimension, je change la dimension de mon image
for (i=0 ; i < MasterSIS.image.getHeight() ; i++)
for (j=0 ; j < MasterSIS.image.getWidth() ; j++)
titi[i*MasterSIS.image.getWidth()+j] = MasterSIS.image.getPixel(i, j) ;
gl.glClear(GL.GL_COLOR_BUFFER_BIT) ; // clear window
gl.glPixelZoom((float)(TailleZoom/100.0), (float)(TailleZoom/100.0)) ;
// J'essai d'afficher mon image dans le ShortBuffer.
gl.glDrawPixels(MasterSIS.image.getWidth(), MasterSIS.image.getHeight(), gl.GL_LUMINANCE16, gl.GL_UNSIGNED_SHORT, toto.wrap(titi)) ;
gl.glFlush(); // flush GL buffers
} |
Partager