I am trying to determine what would be the fastest method of performing a image buffer blit
- glDrawTexi0ES
- pbuffer
- Textured quad?
Sample code below
GLint cropRect[4] = { 0, 0, 400, 240};
int nWidth = 400;
int nHeight = 240;
void* buffer;
buffer = malloc (512 * 256 * (32 / 8 ));
memset (buffer, 128, nWidth * nHeight * (32 / 8 ));
glGenTextures( 1, &texture);
glBindTexture( GL_TEXTURE_2D, texture );
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, 512, 256, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, nWidth, nHeight, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
// Draws a triangle for 800 frames
for(int i = 0; i < 800; ++i)
{
int color;
color = rand() % 100 + 1;
memset (buffer, color, nWidth * nHeight * (32 / 8 ));
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, nWidth, nHeight, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
glViewport(0, 0, nWidth, nHeight);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glFlush();
glLoadIdentity();
glOrthox(0, nWidth, nHeight, 0, 0, 1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture);
glTexEnvx( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glTexParameterx( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameterx( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropRect);
glDrawTexiOES(0,0,0,nWidth, nHeight);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glFlush();
eglSwapBuffers(eglDisplay, eglSurface);
if (!TestEGLError("eglSwapBuffers"))
{
goto cleanup;
}
}
Thanks
Ryan