Subversion Repositories Games.Descent

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 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
 
27
#ifndef _PALETTE_H
28
#define _PALETTE_H
29
 
30
#include "pstypes.h"
31
 
32
#ifdef __cplusplus
33
#include <cstddef>
34
#include <cstdint>
35
#include "dxxsconf.h"
36
#include "dsx-ns.h"
37
#include <array>
38
 
39
struct rgb_t {
40
        ubyte r,g,b;
41
};
42
 
43
typedef uint8_t color_t;
44
 
45
static inline bool operator==(const rgb_t &a, const rgb_t &b) { return a.r == b.r && a.g == b.g && a.b == b.b; }
46
 
47
namespace dcx {
48
 
49
struct palette_array_t : public std::array<rgb_t, 256> {};
50
 
51
#ifdef DXX_BUILD_DESCENT_II
52
#define DEFAULT_LEVEL_PALETTE "groupa.256" //don't confuse with D2_DEFAULT_PALETTE
53
#endif
54
 
55
void copy_bound_palette(palette_array_t &d, const palette_array_t &s);
56
void diminish_palette(palette_array_t &palette);
57
extern void gr_palette_set_gamma( int gamma );
58
extern int gr_palette_get_gamma();
59
void gr_palette_load( palette_array_t &pal );
60
color_t gr_find_closest_color_current( int r, int g, int b );
61
#if !DXX_USE_OGL
62
void gr_palette_read(palette_array_t &palette);
63
#endif
64
extern void init_computed_colors(void);
65
extern ubyte gr_palette_gamma;
66
extern palette_array_t gr_current_pal;
67
extern palette_array_t gr_palette;
68
 
69
using color_palette_index = uint8_t;
70
 
71
static inline const rgb_t &CPAL2T(const color_palette_index c)
72
{
73
        return gr_current_pal[static_cast<std::size_t>(c)];
74
}
75
 
76
static inline const rgb_t &PAL2T(const color_palette_index c)
77
{
78
        return gr_palette[static_cast<std::size_t>(c)];
79
}
80
 
81
#define CPAL2Tr(c) (CPAL2T(c).r / 63.0)
82
#define CPAL2Tg(c) (CPAL2T(c).g / 63.0)
83
#define CPAL2Tb(c) (CPAL2T(c).b / 63.0)
84
#define PAL2Tr(c) (PAL2T(c).r / 63.0)
85
#define PAL2Tg(c) (PAL2T(c).g / 63.0)
86
#define PAL2Tb(c) (PAL2T(c).b / 63.0)
87
//inline GLfloat PAL2Tr(int c);
88
//inline GLfloat PAL2Tg(int c);
89
//inline GLfloat PAL2Tb(int c);
90
}
91
 
92
#ifdef DXX_BUILD_DESCENT_I
93
namespace dsx {
94
void copy_diminish_palette(palette_array_t &palette, const uint8_t *p);
95
}
96
#endif
97
 
98
#endif
99
 
100
#endif