Commit 1ec5b01f authored by Jan Lepper's avatar Jan Lepper

add gl version check

parent bbaf07a9
......@@ -56,6 +56,7 @@ set(SRCS
main/iat.c
main/core_wrapper.cpp
main/wgl_wrapper.cpp
main/gl_version_check.cpp
sfs/sfs.cpp
sfs/hash.cpp
core/core.cpp
......
/**
* IL-2 Graphics Extender
* Copyright (C) 2020 Jan Lepper
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "gl_version_check.h"
#include <render_util/gl_binding/gl_functions.h>
#include <log.h>
using namespace render_util::gl_binding;
namespace
{
constexpr auto MIN_MAJOR = 4;
constexpr auto MIN_MINOR = 5;
}
namespace il2ge
{
void checkGLVersion()
{
int major = 0;
int minor = 0;
gl::GetIntegerv(GL_MAJOR_VERSION, &major);
gl::GetIntegerv(GL_MINOR_VERSION, &minor);
if (major < MIN_MAJOR || minor < MIN_MINOR)
{
LOG_ERROR << "Error: OpenGL version isn't recent enough." << std::endl;
LOG_ERROR << "Required: " << MIN_MAJOR << "." << MIN_MINOR << std::endl;
LOG_ERROR << "Got: " << major << "." << minor << std::endl;
LOG_FLUSH;
_Exit(EXIT_FAILURE);
}
}
}
#ifndef IL2GE_GL_VERSION_CHECK_H
#define IL2GE_GL_VERSION_CHECK_H
namespace il2ge
{
void checkGLVersion();
}
#endif
......@@ -17,6 +17,7 @@
*/
#include "wgl_wrapper.h"
#include "gl_version_check.h"
#include <misc.h>
#include <render_util/gl_binding/gl_interface.h>
......@@ -86,6 +87,7 @@ ContextData *getContextData(HGLRC handle)
void currentContextChanged(ContextData *new_current)
{
render_util::gl_binding::GL_Interface *iface = nullptr;
bool first_time = false;
if (new_current)
{
......@@ -93,6 +95,7 @@ void currentContextChanged(ContextData *new_current)
{
auto iface = std::make_shared<render_util::gl_binding::GL_Interface>(&getProcAddress_ext);
new_current->setGLInterface(iface);
first_time = true;
}
iface = new_current->getGLInterface();
......@@ -100,6 +103,9 @@ void currentContextChanged(ContextData *new_current)
g_data.m_current_context = new_current;
render_util::gl_binding::GL_Interface::setCurrent(iface);
if (first_time)
il2ge::checkGLVersion();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment