[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Depth Screenshot
- To: PyOpenGL Users <pyopengl-users@xxxxxxxxxxxxxxxxxxxxx>, pygame-users@xxxxxxxx
- Subject: [pygame] Depth Screenshot
- From: Ian Mallett <geometrian@xxxxxxxxx>
- Date: Tue, 6 Oct 2009 19:43:34 -0700
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Tue, 06 Oct 2009 22:43:57 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:from:date:message-id :subject:to:content-type; bh=/gp0WLCZ98H3K+NyRF9JPyy3M9CINbqjrsr6OMkbS6s=; b=V4V+O/gsu6rHJ6kxUznQWg1v9Jcqz6UenMAKVz6DHaK0m69DMAHWXrVPIRNGcq7G3R 9L1R2LF34eMe6Q5rR4Ulbz/SxV5JkFAEZGCVQ9dfw/2Zbb3Nq1NrArjqnxp/gyKoTT3Z wyyDYYIeG9mOkXeLQJp+485UZsuJphs6i4lOw=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=NccI19aEaoNzWw7t5wP2SwL9pdjQM8/pWnsNoCcrVrVT+y/GfZdpyZu7M5QBQPbtUl PAMfQyKqLhlogrIxAlQRZbnEJW9LK/UCiyHDvM57Rt9THi9mQA9LKSbpHPuPRCs2UtjC r+NkK8UZj0wUW0j2OX9FjZCNtMTmEyJ3Wfluk=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Hello,
I'm trying to debug a weird FBO/depth problem, and it would be great to have screenshots of the depth. My current method does not work:
def ScreenSurf(rect=AUTO,type=RGB,framebuffer=0):
if rect == AUTO:
size = glGetFloatv(GL_VIEWPORT)
size = [int(round(size[2])),int(round(size[3]))]
rect = [0,0,size[0],size[1]]
glPixelStorei(GL_PACK_ROW_LENGTH,0)
glPixelStorei(GL_PACK_SKIP_ROWS,0)
glPixelStorei(GL_PACK_SKIP_PIXELS,0)
if type==RGBA:
glPixelStorei(GL_PACK_ALIGNMENT,4)
elif type==RGB:
glPixelStorei(GL_PACK_ALIGNMENT,1)
elif type==DEPTH:
glPixelStorei(GL_PACK_ALIGNMENT,2)
try:
data = "">
print len(data)
except:
previous = glGetIntegerv(GL_READ_BUFFER)
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT+framebuffer)
data = "">
glReadBuffer(previous)
if type==RGBA:
return pygame.image.fromstring(data,(rect[2],rect[3]),'RGBA',1)
elif type==RGB:
return pygame.image.fromstring(data,(rect[2],rect[3]),'RGB',1)
elif type==DEPTH:
#What goes here?
The surface that is returned is then saved (pygame.image.save()).
The issue is that in the case of depth, data is of length x*y. In the case of RGB color, it is 3*rect[2]*rect[3]. In the case of RGBA, it is 4*rect[2]*rect[3]. PyGame doesn't know how to convert it (there's no pygame.image.fromstring(data,size,'R',1), for instance). What's a decent way to save the depth as an image?
Thanks,
Ian