title: draw part of image with openGL glDrawPixels
body: <p>I have a function to draw an image in an <code>openGL</code> context. (used in that case to render to a texture) That works for the whole image, but should also be able to render only a rectangular part. Rendering parts works if the part has the same width as the image. For parts that are less wide than the image-data it fails.</p>
  
  <p>Here is the function (reduced to only the part for small width, no cleanup,etc)</p>
  
  <pre><code>void drawImage(uint32 imageWidth, uint32 imageHeight, uint8* pData, 
                 uint32 offX, uint32 partWidth)  // (offX+partWidth&lt;=imageWidth)
  {
      uint8* p(pData);
      if (partWidth != imageWidth)
      {
          glPixelStorei(GL_PACK_ROW_LENGTH, imageWidth);
          p = calcFrom(offX, pData); // point at pixel in row
      } 
      glDrawPixels(partWidth, ImageHeight, GL_BGRA, GL_UNSIGNED_BYTE, p);
  }
  </code></pre>
  
  <p>As said: <code>if (widthPart==imageWidth)</code> the rendering works fine. For some combinations of <code>partWidth</code> and <code>imageWidth</code> it works also but that seems to be a very special case, mainly width very small images and a some special <code>partWidths</code>.</p>
  
  <p>I found no examples for this, but from the docs I think this shold be possible to do somehow like that. Did I missunderstand the whole thing, or have I just overseen a small pit-fall??</p>
  
  <p>Thanks,
  Moritz</p>
  
  <p>P.S: it's running on windows<br>
  [Edited:] P.P.S: by now I have tried to do that as texture. If I replace  <code>glDrawPixels</code> with <code>glTexImage2D</code> I have the same problem...(could upload the whole image and render only part, but for small small parts of big pictures that might not e the best way...)</p>