MLX42 1.0
MLX42
Loading...
Searching...
No Matches
mlx_texture.c File Reference
#include "MLX42/MLX42_Int.h"
Include dependency graph for mlx_texture.c:

Go to the source code of this file.

Functions

mlx_image_tmlx_texture_to_image (mlx_t *mlx, mlx_texture_t *texture)
 
void mlx_delete_texture (mlx_texture_t *texture)
 

Function Documentation

◆ mlx_delete_texture()

void mlx_delete_texture ( mlx_texture_t texture)

Deletes a texture by freeing its allocated data.

Parameters
[in]textureThe texture to free.

Definition at line 37 of file mlx_texture.c.

38{
40
41 mlx_freen(2, texture->pixels, texture);
42}
#define MLX_NONNULL(var)
Definition MLX42_Int.h:46
bool mlx_freen(int32_t count,...)
Definition mlx_utils.c:89
GLuint texture
Definition glad.h:2899
Here is the call graph for this function:

◆ mlx_texture_to_image()

mlx_image_t * mlx_texture_to_image ( mlx_t mlx,
mlx_texture_t texture 
)

Converts a given texture to an image.

Parameters
[in]mlxThe MLX instance handle.
[in]textureThe texture to use to create the image from.
Returns
mlx_image_t* The image created from the texture.

Definition at line 17 of file mlx_texture.c.

18{
21
23 if (image == NULL)
24 return (NULL);
25
28 for (uint32_t i = 0; i < texture->height; i++)
29 {
30 pixelx = &texture->pixels[(i * texture->width) * texture->bytes_per_pixel];
31 pixeli = &image->pixels[(i * image->width) * texture->bytes_per_pixel];
32 memmove(pixeli, pixelx, texture->width * texture->bytes_per_pixel);
33 }
34 return (image);
35}
mlx_image_t * mlx_new_image(mlx_t *mlx, uint32_t width, uint32_t height)
Definition mlx_images.c:161
GLenum GLenum GLsizei void * image
Definition glad.h:5132
GLuint GLsizei GLsizei * length
Definition glad.h:3372
Definition MLX42.h:361
int32_t width
Definition MLX42.h:364
Here is the call graph for this function: