Re: [PyOpenGL-Users] glut, freeglut, dlls lookup
Brought to you by:
mcfletch
From: G. E. D. <ge...@ho...> - 2010-11-04 21:05:25
|
Here are some changes to provide selection of freeglut.dll or glut32.dll for PyOpenGL on Win32 platforms. 1) Put both dlls in site-packages\OpenGL\DLLS. 2) Add USE_FREEGLUT to site-packages\OpenGL\__init__.py as follows: FROM: ---- UNSIGNED_BYTE_IMAGES_AS_STRING = True # Declarations of plugins provided by PyOpenGL itself TO: --- UNSIGNED_BYTE_IMAGES_AS_STRING = True USE_FREEGLUT = False # Declarations of plugins provided by PyOpenGL itself 3) Make following changes to site-packages\OpenGL\platforms\win32.py. FROM: ----- """Windows-specific platform features""" import ctypes from OpenGL.platform import ctypesloader, baseplatform class Win32Platform( baseplatform.BasePlatform ): """Win32-specific platform implementation""" GLUT_GUARD_CALLBACKS = True GL = OpenGL = ctypesloader.loadLibrary( ctypes.windll, \ 'opengl32', mode = ctypes.RTLD_GLOBAL ) GLU = ctypesloader.loadLibrary( ctypes.windll, \ 'glu32', mode = ctypes.RTLD_GLOBAL ) try : GLUT = ctypesloader.loadLibrary( ctypes.windll, \ 'glut32', mode = ctypes.RTLD_GLOBAL ) except WindowsError, err: GLUT = None GLE = None TO: --- """Windows-specific platform features""" import ctypes from OpenGL import USE_FREEGLUT from OpenGL.platform import ctypesloader, baseplatform class Win32Platform( baseplatform.BasePlatform ): """Win32-specific platform implementation""" GLUT_GUARD_CALLBACKS = True GL = OpenGL = ctypesloader.loadLibrary( ctypes.windll, \ 'opengl32', mode = ctypes.RTLD_GLOBAL ) GLU = ctypesloader.loadLibrary( ctypes.windll, \ 'glu32', mode = ctypes.RTLD_GLOBAL ) if USE_FREEGLUT : try : GLUT = ctypesloader.loadLibrary( ctypes.windll, \ 'freeglut', mode = ctypes.RTLD_GLOBAL ) except WindowsError, err: GLUT = None else : try : GLUT = ctypesloader.loadLibrary( ctypes.windll, \ 'glut32', mode = ctypes.RTLD_GLOBAL ) except WindowsError, err: GLUT = None GLE = None 4. Make following changes to site-packages\OpenGL\GLUT\__init__.py. FROM: ----- try: from OpenGL.GLUT.freeglut import * HAVE_FREEGLUT = False except ImportError, err: HAVE_FREEGLUT = True TO: --- try: from OpenGL.GLUT.freeglut import * if bool(glutMainLoopEvent) : HAVE_FREEGLUT = True else : HAVE_FREEGLUT = False except ImportError, err: HAVE_FREEGLUT = False 5. Import PyOpenGL GL, GLE, and GLUT modules using freeglut like this: import OpenGL OpenGL.USE_FREEGLUT = True from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * |