Back-translate a method from JOGL2 to JOGL1?

edited July 2015 in GLSL / Shaders

Hello,

I am new to Processing and to OpenGL. I ran into a version problem that I just can't seem to solve.

Basically, I want to back-convert a method that uses JOGL2 to JOGL1.

Why? I am merging two different sketches. They both work fine independently. However, one of them runs with Processing 2, while the other one uses Processing 1. I would like to stick with the Processing 1 sketch as a base, and add the Processing 2 code functionalities – because, I suppose, vice versa it would be more work.

The problem now is that Processing 2 uses JOGL 2, while Processing 1.1 used JOGL 1.

I get several errors concerning one method that uses OpenGL. The first error was: “The function beginPGL() does not exist.” I have fixed that one doing some research and replacing “pgl.beginPGL();” with “PGraphicsOpenGL pgl = (PgraphicsOpenGL)g;”. ... this should do the same thing, just in JOGL1 syntax.

But now more errors keep popping up. Kindly asking for advice by someone who really knows what's going on in JOGL1 and JOGL2.

This is the original function that I want to convert from JOGL 2 back to JOGL 1:



  // Write the sketch drawing surface texture to 
  // an opengl/directx shared texture

  void sendTexture() 
{

      pgl.beginPGL();
      // Load the current contents of the renderer's
      // drawing surface into its texture.
      pgl.loadTexture();
      // getTexture returns the texture associated with the
      // renderer's. drawing surface, making sure is updated 
      // to reflect the current contents off the screen 
      // (or offscreen drawing surface).      
      Texture tex = pgl.getTexture();
      // Processing Y axis is inverted with respect to OpenGL
      // so we need to invert the texture
      JSpout.WriteTexture(tex.glWidth, tex.glHeight, tex.glName, tex.glTarget, true); // invert
      pgl.endPGL();

  }

This is my current status, resulting in an error: 'Cannot find a class or type named "GL"'

 void sendTexture() {
       PGraphicsOpenGL pgl = (PGraphicsOpenGL)g;
       GL gl = pgl.beginGL();  
      //pg = (PGraphicsOpenGL)g;
      
      //PGraphicsOpenGL pgl = (PGraphicsOpenGL)pg.beginGL();
      
      // Get the OpenGL graphics context
      //GL gl = drawable.getGL();
      
      //Texture TextureIO.newTexture(gl.glViewport(0, 0, width, height));

      
      // Load the current contents of the renderer's
      // drawing surface into its texture.
      
      //pgl.loadTexture();
      //Texture TextureIO.newTexture(pgl image, boolean mipmap);
      
      // getTexture returns the texture associated with the
      // renderer's. drawing surface, making sure is updated 
      // to reflect the current contents off the screen 
      // (or offscreen drawing surface).      
      Texture tex = pgl.getTexture();
      
      // Processing Y axis is inverted with respect to OpenGL
      // so we need to invert the texture
      JSpout.WriteTexture(tex.glWidth, tex.glHeight, tex.glName, tex.glTarget, true); // invert
      pgl.endPGL();
  }

Many regards! b

Answers

Sign In or Register to comment.