From 24b24e2203c776aacd9744bb947f5cf47b03d328 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 30 Sep 2021 16:19:48 +0300 Subject: [PATCH] Completely hide OpenGL from the public headers --- source/core/batch.h | 8 ++++---- source/core/blend.cpp | 4 ++-- source/core/blend.h | 5 ++--- source/core/buffer.h | 1 - source/core/datatype.h | 5 ++--- source/core/framebuffer.cpp | 1 + source/core/framebuffer.h | 4 ---- source/core/frameformat.cpp | 7 ++++--- source/core/frameformat.h | 4 ++-- source/core/matrix.h | 1 - source/core/module.h | 1 - source/core/pipelinestate.cpp | 1 + source/core/pixelformat.cpp | 4 ++-- source/core/pixelformat.h | 5 ++--- source/core/predicate.cpp | 3 ++- source/core/predicate.h | 3 +-- source/core/primitivetype.cpp | 3 ++- source/core/primitivetype.h | 3 +-- source/core/program.h | 1 - source/core/sampler.cpp | 4 ++-- source/core/sampler.h | 5 ++--- source/core/stenciltest.cpp | 3 ++- source/core/stenciltest.h | 2 +- source/core/texture.cpp | 2 +- source/core/texture.h | 7 +++---- source/core/texturecube.cpp | 2 +- source/core/texturecube.h | 3 +-- 27 files changed, 41 insertions(+), 51 deletions(-) diff --git a/source/core/batch.h b/source/core/batch.h index 6f7e43d6..41dac24a 100644 --- a/source/core/batch.h +++ b/source/core/batch.h @@ -33,9 +33,9 @@ public: private: PrimitiveType prim_type; - GLenum gl_prim_type; + unsigned gl_prim_type; DataType index_type; - GLenum gl_index_type; + unsigned gl_index_type; std::vector data; unsigned max_index; @@ -44,10 +44,10 @@ public: ~Batch(); PrimitiveType get_type() const { return prim_type; } - GLenum get_gl_primitive_type() const { return gl_prim_type; } + unsigned get_gl_primitive_type() const { return gl_prim_type; } void set_index_type(DataType); DataType get_index_type() const { return index_type; } - GLenum get_gl_index_type() const { return gl_index_type; } + unsigned get_gl_index_type() const { return gl_index_type; } Batch &append(unsigned); Batch &append(const std::vector &); diff --git a/source/core/blend.cpp b/source/core/blend.cpp index a5e8f44d..324440d3 100644 --- a/source/core/blend.cpp +++ b/source/core/blend.cpp @@ -60,7 +60,7 @@ void Blend::Loader::factors(BlendFactor sf, BlendFactor df) } -GLenum get_gl_blend_equation(BlendEquation eq) +unsigned get_gl_blend_equation(BlendEquation eq) { switch(eq) { @@ -73,7 +73,7 @@ GLenum get_gl_blend_equation(BlendEquation eq) } } -GLenum get_gl_blend_factor(BlendFactor factor) +unsigned get_gl_blend_factor(BlendFactor factor) { switch(factor) { diff --git a/source/core/blend.h b/source/core/blend.h index 986844c0..ad7ba241 100644 --- a/source/core/blend.h +++ b/source/core/blend.h @@ -4,7 +4,6 @@ #include #include #include "color.h" -#include "gl.h" namespace Msp { namespace GL { @@ -63,8 +62,8 @@ struct Blend Blend(BlendEquation, BlendFactor, BlendFactor); }; -GLenum get_gl_blend_equation(BlendEquation); -GLenum get_gl_blend_factor(BlendFactor); +unsigned get_gl_blend_equation(BlendEquation); +unsigned get_gl_blend_factor(BlendFactor); void operator>>(const LexicalConverter &, BlendEquation &); void operator<<(LexicalConverter &, BlendEquation); diff --git a/source/core/buffer.h b/source/core/buffer.h index 0fb2cde1..0e183688 100644 --- a/source/core/buffer.h +++ b/source/core/buffer.h @@ -4,7 +4,6 @@ #include #include #include -#include "gl.h" namespace Msp { namespace GL { diff --git a/source/core/datatype.h b/source/core/datatype.h index 7188cb5a..1620dc58 100644 --- a/source/core/datatype.h +++ b/source/core/datatype.h @@ -3,7 +3,6 @@ #include #include -#include "gl.h" namespace Msp { namespace GL { @@ -133,8 +132,8 @@ struct TypeTraits> static const DataType type = static_cast((TypeTraits::type&0xF00) | ((TypeTraits::type&0xFF)*N*M) | ((N-1)<<12) | ((M-1)<<14)); }; -GLenum get_gl_type(DataType); -DataType from_gl_type(GLenum); +unsigned get_gl_type(DataType); +DataType from_gl_type(unsigned); void require_type(DataType); diff --git a/source/core/framebuffer.cpp b/source/core/framebuffer.cpp index 57655205..53234cc7 100644 --- a/source/core/framebuffer.cpp +++ b/source/core/framebuffer.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include diff --git a/source/core/framebuffer.h b/source/core/framebuffer.h index a58d31d8..89407e8b 100644 --- a/source/core/framebuffer.h +++ b/source/core/framebuffer.h @@ -5,10 +5,6 @@ #include "color.h" #include "frameformat.h" #include "texturecube.h" -#include -#include -#include -#include namespace Msp { namespace GL { diff --git a/source/core/frameformat.cpp b/source/core/frameformat.cpp index f56d13a6..3568dffa 100644 --- a/source/core/frameformat.cpp +++ b/source/core/frameformat.cpp @@ -1,6 +1,7 @@ #include "deviceinfo.h" #include "error.h" #include "frameformat.h" +#include "gl.h" using namespace std; @@ -123,7 +124,7 @@ PixelFormat get_attachment_pixelformat(FrameAttachment fa) return make_pixelformat(comp, type); } -GLenum get_gl_attachment(FrameAttachment fa) +unsigned get_gl_attachment(FrameAttachment fa) { if(get_attach_point(fa)==get_attach_point(DEPTH_ATTACHMENT)) return GL_DEPTH_ATTACHMENT; @@ -133,9 +134,9 @@ GLenum get_gl_attachment(FrameAttachment fa) return GL_COLOR_ATTACHMENT0+get_attach_point(fa); } -GLenum get_gl_buffer_bits(const FrameFormat &format) +unsigned get_gl_buffer_bits(const FrameFormat &format) { - GLenum bits = 0; + unsigned bits = 0; for(FrameAttachment a: format) { if(get_attach_point(a)==get_attach_point(DEPTH_ATTACHMENT)) diff --git a/source/core/frameformat.h b/source/core/frameformat.h index a78985f3..c3f6eae7 100644 --- a/source/core/frameformat.h +++ b/source/core/frameformat.h @@ -76,8 +76,8 @@ inline unsigned get_attach_point(FrameAttachment fa) PixelFormat get_attachment_pixelformat(FrameAttachment); -GLenum get_gl_attachment(FrameAttachment); -GLenum get_gl_buffer_bits(const FrameFormat &); +unsigned get_gl_attachment(FrameAttachment); +unsigned get_gl_buffer_bits(const FrameFormat &); } // namespace GL } // namespace Msp diff --git a/source/core/matrix.h b/source/core/matrix.h index cb61e292..e2f1ada0 100644 --- a/source/core/matrix.h +++ b/source/core/matrix.h @@ -4,7 +4,6 @@ #include #include #include -#include "gl.h" #include "vector.h" namespace Msp { diff --git a/source/core/module.h b/source/core/module.h index 5ea0149d..14a57fe8 100644 --- a/source/core/module.h +++ b/source/core/module.h @@ -4,7 +4,6 @@ #include #include #include "datatype.h" -#include "gl.h" #include "glsl/compiler.h" #include "glsl/sourcemap.h" diff --git a/source/core/pipelinestate.cpp b/source/core/pipelinestate.cpp index 871336bb..d99a3878 100644 --- a/source/core/pipelinestate.cpp +++ b/source/core/pipelinestate.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "blend.h" #include "buffer.h" diff --git a/source/core/pixelformat.cpp b/source/core/pixelformat.cpp index 1ee0cd09..6be6d7c9 100644 --- a/source/core/pixelformat.cpp +++ b/source/core/pixelformat.cpp @@ -169,7 +169,7 @@ void require_pixelformat(PixelFormat pf) } } -GLenum get_gl_components(PixelComponents comp) +unsigned get_gl_components(PixelComponents comp) { switch(comp) { @@ -183,7 +183,7 @@ GLenum get_gl_components(PixelComponents comp) } } -GLenum get_gl_pixelformat(PixelFormat pf) +unsigned get_gl_pixelformat(PixelFormat pf) { switch(pf) { diff --git a/source/core/pixelformat.h b/source/core/pixelformat.h index 75651a8f..65331c99 100644 --- a/source/core/pixelformat.h +++ b/source/core/pixelformat.h @@ -3,7 +3,6 @@ #include #include -#include "gl.h" #include "datatype.h" namespace Msp { @@ -99,8 +98,8 @@ inline unsigned get_pixel_size(PixelFormat f) { return get_component_count(f)*ge void require_pixelformat(PixelFormat); -GLenum get_gl_components(PixelComponents); -GLenum get_gl_pixelformat(PixelFormat); +unsigned get_gl_components(PixelComponents); +unsigned get_gl_pixelformat(PixelFormat); } // namespace GL } // namespace Msp diff --git a/source/core/predicate.cpp b/source/core/predicate.cpp index 4afc6c03..7b0c0587 100644 --- a/source/core/predicate.cpp +++ b/source/core/predicate.cpp @@ -1,4 +1,5 @@ #include +#include "gl.h" #include "predicate.h" using namespace std; @@ -6,7 +7,7 @@ using namespace std; namespace Msp { namespace GL { -GLenum get_gl_predicate(Predicate pred) +unsigned get_gl_predicate(Predicate pred) { switch(pred) { diff --git a/source/core/predicate.h b/source/core/predicate.h index c7e5991e..079ef63e 100644 --- a/source/core/predicate.h +++ b/source/core/predicate.h @@ -2,7 +2,6 @@ #define MSP_GL_PREDICATE_H_ #include -#include "gl.h" namespace Msp { namespace GL { @@ -19,7 +18,7 @@ enum Predicate NOTEQUAL }; -GLenum get_gl_predicate(Predicate); +unsigned get_gl_predicate(Predicate); void operator>>(const LexicalConverter &, Predicate &); void operator<<(LexicalConverter &, Predicate); diff --git a/source/core/primitivetype.cpp b/source/core/primitivetype.cpp index 848da800..416ebae2 100644 --- a/source/core/primitivetype.cpp +++ b/source/core/primitivetype.cpp @@ -1,4 +1,5 @@ #include +#include "gl.h" #include "primitivetype.h" using namespace std; @@ -6,7 +7,7 @@ using namespace std; namespace Msp { namespace GL { -GLenum get_gl_primitive_type(PrimitiveType pt) +unsigned get_gl_primitive_type(PrimitiveType pt) { switch(pt) { diff --git a/source/core/primitivetype.h b/source/core/primitivetype.h index b0854331..cbcb187c 100644 --- a/source/core/primitivetype.h +++ b/source/core/primitivetype.h @@ -2,7 +2,6 @@ #define MSP_GL_PRIMITIVETYPE_H_ #include -#include "gl.h" namespace Msp { namespace GL { @@ -18,7 +17,7 @@ enum PrimitiveType TRIANGLE_FAN }; -GLenum get_gl_primitive_type(PrimitiveType); +unsigned get_gl_primitive_type(PrimitiveType); void operator>>(const LexicalConverter &, PrimitiveType &); diff --git a/source/core/program.h b/source/core/program.h index b384defe..fb7fddde 100644 --- a/source/core/program.h +++ b/source/core/program.h @@ -4,7 +4,6 @@ #include #include #include -#include "gl.h" #include "module.h" #include "reflectdata.h" #include "vertexformat.h" diff --git a/source/core/sampler.cpp b/source/core/sampler.cpp index 45db2980..c36e9852 100644 --- a/source/core/sampler.cpp +++ b/source/core/sampler.cpp @@ -218,7 +218,7 @@ bool is_mipmapped(TextureFilter filter) filter==LINEAR_MIPMAP_NEAREST || filter==LINEAR_MIPMAP_LINEAR); } -GLenum get_gl_filter(TextureFilter filter) +unsigned get_gl_filter(TextureFilter filter) { switch(filter) { @@ -232,7 +232,7 @@ GLenum get_gl_filter(TextureFilter filter) } } -GLenum get_gl_wrap(TextureWrap wrap) +unsigned get_gl_wrap(TextureWrap wrap) { switch(wrap) { diff --git a/source/core/sampler.h b/source/core/sampler.h index 852c9710..b2011d3b 100644 --- a/source/core/sampler.h +++ b/source/core/sampler.h @@ -3,7 +3,6 @@ #include #include "color.h" -#include "gl.h" #include "predicate.h" namespace Msp { @@ -159,8 +158,8 @@ public: bool is_mipmapped(TextureFilter); -GLenum get_gl_filter(TextureFilter); -GLenum get_gl_wrap(TextureWrap); +unsigned get_gl_filter(TextureFilter); +unsigned get_gl_wrap(TextureWrap); void operator>>(const LexicalConverter &, TextureFilter &); void operator>>(const LexicalConverter &, TextureWrap &); diff --git a/source/core/stenciltest.cpp b/source/core/stenciltest.cpp index 7076f4d7..57a191cf 100644 --- a/source/core/stenciltest.cpp +++ b/source/core/stenciltest.cpp @@ -1,5 +1,6 @@ #include #include +#include "gl.h" #include "stenciltest.h" using namespace std; @@ -39,7 +40,7 @@ void StencilTest::Loader::actions(StencilOp sf, StencilOp df, StencilOp dp) } -GLenum get_gl_stencil_op(StencilOp op) +unsigned get_gl_stencil_op(StencilOp op) { switch(op) { diff --git a/source/core/stenciltest.h b/source/core/stenciltest.h index cdc61388..e33882df 100644 --- a/source/core/stenciltest.h +++ b/source/core/stenciltest.h @@ -47,7 +47,7 @@ struct StencilTest StencilTest(); }; -GLenum get_gl_stencil_op(StencilOp); +unsigned get_gl_stencil_op(StencilOp); void operator>>(const LexicalConverter &, StencilOp &); void operator<<(LexicalConverter &, StencilOp); diff --git a/source/core/texture.cpp b/source/core/texture.cpp index 877e4d10..ef8b7eef 100644 --- a/source/core/texture.cpp +++ b/source/core/texture.cpp @@ -125,7 +125,7 @@ void Texture::apply_swizzle() } } -void Texture::set_parameter_i(GLenum param, int value) const +void Texture::set_parameter_i(unsigned param, int value) const { if(ARB_direct_state_access) glTextureParameteri(id, param, value); diff --git a/source/core/texture.h b/source/core/texture.h index 6d474b88..47b2f269 100644 --- a/source/core/texture.h +++ b/source/core/texture.h @@ -3,7 +3,6 @@ #include #include -#include "gl.h" #include "pixelformat.h" #include "resource.h" @@ -58,7 +57,7 @@ protected: }; unsigned id; - GLenum target; + unsigned target; PixelFormat format; PixelFormat storage_fmt; FormatSwizzle swizzle; @@ -69,7 +68,7 @@ protected: static const int swizzle_orders[]; static Texture *scratch_binding; - Texture(GLenum, ResourceManager * = 0); + Texture(unsigned, ResourceManager * = 0); Texture(const Texture &); Texture &operator=(const Texture &); public: @@ -79,7 +78,7 @@ protected: void generate_id(); void set_format(PixelFormat); void apply_swizzle(); - void set_parameter_i(GLenum, int) const; + void set_parameter_i(unsigned, int) const; public: PixelFormat get_format() const { return format; } diff --git a/source/core/texturecube.cpp b/source/core/texturecube.cpp index 3f8eabb3..6239688c 100644 --- a/source/core/texturecube.cpp +++ b/source/core/texturecube.cpp @@ -248,7 +248,7 @@ void TextureCube::Loader::storage_levels(PixelFormat fmt, unsigned s, unsigned l } -GLenum get_gl_cube_face(TextureCubeFace face) +unsigned get_gl_cube_face(TextureCubeFace face) { switch(face) { diff --git a/source/core/texturecube.h b/source/core/texturecube.h index 58184586..8bb5cf43 100644 --- a/source/core/texturecube.h +++ b/source/core/texturecube.h @@ -1,7 +1,6 @@ #ifndef MSP_GL_TEXTURECUBE_H_ #define MSP_GL_TEXTURECUBE_H_ -#include #include #include "texture.h" #include "vector.h" @@ -104,7 +103,7 @@ public: virtual void unload() { } }; -GLenum get_gl_cube_face(TextureCubeFace); +unsigned get_gl_cube_face(TextureCubeFace); void operator>>(const LexicalConverter &, TextureCubeFace &); -- 2.43.0