Public Member Functions

GBufWriter Class Reference

This reference page is linked to from the following overview topics: RPF Files and the G-Buffer.


Search for all occurrences

Detailed Description

See also:
Class GBuffer, Class GBufReader, Structure GBufData, G-Buffer Channel Indices.

Description:
This class is available in release 3.0 and later only.

This is the writer object returned from GBuffer::CreateWriter(). This class assumes pixels are created in increasing order of x.

Here is an example of writing multiple layer data to the G-Buffer using methods of this class.

GBuffer *gb = NewDefaultGBuffer();
gb->SetRasterSize(100,10);
gb->CreateChannels((1<<GB_Z)|(1<<GB_MTL_ID)|(1<<GB_BG));
gb->InitBuffer();

GBufWriter *wrt = gb->CreateWriter();
for (int y=0; y<10; y++)
{
    wrt->StartLine(y);
    BOOL bb = 0;
    for (int x=5; x<100; x+=4) {
        wrt->StartPixel(x);
        wrt->StartNextLayer();
        float z = 5.0f*float(x)*float(y);
        wrt->WriteChannelData(GB_Z,(void *)&z);
        UBYTE mid = 36+x;
        wrt->WriteChannelData(GB_MTL_ID,(void *)&mid);
        Color24 c;
        c.r = 10+x; c.g = 20+x; c.b = 30+x;
        wrt->WriteChannelData(GB_BG,(void *)&c);

        wrt->StartNextLayer();
        z = 15.0f*float(x)*float(y);
        wrt->WriteChannelData(GB_Z,(void *)&z);
        mid = 26+x;
        wrt->WriteChannelData(GB_MTL_ID,(void *)&mid);
        c.r =30+x; c.g = 20+x; c.b = 10+x;
        wrt->WriteChannelData(GB_BG,(void *)&c);

        if (bb) {
            wrt->StartNextLayer();
            z = 17.0f*float(x)*float(y);
            wrt->WriteChannelData(GB_Z,(void *)&z);
            mid = 64+x;
            wrt->WriteChannelData(GB_MTL_ID,(void
                *)&mid);
            c.r = 130+x; c.g = 120+x; c.b = 110+x;
            wrt->WriteChannelData(GB_BG,(void *)&c);
        }
        bb = !bb;
    }
    wrt->EndLine();
}
gb->DestroyWriter(wrt);
All methods of this class are implemented by the System.

#include <gbuf.h>

Inheritance diagram for GBufWriter:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual void  StartLine (int y)=0
virtual void  StartPixel (int x)=0
virtual void  StartNextLayer ()=0
virtual BOOL  WriteChannelData (int chan, void *data)=0
virtual BOOL  WriteAllData (GBufData *data)=0
virtual BOOL  EndLine ()=0
virtual void  DeleteThis ()=0
virtual INT_PTR  Execute (int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0)

Member Function Documentation

virtual void StartLine ( int  y ) [pure virtual]
Remarks:
This method should be called before writing every line.
Parameters:
int y

The zero based index of the scan line to start.
virtual void StartPixel ( int  x ) [pure virtual]
Remarks:
This method must be called before writing each pixel and must be called with increasing x values on a line.
Parameters:
int x

The zero based index of the pixel to start.
virtual void StartNextLayer ( ) [pure virtual]
Remarks:
This method must be called before writing the first layer.
virtual BOOL WriteChannelData ( int  chan,
void *  data 
) [pure virtual]
Remarks:
Call this method to write a data element to the specified channel of the G-Buffer to the current scan line and pixel.
Parameters:
int chan

See G-Buffer Channel Indices.

void *data

Points to the G-Buffer data to write.
Returns:
TRUE on success; FALSE on failure.
virtual BOOL WriteAllData ( GBufData data ) [pure virtual]
Remarks:
This method writes all the channel data from the GBufData structure passed to the current scan line and pixel.
Parameters:
GBufData *data

Points to the G-Buffer data to write. See Structure GBufData.
Returns:
TRUE on success; FALSE on failure.
virtual BOOL EndLine ( ) [pure virtual]
Remarks:
This method should be called after writing each line.
Returns:
TRUE on success; FALSE on failure.
virtual void DeleteThis ( ) [pure virtual]
Remarks:
Deletes this writer object. Call this method when finished using it.
virtual INT_PTR Execute ( int  cmd,
ULONG_PTR  arg1 = 0,
ULONG_PTR  arg2 = 0,
ULONG_PTR  arg3 = 0 
) [inline, virtual]

GBufWriter GBufWriter GBufWriter GBufWriter GBufWriter GBufWriter GBufWriter GBufWriter GBufWriter GBufWriter
GBufWriter GBufWriter GBufWriter GBufWriter GBufWriter GBufWriter GBufWriter GBufWriter GBufWriter GBufWriter