added image type, and integer types
This commit is contained in:
parent
1fa6361401
commit
cfb2fb2ea1
|
@ -0,0 +1,8 @@
|
|||
#ifndef GUARD_99E25E7F8183EF0D8D27390EBC173C04
|
||||
#define GUARD_99E25E7F8183EF0D8D27390EBC173C04
|
||||
|
||||
#include "types.h"
|
||||
|
||||
typedef u32 color32;
|
||||
|
||||
#endif /* GUARD_99E25E7F8183EF0D8D27390EBC173C04 */
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef GUARD_413D576D943A16C984254F2FA4BB5B91
|
||||
#define GUARD_413D576D943A16C984254F2FA4BB5B91
|
||||
|
||||
struct image32 {};
|
||||
|
||||
#endif /* GUARD_413D576D943A16C984254F2FA4BB5B91 */
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef GUARD_9C1995B9551EFCCDC93F439C46AEF061
|
||||
#define GUARD_9C1995B9551EFCCDC93F439C46AEF061
|
||||
|
||||
void sw_init();
|
||||
|
||||
#endif /* GUARD_9C1995B9551EFCCDC93F439C46AEF061 */
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef GUARD_649E63003BEAE79ECA2B813C4E131C9A
|
||||
#define GUARD_649E63003BEAE79ECA2B813C4E131C9A
|
||||
|
||||
typedef signed char i8;
|
||||
typedef unsigned char u8;
|
||||
typedef signed short i16;
|
||||
typedef unsigned short u16;
|
||||
typedef signed int i32;
|
||||
typedef unsigned int u32;
|
||||
typedef signed long long i64;
|
||||
typedef unsigned long long u64;
|
||||
typedef float f32;
|
||||
typedef double f64;
|
||||
|
||||
#endif /* GUARD_649E63003BEAE79ECA2B813C4E131C9A */
|
|
@ -13,4 +13,6 @@ struct window {
|
|||
|
||||
struct window *sw_window_create(struct vec2i size, char *title);
|
||||
|
||||
void sw_window_run(struct window *window);
|
||||
|
||||
#endif /* GUARD_F247452E0BF1EC9CD9131C2A6FD281CA */
|
||||
|
|
|
@ -40,6 +40,8 @@ else
|
|||
endif
|
||||
|
||||
skunk_sources = [
|
||||
'src/color32.c',
|
||||
'src/image32.c',
|
||||
'src/skunkworks.c',
|
||||
'src/test.c',
|
||||
'src/vec2i.c',
|
||||
|
|
|
@ -1,5 +1,26 @@
|
|||
#include "skunkworks.h"
|
||||
|
||||
int aaa(void) {
|
||||
return 0;
|
||||
#include <assert.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
void assert_types();
|
||||
|
||||
void sw_init() {
|
||||
assert_types();
|
||||
}
|
||||
|
||||
/* private */
|
||||
|
||||
void assert_types() {
|
||||
assert(sizeof(i8) == 1);
|
||||
assert(sizeof(u8) == 1);
|
||||
assert(sizeof(i16) == 2);
|
||||
assert(sizeof(u16) == 2);
|
||||
assert(sizeof(i32) == 4);
|
||||
assert(sizeof(u32) == 4);
|
||||
assert(sizeof(i64) == 8);
|
||||
assert(sizeof(u64) == 8);
|
||||
assert(sizeof(f32) == 4);
|
||||
assert(sizeof(f64) == 8);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef GUARD_BAEE408B8F416CA55711305ABAF9CE6C
|
||||
#define GUARD_BAEE408B8F416CA55711305ABAF9CE6C
|
||||
|
||||
#endif /* GUARD_BAEE408B8F416CA55711305ABAF9CE6C */
|
20
src/test.c
20
src/test.c
|
@ -3,32 +3,18 @@
|
|||
#include "window.h"
|
||||
#include <png.h>
|
||||
|
||||
#include "gl.h"
|
||||
#include <skunkworks.h>
|
||||
|
||||
struct window *win;
|
||||
|
||||
void tick();
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
sw_init();
|
||||
printf("hello world\n");
|
||||
win = sw_window_create(sw_vec2i(640, 480), "Skunkworks");
|
||||
png_sig_cmp(0, 0, 0);
|
||||
glClearColor(0.1f, 0.2f, 0.3f, 1.f);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(tick, 0, 1);
|
||||
#else
|
||||
while (!glfwWindowShouldClose(win->_window)) {
|
||||
tick();
|
||||
}
|
||||
#endif
|
||||
|
||||
sw_window_run(win);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tick() {
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glfwSwapBuffers(win->_window);
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
|
23
src/window.c
23
src/window.c
|
@ -4,6 +4,9 @@
|
|||
|
||||
#include "gl.h"
|
||||
|
||||
void tick();
|
||||
struct window *tick_window;
|
||||
|
||||
struct window *sw_window_create(struct vec2i size, char *title) {
|
||||
struct window *win;
|
||||
|
||||
|
@ -22,5 +25,25 @@ struct window *sw_window_create(struct vec2i size, char *title) {
|
|||
glEnable(GL_BLEND);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glClearColor(0.1f, 0.2f, 0.3f, 1.f);
|
||||
return win;
|
||||
}
|
||||
|
||||
void sw_window_run(struct window *window) {
|
||||
tick_window = window;
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(tick, 60, 1);
|
||||
#else
|
||||
while (!glfwWindowShouldClose(window->_window)) {
|
||||
tick();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* private functions */
|
||||
|
||||
void tick() {
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glfwSwapBuffers(tick_window->_window);
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue