| 1 |
/* |
| 2 |
* Portions of this file are copyright Rebirth contributors and licensed as |
| 3 |
* described in COPYING.txt. |
| 4 |
* Portions of this file are copyright Parallax Software and licensed |
| 5 |
* according to the Parallax license below. |
| 6 |
* See COPYING.txt for license details. |
| 7 |
|
| 8 |
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX |
| 9 |
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO |
| 10 |
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A |
| 11 |
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS |
| 12 |
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS |
| 13 |
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE |
| 14 |
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE |
| 15 |
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS |
| 16 |
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. |
| 17 |
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. |
| 18 |
*/ |
| 19 |
|
| 20 |
/* |
| 21 |
* |
| 22 |
* Protoypes for palette functions |
| 23 |
* |
| 24 |
*/ |
| 25 |
|
| 26 |
#pragma once |
| 27 |
|
| 28 |
#include "pstypes.h" |
| 29 |
#include <cstddef> |
| 30 |
#include <cstdint> |
| 31 |
#include "dxxsconf.h" |
| 32 |
#include "dsx-ns.h" |
| 33 |
#include <array> |
| 34 |
|
| 35 |
struct rgb_t { |
| 36 |
ubyte r,g,b; |
| 37 |
[[nodiscard]] |
| 38 |
constexpr bool operator==(const rgb_t &) const = default; |
| 39 |
}; |
| 40 |
|
| 41 |
typedef uint8_t color_t; |
| 42 |
|
| 43 |
namespace dcx { |
| 44 |
|
| 45 |
struct palette_array_t : public std::array<rgb_t, 256> {}; |
| 46 |
|
| 47 |
#ifdef DXX_BUILD_DESCENT |
| 48 |
#if DXX_BUILD_DESCENT == 2 |
| 49 |
#define DEFAULT_LEVEL_PALETTE "groupa.256" //don't confuse with D2_DEFAULT_PALETTE |
| 50 |
#endif |
| 51 |
#endif |
| 52 |
|
| 53 |
void copy_bound_palette(palette_array_t &d, const palette_array_t &s); |
| 54 |
void gr_palette_set_gamma(uint8_t gamma); |
| 55 |
uint8_t gr_palette_get_gamma(); |
| 56 |
void gr_palette_load( palette_array_t &pal ); |
| 57 |
color_t gr_find_closest_color_current( int r, int g, int b ); |
| 58 |
#if !DXX_USE_OGL |
| 59 |
void gr_palette_read(palette_array_t &palette); |
| 60 |
#endif |
| 61 |
void reset_computed_colors(); |
| 62 |
extern ubyte gr_palette_gamma; |
| 63 |
extern palette_array_t gr_current_pal; |
| 64 |
extern palette_array_t gr_palette; |
| 65 |
|
| 66 |
using color_palette_index = uint8_t; |
| 67 |
|
| 68 |
#if DXX_USE_OGL |
| 69 |
static constexpr const rgb_t &PAL2T(const color_palette_index c) |
| 70 |
{ |
| 71 |
return gr_palette[static_cast<std::size_t>(c)]; |
| 72 |
} |
| 73 |
#endif |
| 74 |
|
| 75 |
} |