Opengl error nullfunctionerror attempt to call an undefined function glutinitdisplaymode

Сайт Максима Кузнецова Сисадмин, программист, делюсь опытом Прохождение квеста по запуску OpenGL для Python3 Оказалось, что если просто взять и открыть первый попавшийся урок по OpenGL на Python, то скорее всего ничего не получится. Всё пробовал на Python 3.6.5 под Windows x64. Для начала. пробуем установать пакеты, которые используются в скриптах: Теперь попробуем выполнить […]

Содержание

  1. Сайт Максима Кузнецова
  2. Сисадмин, программист, делюсь опытом
  3. Прохождение квеста по запуску OpenGL для Python3
  4. Об авторе admin
  5. Прохождение квеста по запуску OpenGL для Python3 : 1 комментарий
  6. PyOpenGL :: OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling
  7. Advertisement
  8. Answer
  9. PyOpenGL Bugs
  10. Group
  11. Searches
  12. #232 OpenGL.error.NullFunctionError: Attempt to call an undefined
  13. Discussion
  14. demo not working #192
  15. Comments
  16. OpenGL.error.NullFunctionError: Attempt to call an undefined function glGenFramebuffers #4
  17. Comments

Сайт Максима Кузнецова

Сисадмин, программист, делюсь опытом

Прохождение квеста по запуску OpenGL для Python3

Оказалось, что если просто взять и открыть первый попавшийся урок по OpenGL на Python, то скорее всего ничего не получится. Всё пробовал на Python 3.6.5 под Windows x64. Для начала. пробуем установать пакеты, которые используются в скриптах:

Теперь попробуем выполнить скрипт из примеров примерно с таким содержимым:

Результат получится примерно такой:

По советам из интернета скачиваем freeglut (качал отсюда https://www.transmissionzero.co.uk/files/software/development/GLUT/freeglut-MSVC-3.0.0-2.mp.zip), извлекаем оттуда и ложим рядом со скриптом файл freeglut.dll. Пробуем запустить скрипт снова — получаем ту же самую ошибку. В интернете пишут, что в стандартных пакетах питона какой-то касяк, поэтому их нужно удалить:

А теперь, говорят, надо скачивать альтернативные пакеты вот отсюда: https://www.lfd.uci.edu/

Как я понял, в названии пакета 39 — это версия питона, для которого предназначен пакет, то есть мне для 3.6.5 нужны пакеты с цифрой 36:

Ну и теперь пробуем запустить скрипт:

Python OpenGL

Короче победа. Все загрузки (пакеты для питона и freeglut) проверялись антивирусом, но если будете повторять — качайте на свой страх и риск.

Об авторе admin

Инженер-программист, системный администратор

Прохождение квеста по запуску OpenGL для Python3 : 1 комментарий

Спустя много времени поисков, наконец-то нашел адекватное работающее решение!

Источник

PyOpenGL :: OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling

I’m following this very easy guide in order to make my first steps into PyOpenGL.

I installed pip install PyOpenGL PyOpenGL_accelerate , all good.

I tested the installation through the test code:

import OpenGL.GL import OpenGL.GLUT import OpenGL.GLU print(“Imports successful!”) # If you see this printed to the console then installation was successful

I now run this script:

And the error I receive is OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling

So i read a few guides online and they point to download the wheel from here. So I go ahead and I download PyOpenGL_accelerate‑3.1.5‑cp38‑cp38‑win_amd64.whl and PyOpenGL‑3.1.5‑cp38‑cp38‑win_amd64.whl because I’m running Python 3.8

  1. pip install .PyOpenGL_accelerate-3.1.5-cp39-cp39-win_amd64.whl returns PyOpenGL-accelerate is already installed with the same version as the provided wheel. Use —force-reinstall to force an installation of the wheel.
  2. pip install .PyOpenGL_accelerate-3.1.5-cp38-cp38-win_amd64.whl returns PyOpenGL-accelerate is already installed with the same version as the provided wheel. Use —force-reinstall to force an installation of the wheel.

How can a so simple guide lead me to a so painful result?

How can I check if Visual C++ 14.0 build tools is installed. Maybe that is the only step I’m missing?

Advertisement

Answer

The freeglut DLL is missing from the package.

Download the package wheel (“PyOpenGL‑3.1.5‑cp39‑cp39‑win_amd64.whl”) from, Unofficial Windows Binaries for Python Extension Packages and install it:

Источник

PyOpenGL Bugs

Group

Searches

#232 OpenGL.error.NullFunctionError: Attempt to call an undefined

I get:
C:UsersGregDownloads>shader_sphere.py
WARNING:OpenGL.arrays.numpymodule:Unable to load numpy_formathandler accelerator from OpenGL_accelerate
WARNING:context:Python Image Library (PIL) not installed, no Image support available
http://www.pythonware.com/products/pil/index.htm
WARNING:context:Unable to load node implementation for MMImageTexture: ‘module’ object has no attribute ‘MMImageTexture’
Traceback (most recent call last):
File «C:UsersGregDownloadsshader_sphere.py», line 116, in
TestContext.ContextMainLoop()
File «C:Python27libsite-packagesopenglcontext-2.1.0a11-py2.7.eggOpenGLContextglutcontext.py», line 154, in ContextMainLoop
render = cls( *args, **named)
File «C:Python27libsite-packagesopenglcontext-2.1.0a11-py2.7.eggOpenGLContextglutcontext.py», line 30, in __init__
glutInitDisplayMode( self.DISPLAYMODE )
File «C:Python27libsite-packagespyopengl-3.0.1-py2.7.eggOpenGLplatformbaseplatform.py», line 340, in __call__
self.__name__, self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInitDisplayMode, check for bool(glutInitDisplayMode) before calling

Discussion

I installed PIL, but I still get:

C:UsersGregDownloads>shader_sphere.py
WARNING:OpenGL.arrays.numpymodule:Unable to load numpy_formathandler accelerator from OpenGL_accelerate
Traceback (most recent call last):
File «C:UsersGregDownloadsshader_sphere.py», line 116, in
TestContext.ContextMainLoop()
File «C:Python27libsite-packagesopenglcontext-2.1.0a11-py2.7.eggOpenGLContextglutcontext.py», line 154, in ContextMainLoop
render = cls( *args, **named)
File «C:Python27libsite-packagesopenglcontext-2.1.0a11-py2.7.eggOpenGLContextglutcontext.py», line 30, in __init__
glutInitDisplayMode( self.DISPLAYMODE )
File «C:Python27libsite-packagespyopengl-3.0.1-py2.7.eggOpenGLplatformbaseplatform.py», line 340, in __call__
self.__name__, self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInitDisplayMode, check for bool(glutInitDisplayMode) before calling

You are missing GLUT, though why I can’t say, as it is supposed to be installed with PyOpenGL in the windows installer.

This is Windows 7 x64 with 64-bit Python. The PyOpenGL installer does not work with 64 bit Python (no installers do. see: http://bugs.python.org/issue6792 )

Instead I did: easy_install pyopengl

Then you will need a 64-bit build of GLUT, I’m guessing. FreeGLUT or GLUT32 should work.

Hi! This source code do not import GLUT!
http://bazaar.launchpad.net/

Do you add:
from OpenGL.GLUT import *
in your code?

Oh, and check if you have glu32.dll in Windows/SysWOW64 (if not copy it from Windows/System32), it can help (as i 64bit system there are too folders for libs, and sometimes Win do not care to check them both)

Источник

demo not working #192

Hi Vispy team,
I am playing vispy now but I experience problem to get most demo working (except the basic canvas window one), the error message I get are as following:

in init
self.program.bind(gloo.VertexBuffer(data))

AttributeError: ‘Program’ object has no attribute ‘bind’

I am using:
Python 2.7.5 |Anaconda 1.8.0 (64-bit)
NumPy 1.8.0, SciPy 0.13.3, Matplotlib 1.3.1
and I believe I am using opengl 4.0 (in win8.1)

Let me know if I miss something essential. Thanks!

The text was updated successfully, but these errors were encountered:

Sorry I hasn’t experiment enough in my last post.
I find the last AttributeError problem exists in demos atom.py and galaxy.py, but the display-points example works fine.

What version are you using? I think the 0.2 release had most examples working. The current master has many broken examples, but atom and galaxy should both be working.

Thanks for the response! I am using version 0.2.1. Please let me know how I can help narrow this done.

I am not able to reproduce this problem, and I don’t see any calls
program.bind in either atom.py or galaxy.py under 0.2.1.
Is it possible that you have a bad installation (multiple versions mixed
together) ?

On Sun, Mar 9, 2014 at 10:29 PM, phyinmi notifications@github.com wrote:

Thanks for the response! I am using version 0.2.1. Please let me know how
I can help narrow this done.

Reply to this email directly or view it on GitHubhttps://github.com//issues/192#issuecomment-37148857
.

I am new to vispy so v0.2.1 is the only version I installed.
I also tried some other demos, game-of-life.py gives an error message like below:

line 22, in
from vispy.gloo import Program, FrameBuffer, DepthBuffer

ImportError: cannot import name DepthBuffer

The rain.py demo gives another message:

File «C. Anacondalibsite-packagesOpenGLGLUTspecial.py», line 324, in glutInit
_base_glutInit( ctypes.byref(count), holder )

TypeError: ‘NoneType’ object is not callable

and produce a black window, after I close the window and try to reproduce the problem the error message changed to following:

line 134, in
glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH)

File «C. Anacondalibsite-packagesOpenGLplatformbaseplatform.py», line 384, in call
self.name, self.name,

NullFunctionError: Attempt to call an undefined function glutInitDisplayMode, check for bool(glutInitDisplayMode) before calling

So I guess maybe something is wrong with my OpenGL package?

Источник

OpenGL.error.NullFunctionError: Attempt to call an undefined function glGenFramebuffers #4

Reported by project member ext@sidvind.com, Jul 21, 2011
What steps will reproduce the problem?

  1. Run client on GPU driver which does not implement OpenGL 3.3

<<<
Traceback (most recent call last):
File «client.py», line 398, in
client = Client()
File «client.py», line 172, in init
self._game = GameWidget(self, resolution)
File «/home/ext/workspace/yamosg/client/game.py», line 104, in init
FBOWidget.init(self, Vector2i(0,0), size)
File «/home/ext/workspace/yamosg/client/ui/init.py», line 116, in init
self._fbo = glGenFramebuffers(1)
File «/usr/lib/pymodules/python2.7/OpenGL/latebind.py», line 45, in call
return self._finalCall( _args, *_named )
File «/usr/lib/pymodules/python2.7/OpenGL/wrapper.py», line 573, in wrapperCall
result = self.wrappedOperation( *cArguments )
File «/usr/lib/pymodules/python2.7/OpenGL/platform/baseplatform.py», line 340, in call
self.name, self.name,
OpenGL.error.NullFunctionError: Attempt to call an undefined function glGenFramebuffers, check for bool(glGenFramebuffers) before calling
>>>

Must check if glGenFramebuffer and friends is supported directly by the driver, then if _framebuffer_object is supported and switch to it if possible. If not it should fail with a more useful message.

The text was updated successfully, but these errors were encountered:

Источник

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
try:
  from OpenGL.GLUT import *
  from OpenGL.GL import *
  from OpenGL.GLU import *
except:
  print('ERROR: PyOpenGL not installed properly.')
  import sys
  sys.exit()
 
 
global xrot
global yrot
global ambient
global greencolor
global treecolor
global lightpos
 
def init():
    global xrot
    global yrot
    global ambient
    global greencolor
    global treecolor
    global lightpos
 
    xrot = 0.0
    yrot = 0.0
    ambient = (1.0, 1.0, 10, 1)
    greencolor = (0.2, 0.8, 0.0, 0.8)
    treecolor = (0.9, 0.6, 0.3, 0.8)
    lightpos = (1.0, 1.0, 1.0)
 
    glClearColor(0.5, 0.5, 0.5, 1.0)
    gluOrtho2D(-1.0, 1.0, -1.0, 1.0)
    glRotatef(-90, 1.0, 0.0, 0.0)
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient)
    glEnable(GL_LIGHTING)
    glEnable(GL_LIGHT0)
    glLightfv(GL_LIGHT0, GL_POSITION, lightpos)
 
