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

Crash with problematic frame lwjgl_opengl.dll when using openGL

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Windows 11

      A DESCRIPTION OF THE PROBLEM :
      Using openGL to draw a circle to a window which crash on compilation and doesn't compile. There are no error warnings in the code.

      REGRESSION : Last worked in version 18

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      create a driver file which builds a window class and draws a circle to the window using a circle class using lwjgl.

      ACTUAL -
      code starts to compile and then crashes before anything happens

      ---------- BEGIN SOURCE ----------
      import org.lwjgl.BufferUtils;
      import org.lwjgl.opengl.GL11;
      import org.lwjgl.opengl.GL15;
      import org.lwjgl.opengl.GL20;
      import org.lwjgl.opengl.GL30;
      import org.lwjgl.opengl.GLUtil;
      import org.lwjgl.system.MemoryUtil;

      import java.nio.FloatBuffer;

      public class Circle2 {

          // Number of vertices in the circle
          private static final int VERTEX_COUNT = 32;

          // Vertex data
          private float[] vertices;
          private int vao;
          private int vbo;

          // Shader program
          private int program;

          // Location of the "position" attribute in the shader
          private int positionLocation;

          // Location of the "color" uniform in the shader
          private int colorLocation;

          // Location of the "model" uniform in the shader
          private int modelLocation;

          // Circle position and color
          private float x;
          private float y;
          private float r;
          private float g;
          private float b;

          public Circle2(float x, float y, float r, float g, float b) {


              // Set the fields of the Circle object
              this.x = x;
              this.y = y;
              this.r = r;
              this.g = g;
              this.b = b;

              // Create the shader program
              program = createShaderProgram();

              // Generate the VAO and VBO
              vao = GL30.glGenVertexArrays();
              vbo = GL15.glGenBuffers();

              // Bind the VAO
              GL30.glBindVertexArray(vao);

              // Bind the VBO to the VAO
              GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);


              // Set the "position" attribute in the vertex shader
              positionLocation = GL20.glGetAttribLocation(program, "position");
              GL20.glEnableVertexAttribArray(positionLocation);
              GL20.glVertexAttribPointer(positionLocation, 2, GL11.GL_FLOAT, false, 0, 0);

              // Unbind the VBO
              GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

              // Unbind the VAO
              GL30.glBindVertexArray(0);
          }
          public void render() {
              // Set the current shader program
              GL20.glUseProgram(program);

              // Bind the VAO
              GL30.glBindVertexArray(vao);

              // Set the model matrix uniform in the shader program
              GL20.glUniform2f(modelLocation, x, y);

              // Set the color uniform in the shader program
              GL20.glUniform3f(colorLocation, r, g, b);
              // Draw the circle
              GL11.glDrawArrays(GL11.GL_TRIANGLE_FAN, 0, VERTEX_COUNT);

              // Unbind the VAO
              GL30.glBindVertexArray(0);
          }
          private int createShaderProgram() {
              // Vertex shader source code
              String vertexShaderSource =
                      "#version 330 core\n" +
                              "layout (location = 0) in vec2 position;\n" +
                              "uniform vec2 model;\n" +
                              "void main() {\n" +
                              " gl_Position = model * vec4(position, 0.0, 1.0);\n" +
                              "}\n";

              // Fragment shader source code
              String fragmentShaderSource =
                      "#version 330 core\n" +
                              "uniform vec3 color;\n" +
                              "out vec4 outColor;\n" +
                              "void main() {\n" +
                              " outColor = vec4(color, 1.0);\n" +
                              "}\n";

              // Create the vertex shader
              int vertexShader = GL20.glCreateShader(GL20.GL_VERTEX_SHADER);
              GL20.glShaderSource(vertexShader, vertexShaderSource);
              GL20.glCompileShader(vertexShader);

              // Check for errors
              int status = GL20.glGetShaderi(vertexShader, GL20.GL_COMPILE_STATUS);
              if (status != GL11.GL_TRUE) {
                  throw new RuntimeException(GL20.glGetShaderInfoLog(vertexShader));
              }

              // Create the fragment shader
              int fragmentShader = GL20.glCreateShader(GL20.GL_FRAGMENT_SHADER);
              GL20.glShaderSource(fragmentShader, fragmentShaderSource);
              GL20.glCompileShader(fragmentShader);

              // Check for errors
              status = GL20.glGetShaderi(fragmentShader, GL20.GL_COMPILE_STATUS);
              if (status != GL11.GL_TRUE) {
                  throw new RuntimeException(GL20.glGetShaderInfoLog(fragmentShader));
              }

              // Create the shader program
              int program = GL20.glCreateProgram();
              GL20.glAttachShader(program, vertexShader);
              GL20.glAttachShader(program, fragmentShader);
              GL20.glLinkProgram(program);


              // Check for errors
              status = GL20.glGetProgrami(program, GL20.GL_LINK_STATUS);
              if (status != GL11.GL_TRUE) {
                  throw new RuntimeException(GL20.glGetProgramInfoLog(program));
              }

              // Delete the shaders
              GL20.glDeleteShader(vertexShader);
              GL20.glDeleteShader(fragmentShader);

              return program;
          }


      }
      ---------- 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: