Hi,
I am quite new to JOGL and I have some questions about a feature implemented in JOGL 1.1.2 which seems to be missing in JOGL 2.0. :( What I want to do is using a BufferedImage in an JOGL Texture object. The last stable release of JOGL released by Sun (1.1.2) provided the following method : TextureData com.sun.opengl.util.texture.TextureIO.newTextureData(BufferedImage bufferedimage, boolean flag); But when i set up JOGL 2.0, the only ways to create a texture data object are via files, streams or URLs. I have tried to transform my buffered image in a stream but with no success... So my question is, does JOGL 2.0 allows to load a BufferedImage into a Texture object ? If yes, can someone help me with that, that'd be great :) If no, I'm interested in knowing why! Does the function of JOGL 1.1.2 was 'bad' in any way ? Will it be implemented in future versions of JOGL ? |
all AWT dependencies are now separated in JOGL 2. Whenever you miss
something take a look if you can find a AWT* version of the class you used usually. AWTTextureIO: http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/util/texture/awt/AWTTextureIO.html have fun, michael On 03/10/2011 05:48 PM, AlexRNL [via jogamp] wrote: > > Hi, > > I am quite new to JOGL and I have some questions about a feature implemented > in JOGL 1.1.2 which seems to be missing in JOGL 2.0. :( > > What I want to do is using a BufferedImage in an JOGL Texture object. The > last stable release of JOGL released by Sun (1.1.2) provided the following > method : > > TextureData > com.sun.opengl.util.texture.TextureIO.newTextureData(BufferedImage > bufferedimage, boolean flag); > > > But when i set up JOGL 2.0, the only ways to create a texture data object > are via files, streams or URLs. I have tried to transform my buffered image > in a stream but with no success... > > So my question is, does JOGL 2.0 allows to load a BufferedImage into a > Texture object ? > If yes, can someone help me with that, that'd be great :) > If no, I'm interested in knowing why! Does the function of JOGL 1.1.2 was > 'bad' in any way ? Will it be implemented in future versions of JOGL ? > > _______________________________________________ > If you reply to this email, your message will be added to the discussion below: > http://forum.jogamp.org/Create-a-texture-from-a-BufferedImage-tp2661201p2661201.html > To start a new topic under jogamp, email [hidden email] > To unsubscribe from jogamp, visit http://michael-bien.com/ |
Thanks !
And good luck for improving JOGL, that is a great tool :) |
In reply to this post by Michael Bien
After so many years, I was looking for this solution and this helped me :) Thanks a lot.
|
Hello,
Maybe the way I did it can help you, I found it very nice, by using the AWTGLReadBufferUtil class :
// Here, you render what you want for the texture
The false final parameter above is for rendering upside-down or not (have a try to see what fits better your needs).// Once the scene is rendered, saving it in a texture that will be used as the texture AWTGLReadBufferUtil awtGlReadBufferUtil = new AWTGLReadBufferUtil(gl.getGLProfile(), false); BufferedImage bufferedImage = awtGlReadBufferUtil.readPixelsToBufferedImage(gl, false); TextureData textureData = AWTTextureIO.newTextureData(gl.getGLProfile(), bufferedImage, true); And then, you may want to buffer your image in memory. This is how I did it :
gl.glBindTexture(GL.GL_TEXTURE_2D, idTexture); // Texture parameterization gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR_MIPMAP_LINEAR); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); // Buffering the texture gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, texture.getInternalFormat(), texture.getWidth(), texture.getHeight(), 0, texture.getPixelFormat(), texture.getPixelType(), texture.getBuffer()); gl.glGenerateMipmap(GL.GL_TEXTURE_2D); // Unbinding the texture gl.glBindTexture(GL.GL_TEXTURE_2D, 0); Just pay attention to the version of JOGL you use : I found a bug with the 2.3.1 with an unrecognized pixelFormat. This problem was solved by the 2.3.2 version of JOGL Hope this may help you ;) |
Free forum by Nabble | Edit this page |