🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.graphics.api.opengl
Article #33

How to make a scrrenshot

#33
From: Prof
Date: Thu, 06 Jan 2000 00:00
41 lines
1760 bytes
Hi.

I'm trying to make a screenshot of the framebuffer content and write it to a
.tga file.

Something is going wrong, because the screenshot is distorted.

Here is what I'm doing:
- To read the framebuffer :
    // w = viewport width
    // h = viewport height
    // buffer is of size 3*w*h
     glReadPixels (0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, buffer);

- To write the .tga file:
    1. writing the 18 header bytes:
    //   header[0] = 0;
    //     ....
    //   header[2] = 2;
    //     ....
    //   header[12] = w&255;
    //   header[13] = w>>8;
    //   header[14] = h&255;
    //   header[15] = h>>8;
    //   header[16] = 24;
    //   header[17] = 0;

    2. And then writing the framebuffer content in BGR format
     // before we write we are converting the framebuffer content
     for (i = 0; i < (w*h* 3); i += 3)
     {
          temp = buff[i];
          buff[i] = buff[i + 2];
          buff[i + 2] = temp;
     }

Does anybody know what's wrong here, or can you point me to some samples,
information, etc.

Thanks.
-- Markus
Technical Details
Message-ID: <851jd0$rl$1@newsread.f.de.uu.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 100291,2ad16ac8f9e3514d,start
X-Google-Attributes: gid100291,public
X-Google-Thread: f65bb,2ad16ac8f9e3514d,start
X-Google-Attributes: gidf65bb,public
From: "Prof" <nuebelm@yahoo.com>
Subject: How to make a scrrenshot
Date: 2000/01/06
Message-ID: <851jd0$rl$1@newsread.f.de.uu.net>
X-Deja-AN: 569008589
X-Priority: 3
X-Mimeole: Produced By Microsoft MimeOLE V5.00.2314.1300
X-Complaints-To: abuse@de.uu.net
Organization: Customer of UUNET Deutschland GmbH, Dortmund, Germany
X-MSMail-Priority: Normal
NNTP-Posting-Date: 6 Jan 2000 08:22:56 GMT
Newsgroups: comp.graphics.api.opengl,3dfx.opengl