本文整理匯總了C#中SharpGL.OpenGL.Material方法的典型用法代碼示例。如果您正苦於以下問題:C# OpenGL.Material方法的具體用法?C# OpenGL.Material怎麽用?C# OpenGL.Material使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SharpGL.OpenGL
的用法示例。
在下文中一共展示了OpenGL.Material方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Draw
public void Draw(OpenGL gl)
{
gl.BindTexture(OpenGL.GL_TEXTURE_2D, TextureID);
int[] amb_diff = { Colour.A, Colour.B, Colour.G, Colour.A };
gl.Material(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_AMBIENT_AND_DIFFUSE, amb_diff);
gl.Begin(OpenGL.GL_TRIANGLES);
for (int i = 0; i < 3; i++)
{
Position point = Verts[i].Point;
UV uv = Verts[i].UV;
if (uv != null)
gl.TexCoord(uv.U, uv.V);
gl.Vertex(point.X, point.Y, point.Z);
}
gl.End();
gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0);
}
示例2: ApplyMaterial
private void ApplyMaterial(Material mat, ref OpenGL gl)
{
if (mat.GetMaterialTextureCount(TextureType.Diffuse) > 0)
{
TextureSlot tex = new TextureSlot();
mat.GetMaterialTexture(TextureType.Diffuse, 0, out tex);
LoadModelAsset(tex.FilePath, ref gl);
}
Color4 color = new Color4(.8f, .8f, .8f, 1.0f);
if (mat.HasColorDiffuse)
{
// color = FromColor(mat.ColorDiffuse);
}
var colorf = new float[4];
color4_to_float4(color, colorf);
gl.Material(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_DIFFUSE, colorf);
color = new Color4(0, 0, 0, 1.0f);
if (mat.HasColorSpecular)
{
color = FromColor(mat.ColorSpecular);
}
gl.Material(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_SPECULAR, colorf);
color = new Color4(.2f, .2f, .2f, 1.0f);
if (mat.HasColorAmbient)
{
color = FromColor(mat.ColorAmbient);
}
gl.Material(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_AMBIENT, colorf);
color = new Color4(0, 0, 0, 1.0f);
if (mat.HasColorEmissive)
{
color = FromColor(mat.ColorEmissive);
}
gl.Material(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_EMISSION, colorf);
float shininess = 1;
float strength = 1;
if (mat.HasShininess)
{
shininess = mat.Shininess;
}
if (mat.HasShininessStrength)
{
strength = mat.ShininessStrength;
}
gl.Material(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_SHININESS, shininess * strength);
}
示例3: DrawDataTriangles
private void DrawDataTriangles(OpenGL gl)
{
// draw samples
// Draw
gl.Begin(OpenGL.GL_TRIANGLES);
int x, z;
float fCurrent;
uint nType = OpenGL.GL_AMBIENT_AND_DIFFUSE;
for (x = 0; x < m_nSweepSteps - 1; x++)
{
for (z = 0; z < m_nTotalSweeps - 1; z++)
{
// Current value, I need one more, to create triangles
fCurrent = m_arrSweepData[x, z] / (float)m_nTotalSweeps;
//gl.Color(ColorMap(fCurrent));
gl.Material(OpenGL.GL_FRONT, nType, ColorMap(fCurrent));
gl.Vertex(-(float)x / (float)m_nSweepSteps, fCurrent, (float)z / (float)m_nTotalSweeps);
fCurrent = m_arrSweepData[x, z + 1] / (float)m_nTotalSweeps;
gl.Material(OpenGL.GL_FRONT, nType, ColorMap(fCurrent));
gl.Vertex(-(float)x / (float)m_nSweepSteps, fCurrent, (float)(z + 1) / (float)m_nTotalSweeps);
fCurrent = m_arrSweepData[x + 1, z] / (float)m_nTotalSweeps;
gl.Material(OpenGL.GL_FRONT, nType, ColorMap(fCurrent));
gl.Vertex(-(float)(x + 1) / (float)m_nSweepSteps, fCurrent, (float)z / (float)m_nTotalSweeps);
// done 1st triangle
fCurrent = m_arrSweepData[x, z + 1] / (float)m_nTotalSweeps;
gl.Material(OpenGL.GL_FRONT, nType, ColorMap(fCurrent));
gl.Vertex(-(float)x / (float)m_nSweepSteps, fCurrent, (float)(z + 1) / (float)m_nTotalSweeps);
fCurrent = m_arrSweepData[x + 1, z] / (float)m_nTotalSweeps;
gl.Material(OpenGL.GL_FRONT, nType, ColorMap(fCurrent));
gl.Vertex(-(float)(x + 1) / (float)m_nSweepSteps, fCurrent, (float)z / (float)m_nTotalSweeps);
fCurrent = m_arrSweepData[x + 1, z + 1] / (float)m_nTotalSweeps;
gl.Material(OpenGL.GL_FRONT, nType, ColorMap(fCurrent));
gl.Vertex(-(float)(x + 1) / (float)m_nSweepSteps, fCurrent, (float)(z + 1) / (float)m_nTotalSweeps);
}
}
gl.End();
}