mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-12 22:53:27 +00:00
Merge pull request #143 from luadebug/opengl
fix `pixi run examples` for linux
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -7,6 +7,8 @@
|
|||||||
/clang-coverage/
|
/clang-coverage/
|
||||||
*.gcov
|
*.gcov
|
||||||
*.bin
|
*.bin
|
||||||
|
# pixi lock
|
||||||
|
pixi.lock
|
||||||
# pixi environments
|
# pixi environments
|
||||||
.pixi/*
|
.pixi/*
|
||||||
!.pixi/config.toml
|
!.pixi/config.toml
|
||||||
|
|||||||
@@ -120,9 +120,14 @@ int main()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "GLFW Version: " << glfwGetVersionString() << "\n";
|
||||||
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
|
// Force GLX context creation API to ensure compatibility with GLEW
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
||||||
#endif
|
#endif
|
||||||
@@ -141,15 +146,30 @@ int main()
|
|||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
|
|
||||||
|
// Check if context is valid using standard GL
|
||||||
|
const GLubyte* renderer = glGetString(GL_RENDERER);
|
||||||
|
const GLubyte* version = glGetString(GL_VERSION);
|
||||||
|
if (renderer && version) {
|
||||||
|
std::cout << "Renderer: " << renderer << "\n";
|
||||||
|
std::cout << "OpenGL version supported: " << version << "\n";
|
||||||
|
} else {
|
||||||
|
std::cerr << "Failed to get GL_RENDERER or GL_VERSION. Context might be invalid.\n";
|
||||||
|
}
|
||||||
|
|
||||||
// ---------- GLEW init ----------
|
// ---------- GLEW init ----------
|
||||||
glewExperimental = GL_TRUE;
|
glewExperimental = GL_TRUE;
|
||||||
GLenum glewErr = glewInit();
|
GLenum glewErr = glewInit();
|
||||||
if (glewErr != GLEW_OK)
|
if (glewErr != GLEW_OK)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to initialize GLEW: " << reinterpret_cast<const char*>(glewGetErrorString(glewErr))
|
// Ignore NO_GLX_DISPLAY if we have a valid context
|
||||||
<< "\n";
|
if (glewErr == GLEW_ERROR_NO_GLX_DISPLAY && renderer) {
|
||||||
glfwTerminate();
|
std::cerr << "GLEW warning: " << glewGetErrorString(glewErr) << " (Ignored because context seems valid)\n";
|
||||||
return -1;
|
} else {
|
||||||
|
std::cerr << "Failed to initialize GLEW: " << reinterpret_cast<const char*>(glewGetErrorString(glewErr))
|
||||||
|
<< "\n";
|
||||||
|
glfwTerminate();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- GL state ----------
|
// ---------- GL state ----------
|
||||||
|
|||||||
18
pixi.toml
18
pixi.toml
@@ -37,6 +37,15 @@ ninja = ">=1.13.2,<2"
|
|||||||
|
|
||||||
[target.linux-64.dependencies]
|
[target.linux-64.dependencies]
|
||||||
mesa-libgl-devel-cos7-x86_64 = ">=18.3.4,<19"
|
mesa-libgl-devel-cos7-x86_64 = ">=18.3.4,<19"
|
||||||
|
xorg-x11-server-xvfb-cos7-x86_64 = ">=1.20.4,<2"
|
||||||
|
|
||||||
|
[target.linux-64.activation.env]
|
||||||
|
__GLX_VENDOR_LIBRARY_NAME = "mesa"
|
||||||
|
EGL_PLATFORM = "x11"
|
||||||
|
GLFW_PLATFORM = "x11"
|
||||||
|
|
||||||
|
[target.linux-64.tasks]
|
||||||
|
examples = { cwd = "pixi", cmd = "xvfb-run -a -s '-screen 0 1024x768x24 +extension GLX +render' cmake -DCMAKE_BUILD_TYPE=Debug -P run.examples.cmake", depends-on = ["build"] }
|
||||||
|
|
||||||
[target.win-64.dependencies]
|
[target.win-64.dependencies]
|
||||||
mesa-libgl-devel-cos7-x86_64 = ">=18.3.4,<19"
|
mesa-libgl-devel-cos7-x86_64 = ">=18.3.4,<19"
|
||||||
@@ -49,3 +58,12 @@ mesa-libgl-devel-cos7-aarch64 = ">=18.3.4,<19"
|
|||||||
|
|
||||||
[target.linux-aarch64.dependencies]
|
[target.linux-aarch64.dependencies]
|
||||||
mesa-libgl-devel-cos7-aarch64 = ">=18.3.4,<19"
|
mesa-libgl-devel-cos7-aarch64 = ">=18.3.4,<19"
|
||||||
|
xorg-x11-server-xvfb-cos7-aarch64 = ">=1.20.4,<2"
|
||||||
|
|
||||||
|
[target.linux-aarch64.activation.env]
|
||||||
|
__GLX_VENDOR_LIBRARY_NAME = "mesa"
|
||||||
|
EGL_PLATFORM = "x11"
|
||||||
|
GLFW_PLATFORM = "x11"
|
||||||
|
|
||||||
|
[target.linux-aarch64.tasks]
|
||||||
|
examples = { cwd = "pixi", cmd = "xvfb-run -a -s '-screen 0 1024x768x24 +extension GLX +render' cmake -DCMAKE_BUILD_TYPE=Debug -P run.examples.cmake", depends-on = ["build"] }
|
||||||
|
|||||||
Reference in New Issue
Block a user