当前位置: 首页>>代码示例>>C#>>正文


C# OpenGL.LineWidth方法代码示例

本文整理汇总了C#中SharpGL.OpenGL.LineWidth方法的典型用法代码示例。如果您正苦于以下问题:C# OpenGL.LineWidth方法的具体用法?C# OpenGL.LineWidth怎么用?C# OpenGL.LineWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SharpGL.OpenGL的用法示例。


在下文中一共展示了OpenGL.LineWidth方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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));
     }
 }
开发者ID:shirinkinV,项目名称:Course_work,代码行数:28,代码来源:Grapics.cs

示例2: 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);
            gl.Color(Convert.ColorToGLColor(c1));
            gl.Vertex(v1.X, v1.Y, v1.Z);
            gl.Color(Convert.ColorToGLColor(c2));
            gl.Vertex(v2.X, v2.Y, v2.Z);
            gl.End();

            //  Restore attributes.
            gl.PopAttrib();

            displayList.End(gl);
        }
开发者ID:chances,项目名称:Animatum,代码行数:30,代码来源:Line.cs

示例3: 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();
        }
开发者ID:KyMaP13,项目名称:sharpcam,代码行数:32,代码来源:Details.cs

示例4: drawFunction

        void drawFunction(OpenGL gl, FunctionAppearance app)
        {
            gl.LineWidth(app.lineWidth);
            double aInPaintCoords = centerCoordinateX + app.a / unitsProPixel;
            double bInPaintCoords = centerCoordinateX + app.b / unitsProPixel;
            double a = 0;
            double b = 0;
            if (aInPaintCoords<=x+width)
            {
                if (bInPaintCoords >= x)
                {
                    if (aInPaintCoords >= x)
                    {
                        a = app.a;
                    }
                    else
                    {
                        a = (x-centerCoordinateX) * unitsProPixel;
                    }
                    if (bInPaintCoords <= x + width)
                    {
                        b = app.b;
                    }
                    else
                    {
                        b = (x + width - centerCoordinateX) * unitsProPixel;
                    }

                    gl.Begin(OpenGL.GL_LINE_STRIP);
                    double xInFunctionCoords = a;
                    double xInPaintCoords = Math.Max(aInPaintCoords, x);
                    gl.Color((float)(app.color >> 16 & 0xff) / 255, (float)(app.color >> 8 & 0xff) / 255, (float)(app.color & 0xff) / 255);
                    while (xInFunctionCoords <= b)
                    {
                        double yInPaintCoords = centerCoordinateY + app.func(xInFunctionCoords) / unitsProPixel;

                        if (yInPaintCoords >= y && yInPaintCoords <= y + height)
                        {
                            gl.Vertex(xInPaintCoords, yInPaintCoords, 0);
                        }
                        else
                        {
                            gl.End();
                            gl.Begin(OpenGL.GL_LINE_STRIP);
                        }

                        xInFunctionCoords += unitsProPixel;
                        xInPaintCoords++;
                    }
                    gl.End();

                }
            }
        }
开发者ID:shirinkinV,项目名称:Course_work,代码行数:54,代码来源:Grapics.cs

示例5: 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();
            }
        }
开发者ID:jesterguy,项目名称:Modern_Tactics,代码行数:55,代码来源:BattleMap.cs

示例6: 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);
        }
开发者ID:chances,项目名称:Animatum,代码行数:41,代码来源:Axies.cs

示例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 (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);
        }
开发者ID:chances,项目名称:Animatum,代码行数:40,代码来源:Grid.cs

