private void openGLControl1_OpenGLDraw( object sender, PaintEventArgs e)
{
// 将纹理绑定在要绘制的图像表面
SharpGL.OpenGL gl = this.openGLControl1.OpenGL;
gl.Clear(OpenGL.COLOR_BUFFER_BIT | OpenGL.DEPTH_BUFFER_BIT);
//坐标重置,定位到系统原点
gl.LoadIdentity();
//设置光源位置坐标
fLightPosition = new float[4] { lx, ly, lz, 1f };
gl.Light(OpenGL.LIGHT0, OpenGL.POSITION, fLightPosition); //光源位置
//坐标系移动至(0,0,-6);
gl.Translate(0f, 0f, -6.0f);
//以(0,0,-6)为原点的三维坐标系进行相对位置移动
gl.Translate(x, y, z);
//绑定纹理
texture1.Bind(gl);
//开始六面体
gl.Begin(OpenGL.QUADS);
// Front Face
gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad
gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad
gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, 1.0f, 1.0f); // Top Right Of The Texture and Quad
gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad
gl.End();
texture2.Bind(gl);
gl.Begin(OpenGL.QUADS);
// Back Face
gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and Quad
gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Right Of The Texture and Quad
gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, 1.0f, -1.0f); // Top Left Of The Texture and Quad
gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and Quad
gl.End();
texture3.Bind(gl);
gl.Begin(OpenGL.QUADS);
// Top Face
gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Left Of The Texture and Quad
gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Texture and Quad
gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, 1.0f, 1.0f); // Bottom Right Of The Texture and Quad
gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, 1.0f, -1.0f); // Top Right Of The Texture and Quad
gl.End();
texture4.Bind(gl);
gl.Begin(OpenGL.QUADS);
// Bottom Face
gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, -1.0f, -1.0f); // Top Right Of The Texture and Quad
gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, -1.0f, -1.0f); // Top Left Of The Texture and Quad
gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad
gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad
gl.End();
texture5.Bind(gl);
gl.Begin(OpenGL.QUADS);
// Right face
gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and Quad
gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, 1.0f, -1.0f); // Top Right Of The Texture and Quad
gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad
gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad
gl.End();
texture6.Bind(gl);
gl.Begin(OpenGL.QUADS);
// Left Face
gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and Quad
gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad
gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, 1.0f); // Top Right Of The Texture and Quad
gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Left Of The Texture and Quad
gl.End();
gl.Flush();
}