Opentk/Source/Examples/OpenGL/1.x/Textures.rtf

25 lines
1.7 KiB
Plaintext
Raw Normal View History

2010-10-02 18:52:34 +00:00
{\rtf1\ansi\ansicpg1253\deff0{\fonttbl{\f0\fnil\fcharset0 Arial;}}
{\colortbl ;\red163\green21\blue21;}
{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\cf1\lang1033\b\fs28 Introduction\b0\fs22\par
\par
This sample demonstrates how to load and display a simple texture.\par
\b\fs28\par
Controls\par
\b0\fs22\par
Press Esc or click the close button to exit.\par
\par
\b\fs28 Implementation\par
\b0\fs22\par
1. The OnLoad event handler constructs a new texture object with GL.GenTextures(). It then uses System.Drawing.Bitmap to load an image from the hard drive and uploads the image data to OpenGL via GL.TexImage2D().\par
\par
2. The OnRenderFrame event handler uses immediate mode to render a simple textured quad.\par
\par
Note 1: System.Drawing.Bitmap stores its image data in BGRA order. This means we must use Bgra as our PixelFormat in GL.TexImage2D().\par
\par
Note 2: In GL.TexImage2D(), PixelInternalFormat defines the storage format of texels ("texel elements") in video memory. PixelFormat defines the format of the image data we will upload to video memory. If these do not match, OpenGL will automatically convert our image data from PixelFormat to PixelInternalFormat, which will incure a slight performance penalty.\par
\par
Note 3: In this sample, we explicitly disable mipmaps by setting TextureMinFilter to Linear (via GL.TexParameter()). Alternatively, we could enable mipmaps (set TextureMinFilter to LinearMipmapNearest or LinearMipmapLinear) and generate mipmaps for our source image using GL.GenerateMipmap().\par
\par
Note 4: Do not forget to enable texturing via GL.Enable(EnableCap.Texture2D) prior to rendering. Without this, textures will show up white!\par
}