From: Mikko Rasa Date: Tue, 5 Sep 2023 09:58:20 +0000 (+0300) Subject: Pull in various constants and functions through extensions X-Git-Url: https://git.tdb.fi/?a=commitdiff_plain;h=6b0aaf51ebbf7f46a2d251f802ae78dfc1861ae3;p=libs%2Fgl.git Pull in various constants and functions through extensions Windows SDK does not have glext.h and the base gl.h only has definitions for OpenGL 1.1. --- diff --git a/extensions/arb_multisample.glext b/extensions/arb_multisample.glext new file mode 100644 index 00000000..e21e8fbc --- /dev/null +++ b/extensions/arb_multisample.glext @@ -0,0 +1 @@ +extension ARB_multisample diff --git a/extensions/arb_texture_border_clamp.glext b/extensions/arb_texture_border_clamp.glext new file mode 100644 index 00000000..a295c645 --- /dev/null +++ b/extensions/arb_texture_border_clamp.glext @@ -0,0 +1 @@ +extension ARB_texture_border_clamp diff --git a/extensions/arb_texture_cube_map_array.glext b/extensions/arb_texture_cube_map_array.glext new file mode 100644 index 00000000..01fa2e18 --- /dev/null +++ b/extensions/arb_texture_cube_map_array.glext @@ -0,0 +1 @@ +extension ARB_texture_cube_map_array diff --git a/extensions/arb_texture_mirrored_repeat.glext b/extensions/arb_texture_mirrored_repeat.glext new file mode 100644 index 00000000..c7503805 --- /dev/null +++ b/extensions/arb_texture_mirrored_repeat.glext @@ -0,0 +1 @@ +extension ARB_texture_mirrored_repeat diff --git a/extensions/ext_blend_color.glext b/extensions/ext_blend_color.glext new file mode 100644 index 00000000..e20ef0c4 --- /dev/null +++ b/extensions/ext_blend_color.glext @@ -0,0 +1 @@ +extension EXT_blend_color diff --git a/extensions/ext_stencil_wrap.glext b/extensions/ext_stencil_wrap.glext new file mode 100644 index 00000000..0d24b524 --- /dev/null +++ b/extensions/ext_stencil_wrap.glext @@ -0,0 +1 @@ +extension EXT_stencil_wrap diff --git a/extensions/sgis_texture_edge_clamp.glext b/extensions/sgis_texture_edge_clamp.glext new file mode 100644 index 00000000..5b742b88 --- /dev/null +++ b/extensions/sgis_texture_edge_clamp.glext @@ -0,0 +1 @@ +extension SGIS_texture_edge_clamp diff --git a/extensions/sgis_texture_lod.glext b/extensions/sgis_texture_lod.glext new file mode 100644 index 00000000..0c0b7e82 --- /dev/null +++ b/extensions/sgis_texture_lod.glext @@ -0,0 +1 @@ +extension SGIS_texture_lod diff --git a/source/backends/opengl/blend_backend.cpp b/source/backends/opengl/blend_backend.cpp index 44267480..9d4b43d2 100644 --- a/source/backends/opengl/blend_backend.cpp +++ b/source/backends/opengl/blend_backend.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include "blend.h" diff --git a/source/backends/opengl/datatype_backend.cpp b/source/backends/opengl/datatype_backend.cpp index da97010f..be23911c 100644 --- a/source/backends/opengl/datatype_backend.cpp +++ b/source/backends/opengl/datatype_backend.cpp @@ -1,6 +1,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include "datatype.h" diff --git a/source/backends/opengl/extension.cpp b/source/backends/opengl/extension.cpp index 82661c70..a650b650 100644 --- a/source/backends/opengl/extension.cpp +++ b/source/backends/opengl/extension.cpp @@ -16,6 +16,10 @@ #include "extension.h" #include "gl.h" +#ifndef GL_VERSION_2_0 +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#endif + #ifndef GL_VERSION_3_0 #define GL_NUM_EXTENSIONS 0x821D #endif diff --git a/source/backends/opengl/framebuffer_backend.cpp b/source/backends/opengl/framebuffer_backend.cpp index a81566b5..247d9a4b 100644 --- a/source/backends/opengl/framebuffer_backend.cpp +++ b/source/backends/opengl/framebuffer_backend.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include diff --git a/source/backends/opengl/gl.h b/source/backends/opengl/gl.h index 28ac186f..c243ebd7 100644 --- a/source/backends/opengl/gl.h +++ b/source/backends/opengl/gl.h @@ -16,26 +16,38 @@ typedef double GLdouble; typedef long long GLint64; -#else - #ifdef _WIN32 - #ifndef WINAPI - #if defined(_ARM_) - #define WINAPI - #else - #define WINAPI __stdcall - #endif - #endif - #ifndef APIENTRY - #define APIENTRY WINAPI - #endif - #ifndef DECLSPEC_IMPORT - #define DECLSPEC_IMPORT __declspec(dllimport) - #endif - #ifndef WINGDIAPI - #define WINGDIAPI DECLSPEC_IMPORT +#elif defined(_WIN32) + #ifndef WINAPI + #if defined(_ARM_) + #define WINAPI + #else + #define WINAPI __stdcall #endif #endif + #ifndef APIENTRY + #define APIENTRY WINAPI + #endif + #ifndef DECLSPEC_IMPORT + #define DECLSPEC_IMPORT __declspec(dllimport) + #endif + #ifndef WINGDIAPI + #define WINGDIAPI DECLSPEC_IMPORT + #endif + #include + #include + using GLchar = char; + using GLintptr = intptr_t; + #ifdef _WIN64 + using GLsizeiptr = signed long int; + #else + using GLsizeiptr = signed long long int; + #endif + using GLint64 = int64_t; + using GLDEBUGPROC = void (APIENTRY *)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void *); + using GLhalfNV = unsigned short; + +#else #include #include #endif diff --git a/source/backends/opengl/pipelinestate_backend.cpp b/source/backends/opengl/pipelinestate_backend.cpp index 7c41bd36..af6584a7 100644 --- a/source/backends/opengl/pipelinestate_backend.cpp +++ b/source/backends/opengl/pipelinestate_backend.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include #include #include @@ -6,8 +8,11 @@ #include #include #include +#include +#include #include #include +#include #include "blend.h" #include "buffer.h" #include "depthtest.h" @@ -143,6 +148,8 @@ void OpenGLPipelineState::apply() const glBindTextureUnit(r.binding, r.texture->id); else { + static Require _req(ARB_multitexture); + glActiveTexture(GL_TEXTURE0+r.binding); if(dev_state.bound_tex_targets[r.binding] && static_cast(r.texture->target)!=dev_state.bound_tex_targets[r.binding]) glBindTexture(dev_state.bound_tex_targets[r.binding], 0); @@ -240,6 +247,9 @@ void OpenGLPipelineState::apply() const const Blend &blend = self.blend; if(blend.enabled) { + static Require _req(EXT_blend_minmax); + static Require _req2(EXT_blend_color); + glEnable(GL_BLEND); glBlendEquation(get_gl_blend_equation(blend.equation)); glBlendFunc(get_gl_blend_factor(blend.src_factor), get_gl_blend_factor(blend.dst_factor)); diff --git a/source/backends/opengl/primitivetype_backend.cpp b/source/backends/opengl/primitivetype_backend.cpp index a3c862c0..e3995dcd 100644 --- a/source/backends/opengl/primitivetype_backend.cpp +++ b/source/backends/opengl/primitivetype_backend.cpp @@ -1,3 +1,4 @@ +#include #include "gl.h" #include "primitivetype.h" #include "primitivetype_backend.h" diff --git a/source/backends/opengl/sampler_backend.cpp b/source/backends/opengl/sampler_backend.cpp index 31dcc6bc..161429f0 100644 --- a/source/backends/opengl/sampler_backend.cpp +++ b/source/backends/opengl/sampler_backend.cpp @@ -1,9 +1,12 @@ #include #include #include +#include +#include #include #include #include +#include #include "gl.h" #include "sampler.h" #include "sampler_backend.h" @@ -52,7 +55,7 @@ void OpenGLSampler::update(unsigned mask) const if(mask&Sampler::MAG_FILTER) glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, get_gl_filter(self.mag_filter)); if(mask&Sampler::MAX_ANISOTROPY) - glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, self.max_anisotropy); + glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY, self.max_anisotropy); if(mask&Sampler::WRAP_S) glSamplerParameteri(id, GL_TEXTURE_WRAP_S, get_gl_wrap(self.wrap_s)); if(mask&Sampler::WRAP_T) diff --git a/source/backends/opengl/stenciltest_backend.cpp b/source/backends/opengl/stenciltest_backend.cpp index 1c049ea3..f26bdbe6 100644 --- a/source/backends/opengl/stenciltest_backend.cpp +++ b/source/backends/opengl/stenciltest_backend.cpp @@ -1,3 +1,4 @@ +#include #include "gl.h" #include "stenciltest.h" #include "stenciltest_backend.h" diff --git a/source/backends/opengl/systemframebuffer.cpp b/source/backends/opengl/systemframebuffer.cpp index 2d066452..7b92ddca 100644 --- a/source/backends/opengl/systemframebuffer.cpp +++ b/source/backends/opengl/systemframebuffer.cpp @@ -1,3 +1,4 @@ +#include #include #include "gl.h" #include "systemframebuffer.h" diff --git a/source/backends/opengl/texture1d_backend.cpp b/source/backends/opengl/texture1d_backend.cpp index aa9e1f29..f7831dbd 100644 --- a/source/backends/opengl/texture1d_backend.cpp +++ b/source/backends/opengl/texture1d_backend.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "gl.h" #include "texture1d.h" #include "texture1d_backend.h" diff --git a/source/backends/opengl/texture2d_backend.cpp b/source/backends/opengl/texture2d_backend.cpp index a4e3cad6..9abfab54 100644 --- a/source/backends/opengl/texture2d_backend.cpp +++ b/source/backends/opengl/texture2d_backend.cpp @@ -1,6 +1,8 @@ #include +#include #include #include +#include #include "buffer.h" #include "gl.h" #include "texture2d.h" diff --git a/source/backends/opengl/texture3d_backend.cpp b/source/backends/opengl/texture3d_backend.cpp index 81783850..b71ad811 100644 --- a/source/backends/opengl/texture3d_backend.cpp +++ b/source/backends/opengl/texture3d_backend.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "gl.h" #include "texture3d.h" #include "texture3d_backend.h" diff --git a/source/backends/opengl/texture_backend.cpp b/source/backends/opengl/texture_backend.cpp index 818defdd..c96227d4 100644 --- a/source/backends/opengl/texture_backend.cpp +++ b/source/backends/opengl/texture_backend.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -118,6 +119,8 @@ void OpenGLTexture::set_debug_name(const string &name) void OpenGLTexture::bind_scratch() { + static Require _req(ARB_multitexture); + const OpenGLTexture *&scratch_binding = Device::get_current().get_state().scratch_texture; if(!scratch_binding) glActiveTexture(GL_TEXTURE0); diff --git a/source/backends/opengl/texturecube_backend.cpp b/source/backends/opengl/texturecube_backend.cpp index e363f6fb..9b703c05 100644 --- a/source/backends/opengl/texturecube_backend.cpp +++ b/source/backends/opengl/texturecube_backend.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "gl.h" #include "texturecube.h" #include "texturecube_backend.h"