PDA

View Full Version : warp a an image on multiface object



rashesh
10-01-2009, 03:43 PM
Hi all

I am tryng to warp one texture (bmp image) on a surface made up of hundreds of ploygons. Image wraps fine length wise but not width wise.

any ideas?
thanks in advance

Gl.glGenTextures(1, out texName);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, texName);

Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_CLAMP);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_CLAMP);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_NEAREST_MIPMAP_NEAREST);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_NEAREST_MIPMAP_NEAREST);
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA, checkImageWidth, checkImageHeight, 0, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE,checkImage);
Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, Gl.GL_RGBA, checkImageWidth, checkImageHeight, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE,checkImage);

Alfonse Reinheart
10-01-2009, 06:15 PM
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_NEAREST_MIPMAP_NEAREST);

This is not allowed. The magnification filter can be GL_NEAREST or GL_LINEAR.

dletozeun
10-02-2009, 03:51 AM
And the call to glTexImage2D*is useless since you call gluBuild2DMipmaps but is not the cause of your problem IMO. Show us a screenshot of the problem it persists.

rashesh
10-02-2009, 08:56 AM
thanks for reply

Gl.glGenTextures(1, out texName);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, texName);

Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_REPEAT);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_REPEAT);

Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR_MIPMAP_LINEAR);
Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, Gl.GL_RGBA, checkImageWidth, checkImageHeight, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE,checkImage);


Gl.glEnable(Gl.GL_TEXTURE_2D);

Gl.glTexEnvf(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_MODULATE);

Gl.glBegin(Gl.GL_QUADS);
Gl.glTexCoord2d((double)sl0/sliceCount,(double)pt0/pointCount);
Gl.glVertex3dv(ref this.coordinates[this.indices[i++], 0]);
....many points follow
Gl.glEnd();
Gl.glDisable(Gl.GL_TEXTURE_2D);

I have corrected it but doesnt make any difference. all points are arrange in row and columns> Each row and column has fixed number of points.

rashesh
10-02-2009, 09:02 AM
thanks for reply link to rendered image on cylinder http://www.medico-supplies.com/Rendered%20Image.JPG

image to be wrapped
http://www.medico-supplies.com/imagewrapped.JPG

Gl.glGenTextures(1, out texName);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, texName);

Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_REPEAT);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_REPEAT);

Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR_MIPMAP_LINEAR);
Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, Gl.GL_RGBA, checkImageWidth, checkImageHeight, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE,checkImage);


Gl.glEnable(Gl.GL_TEXTURE_2D);

Gl.glTexEnvf(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_MODULATE);

Gl.glBegin(Gl.GL_QUADS);
Gl.glTexCoord2d((double)sl0/sliceCount,(double)pt0/pointCount);
Gl.glVertex3dv(ref this.coordinates[this.indices[i++], 0]);
....many points follow
Gl.glEnd();
Gl.glDisable(Gl.GL_TEXTURE_2D);

I have corrected it but doesnt make any difference. all points are arrange in row and columns> Each row and column has fixed number of points.

rashesh
10-02-2009, 10:23 AM
works now ...thanks a lot guys