| TGX 1.1.3 A tiny 2D/3D graphics library optimized for 32 bits microcontrollers.

Loading...
Searching...
No Matches
Renderer3DFlash.h
Go to the documentation of this file.
1
6//
7// Copyright 2020 Arvind Singh
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Lesser General Public
11// License as published by the Free Software Foundation; either
12//version 2.1 of the License, or (at your option) any later version.
13//
14// This library is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU
17// Lesser General Public License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; If not, see <http://www.gnu.org/licenses/>.
21
22#ifndef _TGX_RENDERER3D_FLASH_H_
23#define _TGX_RENDERER3D_FLASH_H_
24
25#include "tgx_config.h"
26
27
28#ifdef __cplusplus
29
30#if defined(TGX_RUN_ON_TEENSY4) && defined(TEENSYDUINO)
31
32 namespace tgx
33{
34 namespace Renderer3D_detail
35{
36
37 template<typename T> struct RemoveReference { typedef T type; };
38 template<typename T> struct RemoveReference<T&> { typedef T type; };
39 template<typename T> struct RemoveReference<T&&> { typedef T type; };
40
41 template<typename T> struct Renderer3DFlashTraits;
42
43 template<typename color_t, Shader LOADED_SHADERS, typename ZBUFFER_t, int MAX_DIRECTIONAL_LIGHTS, int MAX_SPOT_LIGHTS>
44 struct Renderer3DFlashTraits<Renderer3D<color_t, LOADED_SHADERS, ZBUFFER_t, MAX_DIRECTIONAL_LIGHTS, MAX_SPOT_LIGHTS> >
45 {
46 typedef color_t color_type;
47 };
48
49}
50}
51
52 #define TGX_RENDERER3D_FLASH_SECTION(NAME) __attribute__((section(".flashmem.tgx.renderer3d." NAME)))
53
54 #define TGX_RENDERER3D_FLASH_CAT_(A, B) A##B
55 #define TGX_RENDERER3D_FLASH_CAT(A, B) TGX_RENDERER3D_FLASH_CAT_(A, B)
56
63 #define TGX_RENDERER3D_FLASH_SPHERE_CORE_PATH(RENDERER3D_OBJECT) \
64 TGX_RENDERER3D_FLASH_SPHERE_CORE_PATH_(RENDERER3D_OBJECT, TGX_RENDERER3D_FLASH_CAT(_tgx_renderer3d_flash_sphere_, __LINE__))
65
66 #define TGX_RENDERER3D_FLASH_SPHERE_CORE_PATH_(RENDERER3D_OBJECT, RENDERER_T) \
67 namespace tgx { \
68 typedef typename ::tgx::Renderer3D_detail::RemoveReference<decltype(RENDERER3D_OBJECT)>::type RENDERER_T; \
69 typedef typename ::tgx::Renderer3D_detail::Renderer3DFlashTraits<RENDERER_T>::color_type TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t); \
70 template TGX_RENDERER3D_FLASH_SECTION("sphere") void RENDERER_T::drawSphere(int, int); \
71 template TGX_RENDERER3D_FLASH_SECTION("sphere") void RENDERER_T::drawSphere(int, int, const Image<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*); \
72 template TGX_RENDERER3D_FLASH_SECTION("sphere") void RENDERER_T::drawAdaptativeSphere(float); \
73 template TGX_RENDERER3D_FLASH_SECTION("sphere") void RENDERER_T::drawAdaptativeSphere(const Image<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*, float); \
74 template TGX_RENDERER3D_FLASH_SECTION("sphere") void RENDERER_T::_drawSphere<false, Renderer3D_detail::WIREFRAME_FAST>(int, int, const Image<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*, float, TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t), float); \
75 }
76
77 #if TGX_DRAWSPHERE_USE_STRIP_BANDS
78 #define TGX_RENDERER3D_FLASH_SPHERE_STRIP_PATH(RENDERER3D_OBJECT) \
79 TGX_RENDERER3D_FLASH_SPHERE_STRIP_PATH_(RENDERER3D_OBJECT, TGX_RENDERER3D_FLASH_CAT(_tgx_renderer3d_flash_sphere_strip_, __LINE__))
80
81 #define TGX_RENDERER3D_FLASH_SPHERE_STRIP_PATH_(RENDERER3D_OBJECT, RENDERER_T) \
82 namespace tgx { \
83 typedef typename ::tgx::Renderer3D_detail::RemoveReference<decltype(RENDERER3D_OBJECT)>::type RENDERER_T; \
84 template TGX_RENDERER3D_FLASH_SECTION("sphere") void RENDERER_T::_drawSphereGouraudStripBand(const int, int, const float*, const float*, float, float, float, float, float, float, float, float, bool); \
85 template TGX_RENDERER3D_FLASH_SECTION("sphere") void RENDERER_T::_drawSphereGouraudCap(const int, int, bool, const float*, const float*, float, float, float, float, float, bool); \
86 }
87
88 #define TGX_PLACE_RENDERER3D_SPHERE_PATH_IN_FLASH(RENDERER3D_OBJECT) \
89 TGX_RENDERER3D_FLASH_SPHERE_CORE_PATH(RENDERER3D_OBJECT) \
90 TGX_RENDERER3D_FLASH_SPHERE_STRIP_PATH(RENDERER3D_OBJECT)
91 #else
92 #define TGX_PLACE_RENDERER3D_SPHERE_PATH_IN_FLASH(RENDERER3D_OBJECT) \
93 TGX_RENDERER3D_FLASH_SPHERE_CORE_PATH(RENDERER3D_OBJECT)
94 #endif
95
104 #define TGX_PLACE_RENDERER3D_TRUNCATED_CONE_PATH_IN_FLASH(RENDERER3D_OBJECT) \
105 TGX_PLACE_RENDERER3D_TRUNCATED_CONE_PATH_IN_FLASH_(RENDERER3D_OBJECT, TGX_RENDERER3D_FLASH_CAT(_tgx_renderer3d_flash_cone_, __LINE__))
106
107 #define TGX_PLACE_RENDERER3D_TRUNCATED_CONE_PATH_IN_FLASH_(RENDERER3D_OBJECT, RENDERER_T) \
108 namespace tgx { \
109 typedef typename ::tgx::Renderer3D_detail::RemoveReference<decltype(RENDERER3D_OBJECT)>::type RENDERER_T; \
110 typedef typename ::tgx::Renderer3D_detail::Renderer3DFlashTraits<RENDERER_T>::color_type TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t); \
111 template TGX_RENDERER3D_FLASH_SECTION("truncatedcone") void RENDERER_T::drawCylinder(int, bool, bool); \
112 template TGX_RENDERER3D_FLASH_SECTION("truncatedcone") void RENDERER_T::drawCylinder(int, const Image<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*, const Image<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*, const Image<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*, bool, bool); \
113 template TGX_RENDERER3D_FLASH_SECTION("truncatedcone") void RENDERER_T::drawCone(int, bool); \
114 template TGX_RENDERER3D_FLASH_SECTION("truncatedcone") void RENDERER_T::drawCone(int, const Image<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*, const Image<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*, bool); \
115 template TGX_RENDERER3D_FLASH_SECTION("truncatedcone") void RENDERER_T::drawTruncatedCone(int, float, float, bool, bool); \
116 template TGX_RENDERER3D_FLASH_SECTION("truncatedcone") void RENDERER_T::drawTruncatedCone(int, float, float, const Image<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*, const Image<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*, const Image<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*, bool, bool); \
117 template TGX_RENDERER3D_FLASH_SECTION("truncatedcone") void RENDERER_T::_drawTruncatedCone(int, float, float, const Image<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*, const Image<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*, const Image<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*, bool, bool); \
118 template TGX_RENDERER3D_FLASH_SECTION("truncatedcone") void RENDERER_T::_drawTruncatedConeGouraudCachedTriangle(const int, typename RENDERER_T::ExtVec4&, fVec3&, typename RENDERER_T::ExtVec4&, fVec3&, typename RENDERER_T::ExtVec4&, fVec3&, bool, bool, float, bool); \
119 template TGX_RENDERER3D_FLASH_SECTION("truncatedcone") void RENDERER_T::_drawTruncatedConeGouraudSideStrip(const int, int, float, float, const float*, const float*, float, float, float, float, bool); \
120 template TGX_RENDERER3D_FLASH_SECTION("truncatedcone") void RENDERER_T::_drawTruncatedConeGouraudConeFan(const int, int, bool, float, const float*, const float*, float, float, float, float, bool); \
121 template TGX_RENDERER3D_FLASH_SECTION("truncatedcone") void RENDERER_T::_drawTruncatedConeGouraudCapFan(const int, int, bool, float, const float*, const float*, float, bool); \
122 }
123
131 #define TGX_PLACE_RENDERER3D_MESH3D_PATH_IN_FLASH(RENDERER3D_OBJECT) \
132 TGX_PLACE_RENDERER3D_MESH3D_PATH_IN_FLASH_(RENDERER3D_OBJECT, TGX_RENDERER3D_FLASH_CAT(_tgx_renderer3d_flash_mesh3d_, __LINE__))
133
134 #define TGX_PLACE_RENDERER3D_MESH3D_PATH_IN_FLASH_(RENDERER3D_OBJECT, RENDERER_T) \
135 namespace tgx { \
136 typedef typename ::tgx::Renderer3D_detail::RemoveReference<decltype(RENDERER3D_OBJECT)>::type RENDERER_T; \
137 typedef typename ::tgx::Renderer3D_detail::Renderer3DFlashTraits<RENDERER_T>::color_type TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t); \
138 template TGX_RENDERER3D_FLASH_SECTION("mesh3d") void RENDERER_T::drawMesh(const Mesh3D<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*, bool, bool); \
139 template TGX_RENDERER3D_FLASH_SECTION("mesh3d") void RENDERER_T::_drawMesh(const int, const Mesh3D<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*); \
140 }
141
150 #define TGX_PLACE_RENDERER3D_MESH3DV2_PATH_IN_FLASH(RENDERER3D_OBJECT) \
151 TGX_PLACE_RENDERER3D_MESH3DV2_PATH_IN_FLASH_(RENDERER3D_OBJECT, TGX_RENDERER3D_FLASH_CAT(_tgx_renderer3d_flash_mesh3dv2_, __LINE__))
152
153 #define TGX_PLACE_RENDERER3D_MESH3DV2_PATH_IN_FLASH_(RENDERER3D_OBJECT, RENDERER_T) \
154 namespace tgx { \
155 typedef typename ::tgx::Renderer3D_detail::RemoveReference<decltype(RENDERER3D_OBJECT)>::type RENDERER_T; \
156 typedef typename ::tgx::Renderer3D_detail::Renderer3DFlashTraits<RENDERER_T>::color_type TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t); \
157 template TGX_RENDERER3D_FLASH_SECTION("mesh3dv2") void RENDERER_T::_drawMesh(const int, const Mesh3Dv2<TGX_RENDERER3D_FLASH_CAT(RENDERER_T, _color_t)>*, bool); \
158 }
159
160#else
161
162 #define TGX_PLACE_RENDERER3D_SPHERE_PATH_IN_FLASH(RENDERER3D_OBJECT)
163 #define TGX_PLACE_RENDERER3D_TRUNCATED_CONE_PATH_IN_FLASH(RENDERER3D_OBJECT)
164 #define TGX_PLACE_RENDERER3D_MESH3D_PATH_IN_FLASH(RENDERER3D_OBJECT)
165 #define TGX_PLACE_RENDERER3D_MESH3DV2_PATH_IN_FLASH(RENDERER3D_OBJECT)
166
167#endif
168
169
170#endif
171
172#endif
173
tgx::Renderer3D
Class for drawing 3D objects onto a Image [MAIN CLASS FOR THE 3D API].
Definition: Renderer3D.h:120
tgx::Renderer3D_detail::RemoveReference
Definition: Renderer3DFlash.h:37
tgx::Renderer3D_detail::Renderer3DFlashTraits
Definition: Renderer3DFlash.h:41
tgx_config.h
Configuration file depending on the architecture.