zenilib: zenilib/jni/external/zenilib/zeni_graphics/Renderable.cpp Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Renderable.cpp
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2 * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3 *
4 * zenilib is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * zenilib is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <zeni_graphics.h>
19
20 #if defined(_DEBUG) && defined(_WINDOWS)
21 #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
22 #define new DEBUG_NEW
23 #endif
24
25 namespace Zeni {
26
27 Renderable::~Renderable() {
28 if(delete_m_material)
29 delete m_material;
30 }
31
32 void Renderable::give_Material(Material * const &material) {
33 if(delete_m_material)
34 delete m_material;
35 else
36 delete_m_material = true;
37
38 m_material = material;
39 }
40
41 void Renderable::lend_Material(const Material * const &material) {
42 if(delete_m_material) {
43 delete m_material;
44 delete_m_material = false;
45 }
46
47 m_material = const_cast< Material * const &>(material);
48 }
49
50 void Renderable::fax_Material(const Material * const &material) {
51 give_Material(material ?
52 new Material(*material) :
53 0);
54 }
55
56 void Renderable::pre_render() const {
57 if(m_material)
58 get_Video().set_Material(*m_material);
59 }
60
61 void Renderable::post_render() const {
62 if(m_material)
63 get_Video().unset_Material(*m_material);
64 }
65
66 }
Zeni::Video::set_Material
virtual void set_Material(const Material &material)=0
Set a Material.
Zeni::Renderable::post_render
virtual void post_render() const
Definition: Renderable.cpp:61
Zeni::Material
An Abstraction of a Material.
Definition: Material.h:56
Zeni::Video::unset_Material
virtual void unset_Material(const Material &material)=0
Unset a Material.
Zeni::Renderable::fax_Material
void fax_Material(const Material *const &material)
Set the Material, giving the Renderable a copy.
Definition: Renderable.cpp:50
Zeni::get_Video
Video & get_Video()
Get access to the singleton.
Definition: Video.cpp:149
Zeni::Renderable::pre_render
virtual void pre_render() const
Definition: Renderable.cpp:56
Zeni::Renderable::give_Material
void give_Material(Material *const &material)
Set the Material, giving the Renderable ownership.
Definition: Renderable.cpp:32
zeni_graphics.h
Zeni::Renderable::lend_Material
void lend_Material(const Material *const &material)
Set the Material, giving the Renderable no ownership.
Definition: Renderable.cpp:41
Zeni::Renderable::~Renderable
virtual ~Renderable()
Definition: Renderable.cpp:27