本文整理匯總了C#中SharpGL.OpenGL.Color方法的典型用法代碼示例。如果您正苦於以下問題:C# OpenGL.Color方法的具體用法?C# OpenGL.Color怎麽用?C# OpenGL.Color使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SharpGL.OpenGL
的用法示例。
在下文中一共展示了OpenGL.Color方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: openGLControl_OpenGLDraw
/// <summary>
/// Handles the OpenGLDraw event of the openGLControl control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RenderEventArgs"/> instance containing the event data.</param>
public void openGLControl_OpenGLDraw(object sender, RenderEventArgs e)
{
// Get the OpenGL object.
gl = openGLControl.OpenGL;
// Clear the color and depth buffer.
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
// Load the identity matrix.
gl.LoadIdentity();
// Rotate around the Y axis.
//gl.Rotate(rotation, 0.0f, 1.0f, 0.0f);
cord = ComInput.Coordinates.Instance;
this.ModelRotater(gl);
gl.Enable(OpenGL.GL_BLEND);
gl.BlendFunc(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA);
// Draw a coloured parallelepiped.
gl.Begin(OpenGL.GL_QUADS);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(-2.0f, -0.25f, -1.0f);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(2.0f, -0.25f, -1.0f);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(2.0f, 0.25f, -1.0f);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(-2.0f, 0.25f, -1.0f);
//-------------------------------------
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(-2.0f, -0.25f, -1.0f);
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(-2.0f, -0.25f, 1.0f);
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(-2.0f, 0.25f, 1.0f);
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(-2.0f, 0.25f, -1.0f);
//-------------------------------------
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(-2.0f, -0.25f, 1.0f);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(2.0f, -0.25f, 1.0f);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(2.0f, 0.25f, 1.0f);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(-2.0f, 0.25f, 1.0f);
//-------------------------------------
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(2.0f, -0.25f, 1.0f);
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(2.0f, -0.25f, -1.0f);
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(2.0f, 0.25f, -1.0f);
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(2.0f, 0.25f, 1.0f);
//-------------------------------------
gl.Color(0.0f, 1.0f, 1.0f);
gl.Vertex(-2.0f, 0.25f, -1.0f);
gl.Color(0.0f, 1.0f, 1.0f);
gl.Vertex(2.0f, 0.25f, -1.0f);
gl.Color(0.0f, 1.0f, 1.0f);
gl.Vertex(2.0f, 0.25f, 1.0f);
gl.Color(0.0f, 1.0f, 1.0f);
gl.Vertex(-2.0f, 0.25f, 1.0f);
//--------------------------------------
gl.Color(0.0f, 0.0f, 1.0f);
gl.Vertex(-2.0f, -0.25f, -1.0f);
gl.Color(0.0f, 0.0f, 1.0f);
gl.Vertex(2.0f, -0.25f, -1.0f);
gl.Color(0.0f, 0.0f, 1.0f);
gl.Vertex(2.0f, -0.25f, 1.0f);
gl.Color(0.0f, 0.0f, 1.0f);
gl.Vertex(-2.0f, -0.25f, 1.0f);
gl.End();
//.........這裏部分代碼省略.........
示例2: Draw3D
public override void Draw3D(OpenGL gl)
{
float drawCoord = (int)(y * 2) % pieces;
float size = 2;
double theta = 0;
if (fever)
{
size = 3f;
if (xpos < -4)
theta = (xpos + 4) * Math.PI / 4;
else if (xpos > 4)
theta = (xpos - 4) * Math.PI / 4;
}
gl.Begin(BeginMode.Quads);
{
if (fever)
gl.Color(1.0f, 0.5f, 0.5f);
gl.TexCoord(drawCoord / pieces, 1);
gl.Vertex(xpos * 0.5f - (0.4f * size) * Math.Cos(theta), y - (0.4f * size) * Math.Sin(theta), 0);
gl.TexCoord(drawCoord / pieces, 0);
gl.Vertex(xpos * 0.5f - (0.4f * size) * Math.Cos(theta), y - (0.4f * size) * Math.Sin(theta), size);
gl.TexCoord((drawCoord + 1) / pieces, 0);
gl.Vertex(xpos * 0.5f + (0.4f * size) * Math.Cos(theta), y + (0.4f * size) * Math.Sin(theta), size);
gl.TexCoord((drawCoord + 1) / pieces, 1);
gl.Vertex(xpos * 0.5f + (0.4f * size) * Math.Cos(theta), y + (0.4f * size) * Math.Sin(theta), 0);
gl.Color(1.0f, 1.0f, 1.0f);
}
gl.End();
}
示例3: paint
public void paint(OpenGL gl)
{
gl.Color(1f, 1f, 1f);
gl.Begin(OpenGL.GL_TRIANGLE_STRIP);
gl.Vertex(x, y + height, 0);
gl.Vertex(x, y, 0);
gl.Vertex(x+width, y + height, 0);
gl.Vertex(x+width, y, 0);
gl.End();
gl.LineWidth(1);
gl.Begin(OpenGL.GL_LINES);
gl.Color(0, 0, 0);
if (centerCoordinateX <= x + width && centerCoordinateX >= x)
{
gl.Vertex4d(centerCoordinateX, y, 0, 1);
gl.Vertex4d(centerCoordinateX, y + height, 0, 1);
}
if (centerCoordinateY <= y + height && centerCoordinateY >= y)
{
gl.Vertex4d(x, centerCoordinateY, 0, 1);
gl.Vertex4d(x+width, centerCoordinateY, 0, 1);
}
gl.End();
for(int i = 0; i < functions.Count; i++)
{
drawFunction(gl, functions.ElementAt(i));
}
}
示例4: Draw
public static void Draw(OpenGL gl, double height, double length, double width)
{
gl.LineWidth(1);
gl.Color(0.7, 0.7, 0.7);
gl.Begin(OpenGL.GL_LINE_LOOP);
gl.Vertex(0, height, 0 );
gl.Vertex(0, height, width);
gl.Vertex(length, height, width);
gl.Vertex(length, height, 0 );
gl.End();
gl.Begin(OpenGL.GL_LINES);
gl.Vertex(0, height, 0);
gl.Vertex(0, 0, 0);
gl.Vertex(length, height, 0);
gl.Vertex(length, 0, 0);
gl.Vertex(0, height, width);
gl.Vertex(0, 0, width);
gl.Vertex(length, height, width);
gl.Vertex(length, 0, width);
gl.End();
gl.Begin(OpenGL.GL_LINE_LOOP);
gl.Vertex(0, 0, 0);
gl.Vertex(0, 0, width);
gl.Vertex(length, 0, width);
gl.Vertex(length, 0, 0);
gl.End();
}
示例5: RenderVertices_Immediate
private void RenderVertices_Immediate(OpenGL gl)
{
gl.Color(1f, 0f, 0f);
gl.Begin(OpenGL.GL_POINTS);
for(uint i=0;i<vertices.Length; i++)
{
gl.Vertex(vertices[i]);
}
gl.End();
}
示例6: drawCoordinateAxes
private void drawCoordinateAxes(OpenGL gl)
{
gl.Color(OpenGlUtility.GetOpenGlColor(Color.Red));
gl.Begin(OpenGL.GL_LINES);
gl.Vertex(0, 0, 0);
gl.Vertex(100, 0, 0);
gl.End();
gl.Color(OpenGlUtility.GetOpenGlColor(Color.Green));
gl.Begin(OpenGL.GL_LINES);
gl.Vertex(0, 0, 0);
gl.Vertex(0, 100, 0);
gl.End();
gl.Color(OpenGlUtility.GetOpenGlColor(Color.Blue));
gl.Begin(OpenGL.GL_LINES);
gl.Vertex(0, 0, 0);
gl.Vertex(0, 0, 100);
gl.End();
}
示例7: CreateDisplayList
private void CreateDisplayList(OpenGL gl)
{
displayList = new DisplayList();
displayList.Generate(gl);
displayList.New(gl, DisplayList.DisplayListMode.CompileAndExecute);
//Push all attributes, disable lighting and depth testing.
gl.PushAttrib(OpenGL.GL_CURRENT_BIT | OpenGL.GL_ENABLE_BIT |
OpenGL.GL_LINE_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
gl.Disable(OpenGL.GL_LIGHTING);
gl.Disable(OpenGL.GL_TEXTURE_2D);
gl.DepthFunc(OpenGL.GL_ALWAYS);
//Set line width.
gl.LineWidth(lineWidth);
//Draw the line.
gl.Begin(OpenGL.GL_LINES);
for (float i = (size * -1); i < size; i+=0.4f)
{
float add = 0.2f;
if (i > 0) add = 0.4f;
if (i < 0 && i > -0.2f) add = 0.4f;
gl.Color(1f, 0f, 0f, 1f);
gl.Vertex(i, 0, 0);
gl.Vertex(i + add, 0, 0);
gl.Color(0f, 1f, 0f, 1f);
gl.Vertex(0, i, 0);
gl.Vertex(0, i + add, 0);
gl.Color(0f, 0f, 1f, 1f);
gl.Vertex(0, 0, i);
gl.Vertex(0, 0, i + add);
}
gl.End();
// Restore attributes.
gl.PopAttrib();
displayList.End(gl);
}
示例8: Bed
private void Bed(OpenGL gl, double x, double y, double z, double width, double height)
{
gl.Begin(OpenGL.GL_QUADS);
gl.Color(1f, 1f, 1f, 1f);
gl.Vertex(x, y + height, -6.0f);
gl.Vertex(x, y, -6.0f);
gl.Vertex(x + width, y, -6.0f);
gl.Vertex(x + width, y + height, -6.0f);
gl.End();
}
示例9: CreateDisplayList
private void CreateDisplayList(OpenGL gl)
{
displayList = new DisplayList();
displayList.Generate(gl);
displayList.New(gl, DisplayList.DisplayListMode.CompileAndExecute);
//Push all attributes, disable lighting and depth testing.
gl.PushAttrib(OpenGL.GL_CURRENT_BIT | OpenGL.GL_ENABLE_BIT |
OpenGL.GL_LINE_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
gl.Disable(OpenGL.GL_LIGHTING);
gl.Disable(OpenGL.GL_TEXTURE_2D);
gl.DepthFunc(OpenGL.GL_ALWAYS);
//Set line width.
gl.LineWidth(lineWidth);
//Draw the line.
gl.Begin(OpenGL.GL_LINES);
for (int i = (size * -1); i <= size; i++)
{
if (i != 0)
{
if ((i % 4) == 0)
gl.Color(Convert.ColorToGLColor(darkColor));
else
gl.Color(Convert.ColorToGLColor(lightColor));
gl.Vertex(i, (size * -1), 0);
gl.Vertex(i, size, 0);
gl.Vertex((size * -1), i, 0);
gl.Vertex(size, i, 0);
}
}
gl.End();
// Restore attributes.
gl.PopAttrib();
displayList.End(gl);
}
示例10: drawMaze
private void drawMaze(OpenGL gl)
{
if (dataModel.MazeStructure.Origin != null)
{
// Draw a coloured pyramid.
gl.Begin(OpenGL.GL_TRIANGLES);
gl.Color(0.0f, 1.0f, 0.0f);
float x = dataModel.MazeStructure.Origin.Coordinates.X;
float y = dataModel.MazeStructure.Origin.Coordinates.Y;
float z = 1.0f;
gl.Vertex(x, y, z);
gl.DrawText(0, 0, 128.0f, 128.0f, 128.0f, "Arial", 12.0f, "Drawing maze");
/*
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(0.0f, 1.0f, 0.0f);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(-1.0f, -1.0f, 1.0f);
gl.Color(0.0f, 0.0f, 1.0f);
gl.Vertex(1.0f, -1.0f, 1.0f);
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(0.0f, 1.0f, 0.0f);
gl.Color(0.0f, 0.0f, 1.0f);
gl.Vertex(1.0f, -1.0f, 1.0f);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(1.0f, -1.0f, -1.0f);
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(0.0f, 1.0f, 0.0f);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(1.0f, -1.0f, -1.0f);
gl.Color(0.0f, 0.0f, 1.0f);
gl.Vertex(-1.0f, -1.0f, -1.0f);
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(0.0f, 1.0f, 0.0f);
gl.Color(0.0f, 0.0f, 1.0f);
gl.Vertex(-1.0f, -1.0f, -1.0f);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(-1.0f, -1.0f, 1.0f);
*/
gl.End();
}
if (dataModel != null)
gl.DrawText(0, 0, 128.0f, 128.0f, 128.0f, "Arial", 12.0f, dataModel.SolverAgentList.Count.ToString());
}
示例11: DrawGrid
public void DrawGrid(OpenGL gl, int camX,int camY)
{
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
gl.LoadIdentity();
int MapHeight = tileMap.mapHeight;
int MapWidth = tileMap.mapWidth;
float[] darkColor = { 0.2f, 0.2f, 0.2f };
float[] lightColor = { 0.25f, 0.25f, 0.25f };
for (int h = 0; h < MapHeight; h++)
{
if (h % 10 == 0)
{
gl.LineWidth(2.0f);
gl.Color(lightColor);
}
else
{
gl.LineWidth(1.0f);
gl.Color(darkColor);
}
if (h == 0)
{
gl.LineWidth(4.0f);
gl.Color(lightColor);
}
gl.Begin(OpenGL.GL_LINES); // Start Drawing Verticle Cell Borders
gl.Vertex(0 - camX, h * tileSize - camY, 0);// Left Side Of Horizontal Line
gl.Vertex((MapWidth * tileSize) - camX, (h * tileSize) - camY, 0);// Right Side Of Horizontal Line
gl.End();
}
for (int v = 0; v < MapWidth; v++)
{
if (v % 10 == 0)
{
gl.LineWidth(2.0f);
gl.Color(lightColor);
}
else
{
gl.LineWidth(1.0f);
gl.Color(darkColor);
}
if (v == 0)
{
gl.LineWidth(4.0f);
gl.Color(lightColor);
}
gl.Begin(OpenGL.GL_LINES); // Start Drawing Verticle Cell Borders
gl.Vertex(v * tileSize - camX, 0 - camY, 0);// Left Side Of Horizontal Line
gl.Vertex((v * tileSize) - camX, (MapHeight * tileSize) - camY, 0);// Right Side Of Horizontal Line
gl.End();
}
}
示例12: Draw
public override void Draw(OpenGL gl)
{
PointFloat _size = GetSize();
PointFloat[] pointData = RenderLogics.RectPoint(GetPosition(), _size, GetRotation());
byte[] color = GetColor();
GetTexture().UseTexure(gl);
gl.Begin(OpenGL.GL_QUADS);
gl.Color(color[0], color[1], color[2]);
gl.TexCoord(0, 0);
gl.Vertex(pointData[1].x, pointData[1].y);
gl.TexCoord(0, 1);
gl.Vertex(pointData[0].x, pointData[0].y);
gl.TexCoord(1, 1);
gl.Vertex(pointData[3].x, pointData[3].y);
gl.TexCoord(1, 0);
gl.Vertex(pointData[2].x, pointData[2].y);
gl.End();
}
示例13: DrawSprite
public void DrawSprite(float posX, float posY, Sprite sprite, OpenGL gl)
{
float[] verts = {
posX, posY,
posX + 32, posY,
posX + 32, posY + 32,
posX, posY + 32
};
float tw = sprite.spriteWidth;
float th = sprite.spriteHeight;
float tx = sprite.spriteX;
float ty = sprite.spriteY;
float[] texVerts = {
tx, ty,
tx + tw, ty,
tx + tw, ty + th,
tx, ty + th
};
gl.Color(1.0, 1.0, 1.0, 1.0); // reset gl color
tex.Bind(gl);
gl.Begin(OpenGL.GL_QUADS);
gl.TexCoord(texVerts[0], texVerts[1]); gl.Vertex(verts[0], verts[1], 0.0f); // Bottom Left Of The Texture and Quad
gl.TexCoord(texVerts[2], texVerts[3]); gl.Vertex(verts[2], verts[3], 0.0f); // Bottom Right Of The Texture and Quad
gl.TexCoord(texVerts[4], texVerts[5]); gl.Vertex(verts[4], verts[5], 0.0f); // Top Right Of The Texture and Quad
gl.TexCoord(texVerts[6], texVerts[7]); gl.Vertex(verts[6], verts[7], 0.0f); // Top Left Of The Texture and Quad
gl.End();
//this is sposed to be better but doesnt seem to work
//gl.VertexPointer(2, OpenGL.GL_FLOAT, 0, verts);
//gl.TexCoordPointer(2, OpenGL.GL_FLOAT, 0, texVerts);
//gl.DrawArrays(OpenGL.GL_TRIANGLE_STRIP,0,4);
}
示例14: Draw
public override void Draw(ref OpenGL gl)
{
if (!TexturesInitialised)
{
InitializeTexture(ref gl);
}
// Clear the color and depth buffer.
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
// Load the identity matrix.
gl.LoadIdentity();
gl.Enable(OpenGL.GL_TEXTURE_2D);
gl.Enable(OpenGL.GL_LIGHTING);
gl.Enable(OpenGL.GL_LIGHT0);
gl.Enable(OpenGL.GL_DEPTH_TEST);
gl.Enable(OpenGL.GL_NORMALIZE);
gl.BindTexture(OpenGL.GL_TEXTURE_2D, gtexture[0]);
gl.Color(1.0f, 1.0f, 1.0f, 0.1f);
gl.Begin(OpenGL.GL_QUADS);
gl.FrontFace(OpenGL.GL_FRONT_FACE);
gl.TexCoord(1.0f, 1.0f);
gl.Vertex(gImage1.Width, gImage1.Height, 1.0f);
gl.TexCoord(0.0f, 1.0f);
gl.Vertex(0.0f, gImage1.Height, 1.0f);
gl.TexCoord(0.0f, 0.0f);
gl.Vertex(0.0f, 0.0f, 1.0f);
gl.TexCoord(1.0f, 0.0f);
gl.Vertex(gImage1.Width, 0.0f, 1.0f);
gl.End();
gl.Disable(OpenGL.GL_TEXTURE_2D);
gl.MatrixMode(OpenGL.GL_PROJECTION);
gl.LoadIdentity();
gl.Ortho(0.0, (double)gImage1.Width, (double)gImage1.Height, 0.0, -1.0, 1.0);
gl.MatrixMode(OpenGL.GL_MODELVIEW);
gl.Disable(OpenGL.GL_DEPTH_TEST);
}
示例15: triangle
private void triangle(OpenGL gl, double x1, double y1, double x2, double y2, double x3, double y3, int n)
{
gl.PolygonMode(OpenGL.GL_FRONT, OpenGL.GL_FILL);
gl.Begin(OpenGL.GL_TRIANGLES);
gl.Color(ColorR[n], ColorG[n], ColorB[n]);
gl.Vertex(x1, y1, 0);
gl.Vertex(x2, y2, 0);
gl.Vertex(x3, y3, 0);
gl.End();
}