1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Gl.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit);
Gl.LightModel(LightModelParameter.LightModelAmbient, ambient_model);
Gl.Material(MaterialFace.FrontAndBack, MaterialParameter.AmbientAndDiffuse, mat_diffusion);
Gl.Material(MaterialFace.FrontAndBack, MaterialParameter.Specular, mat_specular);
Gl.Light(LightName.Light0, LightParameter.Diffuse, diffusion);
Gl.Light(LightName.Light0, LightParameter.Position, position);
Control senderControl = (Control)sender;
// Setup model-view matrix
// Model-view matrix selector
Gl.MatrixMode(MatrixMode.Modelview);
// Load (reset) to identity
Gl.LoadIdentity();
Gl.Rotate(_Angle++, 0.0f, 1.0f, .0f);
Gl.Scale(0.5, 0.5, 0.5);
Gl.Begin(PrimitiveType.Triangles);
int index = 0;
for (int i = 0; i < theObject.size; ++i)
{
index = (i * 8);
// Feed triangle data: color and position
// Note: vertex attributes (color, texture coordinates, ...) are specified before position information
// Note: vertex data is passed using method calls (performance killer!)
// Gl.Color3(c1[i % 3]);
Gl.Normal3(theObject.position_texture_normal[index + 5], theObject.position_texture_normal[index + 6], theObject.position_texture_normal[index + 7]);
Gl.TexCoord2(theObject.position_texture_normal[index+3], theObject.position_texture_normal[index+4]);
Gl.Vertex3((float)theObject.position_texture_normal[index], theObject.position_texture_normal[index + 1], theObject.position_texture_normal[index + 2]);
}
// Triangles ends
Gl.End(); |
Partager