Subversion Repositories Games.Descent

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
  3.  * It is copyright by its individual contributors, as recorded in the
  4.  * project's Git history.  See COPYING.txt at the top level for license
  5.  * terms and a link to the Git history.
  6.  */
  7. /* interface to OpenGL functions
  8.  * Added 9/15/99 Matthew Mueller
  9.  * Got rid of OpenGL-internal stuff 2004-5-16 Martin Schaffner
  10.  */
  11.  
  12. #ifndef _OGL_INIT_H_
  13. #define _OGL_INIT_H_
  14.  
  15. #include "dxxsconf.h"
  16. #ifdef _MSC_VER
  17. #include <windows.h>
  18. #include <stddef.h>
  19. #endif
  20.  
  21. #include "d_gl.h"
  22. #include "dsx-ns.h"
  23. #include "fwd-gr.h"
  24. #include "palette.h"
  25. #include "pstypes.h"
  26. #include "3d.h"
  27. #include "ogl_extensions.h"
  28. #include <array>
  29.  
  30. #define OGL_TEXFILT_CLASSIC  0
  31. #define OGL_TEXFILT_UPSCALE  1
  32. #define OGL_TEXFILT_TRLINEAR 2
  33.  
  34. #ifdef __cplusplus
  35.  
  36. /* we need to export ogl_texture for 2d/font.c */
  37. struct ogl_texture
  38. {
  39.         GLuint handle;
  40.         GLint internalformat;
  41.         GLenum format;
  42.         int w,h,tw,th,lw;
  43.         int bytesu;
  44.         int bytes;
  45.         GLfloat u,v;
  46.         GLfloat prio;
  47.         int wrapstate;
  48.         unsigned long numrend;
  49. };
  50.  
  51. extern ogl_texture* ogl_get_free_texture();
  52. void ogl_init_texture(ogl_texture &t, int w, int h, int flags);
  53.  
  54. void ogl_init_shared_palette(void);
  55.  
  56. namespace dcx {
  57.  
  58. #define OGL_FLAG_MIPMAP (1 << 0)
  59. #define OGL_FLAG_NOCOLOR (1 << 1)
  60. #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.
  61. void ogl_loadbmtexture_f(grs_bitmap &bm, int texfilt, bool texanis, bool edgepad);
  62. void ogl_freebmtexture(grs_bitmap &bm);
  63.  
  64. void ogl_start_frame(grs_canvas &);
  65. void ogl_end_frame(void);
  66. void ogl_set_screen_mode(void);
  67.  
  68. struct ogl_colors
  69. {
  70.         using array_type = std::array<GLfloat, 16>;
  71.         static const array_type white;
  72.         const array_type &init(int c)
  73.         {
  74.                 return
  75. #ifdef DXX_CONSTANT_TRUE
  76.                         DXX_CONSTANT_TRUE(c == -1)
  77.                         ? white
  78.                         : DXX_CONSTANT_TRUE(c != -1)
  79.                                 ? init_palette(c)
  80.                                 :
  81. #endif
  82.                 init_maybe_white(c);
  83.         }
  84.         const array_type &init_maybe_white(int c);
  85.         const array_type &init_palette(unsigned c);
  86. private:
  87.         array_type a;
  88. };
  89.  
  90. void ogl_urect(grs_canvas &, int left, int top, int right, int bot, color_palette_index color);
  91. bool ogl_ubitmapm_cs(grs_canvas &, int x, int y,int dw, int dh, grs_bitmap &bm,int c, int scale);
  92. bool ogl_ubitmapm_cs(grs_canvas &, int x, int y,int dw, int dh, grs_bitmap &bm, const ogl_colors::array_type &c, int scale);
  93. 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, unsigned texfilt);
  94. bool ogl_ubitblt(unsigned w, unsigned h, unsigned dx, unsigned dy, unsigned sx, unsigned sy, const grs_bitmap &src, grs_bitmap &dest);
  95. void ogl_upixelc(const grs_bitmap &, unsigned x, unsigned y, color_palette_index c);
  96. color_palette_index ogl_ugpixel(const grs_bitmap &bitmap, unsigned x, unsigned y);
  97. void ogl_ulinec(grs_canvas &, int left, int top, int right, int bot, int c);
  98. }
  99. #ifdef dsx
  100. namespace dsx {
  101. void ogl_cache_level_textures();
  102. }
  103. #endif
  104.  
  105. #include "3d.h"
  106. 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, unsigned orient);
  107.  
  108. template <std::size_t N>
  109. 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 unsigned orient)
  110. {
  111.         static_assert(N <= MAX_POINTS_PER_POLY, "too many points in tmap");
  112. #ifdef DXX_CONSTANT_TRUE
  113.         if (DXX_CONSTANT_TRUE(nv > N))
  114.                 DXX_ALWAYS_ERROR_FUNCTION(dxx_trap_tmap_overread, "reading beyond array");
  115. #endif
  116.         if (nv > N)
  117.                 return;
  118.         _g3_draw_tmap_2(canvas, nv, &pointlist[0], &uvl_list[0], &light_rgb[0], bmbot, bm, orient);
  119. }
  120.  
  121. void ogl_draw_vertex_reticle(int cross,int primary,int secondary,int color,int alpha,int size_offs);
  122. namespace dcx {
  123. void ogl_toggle_depth_test(int enable);
  124. void ogl_set_blending(gr_blend);
  125. unsigned pow2ize(unsigned x);//from ogl.c
  126. }
  127.  
  128. #endif
  129.  
  130. #endif /* _OGL_INIT_H_ */
  131.