예제 #1
0
        /// <summary>
        /// Initialise and load a texture.
        /// </summary>
        private void InitAndLoadTexture()
        {
            // tell the graphics card what texture we are working with.
            GL.BindTexture(TextureTarget.Texture2D, m_Texture1);

            // set filtering and wrapping options.
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);

            // load the image data into the texture target.
            byte[] imgdata;
            EmbeddedResourceHelper.GetEmbeddedFileAsBytes(Assembly.GetExecutingAssembly(), "texturedemo.bmp", out imgdata);

            unsafe
            {
                fixed(byte *p = imgdata)
                {
                    GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb, 256, 256, 0, PixelFormat.Rgb, PixelType.UnsignedByte, (IntPtr)p);
                }
            }
        }