小编QDi*_*inh的帖子

在 OpenGL 中使用纹理图集作为纹理数组

我现在正在构建一个体素游戏。一开始,我使用一个存储所有体素纹理的纹理图集,它工作正常。之后,我决定在我的游戏中使用 Greedy Meshing,因此纹理图集不再有用。我读了一些文章,说应该改用纹理数组。然后我尝试阅读并使用纹理数组技术进行纹理化。然而,我得到的结果在我的游戏中全黑。那么我错过了什么?

这是我的纹理图集 (600 x 600)

我的纹理图集

这是我的 Texture2DArray,我使用这个类来读取和保存一个纹理数组

Texture2DArray::Texture2DArray() : Internal_Format(GL_RGBA8), Image_Format(GL_RGBA), Wrap_S(GL_REPEAT), Wrap_T(GL_REPEAT), Wrap_R(GL_REPEAT), Filter_Min(GL_NEAREST), Filter_Max(GL_NEAREST), Width(0), Height(0)
{
   glGenTextures(1, &this->ID);
}

void Texture2DArray::Generate(GLuint width, GLuint height, unsigned char* data)
{
   this->Width = width;
   this->Height = height;

   glBindTexture(GL_TEXTURE_2D_ARRAY, this->ID);

   // I cannot decide what the texture array layer (depth) should be (I put here is 1 for layer number)
   //Can anyone explain to me how to decide the texture layer here? 
   glTexImage3D(GL_TEXTURE_2D_ARRAY, 1, this->Internal_Format, this->Width, this->Height, 0, …
Run Code Online (Sandbox Code Playgroud)

c++ opengl texture-mapping voxel opengl-3

4
推荐指数
1
解决办法
2795
查看次数

标签 统计

c++ ×1

opengl ×1

opengl-3 ×1

texture-mapping ×1

voxel ×1