Python Forum
NullFunctionError opengl glutInit
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NullFunctionError opengl glutInit
#1
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *

window = 0                                             # glut window number
width, height = 500, 400                               # window size

def draw():                                            # ondraw is called all the time
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # clear the screen
    glLoadIdentity()                                   # reset position
    
    # ToDo draw rectangle
    
    glutSwapBuffers()                                  # important for double buffering
    

# initialization
glutInit()                                             # initialize glut
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
glutInitWindowSize(width, height)                      # set window size
glutInitWindowPosition(0, 0)                           # set window position
window = glutCreateWindow("noobtuts.com")              # create window with title
glutDisplayFunc(draw)                                  # set draw function callback
glutIdleFunc(draw)                                     # draw all the time
glutMainLoop()                                         # start everything
Error:
Traceback (most recent call last):   File "graphic.py", line 47, in <module>     if __name__ == '__main__': main()   File "graphic.py", line 9, in main     glutInit(sys.argv)   File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\site-package s\pyopengl-3.1.1a1-py3.5.egg\OpenGL\GLUT\special.py", line 333, in glutInit     _base_glutInit( ctypes.byref(count), holder )   File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\site-package s\pyopengl-3.1.1a1-py3.5.egg\OpenGL\platform\baseplatform.py", line 407, in __ca ll__     self.__name__, self.__name__, OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling
i copied and paste this from the internet to my project,so there should not be any error.
I am only 15 years old,so please dont use too much hard to understand or mathematical term in the answer.

Why is no one answering me?
Reply
#2
Apparently, there is no glutInit in the namespace. There is a hint in the error message to check for glutInit() before calling it.
The bottom line.

"check for bool(glutInit) before calling"

You can do the same calling dir():
if 'glutInit' in dir():
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
Thanks,let me try it first.
I will come back if there is still error.
I also heard from another website that glut needs to be downloaded seperately because it does not come with pypl PyOpenGL download.
Reply
#4
It's quite possible. This module is big  Smile
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pygame with OpenGL on RPI Zero without X: invalid operation aserranoh 0 1,354 Mar-20-2022, 09:49 PM
Last Post: aserranoh
  Creating shadow in OpenGL with normal? hsunteik 0 3,336 Apr-27-2017, 08:23 AM
Last Post: hsunteik
  how to destroy or remove object rendered with opengl from the screen? hsunteik 1 7,016 Apr-09-2017, 01:30 PM
Last Post: hsunteik
  NullFunctionError in opengl hsunteik 2 4,034 Apr-04-2017, 07:29 AM
Last Post: hsunteik
  Traditional OpenGL vs GLSL? hsunteik 2 4,027 Mar-27-2017, 03:54 PM
Last Post: nilamo
  How to set the window icon with OpenGL GLUT hsunteik 3 6,192 Mar-19-2017, 11:53 AM
Last Post: Larz60+
  how to draw terrain like minecraft in python using opengl with perlin noise value? hsunteik 0 5,448 Jan-21-2017, 11:45 AM
Last Post: hsunteik
  Can OpenGL object be overlap? hsunteik 4 5,035 Jan-19-2017, 02:43 PM
Last Post: Windspar
  find location of opengl object? hsunteik 1 3,313 Jan-17-2017, 11:30 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020