示例8: DrawMesh

        /// <summary>
        /// Draw a mesh.
        /// </summary>
        /// <param name="gl">OpenGL handler.</param>
        /// <param name="buildingObj">The mesh.</param>BuildingObjectLib3DS _object,
        private void DrawMesh(OpenGL gl,  Lib3dsMesh thisMesh, Hashtable textures, List<Lib3dsMaterial> matrials, DrawType type)
        {
            if (thisMesh == null || thisMesh.nfaces == 0)
                return;

            // Draw all the faces in this mesh.
            for (int j = 0; j < thisMesh.faces.Count; j++)
            {
                Lib3dsFace thisFace = thisMesh.faces[j];
                float transparency = matrials[thisFace.material].transparency;
                //float[] fogColor = new float[4] { 0.5f, 0.5f, 0.5f, 1.0f };
                //float[] LightAmbient = new float[4] { 0.5f, 0.5f, 0.5f, 1.0f };
                //float[] LightDiffuse = new float[4] { 1.0f, 1.0f, 1.0f, 1.0f };
                //float[] LightPosition = new float[4] { 0.0f, 0.0f, 2.0f, 1.0f };

                switch (type)
                {
                    case DrawType.WireFrame:
                        gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_LINE);
                        IsDrawTexture = false;
                        gl.Color(0.5f, 0.5f, 0.5f, 0.5f);
                        gl.LineWidth(1.5f);
                        break;
                    case DrawType.Full:
                        IsDrawTexture = BindTexture(gl, textures, matrials[thisFace.material].name);
                        gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL);
                        break;
                    case DrawType.Face:
                        gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL);
                        IsDrawTexture = false;
                        break;
                    case DrawType.Translucent:
                        IsDrawTexture = BindTexture(gl, textures, matrials[thisFace.material].name);
                        gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL);
                        gl.Enable(OpenGL.GL_BLEND);
                        gl.BlendFunc(OpenGL.GL_SRC_ALPHA,OpenGL.GL_ONE_MINUS_SRC_ALPHA);

                        //gl.Enable(OpenGL.GL_TEXTURE_2D);							// Enable Texture Mapping
                        //gl.ShadeModel(OpenGL.GL_SMOOTH);							// Enable Smooth Shading
                        //gl.ClearColor(0.5f,0.5f,0.5f,1.0f);					// We'll Clear To The Color Of The Fog
                        //gl.ClearDepth(1.0f);									// Depth Buffer Setup
                        //gl.Enable(OpenGL.GL_DEPTH_TEST);							// Enables Depth Testing
                        //gl.DepthFunc(OpenGL.GL_LEQUAL);								// The Type Of Depth Testing To Do
                        //gl.Hint(OpenGL.GL_PERSPECTIVE_CORRECTION_HINT, OpenGL.GL_NICEST);	// Really Nice Perspective Calculations

                        //gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_AMBIENT, LightAmbient);		// Setup The Ambient Light
                        //gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_DIFFUSE, LightDiffuse);		// Setup The Diffuse Light
                        //gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_POSITION,LightPosition);	// Position The Light
                        //gl.Enable(OpenGL.GL_LIGHT1);

                        //gl.Fog(OpenGL.GL_FOG_COLOR, fogColor);//设置雾颜色,f是一个指定颜色的数组float f[4]
                        //gl.Fog(OpenGL.GL_FOG_DENSITY, 0.85f); // 设置雾的密度
                        //gl.Hint(OpenGL.GL_FOG_HINT, OpenGL.GL_DONT_CARE); // 设置系统如何计算雾气
                        //gl.Fog(OpenGL.GL_FOG_START, 0.01f);//设置雾从多远开始
                        //gl.Fog(OpenGL.GL_FOG_END, 100.0f);//设置雾从多远结束
                        //gl.Fog(OpenGL.GL_FOG_MODE, OpenGL.GL_LINEAR);//设置使用哪种雾,共有三中雾化模式
                        //gl.Enable(OpenGL.GL_FOG);//打开雾效果

                        transparency = 0.2f;
                        break;
                    default:
                        gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL);
                        IsDrawTexture = false;
                        break;
                }
                if (type != DrawType.WireFrame)
                {
                    gl.Color(matrials[thisFace.material].diffuse[0], matrials[thisFace.material].diffuse[1],
                        matrials[thisFace.material].diffuse[2], matrials[thisFace.material].transparency);
                }

                gl.Begin(OpenGL.GL_TRIANGLES);

                for (int k = 0; k != 3; ++k)
                {
                    int index = thisFace.index[k];

                    if (IsDrawTexture)
                        gl.TexCoord(thisMesh.texcos[index].s, thisMesh.texcos[index].t);
                    gl.Vertex(thisMesh.vertices[index].x / 20, thisMesh.vertices[index].z / 20, -thisMesh.vertices[index].y / 20);
                }

                gl.End();
                if(type == DrawType.Translucent)
                   gl.Disable(OpenGL.GL_BLEND);
            }
        }
开发者ID:k19862217,项目名称:DioramaExhibitionSupportSystem,代码行数:92,代码来源:3DSDrawer.cs

示例9: Draw

        /// <summary>
        /// Use this to draw the vertex grid.
        /// </summary>
        /// <param name="gl">OpenGL object.</param>
        /// <param name="points">Draw each individual vertex (with selection names).</param>
        /// <param name="lines">Draw the lines connecting the points.</param>
        public virtual void Draw(OpenGL gl, bool points, bool lines)
        {
            //	Save the attributes.
            gl.PushAttrib(OpenGL.ALL_ATTRIB_BITS);
            gl.Disable(OpenGL.LIGHTING);
            gl.Color(1, 0, 0, 1);

            if(points)
            {
                int name = 0;

                gl.PointSize(5);

                //	Add a new name (the vertex name).
                gl.PushName(0);

                foreach(Vertex v in vertices)
                {
                    //	Set the name, draw the vertex.
                    gl.LoadName((uint)name++);
                    ((IInteractable)v).DrawPick(gl);
                }

                //	Pop the name.
                gl.PopName();
            }

            if(lines)
            {
                //	Draw lines along each row, then along each column.
                gl.DepthFunc(OpenGL.ALWAYS);

                gl.LineWidth(1);
                gl.Disable(OpenGL.LINE_SMOOTH);

                for(int col=0; col < y; col++)
                {
                    for(int row=0; row < x; row++)
                    {
                        //	Create vertex indicies.
                        int nTopLeft = (col * x) + row;
                        int nBottomLeft = ((col + 1) * x) + row;

                        gl.Begin(OpenGL.LINES);
                        if(row < (x-1))
                        {
                            gl.Vertex(vertices[nTopLeft]);
                            gl.Vertex(vertices[nTopLeft + 1]);
                        }
                        if(col < (y-1))
                        {
                            gl.Vertex(vertices[nTopLeft]);
                            gl.Vertex(vertices[nBottomLeft]);
                        }
                        gl.End();
                    }
                }
                gl.DepthFunc(OpenGL.LESS);
            }

            gl.PopAttrib();
        }
