Re: [PyOpenGL-Users] Texture colour wrapping
Brought to you by:
mcfletch
From: Dirk R. <dir...@gm...> - 2011-11-05 19:02:22
|
Hi Brice, On 11/05/2011 01:46 PM, Brice Thurin wrote: > Thanks for both your reply. The range of the input data vary but I could fix it > if it makes things easier. > > Note I do not want 2pi and 4pi to both map to the same physical location, I want > 2pi and 4pi to be displayed with the same gray level or colour. Ah, ok, I was starting to get confused. You really do want the basic input value -> color mapping. That's pretty easy. Define the color map that you want to use as a texture (1D is fine, 2D works too). Set the texture wrapping mode to REPEAT (glTexParameter(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT)). This makes OpenGL accept any texture coordinate value and just use the fractional part to index into the texture. Use your input values (your -15pi to 15pi) as the texture coordinate for each vertex. The texture coordinates will always be between 0 and 1, so if you want the texture to repeat after 2pi you will either need to divide them by 2pi before giving them to OpenGL, or use a texture matrix to divide. Hope it helps Dirk |