I have problem with getting my screenshot function to work.
The screenshot I should get is: http://lapas.dau.lv/salitis/1.bmp
But instead I receive: http://lapas.dau.lv/salitis/2.bmp
First shot is taken via PrtScr, second via function posted below.
I’ve checked file output routine with regular (selfmade) arrays & it worked as it should. Firsty I noticed that problem arrised when there were pixels affected by Cg vp/fp on screen, but now it seems that it’s allways apparent. Walls are drawn with bumpmap shader applied.
Maybe problem is with glReadPixels, as I noticed that some people uses w+1 and h+1 to get data, but after experimenting with these values nothing changed. I have no idea what could be wrong
The function I use to make screenshot:
Thanks, but I don’t actually understand why… Even more 60% of image is outputted correctly. And BMP is is based on bytes, so that every pixel consists of 3 bytes, not 2 or 1/2 byte (GL_RGB8 -> 8bits per color chanel intensity of pixel). BTW, texture reading function without binary is working OK. I’m confused…
EDIT:
I noticed your comment about pack aligment in other thread, but if that’s the problem, how ios::binary can solve it?
Hmm, strange I added glPixelStores, and nothing changed, added ios::binary & everything is OK, why thats so? What’s the difference between ios::binary and ordinary, I’m writing chars anyway :?
Originally posted by M/\dm/
: Hmm, strange I added glPixelStores, and nothing changed, added ios::binary & everything is OK, why thats so? What’s the difference between ios::binary and ordinary, I’m writing chars anyway :?
Windows massages line feeds. If you write the string "
" to a file, it will get converted to two bytes, a line feed and a carriage return character. This is only useful for text files - if it can be considered useful at all -, which is the assumed default when opening any file. There’s a statistical 1 in 256 chance that a byte in your binary data happens to be
. That’s the cause of your problems, and that’s why you need to specify ios::binary. It will turn these line feed transformations off.
PS: AFAIK this doesn’t apply to *nix, only to Windows (and DOS).
[This message has been edited by zeckensack (edited 02-04-2004).]