I'm having a real problem with my code. I'm working on rewriting gx to use opengl es. My setup for the graphics portion are as follows:
1. 1 texture which simulates the screen buffer
2. 2 arrays of unsigned short to hold the current screen buffer & the previous screen buffer

Well, it all works fine when I'm updating the entire screen ( when the current screen buffer is different from the old screen buffer from 0,0-max width,max height ) because I subteximage2d the screen buffer to the texture.

The angling occurs when I use the old screen buffer to hold the changed screen area and subteximage2d that buffer to the texture.

I guess I'm just asking anyone if I'm missing something blatantly obvious... I've gone through this for a couple of days now & I may just be overlooking something.

Note: glesClipRect is a RECT where top and left are "normal", while bottom is the height of the clip rect.

Code :
int GXEndDraw() {
	char szText[255];
 
	frame++;
 
	gxLog("GXEndDraw:\n");
	// glBindTexture(GL_TEXTURE_2D,glesTex);
 
	unsigned long curTime = GetTickCount() - firstTime;
 
	if ( ( curTime - m_lastTime ) > 1000 ) {
		sprintf(szText,"GXEndDraw: FPS: %d\n",frame);
		gxLog(szText);
		m_lastTime = curTime;
		frame = 0;
	}
	glClear(GL_COLOR_BUFFER_BIT);
 
	// create a simple mark to show we are using ngx
	for ( int y=0;y<25;y++) {
		for ( int x=0;x<25;x++) {
			GXSetPixel(x,y,x,y,x);
		}
	}	
 
	RECT r;
	int x,y;
 
	GLushort * glnew;
	GLushort * glold;
	int lineheight = m_curProp.cbxPitch*m_curProp.cxWidth;
	r.left = lineheight;
	r.top = m_curProp.cyHeight;
	r.bottom = 0;
	r.right = 0;
	int width,height;
 
	if ( memcmp(glesPixels,glesOldPixels,nBufsize)) {
		// scene has changed
		int bot = glesClipRect.top + glesClipRect.bottom;
		if ( bot > m_curProp.cyHeight ) {
			bot = m_curProp.cyHeight;
		}
		for(y=glesClipRect.top;y<bot;y++) {
			for(x=0;x<m_curProp.cxWidth;x++) {
				glnew = (GLushort*)(glesPixels+(y*lineheight+x*m_curProp.cbxPitch));
				glold = (GLushort*)(glesOldPixels+(y*lineheight+x*m_curProp.cbxPitch));
				if ( *glnew != *glold ) {
					if ( y < r.top ) {
						r.top = y;
					} else if ( y > r.bottom ) {
						r.bottom = y;
					}
					if ( x < r.left ) {
						r.left = x;
					} else if ( x > r.right ) {
						r.right = x;
					}
				}
			}
		}
 
		if (( r.left <= glesClipRect.left ) &&
			( r.top <= glesClipRect.top ) &&
			( r.right >= m_curProp.cxWidth ) &&
			( r.bottom >= ( glesClipRect.bottom - glesClipRect.top ))) {
			// blit the whole screen
			glTexSubImage2D(
				GL_TEXTURE_2D,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
				0,
				0,
				glesClipRect.top,
				m_curProp.cxWidth,
				glesClipRect.bottom,
				GL_RGB,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
				GL_UNSIGNED_SHORT_5_6_5,
				glesPixels
			);
		} else {
			// blit only the changed parts
			if ( r.left > 0 ) {
				r.left--;
			};
			if ( r.right < m_curProp.cxWidth ) {
				r.right++;
			}
			if ( r.top > 0 ) {
				r.top--;
			}
			if ( r.bottom < m_curProp.cyHeight ) {
				r.bottom++;
			}
			sprintf(szText,"GXEndDraw: cliprect (%d,%d)-(%d,%d)\n",
				r.left,
				r.top,
				r.right,
				r.bottom);
			gxLog(szText);
 
			width = r.right - r.left +1;
			height = r.bottom - r.top +1;
 
			//	copy changed area into temp pixel store
			for(y=r.top;y<=r.bottom;y++) {
				if ( width < 20 && height < 20 ) {
					sprintf(szText,"[W:%03d|H:%03d|O:%03d|P:%03d]\n",
						width,
						height,
						(y-r.top),
						y);
					gxLog(szText);
				}
				for(x=r.left;x<=r.right;x++) {
					glnew = (GLushort*)(glesPixels+
						(y*lineheight+
						x*m_curProp.cbxPitch));
					glold = (GLushort*)(glesOldPixels+
						((y-r.top)*width*m_curProp.cbxPitch+
						(x-r.left)*m_curProp.cbxPitch));
					*glold = *glnew;
					if ( width < 20 && height < 20 ) {
						sprintf(szText,"[%03d|%03d|%04x]",
							(x-r.left),
							x,
							*glold);
						gxLog(szText);
					}
				}
				if ( width < 20 && height < 20 ) {
					gxLog("\n");
				}
			}
			// blit changed zone
			glTexSubImage2D(
				GL_TEXTURE_2D,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
				0,
				r.left,
				r.top,
				width,
				height,
				GL_RGB,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
				GL_UNSIGNED_SHORT_5_6_5,
				glesOldPixels
			);
		}
	} else {
		/* 
		do nothing since scene has not changed
		*/	
	}
	GLuint error;
 
	error = glGetError();
	if ( error > 0 ) {
		wsprintf((LPTSTR)szText,L"Last Error: %x",error);
//		MessageBox(NULL,(LPCTSTR)szText,L"Error",MB_OK|MB_ICONERROR);
		SetLastError(error);
		return 0;
	}
 
	glDrawTexiOES(0,0,1,m_curProp.cxWidth,m_curProp.cyHeight);
 
	eglSwapBuffers(glesDisplay, glesSurface);
 
	return 1;
	// return gxEndDraw();			  
};