Java fatal runtime error while loading texture in LWJGL












-1















My program is crashing due to an EXCEPTION_ACCESS_VIOLATION in the file ig7icd64.dll file.



I'm creating a simple project with the LWJGL library and some external jars found here: https://github.com/CodingAP/LWJGL-3-Tutorial.git (just using slick-util3) and when loading textures from resource files ('.png') the program crashes.



I have many classes which are using a lot of GLXX.gl[function_name_here],
but I will explain why I do not list all of them.



I create a window with a Window class which just sets up a GLFW-context and works just fine.



I have a Model class which gets extended by UntexturedModel as well as TexturedModel. These set up VertexArrays and VertexBuffers and function normally.
I even have a Shader class which reads two shader files and applies them with no errors.



public class UntexturedModel extends Model {

private int vertexArrayID, vertexBufferID, indicesBufferID, vertexCount;

public UntexturedModel(float vertices, int indices) {
vertexArrayID = super.createVertexArray();
indicesBufferID = super.bindIndicesBuffer(indices);
vertexBufferID = super.storeData(0, 3, vertices);
vertexCount = indices.length;
GL30.glBindVertexArray(0);
}

public void destroy () {
GL30.glDeleteVertexArrays(vertexArrayID);
GL15.glDeleteBuffers(vertexBufferID);
GL15.glDeleteBuffers(indicesBufferID);
}

// I have not included the getters for the IDs due to the space available
}


This extends the Model class which follows:



public class Model {

protected int createVertexArray() {
int vertexArrayID = GL30.glGenVertexArrays();
GL30.glBindVertexArray(vertexArrayID);
return vertexArrayID;
}

protected int storeData (int attributeNumber, int coordSize, float data) {

FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
buffer.put(data);
buffer.flip();

int bufferID = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, bufferID);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);

GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0);

GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

return bufferID;
}

protected int bindIndicesBuffer (int indices) {

IntBuffer buffer = BufferUtils.createIntBuffer(indices.length);
buffer.put(indices);
buffer.flip();

int bufferID = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, bufferID);
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);

return bufferID;
}
}


The TexturedModel is in essence the same as UntexturedModel, but has an additional float textureCoords which gets added using storeData(1, 2, textureCoords); It also has an attribute Material which uses the external jars:



public class Material {

private int textureID;

public Material (String file) {
try {

textureID = TextureLoader.getTexture("png", new FileInputStream("res/" + file)).getTextureID();
// Possible error location: TextureLoader is an external jar

} catch (IOException e) {
System.err.println("Error: Couldn't load texture");
System.exit(-1);
}
}

public void destroy () {
GL11.glDeleteTextures(textureID);
}
// I'm ignoring getters once again
}


Using the UntexturedModel class works fine, even with shader files. I will include the BasicShader and Shader classes below:



