English 中文(简体)
冰川融化阵列
原标题:glsl pyOpenGL array passing

I m currently playing around with glsl. For that purpose i need to pass an array from the opengl code to the gsls, which then in return calculates a new color out of the array. But somehow this doesn t work for me. Instead of getting the whole array I m always stuck with only the first entry. Could you help me by saying what I m doing wrong?

import numpy as np
\...
array = np.array([1.2,2.5,3.8,4.3,5.6, #....])
location = glGetUniformLocation(program,"arrayInShader")
glUniform1fv(location,1,array)

以及 in:

uniform float arrayInShader[5];
varying vec3 color;
void main()
{
    color.r=arrayInShader[0]+arrayInShader[1];
    color.g=arrayInShader[2];
    color.b=arrayInShader[3]+arrayInShader[4];
}

感谢许多gu!

最佳回答

<代码>glUniform*v的第二个参数是count。 卸载内容的数量。 你说,你只把1个浮体重新装入阵列,因此,开放式利比里亚公司只向阵列载一个浮体。

问题回答

暂无回答




相关问题
Building an interleaved buffer for pyopengl and numpy

I m trying to batch up a bunch of vertices and texture coords in an interleaved array before sending it to pyOpengl s glInterleavedArrays/glDrawArrays. The only problem is that I m unable to find a ...

Transparent FrameBuffer background in OpenGL

I want to use glClear and glClearColor to fill a frame buffer with a colour including alpha transparency. However the framebuffer always renders as opaque when binded to a texture which is rendered to ...

New to OpenGL and deprecation [closed]

I ve begun playing around with OpenGL in Python using PyOpenGL 3.0.1b. I looked at some sample code and started running it and modifying it etc. All was well until I became a little less ignorant. ...

Merging multiple line segments

My program uses PyOpenGL (so it s Python) with psyco. I have around 21,000 line segments which I need to render in each frame of my render (unless the user zooms in, in which case line segments are ...

How to uncheck a checkbox to stop infinite drawing in pyqt?

My problem is I want to keep rotating the scene if the checkbox is checked, and stop this rotation immediately once it is unchecked. However, "keep rotating" means an infinite loop... So after ...

热门标签