Compare commits
2 commits
1db8d530c5
...
6e9ca865f9
Author | SHA1 | Date | |
---|---|---|---|
6e9ca865f9 | |||
832120d335 |
5 changed files with 8048 additions and 11 deletions
3
Makefile
3
Makefile
|
@ -2,7 +2,7 @@ BINARY=gear
|
||||||
|
|
||||||
SHADERC=sokol-shdc
|
SHADERC=sokol-shdc
|
||||||
|
|
||||||
CFLAGS=-I. -Iinclude -Wall -Wextra -Werror -Wno-header-guard -std=c99
|
CFLAGS=-I. -Iinclude -Wall -Wextra -Werror -Wno-header-guard
|
||||||
SHADER_FLAGS=--slang glsl430:hlsl5:metal_macos
|
SHADER_FLAGS=--slang glsl430:hlsl5:metal_macos
|
||||||
|
|
||||||
C_FILES=$(shell find -L * -type f -name '*.c')
|
C_FILES=$(shell find -L * -type f -name '*.c')
|
||||||
|
@ -18,6 +18,7 @@ else
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
ifeq ($(UNAME_S), Linux)
|
ifeq ($(UNAME_S), Linux)
|
||||||
CFLAGS += -DSOKOL_GLCORE
|
CFLAGS += -DSOKOL_GLCORE
|
||||||
|
LDFLAGS += $(shell pkg-config --libs x11 xi xcursor gl) -ldl -pthread -lm -lasound
|
||||||
endif
|
endif
|
||||||
ifeq ($(UNAME_S), Darwin)
|
ifeq ($(UNAME_S), Darwin)
|
||||||
CFLAGS += -DSOKOL_METAL
|
CFLAGS += -DSOKOL_METAL
|
||||||
|
|
BIN
happi.jpg
Normal file
BIN
happi.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
38
include/stb/LICENSE
Normal file
38
include/stb/LICENSE
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
This software is available under 2 licenses -- choose whichever you prefer.
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
ALTERNATIVE A - MIT License
|
||||||
|
Copyright (c) 2017 Sean Barrett
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||||
|
This is free and unencumbered software released into the public domain.
|
||||||
|
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||||
|
software, either in source code form or as a compiled binary, for any purpose,
|
||||||
|
commercial or non-commercial, and by any means.
|
||||||
|
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||||
|
software dedicate any and all copyright interest in the software to the public
|
||||||
|
domain. We make this dedication for the benefit of the public at large and to
|
||||||
|
the detriment of our heirs and successors. We intend this dedication to be an
|
||||||
|
overt act of relinquishment in perpetuity of all present and future rights to
|
||||||
|
this software under copyright law.
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
7988
include/stb/stb_image.h
Normal file
7988
include/stb/stb_image.h
Normal file
File diff suppressed because it is too large
Load diff
30
src/main.c
30
src/main.c
|
@ -5,6 +5,11 @@
|
||||||
#include <slibs/slibs.h>
|
#include <slibs/slibs.h>
|
||||||
#include <HandmadeMath/HandmadeMath.h>
|
#include <HandmadeMath/HandmadeMath.h>
|
||||||
|
|
||||||
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
|
#include <stb/stb_image.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <shaders/transform.glsl.h>
|
#include <shaders/transform.glsl.h>
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
@ -26,9 +31,9 @@ static void init(void) {
|
||||||
});
|
});
|
||||||
|
|
||||||
vertex_t vertices[] = {
|
vertex_t vertices[] = {
|
||||||
{ 1.0f, 1.0f, 0.0f, 0xFFFF0000, 1.0f * 32767, 1.0f * 32767 }, // top right
|
{ 1.0f, 1.0f, 0.0f, 0xFFFFFFFF, 1.0f * 32767, 1.0f * 32767 }, // top right
|
||||||
{ 1.0f, -1.0f, 0.0f, 0xFF00FF00, 1.0f * 32767, 0.0f * 32767 }, // bottom right
|
{ 1.0f, -1.0f, 0.0f, 0xFFFFFFFF, 1.0f * 32767, 0.0f * 32767 }, // bottom right
|
||||||
{ -1.0f, -1.0f, 0.0f, 0xFF0000FF, 0.0f * 32767, 0.0f * 32767 }, // bottom left
|
{ -1.0f, -1.0f, 0.0f, 0xFFFFFFFF, 0.0f * 32767, 0.0f * 32767 }, // bottom left
|
||||||
{ -1.0f, 1.0f, 0.0f, 0xFFFFFFFF, 0.0f * 32767, 1.0f * 32767 } // top left
|
{ -1.0f, 1.0f, 0.0f, 0xFFFFFFFF, 0.0f * 32767, 1.0f * 32767 } // top left
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -50,19 +55,21 @@ static void init(void) {
|
||||||
.label = "triangle-indices"
|
.label = "triangle-indices"
|
||||||
});
|
});
|
||||||
|
|
||||||
uint32_t pixels[2*2] = {
|
int desired_channels = 4;
|
||||||
0xFFFFFFFF, 0xFF222222,
|
int width, height, channels;
|
||||||
0xFF222222, 0xFFFFFFFF
|
stbi_set_flip_vertically_on_load(true);
|
||||||
};
|
uint8_t* pixels = stbi_load("happi.jpg", &width, &height, &channels, desired_channels);
|
||||||
|
|
||||||
bind->fs.images[SLOT_tex] = sg_make_image(&(sg_image_desc){
|
bind->fs.images[SLOT_tex] = sg_make_image(&(sg_image_desc){
|
||||||
.width = 2,
|
.width = width,
|
||||||
.height = 2,
|
.height = height,
|
||||||
.data.subimage[0][0] = SG_RANGE(pixels),
|
.data.subimage[0][0] = {.ptr = pixels, .size = width * height * desired_channels},
|
||||||
.label = "triangle-texture",
|
.label = "triangle-texture",
|
||||||
.pixel_format = SG_PIXELFORMAT_RGBA8,
|
.pixel_format = SG_PIXELFORMAT_RGBA8,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
stbi_image_free(pixels);
|
||||||
|
|
||||||
bind->fs.samplers[SLOT_smp] = sg_make_sampler(&(sg_sampler_desc){
|
bind->fs.samplers[SLOT_smp] = sg_make_sampler(&(sg_sampler_desc){
|
||||||
.label = "triangle-sampler",
|
.label = "triangle-sampler",
|
||||||
});
|
});
|
||||||
|
@ -97,6 +104,8 @@ float t = 0.0f;
|
||||||
void frame(void) {
|
void frame(void) {
|
||||||
t += sapp_frame_duration();
|
t += sapp_frame_duration();
|
||||||
|
|
||||||
|
printf("%f\n", 1.0f/sapp_frame_duration());
|
||||||
|
|
||||||
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = sglue_swapchain() });
|
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = sglue_swapchain() });
|
||||||
sg_apply_pipeline(state.pip);
|
sg_apply_pipeline(state.pip);
|
||||||
|
|
||||||
|
@ -137,5 +146,6 @@ sapp_desc sokol_main(int argc, char* argv[]) {
|
||||||
.window_title = "Gear",
|
.window_title = "Gear",
|
||||||
.icon.sokol_default = true,
|
.icon.sokol_default = true,
|
||||||
.logger.func = slog_func,
|
.logger.func = slog_func,
|
||||||
|
.swap_interval = 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue