Vesper 0.5.1
Vesper is short form for the Latin word for "Bat", as Vesper is designed to be small, lightweight, and easily handle things like particles and flocking behaviors in accordance with the nature of bats. \n It is meant to be a particle simulation, VFX editor, and CAN be used secondarily as a small game engine.
GitHub | Vesper Updates | Creator
Loading...
Searching...
No Matches
Vesper Namespace Reference

TEMPORARY. More...

Namespaces

namespace  Math
namespace  Key
 Namespace for keyboard key codes.
namespace  Random
namespace  Color
 Provides commonly used colors and color manipulation functions.
namespace  Mouse
 Namespace for mouse button codes.

Classes

class  Input
 Base input class for querying input states. More...
struct  ApplicationSettings
 WIP. More...
class  Application
 The core application class that manages the main loop, window, layers, and event handling. More...
class  FileDialogs
 Cross-platform file dialog utilities. More...
class  FileSystem
class  WindowsWindow
class  WindowResizeEvent
 Event for registering window resize. More...
class  WindowCloseEvent
 Event for registering window close. More...
class  AppTickEvent
 Event for registering application tick. More...
class  AppUpdateEvent
 Event for registering application update. More...
class  AppRenderEvent
 Event for registering application render. More...
class  MouseMovedEvent
 Event for registering mouse movement. More...
class  MouseScrolledEvent
 Event for registering mouse scroll wheel movement. More...
class  MouseButtonEvent
 Base class for mouse button events. More...
class  MouseButtonPressedEvent
 Event for registering mouse button presses. More...
class  MouseButtonReleasedEvent
 Event for registering mouse button releases. More...
class  KeyEvent
 Base class for keyboard events. More...
class  KeyPressedEvent
 Event for registering key press. More...
class  KeyReleasedEvent
 Event for registering key release. More...
class  KeyTypedEvent
 Event for registering key typing. More...
class  OpenGLContext
class  GraphicsContext
 Abstract class representing a graphics context. More...
class  OpenGLFramebuffer
class  OpenGLImGuiLayer
class  RendererAPI
 An abstract class defining the interface for a rendering API. More...
class  OpenGLRendererAPI
 An implementation of the RendererAPI for OpenGL. More...
class  OpenGLShader
class  OpenGLTexture2D
class  OpenGLUniformBuffer
class  OpenGLVertexArray
class  Layer
 Represents a reusable application layer that receives lifecycle callbacks (attach, detach, update, events, render, and ImGui render). Intended as a base class for concrete layers. More...
class  LayerStack
 Manages an ordered stack of Layer pointers. Layers can be pushed or popped and the stack can be iterated in forward or reverse order. More...
class  Log
 A logging utility class for the Vesper engine. More...
class  ImGuiLayer
struct  ParticleProps
class  ParticleSystem
class  Renderer2D
 A 2D renderer for drawing quads and sprites. More...
class  OrthographicCamera
struct  BufferElement
 Represents a single element in a buffer layout. More...
class  BufferLayout
 Represents the layout of a buffer, consisting of multiple BufferElements. More...
class  VertexBuffer
 Abstract base class for a vertex buffer. More...
class  IndexBuffer
 Abstract base class for an index buffer. More...
class  OpenGLVertexBuffer
class  OpenGLIndexBuffer
class  EditorCamera
struct  FramebufferSpecification
 Specification for creating a Framebuffer. More...
class  Framebuffer
 Abstract class representing a framebuffer. More...
class  Renderer
 The main renderer class responsible for managing rendering operations. More...
struct  ProfileResult
struct  InstrumentationSession
class  Instrumentor
class  InstrumentationTimer
struct  OrthographicCameraBounds
class  OrthographicCameraController
class  RenderCommand
 A static class that provides an interface for issuing rendering commands. More...
class  Shader
 An abstraction for a shader program. More...
class  ShaderLibrary
 A library for managing and storing shaders. More...
class  Texture
 An abstraction for a texture. More...
class  Texture2D
 An abstraction for a 2D texture. More...
class  TextureLibrary
 A library for managing and storing textures. More...
class  SubTexture2D
 Represents a sub-region of a 2D texture, useful for sprite sheets. More...
class  Camera
class  Timestep
 Represents a time step in seconds. More...
class  Event
 Abstract base class for all events. More...
class  EventDispatcher
 Stack-based templated event dispatcher. More...
struct  QuadVertex
struct  Renderer2DData
class  UniformBuffer
 An abstraction for a uniform buffer object (UBO). More...
class  VertexArray
 An abstraction for a vertex array object (VAO). More...
class  Entity
 Represents an entity in a scene. More...
class  Scene
class  ScriptableEntity
 Base class for scriptable entities within a scene. More...
class  SceneCamera
class  EditorLayer
class  SceneSerializer
class  SceneHierarchyPanel
struct  UUID
 Universally Unique Identifier. More...
struct  UUIDComponent
 Component that holds a UUID. More...
struct  NameComponent
 Component that holds the name of an entity. More...
struct  TransformComponent
 Component that holds the transform of an entity. More...
struct  SpriteRendererComponent
 Component that holds sprite rendering data. More...
struct  SubTextureComponent
 Component that holds sub-texture data for sprites. More...
struct  TextureAnimationComponent
 Animates through a series of sub textures. More...
struct  CameraComponent
 Component that holds camera data. More...
struct  NativeScriptComponent
 Component that holds scripting data for an entity. More...
class  VesperEditor
struct  WindowProps
 Holds the data for window configuration. More...
class  Window
 Abstract interface representing an application window. More...

Typedefs

using FloatingPointMicroseconds = std::chrono::duration<double, std::micro>
using KeyCode = uint16_t
 Alias for keyboard key code type.
using MouseCode = uint8_t
 Alias for mouse button code type.
template<typename T>
using Scope = std::unique_ptr<T>
 A smart pointer type representing exclusive ownership of an object.
template<typename T>
using Ref = std::shared_ptr<T>
 A smart pointer type representing shared ownership of an object.

Enumerations

enum class  ShaderDataType {
  None = 0 , Float , Float2 , Float3 ,
  Float4 , Mat3 , Mat4 , Int ,
  Int2 , Int3 , Int4 , Bool
}
 The different data types that can be used in shaders. More...
enum class  EventType {
  None = 0 , WindowClose , WindowResize , WindowFocus ,
  WindowLostFocus , WindowMoved , AppTick , AppUpdate ,
  AppRender , KeyPressed , KeyReleased , KeyTyped ,
  MouseButtonPressed , MouseButtonReleased , MouseMoved , MouseScrolled
}
 Enumeration of event types. More...
enum  EventCategory {
  None = 0 , EventCategoryApplication = BIT(0) , EventCategoryInput = BIT(1) , EventCategoryKeyboard = BIT(2) ,
  EventCategoryMouse = BIT(3) , EventCategoryMouseButton = BIT(4)
}
 Enumeration of event categories. More...
enum class  WindowMode { Windowed = 0 , Fullscreen = 1 , Borderless = 2 }
 WIP. More...

Functions

ApplicationCreateApplication ()
static void GLFWErrorCallback (int error, const char *description)
static GLenum ShaderTypeFromString (const std::string &type)
static GLenum ShaderDataTypeToOpenGLBaseType (ShaderDataType type)
static uint32_t ShaderDataTypeSize (ShaderDataType type)
 Returns the size in bytes of the given ShaderDataType.
std::string format_as (const Event &e)
 Format an event as a string.
static void SerializeEntity (YAML::Emitter &out, Entity entity)
static void DisplayVesperInfo_ImGui ()
static void DrawVec3Control (const std::string &label, glm::vec3 &values, float resetValue=0.0f, float columnWidth=100.0f)
static void DrawVec2Control (const std::string &label, glm::vec2 &values, float resetValue=0.0f, float columnWidth=100.0f)
static void SubTextureEdit (const std::string &label, SubTextureComponent &subTexture)
template<typename T, typename UIFunction>
static void DrawComponent (const std::string &name, Entity entity, UIFunction uiFunction)
template<typename T, typename... Args>
constexpr Scope< T > CreateScope (Args &&... args)
 Creates a Scope (unique_ptr) for the given type and constructor arguments.
template<typename T, typename... Args>
constexpr Ref< T > CreateRef (Args &&... args)
 Creates a Ref (shared_ptr) for the given type and constructor arguments.

Variables

static bool s_GLFWInitialized = false
static const uint32_t s_MaxFramebufferSize = 8192
 TODO: Get the actual maximum size from the GPU!
static Renderer2DData s_Data

Detailed Description

TEMPORARY.

The main namespace for the Vesper engine.

Temporary.

TODO: Abstract this to OpenGL/DirectX/Vulkan etc ImGui layers.

Todo
Temporary
Todo
Temporary

Class Documentation

◆ Vesper::ApplicationSettings

struct Vesper::ApplicationSettings

WIP.

Class Members
string ApplicationName = "Vesper Application"
bool EnableImGui = true
bool EnableVSync = false
uint32_t Height = 720
WindowMode Mode = WindowMode::Windowed
API RendererAPI = RendererAPI::API::OpenGL
uint32_t Width = 1280
string WorkingDirectory

