title: OpenGL ES draw camera preview, extra horizontal lines only for some image size
body: <p>I have RGB buffer that I draw on texture which placed to GLSurfaceView.
  The size of RGB image is the same as the size of GLSurfaceView.</p>
  
  <p>Image of size 1024x600 (16:9, full screen) is drawn correctly. But image of size 800x600 (4:3) is drawn with horizontal lines as <a href="https://stackoverflow.com/questions/4837928/opengl-es-texture-problem-4-duplicate-columns-and-horizontal-lines-android">here</a> but without additional columns.</p>
  
  <p>Here is the code how I draw images:
  <em>SurfaceView code</em></p>
  
  <pre><code>public void onSurfaceChanged(GL10 gl, int width, int height) {
      if(height == 0) {                       //Prevent A Divide By Zero By
          height = 1;                         //Making Height Equal One
      }
  
      currHalfWidth = width/2;
      currHalfHeight = height/2;
  
      cameraDist = (float)(currHalfHeight / Math.tan(Math.toRadians(45.0f / 2.0f)));
  
      gl.glViewport(0, 0, width, height);     //Reset The Current Viewport
      gl.glMatrixMode(GL10.GL_PROJECTION);    //Select The Projection Matrix
      gl.glLoadIdentity();                    //Reset The Projection Matrix
  
      //Calculate The Aspect Ratio Of The Window
      GLU.gluPerspective(gl, 45.0f, (float)width / (float)height, 0.1f, 2000.0f);
      //GLU.gluPerspective(gl, 0.0f, (float)width / (float)height, 0.1f, 100.0f);
  
      gl.glMatrixMode(GL10.GL_MODELVIEW);     //Select The Modelview Matrix
      gl.glLoadIdentity();                    //Reset The Modelview Matrix
  
      cameraPreview.setSurfaceSize(width, height);
  }
  </code></pre>
  
  <p><em>CameraPreview code</em></p>
  
  <pre><code>public void setSurfaceSize(int width, int height)
  {
      surfaceWidth = width;
      surfaceHeight = height;
      out = new byte[width*height*2];
  
      vertexBuffer.clear();
  
      vertices = new float[]{ 
              -height/2.0f, -width/2.0f, 0.0f, //Bottom Left
              height/2.0f, -width/2.0f, 0.0f,     //Bottom Right
              -height/2.0f, width/2.0f, 0.0f,     //Top Left
              height/2.0f, width/2.0f, 0.0f   //Top Right
                              };
      vertexBuffer.put(vertices);
      vertexBuffer.position(0);
  }
  
  public void draw(GL10 gl, byte[] yuv_data, Context context) {
  
      if(yuv_data != null &amp;&amp; context != null)
          this.loadGLTexture(gl, yuv_data, context);
  
  
      // bind the previously generated texture        
      gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);       
  
      // Point to our buffers
      gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
      gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
  
      // Set the face rotation
      gl.glFrontFace(GL10.GL_CW); 
  
      // Point to our vertex buffer
      gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
      gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer); 
  
      // Draw the vertices as triangle strip
      gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);        
  
      //Disable the client state before leaving
      gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
      gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
  }
  
  public void loadGLTexture(GL10 gl, byte[] yuv_data, Context context) {      
  
  
      Camera.Parameters params = MainScreen.getCameraParameters();
      int imageWidth = params.getPreviewSize().width;
      int imageHeight = params.getPreviewSize().height;           
  
      textureWidth = 512;
      textureHeight = 512;        
  
      NativeConverter.convertPreview(yuv_data, out, imageWidth, imageHeight, textureWidth, textureHeight);        
  
      //...and bind it to our array
      gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);  
  
      //Create Nearest Filtered Texture
      gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
      gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_NEAREST);
  
      //Different possible texture parameters, e.g. GL10.GL_CLAMP_TO_EDGE
      gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_REPEAT);
      gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_REPEAT);             
  
      gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGB, textureWidth, textureHeight, 0, GL10.GL_RGB, GL10.GL_UNSIGNED_BYTE, ByteBuffer.wrap(out));      
  }
  </code></pre>
  
  <p><strong>UPD</strong>: Problems solved! It wasn't openGL issue, but input 'yuv_data' buffer was already corrupted.</p>