gpt4 book ai didi

java - LWJGL VBO 在 Radeon HD 6670 上生成看似随机的顶点?

转载 作者:行者123 更新时间:2023-11-29 09:01:46 24 4
gpt4 key购买 nike

我在一个带有分块系统的 block 世界上工作,我遇到了一个 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);
}

最佳答案

您的显卡未正确安装。这发生在我身上很多次。我把我的卡拿出来放回去,然后一切正常。 :)

关于java - LWJGL VBO 在 Radeon HD 6670 上生成看似随机的顶点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17007046/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com