Skip to content

Textures

SMG edited this page Jun 16, 2019 · 3 revisions

Texture Format Basics

How the raw image data is structured is largely irrelevant. OpenGL will assume the provided data is of the given format and dimensions and attempt to read it as such. Provided correct format information is critical to ensure textures load and render correctly. For beginners, it's recommended to use the Bitmap class provided by C#, as this allows for loading from jpeg, png, and tiff.

Loading compressed or uncompressed formats requires separate LoadImageData methods. Attempting to use a compressed format for the uncompressed load method and vice versa will throw an exception. Note that the format enums for OpenTK don't make this distinction.

Compressed Formats

Uncompressed Formats

Loading Texture Data

Loading texture data in SFGraphics work in a very similar fashion to buffers. The raw binary data can be structured into an array of any struct as long as the provided dimensions and format are correct. The type T for LoadImageData will most likely be byte for files read from disk. Additional methods for loading from the Bitmap class are also provided.

Clone this wiki locally