Panda3D
fltPackedColor.cxx
1 // Filename: fltPackedColor.cxx
2 // Created by: drose (25Aug00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "fltPackedColor.h"
16 #include "fltRecordReader.h"
17 #include "fltRecordWriter.h"
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function: FltPackedColor::output
21 // Access: Public
22 // Description:
23 ////////////////////////////////////////////////////////////////////
24 void FltPackedColor::
25 output(ostream &out) const {
26  out << "(" << _r << " " << _g << " " << _b << " " << _a << ")";
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: FltPackedColor::extract_record
31 // Access: Public
32 // Description:
33 ////////////////////////////////////////////////////////////////////
34 bool FltPackedColor::
35 extract_record(FltRecordReader &reader) {
36  DatagramIterator &iterator = reader.get_iterator();
37 
38  _a = iterator.get_uint8();
39  _b = iterator.get_uint8();
40  _g = iterator.get_uint8();
41  _r = iterator.get_uint8();
42 
43  return true;
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: FltPackedColor::build_record
48 // Access: Public
49 // Description:
50 ////////////////////////////////////////////////////////////////////
51 bool FltPackedColor::
52 build_record(FltRecordWriter &writer) const {
53  Datagram &datagram = writer.update_datagram();
54 
55  datagram.add_uint8(_a);
56  datagram.add_uint8(_b);
57  datagram.add_uint8(_g);
58  datagram.add_uint8(_r);
59 
60  return true;
61 }
void add_uint8(PN_uint8 value)
Adds an unsigned 8-bit integer to the datagram.
Definition: datagram.I:138
This class writes a sequence of FltRecords to an ostream, handling opcode and size counts properly...
This class turns an istream into a sequence of FltRecords by reading a sequence of Datagrams and extr...
DatagramIterator & get_iterator()
Returns an iterator suitable for extracting data from the current record.
PN_uint8 get_uint8()
Extracts an unsigned 8-bit integer.
A class to retrieve the individual data elements previously stored in a Datagram. ...
Datagram & update_datagram()
Returns a modifiable reference to the datagram associated with the current record.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43