Talk About Network

Google





Graphics > OpenGL 3D API > optimize interl...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 4749 of 5061
Post > Topic >>

optimize interleaced RGB texture

by "Clemens" <yycvm@[EMAIL PROTECTED] > May 14, 2008 at 03:53 PM

Hi,

I've tried to optimize the merge of seperate colors into a texture, but
it's
very much slower !!! : 4ms vs. 120ms for a 256*256 texture.

The idea is to copy r, g, b values into a frame buffer by using
glColorMask
and then copy to texture inside hardware

Does any body have a better idea ?

Clemens


void Frame::Way1()

{

int iLen = sizeof( r);

for( int i=0; i < iLen; ++i)

{

rgb[i][0] = r[i];

rgb[i][1] = g[i];

rgb[i][2] = b[i];

}

GLuint iTex = -1;

glGenTextures( 1, & iTex);

glBindTexture( GL_TEXTURE_2D, iTex);

glTexImage2D( GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE,
rgb);

glDeleteTextures( 1, & iTex);

}

void Frame::Way2()

{

glPushAttrib( GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT );

int iNumBuffer = -1;

glGetIntegerv( GL_DRAW_BUFFER, & iNumBuffer);

glDrawBuffer( GL_AUX0);

// Drawing onto buffer

glRasterPos2i( 0, 0);

glColorMask( 1, 0, 0, 1);

glDrawPixels( 256, 256, GL_RED, GL_UNSIGNED_BYTE, r);

glColorMask( 0, 1, 0, 0);

glDrawPixels( 256, 256, GL_GREEN, GL_UNSIGNED_BYTE, g);

glColorMask( 0, 0, 1, 1);

glDrawPixels( 256, 256, GL_BLUE, GL_UNSIGNED_BYTE, b);

glColorMask( 1, 1, 1, 1);

// retrieving into texture buffer

GLuint iTex = -1;

glGenTextures( 1, & iTex);

glBindTexture( GL_TEXTURE_2D, iTex);

glCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256);

glGetTexImage( GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, rgb_res);

glPopAttrib();

}
 




 4 Posts in Topic:
optimize interleaced RGB texture
"Clemens" <y  2008-05-14 15:53:59 
Re: optimize interleaced RGB texture
fungus <openglMYSOCKS@  2008-05-14 16:59:58 
Re: optimize interleaced RGB texture
"Clemens" <y  2008-05-15 17:51:34 
Re: optimize interleaced RGB texture
fungus <openglMYSOCKS@  2008-05-15 10:56:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 15:20:15 PST 2009.