本文整理汇总了C#中SharpGL.OpenGL.ShadeModel方法的典型用法代码示例。如果您正苦于以下问题:C# OpenGL.ShadeModel方法的具体用法?C# OpenGL.ShadeModel怎么用?C# OpenGL.ShadeModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpGL.OpenGL
的用法示例。
在下文中一共展示了OpenGL.ShadeModel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitShader
void IRenderable.Render(OpenGL gl, RenderMode renderMode)
{
if (positionBuffer == null || colorBuffer == null) { return; }
if (this.shaderProgram == null)
{
this.shaderProgram = InitShader(gl, renderMode);
}
if (this.vertexArrayObject == null)
{
CreateVertexArrayObject(gl, renderMode);
}
BeforeRendering(gl, renderMode);
if (this.RenderGridWireframe && this.vertexArrayObject != null)
{
//if (wireframeIndexBuffer != null)
if (positionBuffer != null && colorBuffer != null && indexBuffer != null)
{
shaderProgram.SetUniform1(gl, "renderingWireframe", 1.0f);// shader一律上白色。
gl.Disable(OpenGL.GL_LINE_STIPPLE);
gl.Disable(OpenGL.GL_POLYGON_STIPPLE);
gl.Enable(OpenGL.GL_LINE_SMOOTH);
gl.Enable(OpenGL.GL_POLYGON_SMOOTH);
gl.ShadeModel(SharpGL.Enumerations.ShadeModel.Smooth);
gl.Hint(SharpGL.Enumerations.HintTarget.LineSmooth, SharpGL.Enumerations.HintMode.Nicest);
gl.Hint(SharpGL.Enumerations.HintTarget.PolygonSmooth, SharpGL.Enumerations.HintMode.Nicest);
gl.PolygonMode(SharpGL.Enumerations.FaceMode.FrontAndBack, SharpGL.Enumerations.PolygonMode.Lines);
gl.Enable(OpenGL.GL_PRIMITIVE_RESTART);
gl.PrimitiveRestartIndex(uint.MaxValue);
gl.Enable(OpenGL.GL_BLEND);
gl.BlendFunc(SharpGL.Enumerations.BlendingSourceFactor.SourceAlpha, SharpGL.Enumerations.BlendingDestinationFactor.OneMinusSourceAlpha);
gl.BindVertexArray(this.vertexArrayObject[0]);
gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, indexBuffer[0]);
gl.DrawElements(OpenGL.GL_QUAD_STRIP, this.indexBufferLength, OpenGL.GL_UNSIGNED_INT, IntPtr.Zero);
gl.BindVertexArray(0);
gl.Disable(OpenGL.GL_BLEND);
gl.Disable(OpenGL.GL_PRIMITIVE_RESTART);
gl.PolygonMode(SharpGL.Enumerations.FaceMode.FrontAndBack, SharpGL.Enumerations.PolygonMode.Filled);
gl.Disable(OpenGL.GL_POLYGON_SMOOTH);
}
}
if (this.RenderGrid && this.vertexArrayObject != null)
{
if (positionBuffer != null && colorBuffer != null && indexBuffer != null)
{
shaderProgram.SetUniform1(gl, "renderingWireframe", 0.0f);// shader根据uv buffer来上色。
gl.Enable(OpenGL.GL_PRIMITIVE_RESTART);
gl.PrimitiveRestartIndex(uint.MaxValue);
gl.Enable(OpenGL.GL_BLEND);
gl.BlendFunc(SharpGL.Enumerations.BlendingSourceFactor.SourceAlpha, SharpGL.Enumerations.BlendingDestinationFactor.OneMinusSourceAlpha);
gl.BindVertexArray(this.vertexArrayObject[0]);
gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, indexBuffer[0]);
gl.DrawElements(OpenGL.GL_QUAD_STRIP, this.indexBufferLength, OpenGL.GL_UNSIGNED_INT, IntPtr.Zero);
gl.BindVertexArray(0);
gl.Disable(OpenGL.GL_BLEND);
gl.Disable(OpenGL.GL_PRIMITIVE_RESTART);
}
}
AfterRendering(gl, renderMode);
}
示例2: InitEngine
public void InitEngine(OpenGL gl)
{
try
{
DebugTools.LogToConsole("Prepareing GL");
//setup open gl and activate modes
gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_S, OpenGL.GL_REPEAT);
gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_T, OpenGL.GL_REPEAT);
gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MAG_FILTER, OpenGL.GL_NEAREST);
gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MIN_FILTER, OpenGL.GL_NEAREST);
gl.Enable(OpenGL.GL_BLEND);
gl.Enable(OpenGL.GL_TEXTURE_2D);
gl.Enable(OpenGL.GL_DEPTH_TEST);
//fffgl.Enable(OpenGL.GL_LIGHTING);
gl.BlendFunc(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA);
gl.ShadeModel(OpenGL.GL_SMOOTH);
//Darw the first frame with a load test
Draw(gl);
DebugTools.LogToConsole("Loading Resources");
//Loading the resources and bind to gl
resourceManager = new ResourceManager();
DebugTools.LogToConsole("Applying Textures");
resourceManager.InitTextures(gl);
DebugTools.LogToConsole("Loading Level");
//Loading level
//_level = new MasterMindGame.MasterMind();
//_level.Build(this);
_level = new MasterMindGame.MasterMind();
_level.Build(this);
GameObjects.Sort(
delegate(GameObject p1, GameObject p2)
{
return p1.Z_Index.CompareTo(p2.Z_Index);
}
);
//Startup is complete
StartupComplete = true;
}
catch (Exception error)
{
DebugTools.LogError(error);
}
}
示例3: CreateBasicLighting
public void CreateBasicLighting(OpenGL _context, Vector4 _position)
{
//ThrowIfNull(_context);
_context.Enable(OpenGL.GL_DEPTH_TEST);
float[] global_ambient = new float[] { 0.5f, 0.5f, 0.5f, 1.0f };
float[] light0ambient = new float[] { 0.2f, 0.2f, 0.2f, 1.0f };
float[] light0diffuse = new float[] { 0.3f, 0.3f, 0.3f, 1.0f };
float[] light0specular = new float[] { 0.8f, 0.8f, 0.8f, 1.0f };
float[] lmodel_ambient = new float[] { 0.2f, 0.2f, 0.2f, 1.0f };
_context.LightModel(OpenGL.GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
_context.LightModel(OpenGL.GL_LIGHT_MODEL_AMBIENT, global_ambient);
_context.Light(OpenGL.GL_LIGHT0, OpenGL.GL_POSITION, _position.ToFloatArray());
_context.Light(OpenGL.GL_LIGHT0, OpenGL.GL_AMBIENT, light0ambient);
_context.Light(OpenGL.GL_LIGHT0, OpenGL.GL_DIFFUSE, light0diffuse);
_context.Light(OpenGL.GL_LIGHT0, OpenGL.GL_SPECULAR, light0specular);
_context.Enable(OpenGL.GL_LIGHTING);
_context.Enable(OpenGL.GL_LIGHT0);
_context.ShadeModel(OpenGL.GL_SMOOTH);
}
示例4: StartRendering
/// <summary>
/// Create device and renderbuffer, initialize NV_DX_interop and start rendering.
/// </summary>
private void StartRendering()
{
_gl = new OpenGL();
_hwnd = new HwndSource(0, 0, 0, 0, 0, "test", IntPtr.Zero).Handle;
_gl.Create(SharpGL.Version.OpenGLVersion.OpenGL2_1, RenderContextType.HiddenWindow, 1, 1, 32, _hwnd);
// Set the most basic OpenGL styles.
_gl.ShadeModel(OpenGL.GL_SMOOTH);
_gl.ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
_gl.ClearDepth(1.0f);
_gl.Enable(OpenGL.GL_BLEND);
_gl.Disable(OpenGL.GL_DEPTH_TEST);
_gl.Enable(OpenGL.GL_TEXTURE_2D);
_gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_REPLACE);
_gl.BlendFunc(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA);
//_gl.Enable(OpenGL.GL_MULTISAMPLE);
//_gl.Enable(OpenGL.GL_MULTISAMPLE_ARB);
_gl.Hint(0x8534, OpenGL.GL_FASTEST);
ResizeRendering();
// leverage the Rendering event of WPF's composition target to
// update the custom D3D scene
CompositionTarget.Rendering += OnRenderOpenGL;
if (GLInitialize != null)
GLInitialize(this, new EventArgs());
}