Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 13af438612 | |||
| 815d7aa808 | |||
| 3e47bbd704 | |||
| 4b77b034f3 | |||
| 49277a4b2d | |||
| 5faf5948bf | |||
| 270e57acfc | |||
| 5159763baa | |||
| 49c80e60e8 | |||
| 4158674031 | |||
| 1de986b6ac | |||
| 395e8dc58a | |||
| 0044b05130 | |||
| 46bf26a7c3 | |||
| 27b9789d7c | |||
| 7a1c42ab15 | |||
| c73e6e08a8 | |||
| 1bb1d71230 | |||
| 0030275bc9 | |||
| 629c9d9b27 | |||
| ba9014756b | |||
| 2d509d15d3 | |||
| d03d4b285d | |||
| 84314221b8 | |||
| 3a26bbf84f | |||
| a09d0896d6 | |||
| 83cac2afa1 | |||
| 65604f0a93 | |||
| 2c28850150 | |||
| 173a487d22 | |||
| dca59a1241 | |||
| 9b1e40a368 | |||
| edfa461c9a | |||
| 3e00aefff5 | |||
| 53500ed4e2 | |||
| ac898aec6a | |||
| 418599451d | |||
| 0f21814c41 | |||
| ffddf12a70 | |||
| 7bdb22f93f | |||
| a064dc6d09 | |||
| 22439814a8 | |||
| 6cee1f56df | |||
| 8a019c6c36 | |||
| f8c6d794fa |
@@ -1,3 +1,4 @@
|
|||||||
Build/
|
Build/
|
||||||
Nocheckin/
|
Nocheckin/
|
||||||
feely_pona_build.exe
|
feely_pona_build.exe
|
||||||
|
feely_pona_version.txt
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Vendored
+649
@@ -0,0 +1,649 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2021, Dominic Szablewski - https://phoboslab.org
|
||||||
|
SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
|
||||||
|
QOI - The "Quite OK Image" format for fast, lossless image compression
|
||||||
|
|
||||||
|
-- About
|
||||||
|
|
||||||
|
QOI encodes and decodes images in a lossless format. Compared to stb_image and
|
||||||
|
stb_image_write QOI offers 20x-50x faster encoding, 3x-4x faster decoding and
|
||||||
|
20% better compression.
|
||||||
|
|
||||||
|
|
||||||
|
-- Synopsis
|
||||||
|
|
||||||
|
// Define `QOI_IMPLEMENTATION` in *one* C/C++ file before including this
|
||||||
|
// library to create the implementation.
|
||||||
|
|
||||||
|
#define QOI_IMPLEMENTATION
|
||||||
|
#include "qoi.h"
|
||||||
|
|
||||||
|
// Encode and store an RGBA buffer to the file system. The qoi_desc describes
|
||||||
|
// the input pixel data.
|
||||||
|
qoi_write("image_new.qoi", rgba_pixels, &(qoi_desc){
|
||||||
|
.width = 1920,
|
||||||
|
.height = 1080,
|
||||||
|
.channels = 4,
|
||||||
|
.colorspace = QOI_SRGB
|
||||||
|
});
|
||||||
|
|
||||||
|
// Load and decode a QOI image from the file system into a 32bbp RGBA buffer.
|
||||||
|
// The qoi_desc struct will be filled with the width, height, number of channels
|
||||||
|
// and colorspace read from the file header.
|
||||||
|
qoi_desc desc;
|
||||||
|
void *rgba_pixels = qoi_read("image.qoi", &desc, 4);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Documentation
|
||||||
|
|
||||||
|
This library provides the following functions;
|
||||||
|
- qoi_read -- read and decode a QOI file
|
||||||
|
- qoi_decode -- decode the raw bytes of a QOI image from memory
|
||||||
|
- qoi_write -- encode and write a QOI file
|
||||||
|
- qoi_encode -- encode an rgba buffer into a QOI image in memory
|
||||||
|
|
||||||
|
See the function declaration below for the signature and more information.
|
||||||
|
|
||||||
|
If you don't want/need the qoi_read and qoi_write functions, you can define
|
||||||
|
QOI_NO_STDIO before including this library.
|
||||||
|
|
||||||
|
This library uses malloc() and free(). To supply your own malloc implementation
|
||||||
|
you can define QOI_MALLOC and QOI_FREE before including this library.
|
||||||
|
|
||||||
|
This library uses memset() to zero-initialize the index. To supply your own
|
||||||
|
implementation you can define QOI_ZEROARR before including this library.
|
||||||
|
|
||||||
|
|
||||||
|
-- Data Format
|
||||||
|
|
||||||
|
A QOI file has a 14 byte header, followed by any number of data "chunks" and an
|
||||||
|
8-byte end marker.
|
||||||
|
|
||||||
|
struct qoi_header_t {
|
||||||
|
char magic[4]; // magic bytes "qoif"
|
||||||
|
uint32_t width; // image width in pixels (BE)
|
||||||
|
uint32_t height; // image height in pixels (BE)
|
||||||
|
uint8_t channels; // 3 = RGB, 4 = RGBA
|
||||||
|
uint8_t colorspace; // 0 = sRGB with linear alpha, 1 = all channels linear
|
||||||
|
};
|
||||||
|
|
||||||
|
Images are encoded row by row, left to right, top to bottom. The decoder and
|
||||||
|
encoder start with {r: 0, g: 0, b: 0, a: 255} as the previous pixel value. An
|
||||||
|
image is complete when all pixels specified by width * height have been covered.
|
||||||
|
|
||||||
|
Pixels are encoded as
|
||||||
|
- a run of the previous pixel
|
||||||
|
- an index into an array of previously seen pixels
|
||||||
|
- a difference to the previous pixel value in r,g,b
|
||||||
|
- full r,g,b or r,g,b,a values
|
||||||
|
|
||||||
|
The color channels are assumed to not be premultiplied with the alpha channel
|
||||||
|
("un-premultiplied alpha").
|
||||||
|
|
||||||
|
A running array[64] (zero-initialized) of previously seen pixel values is
|
||||||
|
maintained by the encoder and decoder. Each pixel that is seen by the encoder
|
||||||
|
and decoder is put into this array at the position formed by a hash function of
|
||||||
|
the color value. In the encoder, if the pixel value at the index matches the
|
||||||
|
current pixel, this index position is written to the stream as QOI_OP_INDEX.
|
||||||
|
The hash function for the index is:
|
||||||
|
|
||||||
|
index_position = (r * 3 + g * 5 + b * 7 + a * 11) % 64
|
||||||
|
|
||||||
|
Each chunk starts with a 2- or 8-bit tag, followed by a number of data bits. The
|
||||||
|
bit length of chunks is divisible by 8 - i.e. all chunks are byte aligned. All
|
||||||
|
values encoded in these data bits have the most significant bit on the left.
|
||||||
|
|
||||||
|
The 8-bit tags have precedence over the 2-bit tags. A decoder must check for the
|
||||||
|
presence of an 8-bit tag first.
|
||||||
|
|
||||||
|
The byte stream's end is marked with 7 0x00 bytes followed a single 0x01 byte.
|
||||||
|
|
||||||
|
|
||||||
|
The possible chunks are:
|
||||||
|
|
||||||
|
|
||||||
|
.- QOI_OP_INDEX ----------.
|
||||||
|
| Byte[0] |
|
||||||
|
| 7 6 5 4 3 2 1 0 |
|
||||||
|
|-------+-----------------|
|
||||||
|
| 0 0 | index |
|
||||||
|
`-------------------------`
|
||||||
|
2-bit tag b00
|
||||||
|
6-bit index into the color index array: 0..63
|
||||||
|
|
||||||
|
A valid encoder must not issue 2 or more consecutive QOI_OP_INDEX chunks to the
|
||||||
|
same index. QOI_OP_RUN should be used instead.
|
||||||
|
|
||||||
|
|
||||||
|
.- QOI_OP_DIFF -----------.
|
||||||
|
| Byte[0] |
|
||||||
|
| 7 6 5 4 3 2 1 0 |
|
||||||
|
|-------+-----+-----+-----|
|
||||||
|
| 0 1 | dr | dg | db |
|
||||||
|
`-------------------------`
|
||||||
|
2-bit tag b01
|
||||||
|
2-bit red channel difference from the previous pixel between -2..1
|
||||||
|
2-bit green channel difference from the previous pixel between -2..1
|
||||||
|
2-bit blue channel difference from the previous pixel between -2..1
|
||||||
|
|
||||||
|
The difference to the current channel values are using a wraparound operation,
|
||||||
|
so "1 - 2" will result in 255, while "255 + 1" will result in 0.
|
||||||
|
|
||||||
|
Values are stored as unsigned integers with a bias of 2. E.g. -2 is stored as
|
||||||
|
0 (b00). 1 is stored as 3 (b11).
|
||||||
|
|
||||||
|
The alpha value remains unchanged from the previous pixel.
|
||||||
|
|
||||||
|
|
||||||
|
.- QOI_OP_LUMA -------------------------------------.
|
||||||
|
| Byte[0] | Byte[1] |
|
||||||
|
| 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 |
|
||||||
|
|-------+-----------------+-------------+-----------|
|
||||||
|
| 1 0 | green diff | dr - dg | db - dg |
|
||||||
|
`---------------------------------------------------`
|
||||||
|
2-bit tag b10
|
||||||
|
6-bit green channel difference from the previous pixel -32..31
|
||||||
|
4-bit red channel difference minus green channel difference -8..7
|
||||||
|
4-bit blue channel difference minus green channel difference -8..7
|
||||||
|
|
||||||
|
The green channel is used to indicate the general direction of change and is
|
||||||
|
encoded in 6 bits. The red and blue channels (dr and db) base their diffs off
|
||||||
|
of the green channel difference and are encoded in 4 bits. I.e.:
|
||||||
|
dr_dg = (cur_px.r - prev_px.r) - (cur_px.g - prev_px.g)
|
||||||
|
db_dg = (cur_px.b - prev_px.b) - (cur_px.g - prev_px.g)
|
||||||
|
|
||||||
|
The difference to the current channel values are using a wraparound operation,
|
||||||
|
so "10 - 13" will result in 253, while "250 + 7" will result in 1.
|
||||||
|
|
||||||
|
Values are stored as unsigned integers with a bias of 32 for the green channel
|
||||||
|
and a bias of 8 for the red and blue channel.
|
||||||
|
|
||||||
|
The alpha value remains unchanged from the previous pixel.
|
||||||
|
|
||||||
|
|
||||||
|
.- QOI_OP_RUN ------------.
|
||||||
|
| Byte[0] |
|
||||||
|
| 7 6 5 4 3 2 1 0 |
|
||||||
|
|-------+-----------------|
|
||||||
|
| 1 1 | run |
|
||||||
|
`-------------------------`
|
||||||
|
2-bit tag b11
|
||||||
|
6-bit run-length repeating the previous pixel: 1..62
|
||||||
|
|
||||||
|
The run-length is stored with a bias of -1. Note that the run-lengths 63 and 64
|
||||||
|
(b111110 and b111111) are illegal as they are occupied by the QOI_OP_RGB and
|
||||||
|
QOI_OP_RGBA tags.
|
||||||
|
|
||||||
|
|
||||||
|
.- QOI_OP_RGB ------------------------------------------.
|
||||||
|
| Byte[0] | Byte[1] | Byte[2] | Byte[3] |
|
||||||
|
| 7 6 5 4 3 2 1 0 | 7 .. 0 | 7 .. 0 | 7 .. 0 |
|
||||||
|
|-------------------------+---------+---------+---------|
|
||||||
|
| 1 1 1 1 1 1 1 0 | red | green | blue |
|
||||||
|
`-------------------------------------------------------`
|
||||||
|
8-bit tag b11111110
|
||||||
|
8-bit red channel value
|
||||||
|
8-bit green channel value
|
||||||
|
8-bit blue channel value
|
||||||
|
|
||||||
|
The alpha value remains unchanged from the previous pixel.
|
||||||
|
|
||||||
|
|
||||||
|
.- QOI_OP_RGBA ---------------------------------------------------.
|
||||||
|
| Byte[0] | Byte[1] | Byte[2] | Byte[3] | Byte[4] |
|
||||||
|
| 7 6 5 4 3 2 1 0 | 7 .. 0 | 7 .. 0 | 7 .. 0 | 7 .. 0 |
|
||||||
|
|-------------------------+---------+---------+---------+---------|
|
||||||
|
| 1 1 1 1 1 1 1 1 | red | green | blue | alpha |
|
||||||
|
`-----------------------------------------------------------------`
|
||||||
|
8-bit tag b11111111
|
||||||
|
8-bit red channel value
|
||||||
|
8-bit green channel value
|
||||||
|
8-bit blue channel value
|
||||||
|
8-bit alpha channel value
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
Header - Public functions */
|
||||||
|
|
||||||
|
#ifndef QOI_H
|
||||||
|
#define QOI_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* A pointer to a qoi_desc struct has to be supplied to all of qoi's functions.
|
||||||
|
It describes either the input format (for qoi_write and qoi_encode), or is
|
||||||
|
filled with the description read from the file header (for qoi_read and
|
||||||
|
qoi_decode).
|
||||||
|
|
||||||
|
The colorspace in this qoi_desc is an enum where
|
||||||
|
0 = sRGB, i.e. gamma scaled RGB channels and a linear alpha channel
|
||||||
|
1 = all channels are linear
|
||||||
|
You may use the constants QOI_SRGB or QOI_LINEAR. The colorspace is purely
|
||||||
|
informative. It will be saved to the file header, but does not affect
|
||||||
|
how chunks are en-/decoded. */
|
||||||
|
|
||||||
|
#define QOI_SRGB 0
|
||||||
|
#define QOI_LINEAR 1
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned int width;
|
||||||
|
unsigned int height;
|
||||||
|
unsigned char channels;
|
||||||
|
unsigned char colorspace;
|
||||||
|
} qoi_desc;
|
||||||
|
|
||||||
|
#ifndef QOI_NO_STDIO
|
||||||
|
|
||||||
|
/* Encode raw RGB or RGBA pixels into a QOI image and write it to the file
|
||||||
|
system. The qoi_desc struct must be filled with the image width, height,
|
||||||
|
number of channels (3 = RGB, 4 = RGBA) and the colorspace.
|
||||||
|
|
||||||
|
The function returns 0 on failure (invalid parameters, or fopen or malloc
|
||||||
|
failed) or the number of bytes written on success. */
|
||||||
|
|
||||||
|
int qoi_write(const char *filename, const void *data, const qoi_desc *desc);
|
||||||
|
|
||||||
|
|
||||||
|
/* Read and decode a QOI image from the file system. If channels is 0, the
|
||||||
|
number of channels from the file header is used. If channels is 3 or 4 the
|
||||||
|
output format will be forced into this number of channels.
|
||||||
|
|
||||||
|
The function either returns NULL on failure (invalid data, or malloc or fopen
|
||||||
|
failed) or a pointer to the decoded pixels. On success, the qoi_desc struct
|
||||||
|
will be filled with the description from the file header.
|
||||||
|
|
||||||
|
The returned pixel data should be free()d after use. */
|
||||||
|
|
||||||
|
void *qoi_read(const char *filename, qoi_desc *desc, int channels);
|
||||||
|
|
||||||
|
#endif /* QOI_NO_STDIO */
|
||||||
|
|
||||||
|
|
||||||
|
/* Encode raw RGB or RGBA pixels into a QOI image in memory.
|
||||||
|
|
||||||
|
The function either returns NULL on failure (invalid parameters or malloc
|
||||||
|
failed) or a pointer to the encoded data on success. On success the out_len
|
||||||
|
is set to the size in bytes of the encoded data.
|
||||||
|
|
||||||
|
The returned qoi data should be free()d after use. */
|
||||||
|
|
||||||
|
void *qoi_encode(const void *data, const qoi_desc *desc, int *out_len);
|
||||||
|
|
||||||
|
|
||||||
|
/* Decode a QOI image from memory.
|
||||||
|
|
||||||
|
The function either returns NULL on failure (invalid parameters or malloc
|
||||||
|
failed) or a pointer to the decoded pixels. On success, the qoi_desc struct
|
||||||
|
is filled with the description from the file header.
|
||||||
|
|
||||||
|
The returned pixel data should be free()d after use. */
|
||||||
|
|
||||||
|
void *qoi_decode(const void *data, int size, qoi_desc *desc, int channels);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* QOI_H */
|
||||||
|
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
Implementation */
|
||||||
|
|
||||||
|
#ifdef QOI_IMPLEMENTATION
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifndef QOI_MALLOC
|
||||||
|
#define QOI_MALLOC(sz) malloc(sz)
|
||||||
|
#define QOI_FREE(p) free(p)
|
||||||
|
#endif
|
||||||
|
#ifndef QOI_ZEROARR
|
||||||
|
#define QOI_ZEROARR(a) memset((a),0,sizeof(a))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define QOI_OP_INDEX 0x00 /* 00xxxxxx */
|
||||||
|
#define QOI_OP_DIFF 0x40 /* 01xxxxxx */
|
||||||
|
#define QOI_OP_LUMA 0x80 /* 10xxxxxx */
|
||||||
|
#define QOI_OP_RUN 0xc0 /* 11xxxxxx */
|
||||||
|
#define QOI_OP_RGB 0xfe /* 11111110 */
|
||||||
|
#define QOI_OP_RGBA 0xff /* 11111111 */
|
||||||
|
|
||||||
|
#define QOI_MASK_2 0xc0 /* 11000000 */
|
||||||
|
|
||||||
|
#define QOI_COLOR_HASH(C) (C.rgba.r*3 + C.rgba.g*5 + C.rgba.b*7 + C.rgba.a*11)
|
||||||
|
#define QOI_MAGIC \
|
||||||
|
(((unsigned int)'q') << 24 | ((unsigned int)'o') << 16 | \
|
||||||
|
((unsigned int)'i') << 8 | ((unsigned int)'f'))
|
||||||
|
#define QOI_HEADER_SIZE 14
|
||||||
|
|
||||||
|
/* 2GB is the max file size that this implementation can safely handle. We guard
|
||||||
|
against anything larger than that, assuming the worst case with 5 bytes per
|
||||||
|
pixel, rounded down to a nice clean value. 400 million pixels ought to be
|
||||||
|
enough for anybody. */
|
||||||
|
#define QOI_PIXELS_MAX ((unsigned int)400000000)
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
struct { unsigned char r, g, b, a; } rgba;
|
||||||
|
unsigned int v;
|
||||||
|
} qoi_rgba_t;
|
||||||
|
|
||||||
|
static const unsigned char qoi_padding[8] = {0,0,0,0,0,0,0,1};
|
||||||
|
|
||||||
|
static void qoi_write_32(unsigned char *bytes, int *p, unsigned int v) {
|
||||||
|
bytes[(*p)++] = (0xff000000 & v) >> 24;
|
||||||
|
bytes[(*p)++] = (0x00ff0000 & v) >> 16;
|
||||||
|
bytes[(*p)++] = (0x0000ff00 & v) >> 8;
|
||||||
|
bytes[(*p)++] = (0x000000ff & v);
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned int qoi_read_32(const unsigned char *bytes, int *p) {
|
||||||
|
unsigned int a = bytes[(*p)++];
|
||||||
|
unsigned int b = bytes[(*p)++];
|
||||||
|
unsigned int c = bytes[(*p)++];
|
||||||
|
unsigned int d = bytes[(*p)++];
|
||||||
|
return a << 24 | b << 16 | c << 8 | d;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *qoi_encode(const void *data, const qoi_desc *desc, int *out_len) {
|
||||||
|
int i, max_size, p, run;
|
||||||
|
int px_len, px_end, px_pos, channels;
|
||||||
|
unsigned char *bytes;
|
||||||
|
const unsigned char *pixels;
|
||||||
|
qoi_rgba_t index[64];
|
||||||
|
qoi_rgba_t px, px_prev;
|
||||||
|
|
||||||
|
if (
|
||||||
|
data == NULL || out_len == NULL || desc == NULL ||
|
||||||
|
desc->width == 0 || desc->height == 0 ||
|
||||||
|
desc->channels < 3 || desc->channels > 4 ||
|
||||||
|
desc->colorspace > 1 ||
|
||||||
|
desc->height >= QOI_PIXELS_MAX / desc->width
|
||||||
|
) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
max_size =
|
||||||
|
desc->width * desc->height * (desc->channels + 1) +
|
||||||
|
QOI_HEADER_SIZE + sizeof(qoi_padding);
|
||||||
|
|
||||||
|
p = 0;
|
||||||
|
bytes = (unsigned char *) QOI_MALLOC(max_size);
|
||||||
|
if (!bytes) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
qoi_write_32(bytes, &p, QOI_MAGIC);
|
||||||
|
qoi_write_32(bytes, &p, desc->width);
|
||||||
|
qoi_write_32(bytes, &p, desc->height);
|
||||||
|
bytes[p++] = desc->channels;
|
||||||
|
bytes[p++] = desc->colorspace;
|
||||||
|
|
||||||
|
|
||||||
|
pixels = (const unsigned char *)data;
|
||||||
|
|
||||||
|
QOI_ZEROARR(index);
|
||||||
|
|
||||||
|
run = 0;
|
||||||
|
px_prev.rgba.r = 0;
|
||||||
|
px_prev.rgba.g = 0;
|
||||||
|
px_prev.rgba.b = 0;
|
||||||
|
px_prev.rgba.a = 255;
|
||||||
|
px = px_prev;
|
||||||
|
|
||||||
|
px_len = desc->width * desc->height * desc->channels;
|
||||||
|
px_end = px_len - desc->channels;
|
||||||
|
channels = desc->channels;
|
||||||
|
|
||||||
|
for (px_pos = 0; px_pos < px_len; px_pos += channels) {
|
||||||
|
px.rgba.r = pixels[px_pos + 0];
|
||||||
|
px.rgba.g = pixels[px_pos + 1];
|
||||||
|
px.rgba.b = pixels[px_pos + 2];
|
||||||
|
|
||||||
|
if (channels == 4) {
|
||||||
|
px.rgba.a = pixels[px_pos + 3];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (px.v == px_prev.v) {
|
||||||
|
run++;
|
||||||
|
if (run == 62 || px_pos == px_end) {
|
||||||
|
bytes[p++] = QOI_OP_RUN | (run - 1);
|
||||||
|
run = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int index_pos;
|
||||||
|
|
||||||
|
if (run > 0) {
|
||||||
|
bytes[p++] = QOI_OP_RUN | (run - 1);
|
||||||
|
run = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
index_pos = QOI_COLOR_HASH(px) % 64;
|
||||||
|
|
||||||
|
if (index[index_pos].v == px.v) {
|
||||||
|
bytes[p++] = QOI_OP_INDEX | index_pos;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
index[index_pos] = px;
|
||||||
|
|
||||||
|
if (px.rgba.a == px_prev.rgba.a) {
|
||||||
|
signed char vr = px.rgba.r - px_prev.rgba.r;
|
||||||
|
signed char vg = px.rgba.g - px_prev.rgba.g;
|
||||||
|
signed char vb = px.rgba.b - px_prev.rgba.b;
|
||||||
|
|
||||||
|
signed char vg_r = vr - vg;
|
||||||
|
signed char vg_b = vb - vg;
|
||||||
|
|
||||||
|
if (
|
||||||
|
vr > -3 && vr < 2 &&
|
||||||
|
vg > -3 && vg < 2 &&
|
||||||
|
vb > -3 && vb < 2
|
||||||
|
) {
|
||||||
|
bytes[p++] = QOI_OP_DIFF | (vr + 2) << 4 | (vg + 2) << 2 | (vb + 2);
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
vg_r > -9 && vg_r < 8 &&
|
||||||
|
vg > -33 && vg < 32 &&
|
||||||
|
vg_b > -9 && vg_b < 8
|
||||||
|
) {
|
||||||
|
bytes[p++] = QOI_OP_LUMA | (vg + 32);
|
||||||
|
bytes[p++] = (vg_r + 8) << 4 | (vg_b + 8);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bytes[p++] = QOI_OP_RGB;
|
||||||
|
bytes[p++] = px.rgba.r;
|
||||||
|
bytes[p++] = px.rgba.g;
|
||||||
|
bytes[p++] = px.rgba.b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bytes[p++] = QOI_OP_RGBA;
|
||||||
|
bytes[p++] = px.rgba.r;
|
||||||
|
bytes[p++] = px.rgba.g;
|
||||||
|
bytes[p++] = px.rgba.b;
|
||||||
|
bytes[p++] = px.rgba.a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
px_prev = px;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < (int)sizeof(qoi_padding); i++) {
|
||||||
|
bytes[p++] = qoi_padding[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
*out_len = p;
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *qoi_decode(const void *data, int size, qoi_desc *desc, int channels) {
|
||||||
|
const unsigned char *bytes;
|
||||||
|
unsigned int header_magic;
|
||||||
|
unsigned char *pixels;
|
||||||
|
qoi_rgba_t index[64];
|
||||||
|
qoi_rgba_t px;
|
||||||
|
int px_len, chunks_len, px_pos;
|
||||||
|
int p = 0, run = 0;
|
||||||
|
|
||||||
|
if (
|
||||||
|
data == NULL || desc == NULL ||
|
||||||
|
(channels != 0 && channels != 3 && channels != 4) ||
|
||||||
|
size < QOI_HEADER_SIZE + (int)sizeof(qoi_padding)
|
||||||
|
) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes = (const unsigned char *)data;
|
||||||
|
|
||||||
|
header_magic = qoi_read_32(bytes, &p);
|
||||||
|
desc->width = qoi_read_32(bytes, &p);
|
||||||
|
desc->height = qoi_read_32(bytes, &p);
|
||||||
|
desc->channels = bytes[p++];
|
||||||
|
desc->colorspace = bytes[p++];
|
||||||
|
|
||||||
|
if (
|
||||||
|
desc->width == 0 || desc->height == 0 ||
|
||||||
|
desc->channels < 3 || desc->channels > 4 ||
|
||||||
|
desc->colorspace > 1 ||
|
||||||
|
header_magic != QOI_MAGIC ||
|
||||||
|
desc->height >= QOI_PIXELS_MAX / desc->width
|
||||||
|
) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (channels == 0) {
|
||||||
|
channels = desc->channels;
|
||||||
|
}
|
||||||
|
|
||||||
|
px_len = desc->width * desc->height * channels;
|
||||||
|
pixels = (unsigned char *) QOI_MALLOC(px_len);
|
||||||
|
if (!pixels) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
QOI_ZEROARR(index);
|
||||||
|
px.rgba.r = 0;
|
||||||
|
px.rgba.g = 0;
|
||||||
|
px.rgba.b = 0;
|
||||||
|
px.rgba.a = 255;
|
||||||
|
|
||||||
|
chunks_len = size - (int)sizeof(qoi_padding);
|
||||||
|
for (px_pos = 0; px_pos < px_len; px_pos += channels) {
|
||||||
|
if (run > 0) {
|
||||||
|
run--;
|
||||||
|
}
|
||||||
|
else if (p < chunks_len) {
|
||||||
|
int b1 = bytes[p++];
|
||||||
|
|
||||||
|
if (b1 == QOI_OP_RGB) {
|
||||||
|
px.rgba.r = bytes[p++];
|
||||||
|
px.rgba.g = bytes[p++];
|
||||||
|
px.rgba.b = bytes[p++];
|
||||||
|
}
|
||||||
|
else if (b1 == QOI_OP_RGBA) {
|
||||||
|
px.rgba.r = bytes[p++];
|
||||||
|
px.rgba.g = bytes[p++];
|
||||||
|
px.rgba.b = bytes[p++];
|
||||||
|
px.rgba.a = bytes[p++];
|
||||||
|
}
|
||||||
|
else if ((b1 & QOI_MASK_2) == QOI_OP_INDEX) {
|
||||||
|
px = index[b1];
|
||||||
|
}
|
||||||
|
else if ((b1 & QOI_MASK_2) == QOI_OP_DIFF) {
|
||||||
|
px.rgba.r += ((b1 >> 4) & 0x03) - 2;
|
||||||
|
px.rgba.g += ((b1 >> 2) & 0x03) - 2;
|
||||||
|
px.rgba.b += ( b1 & 0x03) - 2;
|
||||||
|
}
|
||||||
|
else if ((b1 & QOI_MASK_2) == QOI_OP_LUMA) {
|
||||||
|
int b2 = bytes[p++];
|
||||||
|
int vg = (b1 & 0x3f) - 32;
|
||||||
|
px.rgba.r += vg - 8 + ((b2 >> 4) & 0x0f);
|
||||||
|
px.rgba.g += vg;
|
||||||
|
px.rgba.b += vg - 8 + (b2 & 0x0f);
|
||||||
|
}
|
||||||
|
else if ((b1 & QOI_MASK_2) == QOI_OP_RUN) {
|
||||||
|
run = (b1 & 0x3f);
|
||||||
|
}
|
||||||
|
|
||||||
|
index[QOI_COLOR_HASH(px) % 64] = px;
|
||||||
|
}
|
||||||
|
|
||||||
|
pixels[px_pos + 0] = px.rgba.r;
|
||||||
|
pixels[px_pos + 1] = px.rgba.g;
|
||||||
|
pixels[px_pos + 2] = px.rgba.b;
|
||||||
|
|
||||||
|
if (channels == 4) {
|
||||||
|
pixels[px_pos + 3] = px.rgba.a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pixels;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef QOI_NO_STDIO
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int qoi_write(const char *filename, const void *data, const qoi_desc *desc) {
|
||||||
|
FILE *f = fopen(filename, "wb");
|
||||||
|
int size, err;
|
||||||
|
void *encoded;
|
||||||
|
|
||||||
|
if (!f) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
encoded = qoi_encode(data, desc, &size);
|
||||||
|
if (!encoded) {
|
||||||
|
fclose(f);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fwrite(encoded, 1, size, f);
|
||||||
|
fflush(f);
|
||||||
|
err = ferror(f);
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
QOI_FREE(encoded);
|
||||||
|
return err ? 0 : size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *qoi_read(const char *filename, qoi_desc *desc, int channels) {
|
||||||
|
FILE *f = fopen(filename, "rb");
|
||||||
|
int size, bytes_read;
|
||||||
|
void *pixels, *data;
|
||||||
|
|
||||||
|
if (!f) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
size = ftell(f);
|
||||||
|
if (size <= 0 || fseek(f, 0, SEEK_SET) != 0) {
|
||||||
|
fclose(f);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = QOI_MALLOC(size);
|
||||||
|
if (!data) {
|
||||||
|
fclose(f);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes_read = fread(data, 1, size, f);
|
||||||
|
fclose(f);
|
||||||
|
pixels = (bytes_read != size) ? NULL : qoi_decode(data, bytes_read, desc, channels);
|
||||||
|
QOI_FREE(data);
|
||||||
|
return pixels;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* QOI_NO_STDIO */
|
||||||
|
#endif /* QOI_IMPLEMENTATION */
|
||||||
Vendored
+91
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2021, Dominic Szablewski - https://phoboslab.org
|
||||||
|
SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
|
||||||
|
Command line tool to convert between png <> qoi format
|
||||||
|
|
||||||
|
Requires:
|
||||||
|
-"stb_image.h" (https://github.com/nothings/stb/blob/master/stb_image.h)
|
||||||
|
-"stb_image_write.h" (https://github.com/nothings/stb/blob/master/stb_image_write.h)
|
||||||
|
-"qoi.h" (https://github.com/phoboslab/qoi/blob/master/qoi.h)
|
||||||
|
|
||||||
|
Compile with:
|
||||||
|
gcc qoiconv.c -std=c99 -O3 -o qoiconv
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
|
#define STBI_ONLY_PNG
|
||||||
|
#define STBI_NO_LINEAR
|
||||||
|
#include "stb_image.h"
|
||||||
|
|
||||||
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||||
|
#include "stb_image_write.h"
|
||||||
|
|
||||||
|
#define QOI_IMPLEMENTATION
|
||||||
|
#include "qoi.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define STR_ENDS_WITH(S, E) (strcmp(S + strlen(S) - (sizeof(E)-1), E) == 0)
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
if (argc < 3) {
|
||||||
|
puts("Usage: qoiconv <infile> <outfile>");
|
||||||
|
puts("Examples:");
|
||||||
|
puts(" qoiconv input.png output.qoi");
|
||||||
|
puts(" qoiconv input.qoi output.png");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *pixels = NULL;
|
||||||
|
int w, h, channels;
|
||||||
|
if (STR_ENDS_WITH(argv[1], ".png")) {
|
||||||
|
if(!stbi_info(argv[1], &w, &h, &channels)) {
|
||||||
|
printf("Couldn't read header %s\n", argv[1]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Force all odd encodings to be RGBA
|
||||||
|
if(channels != 3) {
|
||||||
|
channels = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
pixels = (void *)stbi_load(argv[1], &w, &h, NULL, channels);
|
||||||
|
}
|
||||||
|
else if (STR_ENDS_WITH(argv[1], ".qoi")) {
|
||||||
|
qoi_desc desc;
|
||||||
|
pixels = qoi_read(argv[1], &desc, 0);
|
||||||
|
channels = desc.channels;
|
||||||
|
w = desc.width;
|
||||||
|
h = desc.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pixels == NULL) {
|
||||||
|
printf("Couldn't load/decode %s\n", argv[1]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int encoded = 0;
|
||||||
|
if (STR_ENDS_WITH(argv[2], ".png")) {
|
||||||
|
encoded = stbi_write_png(argv[2], w, h, channels, pixels, 0);
|
||||||
|
}
|
||||||
|
else if (STR_ENDS_WITH(argv[2], ".qoi")) {
|
||||||
|
encoded = qoi_write(argv[2], pixels, &(qoi_desc){
|
||||||
|
.width = w,
|
||||||
|
.height = h,
|
||||||
|
.channels = channels,
|
||||||
|
.colorspace = QOI_SRGB
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!encoded) {
|
||||||
|
printf("Couldn't write/encode %s\n", argv[2]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(pixels);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Vendored
+1
-1
Submodule External/tely updated: b4b45f8d7c...c1056434f0
+458
@@ -0,0 +1,458 @@
|
|||||||
|
Language: Cpp
|
||||||
|
|
||||||
|
IndentWidth: 4
|
||||||
|
TabWidth: 4
|
||||||
|
|
||||||
|
# Align parameters on the open bracket, e.g.:
|
||||||
|
# someLongFunction(argument1,
|
||||||
|
# argument2);
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
|
||||||
|
# Align array column and left justify the columns e.g.:
|
||||||
|
# struct test demo[] =
|
||||||
|
# {
|
||||||
|
# {56, 23, "hello"},
|
||||||
|
# {-1, 93463, "world"},
|
||||||
|
# {7, 5, "!!" }
|
||||||
|
# };
|
||||||
|
AlignArrayOfStructures: Left
|
||||||
|
|
||||||
|
# Align assignments on consecutive lines. This will result in formattings like:
|
||||||
|
#
|
||||||
|
# int a = 1;
|
||||||
|
# int somelongname = 2;
|
||||||
|
# double c = 3;
|
||||||
|
#
|
||||||
|
# int d = 3;
|
||||||
|
# /* A comment. */
|
||||||
|
# double e = 4;
|
||||||
|
AlignConsecutiveAssignments: Consecutive
|
||||||
|
AlignConsecutiveBitFields: Consecutive
|
||||||
|
AlignConsecutiveDeclarations: Consecutive
|
||||||
|
AlignConsecutiveMacros: Consecutive
|
||||||
|
|
||||||
|
# Align escaped newlines as far left as possible.
|
||||||
|
# #define A \
|
||||||
|
# int aaaa; \
|
||||||
|
# int b; \
|
||||||
|
# int dddddddddd;
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
|
||||||
|
# Horizontally align operands of binary and ternary expressions.
|
||||||
|
# Specifically, this aligns operands of a single expression that needs to be
|
||||||
|
# split over multiple lines, e.g.:
|
||||||
|
#
|
||||||
|
# int aaa = bbbbbbbbbbbbbbb +
|
||||||
|
# ccccccccccccccc;
|
||||||
|
AlignOperands: Align
|
||||||
|
|
||||||
|
# true: false:
|
||||||
|
# int a; // My comment a vs. int a; // My comment a
|
||||||
|
# int b = 2; // comment b int b = 2; // comment about b
|
||||||
|
AlignTrailingComments: true
|
||||||
|
|
||||||
|
# If the function declaration doesn’t fit on a line, allow putting all
|
||||||
|
# parameters of a function declaration onto the next line even if
|
||||||
|
# BinPackParameters is false.
|
||||||
|
#
|
||||||
|
# true:
|
||||||
|
# void myFunction(
|
||||||
|
# int a, int b, int c, int d, int e);
|
||||||
|
#
|
||||||
|
# false:
|
||||||
|
# void myFunction(int a,
|
||||||
|
# int b,
|
||||||
|
# int c,
|
||||||
|
# int d,
|
||||||
|
# int e);
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
AllowShortBlocksOnASingleLine: Never # "while (true) { continue; }" can be put on a single line.
|
||||||
|
|
||||||
|
# If true, short case labels will be contracted to a single line.
|
||||||
|
#
|
||||||
|
# true: false:
|
||||||
|
# switch (a) { vs. switch (a) {
|
||||||
|
# case 1: x = 1; break; case 1:
|
||||||
|
# case 2: return; x = 1;
|
||||||
|
# } break;
|
||||||
|
# case 2:
|
||||||
|
# return;
|
||||||
|
# }
|
||||||
|
AllowShortCaseLabelsOnASingleLine: true
|
||||||
|
AllowShortEnumsOnASingleLine: true # enum { A, B } myEnum;
|
||||||
|
|
||||||
|
# Only merge functions defined inside a class. Implies “empty”.
|
||||||
|
#
|
||||||
|
# class Foo {
|
||||||
|
# void f() { foo(); }
|
||||||
|
# };
|
||||||
|
# void f() {
|
||||||
|
# foo();
|
||||||
|
# }
|
||||||
|
# void f() {}
|
||||||
|
AllowShortFunctionsOnASingleLine: Inline
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
|
||||||
|
# Only merge empty lambdas.
|
||||||
|
#
|
||||||
|
# auto lambda = [](int a) {}
|
||||||
|
# auto lambda2 = [](int a) {
|
||||||
|
# return a;
|
||||||
|
# };
|
||||||
|
AllowShortLambdasOnASingleLine: Empty
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
|
||||||
|
# true: false:
|
||||||
|
# aaaa = vs. aaaa = "bbbb"
|
||||||
|
# "bbbb" "cccc";
|
||||||
|
# "cccc";
|
||||||
|
AlwaysBreakBeforeMultilineStrings: true
|
||||||
|
|
||||||
|
# Force break after template declaration only when the following declaration
|
||||||
|
# spans multiple lines.
|
||||||
|
#
|
||||||
|
# template <typename T> T foo() {
|
||||||
|
# }
|
||||||
|
# template <typename T>
|
||||||
|
# T foo(int aaaaaaaaaaaaaaaaaaaaa,
|
||||||
|
# int bbbbbbbbbbbbbbbbbbbbb) {
|
||||||
|
# }
|
||||||
|
AlwaysBreakTemplateDeclarations: MultiLine
|
||||||
|
|
||||||
|
# If false, a function call’s arguments will either be all on the same line or
|
||||||
|
# will have one line each.
|
||||||
|
#
|
||||||
|
# true:
|
||||||
|
# void f() {
|
||||||
|
# f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa,
|
||||||
|
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# false:
|
||||||
|
# void f() {
|
||||||
|
# f(aaaaaaaaaaaaaaaaaaaa,
|
||||||
|
# aaaaaaaaaaaaaaaaaaaa,
|
||||||
|
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
|
||||||
|
# }
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false # As BinPackArguments but for function definition parameters
|
||||||
|
|
||||||
|
# Add space after the : only (space may be added before if needed for
|
||||||
|
# AlignConsecutiveBitFields).
|
||||||
|
#
|
||||||
|
# unsigned bf: 2;
|
||||||
|
BitFieldColonSpacing: After
|
||||||
|
|
||||||
|
# LooooooooooongType loooooooooooooooooooooongVariable =
|
||||||
|
# someLooooooooooooooooongFunction();
|
||||||
|
#
|
||||||
|
# bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
|
||||||
|
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
|
||||||
|
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
|
||||||
|
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
|
||||||
|
# ccccccccccccccccccccccccccccccccccccccccc;
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
|
||||||
|
# Always attach braces to surrounding context, but break before braces on
|
||||||
|
# function, namespace and class definitions.
|
||||||
|
BreakBeforeBraces: Linux
|
||||||
|
|
||||||
|
# true:
|
||||||
|
# template<typename T>
|
||||||
|
# concept ...
|
||||||
|
#
|
||||||
|
# false:
|
||||||
|
# template<typename T> concept ...
|
||||||
|
BreakBeforeConceptDeclarations: false
|
||||||
|
|
||||||
|
# true:
|
||||||
|
# veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription
|
||||||
|
# ? firstValue
|
||||||
|
# : SecondValueVeryVeryVeryVeryLong;
|
||||||
|
#
|
||||||
|
# false:
|
||||||
|
# veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription ?
|
||||||
|
# firstValue :
|
||||||
|
# SecondValueVeryVeryVeryVeryLong;
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
|
||||||
|
# Break constructor initializers before the colon and commas, and align the
|
||||||
|
# commas with the colon.
|
||||||
|
#
|
||||||
|
# Constructor()
|
||||||
|
# : initializer1()
|
||||||
|
# , initializer2()
|
||||||
|
BreakConstructorInitializers: BeforeComma
|
||||||
|
|
||||||
|
# Break inheritance list only after the commas.
|
||||||
|
#
|
||||||
|
# class Foo : Base1,
|
||||||
|
# Base2
|
||||||
|
# {};
|
||||||
|
BreakInheritanceList: AfterComma
|
||||||
|
|
||||||
|
# true:
|
||||||
|
# const char* x = "veryVeryVeryVeryVeryVe"
|
||||||
|
# "ryVeryVeryVeryVeryVery"
|
||||||
|
# "VeryLongString";
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 0
|
||||||
|
|
||||||
|
# false:
|
||||||
|
# namespace Foo {
|
||||||
|
# namespace Bar {
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
CompactNamespaces: false
|
||||||
|
|
||||||
|
# true: false:
|
||||||
|
# vector<int> x{1, 2, 3, 4}; vs. vector<int> x{ 1, 2, 3, 4 };
|
||||||
|
# vector<T> x{{}, {}, {}, {}}; vector<T> x{ {}, {}, {}, {} };
|
||||||
|
# f(MyMap[{composite, key}]); f(MyMap[{ composite, key }]);
|
||||||
|
# new int[3]{1, 2, 3}; new int[3]{ 1, 2, 3 };
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
|
||||||
|
# Analyze the formatted file for the most used line ending (\r\n or \n). UseCRLF
|
||||||
|
# is only used as a fallback if none can be derived.
|
||||||
|
DeriveLineEnding: true
|
||||||
|
DerivePointerAlignment: true # As per DeriveLineEnding except for pointers and references
|
||||||
|
|
||||||
|
# Add empty line only when access modifier starts a new logical block. Logical
|
||||||
|
# block is a group of one or more member fields or functions.
|
||||||
|
#
|
||||||
|
# struct foo {
|
||||||
|
# private:
|
||||||
|
# int i;
|
||||||
|
#
|
||||||
|
# protected:
|
||||||
|
# int j;
|
||||||
|
# /* comment */
|
||||||
|
# public:
|
||||||
|
# foo() {}
|
||||||
|
#
|
||||||
|
# private:
|
||||||
|
# protected:
|
||||||
|
# };
|
||||||
|
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||||
|
|
||||||
|
# true: false:
|
||||||
|
# namespace a { vs. namespace a {
|
||||||
|
# foo(); foo();
|
||||||
|
# bar(); bar();
|
||||||
|
# } // namespace a }
|
||||||
|
FixNamespaceComments: true
|
||||||
|
|
||||||
|
# false: true:
|
||||||
|
# class C { vs. class C {
|
||||||
|
# class D { class D {
|
||||||
|
# void bar(); void bar();
|
||||||
|
# protected: protected:
|
||||||
|
# D(); D();
|
||||||
|
# }; };
|
||||||
|
# public: public:
|
||||||
|
# C(); C();
|
||||||
|
# }; };
|
||||||
|
# void foo() { void foo() {
|
||||||
|
# return 1; return 1;
|
||||||
|
# } }
|
||||||
|
IndentAccessModifiers: false
|
||||||
|
|
||||||
|
# false: true:
|
||||||
|
# switch (fool) { vs. switch (fool) {
|
||||||
|
# case 1: { case 1:
|
||||||
|
# bar(); {
|
||||||
|
# } break; bar();
|
||||||
|
# default: { }
|
||||||
|
# plop(); break;
|
||||||
|
# } default:
|
||||||
|
# } {
|
||||||
|
# plop();
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
IndentCaseBlocks: false
|
||||||
|
|
||||||
|
# false: true:
|
||||||
|
# switch (fool) { vs. switch (fool) {
|
||||||
|
# case 1: case 1:
|
||||||
|
# bar(); bar();
|
||||||
|
# break; break;
|
||||||
|
# default: default:
|
||||||
|
# plop(); plop();
|
||||||
|
# } }
|
||||||
|
IndentCaseLabels: true
|
||||||
|
|
||||||
|
# extern "C" {
|
||||||
|
# void foo();
|
||||||
|
# }
|
||||||
|
IndentExternBlock: NoIndent
|
||||||
|
|
||||||
|
# Indents directives before the hash.
|
||||||
|
#
|
||||||
|
# #if FOO
|
||||||
|
# #if BAR
|
||||||
|
# #include <foo>
|
||||||
|
# #endif
|
||||||
|
# #endif
|
||||||
|
IndentPPDirectives: BeforeHash
|
||||||
|
|
||||||
|
# true: false:
|
||||||
|
# if (foo) { vs. if (foo) {
|
||||||
|
# bar();
|
||||||
|
# bar(); }
|
||||||
|
# }
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
|
||||||
|
# The maximum number of consecutive empty lines to keep.
|
||||||
|
#
|
||||||
|
# MaxEmptyLinesToKeep: 1 vs. MaxEmptyLinesToKeep: 0
|
||||||
|
# int f() { int f() {
|
||||||
|
# int = 1; int i = 1;
|
||||||
|
# i = foo();
|
||||||
|
# i = foo(); return i;
|
||||||
|
# }
|
||||||
|
# return i;
|
||||||
|
# }
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
|
||||||
|
# Put all constructor initializers on the current line if they fit. Otherwise,
|
||||||
|
# put each one on its own line.
|
||||||
|
#
|
||||||
|
# Constructor() : a(), b()
|
||||||
|
#
|
||||||
|
# Constructor()
|
||||||
|
# : aaaaaaaaaaaaaaaaaaaa(),
|
||||||
|
# bbbbbbbbbbbbbbbbbbbb(),
|
||||||
|
# ddddddddddddd()
|
||||||
|
PackConstructorInitializers: CurrentLine
|
||||||
|
PointerAlignment: Right
|
||||||
|
|
||||||
|
# false:
|
||||||
|
# // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
|
||||||
|
# /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information */
|
||||||
|
#
|
||||||
|
# true:
|
||||||
|
# // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
|
||||||
|
# // information
|
||||||
|
# /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
|
||||||
|
# * information */
|
||||||
|
ReflowComments: true
|
||||||
|
|
||||||
|
# false: true:
|
||||||
|
#
|
||||||
|
# if (isa<FunctionDecl>(D)) { vs. if (isa<FunctionDecl>(D))
|
||||||
|
# handleFunctionDecl(D); handleFunctionDecl(D);
|
||||||
|
# } else if (isa<VarDecl>(D)) { else if (isa<VarDecl>(D))
|
||||||
|
# handleVarDecl(D); handleVarDecl(D);
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# if (isa<VarDecl>(D)) { vs. if (isa<VarDecl>(D)) {
|
||||||
|
# for (auto *A : D.attrs()) { for (auto *A : D.attrs())
|
||||||
|
# if (shouldProcessAttr(A)) { if (shouldProcessAttr(A))
|
||||||
|
# handleAttr(A); handleAttr(A);
|
||||||
|
# } }
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# if (isa<FunctionDecl>(D)) { vs. if (isa<FunctionDecl>(D))
|
||||||
|
# for (auto *A : D.attrs()) { for (auto *A : D.attrs())
|
||||||
|
# handleAttr(A); handleAttr(A);
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# if (auto *D = (T)(D)) { vs. if (auto *D = (T)(D)) {
|
||||||
|
# if (shouldProcess(D)) { if (shouldProcess(D))
|
||||||
|
# handleVarDecl(D); handleVarDecl(D);
|
||||||
|
# } else { else
|
||||||
|
# markAsIgnored(D); markAsIgnored(D);
|
||||||
|
# } }
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# if (a) { vs. if (a)
|
||||||
|
# b(); b();
|
||||||
|
# } else { else if (c)
|
||||||
|
# if (c) { d();
|
||||||
|
# d(); else
|
||||||
|
# } else { e();
|
||||||
|
# e();
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
RemoveBracesLLVM: true
|
||||||
|
|
||||||
|
# Never v.s. Always
|
||||||
|
# #include <cstring> #include <cstring>
|
||||||
|
# struct Foo {
|
||||||
|
# int a, b, c; struct Foo {
|
||||||
|
# }; int a, b, c;
|
||||||
|
# namespace Ns { };
|
||||||
|
# class Bar {
|
||||||
|
# public: namespace Ns {
|
||||||
|
# struct Foobar { class Bar {
|
||||||
|
# int a; public:
|
||||||
|
# int b; struct Foobar {
|
||||||
|
# }; int a;
|
||||||
|
# private: int b;
|
||||||
|
# int t; };
|
||||||
|
# int method1() {
|
||||||
|
# // ... private:
|
||||||
|
# } int t;
|
||||||
|
# enum List {
|
||||||
|
# ITEM1, int method1() {
|
||||||
|
# ITEM2 // ...
|
||||||
|
# }; }
|
||||||
|
# template<typename T>
|
||||||
|
# int method2(T x) { enum List {
|
||||||
|
# // ... ITEM1,
|
||||||
|
# } ITEM2
|
||||||
|
# int i, j, k; };
|
||||||
|
# int method3(int par) {
|
||||||
|
# // ... template<typename T>
|
||||||
|
# } int method2(T x) {
|
||||||
|
# }; // ...
|
||||||
|
# class C {}; }
|
||||||
|
# }
|
||||||
|
# int i, j, k;
|
||||||
|
#
|
||||||
|
# int method3(int par) {
|
||||||
|
# // ...
|
||||||
|
# }
|
||||||
|
# };
|
||||||
|
#
|
||||||
|
# class C {};
|
||||||
|
# }
|
||||||
|
SeparateDefinitionBlocks: Always
|
||||||
|
|
||||||
|
# true: false:
|
||||||
|
# int a = 5; vs. int a= 5;
|
||||||
|
# a += 42; a+= 42;
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
|
||||||
|
# Put a space before opening parentheses only after control statement keywords
|
||||||
|
# (for/if/while...).
|
||||||
|
#
|
||||||
|
# void f() {
|
||||||
|
# if (true) {
|
||||||
|
# f();
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
|
||||||
|
# static_cast<int>(arg);
|
||||||
|
# std::function<void(int)> fct;
|
||||||
|
SpacesInAngles: Never
|
||||||
|
|
||||||
|
Standard: Auto
|
||||||
|
|
||||||
|
# Macros which are ignored in front of a statement, as if they were an
|
||||||
|
# attribute. So that they are not parsed as identifier, for example for Qts
|
||||||
|
# emit.
|
||||||
|
# unsigned char data = 'x';
|
||||||
|
# emit signal(data); // This is parsed as variable declaration.
|
||||||
|
#
|
||||||
|
# vs.
|
||||||
|
#
|
||||||
|
# unsigned char data = 'x';
|
||||||
|
# emit signal(data); // Now it's fine again.
|
||||||
|
StatementAttributeLikeMacros: [emit]
|
||||||
|
---
|
||||||
@@ -6,14 +6,20 @@ set script_dir=%script_dir_backslash:~0,-1%
|
|||||||
set build_dir=%script_dir%\Build
|
set build_dir=%script_dir%\Build
|
||||||
set code_dir=%script_dir%
|
set code_dir=%script_dir%
|
||||||
|
|
||||||
|
REM Bootstrap a version
|
||||||
|
git show -s --date=format:%%Y-%%m-%%d --format=%%cd HEAD> feely_pona_version.txt
|
||||||
|
git rev-parse --short=8 HEAD>> feely_pona_version.txt
|
||||||
|
git rev-list --count HEAD>> feely_pona_version.txt
|
||||||
|
|
||||||
REM Bootstrap the build program
|
REM Bootstrap the build program
|
||||||
|
mkdir %build_dir% 2>nul
|
||||||
pushd %build_dir%
|
pushd %build_dir%
|
||||||
cl /nologo /Z7 /W4 %code_dir%\feely_pona_build.cpp || exit /B 1
|
cl /nologo /Z7 /W4 %code_dir%\feely_pona_build.cpp || exit /B 1
|
||||||
copy feely_pona_build.exe %code_dir% 1>nul
|
copy feely_pona_build.exe %code_dir% 1>nul
|
||||||
popd
|
popd
|
||||||
|
|
||||||
REM Run the build program
|
REM Run the build program
|
||||||
%code_dir%\feely_pona_build.exe || exit /B 1
|
%code_dir%\feely_pona_build.exe %* || exit /B 1
|
||||||
|
|
||||||
popd
|
popd
|
||||||
exit /B 1
|
exit /B 1
|
||||||
|
|||||||
+1
-1
@@ -10,4 +10,4 @@ if not exist "%sprite_packer%" (
|
|||||||
exit /B 1
|
exit /B 1
|
||||||
)
|
)
|
||||||
|
|
||||||
%sprite_packer% 6144x6144 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\atlas || exit /b 1
|
%sprite_packer% 5100x5100 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\atlas || exit /b 1
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
set script_dir_backslash=%~dp0
|
||||||
|
set script_dir=%script_dir_backslash:~0,-1%
|
||||||
|
set build_dir=%script_dir%\Build
|
||||||
|
|
||||||
|
scp -P 8110 %build_dir%\Terry_Cherry_Emscripten\Terry_Cherry.html doylet@doylet.dev:/selfhost/TerryCherry/index.html
|
||||||
|
scp -P 8110 %build_dir%\Terry_Cherry_Emscripten\Terry_Cherry.data doylet@doylet.dev:/selfhost/TerryCherry/Terry_Cherry.data
|
||||||
|
scp -P 8110 %build_dir%\Terry_Cherry_Emscripten\Terry_Cherry.js doylet@doylet.dev:/selfhost/TerryCherry/Terry_Cherry.js
|
||||||
|
scp -P 8110 %build_dir%\Terry_Cherry_Emscripten\Terry_Cherry.wasm doylet@doylet.dev:/selfhost/TerryCherry/Terry_Cherry.wasm
|
||||||
+789
-602
File diff suppressed because it is too large
Load Diff
+2
-1
@@ -1,4 +1,4 @@
|
|||||||
#if defined(__clang__)
|
#if defined(_CLANGD)
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "feely_pona_unity.h"
|
#include "feely_pona_unity.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -52,6 +52,7 @@ struct FP_GlobalAnimations
|
|||||||
Dqn_String8 heart = DQN_STRING8("heart");
|
Dqn_String8 heart = DQN_STRING8("heart");
|
||||||
Dqn_String8 heart_bleed = DQN_STRING8("heart_bleed");
|
Dqn_String8 heart_bleed = DQN_STRING8("heart_bleed");
|
||||||
|
|
||||||
|
Dqn_String8 icon_attack = DQN_STRING8("icon_attack");
|
||||||
Dqn_String8 icon_health = DQN_STRING8("icon_health");
|
Dqn_String8 icon_health = DQN_STRING8("icon_health");
|
||||||
Dqn_String8 icon_money = DQN_STRING8("icon_money");
|
Dqn_String8 icon_money = DQN_STRING8("icon_money");
|
||||||
Dqn_String8 icon_phone = DQN_STRING8("icon_phone");
|
Dqn_String8 icon_phone = DQN_STRING8("icon_phone");
|
||||||
|
|||||||
+336
-84
@@ -80,25 +80,22 @@ void RebuildProgramIfRequired(int argc, char const **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PRINT_HELP Dqn_Print_StdLnF(Dqn_PrintStd_Out, "USAGE: feely_pona_build [--help|--dry-run]")
|
#define PRINT_HELP Dqn_Print_StdLnF(Dqn_PrintStd_Out, "USAGE: feely_pona_build [--help|--dry-run|--web]")
|
||||||
int main(int argc, char const **argv)
|
int main(int argc, char const **argv)
|
||||||
{
|
{
|
||||||
Dqn_Library_Init(Dqn_LibraryOnInit_Nil);
|
Dqn_Library_Init(Dqn_LibraryOnInit_Nil);
|
||||||
if (argc > 2) {
|
|
||||||
PRINT_HELP;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dry_run = false;
|
bool dry_run = false;
|
||||||
if (argc == 2) {
|
bool target_web = false;
|
||||||
Dqn_String8 arg = Dqn_String8_InitCString8(argv[1]);
|
for (Dqn_usize arg_index = 1; arg_index < argc; arg_index++) {
|
||||||
|
Dqn_String8 arg = Dqn_String8_InitCString8(argv[arg_index]);
|
||||||
if (arg == DQN_STRING8("--help")) {
|
if (arg == DQN_STRING8("--help")) {
|
||||||
PRINT_HELP;
|
PRINT_HELP;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else if (arg == DQN_STRING8("--dry-run")) {
|
||||||
|
|
||||||
if (arg == DQN_STRING8("--dry-run")) {
|
|
||||||
dry_run = true;
|
dry_run = true;
|
||||||
|
} else if (arg == DQN_STRING8("--web")) {
|
||||||
|
target_web = true;
|
||||||
} else {
|
} else {
|
||||||
PRINT_HELP;
|
PRINT_HELP;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -115,6 +112,7 @@ int main(int argc, char const **argv)
|
|||||||
build_timings[0] = Dqn_OS_PerfCounterNow();
|
build_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr);
|
Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr);
|
||||||
Dqn_String8 const exe_dir = Dqn_OS_EXEDir(scratch.arena);
|
Dqn_String8 const exe_dir = Dqn_OS_EXEDir(scratch.arena);
|
||||||
|
Dqn_String8 const code_dir = exe_dir;
|
||||||
Dqn_String8 const build_dir = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Build", DQN_STRING_FMT(exe_dir));
|
Dqn_String8 const build_dir = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Build", DQN_STRING_FMT(exe_dir));
|
||||||
Dqn_String8 const tely_dir = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/tely", DQN_STRING_FMT(exe_dir));
|
Dqn_String8 const tely_dir = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/tely", DQN_STRING_FMT(exe_dir));
|
||||||
|
|
||||||
@@ -137,61 +135,119 @@ int main(int argc, char const **argv)
|
|||||||
{
|
{
|
||||||
robocopy_timings[0] = Dqn_OS_PerfCounterNow();
|
robocopy_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
DQN_DEFER { robocopy_timings[1] = Dqn_OS_PerfCounterNow(); };
|
DQN_DEFER { robocopy_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
Dqn_String8 robocopy_cmd = Dqn_String8_InitF(scratch.allocator, "robocopy /MIR /NJH /NJS /NDL /NP %.*s\\Data %.*s\\Data", DQN_STRING_FMT(exe_dir), DQN_STRING_FMT(build_dir));
|
Dqn_String8 robocopy_cmd[] = {
|
||||||
if (dry_run) {
|
Dqn_String8_InitF(scratch.allocator, "robocopy /NJH /NJS /NDL /NP %.*s\\Data\\Textures %.*s\\Data\\Textures atlas.*", DQN_STRING_FMT(exe_dir), DQN_STRING_FMT(build_dir)),
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(robocopy_cmd));
|
Dqn_String8_InitF(scratch.allocator, "robocopy /MIR /NJH /NJS /NDL /NP %.*s\\Data\\Fonts %.*s\\Data\\Fonts", DQN_STRING_FMT(exe_dir), DQN_STRING_FMT(build_dir)),
|
||||||
} else {
|
Dqn_String8_InitF(scratch.allocator, "robocopy /MIR /NJH /NJS /NDL /NP %.*s\\Data\\Audio %.*s\\Data\\Audio", DQN_STRING_FMT(exe_dir), DQN_STRING_FMT(build_dir)),
|
||||||
Dqn_OS_Exec(robocopy_cmd, /*working_dir*/ {});
|
};
|
||||||
|
|
||||||
|
for (Dqn_String8 cmd : robocopy_cmd) {
|
||||||
|
if (dry_run)
|
||||||
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
|
||||||
|
else
|
||||||
|
Dqn_OS_Exec(cmd, /*working_dir*/ {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Raylib ================================================================================
|
// NOTE: Raylib ================================================================================
|
||||||
Dqn_CPPBuildContext raylib_build_context = {};
|
|
||||||
Dqn_String8 const raylib_dir = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/tely/external/raylib", DQN_STRING_FMT(exe_dir));
|
Dqn_String8 const raylib_dir = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/tely/external/raylib", DQN_STRING_FMT(exe_dir));
|
||||||
|
Dqn_Slice<Dqn_String8> const raylib_base_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||||
uint64_t raylib_timings[2] = {};
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rcore.c", DQN_STRING_FMT(raylib_dir)),
|
||||||
{
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/utils.c", DQN_STRING_FMT(raylib_dir)),
|
||||||
raylib_timings[0] = Dqn_OS_PerfCounterNow();
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/raudio.c", DQN_STRING_FMT(raylib_dir)),
|
||||||
DQN_DEFER { raylib_timings[1] = Dqn_OS_PerfCounterNow(); };
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rmodels.c", DQN_STRING_FMT(raylib_dir)),
|
||||||
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rtext.c", DQN_STRING_FMT(raylib_dir)),
|
||||||
raylib_build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rtextures.c", DQN_STRING_FMT(raylib_dir)),
|
||||||
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rcore.c", DQN_STRING_FMT(raylib_dir))},
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rshapes.c", DQN_STRING_FMT(raylib_dir)),
|
||||||
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/utils.c", DQN_STRING_FMT(raylib_dir))},
|
|
||||||
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/raudio.c", DQN_STRING_FMT(raylib_dir))},
|
|
||||||
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rmodels.c", DQN_STRING_FMT(raylib_dir))},
|
|
||||||
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rtext.c", DQN_STRING_FMT(raylib_dir))},
|
|
||||||
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rtextures.c", DQN_STRING_FMT(raylib_dir))},
|
|
||||||
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rshapes.c", DQN_STRING_FMT(raylib_dir))},
|
|
||||||
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rglfw.c", DQN_STRING_FMT(raylib_dir))},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
raylib_build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
Dqn_List<Dqn_String8> raylib_pc_output_files = Dqn_List_Init<Dqn_String8>(scratch.arena, 16);
|
||||||
|
uint64_t raylib_pc_timings[2] = {};
|
||||||
|
{
|
||||||
|
raylib_pc_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
|
DQN_DEFER { raylib_pc_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
|
// NOTE: Setup raylib build context ========================================================
|
||||||
|
Dqn_CPPBuildContext build_context = {};
|
||||||
|
{
|
||||||
|
build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s", DQN_STRING_FMT(raylib_dir)),
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s", DQN_STRING_FMT(raylib_dir)),
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/external/glfw/include", DQN_STRING_FMT(raylib_dir)),
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/external/glfw/include", DQN_STRING_FMT(raylib_dir)),
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/glfw/deps/mingw", DQN_STRING_FMT(raylib_dir)),
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/glfw/deps/mingw", DQN_STRING_FMT(raylib_dir)),
|
||||||
});
|
});
|
||||||
|
|
||||||
raylib_build_context.compile_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
build_context.compile_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||||
DQN_STRING8("cl"),
|
DQN_STRING8("cl"),
|
||||||
DQN_STRING8("/w"),
|
DQN_STRING8("/w"),
|
||||||
DQN_STRING8("/c"),
|
DQN_STRING8("/c"),
|
||||||
DQN_STRING8("/D _DEFAULT_SOURCE"),
|
DQN_STRING8("/D _DEFAULT_SOURCE"),
|
||||||
DQN_STRING8("/D PLATFORM_DESKTOP"),
|
DQN_STRING8("/D PLATFORM_DESKTOP"),
|
||||||
DQN_STRING8("/W4"),
|
|
||||||
DQN_STRING8("/Z7"),
|
DQN_STRING8("/Z7"),
|
||||||
DQN_STRING8("/MT"),
|
DQN_STRING8("/MT"),
|
||||||
DQN_STRING8("/EHsc"),
|
DQN_STRING8("/EHsc"),
|
||||||
DQN_STRING8("/nologo"),
|
DQN_STRING8("/nologo"),
|
||||||
});
|
});
|
||||||
|
build_context.build_dir = build_dir;
|
||||||
|
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
||||||
|
}
|
||||||
|
|
||||||
raylib_build_context.link_flags = common_link_flags;
|
// NOTE: Compile each file separately with a custom output name ============================
|
||||||
raylib_build_context.build_dir = build_dir;
|
for (Dqn_String8 base_file : raylib_base_files) {
|
||||||
|
Dqn_String8 file_stem = Dqn_String8_FileNameNoExtension(base_file);
|
||||||
|
|
||||||
|
Dqn_CPPBuildCompileFile build_file = {};
|
||||||
|
build_file.input_file_path = base_file;
|
||||||
|
build_file.output_file_path = Dqn_String8_InitF(scratch.allocator, "raylib_%.*s.obj", DQN_STRING_FMT(file_stem));
|
||||||
|
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||||
|
Dqn_List_Add(&raylib_pc_output_files, build_file.output_file_path);
|
||||||
|
|
||||||
if (dry_run) {
|
if (dry_run) {
|
||||||
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(raylib_build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
|
||||||
} else {
|
} else {
|
||||||
Dqn_CPPBuild_ExecOrAbort(raylib_build_context, Dqn_CPPBuildMode_CacheBuild);
|
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: Build rlgfw =======================================================================
|
||||||
|
{
|
||||||
|
Dqn_CPPBuildCompileFile build_file = {};
|
||||||
|
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rglfw.c", DQN_STRING_FMT(raylib_dir));
|
||||||
|
build_file.output_file_path = Dqn_String8_InitF(scratch.allocator, "raylib_rglfw.obj");
|
||||||
|
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||||
|
Dqn_List_Add(&raylib_pc_output_files, build_file.output_file_path);
|
||||||
|
|
||||||
|
if (dry_run) {
|
||||||
|
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||||
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
|
||||||
|
} else {
|
||||||
|
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: QOI Converter =========================================================================
|
||||||
|
uint64_t qoi_converter_timings[2] = {};
|
||||||
|
{
|
||||||
|
qoi_converter_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
|
DQN_DEFER { qoi_converter_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
|
Dqn_CPPBuildContext build_context = {};
|
||||||
|
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
||||||
|
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||||
|
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/qoiconv.c", DQN_STRING_FMT(code_dir)) },
|
||||||
|
});
|
||||||
|
|
||||||
|
build_context.compile_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("cl"), DQN_STRING8("-O2"), DQN_STRING8("-MT"), DQN_STRING8("/nologo")});
|
||||||
|
build_context.link_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/link"), DQN_STRING8("/incremental:no")});
|
||||||
|
build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/stb", DQN_STRING_FMT(tely_dir))});
|
||||||
|
build_context.build_dir = build_dir;
|
||||||
|
|
||||||
|
if (dry_run) {
|
||||||
|
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||||
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
|
||||||
|
} else {
|
||||||
|
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,18 +257,23 @@ int main(int argc, char const **argv)
|
|||||||
feely_pona_sprite_packer_timings[0] = Dqn_OS_PerfCounterNow();
|
feely_pona_sprite_packer_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
DQN_DEFER { feely_pona_sprite_packer_timings[1] = Dqn_OS_PerfCounterNow(); };
|
DQN_DEFER { feely_pona_sprite_packer_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
Dqn_String8 code_dir = exe_dir;
|
|
||||||
Dqn_CPPBuildContext build_context = {};
|
Dqn_CPPBuildContext build_context = {};
|
||||||
|
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
||||||
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||||
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_sprite_packer.h", DQN_STRING_FMT(code_dir)) },
|
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_sprite_packer.cpp", DQN_STRING_FMT(code_dir)) },
|
||||||
});
|
});
|
||||||
|
|
||||||
build_context.compile_flags = common_compile_flags;
|
build_context.compile_flags = common_compile_flags;
|
||||||
build_context.link_flags = common_link_flags;
|
build_context.link_flags = common_link_flags;
|
||||||
build_context.build_dir = build_dir;
|
build_context.build_dir = build_dir;
|
||||||
|
|
||||||
|
if (dry_run) {
|
||||||
|
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||||
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
|
||||||
|
} else {
|
||||||
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
|
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: Feely Pona No DLL =====================================================================
|
// NOTE: Feely Pona No DLL =====================================================================
|
||||||
uint64_t feely_pona_no_dll_timings[2] = {};
|
uint64_t feely_pona_no_dll_timings[2] = {};
|
||||||
@@ -221,37 +282,27 @@ int main(int argc, char const **argv)
|
|||||||
feely_pona_no_dll_timings[0] = Dqn_OS_PerfCounterNow();
|
feely_pona_no_dll_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
DQN_DEFER { feely_pona_no_dll_timings[1] = Dqn_OS_PerfCounterNow(); };
|
DQN_DEFER { feely_pona_no_dll_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
Dqn_String8 code_dir = exe_dir;
|
Dqn_CPPBuildCompileFile build_file = {};
|
||||||
feely_pona_no_dll_build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity_nodll.h", DQN_STRING_FMT(code_dir));
|
||||||
Dqn_CPPBuildCompileFile{
|
build_file.flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/Tp")});
|
||||||
{Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/Tp")})},
|
feely_pona_no_dll_build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity_nodll.h", DQN_STRING_FMT(code_dir))
|
feely_pona_no_dll_build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||||
},
|
feely_pona_no_dll_build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {raylib_dir});
|
||||||
});
|
|
||||||
|
|
||||||
feely_pona_no_dll_build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s", DQN_STRING_FMT(raylib_dir)),
|
|
||||||
});
|
|
||||||
|
|
||||||
feely_pona_no_dll_build_context.compile_flags = common_compile_flags;
|
feely_pona_no_dll_build_context.compile_flags = common_compile_flags;
|
||||||
|
feely_pona_no_dll_build_context.build_dir = build_dir;
|
||||||
|
|
||||||
// NOTE: Link to raylib object files and windows libs ======================================
|
// NOTE: Link to raylib object files and windows libs ======================================
|
||||||
Dqn_List<Dqn_String8> link_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_link_flags);
|
Dqn_List<Dqn_String8> link_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_link_flags);
|
||||||
{
|
{
|
||||||
for (Dqn_CPPBuildCompileFile file : raylib_build_context.compile_files) {
|
for (Dqn_ListIterator<Dqn_String8> it = {}; Dqn_List_Iterate(&raylib_pc_output_files, &it, 0); )
|
||||||
Dqn_String8 file_stem = Dqn_String8_FileNameNoExtension(file.path);
|
Dqn_List_Add(&link_flags, *it.data);
|
||||||
Dqn_String8 obj_file = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s.obj", DQN_STRING_FMT(raylib_build_context.build_dir), DQN_STRING_FMT(file_stem));
|
|
||||||
Dqn_List_Add(&link_flags, obj_file);
|
|
||||||
}
|
|
||||||
Dqn_List_Add(&link_flags, DQN_STRING8("gdi32.lib"));
|
Dqn_List_Add(&link_flags, DQN_STRING8("gdi32.lib"));
|
||||||
Dqn_List_Add(&link_flags, DQN_STRING8("opengl32.lib"));
|
Dqn_List_Add(&link_flags, DQN_STRING8("opengl32.lib"));
|
||||||
Dqn_List_Add(&link_flags, DQN_STRING8("winmm.lib"));
|
Dqn_List_Add(&link_flags, DQN_STRING8("winmm.lib"));
|
||||||
Dqn_List_Add(&link_flags, DQN_STRING8("user32.lib"));
|
Dqn_List_Add(&link_flags, DQN_STRING8("user32.lib"));
|
||||||
Dqn_List_Add(&link_flags, DQN_STRING8("shell32.lib"));
|
Dqn_List_Add(&link_flags, DQN_STRING8("shell32.lib"));
|
||||||
}
|
}
|
||||||
|
|
||||||
feely_pona_no_dll_build_context.link_flags = Dqn_List_ToSliceCopy(&link_flags, scratch.arena);
|
feely_pona_no_dll_build_context.link_flags = Dqn_List_ToSliceCopy(&link_flags, scratch.arena);
|
||||||
feely_pona_no_dll_build_context.build_dir = build_dir;
|
|
||||||
|
|
||||||
if (dry_run) {
|
if (dry_run) {
|
||||||
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(feely_pona_no_dll_build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(feely_pona_no_dll_build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||||
@@ -267,20 +318,18 @@ int main(int argc, char const **argv)
|
|||||||
feely_pona_dll_timings[0] = Dqn_OS_PerfCounterNow();
|
feely_pona_dll_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
DQN_DEFER { feely_pona_dll_timings[1] = Dqn_OS_PerfCounterNow(); };
|
DQN_DEFER { feely_pona_dll_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
Dqn_String8 code_dir = exe_dir;
|
Dqn_CPPBuildCompileFile build_file = {};
|
||||||
Dqn_CPPBuildContext build_context = {};
|
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity.h", DQN_STRING_FMT(code_dir));
|
||||||
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
build_file.output_file_path = Dqn_FsPath_ConvertF(scratch.arena, "tely_dll_msvc", DQN_STRING_FMT(code_dir));
|
||||||
Dqn_CPPBuildCompileFile{
|
build_file.flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/Tp")});
|
||||||
{Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/Tp")})},
|
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity.h", DQN_STRING_FMT(code_dir))
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
Dqn_List<Dqn_String8> compile_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_compile_flags);
|
Dqn_List<Dqn_String8> compile_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_compile_flags);
|
||||||
Dqn_List_Add(&compile_flags, DQN_STRING8("/LD"));
|
Dqn_List_Add(&compile_flags, DQN_STRING8("/LD"));
|
||||||
Dqn_List_Add(&compile_flags, DQN_STRING8("/Fotely_dll_msvc"));
|
|
||||||
Dqn_List_Add(&compile_flags, DQN_STRING8("/Fetely_dll_msvc"));
|
Dqn_List_Add(&compile_flags, DQN_STRING8("/Fetely_dll_msvc"));
|
||||||
|
|
||||||
|
Dqn_CPPBuildContext build_context = {};
|
||||||
|
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
||||||
|
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||||
build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
||||||
build_context.link_flags = feely_pona_no_dll_build_context.link_flags;
|
build_context.link_flags = feely_pona_no_dll_build_context.link_flags;
|
||||||
build_context.build_dir = build_dir;
|
build_context.build_dir = build_dir;
|
||||||
@@ -299,41 +348,244 @@ int main(int argc, char const **argv)
|
|||||||
feely_pona_platform_timings[0] = Dqn_OS_PerfCounterNow();
|
feely_pona_platform_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
DQN_DEFER { feely_pona_platform_timings[1] = Dqn_OS_PerfCounterNow(); };
|
DQN_DEFER { feely_pona_platform_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
Dqn_String8 code_dir = exe_dir;
|
Dqn_CPPBuildCompileFile build_file = {};
|
||||||
Dqn_CPPBuildContext build_context = {};
|
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/tely_platform_raylib_unity.h", DQN_STRING_FMT(tely_dir));
|
||||||
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
build_file.output_file_path = Dqn_FsPath_ConvertF(scratch.arena, "feely_pona_msvc", DQN_STRING_FMT(code_dir));
|
||||||
Dqn_CPPBuildCompileFile{
|
build_file.flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/Tp")});
|
||||||
{Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/Tp")})},
|
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/tely_platform_raylib_unity.h", DQN_STRING_FMT(tely_dir))
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
|
||||||
raylib_dir,
|
|
||||||
});
|
|
||||||
|
|
||||||
Dqn_List<Dqn_String8> compile_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_compile_flags);
|
Dqn_List<Dqn_String8> compile_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_compile_flags);
|
||||||
Dqn_List_Add(&compile_flags, DQN_STRING8("/Fofeely_pona_msvc"));
|
|
||||||
Dqn_List_Add(&compile_flags, DQN_STRING8("/Fefeely_pona_msvc"));
|
Dqn_List_Add(&compile_flags, DQN_STRING8("/Fefeely_pona_msvc"));
|
||||||
|
|
||||||
|
Dqn_CPPBuildContext build_context = {};
|
||||||
|
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
||||||
|
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||||
build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
||||||
build_context.link_flags = feely_pona_no_dll_build_context.link_flags;
|
build_context.link_flags = feely_pona_no_dll_build_context.link_flags;
|
||||||
build_context.build_dir = build_dir;
|
build_context.build_dir = build_dir;
|
||||||
|
build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {raylib_dir});
|
||||||
|
|
||||||
|
if (dry_run) {
|
||||||
|
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||||
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
|
||||||
|
} else {
|
||||||
|
Dqn_String8 exe_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_msvc.exe", DQN_STRING_FMT(build_dir));
|
||||||
|
bool exe_is_locked = false;
|
||||||
|
if (Dqn_Fs_Exists(exe_path)) {
|
||||||
|
Dqn_FsFile exe_file = Dqn_Fs_OpenFile(exe_path, Dqn_FsFileOpen_OpenIfExist, Dqn_FsFileAccess_Read | Dqn_FsFileAccess_Write);
|
||||||
|
exe_is_locked = exe_file.error_size;
|
||||||
|
Dqn_Fs_CloseFile(&exe_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!exe_is_locked) {
|
||||||
|
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_AlwaysRebuild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: raylib emscripten =====================================================================
|
||||||
|
uint64_t raylib_emscripten_timings[2] = {};
|
||||||
|
uint64_t feely_pona_emscripten_timings[2] = {};
|
||||||
|
if (target_web) {
|
||||||
|
Dqn_String8 const raylib_emscripten_lib_name = DQN_STRING8("raylib_emscripten.a");
|
||||||
|
bool debug_build = false;
|
||||||
|
|
||||||
|
Dqn_List<Dqn_String8> build_specific_compile_flags = {};
|
||||||
|
if (debug_build) {
|
||||||
|
build_specific_compile_flags = Dqn_List_InitCArrayCopy<Dqn_String8>(scratch.arena, 32, {
|
||||||
|
DQN_STRING8("-s"), DQN_STRING8("ASSERTIONS=2"),
|
||||||
|
DQN_STRING8("-s"), DQN_STRING8("SAFE_HEAP=0"),
|
||||||
|
DQN_STRING8("-s"), DQN_STRING8("STACK_OVERFLOW_CHECK=2"),
|
||||||
|
DQN_STRING8("--profiling-funcs"), // Expose function names in stack trace
|
||||||
|
DQN_STRING8("-g"), // Debug symbols
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
build_specific_compile_flags = Dqn_List_InitCArrayCopy<Dqn_String8>(scratch.arena, 32, {
|
||||||
|
DQN_STRING8("-Os"), // Optimise for size
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: Compile each raylib file separately with emcc =====================================
|
||||||
|
{
|
||||||
|
raylib_emscripten_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
|
DQN_DEFER { raylib_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
|
// NOTE: Setup build context ===========================================================
|
||||||
|
Dqn_List<Dqn_String8> raylib_emscripten_output_files = Dqn_List_Init<Dqn_String8>(scratch.arena, 16);
|
||||||
|
Dqn_CPPBuildContext raylib_emscripten_build_context = {};
|
||||||
|
raylib_emscripten_build_context.compiler = Dqn_CPPBuildCompiler_GCC;
|
||||||
|
|
||||||
|
for (Dqn_String8 base_file : raylib_base_files) {
|
||||||
|
Dqn_String8 file_stem = Dqn_String8_FileNameNoExtension(base_file);
|
||||||
|
|
||||||
|
// NOTE: Append "emscripten" suffix to the object files
|
||||||
|
Dqn_CPPBuildCompileFile build_file = {};
|
||||||
|
build_file.input_file_path = base_file;
|
||||||
|
build_file.output_file_path = Dqn_String8_InitF(scratch.allocator, "raylib_%.*s_emscripten.o", DQN_STRING_FMT(file_stem));
|
||||||
|
|
||||||
|
Dqn_List<Dqn_String8> compile_flags = Dqn_List_InitCArrayCopy(scratch.arena, 32, {
|
||||||
|
DQN_STRING8("cmd"),
|
||||||
|
DQN_STRING8("/C"),
|
||||||
|
DQN_STRING8("emcc.bat"),
|
||||||
|
DQN_STRING8("-c"), // Compile and assemble, but do not link
|
||||||
|
DQN_STRING8("-Wall"),
|
||||||
|
DQN_STRING8("-Os"), // Optimize for size
|
||||||
|
DQN_STRING8("-D PLATFORM_WEB"),
|
||||||
|
DQN_STRING8("-D GRAPHICS_API_OPENGL_ES2"),
|
||||||
|
});
|
||||||
|
Dqn_List_AddList(&compile_flags, build_specific_compile_flags);
|
||||||
|
|
||||||
|
raylib_emscripten_build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||||
|
raylib_emscripten_build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
||||||
|
raylib_emscripten_build_context.build_dir = build_dir;
|
||||||
|
Dqn_List_Add(&raylib_emscripten_output_files, build_file.output_file_path);
|
||||||
|
|
||||||
|
if (dry_run) {
|
||||||
|
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(raylib_emscripten_build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||||
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
|
||||||
|
} else {
|
||||||
|
Dqn_CPPBuild_ExecOrAbort(raylib_emscripten_build_context, Dqn_CPPBuildMode_CacheBuild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: Build the wasm raylib library =================================================
|
||||||
|
{
|
||||||
|
Dqn_String8Builder builder = {};
|
||||||
|
builder.allocator = scratch.allocator;
|
||||||
|
Dqn_String8Builder_AppendF(&builder, "cmd /C emar.bat rcs %.*s", DQN_STRING_FMT(raylib_emscripten_lib_name));
|
||||||
|
|
||||||
|
for (Dqn_ListIterator<Dqn_String8> it = {}; Dqn_List_Iterate(&raylib_emscripten_output_files, &it, 0); )
|
||||||
|
Dqn_String8Builder_AppendF(&builder, " %.*s", DQN_STRING_FMT(*it.data));
|
||||||
|
|
||||||
|
Dqn_String8 cmd = Dqn_String8Builder_Build(&builder, scratch.allocator);
|
||||||
|
if (dry_run) {
|
||||||
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
|
||||||
|
} else {
|
||||||
|
Dqn_OS_ExecOrAbort(cmd, build_dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: feely pona emscripten =============================================================
|
||||||
|
{
|
||||||
|
feely_pona_emscripten_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
|
DQN_DEFER { feely_pona_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
|
// NOTE: feely pona emscripten shell =======================================================
|
||||||
|
Dqn_String8 html_shell_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_emscripten_shell.html", DQN_STRING_FMT(build_dir));
|
||||||
|
{
|
||||||
|
Dqn_String8 html_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_emscripten_shell.html", DQN_STRING_FMT(code_dir));
|
||||||
|
Dqn_String8 html_buffer = Dqn_Fs_Read(html_path, scratch.allocator);
|
||||||
|
if (!DQN_CHECKF(html_buffer.size,
|
||||||
|
"Failed to read Emscripten HTML shell file. The file at\n\n '%.*s'\n\ndoes not exist or is not readable",
|
||||||
|
DQN_STRING_FMT(html_path)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
Dqn_String8 version_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_version.txt", DQN_STRING_FMT(code_dir));
|
||||||
|
Dqn_String8 version_buffer = Dqn_Fs_Read(version_path, scratch.allocator);
|
||||||
|
Dqn_String8SplitAllocResult version_parts = Dqn_String8_SplitAlloc(scratch.allocator, version_buffer, DQN_STRING8("\n"));
|
||||||
|
|
||||||
|
if (!DQN_CHECKF(version_parts.size == 3,
|
||||||
|
"Version file '%.*s' must have 3 lines containing, date, commit hash and number of commits. The buffer we tried extracting information from was\n\n%.*s\n\n",
|
||||||
|
DQN_STRING_FMT(version_path),
|
||||||
|
DQN_STRING_FMT(version_buffer))) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dqn_String8 date = Dqn_String8_TrimWhitespaceAround(version_parts.data[0]);
|
||||||
|
Dqn_String8 commit_hash = Dqn_String8_TrimWhitespaceAround(version_parts.data[1]);
|
||||||
|
Dqn_String8 commit_count = Dqn_String8_TrimWhitespaceAround(version_parts.data[2]);
|
||||||
|
Dqn_String8 version_text = Dqn_String8_InitF(scratch.allocator,
|
||||||
|
"%.*s edition rev. %.*s-%.*s",
|
||||||
|
DQN_STRING_FMT(date),
|
||||||
|
DQN_STRING_FMT(commit_count),
|
||||||
|
DQN_STRING_FMT(commit_hash));
|
||||||
|
|
||||||
|
Dqn_String8 html_buffer_processed = Dqn_String8_Replace(html_buffer,
|
||||||
|
DQN_STRING8("@version@"),
|
||||||
|
version_text,
|
||||||
|
0 /*start_index*/,
|
||||||
|
scratch.allocator);
|
||||||
|
if (!DQN_CHECKF(Dqn_Fs_Write(html_shell_path,
|
||||||
|
html_buffer_processed),
|
||||||
|
"Failed to write Emscripten HTML shell with the project version inserted into it. We were unable to write to the target location\n\n '%.*s'\n",
|
||||||
|
DQN_STRING_FMT(html_shell_path)))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: Compile with emcc =============================================================
|
||||||
|
Dqn_CPPBuildContext build_context = {};
|
||||||
|
build_context.compile_file_obj_suffix = DQN_CPP_BUILD_OBJ_SUFFIX_O;
|
||||||
|
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||||
|
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity_nodll.cpp", DQN_STRING_FMT(code_dir)) },
|
||||||
|
});
|
||||||
|
|
||||||
|
Dqn_String8 output_name = DQN_STRING8("Terry_Cherry");
|
||||||
|
Dqn_List<Dqn_String8> compile_flags = Dqn_List_InitCArrayCopy(scratch.arena, 32, {
|
||||||
|
DQN_STRING8("cmd"), DQN_STRING8("/C"), DQN_STRING8("emcc.bat"),
|
||||||
|
DQN_STRING8("-o"), Dqn_String8_InitF(scratch.allocator, "%.*s.html", DQN_STRING_FMT(output_name)),
|
||||||
|
DQN_STRING8("-Wall"),
|
||||||
|
DQN_STRING8("--shell-file"), html_shell_path,
|
||||||
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s", DQN_STRING_FMT(build_dir), DQN_STRING_FMT(raylib_emscripten_lib_name)),
|
||||||
|
DQN_STRING8("-s"), DQN_STRING8("USE_GLFW=3"),
|
||||||
|
DQN_STRING8("-s"), DQN_STRING8("TOTAL_MEMORY=512MB"),
|
||||||
|
DQN_STRING8("-s"), DQN_STRING8("TOTAL_STACK=32MB"),
|
||||||
|
DQN_STRING8("-s"), DQN_STRING8("ALLOW_MEMORY_GROWTH"),
|
||||||
|
DQN_STRING8("--preload-file"), DQN_STRING8("Data"),
|
||||||
|
DQN_STRING8("-msimd128"),
|
||||||
|
DQN_STRING8("-msse2"),
|
||||||
|
});
|
||||||
|
Dqn_List_AddList(&compile_flags, build_specific_compile_flags);
|
||||||
|
|
||||||
|
build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
||||||
|
build_context.build_dir = build_dir;
|
||||||
|
|
||||||
if (dry_run) {
|
if (dry_run) {
|
||||||
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
|
||||||
} else {
|
} else {
|
||||||
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_AlwaysRebuild);
|
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: Move the files to a directory
|
||||||
|
Dqn_String8 folder_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s_Emscripten", DQN_STRING_FMT(build_dir), DQN_STRING_FMT(output_name));
|
||||||
|
if (!Dqn_Fs_DirExists(folder_path)) {
|
||||||
|
Dqn_String8 mkdir_cmd = Dqn_String8_InitF(scratch.allocator, "mkdir %.*s", DQN_STRING_FMT(folder_path));
|
||||||
|
Dqn_OS_ExecOrAbort(mkdir_cmd, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
Dqn_String8 const generated_file_extension[] = {
|
||||||
|
DQN_STRING8("data"),
|
||||||
|
DQN_STRING8("html"),
|
||||||
|
DQN_STRING8("js"),
|
||||||
|
DQN_STRING8("wasm"),
|
||||||
|
};
|
||||||
|
|
||||||
|
for (Dqn_String8 file_ext : generated_file_extension) {
|
||||||
|
Dqn_String8 src_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s.%.*s", DQN_STRING_FMT(build_dir), DQN_STRING_FMT(output_name), DQN_STRING_FMT(file_ext));
|
||||||
|
Dqn_String8 dest_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s.%.*s", DQN_STRING_FMT(folder_path), DQN_STRING_FMT(output_name), DQN_STRING_FMT(file_ext));
|
||||||
|
Dqn_String8 cmd = Dqn_String8_InitF(scratch.allocator, "cmd /C move /Y %.*s %.*s", DQN_STRING_FMT(src_path), DQN_STRING_FMT(dest_path));
|
||||||
|
if (dry_run) {
|
||||||
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
|
||||||
|
} else {
|
||||||
|
Dqn_OS_ExecOrAbort(cmd, build_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
build_timings[1] = Dqn_OS_PerfCounterNow();
|
build_timings[1] = Dqn_OS_PerfCounterNow();
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "\n-- Dqn_CPPBuild Timings (%.2fms)", Dqn_OS_PerfCounterMs(build_timings[0], build_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "\n-- Dqn_CPPBuild Timings (%.2fms)", Dqn_OS_PerfCounterMs(build_timings[0], build_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " robocopy: %.2fms", Dqn_OS_PerfCounterMs(robocopy_timings[0], robocopy_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " robocopy: %.2fms", Dqn_OS_PerfCounterMs(robocopy_timings[0], robocopy_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " raylib: %.2fms", Dqn_OS_PerfCounterMs(raylib_timings[0], raylib_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " raylib: %.2fms", Dqn_OS_PerfCounterMs(raylib_pc_timings[0], raylib_pc_timings[1]));
|
||||||
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " qoi_converter: %.2fms", Dqn_OS_PerfCounterMs(qoi_converter_timings[0], qoi_converter_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona sprite packer: %.2fms", Dqn_OS_PerfCounterMs(feely_pona_sprite_packer_timings[0], feely_pona_sprite_packer_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona sprite packer: %.2fms", Dqn_OS_PerfCounterMs(feely_pona_sprite_packer_timings[0], feely_pona_sprite_packer_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (no dll): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_no_dll_timings[0], feely_pona_no_dll_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (no dll): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_no_dll_timings[0], feely_pona_no_dll_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (dll): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_dll_timings[0], feely_pona_dll_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (dll): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_dll_timings[0], feely_pona_dll_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (platform): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_platform_timings[0], feely_pona_platform_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (platform-raylib): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_platform_timings[0], feely_pona_platform_timings[1]));
|
||||||
|
if (target_web) {
|
||||||
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " raylib (emscripten): %.2fms", Dqn_OS_PerfCounterMs(raylib_emscripten_timings[0], raylib_emscripten_timings[1]));
|
||||||
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (emscripten): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_emscripten_timings[0], feely_pona_emscripten_timings[1]));
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,227 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="EN-us">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
|
||||||
|
<title>Terry Cherry</title>
|
||||||
|
|
||||||
|
<meta name="title" content="Terry Cherry">
|
||||||
|
<meta name="description" content="Terry fends off the hordes of cherries">
|
||||||
|
<meta name="viewport" content="width=device-width">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: arial;
|
||||||
|
margin: 0;
|
||||||
|
padding: none;
|
||||||
|
background: #301010;
|
||||||
|
}
|
||||||
|
|
||||||
|
#header {
|
||||||
|
font-weight: bold;
|
||||||
|
color: white;
|
||||||
|
height: 30px;
|
||||||
|
text-align: center;
|
||||||
|
padding-left: 5px;
|
||||||
|
padding-right: 5px;
|
||||||
|
padding-top: 5px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
|
||||||
|
div.emscripten { text-align: center; }
|
||||||
|
div.emscripten_border { border: 0px solid black; }
|
||||||
|
div.emscripten_status { border: 0px solid black; }
|
||||||
|
|
||||||
|
/* NOTE: Canvas *must not* have any border or padding, or mouse coords will be wrong */
|
||||||
|
canvas.emscripten {
|
||||||
|
border: 0px none;
|
||||||
|
background: black;
|
||||||
|
width: 75vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
#status {
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: top;
|
||||||
|
font-weight: normal;
|
||||||
|
font-size: 0.8em;
|
||||||
|
color: darkgray;
|
||||||
|
}
|
||||||
|
|
||||||
|
#progress {
|
||||||
|
height: 0px;
|
||||||
|
width: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#controls {
|
||||||
|
display: inline-block;
|
||||||
|
float: right;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
#output {
|
||||||
|
width: 90%;
|
||||||
|
height: 140px;
|
||||||
|
margin: 0 auto;
|
||||||
|
margin-top: 10px;
|
||||||
|
display: block;
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
font-family: 'Lucida Console', Monaco, monospace;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=button] {
|
||||||
|
background-color: lightgray;
|
||||||
|
color: black;
|
||||||
|
text-decoration: none;
|
||||||
|
cursor: pointer;
|
||||||
|
width: 140px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=button]:hover {
|
||||||
|
background-color: #f5f5f5ff;
|
||||||
|
border-color: black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="header">
|
||||||
|
<h1 style="font-size: 1em; text-align: center; margin-top: 0; margin-bottom: 0; padding-bottom: 3px">Terry Cherry</h1>
|
||||||
|
<div class="emscripten" id="status">Downloading...</div>
|
||||||
|
<div class="emscripten">
|
||||||
|
<progress value="0" max="100" id="progress" hidden=0></progress>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="emscripten_border">
|
||||||
|
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="display: flex; justify-content: space-around;">
|
||||||
|
<span id='controls'>
|
||||||
|
<span><input type="button" value="🖵 FULLSCREEN" onclick="Module.requestFullscreen(false, false)"></span>
|
||||||
|
<span><input type="button" id="btn-audio" value="🔇 SUSPEND" onclick="toggleAudio()"></span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<textarea id="output" rows="8"></textarea>
|
||||||
|
<script type='text/javascript'>
|
||||||
|
var statusElement = document.querySelector('#status');
|
||||||
|
var progressElement = document.querySelector('#progress');
|
||||||
|
var Module = {
|
||||||
|
preRun: [],
|
||||||
|
postRun: [],
|
||||||
|
print: (function() {
|
||||||
|
var element = document.querySelector('#output');
|
||||||
|
|
||||||
|
if (element) element.value = ''; // Clear browser cache
|
||||||
|
|
||||||
|
return function(text) {
|
||||||
|
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
|
||||||
|
// These replacements are necessary if you render to raw HTML
|
||||||
|
//text = text.replace(/&/g, "&");
|
||||||
|
//text = text.replace(/</g, "<");
|
||||||
|
//text = text.replace(/>/g, ">");
|
||||||
|
//text = text.replace('\n', '<br>', 'g');
|
||||||
|
console.log(text);
|
||||||
|
|
||||||
|
if (element) {
|
||||||
|
element.value += text + "\n";
|
||||||
|
element.scrollTop = element.scrollHeight; // focus on bottom
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})(),
|
||||||
|
printErr: function(text) {
|
||||||
|
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
|
||||||
|
|
||||||
|
console.error(text);
|
||||||
|
},
|
||||||
|
canvas: (function() {
|
||||||
|
var canvas = document.querySelector('#canvas');
|
||||||
|
|
||||||
|
// As a default initial behavior, pop up an alert when webgl context is lost.
|
||||||
|
// To make your application robust, you may want to override this behavior before shipping!
|
||||||
|
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
|
||||||
|
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
|
||||||
|
|
||||||
|
return canvas;
|
||||||
|
})(),
|
||||||
|
setStatus: function(text) {
|
||||||
|
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
|
||||||
|
if (text === Module.setStatus.last.text) return;
|
||||||
|
|
||||||
|
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
|
||||||
|
var now = Date.now();
|
||||||
|
|
||||||
|
if (m && now - Module.setStatus.last.time < 30) return; // If this is a progress update, skip it if too soon
|
||||||
|
|
||||||
|
Module.setStatus.last.time = now;
|
||||||
|
Module.setStatus.last.text = text;
|
||||||
|
|
||||||
|
if (m) {
|
||||||
|
text = m[1];
|
||||||
|
progressElement.value = parseInt(m[2])*100;
|
||||||
|
progressElement.max = parseInt(m[4])*100;
|
||||||
|
progressElement.hidden = true;
|
||||||
|
} else {
|
||||||
|
progressElement.value = null;
|
||||||
|
progressElement.max = null;
|
||||||
|
progressElement.hidden = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text) {
|
||||||
|
statusElement.innerHTML = '@version@: ' + text;
|
||||||
|
} else {
|
||||||
|
statusElement.innerHTML = '@version@';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
totalDependencies: 0,
|
||||||
|
monitorRunDependencies: function(left) {
|
||||||
|
this.totalDependencies = Math.max(this.totalDependencies, left);
|
||||||
|
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
|
||||||
|
},
|
||||||
|
//noInitialRun: true
|
||||||
|
};
|
||||||
|
|
||||||
|
Module.setStatus('Downloading...');
|
||||||
|
|
||||||
|
window.onerror = function() {
|
||||||
|
Module.setStatus('Exception thrown, see JavaScript console');
|
||||||
|
Module.setStatus = function(text) { if (text) Module.printErr('[post-exception status] ' + text); };
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- REF: https://developers.google.com/web/updates/2018/11/web-audio-autoplay -->
|
||||||
|
<script type='text/javascript'>
|
||||||
|
var audioBtn = document.querySelector('#btn-audio');
|
||||||
|
// An array of all contexts to resume on the page
|
||||||
|
const audioContexList = [];
|
||||||
|
(function() {
|
||||||
|
// A proxy object to intercept AudioContexts and
|
||||||
|
// add them to the array for tracking and resuming later
|
||||||
|
self.AudioContext = new Proxy(self.AudioContext, {
|
||||||
|
construct(target, args) {
|
||||||
|
const result = new target(...args);
|
||||||
|
audioContexList.push(result);
|
||||||
|
if (result.state == "suspended") audioBtn.value = "🔈 RESUME";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
|
function toggleAudio() {
|
||||||
|
var resumed = false;
|
||||||
|
audioContexList.forEach(ctx => {
|
||||||
|
if (ctx.state == "suspended") { ctx.resume(); resumed = true; }
|
||||||
|
else if (ctx.state == "running") ctx.suspend();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (resumed) audioBtn.value = "🔇 SUSPEND";
|
||||||
|
else audioBtn.value = "🔈 RESUME";
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{{{ SCRIPT }}}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,292 @@
|
|||||||
|
#if defined(_CLANGD)
|
||||||
|
#pragma once
|
||||||
|
#include "feely_pona_unity.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static bool FP_Entity_IsBuildingForMobs(FP_GameEntity *entity)
|
||||||
|
{
|
||||||
|
bool result = entity->type == FP_EntityType_AirportTerry ||
|
||||||
|
entity->type == FP_EntityType_ClubTerry ||
|
||||||
|
entity->type == FP_EntityType_ChurchTerry ||
|
||||||
|
entity->type == FP_EntityType_KennelTerry;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Dqn_f32 FP_Entity_CalcSpriteScaleForDesiredHeight(FP_Game *game, FP_Meters height, Dqn_Rect sprite_rect)
|
||||||
|
{
|
||||||
|
Dqn_f32 sprite_in_meters = FP_Game_PixelsToMetersNx1(game->play, sprite_rect.size.y);
|
||||||
|
Dqn_f32 result = height.meters / sprite_in_meters;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FP_EntityRenderData FP_Entity_GetRenderData(FP_Game *game, FP_EntityType type, uint32_t raw_state, FP_GameDirection direction)
|
||||||
|
{
|
||||||
|
FP_EntityRenderData result = {};
|
||||||
|
switch (type) {
|
||||||
|
case FP_EntityType_Nil: {
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_Map: {
|
||||||
|
result.height.meters = 41.9f;
|
||||||
|
result.anim_name = g_anim_names.map;
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_Terry: {
|
||||||
|
result.height.meters = 1.8f;
|
||||||
|
FP_EntityTerryState state = DQN_CAST(FP_EntityTerryState)raw_state;
|
||||||
|
switch (state) {
|
||||||
|
case FP_EntityTerryState_Idle: result.anim_name = g_anim_names.terry_walk_idle; break;
|
||||||
|
|
||||||
|
case FP_EntityTerryState_Attack: {
|
||||||
|
switch (direction) {
|
||||||
|
case FP_GameDirection_Up: result.anim_name = g_anim_names.terry_attack_up; result.height.meters *= 1.5f; break;
|
||||||
|
case FP_GameDirection_Down: result.anim_name = g_anim_names.terry_attack_down; result.height.meters *= 1.6f; break;
|
||||||
|
case FP_GameDirection_Left: result.anim_name = g_anim_names.terry_attack_side; result.height.meters *= 1.5f; break;
|
||||||
|
case FP_GameDirection_Right: result.anim_name = g_anim_names.terry_attack_side; result.height.meters *= 1.5f; result.flip = TELY_AssetFlip_X; break;
|
||||||
|
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityTerryState_RangeAttack: {
|
||||||
|
switch (direction) {
|
||||||
|
case FP_GameDirection_Up: result.anim_name = g_anim_names.terry_attack_phone_up; result.height.meters *= 1.25f; break;
|
||||||
|
case FP_GameDirection_Down: result.anim_name = g_anim_names.terry_attack_phone_down; result.height.meters *= 1.25f; break;
|
||||||
|
case FP_GameDirection_Left: result.anim_name = g_anim_names.terry_attack_phone_side; result.height.meters *= 1.25f; result.flip = TELY_AssetFlip_X; break;
|
||||||
|
case FP_GameDirection_Right: result.anim_name = g_anim_names.terry_attack_phone_side; result.height.meters *= 1.25f; break;
|
||||||
|
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityTerryState_Dash: {
|
||||||
|
switch (direction) {
|
||||||
|
case FP_GameDirection_Up: result.anim_name = g_anim_names.terry_ghost; break;
|
||||||
|
case FP_GameDirection_Down: result.anim_name = g_anim_names.terry_ghost; break;
|
||||||
|
case FP_GameDirection_Left: result.anim_name = g_anim_names.terry_ghost; break;
|
||||||
|
case FP_GameDirection_Right: result.anim_name = g_anim_names.terry_ghost; result.flip = TELY_AssetFlip_X; break;
|
||||||
|
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityTerryState_Run: {
|
||||||
|
switch (direction) {
|
||||||
|
case FP_GameDirection_Up: result.anim_name = g_anim_names.terry_walk_up; break;
|
||||||
|
case FP_GameDirection_Down: result.anim_name = g_anim_names.terry_walk_down; break;
|
||||||
|
case FP_GameDirection_Left: result.anim_name = g_anim_names.terry_walk_left; break;
|
||||||
|
case FP_GameDirection_Right: result.anim_name = g_anim_names.terry_walk_right; break;
|
||||||
|
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityTerryState_DeadGhost: {
|
||||||
|
result.anim_name = g_anim_names.terry_death; break;
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_Smoochie: {
|
||||||
|
result.height.meters = 1.6f;
|
||||||
|
FP_EntitySmoochieState state = DQN_CAST(FP_EntitySmoochieState)raw_state;
|
||||||
|
switch (state) {
|
||||||
|
case FP_EntitySmoochieState_Idle: result.anim_name = g_anim_names.smoochie_walk_down; break;
|
||||||
|
case FP_EntitySmoochieState_Attack: result.anim_name = g_anim_names.smoochie_attack_down; break;
|
||||||
|
case FP_EntitySmoochieState_HurtSide: result.anim_name = g_anim_names.smoochie_hurt_side; result.flip = direction == FP_GameDirection_Right ? TELY_AssetFlip_X : TELY_AssetFlip_No; break;
|
||||||
|
case FP_EntitySmoochieState_Death: result.anim_name = g_anim_names.smoochie_death; break;
|
||||||
|
case FP_EntitySmoochieState_Run: {
|
||||||
|
switch (direction) {
|
||||||
|
case FP_GameDirection_Up: result.anim_name = g_anim_names.smoochie_walk_up; break;
|
||||||
|
case FP_GameDirection_Down: result.anim_name = g_anim_names.smoochie_walk_down; break;
|
||||||
|
case FP_GameDirection_Left: result.anim_name = g_anim_names.smoochie_walk_left; break;
|
||||||
|
case FP_GameDirection_Right: result.anim_name = g_anim_names.smoochie_walk_right; break;
|
||||||
|
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_MerchantTerry: {
|
||||||
|
result.height.meters = 3.66f;
|
||||||
|
FP_EntityMerchantTerryState state = DQN_CAST(FP_EntityMerchantTerryState)raw_state;
|
||||||
|
switch (state) {
|
||||||
|
case FP_EntityMerchantTerryState_Idle: result.anim_name = g_anim_names.merchant_terry; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_MerchantGraveyard: {
|
||||||
|
result.height.meters = 3.66f;
|
||||||
|
FP_EntityMerchantGraveyardState state = DQN_CAST(FP_EntityMerchantGraveyardState)raw_state;
|
||||||
|
switch (state) {
|
||||||
|
case FP_EntityMerchantGraveyardState_Idle: result.anim_name = g_anim_names.merchant_graveyard; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_MerchantGym: {
|
||||||
|
result.height.meters = 3.66f;
|
||||||
|
result.anim_name = g_anim_names.merchant_gym;
|
||||||
|
FP_EntityMerchantGymState state = DQN_CAST(FP_EntityMerchantGymState)raw_state;
|
||||||
|
switch (state) {
|
||||||
|
case FP_EntityMerchantGymState_Idle: result.anim_name = g_anim_names.merchant_gym; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_MerchantPhoneCompany: {
|
||||||
|
result.height.meters = 5.f;
|
||||||
|
FP_EntityMerchantPhoneCompanyState state = DQN_CAST(FP_EntityMerchantPhoneCompanyState)raw_state;
|
||||||
|
switch (state) {
|
||||||
|
case FP_EntityMerchantPhoneCompanyState_Idle: result.anim_name = g_anim_names.merchant_phone_company; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_ClubTerry: {
|
||||||
|
result.height.meters = 4.f;
|
||||||
|
FP_EntityClubTerryState state = DQN_CAST(FP_EntityClubTerryState)raw_state;
|
||||||
|
switch (state) {
|
||||||
|
case FP_EntityClubTerryState_Idle: result.anim_name = g_anim_names.club_terry_dark; break;
|
||||||
|
case FP_EntityClubTerryState_PartyTime: result.anim_name = g_anim_names.club_terry_alive; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_Clinger: {
|
||||||
|
result.height.meters = 1.6f;
|
||||||
|
FP_EntityClingerState state = DQN_CAST(FP_EntityClingerState)raw_state;
|
||||||
|
switch (state) {
|
||||||
|
case FP_EntityClingerState_Idle: result.anim_name = g_anim_names.clinger_walk_down; break;
|
||||||
|
|
||||||
|
case FP_EntityClingerState_Attack: {
|
||||||
|
switch (direction) {
|
||||||
|
case FP_GameDirection_Up: result.anim_name = g_anim_names.clinger_attack_up; break;
|
||||||
|
case FP_GameDirection_Down: result.anim_name = g_anim_names.clinger_attack_down; break;
|
||||||
|
case FP_GameDirection_Left: result.anim_name = g_anim_names.clinger_attack_side; result.flip = TELY_AssetFlip_X; break;
|
||||||
|
case FP_GameDirection_Right: result.anim_name = g_anim_names.clinger_attack_side; break;
|
||||||
|
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityClingerState_Death: result.anim_name = g_anim_names.clinger_death; break;
|
||||||
|
|
||||||
|
case FP_EntityClingerState_Run: {
|
||||||
|
switch (direction) {
|
||||||
|
case FP_GameDirection_Up: result.anim_name = g_anim_names.clinger_walk_up; break;
|
||||||
|
case FP_GameDirection_Down: result.anim_name = g_anim_names.clinger_walk_down; break;
|
||||||
|
case FP_GameDirection_Left: result.anim_name = g_anim_names.clinger_walk_down; break;
|
||||||
|
case FP_GameDirection_Right: result.anim_name = g_anim_names.clinger_walk_down; break;
|
||||||
|
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_Heart: {
|
||||||
|
result.height.meters = 4.f;
|
||||||
|
FP_EntityHeartState state = DQN_CAST(FP_EntityHeartState)raw_state;
|
||||||
|
switch (state) {
|
||||||
|
case FP_EntityHeartState_Idle: result.anim_name = g_anim_names.heart; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_AirportTerry: {
|
||||||
|
result.height.meters = 4.f;
|
||||||
|
FP_EntityAirportTerryState state = DQN_CAST(FP_EntityAirportTerryState)raw_state;
|
||||||
|
switch (state) {
|
||||||
|
case FP_EntityAirportTerryState_Idle: result.anim_name = g_anim_names.airport_terry; break;
|
||||||
|
case FP_EntityAirportTerryState_FlyPassenger: result.anim_name = g_anim_names.airport_terry; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_Catfish: {
|
||||||
|
result.height.meters = 1.6f;
|
||||||
|
FP_EntityCatfishState state = DQN_CAST(FP_EntityCatfishState)raw_state;
|
||||||
|
switch (state) {
|
||||||
|
case FP_EntityCatfishState_Idle: result.anim_name = g_anim_names.catfish_walk_down; break;
|
||||||
|
case FP_EntityCatfishState_Attack: {
|
||||||
|
switch (direction) {
|
||||||
|
case FP_GameDirection_Up: result.anim_name = g_anim_names.catfish_attack_up; break;
|
||||||
|
case FP_GameDirection_Down: result.anim_name = g_anim_names.catfish_attack_down; break;
|
||||||
|
case FP_GameDirection_Left: result.anim_name = g_anim_names.catfish_attack_side; break;
|
||||||
|
case FP_GameDirection_Right: result.anim_name = g_anim_names.catfish_attack_side; result.flip = TELY_AssetFlip_X; break;
|
||||||
|
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case FP_EntityCatfishState_Death: result.anim_name = g_anim_names.catfish_death; break;
|
||||||
|
case FP_EntityCatfishState_Run: {
|
||||||
|
switch (direction) {
|
||||||
|
case FP_GameDirection_Up: result.anim_name = g_anim_names.catfish_walk_up; break;
|
||||||
|
case FP_GameDirection_Down: result.anim_name = g_anim_names.catfish_walk_down; break;
|
||||||
|
case FP_GameDirection_Left: result.anim_name = g_anim_names.catfish_walk_side; break;
|
||||||
|
case FP_GameDirection_Right: result.anim_name = g_anim_names.catfish_walk_side; result.flip = TELY_AssetFlip_X; break;
|
||||||
|
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_ChurchTerry: {
|
||||||
|
result.height.meters = 4.f;
|
||||||
|
FP_EntityChurchTerryState state = DQN_CAST(FP_EntityChurchTerryState)raw_state;
|
||||||
|
switch (state) {
|
||||||
|
case FP_EntityChurchTerryState_Idle: result.anim_name = g_anim_names.church_terry_dark; break;
|
||||||
|
case FP_EntityChurchTerryState_ConvertPatron: result.anim_name = g_anim_names.church_terry_alive; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_KennelTerry: {
|
||||||
|
result.height.meters = 3.f;
|
||||||
|
FP_EntityKennelTerryState state = DQN_CAST(FP_EntityKennelTerryState)raw_state;
|
||||||
|
switch (state) {
|
||||||
|
case FP_EntityKennelTerryState_Idle: result.anim_name = g_anim_names.kennel_terry; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_PhoneMessageProjectile: {
|
||||||
|
result.height.meters = 1.f;
|
||||||
|
result.anim_name = g_anim_names.terry_attack_phone_message;
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_AirportTerryPlane: {
|
||||||
|
result.height.meters = 1.5f;
|
||||||
|
result.anim_name = g_anim_names.airport_terry_plane;
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_MobSpawner: {
|
||||||
|
result.height.meters = 3.f;
|
||||||
|
FP_EntityMobSpawnerState state = DQN_CAST(FP_EntityMobSpawnerState)raw_state;
|
||||||
|
switch (state) {
|
||||||
|
case FP_EntityMobSpawnerState_Idle: result.anim_name = g_anim_names.portal; break;
|
||||||
|
case FP_EntityMobSpawnerState_Shutdown: {
|
||||||
|
result.anim_name = g_anim_names.portal_break;
|
||||||
|
result.height.meters = 3.5f;
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_PortalMonkey: {
|
||||||
|
result.height.meters = 1.f;
|
||||||
|
result.anim_name = g_anim_names.portal_monk; break;
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_Billboard: {
|
||||||
|
result.height.meters = 7.5f;
|
||||||
|
FP_EntityBillboardState state = DQN_CAST(FP_EntityBillboardState)raw_state;
|
||||||
|
switch (state) {
|
||||||
|
case FP_EntityBillboardState_Attack: result.anim_name = g_anim_names.map_billboard_attack; break;
|
||||||
|
case FP_EntityBillboardState_Dash: result.anim_name = g_anim_names.map_billboard_dash; break;
|
||||||
|
case FP_EntityBillboardState_Monkey: result.anim_name = g_anim_names.map_billboard_monkey; break;
|
||||||
|
case FP_EntityBillboardState_RangeAttack: result.anim_name = g_anim_names.map_billboard_range_attack; break;
|
||||||
|
case FP_EntityBillboardState_Strafe: result.anim_name = g_anim_names.map_billboard_strafe; break;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_Count: DQN_INVALID_CODE_PATH; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.sheet = &game->atlas_sprite_sheet;
|
||||||
|
TELY_AssetSpriteAnimation *sprite_anim = TELY_Asset_GetSpriteAnimation(result.sheet, result.anim_name);
|
||||||
|
if (sprite_anim) {
|
||||||
|
result.sheet_rect = result.sheet->rects.data[sprite_anim->index];
|
||||||
|
Dqn_f32 size_scale = FP_Entity_CalcSpriteScaleForDesiredHeight(game, result.height, result.sheet_rect);
|
||||||
|
result.render_size = result.sheet_rect.size * size_scale;
|
||||||
|
result.sprite = TELY_Asset_MakeAnimatedSprite(result.sheet, result.anim_name, result.flip);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
+11
-1
@@ -1,4 +1,4 @@
|
|||||||
#if defined(__clang__)
|
#if defined(_CLANGD)
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "feely_pona_unity.h"
|
#include "feely_pona_unity.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -24,6 +24,7 @@ enum FP_EntityType
|
|||||||
FP_EntityType_Smoochie,
|
FP_EntityType_Smoochie,
|
||||||
FP_EntityType_Terry,
|
FP_EntityType_Terry,
|
||||||
FP_EntityType_PhoneMessageProjectile,
|
FP_EntityType_PhoneMessageProjectile,
|
||||||
|
FP_EntityType_Billboard,
|
||||||
FP_EntityType_Count,
|
FP_EntityType_Count,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -127,6 +128,15 @@ enum FP_EntityHeartState
|
|||||||
FP_EntityHeartState_Idle,
|
FP_EntityHeartState_Idle,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum FP_EntityBillboardState
|
||||||
|
{
|
||||||
|
FP_EntityBillboardState_Attack,
|
||||||
|
FP_EntityBillboardState_Dash,
|
||||||
|
FP_EntityBillboardState_Monkey,
|
||||||
|
FP_EntityBillboardState_RangeAttack,
|
||||||
|
FP_EntityBillboardState_Strafe,
|
||||||
|
};
|
||||||
|
|
||||||
struct FP_EntityRenderData
|
struct FP_EntityRenderData
|
||||||
{
|
{
|
||||||
FP_Meters height;
|
FP_Meters height;
|
||||||
|
|||||||
+25
-276
@@ -1,283 +1,8 @@
|
|||||||
#if defined(__clang__)
|
#if defined(_CLANGD)
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "feely_pona_unity.h"
|
#include "feely_pona_unity.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool FP_Entity_IsBuildingForMobs(FP_GameEntity *entity)
|
|
||||||
{
|
|
||||||
bool result = entity->type == FP_EntityType_AirportTerry ||
|
|
||||||
entity->type == FP_EntityType_ClubTerry ||
|
|
||||||
entity->type == FP_EntityType_ChurchTerry ||
|
|
||||||
entity->type == FP_EntityType_KennelTerry;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Dqn_f32 FP_Entity_CalcSpriteScaleForDesiredHeight(FP_Game *game, FP_Meters height, Dqn_Rect sprite_rect)
|
|
||||||
{
|
|
||||||
Dqn_f32 sprite_in_meters = FP_Game_PixelsToMetersNx1(game->play, sprite_rect.size.y);
|
|
||||||
Dqn_f32 result = height.meters / sprite_in_meters;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
FP_EntityRenderData FP_Entity_GetRenderData(FP_Game *game, FP_EntityType type, uint32_t raw_state, FP_GameDirection direction)
|
|
||||||
{
|
|
||||||
FP_EntityRenderData result = {};
|
|
||||||
switch (type) {
|
|
||||||
case FP_EntityType_Nil: {
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_Map: {
|
|
||||||
result.height.meters = 41.9f;
|
|
||||||
result.anim_name = g_anim_names.map;
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_Terry: {
|
|
||||||
result.height.meters = 1.8f;
|
|
||||||
FP_EntityTerryState state = DQN_CAST(FP_EntityTerryState)raw_state;
|
|
||||||
switch (state) {
|
|
||||||
case FP_EntityTerryState_Idle: result.anim_name = g_anim_names.terry_walk_idle; break;
|
|
||||||
|
|
||||||
case FP_EntityTerryState_Attack: {
|
|
||||||
switch (direction) {
|
|
||||||
case FP_GameDirection_Up: result.anim_name = g_anim_names.terry_attack_up; break;
|
|
||||||
case FP_GameDirection_Down: result.anim_name = g_anim_names.terry_attack_down; break;
|
|
||||||
case FP_GameDirection_Left: result.anim_name = g_anim_names.terry_attack_side; break;
|
|
||||||
case FP_GameDirection_Right: result.anim_name = g_anim_names.terry_attack_side; result.flip = TELY_AssetFlip_X; break;
|
|
||||||
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityTerryState_RangeAttack: {
|
|
||||||
switch (direction) {
|
|
||||||
case FP_GameDirection_Up: result.anim_name = g_anim_names.terry_attack_phone_up; break;
|
|
||||||
case FP_GameDirection_Down: result.anim_name = g_anim_names.terry_attack_phone_down; break;
|
|
||||||
case FP_GameDirection_Left: result.anim_name = g_anim_names.terry_attack_phone_side; result.flip = TELY_AssetFlip_X; break;
|
|
||||||
case FP_GameDirection_Right: result.anim_name = g_anim_names.terry_attack_phone_side; break;
|
|
||||||
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityTerryState_Dash: {
|
|
||||||
switch (direction) {
|
|
||||||
case FP_GameDirection_Up: result.anim_name = g_anim_names.terry_ghost; break;
|
|
||||||
case FP_GameDirection_Down: result.anim_name = g_anim_names.terry_ghost; break;
|
|
||||||
case FP_GameDirection_Left: result.anim_name = g_anim_names.terry_ghost; break;
|
|
||||||
case FP_GameDirection_Right: result.anim_name = g_anim_names.terry_ghost; result.flip = TELY_AssetFlip_X; break;
|
|
||||||
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityTerryState_Run: {
|
|
||||||
switch (direction) {
|
|
||||||
case FP_GameDirection_Up: result.anim_name = g_anim_names.terry_walk_up; break;
|
|
||||||
case FP_GameDirection_Down: result.anim_name = g_anim_names.terry_walk_down; break;
|
|
||||||
case FP_GameDirection_Left: result.anim_name = g_anim_names.terry_walk_left; break;
|
|
||||||
case FP_GameDirection_Right: result.anim_name = g_anim_names.terry_walk_right; break;
|
|
||||||
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityTerryState_DeadGhost: {
|
|
||||||
result.anim_name = g_anim_names.terry_death; break;
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_Smoochie: {
|
|
||||||
result.height.meters = 1.6f;
|
|
||||||
FP_EntitySmoochieState state = DQN_CAST(FP_EntitySmoochieState)raw_state;
|
|
||||||
switch (state) {
|
|
||||||
case FP_EntitySmoochieState_Idle: result.anim_name = g_anim_names.smoochie_walk_down; break;
|
|
||||||
case FP_EntitySmoochieState_Attack: result.anim_name = g_anim_names.smoochie_attack_down; break;
|
|
||||||
case FP_EntitySmoochieState_HurtSide: result.anim_name = g_anim_names.smoochie_hurt_side; result.flip = direction == FP_GameDirection_Right ? TELY_AssetFlip_X : TELY_AssetFlip_No; break;
|
|
||||||
case FP_EntitySmoochieState_Death: result.anim_name = g_anim_names.smoochie_death; break;
|
|
||||||
case FP_EntitySmoochieState_Run: {
|
|
||||||
switch (direction) {
|
|
||||||
case FP_GameDirection_Up: result.anim_name = g_anim_names.smoochie_walk_up; break;
|
|
||||||
case FP_GameDirection_Down: result.anim_name = g_anim_names.smoochie_walk_down; break;
|
|
||||||
case FP_GameDirection_Left: result.anim_name = g_anim_names.smoochie_walk_left; break;
|
|
||||||
case FP_GameDirection_Right: result.anim_name = g_anim_names.smoochie_walk_right; break;
|
|
||||||
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_MerchantTerry: {
|
|
||||||
result.height.meters = 3.66f;
|
|
||||||
FP_EntityMerchantTerryState state = DQN_CAST(FP_EntityMerchantTerryState)raw_state;
|
|
||||||
switch (state) {
|
|
||||||
case FP_EntityMerchantTerryState_Idle: result.anim_name = g_anim_names.merchant_terry; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_MerchantGraveyard: {
|
|
||||||
result.height.meters = 3.66f;
|
|
||||||
FP_EntityMerchantGraveyardState state = DQN_CAST(FP_EntityMerchantGraveyardState)raw_state;
|
|
||||||
switch (state) {
|
|
||||||
case FP_EntityMerchantGraveyardState_Idle: result.anim_name = g_anim_names.merchant_graveyard; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_MerchantGym: {
|
|
||||||
result.height.meters = 3.66f;
|
|
||||||
result.anim_name = g_anim_names.merchant_gym;
|
|
||||||
FP_EntityMerchantGymState state = DQN_CAST(FP_EntityMerchantGymState)raw_state;
|
|
||||||
switch (state) {
|
|
||||||
case FP_EntityMerchantGymState_Idle: result.anim_name = g_anim_names.merchant_gym; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_MerchantPhoneCompany: {
|
|
||||||
result.height.meters = 3.66f;
|
|
||||||
FP_EntityMerchantPhoneCompanyState state = DQN_CAST(FP_EntityMerchantPhoneCompanyState)raw_state;
|
|
||||||
switch (state) {
|
|
||||||
case FP_EntityMerchantPhoneCompanyState_Idle: result.anim_name = g_anim_names.merchant_phone_company; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_ClubTerry: {
|
|
||||||
result.height.meters = 4.f;
|
|
||||||
FP_EntityClubTerryState state = DQN_CAST(FP_EntityClubTerryState)raw_state;
|
|
||||||
switch (state) {
|
|
||||||
case FP_EntityClubTerryState_Idle: result.anim_name = g_anim_names.club_terry_dark; break;
|
|
||||||
case FP_EntityClubTerryState_PartyTime: result.anim_name = g_anim_names.club_terry_alive; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_Clinger: {
|
|
||||||
result.height.meters = 1.6f;
|
|
||||||
FP_EntityClingerState state = DQN_CAST(FP_EntityClingerState)raw_state;
|
|
||||||
switch (state) {
|
|
||||||
case FP_EntityClingerState_Idle: result.anim_name = g_anim_names.clinger_walk_down; break;
|
|
||||||
|
|
||||||
case FP_EntityClingerState_Attack: {
|
|
||||||
switch (direction) {
|
|
||||||
case FP_GameDirection_Up: result.anim_name = g_anim_names.clinger_attack_up; break;
|
|
||||||
case FP_GameDirection_Down: result.anim_name = g_anim_names.clinger_attack_down; break;
|
|
||||||
case FP_GameDirection_Left: result.anim_name = g_anim_names.clinger_attack_side; result.flip = TELY_AssetFlip_X; break;
|
|
||||||
case FP_GameDirection_Right: result.anim_name = g_anim_names.clinger_attack_side; break;
|
|
||||||
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityClingerState_Death: result.anim_name = g_anim_names.clinger_death; break;
|
|
||||||
|
|
||||||
case FP_EntityClingerState_Run: {
|
|
||||||
switch (direction) {
|
|
||||||
case FP_GameDirection_Up: result.anim_name = g_anim_names.clinger_walk_up; break;
|
|
||||||
case FP_GameDirection_Down: result.anim_name = g_anim_names.clinger_walk_down; break;
|
|
||||||
case FP_GameDirection_Left: result.anim_name = g_anim_names.clinger_walk_down; break;
|
|
||||||
case FP_GameDirection_Right: result.anim_name = g_anim_names.clinger_walk_down; break;
|
|
||||||
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_Heart: {
|
|
||||||
result.height.meters = 4.f;
|
|
||||||
FP_EntityHeartState state = DQN_CAST(FP_EntityHeartState)raw_state;
|
|
||||||
switch (state) {
|
|
||||||
case FP_EntityHeartState_Idle: result.anim_name = g_anim_names.heart; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_AirportTerry: {
|
|
||||||
result.height.meters = 4.f;
|
|
||||||
FP_EntityAirportTerryState state = DQN_CAST(FP_EntityAirportTerryState)raw_state;
|
|
||||||
switch (state) {
|
|
||||||
case FP_EntityAirportTerryState_Idle: result.anim_name = g_anim_names.airport_terry; break;
|
|
||||||
case FP_EntityAirportTerryState_FlyPassenger: result.anim_name = g_anim_names.airport_terry; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_Catfish: {
|
|
||||||
result.height.meters = 1.6f;
|
|
||||||
FP_EntityCatfishState state = DQN_CAST(FP_EntityCatfishState)raw_state;
|
|
||||||
switch (state) {
|
|
||||||
case FP_EntityCatfishState_Idle: result.anim_name = g_anim_names.catfish_walk_down; break;
|
|
||||||
case FP_EntityCatfishState_Attack: {
|
|
||||||
switch (direction) {
|
|
||||||
case FP_GameDirection_Up: result.anim_name = g_anim_names.catfish_attack_up; break;
|
|
||||||
case FP_GameDirection_Down: result.anim_name = g_anim_names.catfish_attack_down; break;
|
|
||||||
case FP_GameDirection_Left: result.anim_name = g_anim_names.catfish_attack_side; break;
|
|
||||||
case FP_GameDirection_Right: result.anim_name = g_anim_names.catfish_attack_side; result.flip = TELY_AssetFlip_X; break;
|
|
||||||
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
case FP_EntityCatfishState_Death: result.anim_name = g_anim_names.catfish_death; break;
|
|
||||||
case FP_EntityCatfishState_Run: {
|
|
||||||
switch (direction) {
|
|
||||||
case FP_GameDirection_Up: result.anim_name = g_anim_names.catfish_walk_up; break;
|
|
||||||
case FP_GameDirection_Down: result.anim_name = g_anim_names.catfish_walk_down; break;
|
|
||||||
case FP_GameDirection_Left: result.anim_name = g_anim_names.catfish_walk_side; break;
|
|
||||||
case FP_GameDirection_Right: result.anim_name = g_anim_names.catfish_walk_side; result.flip = TELY_AssetFlip_X; break;
|
|
||||||
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_ChurchTerry: {
|
|
||||||
result.height.meters = 4.f;
|
|
||||||
FP_EntityChurchTerryState state = DQN_CAST(FP_EntityChurchTerryState)raw_state;
|
|
||||||
switch (state) {
|
|
||||||
case FP_EntityChurchTerryState_Idle: result.anim_name = g_anim_names.church_terry_dark; break;
|
|
||||||
case FP_EntityChurchTerryState_ConvertPatron: result.anim_name = g_anim_names.church_terry_alive; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_KennelTerry: {
|
|
||||||
result.height.meters = 3.f;
|
|
||||||
FP_EntityKennelTerryState state = DQN_CAST(FP_EntityKennelTerryState)raw_state;
|
|
||||||
switch (state) {
|
|
||||||
case FP_EntityKennelTerryState_Idle: result.anim_name = g_anim_names.kennel_terry; break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_PhoneMessageProjectile: {
|
|
||||||
result.height.meters = 1.f;
|
|
||||||
result.anim_name = g_anim_names.terry_attack_phone_message;
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_AirportTerryPlane: {
|
|
||||||
result.height.meters = 1.5f;
|
|
||||||
result.anim_name = g_anim_names.airport_terry_plane;
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_MobSpawner: {
|
|
||||||
result.height.meters = 3.f;
|
|
||||||
FP_EntityMobSpawnerState state = DQN_CAST(FP_EntityMobSpawnerState)raw_state;
|
|
||||||
switch (state) {
|
|
||||||
case FP_EntityMobSpawnerState_Idle: result.anim_name = g_anim_names.portal; break;
|
|
||||||
case FP_EntityMobSpawnerState_Shutdown: {
|
|
||||||
result.anim_name = g_anim_names.portal_break;
|
|
||||||
result.height.meters = 3.5f;
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_PortalMonkey: {
|
|
||||||
result.height.meters = 1.f;
|
|
||||||
result.anim_name = g_anim_names.portal_monk; break;
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FP_EntityType_Count: DQN_INVALID_CODE_PATH; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.sheet = &game->atlas_sprite_sheet;
|
|
||||||
TELY_AssetSpriteAnimation *sprite_anim = TELY_Asset_GetSpriteAnimation(result.sheet, result.anim_name);
|
|
||||||
if (sprite_anim) {
|
|
||||||
result.sheet_rect = result.sheet->rects.data[sprite_anim->index];
|
|
||||||
Dqn_f32 size_scale = FP_Entity_CalcSpriteScaleForDesiredHeight(game, result.height, result.sheet_rect);
|
|
||||||
result.render_size = result.sheet_rect.size * size_scale;
|
|
||||||
result.sprite = TELY_Asset_MakeAnimatedSprite(result.sheet, result.anim_name, result.flip);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void FP_Entity_AddDebugEditorFlags(FP_Game *game, FP_GameEntityHandle handle)
|
static void FP_Entity_AddDebugEditorFlags(FP_Game *game, FP_GameEntityHandle handle)
|
||||||
{
|
{
|
||||||
FP_GameEntity *entity = FP_Game_GetEntity(game, handle);
|
FP_GameEntity *entity = FP_Game_GetEntity(game, handle);
|
||||||
@@ -819,3 +544,27 @@ static FP_GameEntityHandle FP_Entity_CreateAirportTerryPlane(FP_Game *game, Dqn_
|
|||||||
entity->base_acceleration_per_s.meters = 32.f;
|
entity->base_acceleration_per_s.meters = 32.f;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FP_GameEntityHandle FP_Entity_CreateBillboard(FP_Game *game, Dqn_V2 pos, FP_EntityBillboardState state, DQN_FMT_STRING_ANNOTATE char const *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
FP_GameEntity *entity = FP_Game_MakeEntityPointerFV(game, fmt, args);
|
||||||
|
FP_GameEntityHandle result = entity->handle;
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
entity->action.state = state;
|
||||||
|
entity->action.next_state = state;
|
||||||
|
entity->type = FP_EntityType_Billboard;
|
||||||
|
FP_EntityRenderData render_data = FP_Entity_GetRenderData(game, entity->type, state, FP_GameDirection_Down);
|
||||||
|
entity->sprite_height = render_data.height;
|
||||||
|
uint64_t duration_ms = FP_GAME_ENTITY_ACTION_INFINITE_TIMER;
|
||||||
|
FP_Game_EntityActionReset(game, result, duration_ms, render_data.sprite);
|
||||||
|
|
||||||
|
entity->local_pos = pos;
|
||||||
|
FP_Entity_AddDebugEditorFlags(game, result);
|
||||||
|
|
||||||
|
entity->local_hit_box_offset = Dqn_V2_InitNx2(0, render_data.render_size.h * .1f);
|
||||||
|
entity->local_hit_box_size = Dqn_V2_InitNx2(render_data.render_size.w, render_data.render_size.h - (render_data.render_size.h * .4f));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|||||||
+251
-46
@@ -1,16 +1,8 @@
|
|||||||
#if defined(__clang__)
|
#if defined(_CLANGD)
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "feely_pona_unity.h"
|
#include "feely_pona_unity.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FP_Game_MetersToPixelsNx1(game, val) ((val) * (game).meters_to_pixels)
|
|
||||||
#define FP_Game_MetersToPixelsNx2(game, x, y) (Dqn_V2_InitNx2(x, y) * (game).meters_to_pixels)
|
|
||||||
#define FP_Game_MetersToPixelsV2(game, xy) (xy * (game).meters_to_pixels)
|
|
||||||
|
|
||||||
#define FP_Game_PixelsToMetersNx1(game, val) ((val) * (1.f/(game).meters_to_pixels))
|
|
||||||
#define FP_Game_PixelsToMetersNx2(game, x, y) (Dqn_V2_InitNx2(x, y) * (1.f/(game).meters_to_pixels))
|
|
||||||
#define FP_Game_PixelsToMetersV2(game, xy) (xy * (1.f/(game).meters_to_pixels))
|
|
||||||
|
|
||||||
static bool operator==(FP_GameEntityHandle const &lhs, FP_GameEntityHandle const &rhs)
|
static bool operator==(FP_GameEntityHandle const &lhs, FP_GameEntityHandle const &rhs)
|
||||||
{
|
{
|
||||||
bool result = lhs.id == rhs.id;
|
bool result = lhs.id == rhs.id;
|
||||||
@@ -23,24 +15,29 @@ static bool operator!=(FP_GameEntityHandle const &lhs, FP_GameEntityHandle const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(doyle): Use this
|
static FP_GameCameraM2x3 FP_Game_CameraModelViewM2x3(FP_GameCamera camera)
|
||||||
struct FP_GameCameraM2x3
|
|
||||||
{
|
{
|
||||||
Dqn_M2x3 model_view;
|
FP_GameCameraM2x3 result = {};
|
||||||
Dqn_M2x3 view_model;
|
result.model_view = Dqn_M2x3_Identity();
|
||||||
};
|
result.view_model = Dqn_M2x3_Identity();
|
||||||
|
|
||||||
static Dqn_M2x3 FP_Game_CameraModelViewM2x3(FP_GameCamera camera, TELY_Platform *platform)
|
Dqn_V2 center_offset = camera.size * .5f;
|
||||||
{
|
Dqn_V2 rotate_origin = -camera.world_pos;
|
||||||
Dqn_M2x3 result = Dqn_M2x3_Identity();
|
result.model_view = Dqn_M2x3_Mul(result.model_view, Dqn_M2x3_Translate(rotate_origin));
|
||||||
if (platform) {
|
result.model_view = Dqn_M2x3_Mul(result.model_view, Dqn_M2x3_Rotate(camera.rotate_rads));
|
||||||
Dqn_V2 center_offset = Dqn_V2_InitV2I(platform->core.window_size) * .5f;
|
result.model_view = Dqn_M2x3_Mul(result.model_view, Dqn_M2x3_Scale(camera.scale));
|
||||||
Dqn_V2 rotate_origin = -camera.world_pos - center_offset;
|
result.model_view = Dqn_M2x3_Mul(result.model_view, Dqn_M2x3_Translate(center_offset));
|
||||||
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Translate(rotate_origin));
|
|
||||||
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Rotate(camera.rotate_rads));
|
Dqn_V2 inverse_scale = Dqn_V2_InitNx1(1) / camera.scale;
|
||||||
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Scale(camera.scale));
|
result.view_model = Dqn_M2x3_Mul(result.view_model, Dqn_M2x3_Translate(-center_offset));
|
||||||
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Translate(center_offset));
|
result.view_model = Dqn_M2x3_Mul(result.view_model, Dqn_M2x3_Scale(inverse_scale));
|
||||||
}
|
result.view_model = Dqn_M2x3_Mul(result.view_model, Dqn_M2x3_Rotate(-camera.rotate_rads));
|
||||||
|
result.view_model = Dqn_M2x3_Mul(result.view_model, Dqn_M2x3_Translate(-rotate_origin));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
Dqn_M2x3 identity = Dqn_M2x3_Mul(result.model_view, result.view_model);
|
||||||
|
DQN_ASSERT(identity == Dqn_M2x3_Identity());
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +207,7 @@ static FP_GameEntity *FP_Game_MakeEntityPointerFV(FP_Game *game, DQN_FMT_STRING_
|
|||||||
game->play.entity_free_list = game->play.entity_free_list->next;
|
game->play.entity_free_list = game->play.entity_free_list->next;
|
||||||
result->next = nullptr;
|
result->next = nullptr;
|
||||||
} else {
|
} else {
|
||||||
if (game->play.entities.size >= (FP_GAME_ENTITY_HANDLE_INDEX_MAX + 1))
|
if (game->play.entities.size > FP_GAME_ENTITY_HANDLE_INDEX_MAX)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
result = Dqn_VArray_Make(&game->play.entities, Dqn_ZeroMem_Yes);
|
result = Dqn_VArray_Make(&game->play.entities, Dqn_ZeroMem_Yes);
|
||||||
@@ -583,7 +580,7 @@ static Dqn_Slice<Dqn_V2I> FP_Game_AStarPathFind(FP_Game *game,
|
|||||||
Dqn_DSMap_MakeKeyU64(&astar_info, src_tile_u64).value->tile = src_tile;
|
Dqn_DSMap_MakeKeyU64(&astar_info, src_tile_u64).value->tile = src_tile;
|
||||||
|
|
||||||
// NOTE: Do the A* process =====================================================================
|
// NOTE: Do the A* process =====================================================================
|
||||||
Dqn_usize last_successful_manhattan_dist = UINT64_MAX;
|
Dqn_usize last_successful_manhattan_dist = DQN_USIZE_MAX;
|
||||||
Dqn_V2I last_successful_tile = src_tile;
|
Dqn_V2I last_successful_tile = src_tile;
|
||||||
|
|
||||||
auto zone_astar_expand = Dqn_Profiler_BeginZoneWithIndex(DQN_STRING8("FP_Update: A* expand"), FP_ProfileZone_FPUpdate_AStarExpand);
|
auto zone_astar_expand = Dqn_Profiler_BeginZoneWithIndex(DQN_STRING8("FP_Update: A* expand"), FP_ProfileZone_FPUpdate_AStarExpand);
|
||||||
@@ -748,7 +745,6 @@ static Dqn_V2 FP_Game_CalcWaypointWorldPos(FP_Game *game, FP_GameEntityHandle en
|
|||||||
case FP_GameWaypointType_Queue: {
|
case FP_GameWaypointType_Queue: {
|
||||||
Dqn_ArrayFindResult<FP_GameEntityHandle> find_result = Dqn_FArray_Find<FP_GameEntityHandle>(&waypoint_entity->building_queue, entity_handle);
|
Dqn_ArrayFindResult<FP_GameEntityHandle> find_result = Dqn_FArray_Find<FP_GameEntityHandle>(&waypoint_entity->building_queue, entity_handle);
|
||||||
Dqn_usize index_in_queue = find_result.index;
|
Dqn_usize index_in_queue = find_result.index;
|
||||||
Dqn_Rect entity_hit_box = FP_Game_CalcEntityWorldHitBox(game, entity_handle);
|
|
||||||
Dqn_Rect waypoint_hit_box = FP_Game_CalcEntityWorldHitBox(game, waypoint_entity->handle);
|
Dqn_Rect waypoint_hit_box = FP_Game_CalcEntityWorldHitBox(game, waypoint_entity->handle);
|
||||||
|
|
||||||
Dqn_V2 queue_starting_p = {};
|
Dqn_V2 queue_starting_p = {};
|
||||||
@@ -898,40 +894,249 @@ static void FP_Game_EntityTransitionState(FP_Game *game, FP_GameEntity *entity,
|
|||||||
case FP_EntityType_MerchantTerry:
|
case FP_EntityType_MerchantTerry:
|
||||||
case FP_EntityType_PhoneMessageProjectile:
|
case FP_EntityType_PhoneMessageProjectile:
|
||||||
case FP_EntityType_Count: break;
|
case FP_EntityType_Count: break;
|
||||||
|
case FP_EntityType_AirportTerryPlane:
|
||||||
|
case FP_EntityType_MobSpawner:
|
||||||
|
case FP_EntityType_PortalMonkey: break;
|
||||||
|
case FP_EntityType_Billboard: break;
|
||||||
}
|
}
|
||||||
// NOTE: If no returns are hit above we proceed with the state change
|
// NOTE: If no returns are hit above we proceed with the state change
|
||||||
entity->action.next_state = desired_state;
|
entity->action.next_state = desired_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FP_GameRenderScanlines(TELY_Renderer *renderer, Dqn_f32 scanline_gap, Dqn_f32 scanline_thickness,
|
static void FP_GameRenderScanlines(TELY_Renderer *renderer,
|
||||||
Dqn_V2 screen_size, Dqn_V2 camera_offset)
|
Dqn_f32 scanline_gap,
|
||||||
|
Dqn_f32 scanline_thickness,
|
||||||
|
Dqn_V2 screen_size)
|
||||||
{
|
{
|
||||||
|
TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity());
|
||||||
|
DQN_DEFER { TELY_Render_PopTransform(renderer); };
|
||||||
Dqn_f32 scanline_interval = scanline_gap + scanline_thickness;
|
Dqn_f32 scanline_interval = scanline_gap + scanline_thickness;
|
||||||
Dqn_f32 y_offset = fmodf(camera_offset.y, scanline_interval);
|
for (Dqn_f32 y = 0; y < screen_size.h; y += scanline_interval) {
|
||||||
|
|
||||||
for (Dqn_f32 y = -y_offset; y < screen_size.h; y += scanline_interval)
|
|
||||||
{
|
|
||||||
Dqn_V2 start = Dqn_V2_InitNx2(0, y);
|
Dqn_V2 start = Dqn_V2_InitNx2(0, y);
|
||||||
Dqn_V2 end = Dqn_V2_InitNx2(screen_size.w, y);
|
Dqn_V2 end = Dqn_V2_InitNx2(screen_size.w, y);
|
||||||
TELY_Render_LineColourV4(renderer, start, end, TELY_Colour_V4Alpha(TELY_COLOUR_WHITE_V4, 0.1f), scanline_thickness);
|
TELY_Render_LineColourV4(renderer, start, end, TELY_Colour_V4Alpha(TELY_COLOUR_WHITE_V4, 0.1f), scanline_thickness);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FP_GameRenderCameraFollowScanlines(TELY_Renderer *renderer,
|
static FP_GameCanMoveToPositionResult FP_Game_CanEntityMoveToPosition(FP_Game *game, FP_GameEntityHandle entity_handle, Dqn_V2 delta_pos)
|
||||||
Dqn_V2 screen_size,
|
|
||||||
Dqn_V2 camera_offset,
|
|
||||||
Dqn_f32 scanline_gap,
|
|
||||||
Dqn_f32 scanline_thickness)
|
|
||||||
{
|
{
|
||||||
Dqn_f32 y_offset = camera_offset.y;
|
FP_GameCanMoveToPositionResult result = {};
|
||||||
|
FP_GameEntity *entity = FP_Game_GetEntity(game, entity_handle);
|
||||||
|
if (FP_Game_IsNilEntity(entity))
|
||||||
|
return result;
|
||||||
|
|
||||||
// Adjust starting y to be more negative
|
Dqn_Rect const entity_world_hit_box = FP_Game_CalcEntityWorldHitBox(game, entity->handle);
|
||||||
Dqn_f32 starting_y = -screen_size.h - 150 - y_offset;
|
Dqn_V2 const entity_pos = FP_Game_CalcEntityWorldPos(game, entity->handle);
|
||||||
|
Dqn_f32 const SENTINEL_T = 999.f;
|
||||||
|
Dqn_f32 global_earliest_t = SENTINEL_T;
|
||||||
|
Dqn_V2 global_earliest_pos_just_before_collide = {};
|
||||||
|
Dqn_V2 const entity_new_pos = entity_pos + delta_pos;
|
||||||
|
|
||||||
for (Dqn_f32 y = starting_y; y < screen_size.h; y += scanline_gap + scanline_thickness) {
|
if ((entity->flags & FP_GameEntityFlag_NoClip) == 0) {
|
||||||
Dqn_V2 start = Dqn_V2_InitNx2(camera_offset.x, y + camera_offset.y);
|
for (FP_GameEntityIterator collider_it = {}; FP_Game_DFSPostOrderWalkEntityTree(game, &collider_it, game->play.root_entity);) {
|
||||||
Dqn_V2 end = Dqn_V2_InitNx2(screen_size.w + camera_offset.x, y + camera_offset.y);
|
FP_GameEntity *collider = collider_it.entity;
|
||||||
TELY_Render_LineColourV4(renderer, start, end, TELY_Colour_V4Alpha(TELY_COLOUR_BLACK_V4, 0.1f), scanline_thickness);
|
if (collider->handle == entity->handle)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// TODO(doyle): Calculate the list of collidables at the start of the frame
|
||||||
|
if ((collider->flags & FP_GameEntityFlag_NonTraversable) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
bool skip_colliding_with_player = false;
|
||||||
|
for (FP_GameEntityHandle player : game->play.players) {
|
||||||
|
if (player == collider->handle) {
|
||||||
|
skip_colliding_with_player = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skip_colliding_with_player)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
bool entity_collides_with_collider = true;
|
||||||
|
switch (entity->type) {
|
||||||
|
case FP_EntityType_Catfish: /*FALLTHRU*/
|
||||||
|
case FP_EntityType_Smoochie: /*FALLTHRU*/
|
||||||
|
case FP_EntityType_Clinger: {
|
||||||
|
if (collider->type == FP_EntityType_Smoochie || collider->type == FP_EntityType_Clinger || collider->type == FP_EntityType_Catfish) {
|
||||||
|
entity_collides_with_collider = false;
|
||||||
|
} else if (FP_Entity_IsBuildingForMobs(collider)) {
|
||||||
|
#if 0
|
||||||
|
// NOTE: We disable collision on buildings we have visited to avoid some
|
||||||
|
// problems ...
|
||||||
|
if (FP_SentinelList_Find(&entity->buildings_visited, collider->handle)) {
|
||||||
|
entity_collides_with_collider = false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
entity_collides_with_collider = false;
|
||||||
|
#endif
|
||||||
|
} else if (collider->type == FP_EntityType_Heart ||
|
||||||
|
collider->type == FP_EntityType_MerchantGym ||
|
||||||
|
collider->type == FP_EntityType_MerchantTerry ||
|
||||||
|
collider->type == FP_EntityType_MerchantGraveyard ||
|
||||||
|
collider->type == FP_EntityType_MerchantPhoneCompany) {
|
||||||
|
entity_collides_with_collider = false;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_Terry: {
|
||||||
|
// NOTE: Don't collide with mobs when dashing (e.g. phase through)
|
||||||
|
FP_EntityTerryState state = *DQN_CAST(FP_EntityTerryState *)&entity->action.state;
|
||||||
|
if (state == FP_EntityTerryState_Dash || state == FP_EntityTerryState_DeadGhost) {
|
||||||
|
if (collider->type == FP_EntityType_Smoochie || collider->type == FP_EntityType_Clinger || collider->type == FP_EntityType_Catfish)
|
||||||
|
entity_collides_with_collider = false;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityType_Nil: break;
|
||||||
|
case FP_EntityType_MerchantTerry: break;
|
||||||
|
case FP_EntityType_Count: break;
|
||||||
|
case FP_EntityType_ClubTerry: break;
|
||||||
|
case FP_EntityType_Map: break;
|
||||||
|
case FP_EntityType_MerchantGraveyard: break;
|
||||||
|
case FP_EntityType_MerchantGym: break;
|
||||||
|
case FP_EntityType_MerchantPhoneCompany: break;
|
||||||
|
case FP_EntityType_Heart: break;
|
||||||
|
case FP_EntityType_AirportTerry: break;
|
||||||
|
case FP_EntityType_ChurchTerry: break;
|
||||||
|
case FP_EntityType_KennelTerry: break;
|
||||||
|
case FP_EntityType_PhoneMessageProjectile: break;
|
||||||
|
case FP_EntityType_AirportTerryPlane:
|
||||||
|
case FP_EntityType_MobSpawner:
|
||||||
|
case FP_EntityType_PortalMonkey: break;
|
||||||
|
case FP_EntityType_Billboard: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entity_collides_with_collider)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// NOTE: Sweep collider with half the radius of the source entity
|
||||||
|
Dqn_Rect collider_world_hit_box = FP_Game_CalcEntityWorldHitBox(game, collider->handle);
|
||||||
|
if (Dqn_V2_Area(collider_world_hit_box.size) <= 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Dqn_Rect swept_collider_world_hit_box = collider_world_hit_box;
|
||||||
|
swept_collider_world_hit_box.pos -= (entity_world_hit_box.size * .5f);
|
||||||
|
swept_collider_world_hit_box.size += entity_world_hit_box.size;
|
||||||
|
|
||||||
|
if (!Dqn_Rect_ContainsPoint(swept_collider_world_hit_box, entity_new_pos))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Dqn_f32 collider_left_wall_x = swept_collider_world_hit_box.pos.x;
|
||||||
|
Dqn_f32 collider_right_wall_x = swept_collider_world_hit_box.pos.x + swept_collider_world_hit_box.size.w;
|
||||||
|
Dqn_f32 collider_top_wall_y = swept_collider_world_hit_box.pos.y;
|
||||||
|
Dqn_f32 collider_bottom_wall_y = swept_collider_world_hit_box.pos.y + swept_collider_world_hit_box.size.h;
|
||||||
|
|
||||||
|
Dqn_V2 o = entity_pos;
|
||||||
|
Dqn_V2 d = delta_pos;
|
||||||
|
|
||||||
|
// NOTE: Solve collision by determining the 't' value at which
|
||||||
|
// we hit one of the walls of the collider and move the entity
|
||||||
|
// at exactly that point.
|
||||||
|
// O + td = x
|
||||||
|
// td = x - O
|
||||||
|
// t = (x - O) / d
|
||||||
|
|
||||||
|
Dqn_f32 earliest_t = SENTINEL_T;
|
||||||
|
if (d.x != 0.f) {
|
||||||
|
Dqn_f32 left_t = (collider_left_wall_x - o.x) / d.x;
|
||||||
|
Dqn_f32 right_t = (collider_right_wall_x - o.x) / d.x;
|
||||||
|
if (left_t >= 0.f && left_t <= 1.f)
|
||||||
|
earliest_t = DQN_MIN(earliest_t, left_t);
|
||||||
|
if (right_t >= 0.f && right_t <= 1.f)
|
||||||
|
earliest_t = DQN_MIN(earliest_t, right_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d.y != 0.f) {
|
||||||
|
Dqn_f32 top_t = (collider_top_wall_y - o.y) / d.y;
|
||||||
|
Dqn_f32 bottom_t = (collider_bottom_wall_y - o.y) / d.y;
|
||||||
|
if (top_t >= 0.f && top_t <= 1.f)
|
||||||
|
earliest_t = DQN_MIN(earliest_t, top_t);
|
||||||
|
if (bottom_t >= 0.f && bottom_t <= 1.f)
|
||||||
|
earliest_t = DQN_MIN(earliest_t, bottom_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (earliest_t < global_earliest_t) {
|
||||||
|
global_earliest_t = earliest_t;
|
||||||
|
global_earliest_pos_just_before_collide = entity_pos + (d * earliest_t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.yes = global_earliest_t == SENTINEL_T;
|
||||||
|
if (!result.yes)
|
||||||
|
result.next_closest_valid_move = delta_pos * global_earliest_t;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void FP_Game_MoveEntity(FP_Game *game, FP_GameEntityHandle entity_handle, Dqn_V2 acceleration_meters_per_s)
|
||||||
|
{
|
||||||
|
// f"(t) = a
|
||||||
|
// f'(t) = at + v
|
||||||
|
// f (t) = 0.5f*a(t^2) + vt + p
|
||||||
|
|
||||||
|
FP_GameEntity *entity = FP_Game_GetEntity(game, entity_handle);
|
||||||
|
if (FP_Game_IsNilEntity(entity))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Dqn_f32 t = DQN_CAST(Dqn_f32)DQN_SQUARED(FP_GAME_PHYSICS_STEP);
|
||||||
|
Dqn_f32 t_squared = DQN_SQUARED(t);
|
||||||
|
|
||||||
|
Dqn_f32 velocity_falloff_coefficient = 0.82f;
|
||||||
|
Dqn_f32 acceleration_feel_good_factor = 15'000.f;
|
||||||
|
Dqn_V2 acceleration = FP_Game_MetersToPixelsV2(game->play, acceleration_meters_per_s) * acceleration_feel_good_factor;
|
||||||
|
entity->velocity = (acceleration * t) + entity->velocity * velocity_falloff_coefficient;
|
||||||
|
|
||||||
|
// NOTE: Zero out velocity with epsilon
|
||||||
|
if (DQN_ABS(entity->velocity.x) < 5.f)
|
||||||
|
entity->velocity.x = 0.f;
|
||||||
|
if (DQN_ABS(entity->velocity.y) < 5.f)
|
||||||
|
entity->velocity.y = 0.f;
|
||||||
|
|
||||||
|
Dqn_V2 const delta_pos = (acceleration * 0.5f * t_squared) + (entity->velocity * t);
|
||||||
|
Dqn_Rect const entity_world_hit_box = FP_Game_CalcEntityWorldHitBox(game, entity->handle);
|
||||||
|
Dqn_V2 const entity_pos = FP_Game_CalcEntityWorldPos(game, entity->handle);
|
||||||
|
Dqn_V2 const entity_new_pos = entity_pos + delta_pos;
|
||||||
|
|
||||||
|
FP_GameCanMoveToPositionResult move_to_result = FP_Game_CanEntityMoveToPosition(game, entity->handle, delta_pos);
|
||||||
|
if (move_to_result.yes) {
|
||||||
|
entity->local_pos += delta_pos;
|
||||||
|
} else {
|
||||||
|
entity->local_pos += move_to_result.next_closest_valid_move;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Dqn_Rect FP_Game_GetBuildingPlacementRectForEntity(FP_Game *game, FP_GamePlaceableBuilding placeable_building, FP_GameEntityHandle handle)
|
||||||
|
{
|
||||||
|
Dqn_Rect result = {};
|
||||||
|
FP_GameEntity *entity = FP_Game_GetEntity(game, handle);
|
||||||
|
if (FP_Game_IsNilEntity(entity))
|
||||||
|
return result;
|
||||||
|
|
||||||
|
FP_EntityRenderData render_data = FP_Entity_GetRenderData(game, placeable_building.type, placeable_building.state, entity->direction);
|
||||||
|
Dqn_Rect box = FP_Game_CalcEntityWorldHitBox(game, entity->handle);
|
||||||
|
Dqn_V2 build_p = {};
|
||||||
|
switch (entity->direction) {
|
||||||
|
case FP_GameDirection_Up: {
|
||||||
|
build_p = Dqn_Rect_InterpolatedPoint(box, Dqn_V2_InitNx2(0.5f, 0.f)) - Dqn_V2_InitNx2(0.f, render_data.render_size.h * .5f + 10.f);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_GameDirection_Down: {
|
||||||
|
build_p = Dqn_Rect_InterpolatedPoint(box, Dqn_V2_InitNx2(0.5f, 1.f)) + Dqn_V2_InitNx2(0.f, render_data.render_size.h * .5f + 10.f);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_GameDirection_Left: {
|
||||||
|
build_p = Dqn_Rect_InterpolatedPoint(box, Dqn_V2_InitNx2(0.0f, 0.5f)) - Dqn_V2_InitNx2(render_data.render_size.w * .5f + 10.f, 0);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_GameDirection_Right: {
|
||||||
|
build_p = Dqn_Rect_InterpolatedPoint(box, Dqn_V2_InitNx2(1.f, 0.5f)) + Dqn_V2_InitNx2(render_data.render_size.w * .5f + 10.f, 0);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.size = render_data.render_size;
|
||||||
|
result.pos = build_p - (render_data.render_size * .5f);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|||||||
+79
-21
@@ -1,4 +1,4 @@
|
|||||||
#if defined(__clang__)
|
#if defined(_CLANGD)
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "feely_pona_unity.h"
|
#include "feely_pona_unity.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -45,15 +45,16 @@ struct FP_GameShape
|
|||||||
TELY_RenderShapeMode render_mode;
|
TELY_RenderShapeMode render_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint64_t FP_GAME_ENTITY_HANDLE_GENERATION_MASK = 0xFFFF'0000'0000'0000;
|
const Dqn_usize FP_GAME_ENTITY_HANDLE_GENERATION_MASK_BIT_COUNT = 16;
|
||||||
const uint64_t FP_GAME_ENTITY_HANDLE_GENERATION_RSHIFT = 48;
|
const Dqn_usize FP_GAME_ENTITY_HANDLE_INDEX_MASK = DQN_USIZE_MAX >> FP_GAME_ENTITY_HANDLE_GENERATION_MASK_BIT_COUNT;
|
||||||
const uint64_t FP_GAME_ENTITY_HANDLE_GENERATION_MAX = FP_GAME_ENTITY_HANDLE_GENERATION_MASK >> FP_GAME_ENTITY_HANDLE_GENERATION_RSHIFT;
|
const Dqn_usize FP_GAME_ENTITY_HANDLE_INDEX_MAX = FP_GAME_ENTITY_HANDLE_INDEX_MASK;
|
||||||
|
const Dqn_usize FP_GAME_ENTITY_HANDLE_GENERATION_MASK = ~FP_GAME_ENTITY_HANDLE_INDEX_MASK;
|
||||||
|
const Dqn_usize FP_GAME_ENTITY_HANDLE_GENERATION_RSHIFT = (sizeof(Dqn_usize) * 8) - FP_GAME_ENTITY_HANDLE_GENERATION_MASK_BIT_COUNT;
|
||||||
|
const Dqn_usize FP_GAME_ENTITY_HANDLE_GENERATION_MAX = FP_GAME_ENTITY_HANDLE_GENERATION_MASK >> FP_GAME_ENTITY_HANDLE_GENERATION_RSHIFT;
|
||||||
|
|
||||||
const uint64_t FP_GAME_ENTITY_HANDLE_INDEX_MASK = 0x0000'FFFF'FFFF'FFFF;
|
|
||||||
const uint64_t FP_GAME_ENTITY_HANDLE_INDEX_MAX = FP_GAME_ENTITY_HANDLE_INDEX_MASK - 1;
|
|
||||||
struct FP_GameEntityHandle
|
struct FP_GameEntityHandle
|
||||||
{
|
{
|
||||||
uint64_t id;
|
Dqn_usize id;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FP_GameWaypointArrive
|
enum FP_GameWaypointArrive
|
||||||
@@ -157,6 +158,34 @@ enum FP_GameEntityFaction
|
|||||||
FP_GameEntityFaction_Foe,
|
FP_GameEntityFaction_Foe,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum FP_GameInGameMenu
|
||||||
|
{
|
||||||
|
FP_GameInGameMenu_Nil,
|
||||||
|
FP_GameInGameMenu_Build,
|
||||||
|
FP_GameInGameMenu_Merchant,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FP_GameKeyBind
|
||||||
|
{
|
||||||
|
TELY_PlatformInputScanCode scan_code;
|
||||||
|
TELY_PlatformInputGamepadKey gamepad_key;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FP_GameControls
|
||||||
|
{
|
||||||
|
FP_GameKeyBind up;
|
||||||
|
FP_GameKeyBind down;
|
||||||
|
FP_GameKeyBind left;
|
||||||
|
FP_GameKeyBind right;
|
||||||
|
FP_GameKeyBind attack;
|
||||||
|
FP_GameKeyBind buy_building;
|
||||||
|
FP_GameKeyBind buy_upgrade;
|
||||||
|
FP_GameKeyBind range_attack;
|
||||||
|
FP_GameKeyBind build_mode;
|
||||||
|
FP_GameKeyBind strafe;
|
||||||
|
FP_GameKeyBind dash;
|
||||||
|
};
|
||||||
|
|
||||||
struct FP_GameEntity
|
struct FP_GameEntity
|
||||||
{
|
{
|
||||||
FP_GameEntity *next;
|
FP_GameEntity *next;
|
||||||
@@ -190,10 +219,12 @@ struct FP_GameEntity
|
|||||||
// NOTE: The entity hit box is positioned at the center of the entity.
|
// NOTE: The entity hit box is positioned at the center of the entity.
|
||||||
Dqn_V2 local_hit_box_size;
|
Dqn_V2 local_hit_box_size;
|
||||||
Dqn_V2 local_hit_box_offset;
|
Dqn_V2 local_hit_box_offset;
|
||||||
|
Dqn_f32 trauma01;
|
||||||
|
|
||||||
Dqn_V2 attack_box_size;
|
Dqn_V2 attack_box_size;
|
||||||
Dqn_V2 attack_box_offset;
|
Dqn_V2 attack_box_offset;
|
||||||
bool attack_processed;
|
bool attack_processed;
|
||||||
|
Dqn_usize hit_on_clock_ms;
|
||||||
bool is_dying;
|
bool is_dying;
|
||||||
uint64_t last_attack_timestamp;
|
uint64_t last_attack_timestamp;
|
||||||
uint64_t attack_cooldown_ms;
|
uint64_t attack_cooldown_ms;
|
||||||
@@ -237,6 +268,17 @@ struct FP_GameEntity
|
|||||||
Dqn_FArray<FP_GameEntityHandle, 3> building_queue;
|
Dqn_FArray<FP_GameEntityHandle, 3> building_queue;
|
||||||
uint64_t building_queue_next_sort_timestamp_ms;
|
uint64_t building_queue_next_sort_timestamp_ms;
|
||||||
FP_GameEntityHandle queued_at_building;
|
FP_GameEntityHandle queued_at_building;
|
||||||
|
|
||||||
|
FP_GameInGameMenu in_game_menu;
|
||||||
|
bool build_mode_can_place_building;
|
||||||
|
Dqn_usize build_mode_building_index;
|
||||||
|
|
||||||
|
FP_GameControls controls;
|
||||||
|
|
||||||
|
Dqn_V2 merchant_terry_menu_pos;
|
||||||
|
Dqn_V2 merchant_graveyard_menu_pos;
|
||||||
|
Dqn_V2 merchant_gym_menu_pos;
|
||||||
|
Dqn_V2 merchant_phone_company_menu_pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FP_GameEntityIterator
|
struct FP_GameEntityIterator
|
||||||
@@ -254,14 +296,15 @@ struct FP_GameEntityIterator
|
|||||||
|
|
||||||
struct FP_GameCamera
|
struct FP_GameCamera
|
||||||
{
|
{
|
||||||
|
Dqn_V2 size;
|
||||||
Dqn_V2 world_pos;
|
Dqn_V2 world_pos;
|
||||||
|
Dqn_V2 world_pos_target;
|
||||||
Dqn_f32 rotate_rads;
|
Dqn_f32 rotate_rads;
|
||||||
Dqn_V2 scale;
|
Dqn_V2 scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FP_GameAudio
|
enum FP_GameAudio
|
||||||
{
|
{
|
||||||
FP_GameAudio_TestAudio,
|
|
||||||
FP_GameAudio_TerryHit,
|
FP_GameAudio_TerryHit,
|
||||||
FP_GameAudio_Smooch,
|
FP_GameAudio_Smooch,
|
||||||
FP_GameAudio_Woosh,
|
FP_GameAudio_Woosh,
|
||||||
@@ -280,13 +323,6 @@ enum FP_GameAudio
|
|||||||
FP_GameAudio_Count,
|
FP_GameAudio_Count,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FP_GameInGameMenu
|
|
||||||
{
|
|
||||||
FP_GameInGameMenu_Nil,
|
|
||||||
FP_GameInGameMenu_Build,
|
|
||||||
FP_GameInGameMenu_Merchant,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum FP_GameState
|
enum FP_GameState
|
||||||
{
|
{
|
||||||
FP_GameState_IntroScreen,
|
FP_GameState_IntroScreen,
|
||||||
@@ -309,7 +345,7 @@ struct FP_GamePlay
|
|||||||
FP_GameEntity *entity_free_list;
|
FP_GameEntity *entity_free_list;
|
||||||
FP_GameEntity *map;
|
FP_GameEntity *map;
|
||||||
|
|
||||||
FP_GameEntityHandle player;
|
Dqn_FArray<FP_GameEntityHandle, 2> players;
|
||||||
FP_GameRenderSprite player_merchant_menu;
|
FP_GameRenderSprite player_merchant_menu;
|
||||||
uint64_t player_trigger_purchase_upgrade_timestamp;
|
uint64_t player_trigger_purchase_upgrade_timestamp;
|
||||||
uint64_t player_trigger_purchase_building_timestamp;
|
uint64_t player_trigger_purchase_building_timestamp;
|
||||||
@@ -327,6 +363,7 @@ struct FP_GamePlay
|
|||||||
FP_GameEntityHandle prev_hot_entity;
|
FP_GameEntityHandle prev_hot_entity;
|
||||||
FP_GameEntityHandle prev_active_entity;
|
FP_GameEntityHandle prev_active_entity;
|
||||||
|
|
||||||
|
Dqn_FArray<FP_GameEntityHandle, 2> camera_tracking_entity;
|
||||||
FP_GameCamera camera;
|
FP_GameCamera camera;
|
||||||
Dqn_f32 meters_to_pixels;
|
Dqn_f32 meters_to_pixels;
|
||||||
uint64_t clock_ms;
|
uint64_t clock_ms;
|
||||||
@@ -334,10 +371,8 @@ struct FP_GamePlay
|
|||||||
Dqn_PCG32 rng;
|
Dqn_PCG32 rng;
|
||||||
|
|
||||||
bool debug_ui;
|
bool debug_ui;
|
||||||
|
bool debug_hide_hud;
|
||||||
bool god_mode;
|
bool god_mode;
|
||||||
FP_GameInGameMenu in_game_menu;
|
|
||||||
bool build_mode_can_place_building;
|
|
||||||
Dqn_usize build_mode_building_index;
|
|
||||||
|
|
||||||
Dqn_FArray<FP_GameEntityHandle, 4> mob_spawners;
|
Dqn_FArray<FP_GameEntityHandle, 4> mob_spawners;
|
||||||
Dqn_FArray<FP_GameEntityHandle, 3> portal_monkeys;
|
Dqn_FArray<FP_GameEntityHandle, 3> portal_monkeys;
|
||||||
@@ -358,9 +393,8 @@ struct FP_Game
|
|||||||
TELY_AssetFontHandle jetbrains_mono_font;
|
TELY_AssetFontHandle jetbrains_mono_font;
|
||||||
TELY_AssetFontHandle talkco_font;
|
TELY_AssetFontHandle talkco_font;
|
||||||
TELY_AssetFontHandle talkco_font_large;
|
TELY_AssetFontHandle talkco_font_large;
|
||||||
|
TELY_AssetFontHandle talkco_font_xlarge;
|
||||||
TELY_AssetAudioHandle audio[FP_GameAudio_Count];
|
TELY_AssetAudioHandle audio[FP_GameAudio_Count];
|
||||||
Dqn_Slice<TELY_AssetSpriteAnimation> hero_sprite_anims;
|
|
||||||
TELY_AssetSpriteSheet hero_sprite_sheet;
|
|
||||||
TELY_AssetSpriteSheet atlas_sprite_sheet;
|
TELY_AssetSpriteSheet atlas_sprite_sheet;
|
||||||
TELY_RFui rfui;
|
TELY_RFui rfui;
|
||||||
FP_GamePlay play;
|
FP_GamePlay play;
|
||||||
@@ -394,3 +428,27 @@ FP_GamePlaceableBuilding const PLACEABLE_BUILDINGS[] = {
|
|||||||
{FP_EntityType_ClubTerry, FP_EntityClubTerryState_Idle},
|
{FP_EntityType_ClubTerry, FP_EntityClubTerryState_Idle},
|
||||||
{FP_EntityType_KennelTerry, FP_EntityKennelTerryState_Idle},
|
{FP_EntityType_KennelTerry, FP_EntityKennelTerryState_Idle},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct FP_GameCanMoveToPositionResult
|
||||||
|
{
|
||||||
|
bool yes;
|
||||||
|
Dqn_V2 next_closest_valid_move;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FP_GameCameraM2x3
|
||||||
|
{
|
||||||
|
Dqn_M2x3 model_view;
|
||||||
|
Dqn_M2x3 view_model;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Dqn_f32 const FP_GAME_PHYSICS_STEP = 1 / 60.f;
|
||||||
|
|
||||||
|
#define FP_Game_MetersToPixelsNx1(game, val) ((val) * (game).meters_to_pixels)
|
||||||
|
#define FP_Game_MetersToPixelsNx2(game, x, y) (Dqn_V2_InitNx2(x, y) * (game).meters_to_pixels)
|
||||||
|
#define FP_Game_MetersToPixelsV2(game, xy) (xy * (game).meters_to_pixels)
|
||||||
|
|
||||||
|
#define FP_Game_PixelsToMetersNx1(game, val) ((val) * (1.f/(game).meters_to_pixels))
|
||||||
|
#define FP_Game_PixelsToMetersNx2(game, x, y) (Dqn_V2_InitNx2(x, y) * (1.f/(game).meters_to_pixels))
|
||||||
|
#define FP_Game_PixelsToMetersV2(game, xy) (xy * (1.f/(game).meters_to_pixels))
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
#if defined(__clang__)
|
#if defined(_CLANGD)
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "feely_pona_unity.h"
|
#include "feely_pona_unity.h"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ static Dqn_String8 SpriteAnimNameFromFilePath(Dqn_String8 path)
|
|||||||
|
|
||||||
int main(int argc, char const *argv[])
|
int main(int argc, char const *argv[])
|
||||||
{
|
{
|
||||||
Dqn_Library_Init();
|
Dqn_Library_Init(Dqn_LibraryOnInit_Nil);
|
||||||
Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr);
|
Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr);
|
||||||
|
|
||||||
if (argc != 4) {
|
if (argc != 4) {
|
||||||
|
|||||||
+11
-4
@@ -1,4 +1,4 @@
|
|||||||
#if defined(__clang__)
|
#if defined(_CLANGD)
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "feely_pona_unity.h"
|
#include "feely_pona_unity.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -115,14 +115,21 @@ FP_SentinelListLink<T> *FP_SentinelList_Erase(FP_SentinelList<T> *list, FP_Senti
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void FP_SentinelList_Deinit(FP_SentinelList<T> *list, TELY_ChunkPool *pool)
|
void FP_SentinelList_Clear(FP_SentinelList<T> *list, TELY_ChunkPool *pool)
|
||||||
{
|
{
|
||||||
if (!list || !pool)
|
if (!list || !pool)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (FP_SentinelListLink<T> *link = nullptr; FP_SentinelList_Iterate(list, &link); )
|
for (FP_SentinelListLink<T> *link = nullptr; FP_SentinelList_Iterate(list, &link); )
|
||||||
link = FP_SentinelList_Erase(list, link, pool);
|
link = FP_SentinelList_Erase(list, link, pool);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void FP_SentinelList_Deinit(FP_SentinelList<T> *list, TELY_ChunkPool *pool)
|
||||||
|
{
|
||||||
|
if (!list || !pool)
|
||||||
|
return;
|
||||||
|
FP_SentinelList_Clear(list, pool);
|
||||||
TELY_ChunkPool_Dealloc(pool, list->sentinel);
|
TELY_ChunkPool_Dealloc(pool, list->sentinel);
|
||||||
*list = {};
|
*list = {};
|
||||||
}
|
}
|
||||||
@@ -131,8 +138,8 @@ template <typename T>
|
|||||||
FP_SentinelListLink<T> *FP_SentinelList_Find(FP_SentinelList<T> const *list, T const &find)
|
FP_SentinelListLink<T> *FP_SentinelList_Find(FP_SentinelList<T> const *list, T const &find)
|
||||||
{
|
{
|
||||||
FP_SentinelListLink<T> *result = nullptr;
|
FP_SentinelListLink<T> *result = nullptr;
|
||||||
for (FP_SentinelListLink<FP_GameEntityHandle> *link = nullptr;
|
for (FP_SentinelListLink<T> *link = nullptr;
|
||||||
!result && FP_SentinelList_Iterate<FP_GameEntityHandle>(DQN_CAST(FP_SentinelList<T> *)list, &link); ) {
|
!result && FP_SentinelList_Iterate<T>(DQN_CAST(FP_SentinelList<T> *)list, &link); ) {
|
||||||
if (link->data == find)
|
if (link->data == find)
|
||||||
result = link;
|
result = link;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with inte
|
|||||||
#include "feely_pona_entity.h"
|
#include "feely_pona_entity.h"
|
||||||
#include "feely_pona_game.h"
|
#include "feely_pona_game.h"
|
||||||
|
|
||||||
|
#include "feely_pona_entity.cpp"
|
||||||
#include "feely_pona_game.cpp"
|
#include "feely_pona_game.cpp"
|
||||||
#include "feely_pona_entity_create.cpp"
|
#include "feely_pona_entity_create.cpp"
|
||||||
#include "feely_pona_misc.cpp"
|
#include "feely_pona_misc.cpp"
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
#include "feely_pona_unity_nodll.h"
|
||||||
@@ -42,19 +42,23 @@
|
|||||||
|
|
||||||
DQN_GCC_WARNING_PUSH
|
DQN_GCC_WARNING_PUSH
|
||||||
DQN_GCC_WARNING_DISABLE(-Wunused-function)
|
DQN_GCC_WARNING_DISABLE(-Wunused-function)
|
||||||
#include "External/tely/external/stb/stb_image.h"
|
#include "External/tely/External/stb/stb_image.h"
|
||||||
DQN_GCC_WARNING_POP
|
DQN_GCC_WARNING_POP
|
||||||
|
|
||||||
// =================================================================================================
|
// =================================================================================================
|
||||||
|
|
||||||
#include "External/tely/external/raylib/raylib.h"
|
#include "External/tely/External/raylib/raylib.h"
|
||||||
#include "External/tely/external/raylib/rlgl.h"
|
#include "External/tely/External/raylib/rlgl.h"
|
||||||
#include "External/tely/external/raylib/external/glfw/include/GLFW/glfw3.h"
|
#include "External/tely/External/raylib/external/glfw/include/GLFW/glfw3.h"
|
||||||
|
|
||||||
// NOTE: TELY ======================================================================================
|
// NOTE: TELY ======================================================================================
|
||||||
|
|
||||||
DQN_MSVC_WARNING_PUSH
|
DQN_MSVC_WARNING_PUSH
|
||||||
DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with internal linkage has been removed
|
DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with internal linkage has been removed
|
||||||
|
|
||||||
|
DQN_GCC_WARNING_PUSH
|
||||||
|
DQN_GCC_WARNING_DISABLE(-Wunused-function)
|
||||||
|
|
||||||
#include "External/tely/tely_profile.h"
|
#include "External/tely/tely_profile.h"
|
||||||
#include "External/tely/tely_platform_input.h"
|
#include "External/tely/tely_platform_input.h"
|
||||||
#include "External/tely/tely_tools.h"
|
#include "External/tely/tely_tools.h"
|
||||||
@@ -80,15 +84,21 @@ DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with inte
|
|||||||
#include "feely_pona_entity.h"
|
#include "feely_pona_entity.h"
|
||||||
#include "feely_pona_game.h"
|
#include "feely_pona_game.h"
|
||||||
|
|
||||||
|
#include "feely_pona_entity.cpp"
|
||||||
#include "feely_pona_game.cpp"
|
#include "feely_pona_game.cpp"
|
||||||
#include "feely_pona_entity_create.cpp"
|
#include "feely_pona_entity_create.cpp"
|
||||||
#include "feely_pona_misc.cpp"
|
#include "feely_pona_misc.cpp"
|
||||||
#include "feely_pona.cpp"
|
#include "feely_pona.cpp"
|
||||||
|
DQN_MSVC_WARNING_POP
|
||||||
|
DQN_GCC_WARNING_POP
|
||||||
|
|
||||||
|
#if defined(DQN_PLATFORM_EMSCRIPTEN)
|
||||||
|
#include <emscripten/emscripten.h>
|
||||||
|
#include <emscripten/html5.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// NOTE: TELY_Platform =============================================================================
|
// NOTE: TELY_Platform =============================================================================
|
||||||
|
|
||||||
#define TELY_PLATFORM_NO_DLL
|
#define TELY_PLATFORM_NO_DLL
|
||||||
#include "External/tely/tely_platform.cpp"
|
#include "External/tely/tely_platform.cpp"
|
||||||
#include "External/tely/tely_platform_raylib.cpp"
|
#include "External/tely/tely_platform_raylib.cpp"
|
||||||
|
|
||||||
DQN_MSVC_WARNING_POP
|
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user