我一直在玩一个我一直在制作游戏的问题。我正在使用即时渲染模式在屏幕上显示内容但是当我开始向屏幕添加越来越多的对象时,我的fps开始迅速下降。我想使用VBO来渲染游戏中的所有内容,所以我试图为每个顶点绘制一个具有不同颜色的四边形,就像许多教程和示例解释了如何做。问题是,当我尝试使用gldrawarrays()并启用颜色缓冲区(使用glcolorpointer和glvertexpointer)渲染vbo时,它会给出错误:
A fatal error has been detected by the Java Runtime Environment:
EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000504b6ee0, pid=22964, tid=23500
JRE version: Java(TM) SE Runtime Environment (7.0_45-b18) (build 1.7.0_45-b18)
Java VM: Java HotSpot(TM) 64-Bit Server VM (24.45-b08 mixed mode windows-amd64 compressed oops)
Problematic frame:
C [atio6axx.dll+0x226ee0]
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\Tyler\Dropbox\Programming\Harry Hank\hs_err_pid22964.log
当我不使用glcolorpointer并且只使用glcolor3f设置单一颜色时,它会使用我指定的颜色渲染四边形。失败点是在gldrawarrays,并与颜色缓冲区有关,导致它崩溃。它看起来没有任何理由让它失败。但是有什么我想念的东西或者我做错了什么吗?这是我用于vbo的代码:
初始化:
numOfVertices = 4;
vertexSize = 2;
colorSize = 4;
vertexData = BufferUtils.createFloatBuffer(numOfVertices * vertexSize);
vertexData.put(new float[]{10f, 10f,
100f, 10f,
100f, 100f,
10f, 100f});
vertexData.flip();
colorData = BufferUtils.createFloatBuffer(numOfVertices * colorSize);
colorData.put(new float[]{1f, 0f, 0f,
0f, 1f, 0f,
0f, 0f, 1f,
0f, 1f, 1f});
colorData.flip();
vertHandle = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertHandle);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertexData, GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
colorHandle = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, colorHandle);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, colorData, GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
渲染:
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertHandle);
GL11.glVertexPointer(vertexSize, GL11.GL_FLOAT, 0, 0l);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, colorHandle);
GL11.glVertexPointer(colorSize, GL11.GL_FLOAT, 0, 0l);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
//GL11.glColor3f(1.0f, 0.0f, 0.0f); //i used this when i disable binding color buffer and color pointer
GL11.glDrawArrays(GL11.GL_QUADS, 0, numOfVertices);
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
我已经搜索了几天的解决方案但还没找到。我的显卡驱动程序是最新的(我在一个月前安装了一个新显卡,如果这有任何区别),我也安装了最新版本的java。