1
0
Fork 0

Fix: OpenGL version

master
May B. 2020-11-12 21:55:38 +01:00
parent 82cf0daa75
commit b6bd32ebdb
4 changed files with 12 additions and 14 deletions

View File

@ -8,7 +8,6 @@ option(USE_FMA "Use fma" 1)
option(LOG_DEBUG "Show debug logs" 0)
option(LOG_TRACE "Show trace logs" 0)
option(NATIVE "Build with -march=native" 0)
option(GL_OLD "Use OpenGL 4.2 not 4.6" 0)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
@ -32,7 +31,7 @@ else()
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_compile_definitions(FIXED_WINDOW=${FIXED_WINDOW} LOG_DEBUG=${LOG_DEBUG} LOG_TRACE=${LOG_TRACE} GL_OLD=${GL_OLD} HN_USE_FILESYSTEM=1)
add_compile_definitions(FIXED_WINDOW=${FIXED_WINDOW} LOG_DEBUG=${LOG_DEBUG} LOG_TRACE=${LOG_TRACE} HN_USE_FILESYSTEM=1)
if(PROFILING)
add_compile_definitions(TRACY_ENABLE=1)
endif(PROFILING)

View File

@ -103,7 +103,6 @@ PROFILING | Tracy profiling | `0`
LOG_DEBUG | Debug logs | `0`
LOG_TRACE | Trace logs | `0`
NATIVE | Optimize for native CPU | `0`
GL_OLD | Use OpenGL 4.2 not 4.6 | `0`
1. Build Make
```sh

View File

@ -12,11 +12,8 @@
using namespace render::gl;
constexpr auto GL_MAJOR = 4;
#if GL_OLD
constexpr auto GL_MINOR = 2;
#else
constexpr auto GL_MINOR = 6;
#endif
constexpr auto GL_MINOR_MIN = 2;
constexpr auto GL_MINOR_BEST = 6;
#define CONTENT_DIR "content/"
#define TEXTURES_DIR CONTENT_DIR "textures/"
@ -50,7 +47,7 @@ void framebuffer_size_callback(GLFWwindow *, int width, int height) {
bool Renderer::Load(Window& window, const render::renderOptions& opt, const windowOptions& windOpt) {
Window::CreateInfo windowInfo;
windowInfo.pfnResize = framebuffer_size_callback;
windowInfo.client = {Window::CreateInfo::Client::Type::GL, GL_MAJOR, GL_MINOR};
windowInfo.client = {Window::CreateInfo::Client::Type::GL, GL_MAJOR, GL_MINOR_MIN};
windowInfo.samples = windOpt.getSamples();
windowInfo.fps = windOpt.targetFPS;
windowInfo.fullscreen = windOpt.fullscreen;
@ -62,9 +59,13 @@ bool Renderer::Load(Window& window, const render::renderOptions& opt, const wind
LOG_E("Failed to initialize OpenGL");
return false;
}
if (!gl3wIsSupported(GL_MAJOR, GL_MINOR)) {
LOG_E("OpenGL " << GL_MAJOR << "." << GL_MINOR << " not supported");
return false;
if (!gl3wIsSupported(GL_MAJOR, GL_MINOR_BEST)) {
if (gl3wIsSupported(GL_MAJOR, GL_MINOR_MIN)) {
LOG_W("OpenGL " << GL_MAJOR << "." << GL_MINOR_BEST << " not supported. Some feature like texture sharpness may not work");
} else {
LOG_E("OpenGL " << GL_MAJOR << "." << GL_MINOR_MIN << " not supported");
return false;
}
}
LOG_D("OpenGL " << glGetString(GL_VERSION) << ", GLSL " << glGetString(GL_SHADING_LANGUAGE_VERSION));

View File

@ -76,9 +76,8 @@ void applySampler(GLuint textureID, const Texture::sampling& props) {
glTextureParameteri(textureID, GL_TEXTURE_MAG_FILTER, getFilter(props.magLinear, props.mipmap));
glTextureParameteri(textureID, GL_TEXTURE_MIN_FILTER, getFilter(props.minLinear, props.mipmap));
glTextureParameterf(textureID, GL_TEXTURE_LOD_BIAS, props.mipmapLod);
#if !GL_OLD
glTextureParameterf(textureID, GL_TEXTURE_MAX_ANISOTROPY, props.anisotropy);
#endif
glTextureParameteri(textureID, GL_TEXTURE_WRAP_S, wrap);
glTextureParameteri(textureID, GL_TEXTURE_WRAP_T, wrap);
glTextureParameteri(textureID, GL_TEXTURE_WRAP_R, wrap);