[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] 127.5



I don't see why pygame should be involved at all in your texture creation.

python's "array" module should let you create an array of floats, and glTexImage2d should support GL_FLOAT for the data type argument. Does that work?


On Fri, Jul 30, 2010 at 7:10 AM, Ian Mallett <geometrian@xxxxxxxxx> wrote:
Hi,

Intro:
So, I'm working on computational fluid dynamics, and I need to initialize a velocity texture, which stores a vector field in an image. Velocity vectors can have a range of values; each component could be either positive and negative. The X component goes in the red channel, the Y in the green, and so on. To store the values, the image maps the range [0,255] to [-1.0,1.0]. I need to have a surface set to precisely velocity = 0 on all channels.

The problem:
Because of this, I need a surface filled with the color 127.5. Obviously, more than 8 bits per channel are required. To update the texture, I'm using GL_RGBA32F_ARB, which allocates 32 bits per channel. Unfortunately, the base image created by PyGame has a value of 127 â -0.00196 velocity. In practice, this leads to "drift" in the simulation. Can something be done to send a 32 bit per channel surface filled with 127.5 values to the OpenGL?

Thanks,
Ian