◆ Vesper::ParticleProps

struct Vesper::ParticleProps
Class Members
vec4 ColorBegin = { 1.0f, 1.0f, 1.0f, 1.0f }
vec4 ColorEnd = { 1.0f, 1.0f, 1.0f, 1.0f }
float LifeTime = 1.0f
float LifetimeVariation = 0.0f
vec3 Position = { 0.0f, 0.0f, 0.0f }
float Rotation = 0.0f
float RotationVariation = 0.0f
float SizeBegin = 1.0f
float SizeEnd = 0.0f
float SizeVariation = 0.0f
vec3 Velocity = { 0.0f, 0.0f, 0.0f }
vec3 VelocityVariation = { 0.0f, 0.0f, 0.0f }

◆ Vesper::FramebufferSpecification

struct Vesper::FramebufferSpecification

Specification for creating a Framebuffer.

Class Members
uint32_t Height
uint32_t Samples = 1
bool SwapChainTarget = false
uint32_t Width

◆ Vesper::ProfileResult

struct Vesper::ProfileResult
Class Members
long long End
string Name
long long Start
uint32_t ThreadID

◆ Vesper::InstrumentationSession

struct Vesper::InstrumentationSession
Class Members
string Name

◆ Vesper::QuadVertex

struct Vesper::QuadVertex
Class Members
vec4 Color
vec3 Position
vec2 TexCoord
float TexIndex
float TilingFactor

Typedef Documentation

◆ FloatingPointMicroseconds

using Vesper::FloatingPointMicroseconds = std::chrono::duration<double, std::micro>

◆ KeyCode

using Vesper::KeyCode = uint16_t

Alias for keyboard key code type.

◆ MouseCode

using Vesper::MouseCode = uint8_t

Alias for mouse button code type.

◆ Ref

template<typename T>
using Vesper::Ref = std::shared_ptr<T>

A smart pointer type representing shared ownership of an object.

Template Parameters
TThe type of object to manage.
Note
This is an alias for std::shared_ptr.

◆ Scope

template<typename T>
using Vesper::Scope = std::unique_ptr<T>

A smart pointer type representing exclusive ownership of an object.

Template Parameters
TThe type of object to manage.
Note
This is an alias for std::unique_ptr.

Enumeration Type Documentation

◆ EventCategory

Enumeration of event categories.

Enumerator
None 
EventCategoryApplication 
EventCategoryInput 
EventCategoryKeyboard 
EventCategoryMouse 
EventCategoryMouseButton 
24 {
25 None = 0,
31 };
#define BIT(x)
Macro to shift 1 by x positions to create a bitmask.
Definition Defines_Macros.h:13
@ EventCategoryMouseButton
Definition Event.h:30
@ EventCategoryMouse
Definition Event.h:29
@ EventCategoryApplication
Definition Event.h:26
@ None
Definition Event.h:25
@ EventCategoryInput
Definition Event.h:27
@ EventCategoryKeyboard
Definition Event.h:28

◆ EventType

enum class Vesper::EventType
strong

Enumeration of event types.

Enumerator
None 
WindowClose 
WindowResize 
WindowFocus 
WindowLostFocus 
WindowMoved 
AppTick 
AppUpdate 
AppRender 
KeyPressed 
KeyReleased 
KeyTyped 
MouseButtonPressed 
MouseButtonReleased 
MouseMoved 
MouseScrolled 
14 {
15 None = 0,
20 };
@ WindowLostFocus
Definition Event.h:16
@ WindowFocus
Definition Event.h:16
@ KeyReleased
Definition Event.h:18
@ AppRender
Definition Event.h:17
@ MouseScrolled
Definition Event.h:19
@ AppTick
Definition Event.h:17
@ MouseButtonPressed
Definition Event.h:19
@ MouseButtonReleased
Definition Event.h:19
@ KeyTyped
Definition Event.h:18
@ WindowResize
Definition Event.h:16
@ WindowMoved
Definition Event.h:16
@ AppUpdate
Definition Event.h:17
@ KeyPressed
Definition Event.h:18
@ MouseMoved
Definition Event.h:19
@ WindowClose
Definition Event.h:16

◆ ShaderDataType

enum class Vesper::ShaderDataType
strong

The different data types that can be used in shaders.

