zoukankan      html  css  js  c++  java
  • 在orangepi-PC下使用pyopengl

    在OrangePi-PC下安装显卡驱动以及opengl:

    http://www.orangepi.org/orangepibbsen/forum.php?mod=viewthread&tid=53

    在这个链接中说要:Copy Libs (libGLES* libGLES* LibUmp LibMali) to /usr/lib 

    但是在查找动态链接库的时候,orangepi会在/usr/lib/arm-linux-gnueabihf下查找动态库,请参考ldconfig的手册,或者是查看/etc/ld.so.conf.d下的文件

    因此,我们需要拷贝 (libGLES* libGLES* LibUmp LibMali) 到 /usr/lib/arm-linux-gnueabihf 下

    安装完成后即可使用opengl es以及egl的c接口进行开发

    但是如果安装PyOpenGL:

      http://pyopengl.sourceforge.net

      在ubuntu下直接使用pip安装:

    pip install PyOpenGL --user
    pip install PyOpenGL-accelerate --user

    在import OpenGL.GL或者import OpenGL.GLES2时会报错:

    /home/orangepi/.local/lib/python2.7/site-packages/OpenGL/platform/glx.pyc in GL(self)
         18             ) 
         19         except OSError as err:
    ---> 20             raise ImportError("Unable to load OpenGL library", *err.args)
         21     @baseplatform.lazy_property
         22     def GLU(self):
    
    ImportError: ('Unable to load OpenGL library', '/usr/lib/arm-linux-gnueabihf/GL: cannot read file data: Is a directory', 'GL', None)

    这是由于OrangePi的mali驱动只提供了OpenGL ES接口,而PyOpenGL要求必须有GL接口。

    修正这个问题需要更改PyOpenGL下的platform/glx.py文件(如果使用pip安装,并使用--user参数,则安装路径为:~/.local/lib/python2.7/site-packages/OpenGL/platform/glx.py), 做如下更改:

    @baseplatform.lazy_property
    def GL(self):
        try:
            return ctypesloader.loadLibrary(
                ctypes.cdll,
                'GL',
                mode=ctypes.RTLD_GLOBAL
            )
       except OSError as err:
            # -- raise ImportError("Unable to load OpenGL library", *err.args)
    # ++ return None
    return None
    # GLX doesn't seem to have its own loadable module?
    @baseplatform.lazy_property
    # -- def GLX(self): return self.GL
    # ++ def GLX(self): return self.GLES2
    def GLX(self): return self.GLES2
    @baseplatform.lazy_property
    def GetCurrentContext( self ):
        # -- return self.GL.glXGetCurrentContext
        # ++ return None
        return None
    @baseplatform.lazy_property
    def glGetError( self ): 
        # -- return self.GL.glGetError
        # ++ return self.GLES2.glGetError
        return self.GLES2.glGetError

     这是在import OpenGL.GLES2即可成功

  • 相关阅读:
    JQuery是继prototype之后又一个优秀的Javascript库
    IAsyncResult接口
    Asynchronous Programming Patterns
    操作数据库的时候,使用自带的DbProviderFactory类 (涉及抽象工厂和工厂方法)
    8.2.4对象之间的关系
    git squash 和 git rebase
    8.2.3多态性 第8章 面向对象编程简介
    github的使用教程
    第7章 调试和错误处理 7.1.1 VS中的调试
    markdown的语法说明
  • 原文地址:https://www.cnblogs.com/astreye/p/5125502.html
Copyright © 2011-2022 走看看