我正在使用分块系统处理块世界,我遇到了VBO的错误。我的立方体世界似乎生成随机顶点,但只在Radeon HD 6670上。我现在想知道这是我的代码,LWJGL,OpenGL,6670,还是它的驱动程序漏掉了,如果它是我能解决的问题。我有一些截图,但没有一个正常工作。我在一台带有NVidia卡的笔记本电脑上进行了测试,它运行得非常好,我正在尝试在Intel HD 3000上进行测试。有谁能告诉我,我可能做错了什么?它应该生成一个覆盖16 * 16 * 16立方体网格的面积。
编辑:它似乎也不适用于HD 3000,但在Nvidia卡上一切都很好。以下是截图:http://imgur.com/a/Q30Y3
这是创建VBO并呈现它的代码:
private void updateChunkVertexArray()
{
thisVertices.clear();
GL15.glDeleteBuffers(thisVBOID);
GL15.glDeleteBuffers(thisTexID);
FloatBuffer bufferedTex = BufferUtils
.createFloatBuffer(buffer.size() * 8 * 6);
thisTexID = VBOHandler.createVBO();
thisVBOID = VBOHandler.createVBO();
for (int i = 0; i < buffer.size(); i++)
{
Vector4f thisVec = buffer.get(i);
float x = (thisVec.getX() + offsetX);
float y = (thisVec.getY() + offsetY);
float z = (thisVec.getZ() + offsetZ);
float posx = 1.0f * size + x * 0.25f;
float posy = 1.0f * size + y * 0.25f;
float posz = 1.0f * size + z * 0.25f;
float negx = -1.0f * size + x * 0.25f;
float negy = -1.0f * size + y * 0.25f;
float negz = -1.0f * size + z * 0.25f;
if (world.getBlock(x, y, z + 1f) == 0)
{
bufferedTex.put(texCoords);
float[ ] frontFace =
{
// Front Face
negx, negy, posz, // Bottom Left
posx, negy, posz, // Bottom Right
posx, posy, posz, // Top Right Of
negx, posy, posz
};
for (int t = 0; t < frontFace.length; t++)
{
thisVertices.add(Float.valueOf(frontFace[t]));
}
//bufferedVertices.put(frontFace);
}
if (world.getBlock(x, y, z - 1f) == 0)
{
bufferedTex.put(texCoords);
float[ ] backFace =
{
// Back Face
negx, negy, negz, // Bottom Left
negx, posy, negz, // Bottom Right
posx, posy, negz, // Top Right Of
posx, negy, negz
};
for (int t = 0; t < backFace.length; t++)
{
thisVertices.add(Float.valueOf(backFace[t]));
}
//bufferedVertices.put(backFace);
}
if (world.getBlock(x, y + 1f, z) == 0)
{
bufferedTex.put(texCoords);
float[ ] topFace =
{
// Top Face
negx, posy, negz, // Bottom Left
negx, posy, posz, // Bottom Right
posx, posy, posz, // Top Right Of
posx, posy, negz
};
for (int t = 0; t < topFace.length; t++)
{
thisVertices.add(Float.valueOf(topFace[t]));
}
//bufferedVertices.put(topFace);
}
if (world.getBlock(x, y - 1f, z) == 0)
{
bufferedTex.put(texCoords);
float[ ] bottomFace =
{
// Bottom Face
negx, negy, negz, // Bottom Left
posx, negy, negz, // Bottom Right
posx, negy, posz, // Top Right Of
negx, negy, posz
};
for (int t = 0; t < bottomFace.length; t++)
{
thisVertices.add(Float.valueOf(bottomFace[t]));
}
//bufferedVertices.put(bottomFace);
}
if (world.getBlock(x + 1f, y, z) == 0)
{
bufferedTex.put(texCoords);
float[ ] rightFace =
{
// right Face
posx, negy, negz, // Bottom Left
posx, posy, negz, // Bottom Right
posx, posy, posz, // Top Right Of
posx, negy, posz
};
for (int t = 0; t < rightFace.length; t++)
{
thisVertices.add(Float.valueOf(rightFace[t]));
}
//bufferedVertices.put(rightFace);
}
if (world.getBlock(x - 1f, y, z) == 0)
{
bufferedTex.put(texCoords);
float[ ] leftFace =
{
// left Face
negx, negy, negz, // Bottom Left
negx, negy, posz, // Bottom Right
negx, posy, posz, // Top Right Of
negx, posy, negz
};
for (int t = 0; t < leftFace.length; t++)
{
thisVertices.add(Float.valueOf(leftFace[t]));
}
//bufferedVertices.put(leftFace);
}
}
float[ ] tempVertices = new float[thisVertices.size()];
for (int i = 0; i < thisVertices.size(); i++)
{
Float f = thisVertices.get(i);
tempVertices[i] = Float.valueOf(f);
}
FloatBuffer bufferedVertices = BufferUtils
.createFloatBuffer(thisVertices.size());
bufferedVertices.put(tempVertices);
bufferedVertices.flip();
bufferedTex.flip();
VBOHandler.bufferData(thisVBOID, bufferedVertices);
VBOHandler.bufferData(thisTexID, bufferedTex);
//And now the rendering code...
public void renderChunk()
{
//GL11.glCallList(chunkDisplayList);
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, thisVBOID);
GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0);
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, thisTexID);
GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);
GL11.glDrawArrays(GL11.GL_QUADS, 0, thisVertices.size());
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); // deactivate vertex array
GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
// bind with 0 for normal pointers
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
}
答案 0 :(得分:0)
您的显卡未正确放入。这种情况发生在我身上很多次。我拿出我的卡并把它放回去然后一切正常。 :)