Re: Texture colour wrapping

Dirk Reiners <[email protected]>
Newsgroups gmane.comp.python.opengl.user
Message-ID <[email protected]>
	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


------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.