问题
Im creating a 2D SideScroller game for my thesis. For rendering the environment i want to use Vertex Buffer Objects. At home, everything works fine, but in University i get a similar error message:
A fatal error has been detected by the Java Runtime Environment:
EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x651e3435, pid=964, tid=2988
JRE version: Java(TM) SE Runtime Environment (7.0_55-b13) (build 1.7.0_55-b13)
Java VM: Java HotSpot(TM) Client VM (24.55-b03 mixed mode, sharing windows-x86 )
Problematic frame:
C [nvoglv32.DLL+0xaf3435]
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:
U:\Desktop\newWS\Bachelor\Bachelor\hs_err_pid964.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.
This error appears, when the first Level is complete, and the next Level is loaded here i call
private void init() {
VBOLandScapeHandler = glGenBuffers();
VBOTextureHandler = glGenBuffers();
// VBOTextureHandler = glGenTextures()
createBuffer();
}
private void createBuffer() {
landScapeArray = BufferUtils
.createFloatBuffer(level.getVerticeCount() * 2);
textureArray = BufferUtils
.createFloatBuffer(level.getVerticeCount() * 2);
for (List<LandscapePart> landscapePart : level.getParts()) {
for (LandscapePart cur : landscapePart) {
if (cur instanceof Seesaw || cur.belongsToSeesaw()) {
// landScapeArray.put(new float[] { ((Seesaw)
// cur).getP5().getX(), ((Seesaw) cur).getP5().getY() });
continue;
}
landScapeArray.put(new float[] { cur.getP1().getX(),
cur.getP1().getY() });
landScapeArray.put(new float[] { cur.getP2().getX(),
cur.getP2().getY() });
landScapeArray.put(new float[] { cur.getP3().getX(),
cur.getP3().getY() });
landScapeArray.put(new float[] { cur.getP4().getX(),
cur.getP4().getY() });
textureArray.put(new float[] { 0, 0 });
textureArray.put(new float[] { 1, 0 });
textureArray.put(new float[] { 1, 1 });
textureArray.put(new float[] { 0, 1 });
}
}
landScapeArray.flip();
textureArray.flip();
}
public void draw() {
earth.bind();
// bind landScape data
glBindBuffer(GL_ARRAY_BUFFER, VBOLandScapeHandler);
glBufferData(GL_ARRAY_BUFFER, landScapeArray, GL_STATIC_DRAW);
glVertexPointer(2, GL_FLOAT, 0, 0L);
glBindBuffer(GL_ARRAY_BUFFER, VBOTextureHandler);
glBufferData(GL_ARRAY_BUFFER, textureArray, GL_STATIC_DRAW);
glTexCoordPointer(2, GL_FLOAT, 0, 0L);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glDrawArrays(GL_QUADS, 0, landScapeArray.limit());
// // Unbind the VBO
glBindBuffer(GL_ARRAY_BUFFER, 0);
// // Disable Vertex Arrays (VBOs)
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
At home im using a Geforce gtx 750 ti twin frozr, here in university a Quadro 2000.
Nvidia Driver up-to-date, using immediate mode works fine, but thats no good solution =)
Maybe somehow can get more information in the content of the error report file:
http://www.share-online.biz/dl/3BJUHM7NFGB
Are there any mistakes refilling the VBO?
回答1:
Your problem is most likely here:
glDrawArrays(GL_QUADS, 0, landScapeArray.limit());
I believe landScapeArray.limit()
is the number of float values in your buffer. The 3rd argument of glDrawArrays()
is the number of vertices to be drawn. Since you have 2 floats per vertex, you need:
glDrawArrays(GL_QUADS, 0, landScapeArray.limit() / 2);
来源:https://stackoverflow.com/questions/24367456/lwjgl-rendering-with-vbo-on-different-systems