hi
This commit is contained in:
parent
83314c848f
commit
740b631d44
6 changed files with 119 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,6 +1,5 @@
|
|||
.cache/
|
||||
.session.vim
|
||||
gear
|
||||
*.exe
|
||||
compile_commands.json
|
||||
**/*.o
|
||||
|
|
26
include/gear/base.h
Normal file
26
include/gear/base.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef __G_BASE_H__
|
||||
#define __G_BASE_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
#include <slibs/slibs.h>
|
||||
|
||||
typedef uint8_t u8;
|
||||
typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
typedef uint64_t u64;
|
||||
|
||||
typedef int8_t i8;
|
||||
typedef int16_t i16;
|
||||
typedef int32_t i32;
|
||||
typedef int64_t i64;
|
||||
|
||||
typedef size_t sz;
|
||||
|
||||
typedef float f32;
|
||||
typedef double f64;
|
||||
|
||||
#endif
|
27
include/gear/graphics/color.h
Normal file
27
include/gear/graphics/color.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
#ifndef __G_COLOR_H__
|
||||
#define __G_COLOR_H__
|
||||
|
||||
#include <gear/base.h>
|
||||
|
||||
typedef struct g_color {
|
||||
u8 r;
|
||||
u8 g;
|
||||
u8 b;
|
||||
u8 a;
|
||||
} g_color;
|
||||
|
||||
#define G_COLOR_TO_FLOAT_ARR(color) { color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f }
|
||||
#define G_FLOAT_ARR_TO_COLOR(float) { (u8)(float[0] * 255), (u8)(float[1] * 255), (u8)(float[2] * 255), (u8)(float[3] * 255) }
|
||||
|
||||
#define G_WHITE { 255, 255, 255, 255 }
|
||||
#define G_BLACK { 0, 0, 0, 255 }
|
||||
|
||||
#define G_RED { 255, 0, 0, 255 }
|
||||
#define G_GREEN { 0, 255, 0, 255 }
|
||||
#define G_BLUE { 0, 0, 255, 255 }
|
||||
|
||||
#define G_YELLOW { 255, 255, 0, 255 }
|
||||
#define G_CYAN { 0, 255, 255, 255 }
|
||||
#define G_MAGENTA { 255, 0, 255, 255 }
|
||||
|
||||
#endif
|
20
include/gear/graphics/renderer.h
Normal file
20
include/gear/graphics/renderer.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef __G_RENDERER_H__
|
||||
#define __G_RENDERER_H__
|
||||
|
||||
#include <gear/base.h>
|
||||
#include <gear/graphics/color.h>
|
||||
#include <sokol/sokol_gfx.h>
|
||||
|
||||
typedef struct g_renderer {
|
||||
sg_pass_action pass_action;
|
||||
} g_renderer;
|
||||
|
||||
typedef struct g_renderer_object {
|
||||
sg_bindings bind;
|
||||
sg_pipeline pipeline;
|
||||
} g_renderer_object;
|
||||
|
||||
// src/graphics/renderer/create.c
|
||||
g_renderer g_renderer_create(g_color clear_color);
|
||||
|
||||
#endif
|
29
include/gear/images.h
Normal file
29
include/gear/images.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef __G_IMAGES_H__
|
||||
#define __G_IMAGES_H__
|
||||
|
||||
#include <gear/base.h>
|
||||
|
||||
#define G_IMAGE_CHANNELS 4
|
||||
|
||||
#define G_IMAGE_MISSING_PIXELS (u8*)(u32[4]){ 0xFFFF00FF, 0xFF000000, 0xFF000000, 0xFFFF00FF }
|
||||
#define G_IMAGE_MISSING_DIMENSIONS 2
|
||||
#define G_IMAGE_MISSING_BYTESIZE sizeof(u32) * (G_IMAGE_MISSING_DIMENSIONS * G_IMAGE_MISSING_DIMENSIONS)
|
||||
|
||||
typedef struct g_image {
|
||||
i32 width;
|
||||
i32 height;
|
||||
i32 channels;
|
||||
u8* pixels;
|
||||
} g_image;
|
||||
|
||||
// src/images/create.c
|
||||
g_image* g_image_create(u8* pixels, i32 width, i32 height);
|
||||
g_image* g_image_default();
|
||||
|
||||
// src/images/load.c
|
||||
g_image* g_image_load(const char* filename);
|
||||
|
||||
// src/images/destroy.c
|
||||
void g_image_free(g_image* image);
|
||||
|
||||
#endif
|
17
include/gear/textures.h
Normal file
17
include/gear/textures.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef __G_TEXTURES_H__
|
||||
#define __G_TEXTURES_H__
|
||||
|
||||
#include <gear/base.h>
|
||||
#include <gear/images.h>
|
||||
|
||||
#include <sokol/sokol_gfx.h>
|
||||
|
||||
typedef struct g_texture {
|
||||
sg_image image;
|
||||
sg_sampler sampler;
|
||||
} g_texture;
|
||||
|
||||
// src/textures/create.c
|
||||
g_texture* g_texture_create(g_image* image);
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue