Issues updating openGL old code to processing 3.0

I am having a hard time trying to find references to put this to work on processing 3.0!!!

https://processing.org/discourse/beta/num_1273419930.html

In case anyone is experienced about these libraries I would be really glad!

Answers

  • which bit in particular? it's a 2d grid in 3d space.

    raw opengl has been surpassed by the PShape functionality

    look at createShape / beginShape in the reference.

  • edited September 2016

    Ah, yes, thanks for your reply. I have made this before using createShape. But the whole process is dropping by frame rate considerably. This is why I wanted to try using any low level technique. My goal is to use a custom matrix as a camera transformation, but I can't find any updated example...

    this is currently not working properly:

        PMatrix3D p; 
    
    void setup() {
      size(600, 400, P3D);
    
      p = new PMatrix3D(
        5.400566, 0.519709, -4.3888016, 193.58757, 
        5.284709, -9.016302, 3.312224, 266.927, 
        0.012042404, 7.253584E-5, 0.0084899925, 1.0, 
        0, 0, 0, 1);
    
      p.invert();
    }
    
    void draw() {
    
      float x = map(mouseX, 0, width, -200, 200);
      float z = map(mouseY, 0, height, -150, 150);
    
      //((PGraphicsOpenGL) g).modelview.set(p);
      ((PGraphicsOpenGL) g).camera.set(p);
      //((PGraphicsOpenGL) g).projection.set(p);
      //((PGraphicsOpenGL) g).projmodelview.set(p);
    
      background(20);
      lights();
      translate(width/2, height/2);
      translate(x, 0, z);
      box(100);
    }
    
  • By the way I finally could make the original code more likely.

    still getting a GLException: Not a GL2 implementation

    Got some old reference, but seems like this way of implementing is now obsolete. https://github.com/processing/processing/blob/e107f6dfb8e322a5edcc6ed751cb1ef952619fb8/build/shared/revisions.txt

    import com.jogamp.opengl.*;  
    import java.nio.FloatBuffer;
    
    float[] modelview = { 
      0.670984f, 0.250691f, 0.674993f, 0, -0.288247f, 
      0.966749f, -0.137371f, 0f, -0.68315f, -0.0505059f, 0.720934f, 0f, 
      0.164808f, 2.1425f, 32.9616f, 1f };
    float[] proj = { 
      0.78125f, 0, 0, 0, 0, 1.04167f, 0, 0, 0, 0, -1.0002f, -1, 0, 
      0, -2.0002f, 0 };
    
    FloatBuffer  mvbuf;
    FloatBuffer  projbuf;
    
    void setup() {
      size(1024, 768, P3D);
      PJOGL.profile = 2; //not sure if needed
      mvbuf = FloatBuffer.wrap(modelview);
      projbuf= FloatBuffer.wrap(proj);
    
      GLProfile glp = GLProfile.get(GLProfile.GL2);
      GLCapabilitiesImmutable glcaps = (GLCapabilitiesImmutable) new GLCapabilities(glp);
      GLCapabilities tGLCapabilities = new GLCapabilities(glp);
      println("System Capabilities:" + glcaps.toString());
      println("Profile Details: " + glp.toString());
      println("Is GL2 Supported?: " + glp.isGL2());
    }
    
    void draw() {
      background(0);
    
      PGL pgl = (PJOGL) beginPGL(); 
      GL gl = ((PJOGL) pgl).gl; 
      GL2 gl2 = gl.getGL2(); //GLException: not a GL2 implemantation 
    
      gl2.glMatrixMode(GL2.GL_PROJECTION);
      gl2.glLoadIdentity();
      gl2.glLoadMatrixf(projbuf);
    
      gl2.glMatrixMode(GL2.GL_MODELVIEW);
      gl2.glLoadIdentity();
      gl2.glLoadMatrixf(mvbuf);
    
      drawGrid(100, 10, gl2);
    
      endPGL(); //not sure if this is closing what it supposed to
    }
    
    
    void drawGrid(float len, float offset, GL2 g) {
    
      int nr_lines = (int)(len/offset);
    
      g.glColor3f(1, 1, 1);
      g.glBegin(g.GL_LINES);
      for (int i=-nr_lines; i<nr_lines; i++) {
    
        g.glVertex3f(i*offset, 0, -nr_lines*offset);
        g.glVertex3f(i*offset, 0, nr_lines*offset);
      }
    
      for (int i=-nr_lines; i<nr_lines; i++) {
    
        g.glVertex3f(-nr_lines*offset, 0, i*offset);
        g.glVertex3f(nr_lines*offset, 0, i*offset);
      }
      g.glEnd();
    }
    
  • Please, any one who is familiar with opengl issues could give me a hand on this?

  • After all this time I feel I can't get no one to assist me with these shaders or OpenGL issues in this forum.

  • In case you haven't done so, have you checked prev posts?

    https://forum.processing.org/two/search?Search=getGL2

    In your first code, are you trying to set up a camera angle?

    There is a potential you can get feedback if you describe your issue better. From the link you provided:

    projection and modelview matrices needed for an accurate projection of the scene onto a real world model . Based on the exported modelview and projection matrix, I would like to use Processing to create a nice scene

    What are modelview matrices? What kind of world model are you referring to? I am guessing this is not your post but you ate familiar with that terminology? Maybe is it realted to shaders? From what I have seen in the forum, shaders assistance is limited, hit and miss.

    Kf

Sign In or Register to comment.