Panda3D
Loading...
Searching...
No Matches
alphaTestAttrib.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 alphaTestAttrib.h
10 * @author drose
11 * @date 2002-03-04
12 */
13
14#ifndef ALPHATESTATTRIB_H
15#define ALPHATESTATTRIB_H
16
17#include "pandabase.h"
18#include "renderAttrib.h"
19
20class FactoryParams;
21
22/**
23 * Enables or disables writing of pixel to framebuffer based on its alpha
24 * value relative to a reference alpha value
25 */
26class EXPCL_PANDA_PGRAPH AlphaTestAttrib : public RenderAttrib {
27private:
28 INLINE AlphaTestAttrib(PandaCompareFunc mode = M_always,
29 PN_stdfloat reference_alpha = 1.0f);
30
31PUBLISHED:
32 static CPT(RenderAttrib) make(PandaCompareFunc mode,
33 PN_stdfloat reference_alpha);
34 static CPT(RenderAttrib) make_default();
35
36 INLINE PN_stdfloat get_reference_alpha() const;
37 INLINE PandaCompareFunc get_mode() const;
38
39PUBLISHED:
40 MAKE_PROPERTY(reference_alpha, get_reference_alpha);
41 MAKE_PROPERTY(mode, get_mode);
42
43public:
44 virtual void output(std::ostream &out) const;
45
46protected:
47 virtual int compare_to_impl(const RenderAttrib *other) const;
48 virtual size_t get_hash_impl() const;
49
50private:
51 PandaCompareFunc _mode;
52 PN_stdfloat _reference_alpha; // should be in range [0.0-1.0]
53
54PUBLISHED:
55 static int get_class_slot() {
56 return _attrib_slot;
57 }
58 virtual int get_slot() const {
59 return get_class_slot();
60 }
61 MAKE_PROPERTY(class_slot, get_class_slot);
62
63public:
64 static void register_with_read_factory();
65 virtual void write_datagram(BamWriter *manager, Datagram &dg);
66
67protected:
68 static TypedWritable *make_from_bam(const FactoryParams &params);
69 void fillin(DatagramIterator &scan, BamReader *manager);
70
71public:
72 static TypeHandle get_class_type() {
73 return _type_handle;
74 }
75 static void init_type() {
76 RenderAttrib::init_type();
77 register_type(_type_handle, "AlphaTestAttrib",
78 RenderAttrib::get_class_type());
79 _attrib_slot = register_slot(_type_handle, 100, new AlphaTestAttrib);
80 }
81 virtual TypeHandle get_type() const {
82 return get_class_type();
83 }
84 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
85
86private:
87 static TypeHandle _type_handle;
88 static int _attrib_slot;
89};
90
91#include "alphaTestAttrib.I"
92
93#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_reference_alpha
Returns the alpha reference value.
static ConstPointerTo< RenderAttrib > make(PandaCompareFunc mode, PN_stdfloat reference_alpha)
Constructs a new AlphaTestAttrib object.
get_mode
Returns the alpha write mode.
static ConstPointerTo< RenderAttrib > make_default()
Returns a RenderAttrib that corresponds to whatever the standard default properties for render attrib...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
static int register_slot(TypeHandle type_handle, int sort, RenderAttrib *default_attrib)
Adds the indicated TypeHandle to the registry, if it is not there already, and returns a unique slot ...
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(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.