Nuitka
Nuitka copied to clipboard
glfw --standalone sample doesn't render when moved to another system(ubuntu18->ubuntu22)
As a part of posting build issues separately as discussed. These examples by themselves might be easier to debug. I'm thinking maybe this could be with the dlls again and it's okay if I have to resort to compiling on the same system of this turns out challenging.
Factory Nuitka 1.9rc6 Commercial: None Python: 3.8.10 (default, Oct 4 2023, 11:36:56) Flavor: Unknown Executable: /home/daniel/Desktop/nuitka_tests/env/bin/python OS: Linux Arch: x86_64 Distribution: Ubuntu (based on Debian) 18.04.6 Version C compiler: /usr/bin/gcc (gcc).
Python3.8.10 from source with, only enabled optimizations, created a new venv from it and then pulled factory from pip
python -m pip freeze:
cycler==0.12.1
glfw==2.5.5
kiwisolver==1.4.5
matplotlib==3.4.2
Nuitka @ https://github.com/Nuitka/Nuitka/archive/factory.zip
numpy==1.24.4
opencv-python==4.8.1.78
ordered-set==4.1.0
Pillow==10.1.0
PyOpenGL==3.1.7
PyOpenGL-accelerate==3.1.7
pyparsing==3.1.1
PyQt5==5.15.6
PyQt5-Qt5==5.15.2
PyQt5-sip==12.13.0
python-dateutil==2.8.2
six==1.16.0
zstandard==0.22.0
Sample code that doesn't work on standalone only when moved from the Ubuntu18 system it was compiled on to a Ubuntu22 system:
import glfw
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
import cv2
import numpy as np
# Vertex data for a colored triangle
vertices = [
0.0, 0.5, 0.0, # Vertex 1 (x, y, z)
-0.5, -0.5, 0.0, # Vertex 2
0.5, -0.5, 0.0 # Vertex 3
]
colors = [
1.0, 0.0, 0.0, # Color for Vertex 1 (R, G, B)
0.0, 1.0, 0.0, # Color for Vertex 2
0.0, 0.0, 1.0 # Color for Vertex 3
]
def draw_triangle():
glBegin(GL_TRIANGLES)
for i in range(3):
glColor3fv(colors[i*3:i*3+3]) # Set the color for the current vertex
glVertex3fv(vertices[i*3:i*3+3]) # Set the vertex position
glEnd()
def main():
if not glfw.init():
return
window = glfw.create_window(800, 600, "Simple OpenGL Example", None, None)
if not window:
glfw.terminate()
return
glfw.make_context_current(window)
glShadeModel(GL_FLAT)
glEnable(GL_CULL_FACE)
glCullFace(GL_BACK)
glFrontFace(GL_CCW)
while not glfw.window_should_close(window):
glfw.poll_events()
glClear(GL_COLOR_BUFFER_BIT)
glLoadIdentity()
draw_triangle()
# Capture the framebuffer and save it using OpenCV
buffer = glReadPixels(0, 0, 800, 600, GL_RGB, GL_UNSIGNED_BYTE)
image = np.frombuffer(buffer, dtype=np.uint8).reshape(600, 800, 3)
image = cv2.flip(image, 0) # OpenGL captures the image upside down, so flip it
# Save the image using OpenCV
cv2.imwrite("rendered_image.png", image)
glfw.swap_buffers(window)
glfw.terminate()
if __name__ == "__main__":
main()
Compiled with:
python -m nuitka --standalone --enable-plugin=glfw --include-module=OpenGL_accelerate.formathandler --report=glfw_solo_report.xml gl.py
The expected behavior is to open up a pyqt window and then render a triangle with glfw, finally save that image with opencv as a png to the directory the binary was executed from. This works on the Ubuntu18 machine it was compiled on but when moving to a ubuntu22 machine it doesn't render anything but doesn't crash either, the saved png is just black image instead of the triangle it is meant to save.
I cant attach xml so I included the compilation report with a .txt extension instead. glfw_solo_report.txt
Closed because it works fine with opencv headless
I will still investigate this as a test case, potentially adding it to Nuitka-Watch too, at a low priority of course.