Loading...
Logo
Processing Forum
Hello again,

I have been able to render a few textures toghether into another texture (thanks to kevin.bjorke of course! ) but now I want to render moving objects snakes, fish, worms, etc) that are pretty much 2d textures rendered to GL_QUADS that make them twist while moving.

to be able to do that, I really need to use GL_QUADS, but I cannot use them in a texture of GLGraphicsOffScreen. I have been tempted to use the JOGL, but I'm restraining as it is not supported. Any idea would be greatly appreciated.

thanks in advanced,

Replies(4)

I am not sure if understand correctly your problem, but you can do calls to glBegin( GL_QUADS), etc when rendering offscreen. Just use beginGL/endGL like this:

Copy code
  1. canvas.beginDraw();
  2. gl = canvas.beginGL();
  3. gl.glBegin(GL.GL_QUADS);
  4. ...
  5. canvas.endGL();
  6. canvas.endDraw();
(canvas is the GLGraphicsOffScreen object).

All I get is a blank screen, and sometimes noise. I will try to reinstall nVidia drivers on my ubuntu installation to see if it was a driver corruption.

thanks andres.
Just to make sure it is not a problem with the drivers (seems a little bit extreme), does the following code works for you?

Copy code
  1. import processing.opengl.*;
  2. import codeanticode.glgraphics.*;
  3. import remixlab.proscene.*;
  4. import javax.media.opengl.*;

  5. GLGraphicsOffScreen canvas;
  6. GL gl;

  7. void setup() {
  8.   size(640, 360, GLConstants.GLGRAPHICS); 
  9.   canvas = new GLGraphicsOffScreen(this, 640, 360);
  10. }

  11. void draw() {
  12.   background(255);

  13.   canvas.beginDraw();
  14.   gl = canvas.beginGL();

  15.   gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
  16.   gl.glClear(GL.GL_COLOR_BUFFER_BIT);

  17.   gl.glTranslatef(width/2, height/2, 0);
  18.   gl.glRotatef(frameCount / 5.0, 0, 1, 0);

  19.   gl.glPushMatrix();
  20.   line_3d(new PVector(  0,  50,  50), new PVector(-50, -50, -50), 1.66, color(255, 70, 70));
  21.   line_3d(new PVector(-50, -50, -50), new PVector( 50, -50, -50), 1.66, color(255, 70, 70));
  22.   line_3d(new PVector( 50, -50, -50), new PVector(  0,  50,  50), 1.66, color(255, 70, 70));

  23.   line_3d(new PVector(  0,  50, -50), new PVector(-50, -50,  50), 1.66, color(255, 70, 70));
  24.   line_3d(new PVector(-50, -50,  50), new PVector( 50, -50,  50), 1.66, color(255, 70, 70));
  25.   line_3d(new PVector( 50, -50,  50), new PVector(  0,  50, -50), 1.66, color(255, 70, 70));      
  26.   gl.glPopMatrix();

  27.   canvas.endGL();
  28.   canvas.endDraw();  

  29.   image(canvas.getTexture(), mouseX, mouseY, width/2, height/2);
  30. }

  31. //inspired from James Carruthers's drawLine
  32. //http://processing.org/discourse/yabb2/YaBB.pl?num=1262458611/4#4
  33. void line_3d(PVector pv1, PVector pv2, float weight, color _color) {
  34.   PVector v1 = new PVector(pv2.x - pv1.x, pv2.y - pv1.y, pv2.z - pv1.z);

  35.   float rho = sqrt(pow(v1.x, 2) + pow(v1.y, 2) + pow(v1.z, 2));
  36.   float phi = acos(v1.z / rho);
  37.   float the = atan2(v1.y, v1.x);

  38.   v1.mult(0.5);      

  39.   float zval = pv1.dist(pv2) * 0.5;  
  40.   float rad = radians(120) * weight * 0.5;

  41.   gl.glPushMatrix();
  42.   gl.glTranslatef(pv1.x, pv1.y, pv1.z);
  43.   gl.glTranslatef(v1.x, v1.y, v1.z);
  44.   gl.glRotatef(degrees(the), 0, 0, 1);
  45.   gl.glRotatef(degrees(phi), 0, 1, 0);
  46.   gl.glColor4f(red(_color)/255, green(_color)/255, blue(_color)/255, 0.67);

  47.   //DRAW THE 3D 'LINE' (with 3 planes)  
  48.   gl.glBegin(GL.GL_QUADS);
  49.   //1
  50.   gl.glVertex3f( rad, -rad,  zval);
  51.   gl.glVertex3f( rad, -rad, -zval);
  52.   gl.glVertex3f(-rad, -rad, -zval);
  53.   gl.glVertex3f(-rad, -rad,  zval);      
  54.   //2
  55.   gl.glVertex3f(-rad, -rad,  zval);
  56.   gl.glVertex3f(-rad, -rad, -zval);
  57.   gl.glVertex3f(   0,  rad, -zval);
  58.   gl.glVertex3f(   0,  rad,  zval);
  59.   //3
  60.   gl.glVertex3f(   0,  rad,  zval);
  61.   gl.glVertex3f(   0,  rad, -zval);
  62.   gl.glVertex3f( rad, -rad, -zval);
  63.   gl.glVertex3f( rad, -rad,  zval);
  64.   gl.glEnd();

  65.   gl.glPopMatrix();
  66. }
black screen. I will plug the PC to the internet and redownload drivers (I have it offline to test some other apps behaviours without internet connection). I'll let you know.

thanks for the help.

UPDATE: ok, it was the drivers, a friend tried to impress me with the latest beta drivers, and I just reverted everything back to the stable drivers and magic happened. thankfully that was one of the reasons of getting it offline... hehehe. now I'm at full speed, let hope we don't find another bump on the road.

thanks everyone for their help.