开发者ID:nromik,项目名称:sharpgl,代码行数:68,代码来源:SimpleTypes.cs

示例10: DoRenderFraction

        private void DoRenderFraction(OpenGL gl, RenderMode renderMode)
        {
            if (this.fractionPositionBuffer == null || this.fractionUVBuffer == null) { return; }

            if (this.RenderFraction && this.fractionVertexArrayObject != null)
            {
                shaderProgram.SetUniform1(gl, "renderingWireframe", 0.0f);

                gl.Enable(OpenGL.GL_POLYGON_OFFSET_FILL);
                gl.PolygonOffset(1.0f, 1.0f);

                gl.BindVertexArray(fractionVertexArrayObject[0]);

                switch (this.FractionType)
                {
                    case FractureFormat.Line:
                        float[] originalWidth = new float[1];
                        gl.GetFloat(SharpGL.Enumerations.GetTarget.LineWidth, originalWidth);

                        gl.LineWidth(this.FractionLineWidth);
                        gl.DrawArrays(OpenGL.GL_LINES, 0, this.FractionVertexCount);

                        gl.LineWidth(originalWidth[0]);
                        break;
                    case FractureFormat.Triange:
                        gl.DrawArrays(OpenGL.GL_TRIANGLES, 0, this.FractionVertexCount);
                        break;
                    case FractureFormat.Quad:
                        gl.DrawArrays(OpenGL.GL_QUADS, 0, this.FractionVertexCount);
                        break;
                    default:
                        throw new NotImplementedException();
                    //break;
                }

                gl.BindVertexArray(0);

                gl.Disable(OpenGL.GL_POLYGON_OFFSET_FILL);
            }

            if (this.renderFractionWireframe && this.fractionVertexArrayObject != null)
            {
                shaderProgram.SetUniform1(gl, "renderingWireframe", 1.0f);

                gl.BindVertexArray(fractionVertexArrayObject[0]);
                {
                    gl.PolygonMode(SharpGL.Enumerations.FaceMode.FrontAndBack, SharpGL.Enumerations.PolygonMode.Lines);

                    switch (this.FractionType)
                    {
                        case FractureFormat.Line:
                            gl.DrawArrays(OpenGL.GL_LINES, 0, this.FractionVertexCount);
                            break;
                        case FractureFormat.Triange:
                            gl.DrawArrays(OpenGL.GL_TRIANGLES, 0, this.FractionVertexCount);
                            break;
                        case FractureFormat.Quad:
                            gl.DrawArrays(OpenGL.GL_QUADS, 0, this.FractionVertexCount);
                            break;
                        default:
                            break;
                    }

                    gl.PolygonMode(SharpGL.Enumerations.FaceMode.FrontAndBack, SharpGL.Enumerations.PolygonMode.Filled);
                }
                gl.BindVertexArray(0);
            }
        }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:68,代码来源:DynamicUnstructureGrid.cs

示例11: BindAll

        public void BindAll(OpenGL gl)
        {
            //return;
            UseProgram(gl, () =>
            {
                // Update uniforms.
                foreach (var action in ChangedUniforms)
                {
                    action.Invoke(gl);
                }
                ChangedUniforms.Clear();

                foreach (var group in BufferGroups)
                {
                    group.BindVAO(gl);

                    gl.LineWidth(group.LineWidth);

                    // Use draw elements if an index buffer is defined. Else use draw arrays.
                    if (group.IndicesCount > 0)
                        gl.DrawElements(OpenGL.GL_LINES, group.IndicesCount, OpenGL.GL_UNSIGNED_INT, IntPtr.Zero);
                    else
                        gl.DrawArrays(OpenGL.GL_LINES, 0, group.VerticesCount);
                }
            });
        }
开发者ID:jochemgeussens,项目名称:sharpgl,代码行数:26,代码来源:LinesProgram.cs


注:本文中的SharpGL.OpenGL.LineWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。