2014-06-01 17:55:23 +00:00
|
|
|
/*
|
2018-09-02 00:57:29 +00:00
|
|
|
* This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
|
2014-06-01 17:55:23 +00:00
|
|
|
* It is copyright by its individual contributors, as recorded in the
|
|
|
|
* project's Git history. See COPYING.txt at the top level for license
|
|
|
|
* terms and a link to the Git history.
|
|
|
|
*/
|
2008-01-29 14:49:54 +00:00
|
|
|
/* interface to OpenGL functions
|
|
|
|
* Added 9/15/99 Matthew Mueller
|
|
|
|
* Got rid of OpenGL-internal stuff 2004-5-16 Martin Schaffner
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _OGL_INIT_H_
|
|
|
|
#define _OGL_INIT_H_
|
|
|
|
|
2016-09-24 18:06:10 +00:00
|
|
|
#include "dxxsconf.h"
|
2008-01-29 14:49:54 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#include <windows.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#endif
|
|
|
|
|
2020-07-05 23:34:32 +00:00
|
|
|
#include "d_gl.h"
|
2016-03-19 19:08:10 +00:00
|
|
|
#include "dsx-ns.h"
|
2015-07-25 23:10:45 +00:00
|
|
|
#include "fwd-gr.h"
|
2020-08-24 01:31:28 +00:00
|
|
|
#include "fwd-segment.h"
|
2011-01-16 00:50:28 +00:00
|
|
|
#include "palette.h"
|
|
|
|
#include "pstypes.h"
|
2012-11-11 22:12:51 +00:00
|
|
|
#include "3d.h"
|
2020-05-02 21:18:42 +00:00
|
|
|
#include <array>
|
2011-01-16 00:50:28 +00:00
|
|
|
|
2021-09-04 12:17:14 +00:00
|
|
|
namespace dcx {
|
2012-11-11 22:12:51 +00:00
|
|
|
|
2008-01-29 14:49:54 +00:00
|
|
|
/* we need to export ogl_texture for 2d/font.c */
|
2013-12-22 22:03:07 +00:00
|
|
|
struct ogl_texture
|
|
|
|
{
|
2008-01-29 14:49:54 +00:00
|
|
|
GLuint handle;
|
|
|
|
GLint internalformat;
|
|
|
|
GLenum format;
|
|
|
|
int w,h,tw,th,lw;
|
|
|
|
int bytesu;
|
|
|
|
int bytes;
|
|
|
|
GLfloat u,v;
|
|
|
|
GLfloat prio;
|
|
|
|
int wrapstate;
|
|
|
|
unsigned long numrend;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2008-01-29 14:49:54 +00:00
|
|
|
|
|
|
|
extern ogl_texture* ogl_get_free_texture();
|
2014-11-30 22:09:19 +00:00
|
|
|
void ogl_init_texture(ogl_texture &t, int w, int h, int flags);
|
2008-01-29 14:49:54 +00:00
|
|
|
|
|
|
|
void ogl_init_shared_palette(void);
|
|
|
|
|
2021-01-17 22:23:23 +00:00
|
|
|
/* These values are written to a file as integers, so they must not be
|
|
|
|
* renumbered.
|
|
|
|
*/
|
|
|
|
enum class opengl_texture_filter : uint8_t
|
|
|
|
{
|
|
|
|
classic,
|
|
|
|
upscale,
|
|
|
|
trilinear,
|
|
|
|
};
|
|
|
|
|
2008-01-29 14:49:54 +00:00
|
|
|
#define OGL_FLAG_MIPMAP (1 << 0)
|
|
|
|
#define OGL_FLAG_NOCOLOR (1 << 1)
|
|
|
|
#define OGL_FLAG_ALPHA (1 << 31) // not required for ogl_loadbmtexture, since it uses the BM_FLAG_TRANSPARENT, but is needed for ogl_init_texture.
|
2021-01-17 22:23:23 +00:00
|
|
|
void ogl_loadbmtexture_f(grs_bitmap &bm, opengl_texture_filter texfilt, bool texanis, bool edgepad);
|
2014-11-30 22:09:20 +00:00
|
|
|
void ogl_freebmtexture(grs_bitmap &bm);
|
2008-01-29 14:49:54 +00:00
|
|
|
|
2017-02-11 21:42:33 +00:00
|
|
|
void ogl_start_frame(grs_canvas &);
|
2021-09-12 16:20:52 +00:00
|
|
|
void ogl_stereo_frame(bool left_eye, int xoff);
|
2008-01-29 14:49:54 +00:00
|
|
|
void ogl_end_frame(void);
|
|
|
|
void ogl_set_screen_mode(void);
|
|
|
|
|
2016-02-12 04:02:28 +00:00
|
|
|
struct ogl_colors
|
|
|
|
{
|
2020-05-02 21:18:42 +00:00
|
|
|
using array_type = std::array<GLfloat, 16>;
|
2016-02-12 04:02:28 +00:00
|
|
|
static const array_type white;
|
|
|
|
const array_type &init(int c)
|
|
|
|
{
|
|
|
|
return
|
|
|
|
#ifdef DXX_CONSTANT_TRUE
|
|
|
|
DXX_CONSTANT_TRUE(c == -1)
|
|
|
|
? white
|
|
|
|
: DXX_CONSTANT_TRUE(c != -1)
|
|
|
|
? init_palette(c)
|
|
|
|
:
|
|
|
|
#endif
|
|
|
|
init_maybe_white(c);
|
|
|
|
}
|
|
|
|
const array_type &init_maybe_white(int c);
|
|
|
|
const array_type &init_palette(unsigned c);
|
|
|
|
private:
|
|
|
|
array_type a;
|
|
|
|
};
|
|
|
|
|
2020-07-16 02:31:04 +00:00
|
|
|
void ogl_urect(grs_canvas &, int left, int top, int right, int bot, color_palette_index color);
|
2021-11-01 03:37:18 +00:00
|
|
|
constexpr int opengl_bitmap_use_src_bitmap = 0;
|
|
|
|
constexpr int opengl_bitmap_use_dst_canvas = -1;
|
2021-11-01 03:37:18 +00:00
|
|
|
bool ogl_ubitmapm_cs(grs_canvas &, int x, int y,int dw, int dh, grs_bitmap &bm, int c);
|
|
|
|
bool ogl_ubitmapm_cs(grs_canvas &, int x, int y,int dw, int dh, grs_bitmap &bm, const ogl_colors::array_type &c);
|
2021-01-17 22:23:23 +00:00
|
|
|
bool ogl_ubitblt_i(unsigned dw, unsigned dh, unsigned dx, unsigned dy, unsigned sw, unsigned sh, unsigned sx, unsigned sy, const grs_bitmap &src, grs_bitmap &dest, opengl_texture_filter texfilt);
|
2014-12-02 03:35:01 +00:00
|
|
|
bool ogl_ubitblt(unsigned w, unsigned h, unsigned dx, unsigned dy, unsigned sx, unsigned sy, const grs_bitmap &src, grs_bitmap &dest);
|
2020-07-16 02:31:04 +00:00
|
|
|
void ogl_upixelc(const grs_bitmap &, unsigned x, unsigned y, color_palette_index c);
|
|
|
|
color_palette_index ogl_ugpixel(const grs_bitmap &bitmap, unsigned x, unsigned y);
|
2016-12-29 03:27:09 +00:00
|
|
|
void ogl_ulinec(grs_canvas &, int left, int top, int right, int bot, int c);
|
2015-12-13 18:00:48 +00:00
|
|
|
}
|
2016-01-09 16:38:15 +00:00
|
|
|
#ifdef dsx
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dsx {
|
2015-12-13 18:00:48 +00:00
|
|
|
void ogl_cache_level_textures();
|
|
|
|
}
|
|
|
|
#endif
|
2008-01-29 14:49:54 +00:00
|
|
|
|
2020-08-24 01:31:28 +00:00
|
|
|
void _g3_draw_tmap_2(grs_canvas &, unsigned nv, const g3s_point *const *const pointlist, const g3s_uvl *uvl_list, const g3s_lrgb *light_rgb, grs_bitmap &bmbot, grs_bitmap &bm, texture2_rotation_low orient);
|
2014-09-04 03:02:21 +00:00
|
|
|
|
|
|
|
template <std::size_t N>
|
2020-08-24 01:31:28 +00:00
|
|
|
static inline void g3_draw_tmap_2(grs_canvas &canvas, const unsigned nv, const std::array<cg3s_point *, N> &pointlist, const std::array<g3s_uvl, N> &uvl_list, const std::array<g3s_lrgb, N> &light_rgb, grs_bitmap &bmbot, grs_bitmap &bm, const texture2_rotation_low orient)
|
2014-09-04 03:02:21 +00:00
|
|
|
{
|
|
|
|
static_assert(N <= MAX_POINTS_PER_POLY, "too many points in tmap");
|
2015-07-29 03:05:28 +00:00
|
|
|
#ifdef DXX_CONSTANT_TRUE
|
|
|
|
if (DXX_CONSTANT_TRUE(nv > N))
|
2014-09-04 03:02:21 +00:00
|
|
|
DXX_ALWAYS_ERROR_FUNCTION(dxx_trap_tmap_overread, "reading beyond array");
|
|
|
|
#endif
|
2017-06-07 02:44:55 +00:00
|
|
|
if (nv > N)
|
|
|
|
return;
|
2017-02-11 21:42:41 +00:00
|
|
|
_g3_draw_tmap_2(canvas, nv, &pointlist[0], &uvl_list[0], &light_rgb[0], bmbot, bm, orient);
|
2014-09-04 03:02:21 +00:00
|
|
|
}
|
2008-01-29 14:49:54 +00:00
|
|
|
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dcx {
|
2021-09-12 16:20:52 +00:00
|
|
|
void ogl_draw_vertex_reticle(grs_canvas &, int cross, int primary, int secondary, int color, int alpha, int size_offs);
|
2011-02-17 23:17:49 +00:00
|
|
|
void ogl_toggle_depth_test(int enable);
|
2017-03-18 18:07:36 +00:00
|
|
|
void ogl_set_blending(gr_blend);
|
2013-08-16 02:00:35 +00:00
|
|
|
unsigned pow2ize(unsigned x);//from ogl.c
|
2015-12-13 18:00:48 +00:00
|
|
|
}
|
2008-01-29 14:49:54 +00:00
|
|
|
|
|
|
|
#endif /* _OGL_INIT_H_ */
|