Jump to content
  • Advertisement
Sign in to follow this  
prux

OpenGL Texture deformation

This topic is 3973 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello there, now I want to create some good effects with textures. They are a kind of deformations. For example heres my example: this is a "magnifying glass" effect. Heres a picture about it: I have some idea to do this. I need a 2 dimensioned matrix what defines the points where the texture points should be are. Huh its hard enough. So, where its 0 it doesnt have any effect. So its easy the imagine the effect: screen[x,y]:= bitmap[matr[x,y].x, matr[x,y].y]; this matrix needs to be calculated: void tabfill(int d,int r)
{
  int x,y,z;
  for(x=-LENRAD;x<LENRAD;x++)
  for(y=-LENRAD;y<LENRAD;y++)
  {
    if (x*x+y*y=r*r) //bent van e a korben
    {
      z=sqrt(d*d-x*x-y*y+r*r)/3+1;
      transtab[x+LENRAD][y+LENRAD].x=(x*d)/(z+d)+LENRAD;
      transtab[x+LENRAD][y+LENRAD].y=(y*d)/(z+d)+LENRAD;
    }
    else //ha nincs, akkor marad
    {
      transtab[x+LENRAD][y+LENRAD].x=x+LENRAD;
      transtab[x+LENRAD][y+LENRAD].y=y+LENRAD;
    }
  }
} the effect itself: void len(int x, int y)
{
  int n,m;
  x-=LENRAD;
  y-=LENRAD;
  for(n=0;n<2*LENRAD;n++)
  for(m=0;m<2*LENRAD;m++)
  {
    if(x+n>0 && x+n<320 && y+m>0 && y+m<200)
    screen[x+n+(y+m)*320]=pic[x+transtab[n][m].x+           (y+transtab[n][m].y)*320];
  }
} but how to implements it with Direct3D? Always lock the texture or? Its quite expensive. Once I saw an effect with opengl...

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by prux
but how to implements it with Direct3D? Always lock the texture or? Its quite expensive. Once I saw an effect with opengl...


On modern hardware, implement it in a pixel shader. Use the source image as a texture, for each pixel sample from that texture applying an offset to the u and v coordinate.

Alternatively, on some (but not all) older fixed function hardware, particularly Matrox hardware there is support for EMBM. Take a look at the "Using Bump Mapping" topic in the SDK docs for more details on how to set that up.

Share this post


Link to post
Share on other sites
I found out that glTexCoord2fv and glVertex2fv the key. So this two set up where to draw the pixels to?

Share this post


Link to post
Share on other sites
Isnt there any way to set up where to draw the pixels at? Im not sure the shaders would be the sollution, that openGL example shown easy way - and this is from 1997! There must be a filter or...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!