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


C# OpenGL.TexCoord方法代码示例

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


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

示例1: 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();
        }
开发者ID:Celicath,项目名称:RRRR,代码行数:31,代码来源:Player.cs

示例2: DrawQuadsWithTexture

 private void DrawQuadsWithTexture(OpenGL gl, int texture, params int[][][] quads)
 {
     gl.BindTexture(OpenGL.GL_TEXTURE_2D, _textures[texture]);
     gl.Begin(OpenGL.GL_QUADS);
     foreach (var quad in quads)
     {
         gl.TexCoord(0.0f, 0.0f); gl.Vertex(quad[0]);
         gl.TexCoord(1.0f, 0.0f); gl.Vertex(quad[1]);
         gl.TexCoord(1.0f, 1.0f); gl.Vertex(quad[2]);
         gl.TexCoord(0.0f, 1.0f); gl.Vertex(quad[3]);
     }
     gl.End();
 }
开发者ID:fbmly007,项目名称:3dsexplorer,代码行数:13,代码来源:frmAbout.cs

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

示例4: Draw3D

        public virtual void Draw3D(OpenGL gl)
        {
            float drawCoord = (int)(y * 2) % pieces;

            gl.Begin(BeginMode.Quads);
            {
                gl.TexCoord(drawCoord / pieces, 1);
                gl.Vertex(xpos * 0.5f - 1, y, 0);
                gl.TexCoord(drawCoord / pieces, 0);
                gl.Vertex(xpos * 0.5f - 1, y + 2 * Math.Sin(falling * Math.PI / 180), 2 * Math.Cos(falling * Math.PI / 180));
                gl.TexCoord((drawCoord + 1) / pieces, 0);
                gl.Vertex(xpos * 0.5f + 1, y + 2 * Math.Sin(falling * Math.PI / 180), 2 * Math.Cos(falling * Math.PI / 180));
                gl.TexCoord((drawCoord + 1) / pieces, 1);
                gl.Vertex(xpos * 0.5f + 1, y, 0);
            }
            gl.End();
        }
开发者ID:Celicath,项目名称:RRRR,代码行数:17,代码来源:Walker.cs

示例5: 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);
        }
开发者ID:Kruithne,项目名称:W3DT,代码行数:23,代码来源:Face.cs

示例6: RenderImmediateMode

        /// <summary>
        /// Renders the scene in immediate mode.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        public void RenderImmediateMode(OpenGL gl)
        {
            //  Setup the modelview matrix.
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.LoadIdentity();
            gl.MultMatrix(modelviewMatrix.to_array());

            //  Go through each group.
            foreach (var mesh in meshes)
            {
                var texture = meshTextures.ContainsKey(mesh) ? meshTextures[mesh] : null;
                if(texture != null)
                    texture.Bind(gl);

                uint mode = OpenGL.GL_TRIANGLES;
                if (mesh.indicesPerFace == 4)
                    mode = OpenGL.GL_QUADS;
                else if(mesh.indicesPerFace > 4)
                    mode = OpenGL.GL_POLYGON;

                //  Render the group faces.
                gl.Begin(mode);
                for (int i = 0; i < mesh.vertices.Length; i++ )
                {
                    gl.Vertex(mesh.vertices[i].x, mesh.vertices[i].y, mesh.vertices[i].z);
                    if(mesh.normals != null)
                        gl.Normal(mesh.normals[i].x, mesh.normals[i].y, mesh.normals[i].z);
                    if(mesh.uvs != null)
                        gl.TexCoord(mesh.uvs[i].x, mesh.uvs[i].y);
                }
                gl.End();

                if(texture != null)
                    texture.Unbind(gl);
            }
        }
开发者ID:BloofX,项目名称:sharpgl,代码行数:40,代码来源:Scene.cs

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

