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


C# Texture.Bind方法代码示例

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


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

示例1: Render

 public void Render(Texture terrainTexture)
 {
     gb.Render(() =>
     {
         terrainTexture.Bind(TextureUnit.Texture0);
     },
     (sp) =>
     {
         sp.SetUniform("terraintex", 0);
     });
 }
开发者ID:geofftnz,项目名称:snowscape,代码行数:11,代码来源:TerrainTileParamLoader.cs

示例2: Render

 public void Render(Texture heightmap)
 {
     gb.Render(() =>
     {
         heightmap.Bind(TextureUnit.Texture0);
     },
     (sp) =>
     {
         sp.SetUniform("heightmap", 0);
         sp.SetUniform("texsize", (float)heightmap.Width);
     });
 }
开发者ID:geofftnz,项目名称:snowscape,代码行数:12,代码来源:HeightmapNormalGenerator.cs

示例3: Render

 public void Render(Texture terrainTexture, float waterHeightScale = 1.0f)
 {
     gb.Render(() =>
     {
         terrainTexture.Bind(TextureUnit.Texture0);
     },
     (sp) =>
     {
         sp.SetUniform("terraintex", 0);
         sp.SetUniform("waterHeightScale", waterHeightScale);
     });
 }
开发者ID:geofftnz,项目名称:snowscape,代码行数:12,代码来源:TerrainGlobalLoader.cs

示例4: Render

 public void Render(Texture cloudTexture, Vector3 sunVector, Vector3 cloudScale)
 {
     gb.Render(() =>
     {
         cloudTexture.Bind(TextureUnit.Texture0);
     },
     (sp) =>
     {
         sp.SetUniform("cloudTexture", 0);
         sp.SetUniform("sunDirection", sunVector);
         sp.SetUniform("cloudScale", cloudScale);
     });
 }
开发者ID:geofftnz,项目名称:snowscape,代码行数:13,代码来源:CloudDepthRenderer.cs

示例5: Render

 public void Render(Texture heightmap, Texture shadowheight, Texture normalmap, Vector3 sunVector)
 {
     gb.Render(() =>
     {
         heightmap.Bind(TextureUnit.Texture0);
         shadowheight.Bind(TextureUnit.Texture1);
         normalmap.Bind(TextureUnit.Texture2);
     },
     (sp) =>
     {
         sp.SetUniform("heightTexture", 0);
         sp.SetUniform("shadowTexture", 1);
         sp.SetUniform("normalTexture", 2);
         sp.SetUniform("texsize", (float)heightmap.Width);
         sp.SetUniform("sunVector", sunVector);
     });
 }
开发者ID:geofftnz,项目名称:snowscape,代码行数:17,代码来源:IndirectIlluminationGenerator.cs

示例6: Render

        public void Render(Matrix4 projection, Matrix4 view, Vector3 eyePos, Texture skyCube)
        {
            Matrix4 invProjectionView = Matrix4.Invert(Matrix4.Mult(view, projection));

            GL.Disable(EnableCap.CullFace);
            GL.Enable(EnableCap.DepthTest);

            skyCube.Bind(TextureUnit.Texture0);

            this.program
                .UseProgram()
                .SetUniform("inverse_projectionview_matrix", invProjectionView)
                .SetUniform("eyePos", eyePos)
                .SetUniform("skyCube",0);
            this.vertexVBO.Bind(this.program.VariableLocation("vertex"));
            this.indexVBO.Bind();
            GL.DrawElements(BeginMode.Triangles, this.indexVBO.Length, DrawElementsType.UnsignedInt, 0);
        }
开发者ID:geofftnz,项目名称:snowscape,代码行数:18,代码来源:SkyCubeRenderer.cs

