I’m very new to JOGL, I have been doing some tutorials.
Now i’m havin a wireframe surface in which i want to do zoning that is the color of a particular area is different respective to its z coordinates
how can i able to do it
THANKS IN ADVANCE
The most straightforward way of doing this that I can think of is to actually just use GLSL.
With the most simple mapping being…
gl_FragColor = vec4(gl_FragCoord.z);
But you can take the gl_FragCoord.z value and map it to colors with what ever sort of algebraic expression you’d like.
If however GLSL is not an option then you could still use automatic texture coordinate generation. Have a look at the glTexGen() OpenGL API. I just checked in the red book it says, when GL_OBJECT_LINEAR is used then the generation function is a linear combination of the object coordinates. If you choose appropriate coefficients then you can generate texture coordinates that are simply a function of z. With a 1-D texture of appropriate colors, you’re set.
I hope this helps!
Dear Friends
I am new to JOGL…and no working experience in this domain…can u gove me some simple example illustrating automatic texture generation…so that i can follow that for zoning in my problen of scalar field variable.
L2G (learn to google)
or read the redbook, if you’re new to jogl, then you’re probably new to opengl. In the redbook, it will tell you everything you could possibly want about anything in opengl. And then for fun, you could also read most of the specification. That’s what I did, it worked marvels for what I now know about opengl. I also remember that in the redbook it goes over automatic texture coordinate generation with an example very similar to what you want to do.
http://www.glprogramming.com/red/chapter09.html - read this! Actually, you may want to do some of the NeHe tutorials before you dive into the matter. I believe someone ported these to JOGL but am too lazy to investigate just now - do your own research…
EDIT: beware the link I gave you is to a pretty ancient edition of the red book (1.1). If you are serious about this then you really ought to buy your own, latest is still the 5th edition I think. Also I wouldn’t bother with the blue book as most of its content is online (I love the new OpenGL 2.1 reference pages, http://opengl.org/sdk/docs/man/)…