本文整理汇总了C#中SharpGL.OpenGL.Flush方法的典型用法代码示例。如果您正苦于以下问题:C# OpenGL.Flush方法的具体用法?C# OpenGL.Flush怎么用?C# OpenGL.Flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpGL.OpenGL
的用法示例。
在下文中一共展示了OpenGL.Flush方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawText
/// <summary>
/// Draws the text.
/// </summary>
/// <param name="gl">The gl.</param>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
/// <param name="r">The r.</param>
/// <param name="g">The g.</param>
/// <param name="b">The b.</param>
/// <param name="faceName">Name of the face.</param>
/// <param name="fontSize">Size of the font.</param>
/// <param name="text">The text.</param>
public void DrawText(OpenGL gl, int x, int y, float r, float g, float b, string faceName, float fontSize, string text)
{
// Get the font size in pixels.
var fontHeight = (int)(fontSize * (16.0f / 12.0f));
// Do we have a font bitmap entry for this OpenGL instance and face name?
var result = (from fbe in fontBitmapEntries
where fbe.HDC == gl.RenderContextProvider.DeviceContextHandle
&& fbe.HRC == gl.RenderContextProvider.RenderContextHandle
&& String.Compare(fbe.FaceName, faceName, StringComparison.OrdinalIgnoreCase) == 0
&& fbe.Height == fontHeight
select fbe).ToList();
// Get the FBE or null.
var fontBitmapEntry = result.FirstOrDefault();
// If we don't have the FBE, we must create it.
if (fontBitmapEntry == null)
fontBitmapEntry = CreateFontBitmapEntry(gl, faceName, fontHeight);
double width = gl.RenderContextProvider.Width;
double height = gl.RenderContextProvider.Height;
// Create the appropriate projection matrix.
gl.MatrixMode(OpenGL.GL_PROJECTION);
gl.PushMatrix();
gl.LoadIdentity();
int[] viewport = new int[4];
gl.GetInteger(OpenGL.GL_VIEWPORT, viewport);
gl.Ortho(0, width, 0, height, -1, 1);
// Create the appropriate modelview matrix.
gl.MatrixMode(OpenGL.GL_MODELVIEW);
gl.PushMatrix();
gl.LoadIdentity();
gl.Color(r, g, b);
gl.RasterPos(x, y);
gl.PushAttrib(OpenGL.GL_LIST_BIT | OpenGL.GL_CURRENT_BIT |
OpenGL.GL_ENABLE_BIT | OpenGL.GL_TRANSFORM_BIT);
gl.Color(r, g, b);
gl.Disable(OpenGL.GL_LIGHTING);
gl.Disable(OpenGL.GL_TEXTURE_2D);
gl.Disable(OpenGL.GL_DEPTH_TEST);
gl.RasterPos(x, y);
// Set the list base.
gl.ListBase(fontBitmapEntry.ListBase);
// Create an array of lists for the glyphs.
var lists = text.Select(c => (byte) c).ToArray();
// Call the lists for the string.
gl.CallLists(lists.Length, lists);
gl.Flush();
// Reset the list bit.
gl.PopAttrib();
// Pop the modelview.
gl.PopMatrix();
// back to the projection and pop it, then back to the model view.
gl.MatrixMode(OpenGL.GL_PROJECTION);
gl.PopMatrix();
gl.MatrixMode(OpenGL.GL_MODELVIEW);
}
示例2: DrawText
/// <summary>
/// Draws the text.
/// </summary>
/// <param name="gl">The gl.</param>
/// <param name="faceName">Name of the face.</param>
/// <param name="fontSize">Size of the font.</param>
/// <param name="text">The text.</param>
public void DrawText(OpenGL gl, string faceName, float fontSize,
float deviation, float extrusion, string text)
{
// Get the font size in pixels.
int fontHeight = (int)(fontSize * (16.0f / 12.0f));
// Do we have a font bitmap entry for this OpenGL instance and face name?
var result = from fbe in fontOutlineEntries
where fbe.HDC == gl.RenderContextProvider.DeviceContextHandle
&& fbe.HRC == gl.RenderContextProvider.RenderContextHandle
&& string.Compare(fbe.FaceName, faceName, true) == 0
&& fbe.Height == fontHeight
&& fbe.Deviation == deviation
&& fbe.Extrusion == extrusion
select fbe;
// Get the FBE or null.
var fontOutlineEntry = result == null || result.Count() == 0 ? null : result.First();
// If we don't have the FBE, we must create it.
if (fontOutlineEntry == null)
fontOutlineEntry = CreateFontOutlineEntry(gl, faceName, fontHeight, deviation, extrusion, FontOutlineFormat.Polygons);
// Set the list base.
gl.ListBase(fontOutlineEntry.ListBase);
// Create an array of lists for the glyphs.
List<byte> lists = new List<byte>();
foreach(char c in text)
lists.Add((byte)c);
// Call the lists for the string.
gl.CallLists(lists.Count, lists.ToArray());
gl.Flush();
}
示例3: SampleRendering
private void SampleRendering(OpenGL gl, float rX, float rY, float rZ)
{
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
gl.LoadIdentity(); // Reset The View
gl.Translate(-1.5f, 0.0f, -6.0f); // Move Left And Into The Screen
gl.Rotate(rtri, rX, rY, rZ); // Rotate The Pyramid On It's Y Axis
gl.Begin(OpenGL.GL_TRIANGLES); // Start Drawing The Pyramid
gl.Color(1.0f, 0.0f, 0.0f); // Red
gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Front)
gl.Color(0.0f, 1.0f, 0.0f); // Green
gl.Vertex(-1.0f, -1.0f, 1.0f); // Left Of Triangle (Front)
gl.Color(0.0f, 0.0f, 1.0f); // Blue
gl.Vertex(1.0f, -1.0f, 1.0f); // Right Of Triangle (Front)
gl.Color(1.0f, 0.0f, 0.0f); // Red
gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Right)
gl.Color(0.0f, 0.0f, 1.0f); // Blue
gl.Vertex(1.0f, -1.0f, 1.0f); // Left Of Triangle (Right)
gl.Color(0.0f, 1.0f, 0.0f); // Green
gl.Vertex(1.0f, -1.0f, -1.0f); // Right Of Triangle (Right)
gl.Color(1.0f, 0.0f, 0.0f); // Red
gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Back)
gl.Color(0.0f, 1.0f, 0.0f); // Green
gl.Vertex(1.0f, -1.0f, -1.0f); // Left Of Triangle (Back)
gl.Color(0.0f, 0.0f, 1.0f); // Blue
gl.Vertex(-1.0f, -1.0f, -1.0f); // Right Of Triangle (Back)
gl.Color(1.0f, 0.0f, 0.0f); // Red
gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Left)
gl.Color(0.0f, 0.0f, 1.0f); // Blue
gl.Vertex(-1.0f, -1.0f, -1.0f); // Left Of Triangle (Left)
gl.Color(0.0f, 1.0f, 0.0f); // Green
gl.Vertex(-1.0f, -1.0f, 1.0f); // Right Of Triangle (Left)
gl.End(); // Done Drawing The Pyramid
gl.LoadIdentity();
gl.Translate(1.5f, 0.0f, -7.0f); // Move Right And Into The Screen
gl.Rotate(rquad, rX, rY, rZ); // Rotate The Cube On X, Y & Z
gl.Begin(OpenGL.GL_QUADS); // Start Drawing The Cube
gl.Color(0.0f, 1.0f, 0.0f); // Set The Color To Green
gl.Vertex(1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Top)
gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Top)
gl.Vertex(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Quad (Top)
gl.Vertex(1.0f, 1.0f, 1.0f); // Bottom Right Of The Quad (Top)
gl.Color(1.0f, 0.5f, 0.0f); // Set The Color To Orange
gl.Vertex(1.0f, -1.0f, 1.0f); // Top Right Of The Quad (Bottom)
gl.Vertex(-1.0f, -1.0f, 1.0f); // Top Left Of The Quad (Bottom)
gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Bottom)
gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Bottom)
gl.Color(1.0f, 0.0f, 0.0f); // Set The Color To Red
gl.Vertex(1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Front)
gl.Vertex(-1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Front)
gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Quad (Front)
gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Right Of The Quad (Front)
gl.Color(1.0f, 1.0f, 0.0f); // Set The Color To Yellow
gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Back)
gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Back)
gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Back)
gl.Vertex(1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Back)
gl.Color(0.0f, 0.0f, 1.0f); // Set The Color To Blue
gl.Vertex(-1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Left)
gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Left)
gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Left)
gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Quad (Left)
gl.Color(1.0f, 0.0f, 1.0f); // Set The Color To Violet
gl.Vertex(1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Right)
gl.Vertex(1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Right)
gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Left Of The Quad (Right)
gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Right)
gl.End(); // Done Drawing The Q
gl.Flush();
rtri += 1.0f;// 0.2f; // Increase The Rotation Variable For The Triangle
rquad -= 1.0f;// 0.15f; // Decrease The Rotation Variable For The Quad
}
示例4: DrawText
/// <summary>
/// Draws the text.
/// </summary>
/// <param name="gl">The gl.</param>
/// <param name="faceName">Name of the face.</param>
/// <param name="fontSize">Size of the font.</param>
/// <param name="deviation">The deviation.</param>
/// <param name="extrusion">The extrusion.</param>
/// <param name="text">The text.</param>
public void DrawText(OpenGL gl, string faceName, float fontSize,
float deviation, float extrusion, string text)
{
// Get the font size in pixels.
var fontHeight = (int)(fontSize * (16.0f / 12.0f));
// Do we have a font bitmap entry for this OpenGL instance and face name?
var result = (from fbe in fontOutlineEntries
where fbe.HDC == gl.RenderContextProvider.DeviceContextHandle
&& fbe.HRC == gl.RenderContextProvider.RenderContextHandle
&& String.Compare(fbe.FaceName, faceName, StringComparison.OrdinalIgnoreCase) == 0
&& fbe.Height == fontHeight
&& fbe.Deviation == deviation
&& fbe.Extrusion == extrusion
select fbe).ToList();
// Get the FBE or null.
var fontOutlineEntry = result.FirstOrDefault();
// If we don't have the FBE, we must create it.
if (fontOutlineEntry == null)
fontOutlineEntry = CreateFontOutlineEntry(gl, faceName, fontHeight, deviation, extrusion, FontOutlineFormat.Polygons);
// Set the list base.
gl.ListBase(fontOutlineEntry.ListBase);
// Create an array of lists for the glyphs.
var lists = text.Select(c => (byte) c).ToArray();
// Call the lists for the string.
gl.CallLists(lists.Length, lists);
gl.Flush();
}
示例5: DrawText
/// <summary>
/// Draws the text.
/// </summary>
/// <param name="gl">The gl.</param>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
/// <param name="r">The r.</param>
/// <param name="g">The g.</param>
/// <param name="b">The b.</param>
/// <param name="faceName">Name of the face.</param>
/// <param name="fontSize">Size of the font.</param>
/// <param name="text">The text.</param>
public void DrawText(OpenGL gl, int x, int y, float r, float g, float b, string faceName, float fontSize, string text)
{
// Get the font size in pixels.
int fontHeight = (int)(fontSize * (16.0f / 12.0f));
// Do we have a font bitmap entry for this OpenGL instance and face name?
var result = from fbe in fontBitmapEntries
where fbe.HDC == gl.RenderContextProvider.DeviceContextHandle
&& fbe.HRC == gl.RenderContextProvider.RenderContextHandle
&& string.Compare(fbe.FaceName, faceName, true) == 0
&& fbe.Height == fontHeight
select fbe;
// Get the FBE or null.
FontBitmapEntry fontBitmapEntry = result == null || result.Count() == 0 ? null : result.First();
// If we don't have the FBE, we must create it.
if (fontBitmapEntry == null)
fontBitmapEntry = CreateFontBitmapEntry(gl, faceName, fontHeight);
double width = gl.RenderContextProvider.Width;
double height = gl.RenderContextProvider.Height;
double aspect_ratio = width / height;
// Create the appropriate projection matrix.
gl.MatrixMode(OpenGL.GL_PROJECTION);
gl.PushMatrix();
gl.LoadIdentity();
int[] viewport = new int[4];
gl.GetInteger(OpenGL.GL_VIEWPORT, viewport);
//gl.Ortho2D(viewport[0], viewport[2], viewport[1], viewport[3]);
gl.Ortho(0, width, 0, height, -1, 1);
// Create the appropriate modelview matrix.
gl.MatrixMode(OpenGL.GL_MODELVIEW);
gl.PushMatrix();
gl.LoadIdentity();
//gl.Translate(0, 0, -5);
//gl.RasterPos(x, y);
gl.Color(r, g, b);
gl.RasterPos(x, y);
gl.PushAttrib(OpenGL.GL_LIST_BIT | OpenGL.GL_CURRENT_BIT |
OpenGL.GL_ENABLE_BIT | OpenGL.GL_TRANSFORM_BIT);
gl.Color(r, g, b);
gl.Disable(OpenGL.GL_LIGHTING);
gl.Disable(OpenGL.GL_TEXTURE_2D);
gl.Disable(OpenGL.GL_DEPTH_TEST);
gl.RasterPos(x, y);
/** gl.Enable(OpenGL.GL_BLEND);
gl.BlendFunc(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA); */
// Set the list base.
gl.ListBase(fontBitmapEntry.ListBase);
// Create an array of lists for the glyphs.
List<byte> lists = new List<byte>();
foreach(char c in text)
lists.Add((byte)c);
// Call the lists for the string.
gl.CallLists(lists.Count, lists.ToArray());
gl.Flush();
// Reset the list bit.
gl.PopAttrib();
// Pop the modelview.
gl.PopMatrix();
// back to the projection and pop it, then back to the model view.
gl.MatrixMode(OpenGL.GL_PROJECTION);
gl.PopMatrix();
gl.MatrixMode(OpenGL.GL_MODELVIEW);
}
示例6: OpenGLControl_OpenGLDraw
private void OpenGLControl_OpenGLDraw(object sender, SharpGL.SceneGraph.OpenGLEventArgs args)
{
OpenGL gl = new OpenGL();
ballX -= balMovX;
ballY -= balMovY;
if (Convert.ToInt32(ballX) == -gameSizeX)
{
balMovX = -0.08f;
}
else if (Convert.ToInt32(ballX) == gameSizeX)
{
balMovX = 0.08f;
}
if (Convert.ToInt32(ballY) == -gameSizeY)
{
balMovY = -0.03f;
}
else if (Convert.ToInt32(ballY) == gameSizeY)
{
balMovY = 0.03f;
}
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
gl.LoadIdentity();
gl.Translate(gameX, gameY, gameZ);
gameRect(gl);
Ball(gl);
Bed(gl,bed1X, bed1Y, bed1Z, 0.2f, 1.8f);
Bed(gl,bed2X, bed2Y, bed2Z, 0.2f, 1.8f);
gl.Flush();
}