style: apply clang-format v20
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		
							parent
							
								
									b6953c2a9e
								
							
						
					
					
						commit
						f2c692a118
					
				
					 45 changed files with 220 additions and 163 deletions
				
			
		|  | @ -55,10 +55,13 @@ Application::Application(): m_window(nullptr) | |||
| 	    m_graphics_context->get_shared_context(), | ||||
| 	    Renderer::CreateInfo { | ||||
| 	        .quad_renderer_shader = AssetManager::get_shader("LT_ENGINE_RESOURCES_QUAD_SHADER"), | ||||
| 	        .texture_renderer_shader = AssetManager::get_shader("LT_ENGINE_RESOURCES_TEXTURE_SHADER" | ||||
| 	        .texture_renderer_shader = AssetManager::get_shader( | ||||
| 	            "LT_ENGINE_RESOURCES_TEXTURE_SHADER" | ||||
| 	        ), | ||||
| 	        .tinted_texture_renderer_shader = AssetManager::get_shader( | ||||
| 	            "LT_ENGINE_RESOURCES_TINTED_" | ||||
| 	            "TEXTURE_SHADER" | ||||
| 	        ), | ||||
| 	        .tinted_texture_renderer_shader = AssetManager::get_shader("LT_ENGINE_RESOURCES_TINTED_" | ||||
| 	                                                                   "TEXTURE_SHADER"), | ||||
| 	    } | ||||
| 	); | ||||
| 	ensure(m_graphics_context, "lWindow::lWindow: failed to create 'GraphicsContext'"); | ||||
|  |  | |||
|  | @ -31,8 +31,11 @@ public: | |||
| 
 | ||||
| 	TextAsset(const std::filesystem::path &path); | ||||
| 
 | ||||
| 	void unpack_blob(BlobMetadata::Tag tag, std::byte *destination, size_t destination_capacity) | ||||
| 	    const; | ||||
| 	void unpack_blob( | ||||
| 	    BlobMetadata::Tag tag, | ||||
| 	    std::byte *destination, | ||||
| 	    size_t destination_capacity | ||||
| 	) const; | ||||
| 
 | ||||
| 	[[nodiscard]] auto get_asset_metadata() const -> const Asset::Metadata &; | ||||
| 
 | ||||