public abstract class Shader {

private int vertexShaderID, fragmentShaderID, programID;
private String vertexFile, fragmentFile;

public Shader (String vertexFile, String fragmentFile) {
this.vertexFile = vertexFile;
this.fragmentFile = fragmentFile;
}

public void create () {
programID = GL20.glCreateProgram();

vertexShaderID = GL20.glCreateShader(GL20.GL_VERTEX_SHADER);

GL20.glShaderSource(vertexShaderID, readFile(vertexFile));
GL20.glCompileShader(vertexShaderID);

if (GL20.glGetShaderi(vertexShaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) {
System.err.println("Error: Vertex Shader - " + GL20.glGetShaderInfoLog(vertexShaderID));
}

fragmentShaderID = GL20.glCreateShader(GL20.GL_FRAGMENT_SHADER);

GL20.glShaderSource(fragmentShaderID, readFile(fragmentFile));
GL20.glCompileShader(fragmentShaderID);

if (GL20.glGetShaderi(fragmentShaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) {
System.err.println("Error: Fragment Shader - " + GL20.glGetShaderInfoLog(fragmentShaderID));
}

GL20.glAttachShader(programID, vertexShaderID);
GL20.glAttachShader(programID, fragmentShaderID);

GL20.glLinkProgram(programID);

if (GL20.glGetProgrami(programID, GL20.GL_LINK_STATUS) == GL11.GL_FALSE) {
System.err.println("Error: Program Linking - " + GL20.glGetShaderInfoLog(programID));
}

GL20.glValidateProgram(programID);

if (GL20.glGetProgrami(programID, GL20.GL_VALIDATE_STATUS) == GL11.GL_FALSE) {
System.err.println("Error: Program Validation - " + GL20.glGetShaderInfoLog(programID));
}
}

public abstract void bindAllAttributes();

public void bindAttribute (int index, String location) {
GL20.glBindAttribLocation(programID, index, location);
}

public void bind () {
GL20.glUseProgram(programID);
}

public void destroy () {
GL20.glDetachShader(programID, vertexShaderID);
GL20.glDetachShader(programID, fragmentShaderID);

GL20.glDeleteShader(vertexShaderID);
GL20.glDeleteShader(fragmentShaderID);

GL20.glDeleteProgram(programID);
}

private String readFile (String path) {
BufferedReader reader;
StringBuilder builder = new StringBuilder();

try {

reader = new BufferedReader(new FileReader(path));

String line = reader.readLine();

while (line != null) {

builder.append(line + 'n');
line = reader.readLine();
}

} catch (IOException e) {
System.err.println("Error: Exception while reading from file");
}

return builder.toString();
}
}

public class BasicShader extends Shader {

private static final String VERTEX_FILE = ".\src\shaders\basicVertexShader.vs";
private static final String FRAGMENT_FILE = ".\src\shaders\basicFragmentShader.fs";

public BasicShader() {
super(VERTEX_FILE, FRAGMENT_FILE);
}

@Override
public void bindAllAttributes () {
super.bindAttribute(0, "position");
super.bindAttribute(1, "textCoords");
}
}


I've tested the shader files (basicVertexShader.vs and basicFragmentShader.fs) and they work as intended.



I have tried the following:
Seeing if the .dll file was deleted.
Re-installing Java (jdk and jre included)
Re-installing Eclipse
Updating Graohics Driver to the by Intel suggested verion



I'm using Windows 10 and a Lenovo Thinkpad.



If any additional information is needed, please ask bellow.



Update:



Stack: [0x0000000002b10000,0x0000000002c10000], sp=0x0000000002c0bf40, free space=1007k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)



C [ig7icd64.dll+0x933b0]



C [ig7icd64.dll+0x17b4b2]



C [ig7icd64.dll+0x215514]



C [ig7icd64.dll+0x6d1ee]



C [ig7icd64.dll+0x243745]



C [ig7icd64.dll+0x92555]



C [ig7icd64.dll+0x2a3af8]



C [ig7icd64.dll+0x2a3e09]



C [ig7icd64.dll+0x2a57ba]



C 0x0000000002d88c67



Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)



j org.lwjgl.opengl.GL11C.nglDrawElements(IIIJ)V+0



j org.lwjgl.opengl.GL11C.glDrawElements(IIIJ)V+4



j org.lwjgl.opengl.GL11.glDrawElements(IIIJ)V+4



j render.Renderer.renderTexturedModel(Lrender/TexturedModel;)V+43 (Renderer is a class which just executes the glDrawElements() function; nothing special)



j main.Main.main([Ljava/lang/String;)V+191



v ~StubRoutines::call_stub



Update:
I solved the issue. It lies in Model.storeData(). I don't use attributeNumber or coordSize. CLOSED










share|improve this question

























  • Please provide a MCVE or at the very least tell where it crashes exactly (the hs_err_pid.log file mentioned in the crash report printed to stdout contains a stacktrace) and show the code of that section.

    – httpdigest
    Jan 1 at 19:52






  • 1





    A crash in a draw call is in 99.9999% caused by an enabled vertex attribute which hasn't been properly initialized via glVertexAttribPointer() or an indices pointer given to glDrawElements() which is null. This can happen when you use the long-overload of that method while not having a GL_ELEMENT_ARRAY_BUFFER bound.

    – httpdigest
    Jan 1 at 20:03











  • Situations like these will be caught and reported by: github.com/LWJGLX/debug

    – httpdigest
    Jan 1 at 20:04






  • 1





    Thanks @httpdigest ! I just checked my bindings and the parameters and I messed some obvious numbers. Thanks for your help!

    – J. Lengel
    Jan 1 at 20:41
















-1















My program is crashing due to an EXCEPTION_ACCESS_VIOLATION in the file ig7icd64.dll file.



I'm creating a simple project with the LWJGL library and some external jars found here: https://github.com/CodingAP/LWJGL-3-Tutorial.git (just using slick-util3) and when loading textures from resource files ('.png') the program crashes.



I have many classes which are using a lot of GLXX.gl[function_name_here],
but I will explain why I do not list all of them.



I create a window with a Window class which just sets up a GLFW-context and works just fine.



I have a Model class which gets extended by UntexturedModel as well as TexturedModel. These set up VertexArrays and VertexBuffers and function normally.
I even have a Shader class which reads two shader files and applies them with no errors.



public class UntexturedModel extends Model {

private int vertexArrayID, vertexBufferID, indicesBufferID, vertexCount;

public UntexturedModel(float vertices, int indices) {
vertexArrayID = super.createVertexArray();
indicesBufferID = super.bindIndicesBuffer(indices);
vertexBufferID = super.storeData(0, 3, vertices);
vertexCount = indices.length;
GL30.glBindVertexArray(0);
}

public void destroy () {
GL30.glDeleteVertexArrays(vertexArrayID);
GL15.glDeleteBuffers(vertexBufferID);
GL15.glDeleteBuffers(indicesBufferID);
}

// I have not included the getters for the IDs due to the space available
}


This extends the Model class which follows:



public class Model {

protected int createVertexArray() {
int vertexArrayID = GL30.glGenVertexArrays();
GL30.glBindVertexArray(vertexArrayID);
return vertexArrayID;
}

protected int storeData (int attributeNumber, int coordSize, float data) {

FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
buffer.put(data);
buffer.flip();

int bufferID = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, bufferID);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);

GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0);

GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

return bufferID;
}

protected int bindIndicesBuffer (int indices) {

IntBuffer buffer = BufferUtils.createIntBuffer(indices.length);
buffer.put(indices);
buffer.flip();

int bufferID = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, bufferID);
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);

return bufferID;
}
}


The TexturedModel is in essence the same as UntexturedModel, but has an additional float textureCoords which gets added using storeData(1, 2, textureCoords); It also has an attribute Material which uses the external jars:



public class Material {

private int textureID;

public Material (String file) {
try {

textureID = TextureLoader.getTexture("png", new FileInputStream("res/" + file)).getTextureID();
// Possible error location: TextureLoader is an external jar

} catch (IOException e) {
System.err.println("Error: Couldn't load texture");
System.exit(-1);
}
}

public void destroy () {
GL11.glDeleteTextures(textureID);
}
// I'm ignoring getters once again
}


Using the UntexturedModel class works fine, even with shader files. I will include the BasicShader and Shader classes below:



public abstract class Shader {

private int vertexShaderID, fragmentShaderID, programID;
private String vertexFile, fragmentFile;

public Shader (String vertexFile, String fragmentFile) {
this.vertexFile = vertexFile;
this.fragmentFile = fragmentFile;
}

public void create () {
programID = GL20.glCreateProgram();

vertexShaderID = GL20.glCreateShader(GL20.GL_VERTEX_SHADER);

GL20.glShaderSource(vertexShaderID, readFile(vertexFile));
GL20.glCompileShader(vertexShaderID);

if (GL20.glGetShaderi(vertexShaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) {
System.err.println("Error: Vertex Shader - " + GL20.glGetShaderInfoLog(vertexShaderID));
}

fragmentShaderID = GL20.glCreateShader(GL20.GL_FRAGMENT_SHADER);

GL20.glShaderSource(fragmentShaderID, readFile(fragmentFile));
GL20.glCompileShader(fragmentShaderID);

if (GL20.glGetShaderi(fragmentShaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) {
System.err.println("Error: Fragment Shader - " + GL20.glGetShaderInfoLog(fragmentShaderID));
}

GL20.glAttachShader(programID, vertexShaderID);
GL20.glAttachShader(programID, fragmentShaderID);

GL20.glLinkProgram(programID);

if (GL20.glGetProgrami(programID, GL20.GL_LINK_STATUS) == GL11.GL_FALSE) {
System.err.println("Error: Program Linking - " + GL20.glGetShaderInfoLog(programID));
}

GL20.glValidateProgram(programID);

if (GL20.glGetProgrami(programID, GL20.GL_VALIDATE_STATUS) == GL11.GL_FALSE) {
System.err.println("Error: Program Validation - " + GL20.glGetShaderInfoLog(programID));
}
}

public abstract void bindAllAttributes();

public void bindAttribute (int index, String location) {
GL20.glBindAttribLocation(programID, index, location);
}

public void bind () {
GL20.glUseProgram(programID);
}

public void destroy () {
GL20.glDetachShader(programID, vertexShaderID);
GL20.glDetachShader(programID, fragmentShaderID);

GL20.glDeleteShader(vertexShaderID);
GL20.glDeleteShader(fragmentShaderID);

GL20.glDeleteProgram(programID);
}

private String readFile (String path) {
BufferedReader reader;
StringBuilder builder = new StringBuilder();

try {

reader = new BufferedReader(new FileReader(path));

String line = reader.readLine();

while (line != null) {

builder.append(line + 'n');
line = reader.readLine();
}

} catch (IOException e) {
System.err.println("Error: Exception while reading from file");
}

return builder.toString();
}
}

public class BasicShader extends Shader {

private static final String VERTEX_FILE = ".\src\shaders\basicVertexShader.vs";
private static final String FRAGMENT_FILE = ".\src\shaders\basicFragmentShader.fs";

public BasicShader() {
super(VERTEX_FILE, FRAGMENT_FILE);
}

@Override
public void bindAllAttributes () {
super.bindAttribute(0, "position");
super.bindAttribute(1, "textCoords");
}
}


I've tested the shader files (basicVertexShader.vs and basicFragmentShader.fs) and they work as intended.



I have tried the following:
Seeing if the .dll file was deleted.
Re-installing Java (jdk and jre included)
Re-installing Eclipse
Updating Graohics Driver to the by Intel suggested verion



I'm using Windows 10 and a Lenovo Thinkpad.



If any additional information is needed, please ask bellow.



Update:



Stack: [0x0000000002b10000,0x0000000002c10000], sp=0x0000000002c0bf40, free space=1007k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)



C [ig7icd64.dll+0x933b0]



C [ig7icd64.dll+0x17b4b2]



C [ig7icd64.dll+0x215514]



C [ig7icd64.dll+0x6d1ee]



C [ig7icd64.dll+0x243745]



C [ig7icd64.dll+0x92555]



C [ig7icd64.dll+0x2a3af8]



C [ig7icd64.dll+0x2a3e09]



C [ig7icd64.dll+0x2a57ba]



C 0x0000000002d88c67



Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)



j org.lwjgl.opengl.GL11C.nglDrawElements(IIIJ)V+0



j org.lwjgl.opengl.GL11C.glDrawElements(IIIJ)V+4



j org.lwjgl.opengl.GL11.glDrawElements(IIIJ)V+4



j render.Renderer.renderTexturedModel(Lrender/TexturedModel;)V+43 (Renderer is a class which just executes the glDrawElements() function; nothing special)



j main.Main.main([Ljava/lang/String;)V+191



v ~StubRoutines::call_stub



Update:
I solved the issue. It lies in Model.storeData(). I don't use attributeNumber or coordSize. CLOSED










share|improve this question

























  • Please provide a MCVE or at the very least tell where it crashes exactly (the hs_err_pid.log file mentioned in the crash report printed to stdout contains a stacktrace) and show the code of that section.

    – httpdigest
    Jan 1 at 19:52






  • 1





    A crash in a draw call is in 99.9999% caused by an enabled vertex attribute which hasn't been properly initialized via glVertexAttribPointer() or an indices pointer given to glDrawElements() which is null. This can happen when you use the long-overload of that method while not having a GL_ELEMENT_ARRAY_BUFFER bound.

    – httpdigest
    Jan 1 at 20:03











  • Situations like these will be caught and reported by: github.com/LWJGLX/debug

    – httpdigest
    Jan 1 at 20:04






  • 1





    Thanks @httpdigest ! I just checked my bindings and the parameters and I messed some obvious numbers. Thanks for your help!

    – J. Lengel
    Jan 1 at 20:41














-1












-1








-1








My program is crashing due to an EXCEPTION_ACCESS_VIOLATION in the file ig7icd64.dll file.



I'm creating a simple project with the LWJGL library and some external jars found here: https://github.com/CodingAP/LWJGL-3-Tutorial.git (just using slick-util3) and when loading textures from resource files ('.png') the program crashes.



I have many classes which are using a lot of GLXX.gl[function_name_here],
but I will explain why I do not list all of them.



I create a window with a Window class which just sets up a GLFW-context and works just fine.



I have a Model class which gets extended by UntexturedModel as well as TexturedModel. These set up VertexArrays and VertexBuffers and function normally.
I even have a Shader class which reads two shader files and applies them with no errors.



public class UntexturedModel extends Model {

private int vertexArrayID, vertexBufferID, indicesBufferID, vertexCount;

public UntexturedModel(float vertices, int indices) {
vertexArrayID = super.createVertexArray();
indicesBufferID = super.bindIndicesBuffer(indices);
vertexBufferID = super.storeData(0, 3, vertices);
vertexCount = indices.length;
GL30.glBindVertexArray(0);
}

public void destroy () {
GL30.glDeleteVertexArrays(vertexArrayID);
GL15.glDeleteBuffers(vertexBufferID);
GL15.glDeleteBuffers(indicesBufferID);
}

// I have not included the getters for the IDs due to the space available
}


This extends the Model class which follows:



public class Model {

protected int createVertexArray() {
int vertexArrayID = GL30.glGenVertexArrays();
GL30.glBindVertexArray(vertexArrayID);
return vertexArrayID;
}

protected int storeData (int attributeNumber, int coordSize, float data) {

FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
buffer.put(data);
buffer.flip();

int bufferID = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, bufferID);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);

GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0);

GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

return bufferID;
}

protected int bindIndicesBuffer (int indices) {

IntBuffer buffer = BufferUtils.createIntBuffer(indices.length);
buffer.put(indices);
buffer.flip();

int bufferID = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, bufferID);
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);

return bufferID;
}
}


The TexturedModel is in essence the same as UntexturedModel, but has an additional float textureCoords which gets added using storeData(1, 2, textureCoords); It also has an attribute Material which uses the external jars:



public class Material {

private int textureID;

public Material (String file) {
try {

textureID = TextureLoader.getTexture("png", new FileInputStream("res/" + file)).getTextureID();
// Possible error location: TextureLoader is an external jar

} catch (IOException e) {
System.err.println("Error: Couldn't load texture");
System.exit(-1);
}
}

public void destroy () {
GL11.glDeleteTextures(textureID);
}
// I'm ignoring getters once again
}


Using the UntexturedModel class works fine, even with shader files. I will include the BasicShader and Shader classes below:



public abstract class Shader {

private int vertexShaderID, fragmentShaderID, programID;
private String vertexFile, fragmentFile;

public Shader (String vertexFile, String fragmentFile) {
this.vertexFile = vertexFile;
this.fragmentFile = fragmentFile;
}

public void create () {
programID = GL20.glCreateProgram();

vertexShaderID = GL20.glCreateShader(GL20.GL_VERTEX_SHADER);

GL20.glShaderSource(vertexShaderID, readFile(vertexFile));
GL20.glCompileShader(vertexShaderID);

if (GL20.glGetShaderi(vertexShaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) {
System.err.println("Error: Vertex Shader - " + GL20.glGetShaderInfoLog(vertexShaderID));
}

fragmentShaderID = GL20.glCreateShader(GL20.GL_FRAGMENT_SHADER);

GL20.glShaderSource(fragmentShaderID, readFile(fragmentFile));
GL20.glCompileShader(fragmentShaderID);

if (GL20.glGetShaderi(fragmentShaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) {
System.err.println("Error: Fragment Shader - " + GL20.glGetShaderInfoLog(fragmentShaderID));
}

GL20.glAttachShader(programID, vertexShaderID);
GL20.glAttachShader(programID, fragmentShaderID);

GL20.glLinkProgram(programID);

if (GL20.glGetProgrami(programID, GL20.GL_LINK_STATUS) == GL11.GL_FALSE) {
System.err.println("Error: Program Linking - " + GL20.glGetShaderInfoLog(programID));
}

GL20.glValidateProgram(programID);

if (GL20.glGetProgrami(programID, GL20.GL_VALIDATE_STATUS) == GL11.GL_FALSE) {
System.err.println("Error: Program Validation - " + GL20.glGetShaderInfoLog(programID));
}
}

public abstract void bindAllAttributes();

public void bindAttribute (int index, String location) {
GL20.glBindAttribLocation(programID, index, location);
}

public void bind () {
GL20.glUseProgram(programID);
}

public void destroy () {
GL20.glDetachShader(programID, vertexShaderID);
GL20.glDetachShader(programID, fragmentShaderID);

GL20.glDeleteShader(vertexShaderID);
GL20.glDeleteShader(fragmentShaderID);

GL20.glDeleteProgram(programID);
}

private String readFile (String path) {
BufferedReader reader;
StringBuilder builder = new StringBuilder();

try {

reader = new BufferedReader(new FileReader(path));

String line = reader.readLine();

while (line != null) {

builder.append(line + 'n');
line = reader.readLine();
}

} catch (IOException e) {
System.err.println("Error: Exception while reading from file");
}

return builder.toString();
}
}

public class BasicShader extends Shader {

private static final String VERTEX_FILE = ".\src\shaders\basicVertexShader.vs";
private static final String FRAGMENT_FILE = ".\src\shaders\basicFragmentShader.fs";

public BasicShader() {
super(VERTEX_FILE, FRAGMENT_FILE);
}

@Override
public void bindAllAttributes () {
super.bindAttribute(0, "position");
super.bindAttribute(1, "textCoords");
}
}


I've tested the shader files (basicVertexShader.vs and basicFragmentShader.fs) and they work as intended.



I have tried the following:
Seeing if the .dll file was deleted.
Re-installing Java (jdk and jre included)
Re-installing Eclipse
Updating Graohics Driver to the by Intel suggested verion



I'm using Windows 10 and a Lenovo Thinkpad.



If any additional information is needed, please ask bellow.



Update:



Stack: [0x0000000002b10000,0x0000000002c10000], sp=0x0000000002c0bf40, free space=1007k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)



C [ig7icd64.dll+0x933b0]



C [ig7icd64.dll+0x17b4b2]



C [ig7icd64.dll+0x215514]



C [ig7icd64.dll+0x6d1ee]



C [ig7icd64.dll+0x243745]



C [ig7icd64.dll+0x92555]



C [ig7icd64.dll+0x2a3af8]



C [ig7icd64.dll+0x2a3e09]



C [ig7icd64.dll+0x2a57ba]



C 0x0000000002d88c67



Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)



j org.lwjgl.opengl.GL11C.nglDrawElements(IIIJ)V+0



j org.lwjgl.opengl.GL11C.glDrawElements(IIIJ)V+4



j org.lwjgl.opengl.GL11.glDrawElements(IIIJ)V+4



j render.Renderer.renderTexturedModel(Lrender/TexturedModel;)V+43 (Renderer is a class which just executes the glDrawElements() function; nothing special)



j main.Main.main([Ljava/lang/String;)V+191



v ~StubRoutines::call_stub



Update:
I solved the issue. It lies in Model.storeData(). I don't use attributeNumber or coordSize. CLOSED










share|improve this question
















My program is crashing due to an EXCEPTION_ACCESS_VIOLATION in the file ig7icd64.dll file.



I'm creating a simple project with the LWJGL library and some external jars found here: https://github.com/CodingAP/LWJGL-3-Tutorial.git (just using slick-util3) and when loading textures from resource files ('.png') the program crashes.



I have many classes which are using a lot of GLXX.gl[function_name_here],
but I will explain why I do not list all of them.



I create a window with a Window class which just sets up a GLFW-context and works just fine.



I have a Model class which gets extended by UntexturedModel as well as TexturedModel. These set up VertexArrays and VertexBuffers and function normally.
I even have a Shader class which reads two shader files and applies them with no errors.



public class UntexturedModel extends Model {

private int vertexArrayID, vertexBufferID, indicesBufferID, vertexCount;

public UntexturedModel(float vertices, int indices) {
vertexArrayID = super.createVertexArray();
indicesBufferID = super.bindIndicesBuffer(indices);
vertexBufferID = super.storeData(0, 3, vertices);
vertexCount = indices.length;
GL30.glBindVertexArray(0);
}

public void destroy () {
GL30.glDeleteVertexArrays(vertexArrayID);
GL15.glDeleteBuffers(vertexBufferID);
GL15.glDeleteBuffers(indicesBufferID);
}

// I have not included the getters for the IDs due to the space available
}


This extends the Model class which follows:



public class Model {

protected int createVertexArray() {
int vertexArrayID = GL30.glGenVertexArrays();
GL30.glBindVertexArray(vertexArrayID);
return vertexArrayID;
}

protected int storeData (int attributeNumber, int coordSize, float data) {

FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
buffer.put(data);
buffer.flip();

int bufferID = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, bufferID);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);

GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0);

GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

return bufferID;
}

protected int bindIndicesBuffer (int indices) {

IntBuffer buffer = BufferUtils.createIntBuffer(indices.length);
buffer.put(indices);
buffer.flip();

int bufferID = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, bufferID);
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);

return bufferID;
}
}


The TexturedModel is in essence the same as UntexturedModel, but has an additional float textureCoords which gets added using storeData(1, 2, textureCoords); It also has an attribute Material which uses the external jars:



public class Material {

private int textureID;

public Material (String file) {
try {

textureID = TextureLoader.getTexture("png", new FileInputStream("res/" + file)).getTextureID();
// Possible error location: TextureLoader is an external jar

} catch (IOException e) {
System.err.println("Error: Couldn't load texture");
System.exit(-1);
}
}

public void destroy () {
GL11.glDeleteTextures(textureID);
}
// I'm ignoring getters once again
}


Using the UntexturedModel class works fine, even with shader files. I will include the BasicShader and Shader classes below:



public abstract class Shader {

private int vertexShaderID, fragmentShaderID, programID;
private String vertexFile, fragmentFile;

public Shader (String vertexFile, String fragmentFile) {
this.vertexFile = vertexFile;
this.fragmentFile = fragmentFile;
}

public void create () {
programID = GL20.glCreateProgram();

vertexShaderID = GL20.glCreateShader(GL20.GL_VERTEX_SHADER);

GL20.glShaderSource(vertexShaderID, readFile(vertexFile));
GL20.glCompileShader(vertexShaderID);

if (GL20.glGetShaderi(vertexShaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) {
System.err.println("Error: Vertex Shader - " + GL20.glGetShaderInfoLog(vertexShaderID));
}

fragmentShaderID = GL20.glCreateShader(GL20.GL_FRAGMENT_SHADER);

GL20.glShaderSource(fragmentShaderID, readFile(fragmentFile));
GL20.glCompileShader(fragmentShaderID);

if (GL20.glGetShaderi(fragmentShaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) {
System.err.println("Error: Fragment Shader - " + GL20.glGetShaderInfoLog(fragmentShaderID));
}

GL20.glAttachShader(programID, vertexShaderID);
GL20.glAttachShader(programID, fragmentShaderID);

GL20.glLinkProgram(programID);

if (GL20.glGetProgrami(programID, GL20.GL_LINK_STATUS) == GL11.GL_FALSE) {
System.err.println("Error: Program Linking - " + GL20.glGetShaderInfoLog(programID));
}

GL20.glValidateProgram(programID);

if (GL20.glGetProgrami(programID, GL20.GL_VALIDATE_STATUS) == GL11.GL_FALSE) {
System.err.println("Error: Program Validation - " + GL20.glGetShaderInfoLog(programID));
}
}

public abstract void bindAllAttributes();

public void bindAttribute (int index, String location) {
GL20.glBindAttribLocation(programID, index, location);
}

public void bind () {
GL20.glUseProgram(programID);
}

public void destroy () {
GL20.glDetachShader(programID, vertexShaderID);
GL20.glDetachShader(programID, fragmentShaderID);

GL20.glDeleteShader(vertexShaderID);
GL20.glDeleteShader(fragmentShaderID);

GL20.glDeleteProgram(programID);
}

private String readFile (String path) {
BufferedReader reader;
StringBuilder builder = new StringBuilder();

try {

reader = new BufferedReader(new FileReader(path));

String line = reader.readLine();

while (line != null) {

builder.append(line + 'n');
line = reader.readLine();
}

} catch (IOException e) {
System.err.println("Error: Exception while reading from file");
}

return builder.toString();
}
}

public class BasicShader extends Shader {

private static final String VERTEX_FILE = ".\src\shaders\basicVertexShader.vs";
private static final String FRAGMENT_FILE = ".\src\shaders\basicFragmentShader.fs";

public BasicShader() {
super(VERTEX_FILE, FRAGMENT_FILE);
}

@Override
public void bindAllAttributes () {
super.bindAttribute(0, "position");
super.bindAttribute(1, "textCoords");
}
}


I've tested the shader files (basicVertexShader.vs and basicFragmentShader.fs) and they work as intended.



I have tried the following:
Seeing if the .dll file was deleted.
Re-installing Java (jdk and jre included)
Re-installing Eclipse
Updating Graohics Driver to the by Intel suggested verion



I'm using Windows 10 and a Lenovo Thinkpad.



If any additional information is needed, please ask bellow.



Update:



Stack: [0x0000000002b10000,0x0000000002c10000], sp=0x0000000002c0bf40, free space=1007k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)



C [ig7icd64.dll+0x933b0]



C [ig7icd64.dll+0x17b4b2]



C [ig7icd64.dll+0x215514]



C [ig7icd64.dll+0x6d1ee]



C [ig7icd64.dll+0x243745]



C [ig7icd64.dll+0x92555]



C [ig7icd64.dll+0x2a3af8]



C [ig7icd64.dll+0x2a3e09]



C [ig7icd64.dll+0x2a57ba]



C 0x0000000002d88c67



Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)



j org.lwjgl.opengl.GL11C.nglDrawElements(IIIJ)V+0



j org.lwjgl.opengl.GL11C.glDrawElements(IIIJ)V+4



j org.lwjgl.opengl.GL11.glDrawElements(IIIJ)V+4



j render.Renderer.renderTexturedModel(Lrender/TexturedModel;)V+43 (Renderer is a class which just executes the glDrawElements() function; nothing special)



