TextureData/TextureIO in Processing2?

edited November 2013 in Library Questions

I had built quite a few sketches in Processing 1.x that used TextureData and TextureIO to manage textures for use in straight OpenGL calls. However I cannot seem to find a way to use these types in Processing 2, despite Processing 2 apparently incorporating JOGL (which defines these types as part of com.jpgamp.opengl.util.texture.*). Has anyone figured out the right way to use TextureIO & TextureData?

Answers

  • Answer ✓

    Hi, could you please show any reference/example of how it is used in processing 1?

  • edited November 2013

    It seems that the OpenGL function calls have all been remapped in Processing 2. For instance, for defining a shape, the standard functions glVertex2f & glTexCoord2f have been combined into a single function called vertex that accepts 4 parameters (in one overloaded version) for the vertex and texture vertex. Additionally I have to call textureMode(1) at the start of the shape to get the same normalization I previously had. Finally, to actually load a texture into the current OpenGL context, I loaded the .jpg file as a PImage and then called texture(PImage).

    Now it just seems that the new library has some problems getting pixels to line up on screen, a problem I previously solved by switching from P3D to OPENGL in Processing1x. Thanks anyway!

  • Processing 2 uses JOGL 2, which is substantially different from JOGL 1.x used earlier. However, the TextureIO and TextureData classes are still part of JOGL 2:

    http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/util/texture/TextureIO.html http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/util/texture/TextureData.html

    What is the specific problem you are having when you try to use them from Processing?

  • edited November 2013

    My first problem was that I could no longer import the Sun OpenGL library. (No library found for com.sun.opengl.util.texture). When I commented that line out, I could get further when precompiling, but I could not create TextureData objects (e.g. TextureData texData;) or call TextureIO class functions (e.g. TextureIO.newTexture((BufferedImage)srcImage.getImage(), true);). Oddly enough, I could still create Texture objects. Errors included:

    Cannot find a class or type named "TextureData"

    Cannot find anything named "TextureIO"

  • edited November 2013

    the package structure in JOGL 2 is different, you need the following import:

    import com.jogamp.opengl.util.texture.*;

    Processing does print "No library found for com.jogamp.opengl.util.texture", but that's is misleading, since the package is actually recognized and you can then create TextureIO and TextureData objects. However, the newTexture() method is slightly different. It doesn't take a BufferedImage object anymore, you can see all the options in the [javadoc](http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/util/texture/TextureIO.html#newTexture(java.io.File, boolean)). One is to use an InputStream:

    try {
      TextureIO.newTexture(createInput("img.jpg"), true, "jpg"); 
    } catch (IOException ex) {
      println("error");
    }
    
Sign In or Register to comment.