@bob thank for reply but link you provide is using some external library i want native code help need!!
On Tuesday, 4 December 2012 02:08:52 UTC+5:30, bob wrote: > > Okay. I think this shows you how to do it in Java: > > (from http://slick.javaunlimited.net/viewtopic.php?p=28303#p28303) > > > PolarizeShaderTest.java > Code: > import org.newdawn.slick.AppGameContainer; > import org.newdawn.slick.BasicGame; > import org.newdawn.slick.Color; > import org.newdawn.slick.GameContainer; > import org.newdawn.slick.Graphics; > import org.newdawn.slick.Image; > import org.newdawn.slick.Input; > import org.newdawn.slick.SlickException; > import org.newdawn.slick.opengl.shader.ShaderProgram; > > public class PolarizeShaderTest extends BasicGame { > > public static void main(String[] args) throws SlickException { > new AppGameContainer(new PolarizeShaderTest(), 800, 600, > false).start(); > } > > public PolarizeShaderTest() { > super("Polarize Test"); > } > > private ShaderProgram polarizeShader; > private Image image; > private boolean useShader, shaderSupported; > > private final String VERT = "testdata/shaders/pass.vert"; > private final String FRAG = "testdata/shaders/rect2polar.frag"; > > @Override > public void init(GameContainer container) throws SlickException { > container.getGraphics().setBackground(Color.gray); > > //create a new image > //Slick's images will use texture unit zero by default > image = new Image("testdata/polar.png"); > > //if shaders are supported... > if (ShaderProgram.isSupported()) { > try { > //"Strict Mode" will throw errors if we try > //to set a uniform that does not exist > //or isn't used in the shader. For flexibility, > //let's turn this off. > ShaderProgram.setStrictMode(false); > > //We can conveniently load a program like so: > polarizeShader = ShaderProgram.loadProgram(VERT, FRAG); > > //we have to set up the uniforms tex0, texOff and texSize > polarizeShader.bind(); > > //this means we are sampling from our image > polarizeShader.setUniform1i("tex0", 0); > > //we set up texOff/texSize to account for possible sub-regions > //this allows us to use Image.getSubImage, or NPOT images > float texW = image.getTextureWidth(); > float texH = image.getTextureHeight(); > float texX = image.getTextureOffsetX(); > float texY = image.getTextureOffsetY(); > polarizeShader.setUniform2f("texSize", texW, texH); > polarizeShader.setUniform2f("texOff", texX, texY); > > //unbind the shader once we're done > polarizeShader.unbind(); > > //shader works. > shaderSupported = true; > useShader = true; > } catch (SlickException e) { > e.printStackTrace(); > } > } > } > > @Override > public void render(GameContainer container, Graphics g) > throws SlickException { > //activate the shader > if (shaderSupported && useShader) > polarizeShader.bind(); > > //now anything we draw will use our polarize shader > image.draw(); > > //disable the shader > if (shaderSupported && useShader) > polarizeShader.unbind(); > > String str = shaderSupported > ? "Press space to toggle shader" > : "Shaders not supported!"; > g.drawString(str, 10, 20); > } > > > @Override > public void update(GameContainer container, int delta) > throws SlickException { > if (container.getInput().isKeyPressed(Input.KEY_SPACE)) > useShader = !useShader; > } > } > > > pass.vert > Code: > void main() { > gl_TexCoord[0] = gl_MultiTexCoord0; > gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; > } > > > rect2polar.frag > Code: > #version 120 > > uniform sampler2D tex0; > uniform vec2 texOff; > uniform vec2 texSize; > const float PI = 3.14159265358979323846264; > > void main(void) { > vec2 texCoord = gl_TexCoord[0].st; > > //account for Slick's Image sub-regions (and NPOT images) > texCoord = (texCoord-texOff)/texSize; > > //rectangular to polar filter > vec2 norm = (1.0 - texCoord) * 2.0 - 1.0; > float theta = PI + atan(norm.x, norm.y); > float r = length(norm); > vec2 polar = 1.0 - vec2(theta/(2.0*PI), r); > > //sample the texture using the new coordinates > vec4 color = texture2D(tex0, (polar+texOff)*texSize); > gl_FragColor = color; > } > > > > On Monday, December 3, 2012 1:15:30 PM UTC-6, djhacktor wrote: >> >> @bob its difficult to understand this logic m short of time can you pls >> give me android specific project or class file that will be appreciated >> thanks >> >> On Tuesday, 4 December 2012 00:11:18 UTC+5:30, bob wrote: >>> >>> You will want to see the source code to the GIMP's polar coordinate >>> filter. >>> >>> >>> Here's a little bit: >>> >>> >>> if (pcvals.polrec) >>> >>> { >>> >>> if (wx >= cen_x) >>> >>> { >>> >>> if (wy > cen_y) >>> >>> { >>> >>> phi = G_PI - atan (((double)(wx - cen_x))/ >>> >>> ((double)(wy - cen_y))); >>> >>> } >>> >>> else if (wy < cen_y) >>> >>> { >>> >>> phi = atan (((double)(wx - cen_x))/((double)(cen_y - wy))); >>> >>> } >>> >>> else >>> >>> { >>> >>> phi = G_PI / 2; >>> >>> } >>> >>> } >>> >>> else if (wx < cen_x) >>> >>> { >>> >>> if (wy < cen_y) >>> >>> { >>> >>> phi = 2 * G_PI - atan (((double)(cen_x -wx)) / >>> >>> ((double)(cen_y - wy))); >>> >>> } >>> >>> else if (wy > cen_y) >>> >>> { >>> >>> phi = G_PI + atan (((double)(cen_x - wx))/ >>> >>> ((double)(wy - cen_y))); >>> >>> } >>> >>> else >>> >>> { >>> >>> phi = 1.5 * G_PI; >>> >>> } >>> >>> } >>> >>> >>> r = sqrt (SQR (wx - cen_x) + SQR (wy - cen_y)); >>> >>> On Monday, December 3, 2012 11:49:20 AM UTC-6, djhacktor wrote: >>>> >>>> thank for reply can you give me some sample code it will be great help >>>> >>>> On Monday, 3 December 2012 21:06:28 UTC+5:30, bob wrote: >>>>> >>>>> Here's a sample of how it might >>>>> look:<https://lh5.googleusercontent.com/-JcHGjFm_o5M/ULzG2CfgerI/AAAAAAAAAJM/xaBMEZoV3og/s1600/polar3.png> >>>>> >>>>> >>>>> On Monday, December 3, 2012 12:15:23 AM UTC-6, djhacktor wrote: >>>>>> >>>>>> Hi can any one tell me how to make seek bar in circular shape ?? is >>>>>> there any example ?? >>>>> >>>>> -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en