使用一个立方体纹理,由六张图片拼成一个天空盒,然后让它做沿Y轴逆时针转动。
#include "TEST_Skybox.h"
#include <stdio.h>
using namespace std;
static GLint skybox_rotate_loc = 0;
TEST_FUNC_INIT(Skybox)
{
GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
const GLfloat cube_vertices[] =
{
-1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, -1.0f, -1.0f,
1.0f, -1.0f, 1.0f,
1.0f, 1.0f, -1.0f,
1.0f, 1.0f, 1.0f
};
const GLushort cube_indices[] =
{
0,