Guest User

Processing 3 Fog Demonstration (Broken)

a guest
Jan 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import com.jogamp.opengl.GL;
  2. import com.jogamp.opengl.GL2ES2;
  3. import com.jogamp.opengl.GL2;
  4.  
  5.  
  6. PJOGL pgl;
  7. GL2 gl;
  8.  
  9. void settings(){
  10. PJOGL.profile = 1;
  11. size(800, 600, P3D);
  12. }
  13.  
  14. void setup() {
  15. float[] fogColor = { 1.0f, 0.0f, 0.0f, 1.0f };
  16.  
  17.  
  18.  
  19. pgl = (PJOGL) beginPGL();
  20. gl = pgl.gl.getGL2();
  21.  
  22. gl.glClearDepth(1.0f);
  23. gl.glEnable(GL2.GL_DEPTH_TEST);
  24. gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);
  25. gl.glShadeModel(GL2.GL_SMOOTH);
  26. gl.glClearColor(0.5f,0.5f,0.5f,1.0f);
  27.  
  28. //Setup Fog mode
  29. gl.glEnable(GL2.GL_FOG);
  30. gl.glFogfv(GL2.GL_FOG_COLOR, fogColor, 1);
  31. gl.glFogf(GL2.GL_FOG_DENSITY, 1f);
  32. gl.glHint(GL2.GL_FOG_HINT, GL2.GL_NICEST);
  33. gl.glFogf(GL2.GL_FOG_START, 1f);
  34. gl.glFogf(GL2.GL_FOG_END, 1f);
  35.  
  36.  
  37.  
  38. endPGL();
  39. }
  40.  
  41. void draw() {
  42. pgl = (PJOGL) beginPGL();
  43. gl = pgl.gl.getGL2();
  44. gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
  45. gl.glFogi(GL2.GL_FOG_MODE, GL2.GL_EXP);
  46. gl.glFogf(GL2.GL_FOG_DENSITY, 3.0f);
  47. perspective(radians(90), (float)width/(float)height, 0.1f, 1000);
  48. // Geometry transformations from Processing are automatically passed to the shader
  49. // as long as the uniforms in the shader have the right names.
  50. translate(width/2, height/2);
  51.  
  52.  
  53. rotateX(mouseX * 0.01);
  54. rotateY(mouseY * 0.01);
  55. box(200);
  56.  
  57.  
  58. endPGL();
  59.  
  60. }
Add Comment
Please, Sign In to add comment