Panda3D
fltPackedColor.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file fltPackedColor.cxx
10  * @author drose
11  * @date 2000-08-25
12  */
13 
14 #include "fltPackedColor.h"
15 #include "fltRecordReader.h"
16 #include "fltRecordWriter.h"
17 
18 /**
19  *
20  */
21 void FltPackedColor::
22 output(std::ostream &out) const {
23  out << "(" << _r << " " << _g << " " << _b << " " << _a << ")";
24 }
25 
26 /**
27  *
28  */
29 bool FltPackedColor::
30 extract_record(FltRecordReader &reader) {
31  DatagramIterator &iterator = reader.get_iterator();
32 
33  _a = iterator.get_uint8();
34  _b = iterator.get_uint8();
35  _g = iterator.get_uint8();
36  _r = iterator.get_uint8();
37 
38  return true;
39 }
40 
41 /**
42  *
43  */
44 bool FltPackedColor::
45 build_record(FltRecordWriter &writer) const {
46  Datagram &datagram = writer.update_datagram();
47 
48  datagram.add_uint8(_a);
49  datagram.add_uint8(_b);
50  datagram.add_uint8(_g);
51  datagram.add_uint8(_r);
52 
53  return true;
54 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
uint8_t get_uint8()
Extracts an unsigned 8-bit integer.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
DatagramIterator & get_iterator()
Returns an iterator suitable for extracting data from the current record.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_uint8(uint8_t value)
Adds an unsigned 8-bit integer to the datagram.
Definition: datagram.I:50
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:38