Joined: Feb 2009
RE: Image Processing Algorithms
Heheheh, ran into a interesting optimization problem.....
//RGB-888, 32 bits
int bufsize = window_width * window_height * 4;
int pitch = window_width*4;
unsigned char* ImageBuffer = (unsigned char*)malloc(bufsize);
glReadPixels ( 0, 0, window_width, window_height, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)ImageBuffer);
//do 2xSai/HQ2X/bloom/whatever on ImageBuffer
glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexImage2D( GL_TEXTURE_2D, 0, 3, window_width, window_height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, ImageBuffer);
glVertex3f(-1.0f, -1.0f, 1.0f);
glVertex3f( 1.0f, -1.0f, 1.0f);
glVertex3f( 1.0f, 1.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, 1.0f);
I know, unoptimized.
As I said, I worked out a way.
Render the scene into a 512*512 viewport, then copy the texture. However, for some odd reason, I do not know, the texture in the rendered scene is off centre, by exactly half (only half the image is displayed). Any help with the usage of glViewport and the tex coords would be great. Unfortunately, I lost the code in the past thats perfect for scaling textures according to aspect ratio, viewport size and texture size.