Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java LWJGL OpenGL纹理图集_Java_Opengl_Textures_Voxel_Atlas - Fatal编程技术网

Java LWJGL OpenGL纹理图集

Java LWJGL OpenGL纹理图集,java,opengl,textures,voxel,atlas,Java,Opengl,Textures,Voxel,Atlas,我一直在尝试用LWJGL制作一个基于体素的游戏,但我遇到了一个问题 我的体素具有纹理,这些纹理正在流入纹理图集上的相邻纹理 我不想使用纹理数组或在纹理周围创建边框 这是我的密码 public class SpriteSheet { private int terrainID; public SpriteSheet(float blockResolution) { try { PNGDecoder decoder = new PNGDecoder(new FileInputStream("res

我一直在尝试用LWJGL制作一个基于体素的游戏,但我遇到了一个问题

我的体素具有纹理,这些纹理正在流入纹理图集上的相邻纹理

我不想使用纹理数组或在纹理周围创建边框

这是我的密码

public class SpriteSheet
{
private int terrainID;

public SpriteSheet(float blockResolution)
{
try
{
PNGDecoder decoder = new PNGDecoder(new FileInputStream("res/Terrain.png"));

int width = decoder.getWidth();
int height = decoder.getHeight();

int bytesPerPixel = 4;

ByteBuffer buffer = BufferUtils.createByteBuffer(bytesPerPixel * width * height);

decoder.decode(buffer, width * bytesPerPixel, PNGDecoder.RGBA);

buffer.flip();

terrainID = glGenTextures();

glBindTexture(GL_TEXTURE_2D, terrainID);

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

glBindTexture(GL_TEXTURE_2D, terrainID);

}
catch(IOException e)
{
e.printStackTrace();
}
}

public void dispose()
{
glDeleteTextures(terrainID);
}
}
我做错了什么,我用GL_夹钳_到_边缘,我以为可以修复它

我没有使用mipmaps


类似问题的URL和图片:

你能给我看一张有什么问题的图片吗?我不能,我的声誉不够高。请谷歌纹理图谱出血,这应该有帮助。非常感谢。PS游戏是3D的,所以半像素校正没有帮助。与其添加图片,不如添加一个url到图片,这样我们就可以看到它。然后有一个更高声誉的人可以把链接变成你的图片,可能也会这样做。添加图片的类似问题的URL。