Enumerator
None 
Float 
Float2 
Float3 
Float4 
Mat3 
Mat4 
Int 
Int2 
Int3 
Int4 
Bool 
6 {
7 None = 0,
9 Mat3, Mat4,
10 Int, Int2, Int3, Int4,
11 Bool
12 };
glm::vec3 Float3()
Definition Random.h:121
glm::vec4 Float4()
Definition Random.h:141
glm::vec2 Float2()
Definition Random.h:100
@ Int
Definition Buffer.h:10
@ Int4
Definition Buffer.h:10
@ Float
Definition Buffer.h:8
@ Mat3
Definition Buffer.h:9
@ Int2
Definition Buffer.h:10
@ Int3
Definition Buffer.h:10
@ Mat4
Definition Buffer.h:9
@ Bool
Definition Buffer.h:11

◆ WindowMode

enum class Vesper::WindowMode
strong

WIP.

Enumerator
Windowed 
Fullscreen 
Borderless 
16 {
17 Windowed = 0,
18 Fullscreen = 1,
19 Borderless = 2
20 };
@ Fullscreen
Definition Window.h:18
@ Borderless
Definition Window.h:19
@ Windowed
Definition Window.h:17

Function Documentation

◆ CreateApplication()

Application * Vesper::CreateApplication ( )
24 {
25 return new VesperEditor();
26 }
Definition VesperEditorApp.cpp:9

References Vesper::VesperEditor::VesperEditor().

◆ CreateRef()

template<typename T, typename... Args>
Ref< T > Vesper::CreateRef ( Args &&... args)
constexpr

Creates a Ref (shared_ptr) for the given type and constructor arguments.

Template Parameters
TThe type of object to create.
ArgsThe types of constructor arguments.
Parameters
argsThe constructor arguments.
Returns
A Ref (shared_ptr) managing the created object.
73 {
74 return std::make_shared<T>(std::forward<Args>(args)...);
75 }

◆ CreateScope()

template<typename T, typename... Args>
Scope< T > Vesper::CreateScope ( Args &&... args)
constexpr

Creates a Scope (unique_ptr) for the given type and constructor arguments.

Template Parameters
TThe type of object to create.
ArgsThe types of constructor arguments.
Parameters
argsThe constructor arguments.
Returns
A Scope (unique_ptr) managing the created object.
53 {
54 return std::make_unique<T>(std::forward<Args>(args)...);
55 }

◆ DisplayVesperInfo_ImGui()

void Vesper::DisplayVesperInfo_ImGui ( )
static
8 {
9 ImGui::Begin("Vesper Info");
10
11 if (ImGui::TreeNode("About Vesper"))
12 {
13 ImGui::Text("Vesper Engine");
14 ImGui::Text("Version: 0.1.0");
15 ImGui::Text("Author: Damon Green II");
16 ImGui::Text("GitHub: https://github.com/nomadiidamon/Vesper");
17 ImGui::Separator();
18
19 ImGui::Text("Status: ");
20 ImGui::Text("\tEarly Development of API and 2D Renderer");
21 ImGui::Separator();
22
23 ImGui::TextWrapped("Vesper is a cross-platform game engine currently in early development. The engine is being built from the ground up with a focus on modularity, performance, and ease of use. The goal of Vesper is to provide developers with a powerful and flexible toolset for creating games and interactive applications.");
24 ImGui::Separator();
25
26 if (ImGui::TreeNode("Controls:"))
27 {
28 ImGui::Text("\tWASD: Move Camera");
29 ImGui::Text("\tQ/E: Rotate Camera (if enabled {see settings})");
30 ImGui::Text("\tScroll Wheel: Zoom Camera");
31 ImGui::TreePop();
32 }
33 ImGui::Separator();
34
35 if (ImGui::TreeNode("RoadMap")) {
36
37 if (ImGui::TreeNode("Current Features:"))
38 {
39 ImGui::Text("\t- Cross-Platform Design");
40 ImGui::Text("\t\t- Currently Windows only");
41 ImGui::Text("\t- OpenGL Renderer");
42 ImGui::Text("\t- Orthographic Camera");
43 ImGui::Text("\t- Shader System");
44 ImGui::Text("\t- Texture Loading");
45 ImGui::Text("\t- ImGui Integration");
46 ImGui::Text("\t\t- Current settings panel adjusts camera parameters!");
47
48 ImGui::TreePop();
49 }
50 ImGui::Separator();
51
52 if (ImGui::TreeNode("In Progress:"))
53 {
54 ImGui::Text("\t- 2D Rendering Features");
55 ImGui::Text("\t\t- Sprites");
56 ImGui::Text("\t\t- Sprite Sheets");
57 ImGui::Text("\t\t- Animation");
58 ImGui::TreePop();
59 }
60 ImGui::Separator();
61
62 if (ImGui::TreeNode("Planned Features:"))
63 {
64 ImGui::Text("\t- Vulkan Renderer");
65 ImGui::Text("\t- 2D Editor");
66 ImGui::Text("\t- 2D Particles");
67 ImGui::Text("\t- Audio");
68 ImGui::Text("\t- Timelining");
69 ImGui::Text("\t- Video Playback");
70 ImGui::Text("\t- 3D Renderer");
71 ImGui::Text("\t- 3D Particles");
72 ImGui::TreePop();
73 }
74 ImGui::TreePop();
75 }
76
77 ImGui::TreePop();
78 }
79 ImGui::End();
80 }

Referenced by Vesper::EditorLayer::OnImGuiRender().

◆ DrawComponent()

template<typename T, typename UIFunction>
void Vesper::DrawComponent ( const std::string & name,
Entity entity,
UIFunction uiFunction )
static
333 {
334 const ImGuiTreeNodeFlags treeNodeFlags = ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_FramePadding;
335 if (entity.HasComponent<T>())
336 {
337 auto& component = entity.GetComponent<T>();
338 ImVec2 contentRegionAvailable = ImGui::GetContentRegionAvail();
339
340 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2{ 4, 4 });
341 float lineHeight = ImGui::GetFontSize() + ImGui::GetStyle().FramePadding.y * 2.0f;
342 ImGui::Separator();
343 bool open = ImGui::TreeNodeEx((void*)typeid(T).hash_code(), treeNodeFlags, name.c_str());
344 ImGui::PopStyleVar(
345 );
346 ImGui::SameLine(contentRegionAvailable.x - lineHeight * 0.5f);
347 if (ImGui::Button("+", ImVec2{ lineHeight, lineHeight }))
348 {
349 ImGui::OpenPopup("ComponentSettings");
350 }
351
352 bool removeComponent = false;
353 if (ImGui::BeginPopup("ComponentSettings"))
354 {
355 if (ImGui::MenuItem("Remove component"))
356 removeComponent = true;
357
358 ImGui::EndPopup();
359 }
360
361 if (open)
362 {
363 uiFunction(component);
364 ImGui::TreePop();
365 }
366
367 if (removeComponent)
368 entity.RemoveComponent<T>();
369 }
370 }
T & GetComponent()
Definition Entity.h:70
bool HasComponent() const
Definition Entity.h:33
void RemoveComponent()
Definition Entity.h:95
@ T
Definition KeyCodes.h:57

◆ DrawVec2Control()

void Vesper::DrawVec2Control ( const std::string & label,
glm::vec2 & values,
float resetValue = 0.0f,
float columnWidth = 100.0f )
static
234 {
235 ImGuiIO& io = ImGui::GetIO();
236 auto boldFont = io.Fonts->Fonts[0];
237
238 ImGui::PushID(label.c_str());
239
240 ImGui::Columns(2);
241 ImGui::SetColumnWidth(0, columnWidth);
242 ImGui::Text(label.c_str());
243 ImGui::NextColumn();
244
245 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2{ 0, 0 });
246
247 float lineHeight = ImGui::GetFontSize() + ImGui::GetStyle().FramePadding.y * 2.0f;
248 ImVec2 buttonSize = { lineHeight + 3.0f, lineHeight };
249
250 // Compute available width for the three float controls in the right column
251 float availableWidth = ImGui::GetContentRegionAvail().x;
252 float itemSpacing = ImGui::GetStyle().ItemSpacing.x;
253 float totalButtonWidth = buttonSize.x * 2.0f;
254 // Account for SameLine() spacings between button+control pairs (conservative estimate)
255 float totalSpacing = itemSpacing * 4.0f;
256 float itemWidth = (availableWidth - totalButtonWidth - totalSpacing) / 2.0f;
257 if (itemWidth <= 0.0f)
258 itemWidth = ImGui::CalcItemWidth();
259
260 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.8f, 0.1f, 0.15f, 1.0f });
261 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.9f, 0.2f, 0.2f, 1.0f });
262 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.8f, 0.1f, 0.15f, 1.0f });
263 ImGui::PushFont(boldFont);
264 if (ImGui::Button("X", buttonSize))
265 values.x = resetValue;
266 ImGui::PopFont();
267 ImGui::PopStyleColor(3);
268
269 ImGui::SameLine();
270 ImGui::PushItemWidth(itemWidth);
271 ImGui::DragFloat("##X", &values.x, 0.1f, 0.0f, 0.0f, "%.2f");
272 ImGui::PopItemWidth();
273 ImGui::SameLine();
274
275 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.2f, 0.7f, 0.2f, 1.0f });
276 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.3f, 0.8f, 0.3f, 1.0f });
277 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.2f, 0.7f, 0.2f, 1.0f });
278 ImGui::PushFont(boldFont);
279 if (ImGui::Button("Y", buttonSize))
280 values.y = resetValue;
281 ImGui::PopFont();
282 ImGui::PopStyleColor(3);
283
284 ImGui::SameLine();
285 ImGui::PushItemWidth(itemWidth);
286 ImGui::DragFloat("##Y", &values.y, 0.1f, 0.0f, 0.0f, "%.2f");
287 ImGui::PopItemWidth();
288 ImGui::SameLine();
289
290 ImGui::PopStyleVar();
291
292 ImGui::Columns(1);
293
294 ImGui::PopID();
295 }

◆ DrawVec3Control()

void Vesper::DrawVec3Control ( const std::string & label,
glm::vec3 & values,
float resetValue = 0.0f,
float columnWidth = 100.0f )
static
156 {
157 ImGuiIO& io = ImGui::GetIO();
158 auto boldFont = io.Fonts->Fonts[0];
159
160 ImGui::PushID(label.c_str());
161
162 ImGui::Columns(2);
163 ImGui::SetColumnWidth(0, columnWidth);
164 ImGui::Text(label.c_str());
165 ImGui::NextColumn();
166
167 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2{ 0, 0 });
168
169 float lineHeight = ImGui::GetFontSize() + ImGui::GetStyle().FramePadding.y * 2.0f;
170 ImVec2 buttonSize = { lineHeight + 3.0f, lineHeight };
171
172 // Compute available width for the three float controls in the right column
173 float availableWidth = ImGui::GetContentRegionAvail().x;
174 float itemSpacing = ImGui::GetStyle().ItemSpacing.x;
175 float totalButtonWidth = buttonSize.x * 3.0f;
176 // Account for SameLine() spacings between button+control pairs (conservative estimate)
177 float totalSpacing = itemSpacing * 6.0f;
178 float itemWidth = (availableWidth - totalButtonWidth - totalSpacing) / 3.0f;
179 if (itemWidth <= 0.0f)
180 itemWidth = ImGui::CalcItemWidth();
181
182 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.8f, 0.1f, 0.15f, 1.0f });
183 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.9f, 0.2f, 0.2f, 1.0f });
184 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.8f, 0.1f, 0.15f, 1.0f });
185 ImGui::PushFont(boldFont);
186 if (ImGui::Button("X", buttonSize))
187 values.x = resetValue;
188 ImGui::PopFont();
189 ImGui::PopStyleColor(3);
190
191 ImGui::SameLine();
192 ImGui::PushItemWidth(itemWidth);
193 ImGui::DragFloat("##X", &values.x, 0.1f, 0.0f, 0.0f, "%.2f");
194 ImGui::PopItemWidth();
195 ImGui::SameLine();
196
197 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.2f, 0.7f, 0.2f, 1.0f });
198 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.3f, 0.8f, 0.3f, 1.0f });
199 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.2f, 0.7f, 0.2f, 1.0f });
200 ImGui::PushFont(boldFont);
201 if (ImGui::Button("Y", buttonSize))
202 values.y = resetValue;
203 ImGui::PopFont();
204 ImGui::PopStyleColor(3);
205
206 ImGui::SameLine();
207 ImGui::PushItemWidth(itemWidth);
208 ImGui::DragFloat("##Y", &values.y, 0.1f, 0.0f, 0.0f, "%.2f");
209 ImGui::PopItemWidth();
210 ImGui::SameLine();
211
212 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.1f, 0.25f, 0.8f, 1.0f });
213 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.2f, 0.35f, 0.9f, 1.0f });
214 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.1f, 0.25f, 0.8f, 1.0f });
215 ImGui::PushFont(boldFont);
216 if (ImGui::Button("Z", buttonSize))
217 values.z = resetValue;
218 ImGui::PopFont();
219 ImGui::PopStyleColor(3);
220
221 ImGui::SameLine();
222 ImGui::PushItemWidth(itemWidth);
223 ImGui::DragFloat("##Z", &values.z, 0.1f, 0.0f, 0.0f, "%.2f");
224 ImGui::PopItemWidth();
225
226 ImGui::PopStyleVar();
227
228 ImGui::Columns(1);
229
230 ImGui::PopID();
231 }

◆ format_as()

std::string Vesper::format_as ( const Event & e)
inline

Format an event as a string.

105 {
106 return e.ToString();
107 }
virtual std::string ToString() const
Convert the event to a string representation.
Definition Event.h:52

◆ GLFWErrorCallback()

void Vesper::GLFWErrorCallback ( int error,
const char * description )
static
16 {
17 VZ_CORE_ERROR("GLFW Error ({0}): {1}", error, description);
18 }
#define VZ_CORE_ERROR(...)
error: indicates an error that has occurred
Definition Log.h:41

Referenced by Vesper::WindowsWindow::Init().

◆ SerializeEntity()

void Vesper::SerializeEntity ( YAML::Emitter & out,
Entity entity )
static
121 {
122
123 VZ_CORE_ASSERT(entity.HasComponent<UUIDComponent>(), "Entity has no UUIDComponent!");
124 VZ_CORE_ASSERT(entity.HasComponent<NameComponent>(), "Entity has no NameComponent!");
125
126 out << YAML::BeginMap; // Entity
127 out << YAML::Key << "Entity" << YAML::Value << entity.GetID(); // UUIDComponent
128 out << YAML::Key << "NameComponent" << YAML::Value << entity.GetName();
129
130 if (entity.HasComponent<TransformComponent>()) {
131 out << YAML::Key << "TransformComponent";
132 out << YAML::BeginMap; // TransformComponent
133
134 auto& tc = entity.GetComponent<TransformComponent>();
135 out << YAML::Key << "Translation" << YAML::Value << tc.Translation;
136 out << YAML::Key << "Rotation" << YAML::Value << tc.Rotation;
137 out << YAML::Key << "Scale" << YAML::Value << tc.Scale;
138
139 out << YAML::EndMap; // TransformComponent
140 }
141
142 if (entity.HasComponent<CameraComponent>()) {
143 out << YAML::Key << "CameraComponent";
144 out << YAML::BeginMap; // CameraComponent
145
146 auto& cameraComp = entity.GetComponent<CameraComponent>();
147 auto& camera = cameraComp.Camera;
148
149
150 out << YAML::Key << "Camera" << YAML::Value;
151 out << YAML::BeginMap; // Camera
152 out << YAML::Key << "PerspectiveFOV" << YAML::Value << camera.GetPerspectiveVerticalFOV();
153 out << YAML::Key << "PerspectiveNear" << YAML::Value << camera.GetPerspectiveNearClip();
154 out << YAML::Key << "PerspectiveFar" << YAML::Value << camera.GetPerspectiveFarClip();
155 out << YAML::Key << "OrthographicSize" << YAML::Value << camera.GetOrthographicSize();
156 out << YAML::Key << "OrthographicNear" << YAML::Value << camera.GetOrthographicNearClip();
157 out << YAML::Key << "OrthographicFar" << YAML::Value << camera.GetOrthographicFarClip();
158 out << YAML::EndMap;
159
160 out << YAML::Key << "Primary" << YAML::Value << cameraComp.Primary;
161 out << YAML::Key << "ProjectionType" << YAML::Value << (int)camera.GetProjectionType();
162 out << YAML::Key << "FixedAspectRatio" << YAML::Value << cameraComp.FixedAspectRatio;
163
164 out << YAML::EndMap; // CameraComponent
165 }
166
168 out << YAML::Key << "SpriteRendererComponent";
169 out << YAML::BeginMap; // SpriteRendererComponent
170
171 auto& src = entity.GetComponent<SpriteRendererComponent>();
172 out << YAML::Key << "Color" << YAML::Value << src.Color;
173 // Texture serialization can be added here in the future
174 out << YAML::EndMap; // SpriteRendererComponent
175 }
176 out << YAML::EndMap; // Entity
177 }
#define VZ_CORE_ASSERT(x,...)
Definition Asserts.h:20
const std::string & GetName()
Definition Entity.h:112
const UUID & GetID()
Definition Entity.h:104
Component that holds the name of an entity.
Definition Components.h:46
Component that holds sprite rendering data.
Definition Components.h:90
glm::vec4 Color
Color of the sprite.
Definition Components.h:92
Component that holds the transform of an entity.
Definition Components.h:62
glm::vec3 Translation
Translation (position) vector.
Definition Components.h:64
Component that holds a UUID.
Definition Components.h:30

◆ ShaderDataTypeSize()

uint32_t Vesper::ShaderDataTypeSize ( ShaderDataType type)
static

Returns the size in bytes of the given ShaderDataType.

Parameters
typeThe ShaderDataType to get the size of.
Returns
The size in bytes of the ShaderDataType. Will assert if the type is unknown.
19 {
20 switch (type) {
21 case ShaderDataType::Float: return 4;
22 case ShaderDataType::Float2: return 4 * 2;
23 case ShaderDataType::Float3: return 4 * 3;
24 case ShaderDataType::Float4: return 4 * 4;
25 case ShaderDataType::Mat3: return 4 * 3 * 3;
26 case ShaderDataType::Mat4: return 4 * 4 * 4;
27 case ShaderDataType::Int: return 4;
28 case ShaderDataType::Int2: return 4 * 2;
29 case ShaderDataType::Int3: return 4 * 3;
30 case ShaderDataType::Int4: return 4 * 4;
31 case ShaderDataType::Bool: return 1;
32 }
33 VZ_CORE_ASSERT(false, "Unknown ShaderDataType!");
34 return 0;
35 }
@ Float4
Definition Buffer.h:8
@ Float2
Definition Buffer.h:8
@ Float3
Definition Buffer.h:8

References Bool, Float, Float2, Float3, Float4, Int, Int2, Int3, Int4, Mat3, and Mat4.

Referenced by Vesper::BufferElement::BufferElement().

◆ ShaderDataTypeToOpenGLBaseType()

GLenum Vesper::ShaderDataTypeToOpenGLBaseType ( ShaderDataType type)
static
10 {
11 switch (type)
12 {
13 case ShaderDataType::Float: return GL_FLOAT;
14 case ShaderDataType::Float2: return GL_FLOAT;
15 case ShaderDataType::Float3: return GL_FLOAT;
16 case ShaderDataType::Float4: return GL_FLOAT;
17 case ShaderDataType::Mat3: return GL_FLOAT;
18 case ShaderDataType::Mat4: return GL_FLOAT;
19 case ShaderDataType::Int: return GL_INT;
20 case ShaderDataType::Int2: return GL_INT;
21 case ShaderDataType::Int3: return GL_INT;
22 case ShaderDataType::Int4: return GL_INT;
23 case ShaderDataType::Bool: return GL_BOOL;
24 }
25 VZ_CORE_ASSERT(false, "Unknown ShaderDataType!");
26 return 0;
27 }

◆ ShaderTypeFromString()

GLenum Vesper::ShaderTypeFromString ( const std::string & type)
static
11 {
13 if (type == "vertex")
14 return GL_VERTEX_SHADER;
15 if (type == "fragment" || type == "pixel")
16 return GL_FRAGMENT_SHADER;
17 VZ_CORE_ASSERT(false, "Unknown shader type!");
18 return 0;
19 }
#define VZ_PROFILE_FUNCTION()
Definition Instrumentor.h:240

◆ SubTextureEdit()

void Vesper::SubTextureEdit ( const std::string & label,
SubTextureComponent & subTexture )
static
298 {
299 ImGui::Text(label.c_str());
300
301 auto& subTexRef = subTexture.GetSubTexture();
302 if (subTexRef && subTexRef->GetTexture()) {
303 glm::vec2 oldOffset = subTexture.Offset;
304 glm::vec2 oldTiling = subTexture.TilingFactor;
305
306 DrawVec2Control("Offset", subTexture.Offset);
307 DrawVec2Control("Scale", subTexture.TilingFactor, 1.0f);
308
309 if (subTexRef->GetTexture())
310 {
311 //if (oldOffset != subTexture.Offset || oldTiling != subTexture.TilingFactor) {
312 // subTexture.SetOffset(subTexture.Offset);
313 // subTexture.SetTilingFactor(subTexture.TilingFactor);
314
315 auto tex = subTexRef->GetTexture();
316 if (tex) {
318 tex, subTexture.Offset,
319 glm::vec2(static_cast<float>(tex->GetWidth()) * subTexture.TilingFactor.x,
320 static_cast<float>(tex->GetHeight()) * subTexture.TilingFactor.y));
321 }
322 //}
323 }
324 }
325 else {
326 ImGui::Text("No texture assigned.");
327 }
328
329 }
static Ref< SubTexture2D > CreateFromCoords(const Ref< Texture2D > &texture, const glm::vec2 &coords, const glm::vec2 &cellSize, const glm::vec2 &spriteSize={1, 1})
Creates a SubTexture2D from a grid of cells within the given texture.
Definition SubTexture2D.cpp:17
static void DrawVec2Control(const std::string &label, glm::vec2 &values, float resetValue=0.0f, float columnWidth=100.0f)
Definition SceneHierarchyPanel.cpp:233
glm::vec2 Offset
Offset for the sub-texture.
Definition Components.h:128
Ref< SubTexture2D > & GetSubTexture()
Definition Components.h:158
Ref< SubTexture2D > SubTexture
The sub-texture reference.
Definition Components.h:124
glm::vec2 TilingFactor
Tiling factor for the sub-texture.
Definition Components.h:126

Variable Documentation

◆ s_Data

◆ s_GLFWInitialized

bool Vesper::s_GLFWInitialized = false
static

◆ s_MaxFramebufferSize

const uint32_t Vesper::s_MaxFramebufferSize = 8192
static

TODO: Get the actual maximum size from the GPU!