示例7: openGLControl1_OpenGLInitialized

        /// <summary>
        /// Handles the OpenGLInitialized event of the openGLControl1 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void openGLControl1_OpenGLInitialized(object sender, EventArgs e)
        {
            //  Get OpenGL.
            var gl = openGLControl1.OpenGL;

            //  Load identity modelview.
            gl.MatrixMode(MatrixMode.Modelview);
            gl.LoadIdentity();

            //  Shading states
            gl.ShadeModel(ShadeModel.Smooth);
            gl.ClearColor(1f, 1f, 1f, 0.0f);
            gl.Color(1.0f, 1.0f, 1.0f, 1.0f);
            gl.Hint(HintTarget.PerspectiveCorrection, HintMode.Nicest);
            gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL);
            
            //  Depth states
            gl.ClearDepth(1.0f);
            gl.DepthFunc(DepthFunction.LessThanOrEqual);
            gl.Enable(OpenGL.GL_DEPTH_TEST);

            //  Enable cull face.
            gl.Enable(OpenGL.GL_CULL_FACE);

            //  Load decal texture
            decalImage = new Texture();
            decalImage.Create(gl, "decal.bmp");
            decalImage.Bind(gl);
            gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MAG_FILTER, OpenGL.GL_LINEAR);
            gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MIN_FILTER, OpenGL.GL_LINEAR);
            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);

            //  Load normal map
            normalMap = new Texture();
            normalMap.Create(gl, "Normal map.bmp");
            normalMap.Bind(gl);
            gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MAG_FILTER, OpenGL.GL_LINEAR);
            gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MIN_FILTER, OpenGL.GL_LINEAR);
            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);

            //  Create normalisation cube map
            uint[] textures = new uint[1];
            gl.GenTextures(1, textures);
            normalisationCubeMap = textures[0];
    
            //  Bind and generate the normalisation cube map.
            gl.BindTexture(OpenGL.GL_TEXTURE_CUBE_MAP, normalisationCubeMap);
            GenerateNormalisationCubeMap();

            //  Set the cube map parameters.

            //  Extensions: Note - you can use the old fasioned extension name (as below)...
            gl.TexParameter(OpenGL.GL_TEXTURE_CUBE_MAP_EXT, OpenGL.GL_TEXTURE_MAG_FILTER, OpenGL.GL_LINEAR);
            gl.TexParameter(OpenGL.GL_TEXTURE_CUBE_MAP_EXT, OpenGL.GL_TEXTURE_MIN_FILTER, OpenGL.GL_LINEAR);

            //  Extensions: ...or the standard OpenGL name. For example, EXT_Texture_Cube_Map
            //  became standard in OpenGL 1.3 - but we still have the old fasioned extension functions,
            //  constants etc.
            gl.TexParameter(OpenGL.GL_TEXTURE_CUBE_MAP, OpenGL.GL_TEXTURE_WRAP_S, OpenGL.GL_CLAMP_TO_EDGE);
            gl.TexParameter(OpenGL.GL_TEXTURE_CUBE_MAP, OpenGL.GL_TEXTURE_WRAP_T, OpenGL.GL_CLAMP_TO_EDGE);
            gl.TexParameter(OpenGL.GL_TEXTURE_CUBE_MAP, OpenGL.GL_TEXTURE_WRAP_R, OpenGL.GL_CLAMP_TO_EDGE);
        }
开发者ID:mind0n,项目名称:hive,代码行数:69,代码来源:ExtensionsSampleForm.cs

示例8: DrawTexture

        public static void DrawTexture(Texture texture, float x, float y, float z, float width, float height, int sx, int sy, int sw, int sh, Color4 color)
        {
            float textX = (float)sx / texture.GetWidth();
            float textY = (float)sy / texture.GetHeight();
            float textW = (float)sw / texture.GetWidth();
            float textH = (float)sh / texture.GetHeight();

            if (textX != _texturePosition.X || textY != _texturePosition.Y || textW != _textureDimension.X || textH != _textureDimension.Y)
            {
                _texturePosition.X = textX;
                _texturePosition.Y = textY;
                _textureDimension.X = textW;
                _textureDimension.Y = textH;
                _texCoordsChanged = true;
            }

            texture.Bind();
            SetColor(color);

            RenderQuad(x, y, z, width, height);
        }
