refactored graphics & streams into single files - easier to maintain & read

This commit is contained in:
Noel Berry
2022-02-12 12:19:53 -08:00
parent 9c7d8a4418
commit 99595f265f
53 changed files with 1323 additions and 1560 deletions

View File

@ -1,7 +1,7 @@
#pragma once
#include <blah/common.h>
#include <blah/filesystem.h>
#include <blah/input.h>
#include <blah/filesystem.h>
#include <blah/containers/vector.h>
namespace Blah

View File

@ -67,8 +67,8 @@ namespace Blah
size_t length() override { return SDL_RWsize(handle); }
size_t position() override { return SDL_RWtell(handle); }
size_t seek(size_t position) override { return SDL_RWseek(handle, position, RW_SEEK_SET); }
size_t read(unsigned char* buffer, size_t length) override { return SDL_RWread(handle, buffer, sizeof(char), length); }
size_t write(const unsigned char* buffer, size_t length) override { return SDL_RWwrite(handle, buffer, sizeof(char), length); }
size_t read(void* buffer, size_t length) override { return SDL_RWread(handle, buffer, sizeof(char), length); }
size_t write(const void* buffer, size_t length) override { return SDL_RWwrite(handle, buffer, sizeof(char), length); }
};
struct SDL2_Platform : public Platform

View File

@ -44,8 +44,8 @@ namespace Blah
size_t length() override;
size_t position() override;
size_t seek(size_t position) override;
size_t read(unsigned char* buffer, size_t length) override;
size_t write(const unsigned char* buffer, size_t length) override;
size_t read(void* buffer, size_t length) override;
size_t write(const void* buffer, size_t length) override;
};
struct Win32_Platform : public Platform
@ -181,7 +181,7 @@ size_t Win32File::seek(size_t position)
return result.QuadPart;
}
size_t Win32File::read(unsigned char* buffer, size_t length)
size_t Win32File::read(void* buffer, size_t length)
{
static const DWORD read_step = 65536;
@ -204,7 +204,7 @@ size_t Win32File::read(unsigned char* buffer, size_t length)
return read;
}
size_t Win32File::write(const unsigned char* buffer, size_t length)
size_t Win32File::write(const void* buffer, size_t length)
{
static const DWORD write_step = 65536;

View File

@ -1,11 +1,6 @@
#pragma once
#include <blah/app.h>
#include <blah/graphics/renderpass.h>
#include <blah/graphics/texture.h>
#include <blah/graphics/target.h>
#include <blah/graphics/shader.h>
#include <blah/graphics/mesh.h>
#include <blah/graphics/material.h>
#include <blah/graphics.h>
#include <blah/math/color.h>
namespace Blah
@ -38,7 +33,7 @@ namespace Blah
virtual void after_render() = 0;
// Performs a draw call
virtual void render(const RenderPass& pass) = 0;
virtual void render(const DrawCall& pass) = 0;
// Clears the backbuffer
virtual void clear_backbuffer(Color color, float depth, u8 stencil, ClearMask mask) = 0;

View File

@ -136,7 +136,7 @@ namespace Blah
void update() override;
void before_render() override;
void after_render() override;
void render(const RenderPass& pass) override;
void render(const DrawCall& pass) override;
void clear_backbuffer(Color color, float depth, u8 stencil, ClearMask mask) override;
TextureRef create_texture(int width, int height, TextureFormat format) override;
TargetRef create_target(int width, int height, const TextureFormat* attachments, int attachment_count) override;
@ -145,9 +145,9 @@ namespace Blah
ID3D11InputLayout* get_layout(D3D11_Shader* shader, const VertexFormat& format);
ID3D11BlendState* get_blend(const BlendMode& blend);
ID3D11RasterizerState* get_rasterizer(const RenderPass& pass);
ID3D11RasterizerState* get_rasterizer(const DrawCall& pass);
ID3D11SamplerState* get_sampler(const TextureSampler& sampler);
ID3D11DepthStencilState* get_depthstencil(const RenderPass& pass);
ID3D11DepthStencilState* get_depthstencil(const DrawCall& pass);
};
// Utility Methods
@ -947,7 +947,7 @@ namespace Blah
return MeshRef(new D3D11_Mesh());
}
void Renderer_D3D11::render(const RenderPass& pass)
void Renderer_D3D11::render(const DrawCall& pass)
{
auto ctx = context;
auto mesh = (D3D11_Mesh*)pass.mesh.get();
@ -1531,7 +1531,7 @@ namespace Blah
return nullptr;
}
ID3D11RasterizerState* Renderer_D3D11::get_rasterizer(const RenderPass& pass)
ID3D11RasterizerState* Renderer_D3D11::get_rasterizer(const DrawCall& pass)
{
for (auto& it : rasterizer_cache)
if (it.cull == pass.cull && it.has_scissor == pass.has_scissor)
@ -1572,7 +1572,7 @@ namespace Blah
return nullptr;
}
ID3D11DepthStencilState* Renderer_D3D11::get_depthstencil(const RenderPass& pass)
ID3D11DepthStencilState* Renderer_D3D11::get_depthstencil(const DrawCall& pass)
{
for (auto& it : depthstencil_cache)
if (it.depth == pass.depth)

View File

@ -418,7 +418,7 @@ namespace Blah
void update() override;
void before_render() override;
void after_render() override;
void render(const RenderPass& pass) override;
void render(const DrawCall& pass) override;
void clear_backbuffer(Color color, float depth, u8 stencil, ClearMask mask) override;
TextureRef create_texture(int width, int height, TextureFormat format) override;
TargetRef create_target(int width, int height, const TextureFormat* attachments, int attachment_count) override;
@ -1272,7 +1272,7 @@ namespace Blah
return MeshRef(resource);
}
void Renderer_OpenGL::render(const RenderPass& pass)
void Renderer_OpenGL::render(const DrawCall& pass)
{
// Bind the Target
if (pass.target == App::backbuffer())