mirror of
https://github.com/NoelFB/blah.git
synced 2025-07-15 18:51:53 +08:00
large organizational & cleanup refactor
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
#include <blah/core/app.h>
|
||||
#include <blah/app.h>
|
||||
#include <blah/graphics/renderpass.h>
|
||||
#include <blah/graphics/texture.h>
|
||||
#include <blah/graphics/framebuffer.h>
|
||||
#include <blah/graphics/target.h>
|
||||
#include <blah/graphics/shader.h>
|
||||
#include <blah/graphics/mesh.h>
|
||||
#include <blah/graphics/material.h>
|
||||
#include <blah/math/color.h>
|
||||
#include <blah/numerics/color.h>
|
||||
|
||||
namespace Blah
|
||||
{
|
||||
@ -45,9 +45,9 @@ namespace Blah
|
||||
// if the Texture is invalid, this should return an empty reference.
|
||||
TextureRef create_texture(int width, int height, TextureFormat format);
|
||||
|
||||
// Creates a new FrameBuffer.
|
||||
// if the FrameBuffer is invalid, this should return an empty reference.
|
||||
FrameBufferRef create_framebuffer(int width, int height, const TextureFormat* attachments, int attachment_count);
|
||||
// Creates a new Target.
|
||||
// if the Target is invalid, this should return an empty reference.
|
||||
TargetRef create_target(int width, int height, const TextureFormat* attachments, int attachment_count);
|
||||
|
||||
// Creates a new Shader.
|
||||
// if the Shader is invalid, this should return an empty reference.
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "../internal/graphics_backend.h"
|
||||
#include "../internal/platform_backend.h"
|
||||
#include <blah/core/common.h>
|
||||
#include <blah/common.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cstddef>
|
||||
@ -252,7 +252,7 @@ namespace Blah
|
||||
hr = state.device->CreateTexture2D(&desc, NULL, &staging);
|
||||
if (!SUCCEEDED(hr))
|
||||
{
|
||||
BLAH_ERROR("Failed to create staging texture to get data");
|
||||
BLAH_ASSERT(false, "Failed to create staging texture to get data");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -270,7 +270,7 @@ namespace Blah
|
||||
|
||||
if (!SUCCEEDED(hr))
|
||||
{
|
||||
BLAH_ERROR("Failed to get texture data");
|
||||
BLAH_ASSERT(false, "Failed to get texture data");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -285,16 +285,16 @@ namespace Blah
|
||||
|
||||
};
|
||||
|
||||
class D3D11_FrameBuffer : public FrameBuffer
|
||||
class D3D11_Target : public Target
|
||||
{
|
||||
private:
|
||||
Attachments m_attachments;
|
||||
|
||||
public:
|
||||
StackVector<ID3D11RenderTargetView*, Attachments::MaxCapacity - 1> color_views;
|
||||
StackVector<ID3D11RenderTargetView*, Attachments::capacity - 1> color_views;
|
||||
ID3D11DepthStencilView* depth_view = nullptr;
|
||||
|
||||
D3D11_FrameBuffer(int width, int height, const TextureFormat* attachments, int attachment_count)
|
||||
D3D11_Target(int width, int height, const TextureFormat* attachments, int attachment_count)
|
||||
{
|
||||
for (int i = 0; i < attachment_count; i++)
|
||||
{
|
||||
@ -315,19 +315,19 @@ namespace Blah
|
||||
}
|
||||
}
|
||||
|
||||
~D3D11_FrameBuffer()
|
||||
~D3D11_Target()
|
||||
{
|
||||
for (auto& it : color_views)
|
||||
it->Release();
|
||||
color_views.clear();
|
||||
}
|
||||
|
||||
Attachments& attachments() override
|
||||
Attachments& textures() override
|
||||
{
|
||||
return m_attachments;
|
||||
}
|
||||
|
||||
const Attachments& attachments() const override
|
||||
const Attachments& textures() const override
|
||||
{
|
||||
return m_attachments;
|
||||
}
|
||||
@ -841,9 +841,9 @@ namespace Blah
|
||||
return TextureRef();
|
||||
}
|
||||
|
||||
FrameBufferRef GraphicsBackend::create_framebuffer(int width, int height, const TextureFormat* attachments, int attachment_count)
|
||||
TargetRef GraphicsBackend::create_target(int width, int height, const TextureFormat* attachments, int attachment_count)
|
||||
{
|
||||
return FrameBufferRef(new D3D11_FrameBuffer(width, height, attachments, attachment_count));
|
||||
return TargetRef(new D3D11_Target(width, height, attachments, attachment_count));
|
||||
}
|
||||
|
||||
ShaderRef GraphicsBackend::create_shader(const ShaderData* data)
|
||||
@ -876,7 +876,7 @@ namespace Blah
|
||||
}
|
||||
else
|
||||
{
|
||||
auto target = (D3D11_FrameBuffer*)(pass.target.get());
|
||||
auto target = (D3D11_Target*)(pass.target.get());
|
||||
ctx->OMSetRenderTargets(target->color_views.size(), target->color_views.begin(), target->depth_view);
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "../internal/graphics_backend.h"
|
||||
#include "../internal/platform_backend.h"
|
||||
#include <blah/core/common.h>
|
||||
#include <blah/common.h>
|
||||
|
||||
namespace Blah
|
||||
{
|
||||
@ -56,14 +56,14 @@ namespace Blah
|
||||
|
||||
};
|
||||
|
||||
class Dummy_FrameBuffer : public FrameBuffer
|
||||
class Dummy_Target : public Target
|
||||
{
|
||||
private:
|
||||
Attachments m_attachments;
|
||||
|
||||
public:
|
||||
|
||||
Dummy_FrameBuffer(int width, int height, const TextureFormat* attachments, int attachmentCount)
|
||||
Dummy_Target(int width, int height, const TextureFormat* attachments, int attachmentCount)
|
||||
{
|
||||
for (int i = 0; i < attachmentCount; i++)
|
||||
{
|
||||
@ -73,12 +73,12 @@ namespace Blah
|
||||
}
|
||||
}
|
||||
|
||||
virtual Attachments& attachments() override
|
||||
virtual Attachments& textures() override
|
||||
{
|
||||
return m_attachments;
|
||||
}
|
||||
|
||||
virtual const Attachments& attachments() const override
|
||||
virtual const Attachments& textures() const override
|
||||
{
|
||||
return m_attachments;
|
||||
}
|
||||
@ -186,9 +186,9 @@ namespace Blah
|
||||
return TextureRef(new Dummy_Texture(width, height, format, false));
|
||||
}
|
||||
|
||||
FrameBufferRef GraphicsBackend::create_framebuffer(int width, int height, const TextureFormat* attachments, int attachmentCount)
|
||||
TargetRef GraphicsBackend::create_target(int width, int height, const TextureFormat* attachments, int attachmentCount)
|
||||
{
|
||||
return FrameBufferRef(new Dummy_FrameBuffer(width, height, attachments, attachmentCount));
|
||||
return TargetRef(new Dummy_Target(width, height, attachments, attachmentCount));
|
||||
}
|
||||
|
||||
ShaderRef GraphicsBackend::create_shader(const ShaderData* data)
|
||||
|
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <blah/input/input.h>
|
||||
#include <blah/input.h>
|
||||
|
||||
namespace Blah
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include <blah/core/common.h>
|
||||
#include <blah/core/filesystem.h>
|
||||
#include <blah/common.h>
|
||||
#include <blah/filesystem.h>
|
||||
#include <blah/containers/vector.h>
|
||||
|
||||
namespace Blah
|
||||
@ -66,6 +66,9 @@ namespace Blah
|
||||
// Returns the absolute path to the user directory where save data and settings should be stored
|
||||
const char* user_path();
|
||||
|
||||
// Opens a file and sets the handle, or returns an empty handle if it fails
|
||||
FileRef file_open(const char* path, FileMode mode);
|
||||
|
||||
// Returns true if a file with the given path exists
|
||||
bool file_exists(const char* path);
|
||||
|
||||
@ -87,27 +90,6 @@ namespace Blah
|
||||
// opens a directory in the OS file explorer / finder
|
||||
void dir_explore(const char* path);
|
||||
|
||||
// Opens a file and sets the handle. returns true if the file was successfully opened
|
||||
bool file_open(const char* path, FileHandle* handle, FileMode mode);
|
||||
|
||||
// Returns the length of the file
|
||||
i64 file_length(FileHandle file);
|
||||
|
||||
// Returns the Position of the file
|
||||
i64 file_position(FileHandle file);
|
||||
|
||||
// Seeks the Position of the file and returns the new position from the start of the file
|
||||
i64 file_seek(FileHandle file, i64 seekTo);
|
||||
|
||||
// Reads a specific number of elements of a given size from the file into ptr
|
||||
i64 file_read(FileHandle file, void* ptr, i64 size);
|
||||
|
||||
// Writes a specific number of elements of the given size from ptr to the file
|
||||
i64 file_write(FileHandle file, const void* ptr, i64 size);
|
||||
|
||||
// Closes a file
|
||||
void file_close(FileHandle file);
|
||||
|
||||
// OpenGL Methods
|
||||
void* gl_get_func(const char* name);
|
||||
void* gl_context_create();
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user