Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

simple OPENGL, worked in 1.51, doesn't work anymore....

$
0
0


hello all,

this is a simple OPENGL-code, it worked in 1.51, doesn't work anymore....

can anyone help?

Thank you!

Chrisir  



  1. // imports ---------------------------------------------------
  2. //import processing.opengl.PGraphicsOpenGL;
  3. import javax.media.opengl.GL;
  4. import javax.media.opengl.glu.GLU;
  5. import javax.media.opengl.glu.GLUquadric;
  6. import com.sun.opengl.util.texture.Texture;
  7. import com.sun.opengl.util.texture.TextureIO;
  8. import peasy.PeasyCam; //peasy camera control
  9. // opengl
  10. import processing.opengl.*;
  11. /** PeasyCam **/
  12. import peasy.*;
  13. // Audio
  14. //import ddf.minim.*;
  15. // for export
  16. import superCAD.*;
  17. // global vars -----------------------------------------------
  18. // control behaviour parameters --------------------
  19. boolean testingForDebugging      = false;
  20. int showingCubeData              = 0;
  21. //
  22. boolean boolGl_Control           = false;  // Marble with opengl?
  23. boolean boolGl_Control_for_Boxes = false; // Boxes with opengl?
  24. // Camera Types
  25. boolean CameraMoving          = false;    // camera always ahead of Marble
  26. boolean CameraMoving2         = false;    // good for movie (camera on a circle track)
  27. // Movie
  28. boolean boolMakeMovie         = false;  // saves a Movie
  29. boolean boolUseCheckeredFloor = true;   // Floor Type
  30. // other vars ---------------------------------------------------
  31. // cube
  32. final int cubeSize = 49; // width, height and depth
  33. final int undefinedCube = -11;
  34. // GL stuff
  35. PGraphicsOpenGL pgl;
  36. GL gl;
  37. GLU glu;
  38. GLUquadric mysphere;
  39. GLUquadric myBox;
  40. Texture textureMarble;
  41. float marbleX=200;
  42. float marbleY=200;
  43. float marbleZ=-100;
  44. float r = 19; // Sized to fit the texture
  45. float rotateMarble = 0.39;
  46. float rotateMarbleSpeed = 0.02; // .196
  47. float MarbleRotateX=0.2;
  48. float MarbleRotateY=0.2;
  49. float MarbleRotateZ=0.2;
  50. void setup() {
  51.   size(890, 660, OPENGL);
  52.   // size(screenWidth, screenHeight, OPENGL );
  53.   // noCursor();
  54.   //cam.setMinimumDistance(40);
  55.   //cam.setMaximumDistance(6550);
  56.   // cam.lookAt( 70, 390, 0 );
  57.   pgl = (PGraphicsOpenGL) g; 
  58.   gl = pgl.gl; 
  59.   glu = pgl.glu;
  60.   mysphere = glu.gluNewQuadric();
  61.   glu.gluQuadricDrawStyle(mysphere, glu.GLU_FILL);
  62.   glu.gluQuadricNormals(mysphere, glu.GLU_NONE);
  63.   glu.gluQuadricTexture(mysphere, true);
  64.   myBox = glu.gluNewQuadric();
  65.   glu.gluQuadricDrawStyle(myBox, glu.GLU_FILL);
  66.   glu.gluQuadricNormals(myBox, glu.GLU_NONE);
  67.   glu.gluQuadricTexture(myBox, true); 
  68.   try {   
  69.     textureMarble = TextureIO.newTexture(new
  70.       File(dataPath("textures2.jpg")), true);
  71.   } 
  72.   catch (IOException e) {       
  73.     println("failed to load picture - line 159.   ++++++++++++++++++++++");
  74.     javax.swing.JOptionPane.showMessageDialog(this, e);
  75.     exit();
  76.   }
  77. } // func
  78. void draw (  ) {
  79.   background (0);
  80.   PaintMarble () ;
  81. }
  82. void PaintMarble () {
  83.   pgl.beginGL();
  84.   gl.glPushMatrix();
  85.   gl.glTranslatef( marbleX, marbleY, marbleZ);
  86.   gl.glRotatef(degrees(rotateMarble), MarbleRotateX, MarbleRotateY, MarbleRotateZ);
  87.   gl.glColor3f(1, 1, 1);
  88.   textureMarble.enable();
  89.   textureMarble.bind();
  90.   //The Sphere
  91.   glu.gluSphere(mysphere, r, 40, 40);
  92.   textureMarble.disable();
  93.   gl.glPopMatrix();
  94.   pgl.endGL();
  95.   if (rotateMarble < 360) {
  96.     rotateMarble = rotateMarble + rotateMarbleSpeed;
  97.   }
  98.   else {
  99.     rotateMarble = 0;
  100.   }
  101. } // method


Viewing all articles
Browse latest Browse all 1768

Trending Articles