问题标签 [pyopengl]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1507 浏览

python - 使用 MacPorts 安装 PyOpenGL

我正在尝试使用 macports 安装 PyOpenGL,我想使用 Python 2.7,我也安装了 macports。但是,当我安装它时,似乎只有 Python 2.4 可以访问 PyOpenGL:sudo port install py-opengl

有谁知道发生了什么?如何让 python 2.7 看到 PyOpenGL?

0 投票
3 回答
17409 浏览

python - Python PIL Image.tostring()

我是 Python 和 PIL 的新手。我正在尝试遵循代码示例,了解如何通过 PIL 将图像加载到 Python 中,然后使用 openGL 绘制其像素。这是代码的一些行:

......

这将在画布上绘制一个 200 x 200 的像素块。然而,这不是预期的图像——它看起来像是从随机存储器中绘制像素。随机记忆假设得到以下事实的支持:即使我尝试绘制完全不同的图像,我也会得到相同的图案。有人可以帮我吗?我在 Windows XP 上使用 Python 2.7 和 pyopenGL 和 PIL 的 2.7 版本。

截屏

0 投票
1 回答
361 浏览

opengl - glInterleavedArray formats

I have an interleaved array format and I want to render it in open GL. It is an array of triangles. The vertices are 2D floating points and the colors are RGBA floating points. That is, a single triangle is layed out this this:

Where all number are single precision floats. I'm having trouble figuring out what the format parameter should be. It seems like it needs V2F and C4F, but not such symbolic constant exists. Can I OR them together like (GL_V2F | GL_C4F)?

UPDATE: I'm using python and pyopengl. tibur's answer is very clear and if I were programming in C I'd be done. The python code is pretty similar, but I have to have to offset the pointer into the color array by 8 bytes. I don't know how to do this in python or if it even can be done:

I need to avoid copying the entire interleaved array. Otherwise I could just make a copy and chop off the first 8 bytes.

0 投票
2 回答
469 浏览

opengl - 颜色更新时旋转模型

在 OpenGL 中,我像结构(神经元)一样绘制树(由线条组成),并且基于活动,我在树的每个分支上应用颜色。每个分支部分在一个实例中可以具有不同的颜色。我在与分支对应的实例中记录颜色。

我能够旋转(通过更改模型视图矩阵)树。更新时,我可以看到树枝上不断变化的颜色(活动)。

但是,当颜色发生变化时,我无法旋转树。(完全更新后会看到旋转)翻译模型也是如此,更新时无法翻译。

我应该怎么做才能同时看到它们?

我调用 updateViz 函数来更新颜色。

我使用 PyQt4 和 PyGLWidget

0 投票
2 回答
1115 浏览

python - 在 Python 2.6.6 中使用 pyopengl 时遇到问题

我想要做的是编写一个基本的 OpenGL 2.0 窗口,当我从文件运行代码时,它适用于前几次运行,然后转储错误。如果我从 IDLE GUI 运行完全相同的代码,我每次都会得到一个窗口。以下是添加的 Python 2.6.6 包、代码和错误的列表。我是否使用了任何冲突的软件包?我错过了一个包裹吗?我的导入在 IDLE GUI 中工作。任何帮助都会很棒!

抱歉帖子的长度,我只是想完整地记录问题。Py 安装在 Win XP SP3 上运行,IDLE 标头:

0 投票
1 回答
1137 浏览

glsl - glsl pyOpenGL 数组传递

我目前正在玩 glsl 。为此,我需要将一个数组从 opengl 代码传递给 gsls,然后它会从数组中计算出新的颜色。但不知何故,这对我不起作用。我总是只停留在第一个条目上,而不是获得整个数组。你能帮我说说我做错了什么吗?

在着色器中:

非常感谢你们!

0 投票
2 回答
1983 浏览

python - PIL Image.fromstring from PyOpengl buffer has the wrong size

I use PyOpenGL to draw a 2D Image. Then I want to use the Python Imaging Library (PIL) to store this image to disk. I use GLUT to display the image which works perfectly. But when I use PIL to store the image it extracts the wrong clipping. It has the wrong size.

Here is a minimal example which reproduces the effect and I also attach the output to make it more clear without running some code.

this is how it looks int the GLUT window and how it is supposed to look like this is how it looks int the GLUT window and how it is supposed to look like

and this is how the saved image looks like and this is how the saved image looks like

0 投票
1 回答
619 浏览

opengl - OpenGL VBO 着色器

我有一个 2D VBO 对象,它代表 2D 空间中的点。那时绘制任意形状的最佳方法是什么?可以说我想在每个地方画一个红色的“X”。

我可以使用着色器来做到这一点吗?

0 投票
1 回答
365 浏览

segmentation-fault - glutInitDisplayMode 导致分段错误

我正在尝试执行我的第一个 pyopengl 程序,但在调用 glutInitDisplayMode 函数时遇到了一些问题。这是我所做的:

它不应该那么困难,但仍然给我带来麻烦;)

0 投票
1 回答
907 浏览

opengl - 以整数内部格式渲染纹理

我希望创建和操作具有整数内部格式的纹理(用于与 opencl 的进一步互操作)。但是,在映射此纹理的问题上,我似乎错过了一些重要的事情。这是一个代码示例,它会说更多。可以通过定义 INTERNAL 和 DATACOPY 变量来切换内部格式。

如果我使用浮点标准化内部格式(GL_RGBA,GL_RGBA)作为纹理,它工作得很好。示例代码将绘制嘈杂的彩色图像。但是一旦我切换到 (GL_RGBA8UI, GL_RGBA_INTEGER) 窗口就会变黑。

问题可能只出在我的配置上(nvidia fermi-arch)。因此,感谢您指出我的问题根源的任何帮助。