j main.Main.main([Ljava/lang/String;)V+191



v ~StubRoutines::call_stub



Update:
I solved the issue. It lies in Model.storeData(). I don't use attributeNumber or coordSize. CLOSED







java crash lwjgl






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 31 at 20:48







J. Lengel

















asked Jan 1 at 19:38









J. LengelJ. Lengel

10810




10810













  • Please provide a MCVE or at the very least tell where it crashes exactly (the hs_err_pid.log file mentioned in the crash report printed to stdout contains a stacktrace) and show the code of that section.

    – httpdigest
    Jan 1 at 19:52






  • 1





    A crash in a draw call is in 99.9999% caused by an enabled vertex attribute which hasn't been properly initialized via glVertexAttribPointer() or an indices pointer given to glDrawElements() which is null. This can happen when you use the long-overload of that method while not having a GL_ELEMENT_ARRAY_BUFFER bound.

    – httpdigest
    Jan 1 at 20:03











  • Situations like these will be caught and reported by: github.com/LWJGLX/debug

    – httpdigest
    Jan 1 at 20:04






  • 1





    Thanks @httpdigest ! I just checked my bindings and the parameters and I messed some obvious numbers. Thanks for your help!

    – J. Lengel
    Jan 1 at 20:41



















  • Please provide a MCVE or at the very least tell where it crashes exactly (the hs_err_pid.log file mentioned in the crash report printed to stdout contains a stacktrace) and show the code of that section.

    – httpdigest
    Jan 1 at 19:52






  • 1





    A crash in a draw call is in 99.9999% caused by an enabled vertex attribute which hasn't been properly initialized via glVertexAttribPointer() or an indices pointer given to glDrawElements() which is null. This can happen when you use the long-overload of that method while not having a GL_ELEMENT_ARRAY_BUFFER bound.

    – httpdigest
    Jan 1 at 20:03











  • Situations like these will be caught and reported by: github.com/LWJGLX/debug

    – httpdigest
    Jan 1 at 20:04






  • 1





    Thanks @httpdigest ! I just checked my bindings and the parameters and I messed some obvious numbers. Thanks for your help!

    – J. Lengel
    Jan 1 at 20:41

















Please provide a MCVE or at the very least tell where it crashes exactly (the hs_err_pid.log file mentioned in the crash report printed to stdout contains a stacktrace) and show the code of that section.

– httpdigest
Jan 1 at 19:52





Please provide a MCVE or at the very least tell where it crashes exactly (the hs_err_pid.log file mentioned in the crash report printed to stdout contains a stacktrace) and show the code of that section.

– httpdigest
Jan 1 at 19:52




1




1





A crash in a draw call is in 99.9999% caused by an enabled vertex attribute which hasn't been properly initialized via glVertexAttribPointer() or an indices pointer given to glDrawElements() which is null. This can happen when you use the long-overload of that method while not having a GL_ELEMENT_ARRAY_BUFFER bound.

– httpdigest
Jan 1 at 20:03





A crash in a draw call is in 99.9999% caused by an enabled vertex attribute which hasn't been properly initialized via glVertexAttribPointer() or an indices pointer given to glDrawElements() which is null. This can happen when you use the long-overload of that method while not having a GL_ELEMENT_ARRAY_BUFFER bound.

– httpdigest
Jan 1 at 20:03













Situations like these will be caught and reported by: github.com/LWJGLX/debug

– httpdigest
Jan 1 at 20:04





Situations like these will be caught and reported by: github.com/LWJGLX/debug

– httpdigest
Jan 1 at 20:04




1




1





Thanks @httpdigest ! I just checked my bindings and the parameters and I messed some obvious numbers. Thanks for your help!

– J. Lengel
Jan 1 at 20:41





Thanks @httpdigest ! I just checked my bindings and the parameters and I messed some obvious numbers. Thanks for your help!

– J. Lengel
Jan 1 at 20:41












1 Answer
1






active

oldest

votes


















0














[CLOSED] As you can see in my last edit, my error lies in the Model class. I don't actually use the index and size parameters in the storeData() function which means I'm trying to store the arrays in the same list so the program crashed. Thank you to everyone.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53998379%2fjava-fatal-runtime-error-while-loading-texture-in-lwjgl%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    [CLOSED] As you can see in my last edit, my error lies in the Model class. I don't actually use the index and size parameters in the storeData() function which means I'm trying to store the arrays in the same list so the program crashed. Thank you to everyone.






    share|improve this answer




























      0














      [CLOSED] As you can see in my last edit, my error lies in the Model class. I don't actually use the index and size parameters in the storeData() function which means I'm trying to store the arrays in the same list so the program crashed. Thank you to everyone.






      share|improve this answer


























        0












        0








        0







        [CLOSED] As you can see in my last edit, my error lies in the Model class. I don't actually use the index and size parameters in the storeData() function which means I'm trying to store the arrays in the same list so the program crashed. Thank you to everyone.






        share|improve this answer













        [CLOSED] As you can see in my last edit, my error lies in the Model class. I don't actually use the index and size parameters in the storeData() function which means I'm trying to store the arrays in the same list so the program crashed. Thank you to everyone.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 31 at 20:52









        J. LengelJ. Lengel

        10810




        10810
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53998379%2fjava-fatal-runtime-error-while-loading-texture-in-lwjgl%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas