Issue
I need to use Tessellation in OpenGL, which means that my OpenGL version need to be 4.0 or upper. I get my OpenGL version with glxinfo | grep OpenGL
in terminal. Output shows in the following:
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: NVIDIA GeForce RTX 3090/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 520.61.05
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6.0 NVIDIA 520.61.05
OpenGL shading language version string: 4.60 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 520.61.05
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:
It shows apparently that My OpenGL version is 4.6.0. But when I run the code:
glGetString(GL_VERSION);
I get:
3.3.0 NVIDIA 520.61.05
The reason that why I find this mismatch is that I get segmentation fault
when I call the function:
void glPatchParameteri(GLenum pname, GLint value);
My GLAD
is generated with the expected version 4.6.0
.
And my CMakeLists.txt
is edited as following:
cmake_minimum_required(VERSION 3.23)
project(visualization_displacement_map)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
find_package(glfw3 REQUIRED)
file(GLOB project_file glad.c main.cpp)
add_executable(${PROJECT_NAME} ${project_file} utility/init_func.cpp utility/callback_func.cpp utility/class/SoarCamera.cpp utility/class/SoarCamera.h program/program_test.cpp utility/class/Shader.cpp utility/class/Shader.h utility/debug_func.cpp)
target_link_libraries(${PROJECT_NAME} ${TARGET_LIB}
-lglfw
-lGL
-lm
-lXrandr
-lXi
-lX11
-lXxf86vm
-lpthread
-ldl
-lXinerama
-lXcursor
)
Why does this mismatch happen?
Solution
Which context are you requesting at runtime? Almost sounds like you are requesting a 3.3 context? (or the windowing lib you're using is).
in glut:
glutInitContextVersion( 3, 3 );
glutInitContextProfile( GLUT_CORE_PROFILE );
in glfw:
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
in sdl:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
Answered By - robthebloke Answer Checked By - Dawn Plyler (WPSolving Volunteer)