core.gfx.texture¶
Texture allocation and the core pixel-buffer type.
Overview¶
core.gfx.texture defines the TTexture record that represents a 2D pixel buffer, and provides the newTexture factory function to allocate one from the kernel heap. Textures are used by the TGA image parser (core.fmt.targa), the kernel panic screen, and any other subsystem that needs to hold a rectangular BGRA pixel array.
Dependencies¶
memory.heap—kalloccore.gfx.color—TRGB32,PRGB32
Types¶
TTexture / PTexture¶
A 2D pixel buffer.Width— image width in pixels.Height— image height in pixels.Size— total pixel count (Width * Height).Pixels— pointer to a contiguous heap-allocated array ofTRGB32pixels in row-major order (row 0 first, left to right within each row).
Functions and Procedures¶
newTexture¶
Allocates a newTTexture and its associated Pixels buffer of width * height * sizeof(TRGB32) bytes. Both the structure and the pixel buffer are allocated from the kernel heap. Returns a pointer to the initialised TTexture. The pixel buffer is not zeroed; callers should write all pixels before reading.
Notes¶
There is no freeTexture function. Callers that need to release a texture must call kfree on Texture^.Pixels and then kfree on the TTexture pointer itself.
The pixel buffer layout is BGRA, matching the TRGB32 type defined in core.gfx.color. Pixel at coordinates (x, y) is at Pixels[y * Width + x].