示例8: RecursiveRender

        private void RecursiveRender(Assimp.Scene scene, Node node, ref OpenGL gl)
        {
            Matrix4 m = FromMatrix(node.Transform);
            m.Transpose();
            gl.PushMatrix();
            gl.MultMatrix(FloatFromMatrix(m));

            if (node.HasMeshes)
            {
                foreach (int index in node.MeshIndices)
                {
                    Mesh mesh = scene.Meshes[index];
                    ApplyMaterial(m_model.Materials[mesh.MaterialIndex], ref gl);

                    if (mesh.HasNormals)
                    {

                        gl.Enable(OpenGL.GL_LIGHTING);
                    }
                    else
                    {
                        gl.Disable(OpenGL.GL_LIGHTING);
                    }

                    bool hasColors = mesh.HasVertexColors(0);
                    if (hasColors)
                    {
                        gl.Enable(OpenGL.GL_COLOR_MATERIAL);
                    }
                    else
                    {
                        gl.Disable(OpenGL.GL_COLOR_MATERIAL);
                    }

                    bool hasTexCoords = mesh.HasTextureCoords(0);

                    foreach (Assimp.Face face in mesh.Faces)
                    {
                        BeginMode faceMode;
                        switch (face.IndexCount)
                        {
                            case 1:
                                faceMode = BeginMode.Points;
                                break;
                            case 2:
                                faceMode = BeginMode.Lines;
                                break;
                            case 3:
                                faceMode = BeginMode.Triangles;
                                break;
                            default:
                                faceMode = BeginMode.Polygon;
                                break;
                        }

                        gl.Begin(faceMode);
                        for (int i = 0; i < face.IndexCount; i++)
                        {
                            int indice = face.Indices[i];
                            if (hasColors)
                            {
                                Color4 vertColor = FromColor(mesh.VertexColorChannels[0][indice]);
                                if (mesh.HasNormals)
                                {
                                    Vector3 normal = FromVector(mesh.Normals[indice]);
                                    gl.Normal(normal.X, normal.Y, normal.Z);
                                }
                                if (hasTexCoords)
                                {
                                    Vector3 uvw = FromVector(mesh.TextureCoordinateChannels[0][indice]);
                                    gl.TexCoord(uvw.X, 1 - uvw.Y);
                                }
                                Vector3 pos = FromVector(mesh.Vertices[indice]);
                                gl.Vertex(pos.X, pos.Y, pos.Z);
                            }
                            gl.End();
                        }
                    }
                }

                for (int i = 0; i < node.ChildCount; i++)
                {
                    RecursiveRender(m_model, node.Children[i], ref gl);
                }
            }
        }
开发者ID:EternalEnvy,项目名称:SmackBrosClient,代码行数:86,代码来源:GameplayScreen.cs

示例9: 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

示例10: Draw3DFlying

        public void Draw3DFlying(OpenGL gl)
        {
            double theta = (-flying * 50 + 45) * Math.PI / 180;
            float a = (float)(Math.Sqrt(2) * Math.Cos(theta));
            float b = (float)(Math.Sqrt(2) * Math.Sin(theta));

            gl.Begin(BeginMode.Quads);
            {
                gl.TexCoord(0, 1);
                gl.Vertex(xpos * 0.5f - a + flying, y, 1 - b + Math.Sqrt(Math.Abs(flying / 2)));
                gl.TexCoord(0, 0);
                gl.Vertex(xpos * 0.5f - b + flying, y, 1 + a + Math.Sqrt(Math.Abs(flying / 2)));
                gl.TexCoord(1, 0);
                gl.Vertex(xpos * 0.5f + a + flying, y, 1 + b + Math.Sqrt(Math.Abs(flying / 2)));
                gl.TexCoord(1, 1);
                gl.Vertex(xpos * 0.5f + b + flying, y, 1 - a + Math.Sqrt(Math.Abs(flying / 2)));
            }
            gl.End();
        }
开发者ID:Celicath,项目名称:RRRR,代码行数:19,代码来源:Walker.cs

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

示例12: Draw

 public virtual void Draw(OpenGL gl)
 {
     PointFloat[] pointData = RenderLogics.RectPoint(_pos, _size,_rot);
     _texture.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();
 }
开发者ID:Vinic,项目名称:TomatoEngine,代码行数:16,代码来源:GameObject.cs


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