开发者ID:jikoriko,项目名称:OpentkEngine,代码行数:21,代码来源:Graphics.cs

示例9: DrawSkinnedRectangle

        private void DrawSkinnedRectangle(float x, float y, float z, float width, float length, float height,
            int topSkinX, int topSkinY, int topSkinW, int topSkinH,
            Texture texture, int skinW = 64, int skinH = 32)
        {
            texture.Bind();

            GL.Begin(BeginMode.Quads);

            width /= 2;
            length /= 2;
            height /= 2;

            float tsX = (float) topSkinX / skinW;
            float tsY = (float) topSkinY / skinH;
            float tsW = (float) topSkinW / skinW;
            float tsH = (float) topSkinH / skinH;

            GL.TexCoord2(tsX, tsY + tsH - 0.00005);
            GL.Vertex3(x - width, y + length, z + height); // Bottom Right Of The Quad (Top)
            GL.TexCoord2(tsX + tsW - 0.00005, tsY + tsH - 0.00005);
            GL.Vertex3(x + width, y + length, z + height); // Bottom Left Of The Quad (Top)
            GL.TexCoord2(tsX + tsW - 0.00005, tsY);
            GL.Vertex3(x + width, y + length, z - height); // Top Left Of The Quad (Top)
            GL.TexCoord2(tsX, tsY);
            GL.Vertex3(x - width, y + length, z - height); // Top Right Of The Quad (Top)

            GL.End();
        }
开发者ID:rmbzlib,项目名称:mcskin3d,代码行数:28,代码来源:Editor.cs

示例10: DrawPlayer2D

        private void DrawPlayer2D(Texture tex, Skin skin, bool pickView)
        {
            if (!pickView && GlobalSettings.AlphaCheckerboard)
            {
                _alphaTex.Bind();

                GL.Begin(BeginMode.Quads);
                GL.TexCoord2(0, 0);
                GL.Vertex2(0, 0);
                GL.TexCoord2(_currentViewport.Width / 16.0f, 0);
                GL.Vertex2(_currentViewport.Width, 0);
                GL.TexCoord2(_currentViewport.Width / 16.0f, _currentViewport.Height / 16.0f);
                GL.Vertex2(_currentViewport.Width, _currentViewport.Height);
                GL.TexCoord2(0, _currentViewport.Height / 16.0f);
                GL.Vertex2(0, _currentViewport.Height);
                GL.End();
            }

            if (skin != null)
                tex.Bind();

            GL.PushMatrix();

            GL.Translate((_2DCamOffsetX), (_2DCamOffsetY), 0);
            GL.Translate((_currentViewport.Width / 2) + -_2DCamOffsetX, (_currentViewport.Height / 2) + -_2DCamOffsetY, 0);
            GL.Scale(_2DZoom, _2DZoom, 1);

            if (pickView)
                GL.Disable(EnableCap.Blend);
            else
                GL.Enable(EnableCap.Blend);

            GL.Translate((_2DCamOffsetX), (_2DCamOffsetY), 0);
            if (skin != null)
            {
                float w = skin.Width;
                float h = skin.Height;
                GL.Begin(BeginMode.Quads);
                GL.TexCoord2(0, 0);
                GL.Vertex2(-(CurrentModel.DefaultWidth / 2), -(CurrentModel.DefaultHeight / 2));
                GL.TexCoord2(1, 0);
                GL.Vertex2((CurrentModel.DefaultWidth / 2), -(CurrentModel.DefaultHeight / 2));
                GL.TexCoord2(1, 1);
                GL.Vertex2((CurrentModel.DefaultWidth / 2), (CurrentModel.DefaultHeight / 2));
                GL.TexCoord2(0, 1);
                GL.Vertex2(-(CurrentModel.DefaultWidth / 2), (CurrentModel.DefaultHeight / 2));
                GL.End();
            }

            if (!pickView)
            {
                TextureGL.Unbind();

                if (GlobalSettings.GridEnabled && GlobalSettings.DynamicOverlayGridColor.A > 0)
                {
                    GL.Color4(GlobalSettings.DynamicOverlayGridColor);
                    GL.PushMatrix();
                    GL.Translate(-(CurrentModel.DefaultWidth / 2), -(CurrentModel.DefaultHeight / 2), 0);
                    GL.Begin(BeginMode.Lines);

                    float wX = skin.Width / CurrentModel.DefaultWidth;
                    float wY = skin.Height / CurrentModel.DefaultHeight;

                    for (int i = 0; i <= skin.Width; ++i)
                    {
                        GL.Vertex2(i / wX, 0);
                        GL.Vertex2(i / wX, skin.Height / wY);
                    }

                    for (int i = 0; i <= skin.Height; ++i)
                    {
                        GL.Vertex2(0, i / wY);
                        GL.Vertex2(skin.Width / wX, i / wY);
                    }

                    GL.End();
                    GL.PopMatrix();
                }

                if (GlobalSettings.TextureOverlay && skin != null)
                {
                    if (_backgrounds[_selectedBackground] == _dynamicOverlay)
                    {
                        GL.PushMatrix();
                        GL.Translate(-(CurrentModel.DefaultWidth / 2), -(CurrentModel.DefaultHeight / 2), 0);

                        float stub = (GlobalSettings.DynamicOverlayLineSize / _2DZoom);
                        float one = (1.0f / _2DZoom);

                        var done = new List<RectangleF>();
                        foreach (Mesh mesh in CurrentModel.Meshes)
                        {
                            foreach (Face face in mesh.Faces)
                            {
                                RectangleF toint = face.TexCoordsToFloat((int) CurrentModel.DefaultWidth, (int) CurrentModel.DefaultHeight);

                                if (toint.Width == 0 ||
                                    toint.Height == 0)
                                    continue;
                                if (done.Contains(toint))
//.........这里部分代码省略.........
开发者ID:rmbzlib,项目名称:mcskin3d,代码行数:101,代码来源:Editor.cs

示例11: DrawCharacter2D

        private void DrawCharacter2D(Texture font, byte c, float xOfs, float yOfs, float width, float height)
        {
            font.Bind();

            float tx = (((c - 32) % 16) * 8) / 128.0f;
            float ty = (((c - 32) / 16) * 8) / 64.0f;
            const float txw = 8.0f / 128.0f;
            const float txh = 8.0f / 64.0f;

            GL.Begin(BeginMode.Quads);
            GL.TexCoord2(tx, ty);
            GL.Vertex2(xOfs, yOfs);
            GL.TexCoord2(tx + txw, ty);
            GL.Vertex2(xOfs + width, yOfs);
            GL.TexCoord2(tx + txw, ty + txh);
            GL.Vertex2(xOfs + width, height + yOfs);
            GL.TexCoord2(tx, ty + txh);
            GL.Vertex2(xOfs, height + yOfs);
            GL.End();
        }
开发者ID:rmbzlib,项目名称:mcskin3d,代码行数:20,代码来源:Editor.cs

示例12: SetCurrentTexture

            public void SetCurrentTexture( Texture texture )
            {
                CurrentTexture = texture;

                GL.ActiveTexture( TextureUnit );
                CurrentTexture.Bind();
            }
开发者ID:vashage,项目名称:SA-World-Viewer,代码行数:7,代码来源:ShaderProgram.cs

示例13: Render

 public void Render(Texture inputHeightTexture, Texture inputParamTexture)
 {
     gb.Render(() =>
     {
         inputHeightTexture.Bind(TextureUnit.Texture0);
         inputParamTexture.Bind(TextureUnit.Texture1);
     },
     (sp) =>
     {
         sp.SetUniform("heightTex", 0);
         sp.SetUniform("paramTex", 1);
         sp.SetUniform("texsize", (float)inputHeightTexture.Width);
         sp.SetUniform("invtexsize", 1.0f/(float)inputHeightTexture.Width);
         sp.SetUniform("position", Position);
     });
 }
开发者ID:geofftnz,项目名称:snowscape,代码行数:16,代码来源:DetailGenerator.cs


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