|  |  | |||
|  | @ -95,22 +95,28 @@ void TextAsset::unpack_blob( | |||
| 	case Assets::CompressionType::None: | ||||
| 		if (m_text_blob_metadata.uncompressed_size != m_text_blob_metadata.compressed_size) | ||||
| 		{ | ||||
| 			throw std::runtime_error("Failed to unpack blob from TextAsset: " | ||||
| 			                         "compressed/uncompressed size mismatch for no compression " | ||||
| 			                         "type"); | ||||
| 			throw std::runtime_error( | ||||
| 			    "Failed to unpack blob from TextAsset: " | ||||
| 			    "compressed/uncompressed size mismatch for no compression " | ||||
| 			    "type" | ||||
| 			); | ||||
| 		} | ||||
| 
 | ||||
| 		if (m_text_blob_metadata.uncompressed_size > destination_capacity) | ||||
| 		{ | ||||
| 			throw std::runtime_error("Failed to unpack blob from TextAsset: " | ||||
| 			                         "uncompressed_size > destination_capacity, unpacking " | ||||
| 			                         "would result in segfault"); | ||||
| 			throw std::runtime_error( | ||||
| 			    "Failed to unpack blob from TextAsset: " | ||||
| 			    "uncompressed_size > destination_capacity, unpacking " | ||||
| 			    "would result in segfault" | ||||
| 			); | ||||
| 		} | ||||
| 
 | ||||
| 		if (!m_stream.is_open()) | ||||
| 		{ | ||||
| 			throw std::runtime_error("Failed to unpack blob from TextAsset: ifstream is " | ||||
| 			                         "closed"); | ||||
| 			throw std::runtime_error( | ||||
| 			    "Failed to unpack blob from TextAsset: ifstream is " | ||||
| 			    "closed" | ||||
| 			); | ||||
| 		} | ||||
| 
 | ||||
| 		m_stream.read( | ||||
|  | @ -122,11 +128,13 @@ void TextAsset::unpack_blob( | |||
| 		return; | ||||
| 
 | ||||
| 	default: | ||||
| 		throw std::runtime_error(std::format( | ||||
| 		    "Failed to unpack blob from TextAsset: unsupported " | ||||
| 		    "compression type: {}", | ||||
| 		    std::to_underlying(m_text_blob_metadata.compression_type) | ||||
| 		)); | ||||
| 		throw std::runtime_error( | ||||
| 		    std::format( | ||||
| 		        "Failed to unpack blob from TextAsset: unsupported " | ||||
| 		        "compression type: {}", | ||||
| 		        std::to_underlying(m_text_blob_metadata.compression_type) | ||||
| 		    ) | ||||
| 		); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -96,22 +96,28 @@ void TextureAsset::unpack_blob( | |||
| 	case Assets::CompressionType::None: | ||||
| 		if (m_pixel_blob_metadata.uncompressed_size != m_pixel_blob_metadata.compressed_size) | ||||
| 		{ | ||||
| 			throw std::runtime_error("Failed to unpack blob from TextureAsset: " | ||||
| 			                         "compressed/uncompressed size mismatch for no compression " | ||||
| 			                         "type"); | ||||
| 			throw std::runtime_error( | ||||
| 			    "Failed to unpack blob from TextureAsset: " | ||||
| 			    "compressed/uncompressed size mismatch for no compression " | ||||
| 			    "type" | ||||
| 			); | ||||
| 		} | ||||
| 
 | ||||
| 		if (m_pixel_blob_metadata.uncompressed_size > destination_capacity) | ||||
| 		{ | ||||
| 			throw std::runtime_error("Failed to unpack blob from TextureAsset: " | ||||
| 			                         "uncompressed_size > destination_capacity, unpacking " | ||||
| 			                         "would result in segfault"); | ||||
| 			throw std::runtime_error( | ||||
| 			    "Failed to unpack blob from TextureAsset: " | ||||
| 			    "uncompressed_size > destination_capacity, unpacking " | ||||
| 			    "would result in segfault" | ||||
| 			); | ||||
| 		} | ||||
| 
 | ||||
| 		if (!m_stream.is_open()) | ||||
| 		{ | ||||
| 			throw std::runtime_error("Failed to unpack blob from TextureAsset: ifstream is " | ||||
| 			                         "closed"); | ||||
| 			throw std::runtime_error( | ||||
| 			    "Failed to unpack blob from TextureAsset: ifstream is " | ||||
| 			    "closed" | ||||
| 			); | ||||
| 		} | ||||
| 
 | ||||
| 		m_stream.read( | ||||
|  | @ -123,11 +129,13 @@ void TextureAsset::unpack_blob( | |||
| 		return; | ||||
| 
 | ||||
| 	default: | ||||
| 		throw std::runtime_error(std::format( | ||||
| 		    "Failed to unpack blob from TextureAsset: unsupported " | ||||
| 		    "compression type: {}", | ||||
| 		    std::to_underlying(m_pixel_blob_metadata.compression_type) | ||||
| 		)); | ||||
| 		throw std::runtime_error( | ||||
| 		    std::format( | ||||
| 		        "Failed to unpack blob from TextureAsset: unsupported " | ||||
| 		        "compression type: {}", | ||||
| 		        std::to_underlying(m_pixel_blob_metadata.compression_type) | ||||
| 		    ) | ||||
| 		); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -167,8 +167,8 @@ auto SceneSerializer::deserialize(const std::string &file_path) -> bool | |||
| 			{ | ||||
| 				auto &entitySpriteRendererComponent = deserializedEntity | ||||
| 				                                          .add_component<SpriteRendererComponent>(); | ||||
| 				entitySpriteRendererComponent.tint = spriteRendererComponent["Tint"].as<glm::vec4>( | ||||
| 				); | ||||
| 				entitySpriteRendererComponent.tint = spriteRendererComponent["Tint"] | ||||
| 				                                         .as<glm::vec4>(); | ||||
| 
 | ||||
| 				auto texturePath = spriteRendererComponent["Texture"].as<std::string>(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -37,7 +37,7 @@ enum EventCategory | |||
| #define event_type(type)                      \ | ||||
| 	EventType get_event_type() const override \ | ||||
| 	{                                         \ | ||||
| 		return ::lt::EventType::type;      \ | ||||
| 		return ::lt::EventType::type;         \ | ||||
| 	} | ||||
| 
 | ||||
| #define event_category(eCategory)                                   \ | ||||
|  |  | |||
|  | @ -11,11 +11,13 @@ class Mirror: public Application | |||
| public: | ||||
| 	Mirror() | ||||
| 	{ | ||||
| 		get_window().set_properties(WindowProperties { | ||||
| 		    .title = "Mirror", | ||||
| 		    .size = glm::uvec2(1280u, 720u), | ||||
| 		    .vsync = true, | ||||
| 		}); | ||||
| 		get_window().set_properties( | ||||
| 		    WindowProperties { | ||||
| 		        .title = "Mirror", | ||||
| 		        .size = glm::uvec2(1280u, 720u), | ||||
| 		        .vsync = true, | ||||
| 		    } | ||||
| 		); | ||||
| 
 | ||||
| 		get_layer_stack().emplace_layer<EditorLayer>("MirrorLayer"); | ||||
| 	} | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| #pragma once | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| namespace lt { | ||||
| 
 | ||||
| class SharedContext; | ||||
|  | @ -37,8 +36,8 @@ enum class BlendFactor : uint8_t | |||
| class Blender | ||||
| { | ||||
| public: | ||||
| virtual ~Blender() = default; | ||||
| 	static auto create(const Ref<SharedContext>& sharedContext) -> Scope<Blender>; | ||||
| 	virtual ~Blender() = default; | ||||
| 	static auto create(const Ref<SharedContext> &sharedContext) -> Scope<Blender>; | ||||
| 
 | ||||
| 	virtual void enable(BlendFactor srcFactor, BlendFactor dstFactor) = 0; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| #pragma once | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| namespace lt { | ||||
| 
 | ||||
| class SharedContext; | ||||
|  | @ -14,11 +13,11 @@ enum class ConstantBufferIndex | |||
| class ConstantBuffer | ||||
| { | ||||
| public: | ||||
| virtual ~ConstantBuffer() = default; | ||||
| 	virtual ~ConstantBuffer() = default; | ||||
| 	static auto create( | ||||
| 	    ConstantBufferIndex index, | ||||
| 	    unsigned int size, | ||||
| 	    const Ref<SharedContext>& sharedContext | ||||
| 	    const Ref<SharedContext> &sharedContext | ||||
| 	) -> Scope<ConstantBuffer>; | ||||
| 
 | ||||
| 	virtual auto map() -> void * = 0; | ||||
|  | @ -38,7 +37,7 @@ public: | |||
| 	    float *vertices, | ||||
| 	    unsigned int stride, | ||||
| 	    unsigned int count, | ||||
| 	    const Ref<SharedContext>& sharedContext | ||||
| 	    const Ref<SharedContext> &sharedContext | ||||
| 	) -> Ref<VertexBuffer>; | ||||
| 
 | ||||
| 	virtual ~VertexBuffer() = default; | ||||
|  | @ -58,8 +57,11 @@ protected: | |||
| class IndexBuffer | ||||
| { | ||||
| public: | ||||
| 	static auto create(unsigned int *indices, unsigned int count, const Ref<SharedContext>& sharedContext) | ||||
| 	    -> Ref<IndexBuffer>; | ||||
| 	static auto create( | ||||
| 	    unsigned int *indices, | ||||
| 	    unsigned int count, | ||||
| 	    const Ref<SharedContext> &sharedContext | ||||
| 	) -> Ref<IndexBuffer>; | ||||
| 
 | ||||
| 	virtual ~IndexBuffer() = default; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <d3d11.h> | ||||
| 
 | ||||
| #include <renderer/buffers.hpp> | ||||
| #include <wrl.h> | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <d3d11.h> | ||||
| 
 | ||||
| #include <renderer/framebuffer.hpp> | ||||
| #include <wrl.h> | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <d3d11.h> | ||||
| 
 | ||||
| #include <renderer/graphics_context.hpp> | ||||
| #include <wrl.h> | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <d3d11.h> | ||||
| 
 | ||||
| #include <renderer/render_command.hpp> | ||||
| #include <wrl.h> | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <d3d11.h> | ||||
| 
 | ||||
| #include <renderer/shader.hpp> | ||||
| #include <wrl.h> | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <d3d11.h> | ||||
| 
 | ||||
| #include <renderer/shared_context.hpp> | ||||
| #include <wrl.h> | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <d3d11.h> | ||||
| 
 | ||||
| #include <renderer/texture.hpp> | ||||
| #include <wrl.h> | ||||
| 
 | ||||
|  |  | |||
|  | @ -17,8 +17,10 @@ public: | |||
| 
 | ||||
| 	~dxUserInterface(); | ||||
| 
 | ||||
| 	void platform_implementation(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext) | ||||
| 	    override; | ||||
| 	void platform_implementation( | ||||
| 	    GLFWwindow *windowHandle, | ||||
| 	    Ref<SharedContext> sharedContext | ||||
| 	) override; | ||||
| 
 | ||||
| 	void begin() override; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <d3d11.h> | ||||
| 
 | ||||
| #include <renderer/vertex_layout.hpp> | ||||
| #include <wrl.h> | ||||
| 
 | ||||
|  |  | |||
|  | @ -9,9 +9,9 @@ class SharedContext; | |||
| 
 | ||||
| struct FramebufferSpecification | ||||
| { | ||||
| 	unsigned int width{}; | ||||
| 	unsigned int width {}; | ||||
| 
 | ||||
| 	unsigned int height{}; | ||||
| 	unsigned int height {}; | ||||
| 
 | ||||
| 	unsigned int samples = 1; | ||||
| }; | ||||
|  | @ -19,10 +19,10 @@ struct FramebufferSpecification | |||
| class Framebuffer | ||||
| { | ||||
| public: | ||||
| virtual ~Framebuffer() = default; | ||||
| 	virtual ~Framebuffer() = default; | ||||
| 	static auto create( | ||||
| 	    const FramebufferSpecification &specification, | ||||
| 	    const Ref<SharedContext>& sharedContext | ||||
| 	    const Ref<SharedContext> &sharedContext | ||||
| 	) -> Ref<Framebuffer>; | ||||
| 
 | ||||
| 	virtual void bind_as_target(const glm::vec4 &clearColor) = 0; | ||||
|  |  | |||
|  | @ -8,7 +8,7 @@ namespace lt { | |||
| class glBlender: public Blender | ||||
| { | ||||
| public: | ||||
| virtual ~glBlender() = default; | ||||
| 	virtual ~glBlender() = default; | ||||
| 	glBlender(); | ||||
| 
 | ||||
| 	void enable(BlendFactor srcFactor, BlendFactor dstFactor) override; | ||||
|  |  | |||
|  | @ -22,8 +22,12 @@ public: | |||
| 
 | ||||
| 	void default_target_framebuffer() override; | ||||
| 
 | ||||
| 	void set_viewport(unsigned int x, unsigned int y, unsigned int width, unsigned int height) | ||||
| 	    override; | ||||
| 	void set_viewport( | ||||
| 	    unsigned int x, | ||||
| 	    unsigned int y, | ||||
| 	    unsigned int width, | ||||
| 	    unsigned int height | ||||
| 	) override; | ||||
| 
 | ||||
| private: | ||||
| 	GLFWwindow *m_window_handle; | ||||
|  |  | |||
|  | @ -14,8 +14,10 @@ public: | |||
| 
 | ||||
| 	~glUserInterface() override; | ||||
| 
 | ||||
| 	void platform_implementation(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext) | ||||
| 	    override; | ||||
| 	void platform_implementation( | ||||
| 	    GLFWwindow *windowHandle, | ||||
| 	    Ref<SharedContext> sharedContext | ||||
| 	) override; | ||||
| 
 | ||||
| 	void begin() override; | ||||
| 
 | ||||
|  |  | |||
|  | @ -22,7 +22,7 @@ class glVertexLayout: public VertexLayout | |||
| { | ||||
| public: | ||||
| 	glVertexLayout( | ||||
| 	    const Ref<VertexBuffer>& buffer, | ||||
| 	    const Ref<VertexBuffer> &buffer, | ||||
| 	    const std::vector<std::pair<std::string, VertexElementType>> &elements | ||||
| 	); | ||||
| 
 | ||||
|  |  | |||
|  | @ -12,7 +12,7 @@ class SharedContext; | |||
| class RenderCommand | ||||
| { | ||||
| public: | ||||
| 	static auto create(GLFWwindow *windowHandle, const Ref<SharedContext>& sharedContext) | ||||
| 	static auto create(GLFWwindow *windowHandle, const Ref<SharedContext> &sharedContext) | ||||
| 	    -> Scope<RenderCommand>; | ||||
| 
 | ||||
| 	RenderCommand(const RenderCommand &) = delete; | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| #pragma once | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| namespace lt { | ||||
| 
 | ||||
| class SharedContext | ||||
|  |  | |||
|  | @ -17,9 +17,11 @@ auto Blender::create(const Ref<SharedContext> & /*sharedContext*/) -> Scope<Blen | |||
| 	case GraphicsAPI::OpenGL: return create_scope<glBlender>(); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: | ||||
| 		lt_win(return create_scope<dxBlender>( | ||||
| 		                  std::static_pointer_cast<dxSharedContext>(sharedContext) | ||||
| 		);) | ||||
| 		lt_win( | ||||
| 		    return create_scope<dxBlender>( | ||||
| 		               std::static_pointer_cast<dxSharedContext>(sharedContext) | ||||
| 		    ); | ||||
| 		) | ||||
| 
 | ||||
| 		    default | ||||
| 		    : ensure( | ||||
|  |  | |||
|  | @ -23,11 +23,13 @@ auto ConstantBuffer::create( | |||
| 	case GraphicsAPI::OpenGL: return create_scope<glConstantBuffer>(index, size); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: | ||||
| 		lt_win(return create_scope<dxConstantBuffer>( | ||||
| 		                  index, | ||||
| 		                  size, | ||||
| 		                  std::static_pointer_cast<dxSharedContext>(sharedContext) | ||||
| 		);) | ||||
| 		lt_win( | ||||
| 		    return create_scope<dxConstantBuffer>( | ||||
| 		               index, | ||||
| 		               size, | ||||
| 		               std::static_pointer_cast<dxSharedContext>(sharedContext) | ||||
| 		    ); | ||||
| 		) | ||||
| 
 | ||||
| 		    default | ||||
| 		    : ensure( | ||||
|  | @ -51,12 +53,14 @@ auto VertexBuffer::create( | |||
| 	case GraphicsAPI::OpenGL: return create_ref<glVertexBuffer>(vertices, stride, count); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: | ||||
| 		lt_win(return create_ref<dxVertexBuffer>( | ||||
| 		                  vertices, | ||||
| 		                  stride, | ||||
| 		                  count, | ||||
| 		                  std::static_pointer_cast<dxSharedContext>(sharedContext) | ||||
| 		);) | ||||
| 		lt_win( | ||||
| 		    return create_ref<dxVertexBuffer>( | ||||
| 		               vertices, | ||||
| 		               stride, | ||||
| 		               count, | ||||
| 		               std::static_pointer_cast<dxSharedContext>(sharedContext) | ||||
| 		    ); | ||||
| 		) | ||||
| 
 | ||||
| 		    default | ||||
| 		    : ensure( | ||||
|  | @ -79,11 +83,13 @@ auto IndexBuffer::create( | |||
| 	case GraphicsAPI::OpenGL: return create_ref<glIndexBuffer>(indices, count); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: | ||||
| 		lt_win(return create_ref<dxIndexBuffer>( | ||||
| 		                  indices, | ||||
| 		                  count, | ||||
| 		                  std::dynamic_pointer_cast<dxSharedContext>(sharedContext) | ||||
| 		);) | ||||
| 		lt_win( | ||||
| 		    return create_ref<dxIndexBuffer>( | ||||
| 		               indices, | ||||
| 		               count, | ||||
| 		               std::dynamic_pointer_cast<dxSharedContext>(sharedContext) | ||||
| 		    ); | ||||
| 		) | ||||
| 
 | ||||
| 		    default | ||||
| 		    : ensure( | ||||
|  |  | |||
|  | @ -36,9 +36,11 @@ dxFramebuffer::dxFramebuffer( | |||
| 	srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; | ||||
| 	srvDesc.Texture2D.MipLevels = 1; | ||||
| 	srvDesc.Texture2D.MostDetailedMip = 0; | ||||
| 	dxc(m_context->get_device() | ||||
| 	        ->CreateShaderResourceView(m_color_attachment.Get(), &srvDesc, &m_shader_resource_view) | ||||
| 	); | ||||
| 	dxc(m_context->get_device()->CreateShaderResourceView( | ||||
| 	    m_color_attachment.Get(), | ||||
| 	    &srvDesc, | ||||
| 	    &m_shader_resource_view | ||||
| 	)); | ||||
| 
 | ||||
| 	auto rtvDesc = D3D11_RENDER_TARGET_VIEW_DESC {}; | ||||
| 	rtvDesc.Format = t2dDesc.Format; | ||||
|  | @ -101,9 +103,11 @@ void dxFramebuffer::resize(const glm::uvec2 &size) | |||
| 	dxc(m_context->get_device()->CreateTexture2D(&textureDesc, nullptr, &m_color_attachment)); | ||||
| 	dxc(m_context->get_device() | ||||
| 	        ->CreateRenderTargetView(m_color_attachment.Get(), &rtvDesc, &m_render_target_view)); | ||||
| 	dxc(m_context->get_device() | ||||
| 	        ->CreateShaderResourceView(m_color_attachment.Get(), &srvDesc, &m_shader_resource_view) | ||||
| 	); | ||||
| 	dxc(m_context->get_device()->CreateShaderResourceView( | ||||
| 	    m_color_attachment.Get(), | ||||
| 	    &srvDesc, | ||||
| 	    &m_shader_resource_view | ||||
| 	)); | ||||
| } | ||||
| 
 | ||||
| } // namespace lt
 | ||||
|  |  | |||
|  | @ -94,9 +94,11 @@ void dxGraphicsContext::setup_render_targets() | |||
| 	auto backBuffer = Microsoft::WRL::ComPtr<ID3D11Resource> {}; | ||||
| 
 | ||||
| 	dxc(context->get_swap_chain()->GetBuffer(0u, __uuidof(ID3D11Resource), &backBuffer)); | ||||
| 	dxc(context->get_device() | ||||
| 	        ->CreateRenderTargetView(backBuffer.Get(), nullptr, &context->GetRenderTargetViewRef()) | ||||
| 	); | ||||
| 	dxc(context->get_device()->CreateRenderTargetView( | ||||
| 	    backBuffer.Get(), | ||||
| 	    nullptr, | ||||
| 	    &context->GetRenderTargetViewRef() | ||||
| 	)); | ||||
| 
 | ||||
| 	// set render target view
 | ||||
| 	context->get_device_context() | ||||
|  |  | |||
|  | @ -59,7 +59,8 @@ dxShader::dxShader( | |||
| 	    NULL, | ||||
| 	    &m_vertex_shader | ||||
| 	)); | ||||
| 	dxc(m_context->get_device() | ||||
| 	dxc( | ||||
| 	    m_context->get_device() | ||||
| 	        ->CreatePixelShader(ps->GetBufferPointer(), ps->GetBufferSize(), NULL, &m_pixel_shader) | ||||
| 	); | ||||
| } | ||||
|  |  | |||
|  | @ -18,13 +18,15 @@ dxVertexLayout::dxVertexLayout( | |||
| 	// extract elements desc
 | ||||
| 	for (const auto &element : elements) | ||||
| 	{ | ||||
| 		inputElementsDesc.emplace_back(D3D11_INPUT_ELEMENT_DESC { element.first.c_str(), | ||||
| 		                                                          NULL, | ||||
| 		                                                          get_dxgi_format(element.second), | ||||
| 		                                                          0u, | ||||
| 		                                                          D3D11_APPEND_ALIGNED_ELEMENT, | ||||
| 		                                                          D3D11_INPUT_PER_VERTEX_DATA, | ||||
| 		                                                          0u }); | ||||
| 		inputElementsDesc.emplace_back( | ||||
| 		    D3D11_INPUT_ELEMENT_DESC { element.first.c_str(), | ||||
| 		                               NULL, | ||||
| 		                               get_dxgi_format(element.second), | ||||
| 		                               0u, | ||||
| 		                               D3D11_APPEND_ALIGNED_ELEMENT, | ||||
| 		                               D3D11_INPUT_PER_VERTEX_DATA, | ||||
| 		                               0u } | ||||
| 		); | ||||
| 	} | ||||
| 
 | ||||
| 	auto dxpShader = std::dynamic_pointer_cast<dxShader>(shader); | ||||
|  |  | |||
|  | @ -12,7 +12,7 @@ namespace lt { | |||
| 
 | ||||
| auto Framebuffer::create( | ||||
|     const FramebufferSpecification &specification, | ||||
|     const Ref<SharedContext>&  /*sharedContext*/ | ||||
|     const Ref<SharedContext> & /*sharedContext*/ | ||||
| ) -> Ref<Framebuffer> | ||||
| { | ||||
| 	switch (GraphicsContext::get_graphics_api()) | ||||
|  | @ -20,10 +20,12 @@ auto Framebuffer::create( | |||
| 	case GraphicsAPI::OpenGL: return create_ref<glFramebuffer>(specification); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: | ||||
| 		lt_win(return create_ref<dxFramebuffer>( | ||||
| 		                  specification, | ||||
| 		                  std::static_pointer_cast<dxSharedContext>(sharedContext) | ||||
| 		);); | ||||
| 		lt_win( | ||||
| 		    return create_ref<dxFramebuffer>( | ||||
| 		               specification, | ||||
| 		               std::static_pointer_cast<dxSharedContext>(sharedContext) | ||||
| 		    ); | ||||
| 		); | ||||
| 
 | ||||
| 	default: | ||||
| 		ensure( | ||||
|  |  | |||
|  | @ -1,33 +1,33 @@ | |||
| #include <renderer/gl/blender.hpp> | ||||
| #include <glad/gl.h> | ||||
| #include <renderer/gl/blender.hpp> | ||||
| 
 | ||||
| namespace lt { | ||||
| 
 | ||||
| glBlender::glBlender() | ||||
|     : m_factor_map { // constants
 | ||||
| 	                { BlendFactor::ZERO, GL_ZERO }, | ||||
| 	                { BlendFactor::ONE, GL_ONE }, | ||||
| 	                 { BlendFactor::ZERO, GL_ZERO }, | ||||
| 	                 { BlendFactor::ONE, GL_ONE }, | ||||
| 
 | ||||
| 	                // source						 ,
 | ||||
| 	                { BlendFactor::SRC_COLOR, GL_SRC_COLOR }, | ||||
| 	                { BlendFactor::INVERSE_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR }, | ||||
| 	                 // source						 ,
 | ||||
| 	                 { BlendFactor::SRC_COLOR, GL_SRC_COLOR }, | ||||
| 	                 { BlendFactor::INVERSE_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR }, | ||||
| 
 | ||||
| 	                { BlendFactor::SRC_ALPHA, GL_SRC_ALPHA }, | ||||
| 	                { BlendFactor::INVERSE_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }, | ||||
| 	                 { BlendFactor::SRC_ALPHA, GL_SRC_ALPHA }, | ||||
| 	                 { BlendFactor::INVERSE_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }, | ||||
| 
 | ||||
| 	                // destination					 ,
 | ||||
| 	                { BlendFactor::DST_COLOR, GL_DST_COLOR }, | ||||
| 	                { BlendFactor::INVERSE_DST_COLOR, GL_ONE_MINUS_DST_COLOR }, | ||||
| 	                 // destination					 ,
 | ||||
| 	                 { BlendFactor::DST_COLOR, GL_DST_COLOR }, | ||||
| 	                 { BlendFactor::INVERSE_DST_COLOR, GL_ONE_MINUS_DST_COLOR }, | ||||
| 
 | ||||
| 	                { BlendFactor::DST_ALPHA, GL_DST_ALPHA }, | ||||
| 	                { BlendFactor::INVERSE_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA }, | ||||
| 	                 { BlendFactor::DST_ALPHA, GL_DST_ALPHA }, | ||||
| 	                 { BlendFactor::INVERSE_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA }, | ||||
| 
 | ||||
| 	                // source1						 ,
 | ||||
| 	                { BlendFactor::SRC1_COLOR, GL_SRC1_COLOR }, | ||||
| 	                { BlendFactor::INVERSE_SRC1_COLOR, GL_ONE_MINUS_SRC1_COLOR }, | ||||
| 	                 // source1						 ,
 | ||||
| 	                 { BlendFactor::SRC1_COLOR, GL_SRC1_COLOR }, | ||||
| 	                 { BlendFactor::INVERSE_SRC1_COLOR, GL_ONE_MINUS_SRC1_COLOR }, | ||||
| 
 | ||||
| 	                { BlendFactor::SRC1_ALPHA, GL_SRC1_ALPHA }, | ||||
| 	                { BlendFactor::INVERSE_SRC1_ALPHA, GL_ONE_MINUS_SRC_ALPHA } | ||||
| 	                 { BlendFactor::SRC1_ALPHA, GL_SRC1_ALPHA }, | ||||
| 	                 { BlendFactor::INVERSE_SRC1_ALPHA, GL_ONE_MINUS_SRC_ALPHA } | ||||
|     } | ||||
| { | ||||
| } | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| #include <renderer/gl/framebuffers.hpp> | ||||
| #include <glad/gl.h> | ||||
| #include <glm/glm.hpp> | ||||
| #include <renderer/gl/framebuffers.hpp> | ||||
| 
 | ||||
| namespace lt { | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| #include <renderer/gl/render_command.hpp> | ||||
| #include <glad/gl.h> | ||||
| #include <renderer/gl/render_command.hpp> | ||||
| #ifndef DONT_FUCKING_ORDER_THESSE_PLEASE_FOR_THE_LOVE_OF_GOD_CLANG_FORMAT | ||||
| 	#include <GLFW/glfw3.h> | ||||
| #endif | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| #include <glad/gl.h> | ||||
| #include <debug/assertions.hpp> | ||||
| #include <glad/gl.h> | ||||
| #include <renderer/gl/buffers.hpp> | ||||
| #include <renderer/gl/vertex_layout.hpp> | ||||
| 
 | ||||
|  |  | |||
|  | @ -37,9 +37,10 @@ auto GraphicsContext::create(GraphicsAPI api, GLFWwindow *window_handle) -> Scop | |||
| 		break; | ||||
| 	// directx
 | ||||
| 	case GraphicsAPI::DirectX: | ||||
| 		lt_win(scope_gfx = create_scope<dxGraphicsContext>(window_handle); | ||||
| 		       s_context = scope_gfx.get(); | ||||
| 		       break;) | ||||
| 		lt_win( | ||||
| 		    scope_gfx = create_scope<dxGraphicsContext>(window_handle); s_context = scope_gfx.get(); | ||||
| 		    break; | ||||
| 		) | ||||
| 
 | ||||
| 		    default | ||||
| 		    : ensure( | ||||
|  |  | |||
|  | @ -19,9 +19,11 @@ auto RenderCommand::create(GLFWwindow *windowHandle, const Ref<SharedContext> & | |||
| 	case GraphicsAPI::OpenGL: return create_scope<glRenderCommand>(windowHandle); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: | ||||
| 		lt_win(return create_scope<dxRenderCommand>( | ||||
| 		                  (std::static_pointer_cast<dxSharedContext>)(sharedContext) | ||||
| 		);) | ||||
| 		lt_win( | ||||
| 		    return create_scope<dxRenderCommand>( | ||||
| 		               (std::static_pointer_cast<dxSharedContext>)(sharedContext) | ||||
| 		    ); | ||||
| 		) | ||||
| 
 | ||||
| 		    default | ||||
| 		    : ensure( | ||||
|  |  | |||
|  | @ -1,9 +1,9 @@ | |||
| #include <camera/scene.hpp> | ||||
| #include <debug/assertions.hpp> | ||||
| #include <glm/glm.hpp> | ||||
| #include <glm/gtc/matrix_transform.hpp> | ||||
| #include <glm/matrix.hpp> | ||||
| #include <input/events/window.hpp> | ||||
| #include <debug/assertions.hpp> | ||||
| #include <renderer/blender.hpp> | ||||
| #include <renderer/buffers.hpp> | ||||
| #include <renderer/framebuffer.hpp> | ||||
|  |  | |||
|  | @ -26,11 +26,13 @@ namespace lt { | |||
| 		return create_ref<glShader>(std::move(vertex_asset), std::move(pixel_asset)); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: | ||||
| 		lt_win(return create_ref<dxShader>( | ||||
| 		                  vertex_asset, | ||||
| 		                  pixel_asset, | ||||
| 		                  std::static_pointer_cast<dxSharedContext>(sharedContext) | ||||
| 		);); | ||||
| 		lt_win( | ||||
| 		    return create_ref<dxShader>( | ||||
| 		               vertex_asset, | ||||
| 		               pixel_asset, | ||||
| 		               std::static_pointer_cast<dxSharedContext>(sharedContext) | ||||
| 		    ); | ||||
| 		); | ||||
| 
 | ||||
| 	default: | ||||
| 		ensure( | ||||
|  |  | |||
|  | @ -21,14 +21,16 @@ namespace lt { | |||
| 	case GraphicsAPI::OpenGL: return create_ref<glTexture>(std::move(asset)); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: | ||||
| 		lt_win(return create_ref<dxTexture>( | ||||
| 		                  width, | ||||
| 		                  height, | ||||
| 		                  components, | ||||
| 		                  pixels, | ||||
| 		                  std::static_pointer_cast<dxSharedContext>(sharedContext), | ||||
| 		                  filePath | ||||
| 		);) | ||||
| 		lt_win( | ||||
| 		    return create_ref<dxTexture>( | ||||
| 		               width, | ||||
| 		               height, | ||||
| 		               components, | ||||
| 		               pixels, | ||||
| 		               std::static_pointer_cast<dxSharedContext>(sharedContext), | ||||
| 		               filePath | ||||
| 		    ); | ||||
| 		) | ||||
| 
 | ||||
| 		    default | ||||
| 		    : ensure( | ||||
|  |  | |||
|  | @ -23,11 +23,13 @@ auto VertexLayout::create( | |||
| 	case GraphicsAPI::OpenGL: return create_ref<glVertexLayout>(vertexBuffer, elements); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: | ||||
| 		lt_win(return create_ref<dxVertexLayout>( | ||||
| 		                  shader, | ||||
| 		                  elements, | ||||
| 		                  std::static_pointer_cast<dxSharedContext>(sharedContext) | ||||
| 		);) | ||||
| 		lt_win( | ||||
| 		    return create_ref<dxVertexLayout>( | ||||
| 		               shader, | ||||
| 		               elements, | ||||
| 		               std::static_pointer_cast<dxSharedContext>(sharedContext) | ||||
| 		    ); | ||||
| 		) | ||||
| 
 | ||||
| 		    default | ||||
| 		    : ensure( | ||||
|  |  | |||
|  | @ -13,8 +13,10 @@ public: | |||
| 
 | ||||
| 	~glUserInterface() override; | ||||
| 
 | ||||
| 	void platform_implementation(GLFWwindow *windowHandle, Ref<SharedContext> sharedContext) | ||||
| 	    override; | ||||
| 	void platform_implementation( | ||||
| 	    GLFWwindow *windowHandle, | ||||
| 	    Ref<SharedContext> sharedContext | ||||
| 	) override; | ||||
| 
 | ||||
| 	void begin() override; | ||||
| 
 | ||||
|  |  | |||
|  | @ -20,8 +20,10 @@ public: | |||
| 
 | ||||
| 	void on_event(const Event &event) override; | ||||
| 
 | ||||
| 	void set_properties(const WindowProperties &properties, bool overrideVisibility = false) | ||||
| 	    override; | ||||
| 	void set_properties( | ||||
| 	    const WindowProperties &properties, | ||||
| 	    bool overrideVisibility = false | ||||
| 	) override; | ||||
| 
 | ||||
| 	void set_title(const std::string &title) override; | ||||
| 
 | ||||
|  |  | |||
|  | @ -136,8 +136,9 @@ void lWindow::bind_glfw_events() | |||
| 	glfwSetMouseButtonCallback( | ||||
| 	    m_handle, | ||||
| 	    [](GLFWwindow *window, int button, int action, int /*mods*/) { | ||||
| 		    std::function<void(Event &)> const callback = *(std::function<void(Event &)> *) | ||||
| 		                                                      glfwGetWindowUserPointer(window); | ||||
| 		    std::function<void(Event &)> const callback = *( | ||||
| 		        std::function<void(Event &)> * | ||||
| 		    )glfwGetWindowUserPointer(window); | ||||
| 
 | ||||
| 		    if (action == GLFW_PRESS) | ||||
| 		    { | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue