小编joe*_*Ola的帖子

使用 OpenGL 用不同的图像对立方体进行纹理化

我目前正在进行一个学校项目,我需要对一个仅显示 3 个面的非旋转立方体进行纹理处理。我尝试过自己做,但我只在所有 3 个面上得到一张图像。我不知道是我的方法错误还是我加载剩余两张图像的方式错误。我非常感谢任何人的帮助。

这就是我加载纹理的方式

GLuint VAO, VBO;
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);

glBindVertexArray(VAO);

glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

// position attribute
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);
// texture coord attribute
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3 * sizeof(float)));
glEnableVertexAttribArray(1);

// this is for texture coords

//Load Image
//int width, height; // width1, height1;
//unsigned char* image = SOIL_load_image("res/images/image1.jpg", &width, &height, 0, SOIL_LOAD_RGBA);

GLuint texture1, texture2, texture3;
// texture 1
// ---------
glGenTextures(1, …
Run Code Online (Sandbox Code Playgroud)

opengl textures glew glfw visual-studio-2019

2
推荐指数
1
解决办法
2104
查看次数

标签 统计

glew ×1

glfw ×1

opengl ×1

textures ×1

visual-studio-2019 ×1