V-Gears 0
Free Final Fantasy VII engine.
DebugDraw.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include <OgreHardwareVertexBuffer.h>
19#include <OgreRenderQueueListener.h>
20#include <OgreRoot.h>
21#include <OgreSingleton.h>
22#include <OgreFont.h>
23
24class DebugDraw : public Ogre::RenderQueueListener, public Ogre::Singleton<DebugDraw>{
25
26 public:
27
31 DebugDraw();
32
36 virtual ~DebugDraw();
37
43 void SetColour(const Ogre::ColourValue& colour);
44
51 void SetScreenSpace(const bool screen_space);
52
58 void SetZ(const float z);
59
66 void SetFadeDistance(const float fade_s, const float fade_e);
67
72
77
82
86 CENTER
87 };
88 void SetTextAlignment(TextAlignment alignment);
89
102 void Line(
103 const float x1, const float y1, const float x2, const float y2
104 );
105
116 void Line3d(const Ogre::Vector3& point1, const Ogre::Vector3& point2);
117
129 void Triangle3d(
130 const Ogre::Vector3& point1, const Ogre::Vector3& point2,
131 const Ogre::Vector3& point3
132 );
133
150 void Quad(
151 const float x1, const float y1, const float x2, const float y2,
152 const float x3, const float y3, const float x4, const float y4
153 );
154
167 void Text(const float x, const float y, const Ogre::String& text);
168
183 void Text(
184 const Ogre::Vector3& point, const float x, const float y,
185 const Ogre::String& text
186 );
187
196 void renderQueueEnded(
197 Ogre::uint8 queueGroupId, const Ogre::String& invocation,
198 bool& repeatThisInvocation
199 );
200
201 private:
202
207
212
217
222
227
232
237
242
247
252
256 Ogre::SceneManager* scene_manager_;
257
261 Ogre::RenderSystem* render_system_;
262
266 Ogre::RenderOperation line_render_operation_;
267
271 Ogre::HardwareVertexBufferSharedPtr line_vertex_buffer_;
272
276 unsigned int line_max_vertex_;
277
281 Ogre::RenderOperation line_3d_render_operation_;
282
286 Ogre::HardwareVertexBufferSharedPtr line_3d_vertex_buffer_;
287
292
296 Ogre::RenderOperation triangle_3d_render_operation_;
297
301 Ogre::HardwareVertexBufferSharedPtr triangle_3d_vertex_buffer_;
302
307
311 Ogre::RenderOperation quad_render_operation_;
312
316 Ogre::HardwareVertexBufferSharedPtr quad_vertex_buffer_;
317
321 unsigned int quad_max_vertex_;
322
326 Ogre::RenderOperation text_render_operation_;
327
333 Ogre::HardwareVertexBufferSharedPtr text_vertex_buffer_;
334
340 unsigned int text_max_vertex_;
341
345 Ogre::FontPtr font_;
346
351
356
360 Ogre::MaterialPtr material_;
361
365 Ogre::MaterialPtr material_3d_;
366
370 Ogre::ColourValue colour_;
371
376
381
386
391};
392
396#define DEBUG_DRAW DebugDraw::getSingleton()
397
Definition: DebugDraw.h:24
Ogre::RenderSystem * render_system_
The render system.
Definition: DebugDraw.h:261
void Quad(const float x1, const float y1, const float x2, const float y2, const float x3, const float y3, const float x4, const float y4)
Draws a quad in 2D space.
Definition: DebugDraw.cpp:219
void DestroyLineVertexBuffer()
Destroys a 2D line vertex buffer (2 vertices).
Definition: DebugDraw.cpp:493
unsigned int line_3d_max_vertex_
Maximum number of vertices for debug 3D lines.
Definition: DebugDraw.h:291
Ogre::MaterialPtr material_3d_
Material for a 3D object.
Definition: DebugDraw.h:365
void CreateLineVertexBuffer()
Creates a 2D line vertex buffer (2 vertices).
Definition: DebugDraw.cpp:474
Ogre::FontPtr font_
Font to use for debug text.
Definition: DebugDraw.h:345
void SetScreenSpace(const bool screen_space)
Sets the screen space.
Definition: DebugDraw.cpp:97
void DestroyLine3dVertexBuffer()
Destroys a 3D line vertex buffer (2 vertices).
Definition: DebugDraw.cpp:523
void CreateTriangle3dVertexBuffer()
Creates a 3D triangle vertex buffer (3 vertices).
Definition: DebugDraw.cpp:530
Ogre::RenderOperation text_render_operation_
A text render operation.
Definition: DebugDraw.h:326
int font_height_
Font height for the debug text.
Definition: DebugDraw.h:350
bool screen_space_
The screen space.
Definition: DebugDraw.h:375
Ogre::HardwareVertexBufferSharedPtr line_3d_vertex_buffer_
A 3D line vertex buffer (2 vertices).
Definition: DebugDraw.h:286
TextAlignment text_alignment_
Alignment for debug text.
Definition: DebugDraw.h:355
float z_coordinate_
Z coordinate for the debug object.
Definition: DebugDraw.h:380
void DestroyTriangle3dVertexBuffer()
Destroys a 3D triangle vertex buffer (3 vertices).
Definition: DebugDraw.cpp:553
Ogre::ColourValue colour_
Color for the debug object or text.
Definition: DebugDraw.h:370
void SetTextAlignment(TextAlignment alignment)
Definition: DebugDraw.cpp:106
void SetFadeDistance(const float fade_s, const float fade_e)
Sets the fade distance for text.
Definition: DebugDraw.cpp:101
Ogre::RenderOperation triangle_3d_render_operation_
A 3D triangle render operation.
Definition: DebugDraw.h:296
float fade_start_square_
For text fading.
Definition: DebugDraw.h:385
DebugDraw()
Constructor.
Definition: DebugDraw.cpp:32
Ogre::HardwareVertexBufferSharedPtr line_vertex_buffer_
A 2D line vertex buffer (2 vertices).
Definition: DebugDraw.h:271
void SetZ(const float z)
Set the Z coordinate.
Definition: DebugDraw.cpp:99
void DestroyTextVertexBuffer()
Destroys a text vertex buffer.
Definition: DebugDraw.cpp:607
virtual ~DebugDraw()
Destructor.
Definition: DebugDraw.cpp:86
void Triangle3d(const Ogre::Vector3 &point1, const Ogre::Vector3 &point2, const Ogre::Vector3 &point3)
Draws a triangle in 3D space.
Definition: DebugDraw.cpp:180
TextAlignment
Text alignment modes.
Definition: DebugDraw.h:71
@ LEFT
Left aligned text.
Definition: DebugDraw.h:76
@ CENTER
Center aligned text.
Definition: DebugDraw.h:86
@ RIGHT
Right aligned text.
Definition: DebugDraw.h:81
void SetColour(const Ogre::ColourValue &colour)
Sets the colour of the element to draw.
Definition: DebugDraw.cpp:95
unsigned int line_max_vertex_
Maximum number of vertices for debug 2D lines.
Definition: DebugDraw.h:276
void CreateLine3dVertexBuffer()
Creates a 3D line vertex buffer (2 vertices).
Definition: DebugDraw.cpp:500
Ogre::RenderOperation line_render_operation_
A 2D line render operation.
Definition: DebugDraw.h:266
unsigned int text_max_vertex_
Maximum number of vertices for debug text.
Definition: DebugDraw.h:340
Ogre::HardwareVertexBufferSharedPtr text_vertex_buffer_
A text vertex buffer.
Definition: DebugDraw.h:333
void Line(const float x1, const float y1, const float x2, const float y2)
Draws a line in 2D space.
Definition: DebugDraw.cpp:108
Ogre::HardwareVertexBufferSharedPtr quad_vertex_buffer_
A quad vertex buffer (4 vertices).
Definition: DebugDraw.h:316
Ogre::MaterialPtr material_
Material for a 2D object.
Definition: DebugDraw.h:360
void DestroyQuadVertexBuffer()
Destroys a quad vertex buffer (4 vertices).
Definition: DebugDraw.cpp:579
Ogre::HardwareVertexBufferSharedPtr triangle_3d_vertex_buffer_
A 3D triangle vertex buffer (3 vertices).
Definition: DebugDraw.h:301
Ogre::SceneManager * scene_manager_
The scene manager.
Definition: DebugDraw.h:256
Ogre::RenderOperation line_3d_render_operation_
A 3D line render operation.
Definition: DebugDraw.h:281
void CreateTextVertexBuffer()
Creates a text vertex buffer.
Definition: DebugDraw.cpp:586
void CreateQuadVertexBuffer()
Creates a quad vertex buffer (4 vertices).
Definition: DebugDraw.cpp:560
void Text(const float x, const float y, const Ogre::String &text)
Writes debug text on the game screen.
Definition: DebugDraw.cpp:292
Ogre::RenderOperation quad_render_operation_
A quad render operation.
Definition: DebugDraw.h:311
void Line3d(const Ogre::Vector3 &point1, const Ogre::Vector3 &point2)
Draws a line in 3D space.
Definition: DebugDraw.cpp:149
unsigned int triangle_3d_max_vertex_
Maximum number of vertices for debug 3D triangles.
Definition: DebugDraw.h:306
float fade_end_square_
For text fading.
Definition: DebugDraw.h:390
void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &repeatThisInvocation)
Ends the render queue.
Definition: DebugDraw.cpp:417
unsigned int quad_max_vertex_
Maximum number of vertices for debug quads.
Definition: DebugDraw.h:321
Ogre::String String
Definition: TypeDefine.h:37
unsigned char uint8
Definition: scummsys.h:431