glReadPixel GL_RGB,GL_UNSIGNED_BYTE storage format

  • Follow


Hi,

first sorry for my english, i'm a poor french litle programmer.

I'm currently make (or made) � HomeworldLike game and i'm just like to do
screen shot.

So i made this code :
 GLint view[4];
 glGetIntegerv(GL_VIEWPORT,view);

 unsigned char* t = new unsigned char
[(view[2]-view[0]+1)*(view[3]-view[1]+1)*4];
//i now size of 't' is not good
 glReadBuffer(GL_BACK);
 glPixelZoom(1.0f,1.0f);//we never know
 glReadPixels(0,0,view[2],view[3],GL_RGB,GL_UNSIGNED_BYTE, t);
 save_to_bmp(t,view[2],view[3]);
 delete[] t;


i'm currently sure that view[0]=view[1]=0
and sure that save_to_bmp is good (i hope so).

But when i save my screen i've � shift of 1,2,3 or 0 :) byte by line.

And i think that in the data the color are save like that :

RGBRGBRGB000
RGBRGBRGB000
RGBRGBRGB000...

how can i bee sure that the blue composent of the end pixel of a line is
directly follow(ed) by the red composent of the first pixel of the next line
?!?

Thanks,
Trident.


0
Reply astro.trident (1) 7/21/2004 6:24:03 PM

Trident wrote:
> i think that in the data the color are save like that :
> 
> RGBRGBRGB000
> RGBRGBRGB000
> RGBRGBRGB000...
> 

> how can i bee sure that the blue composent of the end pixel of a line is
> directly follow(ed) by the red composent of the first pixel of the next line
> ?!?


glPixelStorei(GL_PACK_ALIGNMENT, 0);




-- 
<\___/>
/ O O \
\_____/  FTB.    For email, remove my socks.

Governments, like diapers, should be changed often,
and for the same reason.
0
Reply fungus 7/21/2004 7:06:40 PM


So, glPixelStorei(GL_PACK_ALIGNMENT, 1); works realy good.


Thanks a milion.


0
Reply Trident 7/21/2004 7:39:24 PM

Trident wrote:
> So, glPixelStorei(GL_PACK_ALIGNMENT, 1); works realy good.
> 
> 

Um, yes. I meant "1"...


-- 
<\___/>
/ O O \
\_____/  FTB.    For email, remove my socks.

Governments, like diapers, should be changed often,
and for the same reason.
0
Reply fungus 7/21/2004 7:49:29 PM

3 Replies
481 Views

(page loaded in 0.105 seconds)

Similiar Articles:






7/24/2012 3:16:29 PM


Reply: