HoverRace  2.0
ColorPalette.h
Go to the documentation of this file.
1 // ColorPalette.h
2 //
3 // The color palette is a module, not a class. It is the same
4 // colorpalette that is always used
5 //
6 //
7 // Copyright (c) 1995-1998 - Richard Langlois and Grokksoft Inc.
8 //
9 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
10 // you may not use this file except in compliance with the License.
11 //
12 // A copy of the license should have been attached to the package from which
13 // you have taken this file. If you can not find the license you can not use
14 // this file.
15 //
16 //
17 // The author makes no representations about the suitability of
18 // this software for any purpose. It is provided "as is" "AS IS",
19 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
20 // implied.
21 //
22 // See the License for the specific language governing permissions
23 // and limitations under the License.
24 //
25 
26 #pragma once
27 
28 #include <SDL2/SDL.h>
29 
30 #include "../Util/MR_Types.h"
31 
32 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
33 # ifdef MR_ENGINE
34 # define MR_DllDeclare __declspec( dllexport )
35 # else
36 # define MR_DllDeclare __declspec( dllimport )
37 # endif
38 #else
39 # define MR_DllDeclare
40 #endif
41 
42 namespace HoverRace {
43 namespace VideoServices {
44 
45 namespace ColorPalette {
46 
47 #define MR_NB_COLORS 256
48 #define MR_RESERVED_COLORS_BEGINNING 10
49 #define MR_RESERVED_COLORS_END 15
50 #define MR_RESERVED_COLORS 6
51 #define MR_BASIC_COLORS 100 // Includes some extra space
52 #define MR_BACK_COLORS 128
53 
54 #define MR_NB_COLOR_INTENSITY 256
55 #define MR_NORMAL_INTENSITY 128
56 
57 // Color convertion tables
60 extern double basicPalette[][3];
61 extern int basicPaletteSize;
62 
63 using paletteEntry_t = SDL_Color;
64 inline constexpr MR_UInt8 &PalR(paletteEntry_t &ent) noexcept { return ent.r; }
65 inline constexpr MR_UInt8 &PalG(paletteEntry_t &ent) noexcept { return ent.g; }
66 inline constexpr MR_UInt8 &PalB(paletteEntry_t &ent) noexcept { return ent.b; }
67 
68 MR_DllDeclare paletteEntry_t *GetColors(double pGamma, double pIntensity = 0.8, double pIntensityBase = 0.0);
69 MR_DllDeclare const paletteEntry_t &ConvertColor(MR_UInt8 pRed, MR_UInt8 pGreen, MR_UInt8 pBlue, double pGamma, double pIntensity = 0.8, double pIntensityBase = 0.0) noexcept;
70 
71 std::ostream &operator<<(std::ostream &os, const paletteEntry_t &ent);
72 
73 } // namespace ColorPalette
74 
75 } // namespace VideoServices
76 } // namespace HoverRace
77 
78 #undef MR_DllDeclare
constexpr MR_UInt8 & PalG(paletteEntry_t &ent) noexcept
Definition: ColorPalette.h:65
SDL_Color paletteEntry_t
Definition: ColorPalette.h:63
#define MR_DllDeclare
Definition: ColorPalette.h:39
#define MR_NB_COLOR_INTENSITY
Definition: ColorPalette.h:54
constexpr MR_UInt8 & PalR(paletteEntry_t &ent) noexcept
Definition: ColorPalette.h:64
int basicPaletteSize
Definition: ColorTab.cpp:1062
#define MR_NB_COLORS
Definition: ColorPalette.h:47
paletteEntry_t * GetColors(double pGamma, double pIntensity, double pIntensityBase)
Generate the "basic" range of the color palette.
Definition: ColorPalette.cpp:56
MR_DllDeclare MR_UInt8 colorTable[MR_NB_COLOR_INTENSITY][MR_NB_COLORS]
Definition: ColorTab.cpp:32
const paletteEntry_t & ConvertColor(MR_UInt8 pRed, MR_UInt8 pGreen, MR_UInt8 pBlue, double pGamma, double pIntensity, double pIntensityBase) noexcept
Generate a palette entry from RGB components.
Definition: ColorPalette.cpp:113
constexpr MR_UInt8 & PalB(paletteEntry_t &ent) noexcept
Definition: ColorPalette.h:66
std::ostream & operator<<(std::ostream &os, const paletteEntry_t &ent)
Definition: ColorPalette.cpp:149
Definition: Announcement.h:24
double basicPalette[][3]
Definition: ColorTab.cpp:1064
uint8_t MR_UInt8
Definition: MR_Types.h:40
MR_DllDeclare MR_UInt8 colorAdditionTable[MR_NB_COLORS][MR_NB_COLORS]
Definition: ColorTab.cpp:547