2006-03-20 17:12:09 +00:00
|
|
|
/*
|
2014-06-01 17:55:23 +00:00
|
|
|
* Portions of this file are copyright Rebirth contributors and licensed as
|
|
|
|
* described in COPYING.txt.
|
|
|
|
* Portions of this file are copyright Parallax Software and licensed
|
|
|
|
* according to the Parallax license below.
|
|
|
|
* See COPYING.txt for license details.
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
|
|
|
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
2008-03-20 23:23:46 +00:00
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Protoypes for palette functions
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _PALETTE_H
|
|
|
|
#define _PALETTE_H
|
|
|
|
|
2013-10-26 03:40:50 +00:00
|
|
|
#include "pstypes.h"
|
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#ifdef __cplusplus
|
2020-07-16 02:31:04 +00:00
|
|
|
#include <cstddef>
|
2014-08-08 02:07:47 +00:00
|
|
|
#include <cstdint>
|
2013-01-06 21:11:53 +00:00
|
|
|
#include "dxxsconf.h"
|
2016-03-19 19:08:10 +00:00
|
|
|
#include "dsx-ns.h"
|
2020-05-02 21:18:42 +00:00
|
|
|
#include <array>
|
2013-01-06 21:11:53 +00:00
|
|
|
|
|
|
|
struct rgb_t {
|
|
|
|
ubyte r,g,b;
|
|
|
|
};
|
|
|
|
|
2014-08-08 02:07:47 +00:00
|
|
|
typedef uint8_t color_t;
|
|
|
|
|
2013-01-06 21:11:53 +00:00
|
|
|
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; }
|
|
|
|
|
2015-12-22 04:18:50 +00:00
|
|
|
namespace dcx {
|
|
|
|
|
2020-05-02 21:18:42 +00:00
|
|
|
struct palette_array_t : public std::array<rgb_t, 256> {};
|
2012-11-11 22:12:51 +00:00
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
#ifdef DXX_BUILD_DESCENT_II
|
2007-06-11 15:54:09 +00:00
|
|
|
#define DEFAULT_LEVEL_PALETTE "groupa.256" //don't confuse with D2_DEFAULT_PALETTE
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2013-12-17 22:14:43 +00:00
|
|
|
void copy_bound_palette(palette_array_t &d, const palette_array_t &s);
|
|
|
|
void diminish_palette(palette_array_t &palette);
|
2006-03-20 17:12:09 +00:00
|
|
|
extern void gr_palette_set_gamma( int gamma );
|
|
|
|
extern int gr_palette_get_gamma();
|
2015-12-13 18:00:48 +00:00
|
|
|
void gr_palette_load( palette_array_t &pal );
|
2014-08-08 02:07:47 +00:00
|
|
|
color_t gr_find_closest_color_current( int r, int g, int b );
|
2016-09-24 18:06:11 +00:00
|
|
|
#if !DXX_USE_OGL
|
2015-12-04 03:36:31 +00:00
|
|
|
void gr_palette_read(palette_array_t &palette);
|
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
extern void init_computed_colors(void);
|
|
|
|
extern ubyte gr_palette_gamma;
|
2013-01-06 21:03:57 +00:00
|
|
|
extern palette_array_t gr_current_pal;
|
2020-07-16 02:31:04 +00:00
|
|
|
extern palette_array_t gr_palette;
|
|
|
|
|
|
|
|
using color_palette_index = uint8_t;
|
|
|
|
|
|
|
|
static inline const rgb_t &CPAL2T(const color_palette_index c)
|
|
|
|
{
|
|
|
|
return gr_current_pal[static_cast<std::size_t>(c)];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline const rgb_t &PAL2T(const color_palette_index c)
|
|
|
|
{
|
|
|
|
return gr_palette[static_cast<std::size_t>(c)];
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CPAL2Tr(c) (CPAL2T(c).r / 63.0)
|
|
|
|
#define CPAL2Tg(c) (CPAL2T(c).g / 63.0)
|
|
|
|
#define CPAL2Tb(c) (CPAL2T(c).b / 63.0)
|
|
|
|
#define PAL2Tr(c) (PAL2T(c).r / 63.0)
|
|
|
|
#define PAL2Tg(c) (PAL2T(c).g / 63.0)
|
|
|
|
#define PAL2Tb(c) (PAL2T(c).b / 63.0)
|
|
|
|
//inline GLfloat PAL2Tr(int c);
|
|
|
|
//inline GLfloat PAL2Tg(int c);
|
|
|
|
//inline GLfloat PAL2Tb(int c);
|
2015-12-13 18:00:48 +00:00
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2020-05-17 23:35:26 +00:00
|
|
|
#ifdef DXX_BUILD_DESCENT_I
|
|
|
|
namespace dsx {
|
|
|
|
void copy_diminish_palette(palette_array_t &palette, const uint8_t *p);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#endif
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
#endif
|