Panda3D
sourceTextureImage.h
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 sourceTextureImage.h
10 * @author drose
11 * @date 2000-11-28
12 */
13
14#ifndef SOURCETEXTUREIMAGE_H
15#define SOURCETEXTUREIMAGE_H
16
17#include "pandatoolbase.h"
18
19#include "imageFile.h"
20
21class TextureImage;
22class PNMImageHeader;
23
24/**
25 * This is a texture image reference as it appears in an egg file: the source
26 * image of the texture.
27 */
29private:
31
32public:
33 SourceTextureImage(TextureImage *texture, const Filename &filename,
34 const Filename &alpha_filename, int alpha_file_channel);
35
37
39 int get_egg_count() const;
40
41 bool get_size();
42 bool read_header();
43 void set_header(const PNMImageHeader &header);
44
45private:
46 TextureImage *_texture;
47 int _egg_count;
48 bool _read_header;
49 bool _successfully_read_header;
50
51 // The TypedWritable interface follows.
52public:
53 static void register_with_read_factory();
54 virtual void write_datagram(BamWriter *writer, Datagram &datagram);
55 virtual int complete_pointers(TypedWritable **p_list,
56 BamReader *manager);
57
58protected:
59 static TypedWritable *make_SourceTextureImage(const FactoryParams &params);
60 void fillin(DatagramIterator &scan, BamReader *manager);
61
62public:
63 static TypeHandle get_class_type() {
64 return _type_handle;
65 }
66 static void init_type() {
67 ImageFile::init_type();
68 register_type(_type_handle, "SourceTextureImage",
69 ImageFile::get_class_type());
70 }
71 virtual TypeHandle get_type() const {
72 return get_class_type();
73 }
74
75private:
76 static TypeHandle _type_handle;
77};
78
79INLINE std::ostream &
80operator << (std::ostream &out, const SourceTextureImage &source) {
81 source.output_filename(out);
82 return out;
83}
84
85#endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
This is the base class of both TextureImage and PaletteImage.
Definition: imageFile.h:33
void output_filename(std::ostream &out) const
Writes the filename (or pair of filenames) to the indicated output stream.
Definition: imageFile.cxx:424
This is the base class of PNMImage, PNMReader, and PNMWriter.
This is a texture image reference as it appears in an egg file: the source image of the texture.
bool get_size()
Determines the size of the SourceTextureImage, if it is not already known.
virtual void write_datagram(BamWriter *writer, Datagram &datagram)
Fills the indicated datagram up with a binary representation of the current object,...
static void register_with_read_factory()
Registers the current object as something that can be read from a Bam file.
bool read_header()
Reads the actual image header to determine the image properties, like its size.
void increment_egg_count()
Increments by one the number of egg files that are known to reference this SourceTextureImage.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Called after the object is otherwise completely read from a Bam file, this function's job is to store...
TextureImage * get_texture() const
Returns the particular texture that this image is one of the sources for.
void set_header(const PNMImageHeader &header)
Sets the header information associated with this image, as if it were loaded from the disk.
int get_egg_count() const
Returns the number of egg files that share this SourceTextureImage.
This represents a single source texture that is referenced by one or more egg files.
Definition: textureImage.h:46
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22