def specialkeys(key, x, y):
    global xrot
    global yrot
 
    if key == GLUT_KEY_UP:
        xrot -= 2.0
    if key == GLUT_KEY_DOWN:
        xrot += 2.0
    if key == GLUT_KEY_LEFT:
        yrot -= 2.0
    if key == GLUT_KEY_RIGHT:
        yrot += 2.0
 
    glutPostRedisplay()
 
def draw():
    global xrot
    global yrot
    global greencolor
    global treecolor
    global lightpos
 
    glClear(GL_COLOR_BUFFER_BIT)
    glPushMatrix()
    glRotatef(xrot, 1.0, 0.0, 0.0)
    glRotatef(yrot, 0.0, 1.0, 0.0)
    glLightfv(GL_LIGHT0, GL_POSITION, lightpos)
 
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, treecolor)
    glTranslatef(0.0, 0.0, -0.7)
 
    glutSolidCylinder(0.1, 0.2, 20, 20)
 
    glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE, greencolor)
    glTranslatef(0.0, 0.0, 0.2)
 
    glutSolidCone(0.5, 0.5, 20, 20)
    glTranslatef(0.0, 0.0, 0.3)
    glutSolidCone(0.4, 0.4, 20, 20)
    glTranslatef(0.0, 0.0, 0.3)
    glutSolidCone(0.3, 0.3, 20, 20)
 
    glPopMatrix()
    glutSwapBuffers()
 
#try:
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
glutInitWindowSize(300, 300)
glutInitWindowPosition(50, 50)
glutInit(sys.argv)
glutCreateWindow(b"Happy New Year!")
glutDisplayFunc(draw)
glutSpecialFunc(specialkeys)
init()
glutMainLoop()
#except:
    #print('Not work! Why?!?!?!')

Оказалось, что если просто взять и открыть первый попавшийся урок по OpenGL на Python, то скорее всего ничего не получится. Всё пробовал на Python 3.6.5 под Windows x64. Для начала. пробуем установать пакеты, которые используются в скриптах:

Python36python.exe -m pip install PyOpenGL
Collecting PyOpenGL
  Using cached PyOpenGL-3.1.5-py3-none-any.whl (2.4 MB)
Installing collected packages: PyOpenGL
Successfully installed PyOpenGL-3.1.5
Python36python.exe -m pip install PyOpenGL-accelerate
Collecting PyOpenGL-accelerate
  Using cached PyOpenGL_accelerate-3.1.5-cp36-cp36m-win_amd64.whl (329 kB)
Installing collected packages: PyOpenGL-accelerate
Successfully installed PyOpenGL-accelerate-3.1.5

Теперь попробуем выполнить скрипт из примеров примерно с таким содержимым:

from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
...
glutInit()
...

Результат получится примерно такой:

Python36python.exe testopengl.py
Traceback (most recent call last):
  File "testopengl.py", line 30, in <module>
    glutInit()
  File "PythonPython36libsite-pac
kagesOpenGLGLUTspecial.py", line 333, in glutInit
    _base_glutInit( ctypes.byref(count), holder )
  File "PythonPython36libsite-pac
kagesOpenGLplatformbaseplatform.py", line 425, in __call__
    self.__name__, self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit,
check for bool(glutInit) before calling

По советам из интернета скачиваем freeglut (качал отсюда https://www.transmissionzero.co.uk/files/software/development/GLUT/freeglut-MSVC-3.0.0-2.mp.zip), извлекаем оттуда и ложим рядом со скриптом файл freeglut.dll. Пробуем запустить скрипт снова — получаем ту же самую ошибку. В интернете пишут, что в стандартных пакетах питона какой-то касяк, поэтому их нужно удалить:

Python36python.exe -m pip uninstall pyopengl
Found existing installation: PyOpenGL 3.1.5
Uninstalling PyOpenGL-3.1.5:
  Would remove:
    pythonpython36libsite-package
sopengl*
    pythonpython36libsite-package
spyopengl-3.1.5.dist-info*
Proceed (y/n)? y
  Successfully uninstalled PyOpenGL-3.1.5

Python36python.exe -m pip uninstall pyopengl-accelerate
Found existing installation: PyOpenGL-accelerate 3.1.5
Uninstalling PyOpenGL-accelerate-3.1.5:
  Would remove:
    pythonpython36libsite-package
sopengl_accelerate*
    pythonpython36libsite-package
spyopengl_accelerate-3.1.5.dist-info*
Proceed (y/n)? y
  Successfully uninstalled PyOpenGL-accelerate-3.1.5

А теперь, говорят, надо скачивать альтернативные пакеты вот отсюда: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl. Я схватился за самый свежий пакет PyOpenGL‑3.1.5‑cp39‑cp39‑win_amd64.whl, и он мне не подошёл:

Python36python.exe -m pip install PyOpenGL-3.1.5-cp39-cp39-win_amd64.whl
ERROR: PyOpenGL-3.1.5-cp39-cp39-win_amd64.whl is not a supported wheel on this p
latform.

Как я понял, в названии пакета 39 — это версия питона, для которого предназначен пакет, то есть мне для 3.6.5 нужны пакеты с цифрой 36:

Python36python.exe -m pip install PyOpenGL-3.1.5-cp36-cp36m-win_amd64.whl
Processing pyopengl-3.1.5-cp36-cp36m-win_amd64.whl
Installing collected packages: PyOpenGL
Successfully installed PyOpenGL-3.1.5

Python36python.exe -m pip install PyOpenGL_accelerate-3.1.5-cp36-cp36m-win_am
d64.whl
Processing pyopengl_accelerate-3.1.5-cp36-cp36m-win_amd64.whl
Installing collected packages: PyOpenGL-accelerate
Successfully installed PyOpenGL-accelerate-3.1.5

Ну и теперь пробуем запустить скрипт:

python.exe testopengl.py

Python OpenGL

Python OpenGL

Короче победа. Все загрузки (пакеты для питона и freeglut) проверялись антивирусом, но если будете повторять — качайте на свой страх и риск.

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Opengl error 1286 invalid framebuffer operation
  • Opengl error 1283 stack overflow minecraft что делать
  • Opengl error 1282 invalid value майнкрафт как исправить
  • Opengl error 1282 invalid operation minecraft
  • Opengl error 1281 invalid value майнкрафт как исправить

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии