-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditor.h
More file actions
101 lines (82 loc) · 2.13 KB
/
Copy pathEditor.h
File metadata and controls
101 lines (82 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
Copyright (c) 2024-2025 Toksisitee. All rights reserved.
This work is licensed under the terms of the MIT license.
For a copy, refer to license.md or https://opensource.org/licenses/MIT
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
*/
#pragma once
#include <cstdint>
#define TO_STRING(s) #s
#define STRINGIFY(s) TO_STRING(s)
#if _DEBUG
#define EDITOR_CONFIG "Debug"
#else
#define EDITOR_CONFIG "Release"
#endif
#define VERSION_MAJOR 0
#define VERSION_MINOR 1
#define VERSION_PATCH 0
#define EDITOR_NAME L"PopResourceEditor"
#define EDITOR_VERSION STRINGIFY(VERSION_MAJOR) "." STRINGIFY(VERSION_MINOR) "." STRINGIFY(VERSION_PATCH)
#define EDITOR_DATE __DATE__ " " __TIME__
#define EDITOR_DEBUG_FONTS (0)
#define EDITOR_PI (3.14159265358979323846)
#define SAFE_FREE(pBuffer) if (pBuffer) \
free(pBuffer); \
typedef unsigned char BYTE;
#pragma pack(push, 1)
struct Color {
Color() = default;
Color( uint8_t r, uint8_t g, uint8_t b ) : r( r ), g( g ), b( b ) {}
uint8_t r, g, b;
float GetLuminance() const
{
return 0.299f * r + 0.587f * g + 0.114f * b;
}
bool operator==( const Color& o ) const
{
return r == o.r && g == o.g && b == o.b;
}
bool operator!=( const Color& o ) const
{
return !(*this == o);
}
bool operator<( const Color& o ) const
{
if ( r != o.r ) return r < o.r;
if ( g != o.g ) return g < o.g;
return b < o.b;
}
};
#pragma pack(pop)
struct fVec2 {
fVec2() = default;
fVec2( float _x, float _y ) : x( _x ), y( _y ) {}
float x;
float y;
};
enum eImFont : uint8_t
{
Small = 0,
Medium,
Large,
Max
};
inline void WriteRGBTexel( BYTE* pTexels, size_t x, size_t y, size_t pitch, const Color& rgb )
{
size_t i = (y * pitch) + (x * 4);
pTexels[i] = rgb.b;
pTexels[i + 1] = rgb.g;
pTexels[i + 2] = rgb.r;
pTexels[i + 3] = 255;
};
inline void WriteRGBTexel( BYTE* pTexels, size_t x, size_t y, size_t pitch, Color* rgb )
{
size_t i = (y * pitch) + (x * 4);
pTexels[i] = rgb->b;
pTexels[i + 1] = rgb->g;
pTexels[i + 2] = rgb->r;
pTexels[i + 3] = 255;
};