Textures - sarahmss/Cub3d GitHub Wiki
To add textures in our world we will use a technique called texture mapping where we will be painting a bitmap/texture onto a surface. Here,a two-dimensional (2-D) surface, called a texture map, is "wrapped around" a three-dimensional "3D" object. Texture mapping is the electronic equivalent of applying wallpaper, paint,or veneer to a real object [1]. On the ray-casting world that we are creating, texture mapping is just a matter of scaling a slice (a column) of bitmap.
X PixMap (XPM) is an image file format used by the X Window System[2]
First of all, to read from a file to a image object, you need either the XMP or PNG format. In order to read we can call the functions mlx_xpm_file_to_image and mlx_png_file_to_image accordingly. Both functions accept exactly the same parameters and their usage is identical. If the img variable is equal to NULL, it means that the image reading has failed. It will also set the img_width and img_height accordingly, which is ideal when reading sprites.[4]
minlibx functions | Definition |
---|---|
mlx_xpm_file_to_image | Converts an xpm file to a new image instance. |
mlx_xpm_to_image | Converts xpm data to a new image instance. |
- [1] texture-mapping
- [2] X pix map
- [3] ray-casting-tutorial-10
- [4] images