简体   繁体   English

使用Snow Leopard的Python OpenGL?

[英]OpenGL in Python with Snow Leopard?

I'm interested in playing around with OpenGL in Python. 我有兴趣在Python中使用OpenGL。 I've used OpenGL in C++ and Objective-C, but I don't have much experience in Python. 我在C ++和Objective-C中使用过OpenGL,但我在Python方面没有太多经验。 I'm wondering if there's a good tutorial that works in Snow Leopard. 我想知道是否有一个适用于Snow Leopard的好教程。 I'd prefer to stay in 64-bit mode if possible, since I've heard 32-bit programs require loading a lot of extra 32-bit libraries. 如果可能的话,我宁愿保持64位模式,因为我听说过32位程序需要加载很多额外的32位库。

I've already tried a PyOpenGL/wxPython tutorial . 我已经尝试过PyOpenGL / wxPython教程 When I ran the code, it crashed with this message: 当我运行代码时,它崩溃了这条消息:

ImportError: /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode/wx/_core_.so: no appropriate 64-bit architecture (see "man python" for running in 32-bit mode)

It looks like there's a bug in wxPython that prevents it from working on a 64-bit system. 看起来wxPython中存在一个错误 ,它阻止它在64位系统上运行。

I also looked at Pyglet, but they have a similar issue . 我也看过Pyglet,但他们有类似的问题 They provide a work-around (setting Python to 32-bit mode), but it doesn't look like they're going to fix it. 它们提供了一种解决方法(将Python设置为32位模式),但它看起来并不像是要修复它。

Finally, I looked at PyGLUT, but I think it's only for Windows. 最后,我查看了PyGLUT,但我认为它仅适用于Windows。

Are there any other libraries that would let me access OpenGL and draw on the screen? 还有其他库可以让我访问OpenGL并在屏幕上绘图吗? Again, I'd prefer to stay in 64-bit mode, but if nothing works, I'll switch to 32-bit and try wxPython or Pyglet again. 同样,我宁愿保持64位模式,但如果没有任何作用,我将切换到32位并再次尝试wxPython或Pyglet。


Edit: I've also tried PyGame. 编辑:我也试过PyGame。 It depends on SDL which is broken in SL. 这取决于在SL中被破坏的 SDL。 I thought about trying to use Cocoa through PyObjc, but the Xcode Python application templates have been removed . 我想过尝试通过PyObjc使用Cocoa,但Xcode Python应用程序模板已被删除

I've used PyOpenGL 3.0.0 quite successfully on Snow Leopard. 我已经在Snow Leopard上成功使用了PyOpenGL 3.0.0。 It uses ctypes, so it should be making 64-bit calls if those libraries are available (and Snow Leopard's Python includes a 64-bit version). 它使用ctypes,因此如果这些库可用,它应该进行64位调用(而Snow Leopard的Python包含64位版本)。 I haven't used the wxPython stuff with PyOpenGL so that's where you might be running into problems, but PyOpenGL also includes GLUT, which both run fine. 我没有在PyOpenGL中使用wxPython的东西,所以你可能遇到问题,但PyOpenGL也包括GLUT,它们都运行正常。

There's probably no good reason to avoid 32-bit mode. 可能没有理由避免使用32位模式。 Unless your Python programs need to larger address space, of course. 当然,除非你的Python程序需要更大的地址空间。

You could try pygame. 你可以尝试pygame。 Pygame is a python wrapper around SDL. Pygame是围绕SDL的python包装器。 According to their website they have Max OS X binaries. 根据他们的网站,他们有Max OS X二进制文件。 Here is a simple example of using pygame with OpenGL. 这是一个使用pygame和OpenGL的简单示例 Once you are able to create the window and handle events most OpenGL programming is just like it would be in C or C++, but with some added python goodness. 一旦你能够创建窗口并处理事件,大多数OpenGL编程就像在C或C ++中一样,但是有一些额外的python优点。 For OpenGL a great tutorial is NeHe. 对于OpenGL来说,一个很棒的教程是NeHe。

Also when programing with OpenGL in python remember that Python datastructures can be rather slow when it comes to requirements for 3D graphics. 此外,当在python中使用OpenGL进行编程时,请记住,当涉及到3D图形的要求时,Python数据结构可能会相当慢。 PyGL developers for example recommend using ctypes for operations that concern graphics, since that way you can get enough performance for some complicated geometry with bareable FPS. 例如,PyGL开发人员建议将ctypes用于涉及图形的操作,因为通过这种方式,您可以获得具有可靠FPS的某些复杂几何体的足够性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM