资 源 简 介
3D 培训
我写的 3D 游戏培训编程
glUseProgram(m_programSkyBox.Program);
glGenBuffers(1, &skyBoxVertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, skyBoxVertexBuffer);
float vertices[24] = {
-1.0, -1.0, 1.0,
1.0, -1.0, 1.0,
-1.0, 1.0, 1.0,
1.0, 1.0, 1.0,
-1.0, -1.0, -1.0,
1.0, -1.0, -1.0,
-1.0, 1.0, -1.0,
1.0, 1.0, -1.0,
};
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glGenBuffers(1, &skyBoxIndexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, skyBoxIndexBuffer);
GLubyte indices[14] = {0, 1, 2, 3, 7, 1, 5, 4, 7, 6, 2, 4, 0, 1};
绘图 skybox:
glClearColor(0.5f, 0.5f, 0.5f, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgram(m_programSkyBox.Program);
glDisable(GL_DEPTH_TEST); // skybox should be drawn behind anything else
glBindTexture(GL_TEXTURE_CUBE_MAP, m_textures.Cubemap);
glBin