Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8303458

While I am trying to execute an openGL program I am getting the below error log

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Windows11

      A DESCRIPTION OF THE PROBLEM :
      A fatal error has been detected by the Java Runtime Environment:
      #
      # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffbb89c007d, pid=59324, tid=60608
      #
      # JRE version: OpenJDK Runtime Environment (15.0.2+7) (build 15.0.2+7-27)
      # Java VM: OpenJDK 64-Bit Server VM (15.0.2+7-27, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
      # Problematic frame:
      # C [igxelpicd64.dll+0x2f007d]
      #
      # No core dump will be written. Minidumps are not enabled by default on client versions of Windows

      REGRESSION : Last worked in version 15

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      import static com.jogamp.opengl.GL.GL_ARRAY_BUFFER;
      import static com.jogamp.opengl.GL.GL_FLOAT;
      import static com.jogamp.opengl.GL.GL_LINE_LOOP;
      import static com.jogamp.opengl.GL.GL_POINTS;
      import static com.jogamp.opengl.GL.GL_STATIC_DRAW;
      import static com.jogamp.opengl.GL.GL_TRIANGLES;
      import static com.jogamp.opengl.GL2ES3.GL_COLOR;



      import java.io.File;
      import java.nio.FloatBuffer;

      import com.jogamp.common.nio.Buffers;
      import com.jogamp.opengl.GL4;
      import com.jogamp.opengl.GLAutoDrawable;

      public class athalapa_BounceInCircle extends JOGL1_3_VertexArray{

      float radius= HEIGHT/2.4f;
      float Radius= 2*radius/HEIGHT;
      float theta=0, dtheta=1/radius;

      int noOfPointsOn = (int)(2*Math.PI/dtheta); // Total number of points on the circle are 2*PI*r
      float pointsOnCoordinates[] = new float [noOfPointsOn*3]; // x,y,z coordinates of points
      float color[] = {1.0f, 1.0f, 0.0f};

      int noOfPointsIn = 80;// Total number of points inthe circle;
      float pointsInCoordinates[] = new float [noOfPointsIn*3];
      float direction[] = new float [noOfPointsIn*3];
      float colour[] = new float[noOfPointsIn*3];




      public athalapa_BounceInCircle() {

      // draw a circle
      // finding vertices of points on the circle
      for(int i=0; i < 3*noOfPointsOn; i++) {
      theta = theta+dtheta;
      pointsOnCoordinates[i]=(float) (Radius*Math.cos(theta));
      i++;
      pointsOnCoordinates[i]=(float) (Radius*Math.sin(theta));
      i++;
      pointsOnCoordinates[i]=0;
      }
      // generate points inside the circle, direction, and color
      for(int i = 0; i < noOfPointsIn; i++) {
      // calculate a random angle
      float angle = (float) (Math.random() * 2 * Math.PI);

      // calculate the position of the point inside the circle
      float x = (float) (radius * Math.cos(angle));
      float y = (float) (radius * Math.sin(angle));

      // set the position of the point
      pointsInCoordinates[i*3] = x;
      pointsInCoordinates[i*3+1] = y;
      pointsInCoordinates[i*3+2] = 0;

      // set a random direction for the point
      direction[i*3] = (float) (Math.random() * 2 - 1); // x direction
      direction[i*3+1] = (float) (Math.random() * 2 - 1); // y direction
      direction[i*3+2] = 0; // z direction (always 0)

      // set a random color for the point
      colour[i*3] = (float) Math.random(); // red
      colour[i*3+1] = (float) Math.random(); // green
      colour[i*3+2] = (float) Math.random();// blue
      }
      // TODO Auto-generated constructor stub
      }


      public void display(GLAutoDrawable drawable) {

      // clear the display every frame
      float bgColor[] = { 0.0f, 0.0f, 0.0f, 1.0f };
      FloatBuffer bgColorBuffer = Buffers.newDirectFloatBuffer(bgColor);
      gl.glClearBufferfv(GL_COLOR, 0, bgColorBuffer); // clear every frame
      // draw a circle
      // indicate that u r drawing a uniform color: color[0]=1.0f;
      // Use one Vertex Buffer Object for just the points
      // gl.glEnableVertexAttribArray(0); // enable the 0th vertex attribute: position
      // gl.glDisableVertexAttribArray(1); // disable the 1th vertex attribute : color
      // Let the Vertex Shader know that we use uniform color

      // send the array of vertices to the vertex shader
      // draw an array of points: noOfPointsOn


      //draw a points in the circle
      // Use two Vertex Buffer Object for the points and color
      // gl.glEnableVertexAttribArray(0); // enable the 0th vertex attribute: position
      // gl.glEnableVertexAttribArray(1); // enable the 1th vertex attribute: color
      // send the array of vertices to the vertex shader
      // draw an array of points: noOfPointsIn with corresponding color

      // update each vertex in location: pointsInCoordinates +=direction;

      //bounce in the circle;
      // if pointsInCoordinates is outside the circle (pointsInCoordinates to the center=> 1)
      //pointsInCoordinates -= direction;
      //change the direction: vector reflect around the normal;
      //00- pointsInCoordinates => normal
      //dir= -direction;
      //reflect(dir,normal,direction);
      //pointInCoordinates+=direction;
      //end of display

      // draw a circle

      // gl.glUniform1i(uniformColorLoc, 1);

      // Use one Vertex Buffer Object for just the points
      gl.glEnableVertexAttribArray(0); // enable the 0th vertex attribute: position
      gl.glDisableVertexAttribArray(1); // disable the 1th vertex attribute : color

      // Let the Vertex Shader know that we use uniform color
      // gl.glVertexAttrib4f(vertexColorLoc, 1.0f, 1.0f, 1.0f, 1.0f);

      // send the array of vertices to the vertex shader
      gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
      gl.glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0);

      // draw an array of points: noOfPointsOn
      gl.glDrawArrays(GL_LINE_LOOP, 0, noOfPointsOn);

      // draw points inside the circle
      // gl.glUniform1i(uniformColorLoc, 0);

      // Use two Vertex Buffer Objects for the points and color
      gl.glEnableVertexAttribArray(0); // enable the 0th vertex attribute: position
      gl.glEnableVertexAttribArray(1); // enable the 1th vertex attribute: color

      // send the arrays of vertices and colors to the vertex shader
      gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
      gl.glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0);

      gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
      gl.glVertexAttribPointer(1, 3, GL_FLOAT, false, 0, 0);

      // draw an array of points: noOfPointsIn with corresponding color
      gl.glDrawArrays(GL_POINTS, 0, noOfPointsIn);

      // update each vertex in location: pointsInCoordinates += direction;
      for (int i = 0; i < noOfPointsIn * 2; i += 2) {
      pointsInCoordinates[i] += direction[0];
      pointsInCoordinates[i + 1] += direction[1];
      }

      // bounce in the circle
      for (int i = 0; i < noOfPointsIn * 2; i += 2) {
      float x = pointsInCoordinates[i];
      float y = pointsInCoordinates[i + 1];
      float dist = (float) Math.sqrt(x * x + y * y);
      if (dist > 1.0f) {
      x -= direction[0];
      y -= direction[1];
      float[] normal = { x, y };
      normalize(normal);
      float[] dir = { -direction[0], -direction[1] };
      reflect(dir, normal, direction);
      pointsInCoordinates[i] += direction[0];
      pointsInCoordinates[i + 1] += direction[1];
      }
      }

      // update the points in the point VBO
      gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[0]); // use handle 0
      FloatBuffer vBuf = Buffers.newDirectFloatBuffer(pointsOnCoordinates); // vertices packed to upload to V shader
      gl.glBufferData(GL_ARRAY_BUFFER, vBuf.limit() * Float.BYTES, // # of float * size of floats in bytes
      vBuf, // the vertex colors
      GL_STATIC_DRAW);
      gl.glVertexAttribPointer(1, 3, GL_FLOAT, false, 0, 0); // associate vbo[1] with active vao buffer
      // layout (location = 1) in V shader; 3 values for each vertex color
      gl.glPointSize(6.0f);

      }

      // Normalize a 2D vector
      void normalize(float[] vec) {
      float length = (float) Math.sqrt(vec[0] * vec[0] + vec[1] * vec[1]);
      vec[0] /= length;
      vec[1] /= length;
      }

      // Reflect a vector off a surface with a given normal
      void reflect(float[] vec, float[] normal, float[] result) {
      float dotProduct = vec[0] * normal[0] + vec[1] * normal[1];
      result[0] = vec[0] - 2.0f * dotProduct * normal[0];
      result[1] = vec[1] - 2.0f * dotProduct * normal[1];
      }


      public void init(GLAutoDrawable drawable) {

      String vShaderSource[], fShaderSource[];
      gl = (GL4) drawable.getGL();

      System.out.println("a) init: per-vertex values (vertex attributes: positions, colors, etc.) to the vertex shaders in parallel");

      // 7/26/2022: this is added for accommodating packages
      String path = this.getClass().getPackageName().replace(".", "/");

      vShaderSource = readShaderSource("src/"+path+"/athalapa_HW5_V.shader"); // read vertex shader
      fShaderSource = readShaderSource("src/"+path+"/athalapa_HW5_F.shader"); // read vertex shader }

      vfPrograms = initShaders(vShaderSource, fShaderSource);

      // 1. generate vertex arrays indexed by vao
      gl.glGenVertexArrays(vao.length, vao, 0); // vao stores the handles, starting position 0
      System.out.println(" Generate a VAO to hold VBO - arrays of vertex attributes (positions, colors)"); // we only use one vao
      gl.glBindVertexArray(vao[0]); // use handle 0

      // 2. generate vertex buffers indexed by vbo: here to store vertices and colors
      gl.glGenBuffers(vbo.length, vbo, 0);
      System.out.println(" Generate VBO (" + vbo.length + ") to hold arrays of vertex attributes."); // we use two: position
      // and color
      // 5. enable VAO with loaded VBO data: accessible in the vertex shader
      gl.glEnableVertexAttribArray(0); // enable the 0th vertex attribute: position
      gl.glEnableVertexAttribArray(1); // enable the 1th vertex attribute: color
      System.out.print(" Enable corresponding vertex attributes, "); // we use two: position and color
      System.out.println("and then load the attributes in display()."); // we use two: position and color

      }

      public static void main(String[] args) {
      new athalapa_BounceInCircle();
      System.out.println("per-vertex values to the shaders; drawing points, lines, and triangles with per-vertex colors.");

      // TODO Auto-generated method stub

      }
      }

      execute the above java program using JOGL

      ACTUAL -
      showing a bug

      ---------- BEGIN SOURCE ----------
      import static com.jogamp.opengl.GL.GL_ARRAY_BUFFER;
      import static com.jogamp.opengl.GL.GL_FLOAT;
      import static com.jogamp.opengl.GL.GL_LINE_LOOP;
      import static com.jogamp.opengl.GL.GL_POINTS;
      import static com.jogamp.opengl.GL.GL_STATIC_DRAW;
      import static com.jogamp.opengl.GL.GL_TRIANGLES;
      import static com.jogamp.opengl.GL2ES3.GL_COLOR;



      import java.io.File;
      import java.nio.FloatBuffer;

      import com.jogamp.common.nio.Buffers;
      import com.jogamp.opengl.GL4;
      import com.jogamp.opengl.GLAutoDrawable;

      public class athalapa_BounceInCircle extends JOGL1_3_VertexArray{

      float radius= HEIGHT/2.4f;
      float Radius= 2*radius/HEIGHT;
      float theta=0, dtheta=1/radius;

      int noOfPointsOn = (int)(2*Math.PI/dtheta); // Total number of points on the circle are 2*PI*r
      float pointsOnCoordinates[] = new float [noOfPointsOn*3]; // x,y,z coordinates of points
      float color[] = {1.0f, 1.0f, 0.0f};

      int noOfPointsIn = 80;// Total number of points inthe circle;
      float pointsInCoordinates[] = new float [noOfPointsIn*3];
      float direction[] = new float [noOfPointsIn*3];
      float colour[] = new float[noOfPointsIn*3];




      public athalapa_BounceInCircle() {

      // draw a circle
      // finding vertices of points on the circle
      for(int i=0; i < 3*noOfPointsOn; i++) {
      theta = theta+dtheta;
      pointsOnCoordinates[i]=(float) (Radius*Math.cos(theta));
      i++;
      pointsOnCoordinates[i]=(float) (Radius*Math.sin(theta));
      i++;
      pointsOnCoordinates[i]=0;
      }
      // generate points inside the circle, direction, and color
      for(int i = 0; i < noOfPointsIn; i++) {
      // calculate a random angle
      float angle = (float) (Math.random() * 2 * Math.PI);

      // calculate the position of the point inside the circle
      float x = (float) (radius * Math.cos(angle));
      float y = (float) (radius * Math.sin(angle));

      // set the position of the point
      pointsInCoordinates[i*3] = x;
      pointsInCoordinates[i*3+1] = y;
      pointsInCoordinates[i*3+2] = 0;

      // set a random direction for the point
      direction[i*3] = (float) (Math.random() * 2 - 1); // x direction
      direction[i*3+1] = (float) (Math.random() * 2 - 1); // y direction
      direction[i*3+2] = 0; // z direction (always 0)

      // set a random color for the point
      colour[i*3] = (float) Math.random(); // red
      colour[i*3+1] = (float) Math.random(); // green
      colour[i*3+2] = (float) Math.random();// blue
      }
      // TODO Auto-generated constructor stub
      }


      public void display(GLAutoDrawable drawable) {

      // clear the display every frame
      float bgColor[] = { 0.0f, 0.0f, 0.0f, 1.0f };
      FloatBuffer bgColorBuffer = Buffers.newDirectFloatBuffer(bgColor);
      gl.glClearBufferfv(GL_COLOR, 0, bgColorBuffer); // clear every frame
      // draw a circle
      // indicate that u r drawing a uniform color: color[0]=1.0f;
      // Use one Vertex Buffer Object for just the points
      // gl.glEnableVertexAttribArray(0); // enable the 0th vertex attribute: position
      // gl.glDisableVertexAttribArray(1); // disable the 1th vertex attribute : color
      // Let the Vertex Shader know that we use uniform color

      // send the array of vertices to the vertex shader
      // draw an array of points: noOfPointsOn


      //draw a points in the circle
      // Use two Vertex Buffer Object for the points and color
      // gl.glEnableVertexAttribArray(0); // enable the 0th vertex attribute: position
      // gl.glEnableVertexAttribArray(1); // enable the 1th vertex attribute: color
      // send the array of vertices to the vertex shader
      // draw an array of points: noOfPointsIn with corresponding color

      // update each vertex in location: pointsInCoordinates +=direction;

      //bounce in the circle;
      // if pointsInCoordinates is outside the circle (pointsInCoordinates to the center=> 1)
      //pointsInCoordinates -= direction;
      //change the direction: vector reflect around the normal;
      //00- pointsInCoordinates => normal
      //dir= -direction;
      //reflect(dir,normal,direction);
      //pointInCoordinates+=direction;
      //end of display

      // draw a circle

      // gl.glUniform1i(uniformColorLoc, 1);

      // Use one Vertex Buffer Object for just the points
      gl.glEnableVertexAttribArray(0); // enable the 0th vertex attribute: position
      gl.glDisableVertexAttribArray(1); // disable the 1th vertex attribute : color

      // Let the Vertex Shader know that we use uniform color
      // gl.glVertexAttrib4f(vertexColorLoc, 1.0f, 1.0f, 1.0f, 1.0f);

      // send the array of vertices to the vertex shader
      gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
      gl.glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0);

      // draw an array of points: noOfPointsOn
      gl.glDrawArrays(GL_LINE_LOOP, 0, noOfPointsOn);

      // draw points inside the circle
      // gl.glUniform1i(uniformColorLoc, 0);

      // Use two Vertex Buffer Objects for the points and color
      gl.glEnableVertexAttribArray(0); // enable the 0th vertex attribute: position
      gl.glEnableVertexAttribArray(1); // enable the 1th vertex attribute: color

      // send the arrays of vertices and colors to the vertex shader
      gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
      gl.glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0);

      gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
      gl.glVertexAttribPointer(1, 3, GL_FLOAT, false, 0, 0);

      // draw an array of points: noOfPointsIn with corresponding color
      gl.glDrawArrays(GL_POINTS, 0, noOfPointsIn);

      // update each vertex in location: pointsInCoordinates += direction;
      for (int i = 0; i < noOfPointsIn * 2; i += 2) {
      pointsInCoordinates[i] += direction[0];
      pointsInCoordinates[i + 1] += direction[1];
      }

      // bounce in the circle
      for (int i = 0; i < noOfPointsIn * 2; i += 2) {
      float x = pointsInCoordinates[i];
      float y = pointsInCoordinates[i + 1];
      float dist = (float) Math.sqrt(x * x + y * y);
      if (dist > 1.0f) {
      x -= direction[0];
      y -= direction[1];
      float[] normal = { x, y };
      normalize(normal);
      float[] dir = { -direction[0], -direction[1] };
      reflect(dir, normal, direction);
      pointsInCoordinates[i] += direction[0];
      pointsInCoordinates[i + 1] += direction[1];
      }
      }

      // update the points in the point VBO
      gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[0]); // use handle 0
      FloatBuffer vBuf = Buffers.newDirectFloatBuffer(pointsOnCoordinates); // vertices packed to upload to V shader
      gl.glBufferData(GL_ARRAY_BUFFER, vBuf.limit() * Float.BYTES, // # of float * size of floats in bytes
      vBuf, // the vertex colors
      GL_STATIC_DRAW);
      gl.glVertexAttribPointer(1, 3, GL_FLOAT, false, 0, 0); // associate vbo[1] with active vao buffer
      // layout (location = 1) in V shader; 3 values for each vertex color
      gl.glPointSize(6.0f);

      }

      // Normalize a 2D vector
      void normalize(float[] vec) {
      float length = (float) Math.sqrt(vec[0] * vec[0] + vec[1] * vec[1]);
      vec[0] /= length;
      vec[1] /= length;
      }

      // Reflect a vector off a surface with a given normal
      void reflect(float[] vec, float[] normal, float[] result) {
      float dotProduct = vec[0] * normal[0] + vec[1] * normal[1];
      result[0] = vec[0] - 2.0f * dotProduct * normal[0];
      result[1] = vec[1] - 2.0f * dotProduct * normal[1];
      }


      public void init(GLAutoDrawable drawable) {

      String vShaderSource[], fShaderSource[];
      gl = (GL4) drawable.getGL();

      System.out.println("a) init: per-vertex values (vertex attributes: positions, colors, etc.) to the vertex shaders in parallel");

      // 7/26/2022: this is added for accommodating packages
      String path = this.getClass().getPackageName().replace(".", "/");

      vShaderSource = readShaderSource("src/"+path+"/athalapa_HW5_V.shader"); // read vertex shader
      fShaderSource = readShaderSource("src/"+path+"/athalapa_HW5_F.shader"); // read vertex shader }

      vfPrograms = initShaders(vShaderSource, fShaderSource);

      // 1. generate vertex arrays indexed by vao
      gl.glGenVertexArrays(vao.length, vao, 0); // vao stores the handles, starting position 0
      System.out.println(" Generate a VAO to hold VBO - arrays of vertex attributes (positions, colors)"); // we only use one vao
      gl.glBindVertexArray(vao[0]); // use handle 0

      // 2. generate vertex buffers indexed by vbo: here to store vertices and colors
      gl.glGenBuffers(vbo.length, vbo, 0);
      System.out.println(" Generate VBO (" + vbo.length + ") to hold arrays of vertex attributes."); // we use two: position
      // and color
      // 5. enable VAO with loaded VBO data: accessible in the vertex shader
      gl.glEnableVertexAttribArray(0); // enable the 0th vertex attribute: position
      gl.glEnableVertexAttribArray(1); // enable the 1th vertex attribute: color
      System.out.print(" Enable corresponding vertex attributes, "); // we use two: position and color
      System.out.println("and then load the attributes in display()."); // we use two: position and color

      }

      public static void main(String[] args) {
      new athalapa_BounceInCircle();
      System.out.println("per-vertex values to the shaders; drawing points, lines, and triangles with per-vertex colors.");

      // TODO Auto-generated method stub

      }
      }


      ---------- END SOURCE ----------

      FREQUENCY : always


            pnarayanaswa Praveen Narayanaswamy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: