Use the new OpenGL Loader Generator for the gl loader
This commit is contained in:
parent
98a015fbed
commit
fe5cd6510c
10 changed files with 2997 additions and 3375 deletions
|
|
@ -569,7 +569,7 @@ struct cloud_app
|
|||
gl::Enable(gl::BLEND);
|
||||
gl::BlendFunc(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
gl::DepthMask(gl::FALSE_);
|
||||
gl::DepthMask(gl::FALSE);
|
||||
|
||||
cloud_program.bind();
|
||||
cloud_program["u_transform"] = camera.transform();
|
||||
|
|
@ -586,7 +586,7 @@ struct cloud_app
|
|||
shadow_texture.bind();
|
||||
slice_mesh.draw();
|
||||
|
||||
gl::DepthMask(gl::TRUE_);
|
||||
gl::DepthMask(gl::TRUE);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ namespace psemek::app
|
|||
impl().start_time = clock::now();
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, gl::sys::GetLeastMajorVersion());
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, gl::sys::GetLeastMinorVersion());
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, gl::sys::major_version());
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, gl::sys::minor_version());
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
||||
|
|
@ -85,13 +85,16 @@ namespace psemek::app
|
|||
|
||||
SDL_GL_MakeCurrent(impl().window, impl().gl_context);
|
||||
|
||||
if (!gl::sys::LoadFunctions())
|
||||
if (!gl::sys::initialize())
|
||||
throw std::runtime_error("Failed to load OpenGL functions");
|
||||
|
||||
auto vendor = gl::GetString(gl::VENDOR);
|
||||
auto renderer = gl::GetString(gl::RENDERER);
|
||||
|
||||
log::info() << "Initialized OpenGL " << gl::sys::GetMajorVersion() << '.' << gl::sys::GetMinorVersion() << ", " << vendor << ", " << renderer;
|
||||
int major, minor;
|
||||
gl::GetIntegerv(gl::MAJOR_VERSION, &major);
|
||||
gl::GetIntegerv(gl::MINOR_VERSION, &minor);
|
||||
log::info() << "Initialized OpenGL " << major << '.' << minor << ", " << vendor << ", " << renderer;
|
||||
|
||||
SDL_GetWindowSize(impl().window, &impl().width, &impl().height);
|
||||
}
|
||||
|
|
|
|||
18
libs/gfx/gl-loader-generator-config.json
Normal file
18
libs/gfx/gl-loader-generator-config.json
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"spec_file": "gl.xml",
|
||||
"api": "gl",
|
||||
"version": "3.3",
|
||||
"profile": "core",
|
||||
"extensions": [
|
||||
"ARB_texture_filter_anisotropic"
|
||||
],
|
||||
"indent": "\t",
|
||||
"namespace": "gl",
|
||||
"loader_namespace": "sys",
|
||||
"internal_namespace": "internal",
|
||||
"internal_prefix": "",
|
||||
"undef": 4,
|
||||
"strip": true,
|
||||
"out_header": "gl.hpp",
|
||||
"out_source": "gl.cpp"
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ namespace psemek::gfx
|
|||
|
||||
static constexpr GLint size = 1;
|
||||
static constexpr GLenum type = gl::UNSIGNED_BYTE;
|
||||
static constexpr GLboolean normalized = gl::FALSE_;
|
||||
static constexpr GLboolean normalized = gl::FALSE;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
|
@ -91,7 +91,7 @@ namespace psemek::gfx
|
|||
|
||||
static constexpr GLint size = 1;
|
||||
static constexpr GLenum type = gl::BYTE;
|
||||
static constexpr GLboolean normalized = gl::FALSE_;
|
||||
static constexpr GLboolean normalized = gl::FALSE;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
|
@ -101,7 +101,7 @@ namespace psemek::gfx
|
|||
|
||||
static constexpr GLint size = 1;
|
||||
static constexpr GLenum type = gl::UNSIGNED_SHORT;
|
||||
static constexpr GLboolean normalized = gl::FALSE_;
|
||||
static constexpr GLboolean normalized = gl::FALSE;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
|
@ -111,7 +111,7 @@ namespace psemek::gfx
|
|||
|
||||
static constexpr GLint size = 1;
|
||||
static constexpr GLenum type = gl::SHORT;
|
||||
static constexpr GLboolean normalized = gl::FALSE_;
|
||||
static constexpr GLboolean normalized = gl::FALSE;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
|
@ -121,7 +121,7 @@ namespace psemek::gfx
|
|||
|
||||
static constexpr GLint size = 1;
|
||||
static constexpr GLenum type = gl::UNSIGNED_INT;
|
||||
static constexpr GLboolean normalized = gl::FALSE_;
|
||||
static constexpr GLboolean normalized = gl::FALSE;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
|
@ -131,7 +131,7 @@ namespace psemek::gfx
|
|||
|
||||
static constexpr GLint size = 1;
|
||||
static constexpr GLenum type = gl::INT;
|
||||
static constexpr GLboolean normalized = gl::FALSE_;
|
||||
static constexpr GLboolean normalized = gl::FALSE;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
|
@ -141,7 +141,7 @@ namespace psemek::gfx
|
|||
|
||||
static constexpr GLint size = 1;
|
||||
static constexpr GLenum type = gl::FLOAT;
|
||||
static constexpr GLboolean normalized = gl::FALSE_;
|
||||
static constexpr GLboolean normalized = gl::FALSE;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
|
@ -151,7 +151,7 @@ namespace psemek::gfx
|
|||
|
||||
static constexpr GLint size = 1;
|
||||
static constexpr GLenum type = gl::DOUBLE;
|
||||
static constexpr GLboolean normalized = gl::FALSE_;
|
||||
static constexpr GLboolean normalized = gl::FALSE;
|
||||
};
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
|
|
@ -161,7 +161,7 @@ namespace psemek::gfx
|
|||
|
||||
static constexpr GLint size = N;
|
||||
static constexpr GLenum type = attrib_traits<T>::type;
|
||||
static constexpr GLboolean normalized = gl::FALSE_;
|
||||
static constexpr GLboolean normalized = gl::FALSE;
|
||||
};
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
|
|
@ -171,7 +171,7 @@ namespace psemek::gfx
|
|||
|
||||
static constexpr GLint size = N;
|
||||
static constexpr GLenum type = attrib_traits<T>::type;
|
||||
static constexpr GLboolean normalized = gl::FALSE_;
|
||||
static constexpr GLboolean normalized = gl::FALSE;
|
||||
};
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
|
|
@ -181,7 +181,7 @@ namespace psemek::gfx
|
|||
|
||||
static constexpr GLint size = N;
|
||||
static constexpr GLenum type = attrib_traits<T>::type;
|
||||
static constexpr GLboolean normalized = gl::FALSE_;
|
||||
static constexpr GLboolean normalized = gl::FALSE;
|
||||
};
|
||||
|
||||
template <typename T, std::size_t R, std::size_t C>
|
||||
|
|
@ -197,7 +197,7 @@ namespace psemek::gfx
|
|||
|
||||
static constexpr GLint size = attrib_traits<T>::size;
|
||||
static constexpr GLenum type = attrib_traits<T>::type;
|
||||
static constexpr GLboolean normalized = gl::TRUE_;
|
||||
static constexpr GLboolean normalized = gl::TRUE;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -344,7 +344,7 @@ namespace psemek::gfx
|
|||
if (level)
|
||||
{
|
||||
bind();
|
||||
gl::TexParameterf(Target, gl::TEXTURE_MAX_ANISOTROPY_EXT, *level);
|
||||
gl::TexParameterf(Target, gl::TEXTURE_MAX_ANISOTROPY, *level);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace psemek::gfx
|
|||
{
|
||||
switch (e)
|
||||
{
|
||||
case gl::NO_ERROR_: return "GL_NO_ERROR";
|
||||
case gl::NO_ERROR: return "GL_NO_ERROR";
|
||||
case gl::INVALID_ENUM: return "GL_INVALID_ENUM";
|
||||
case gl::INVALID_VALUE: return "GL_INVALID_VALUE";
|
||||
case gl::INVALID_OPERATION: return "GL_INVALID_OPERATION";
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -151,47 +151,47 @@ namespace psemek::gfx
|
|||
|
||||
void program::uniform_proxy::operator = (geom::matrix<float, 2, 2> const & m)
|
||||
{
|
||||
gl::UniformMatrix2fv(location_, 1, gl::TRUE_, m.coords);
|
||||
gl::UniformMatrix2fv(location_, 1, gl::TRUE, m.coords);
|
||||
}
|
||||
|
||||
void program::uniform_proxy::operator = (geom::matrix<float, 2, 3> const & m)
|
||||
{
|
||||
gl::UniformMatrix3x2fv(location_, 1, gl::TRUE_, m.coords);
|
||||
gl::UniformMatrix3x2fv(location_, 1, gl::TRUE, m.coords);
|
||||
}
|
||||
|
||||
void program::uniform_proxy::operator = (geom::matrix<float, 2, 4> const & m)
|
||||
{
|
||||
gl::UniformMatrix4x2fv(location_, 1, gl::TRUE_, m.coords);
|
||||
gl::UniformMatrix4x2fv(location_, 1, gl::TRUE, m.coords);
|
||||
}
|
||||
|
||||
void program::uniform_proxy::operator = (geom::matrix<float, 3, 2> const & m)
|
||||
{
|
||||
gl::UniformMatrix2x3fv(location_, 1, gl::TRUE_, m.coords);
|
||||
gl::UniformMatrix2x3fv(location_, 1, gl::TRUE, m.coords);
|
||||
}
|
||||
|
||||
void program::uniform_proxy::operator = (geom::matrix<float, 3, 3> const & m)
|
||||
{
|
||||
gl::UniformMatrix3fv(location_, 1, gl::TRUE_, m.coords);
|
||||
gl::UniformMatrix3fv(location_, 1, gl::TRUE, m.coords);
|
||||
}
|
||||
|
||||
void program::uniform_proxy::operator = (geom::matrix<float, 3, 4> const & m)
|
||||
{
|
||||
gl::UniformMatrix4x3fv(location_, 1, gl::TRUE_, m.coords);
|
||||
gl::UniformMatrix4x3fv(location_, 1, gl::TRUE, m.coords);
|
||||
}
|
||||
|
||||
void program::uniform_proxy::operator = (geom::matrix<float, 4, 2> const & m)
|
||||
{
|
||||
gl::UniformMatrix2x4fv(location_, 1, gl::TRUE_, m.coords);
|
||||
gl::UniformMatrix2x4fv(location_, 1, gl::TRUE, m.coords);
|
||||
}
|
||||
|
||||
void program::uniform_proxy::operator = (geom::matrix<float, 4, 3> const & m)
|
||||
{
|
||||
gl::UniformMatrix3x4fv(location_, 1, gl::TRUE_, m.coords);
|
||||
gl::UniformMatrix3x4fv(location_, 1, gl::TRUE, m.coords);
|
||||
}
|
||||
|
||||
void program::uniform_proxy::operator = (geom::matrix<float, 4, 4> const & m)
|
||||
{
|
||||
gl::UniformMatrix4fv(location_, 1, gl::TRUE_, m.coords);
|
||||
gl::UniformMatrix4fv(location_, 1, gl::TRUE, m.coords);
|
||||
}
|
||||
|
||||
void program::uniform_proxy::operator = (geom::interval<int> const & i)
|
||||
|
|
@ -218,7 +218,7 @@ namespace psemek::gfx
|
|||
|
||||
GLint status;
|
||||
gl::GetShaderiv(shader, gl::COMPILE_STATUS, &status);
|
||||
if (status != gl::TRUE_)
|
||||
if (status != gl::TRUE)
|
||||
{
|
||||
GLint log_len;
|
||||
gl::GetShaderiv(shader, gl::INFO_LOG_LENGTH, &log_len);
|
||||
|
|
@ -236,7 +236,7 @@ namespace psemek::gfx
|
|||
|
||||
GLint status;
|
||||
gl::GetProgramiv(program, gl::LINK_STATUS, &status);
|
||||
if (status != gl::TRUE_)
|
||||
if (status != gl::TRUE)
|
||||
{
|
||||
GLint log_len;
|
||||
gl::GetProgramiv(program, gl::INFO_LOG_LENGTH, &log_len);
|
||||
|
|
|
|||
|
|
@ -17,11 +17,12 @@ namespace psemek::gfx
|
|||
|
||||
static std::optional<float> get_max_anisotropy()
|
||||
{
|
||||
if (!gl::exts::var_EXT_texture_filter_anisotropic) return std::nullopt;
|
||||
if (!gl::sys::ext_ARB_texture_filter_anisotropic()) return std::nullopt;
|
||||
|
||||
float level;
|
||||
gl::GetFloatv(gl::MAX_TEXTURE_MAX_ANISOTROPY_EXT, &level);
|
||||
gl::GetFloatv(gl::MAX_TEXTURE_MAX_ANISOTROPY, &level);
|
||||
return level;
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
std::optional<float> max_anisotropy()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue