Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. void OGL_Renderer::drawImageToImage(Image& source, const Rectangle_2d& srcRect, Image& destination, const Point_2d& dstPoint)
  2. {
  3.     Image subImage(&source, srcRect.x, srcRect.y, srcRect.w, srcRect.h);
  4.    
  5.     glEnable(mTextureTarget);
  6.     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  7.    
  8.     glBindTexture(mTextureTarget, getTextureId(destination));
  9.    
  10.     glTexParameteri(mTextureTarget, GL_TEXTURE_MIN_FILTER, TEXTURE_FILTER);
  11.     glTexParameteri(mTextureTarget, GL_TEXTURE_MAG_FILTER, TEXTURE_FILTER);
  12.    
  13.     Rectangle_2d clipRect;
  14.    
  15.     (dstPoint.x + srcRect.w) > destination.getWidth() ? clipRect.w = srcRect.w - ((dstPoint.x + srcRect.w) - destination.getWidth()) : clipRect.w = srcRect.w;
  16.     (dstPoint.y + srcRect.h) > destination.getHeight() ? clipRect.h = srcRect.h - ((dstPoint.y + srcRect.h) - destination.getHeight()) : clipRect.h = srcRect.h;
  17.  
  18.     glTexSubImage2D(mTextureTarget, 0, dstPoint.x, dstPoint.y, clipRect.w, clipRect.h, getTextureFormat(subImage.getPixels()), GL_UNSIGNED_BYTE, subImage.getPixels()->pixels);
  19.  
  20.     glDisable(mTextureTarget);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement