I am following this tutorial here.
Just when I start running my program, I encountered a crash. It gives me a crash log that I can’t seem to comprehend. Here’s the crash log:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000005ff7c650, pid=6840, tid=4324
#
# JRE version: Java(TM) SE Runtime Environment (7.0_40-b43) (build 1.7.0_40-b43)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.0-b56 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [nvoglv64.DLL+0x98c650]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\Student\Documents\Workspace\LWJGL\hs_err_pid6840.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Here’s my code:
//Something class.
package core;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.GL_ARRAY_BUFFER;
import static org.lwjgl.opengl.GL15.glBindBuffer;
import static org.lwjgl.util.glu.GLU.gluPerspective;
import game.Game;
import org.lwjgl.util.vector.Matrix4f;
public class Something {
Cube cube;
public Something() {
this.cube = new Cube();
glClearColor(0.4f, 0.8f, 0.95f, 1f);
}
public void render() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
gluPerspective(70f, (float) Game.HEIGHT / (float) Game.WIDTH, 1f, 10f);
glViewport(0, 0, Game.WIDTH, Game.HEIGHT);
glMatrixMode(GL_MATRIX_MODE);
glLoadIdentity();
glEnable(GL_DEPTH_TEST);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glPushMatrix();
glTranslatef(0f, 0f, -2f);
glRotatef(1f, 1f, 1f, 0f);
glBindBuffer(GL_ARRAY_BUFFER, cube.vboVertex);
glVertexPointer(3, GL_FLOAT, 0, 0L);
glBindBuffer(GL_ARRAY_BUFFER, cube.vboColor);
glVertexPointer(3, GL_FLOAT, 0, 0L);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 24);
glPopMatrix();
}
}
//-----------------------------------------------------------------------------------------------------
//Cube class.
package core;
import static org.lwjgl.opengl.GL15.*;
import java.nio.FloatBuffer;
import org.lwjgl.BufferUtils;
public class Cube {
private FloatBuffer vertexBuffer;
private FloatBuffer colorBuffer;
private float[] vertexData = new float[]
{
// Front face
-0.5f, +0.5f, +0.5f,
+0.5f, +0.5f, +0.5f,
-0.5f, -0.5f, +0.5f,
+0.5f, -0.5f, +0.5f,
// Right face
+0.5f, +0.5f, +0.5f,
+0.5f, +0.5f, -0.5f,
+0.5f, -0.5f, +0.5f,
+0.5f, -0.5f, -0.5f,
// Back face
+0.5f, +0.5f, -0.5f,
-0.5f, +0.5f, -0.5f,
+0.5f, -0.5f, -0.5f,
-0.5f, -0.5f, -0.5f,
// Left face
-0.5f, +0.5f, -0.5f,
-0.5f, +0.5f, +0.5f,
-0.5f, -0.5f, -0.5f,
-0.5f, -0.5f, +0.5f,
// Top face
-0.5f, +0.5f, +0.5f,
+0.5f, +0.5f, +0.5f,
-0.5f, +0.5f, -0.5f,
+0.5f, +0.5f, -0.5f,
// Bottom face
-0.5f, -0.5f, +0.5f,
+0.5f, -0.5f, +0.5f,
-0.5f, -0.5f, -0.5f,
+0.5f, -0.5f, -0.5f
};
private float[] colorData = new float[]
{
// Front face
1, 0, 0,
0, 1, 0,
0, 0, 1,
1, 0, 0,
// Right face
0, 1, 0,
0, 0, 1,
1, 0, 0,
0, 1, 0,
// Back face
0, 0, 1,
1, 0, 0,
0, 1, 0,
0, 0, 1,
// Left face
1, 0, 0,
0, 1, 0,
0, 0, 1,
1, 0, 0,
// Top face
0, 1, 0,
0, 0, 1,
1, 0, 0,
0, 1, 0,
// Bottom face
0, 0, 1,
1, 0, 0,
0, 1, 0,
0, 0, 1
};
public int vboVertex;
public int vboColor;
public Cube() {
vertexBuffer = BufferUtils.createFloatBuffer(vertexData.length).put(vertexData);
vertexBuffer.rewind();
colorBuffer = BufferUtils.createFloatBuffer(colorData.length).put(colorData);
colorBuffer.rewind();
vboVertex = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboVertex);
glBufferData(GL_ARRAY_BUFFER, vertexBuffer, vboVertex);
glBindBuffer(GL_ARRAY_BUFFER, 0);
vboColor = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboColor);
glBufferData(GL_ARRAY_BUFFER, colorBuffer, vboColor);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
}
Any ideas what I’m doing wrong? Need more info?