Menu

glgraphicsoffscreen bug (or not?)

Help
2008-09-12
2012-12-26
  • hansi raber

    hansi raber - 2008-09-12

    hey!

    so one other thing i came across i that when you create an offscreen drawing pane that is larger than the sketch, it seems to be impossible to draw anything that is larger than the actual sketch.

    just run this in processing:
    import codeanticode.glgraphics.*;
    import processing.opengl.*;

    GLGraphicsOffScreen graphicsGL;

    void setup(){
      size( 200, 200, GLConstants.GLGRAPHICS );
      graphicsGL = new GLGraphicsOffScreen( 400, 400, this );
      graphicsGL.beginDraw();
      graphicsGL.background( 255, 0, 0 );
      graphicsGL.fill( 255 );
      graphicsGL.ellipse( 200, 200, 200, 200 );
      graphicsGL.endDraw();
    }

    int pos = -200;
    void draw(){
      background( 0 );
      pos ++;
      if( pos > 200 ) pos = -200;
     
      image( graphicsGL.getTexture(), pos, 0 );
    }

    you'll see that only a quarter of the ellipse in the graphicsGL object is visible, even though the background of all the 400x400 pixels is red.
    i can't really figure out whats going on and why this is happening.... :(

    anyways... i really enjoy using your library, thanks so much!

    hansi.  

     
    • hansi raber

      hansi raber - 2008-09-13

      ok, i found a way to work around this:

      import codeanticode.glgraphics.*;
      import processing.opengl.*; 
      import javax.media.opengl.GL;

      GLGraphicsOffScreen graphicsGL; 

      void setup(){
      size( 200, 200, GLConstants.GLGRAPHICS ); 
      graphicsGL = new GLGraphicsOffScreen( 400, 400, this ); 
      graphicsGL.beginDraw(); 
      ((GL)graphicsGL.gl).glViewport( 0, 0, graphicsGL.width, graphicsGL.height );  // adapt the viewport
      graphicsGL.scale( width/(float)graphicsGL.width, height/(float)graphicsGL.height );  // scale accordingly
      graphicsGL.background( 255, 0, 0 ); 
      graphicsGL.fill( 255 ); 
      graphicsGL.ellipse( 200, 200, 200, 200 ); 
      graphicsGL.endDraw(); 
      ((GL)graphicsGL.gl).glViewport( 0, 0, width, height ); // reset the viewport for the sketch
      }

      int pos = -200; 
      void draw(){
      background( 0 ); 
      pos ++; 
      if( pos > 200 ) pos = -200; 

      image( graphicsGL.getTexture(), pos, 0 ); 
      }

       

Log in to post a comment.