GoldFish Engine
Quite simple and lightweight game engine
Loading...
Searching...
No Matches
gf_texture.c
1#define GF_EXPOSE_TEXTURE
2#define GF_EXPOSE_DRAW_DRIVER
3
4#include <gf_pre.h>
5
6/* External library */
7
8/* Interface */
9#include <gf_texture.h>
10
11/* Engine */
12#include <gf_draw_driver.h>
13
14/* Standard */
15#include <stdlib.h>
16
17gf_texture_t* gf_texture_create(gf_draw_t* draw, int width, int height, unsigned char* data) {
18 gf_texture_t* texture = malloc(sizeof(*texture));
19 gf_draw_driver_texture_t* ddtexture;
20 texture->internal_width = width;
21 texture->internal_height = height;
22 ddtexture = gf_draw_driver_register_texture(draw, width, height, &texture->internal_width, &texture->internal_height, data);
23 if(ddtexture == NULL) {
24 free(texture);
25 return NULL;
26 }
27 texture->width = width;
28 texture->height = height;
29 texture->draw_driver_texture = ddtexture;
30 return texture;
31}
32
33void gf_texture_destroy(gf_texture_t* texture) {
34 gf_draw_driver_destroy_texture(texture->draw_driver_texture);
35 free(texture);
36}
Drawing driver.
Required headers before anything.
Texture.
Driver-dependent texture.
Definition draw_driver.h:56
Drawing interface.
Definition draw.h:101
Texture.
Definition texture.h:47
int internal_width
Internal width of texture.
Definition texture.h:47
int internal_height
Internal height of texture.
Definition texture.h:47
gf_draw_driver_texture_t * draw_driver_texture
Driver-dependent texture.
Definition texture.h:47
int height
Height of texture.
Definition texture.h:47
int width
Width of texture.
Definition texture.h:47