FiReTiTi
Messages postés54Date d'inscriptionlundi 20 mars 2006StatutMembreDernière intervention28 septembre 2007
-
25 oct. 2006 à 15:24
FiReTiTi
Messages postés54Date d'inscriptionlundi 20 mars 2006StatutMembreDernière intervention28 septembre 2007
-
26 oct. 2006 à 10:21
Bonjour,
je souhaite afficher une image avec glDrawPixel.
Pour moi, une image est une classe contenant un short[][] qui contient toutes les valeurs de mon image. J'ai donc tapé ceci dans ma classe image :
public void display(GLAutoDrawable drawable)
{
int i, j ;
GL gl = drawable.getGL() ;
short[] titishort = new short[MasterSIS.image.getSize()] ;
ByteBuffer buffer ByteBuffer.allocate(image.getSize()*2); // on multiplie par 2 car 1 short 2 octets
ShortBuffer toto = buffer.asShortBuffer();
for (i=0 ; i < image.getHeight() ; i++)
for (j=0 ; j < image.getWidth() ; j++)
titishort[i*MasterSIS.image.getWidth()+j] = image.getPixel(i, j) ;
FiReTiTi
Messages postés54Date d'inscriptionlundi 20 mars 2006StatutMembreDernière intervention28 septembre 2007 25 oct. 2006 à 16:10
quand je rentre un message, tout ce met automatiquement à la suite, même ne tapant "entrée".
Y a t'il une balise pour indiquer que c'est du code ? par exemple
Twinuts
Messages postés5375Date d'inscriptiondimanche 4 mai 2003StatutModérateurDernière intervention14 juin 2023111 25 oct. 2006 à 16:52
Salut,
Ba tu le retape genre :
---------------------------------------------------------------- Bonjour,
je souhaite afficher une image avec glDrawPixel.
Pour moi, une
image est une classe contenant un short[][] qui contient toutes les
valeurs de mon image.
J'ai donc tapé ceci dans ma classe image :
public
void display(GLAutoDrawable drawable) {
int i, j ;
GL gl =
drawable.getGL() ;
short[] titishort = new
short[MasterSIS.image.getSize()] ;
// on multiplie par 2 car 1
short = 2 octets
ByteBuffer buffer =
ByteBuffer.allocate(image.getSize()*2);
ShortBuffer toto = buffer.asShortBuffer();
for (i=0 ;
i < image.getHeight() ; i++)
for (j=0 ; j < image.getWidth() ;
j++)
titishort[i*MasterSIS.image.getWidth()+j] = image.getPixel(i, j) ;
toto.put(titishort, 0, titishort.length) ;
gl.glClear(GL.GL_COLOR_BUFFER_BIT) ; // clear window
FiReTiTi
Messages postés54Date d'inscriptionlundi 20 mars 2006StatutMembreDernière intervention28 septembre 2007 26 oct. 2006 à 08:47
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Required 524288 remaining bytes in buffer, only had 0
at com.sun.gluegen.runtime.BufferFactory.rangeCheckBytes(BufferFactory.java:274)
at com.sun.opengl.impl.GLImpl.glDrawPixels(GLImpl.java:3648)
at AfficherImage.display(AfficherImage.java:71)
at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:281)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:258)
at javax.media.opengl.GLCanvas.display(GLCanvas.java:130)
at javax.media.opengl.GLCanvas.paint(GLCanvas.java:142)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:276)
at sun.awt.RepaintArea.paint(RepaintArea.java:241)
at apple.awt.ComponentModel.handleEvent(ComponentModel.java:251)
at java.awt.Component.dispatchEventImpl(Component.java:4097)
at java.awt.Component.dispatchEvent(Component.java:3869)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Exception in thread "Thread-2" javax.media.opengl.GLException: java.lang.IndexOutOfBoundsException: Required 524288 remaining bytes in buffer, only had 0
at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:271)
at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:256)
at javax.media.opengl.GLCanvas.display(GLCanvas.java:130)
at com.sun.opengl.util.Animator.display(Animator.java:144)
at com.sun.opengl.util.Animator$MainLoop.run(Animator.java:181)
at java.lang.Thread.run(Thread.java:613)
Caused by: java.lang.IndexOutOfBoundsException: Required 524288 remaining bytes in buffer, only had 0
at com.sun.gluegen.runtime.BufferFactory.rangeCheckBytes(BufferFactory.java:274)
at com.sun.opengl.impl.GLImpl.glDrawPixels(GLImpl.java:3648)
at AfficherImage.display(AfficherImage.java:71)
at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:281)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
at javax.media.opengl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:298)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Twinuts
Messages postés5375Date d'inscriptiondimanche 4 mai 2003StatutModérateurDernière intervention14 juin 2023111 26 oct. 2006 à 09:16
Salut,
il est horrible ton poste je le refais :
---------------------------------------------------------------- Exception in thread "AWT-EventQueue-0"
java.lang.IndexOutOfBoundsException: Required 524288 remaining bytes in
buffer, only had 0
at
com.sun.gluegen.runtime.BufferFactory.rangeCheckBytes(BufferFactory.java:274)
at com.sun.opengl.impl.GLImpl.glDrawPixels(GLImpl.java:3648) at
AfficherImage.display(AfficherImage.java:71)
at
com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:281)
at
com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
at
javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:258)
at javax.media.opengl.GLCanvas.display(GLCanvas.java:130)
at
javax.media.opengl.GLCanvas.paint(GLCanvas.java:142)
at
sun.awt.RepaintArea.paintComponent(RepaintArea.java:276)
at
sun.awt.RepaintArea.paint(RepaintArea.java:241)
at
apple.awt.ComponentModel.handleEvent(ComponentModel.java:251)
at
java.awt.Component.dispatchEventImpl(Component.java:4097)
at
java.awt.Component.dispatchEvent(Component.java:3869)
at
java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Exception in thread "Thread-2" javax.media.opengl.GLException:
java.lang.IndexOutOfBoundsException: Required 524288 remaining bytes in
buffer, only had 0
at
javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:271)
at
javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:256)
at javax.media.opengl.GLCanvas.display(GLCanvas.java:130)
at
com.sun.opengl.util.Animator.display(Animator.java:144)
at
com.sun.opengl.util.Animator$MainLoop.run(Animator.java:181)
at
java.lang.Thread.run(Thread.java:613) Caused by:
java.lang.IndexOutOfBoundsException: Required 524288 remaining bytes in
buffer, only had 0
at
com.sun.gluegen.runtime.BufferFactory.rangeCheckBytes(BufferFactory.java:274)
at com.sun.opengl.impl.GLImpl.glDrawPixels(GLImpl.java:3648)
at
AfficherImage.display(AfficherImage.java:71)
at
com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:281)
at
com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
at
javax.media.opengl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:298)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at
java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
----------------------------------------------------------------
------------------------------------
"On n'est pas au resto : ici on ne fait pas dans les plats tout cuits ..."