removed drawing folder; moved to graphics

This commit is contained in:
Noel Berry 2021-03-22 16:53:27 -07:00
parent a001a61847
commit 9e3f745a38
18 changed files with 78 additions and 17 deletions

View File

@ -11,13 +11,16 @@ add_library(blah
src/core/filesystem.cpp src/core/filesystem.cpp
src/core/common.cpp src/core/common.cpp
src/core/time.cpp src/core/time.cpp
src/graphics/batch.cpp
src/graphics/blend.cpp src/graphics/blend.cpp
src/graphics/framebuffer.cpp src/graphics/framebuffer.cpp
src/graphics/material.cpp src/graphics/material.cpp
src/graphics/mesh.cpp src/graphics/mesh.cpp
src/graphics/renderpass.cpp src/graphics/renderpass.cpp
src/graphics/shader.cpp src/graphics/shader.cpp
src/graphics/spritefont.cpp
src/graphics/subtexture.cpp
src/graphics/texture.cpp src/graphics/texture.cpp
src/input/input.cpp src/input/input.cpp
@ -25,10 +28,6 @@ add_library(blah
src/input/binding_registry.cpp src/input/binding_registry.cpp
src/containers/str.cpp src/containers/str.cpp
src/drawing/batch.cpp
src/drawing/spritefont.cpp
src/drawing/subtexture.cpp
src/images/aseprite.cpp src/images/aseprite.cpp
src/images/font.cpp src/images/font.cpp

View File

@ -9,9 +9,9 @@
#include "blah/containers/stackvector.h" #include "blah/containers/stackvector.h"
#include "blah/containers/str.h" #include "blah/containers/str.h"
#include "blah/drawing/batch.h" #include "blah/graphics/batch.h"
#include "blah/drawing/spritefont.h" #include "blah/graphics/spritefont.h"
#include "blah/drawing/subtexture.h" #include "blah/graphics/subtexture.h"
#include "blah/graphics/blend.h" #include "blah/graphics/blend.h"
#include "blah/graphics/framebuffer.h" #include "blah/graphics/framebuffer.h"

View File

@ -10,6 +10,7 @@ namespace Blah
class StrOf; class StrOf;
using String = StrOf<64>; using String = StrOf<64>;
// A simple String implementation
class Str class Str
{ {
public: public:
@ -138,8 +139,10 @@ namespace Blah
// returns a substring of the string // returns a substring of the string
String substr(int start, int end) const; String substr(int start, int end) const;
// Splits the string into a vector of strings
Vector<String> split(char ch) const; Vector<String> split(char ch) const;
// replaces all occurances of old string with the new string
Str& replace(const Str& old_str, const Str& new_str); Str& replace(const Str& old_str, const Str& new_str);
// replaces all occurances of the given character in the string // replaces all occurances of the given character in the string
@ -171,9 +174,14 @@ namespace Blah
// returns a pointer to the heap buffer or to our stack allocation // returns a pointer to the heap buffer or to our stack allocation
char* data() { return (m_buffer != nullptr ? m_buffer : ((char*)(this) + sizeof(Str))); } char* data() { return (m_buffer != nullptr ? m_buffer : ((char*)(this) + sizeof(Str))); }
// returns a pointer to the heap buffer or to our stack allocation
const char* data() const { return (m_buffer != nullptr ? m_buffer : ((char*)(this) + sizeof(Str))); } const char* data() const { return (m_buffer != nullptr ? m_buffer : ((char*)(this) + sizeof(Str))); }
// assigns the contents of the string
void set(const Str& str) { set(str.cstr(), str.cstr() + str.m_length); } void set(const Str& str) { set(str.cstr(), str.cstr() + str.m_length); }
// assigns the contents of the string
void set(const char* start, const char* end = nullptr); void set(const char* start, const char* end = nullptr);
private: private:
@ -187,6 +195,7 @@ namespace Blah
// combine string // combine string
inline Str operator+(const Str& lhs, const Str& rhs) { Str str; str.append(lhs).append(rhs); return str; } inline Str operator+(const Str& lhs, const Str& rhs) { Str str; str.append(lhs).append(rhs); return str; }
// A string with a local stack buffer of size T
template<int T> template<int T>
class StrOf : public Str class StrOf : public Str
{ {

View File

@ -6,6 +6,7 @@
namespace Blah namespace Blah
{ {
// A lightweight Vector implementation
template<class T> template<class T>
class Vector class Vector
{ {

View File

@ -5,8 +5,8 @@
#include <blah/math/mat3x2.h> #include <blah/math/mat3x2.h>
#include <blah/math/mat4x4.h> #include <blah/math/mat4x4.h>
#include <blah/math/color.h> #include <blah/math/color.h>
#include <blah/drawing/subtexture.h> #include <blah/graphics/subtexture.h>
#include <blah/drawing/spritefont.h> #include <blah/graphics/spritefont.h>
#include <blah/containers/vector.h> #include <blah/containers/vector.h>
#include <blah/graphics/blend.h> #include <blah/graphics/blend.h>
#include <blah/graphics/sampler.h> #include <blah/graphics/sampler.h>
@ -15,9 +15,14 @@
namespace Blah namespace Blah
{ {
// Spritebatcher Color Mode
enum class ColorMode enum class ColorMode
{ {
// Draws textures and shapes normally
Normal, Normal,
// Ignores the texture color but still uses transparency, essentially
// drawing the "shape" of the texture a solid color
Wash Wash
}; };
@ -38,7 +43,7 @@ namespace Blah
inline TextAlign operator|(TextAlign lhs, TextAlign rhs) { return static_cast<TextAlign>(static_cast<char>(lhs) | static_cast<char>(rhs)); } inline TextAlign operator|(TextAlign lhs, TextAlign rhs) { return static_cast<TextAlign>(static_cast<char>(lhs) | static_cast<char>(rhs)); }
inline TextAlign operator&(TextAlign lhs, TextAlign rhs) { return static_cast<TextAlign>(static_cast<char>(lhs) & static_cast<char>(rhs)); } inline TextAlign operator&(TextAlign lhs, TextAlign rhs) { return static_cast<TextAlign>(static_cast<char>(lhs) & static_cast<char>(rhs)); }
// A simple 2D sprite batcher, used for drawing shapes and textures // A 2D sprite batcher, used for drawing shapes and textures
class Batch class Batch
{ {
public: public:

View File

@ -46,6 +46,7 @@ namespace Blah
RGBA = Red | Green | Blue | Alpha, RGBA = Red | Green | Blue | Alpha,
}; };
// BlendMode using for rendering
struct BlendMode struct BlendMode
{ {
// Normal, pre-multiplied, Blend Mode // Normal, pre-multiplied, Blend Mode

View File

@ -5,6 +5,7 @@
namespace Blah namespace Blah
{ {
// Supported Vertex value types
enum class VertexType enum class VertexType
{ {
None, None,
@ -20,6 +21,7 @@ namespace Blah
UShort4 UShort4
}; };
// Vertex Attribute information
struct VertexAttribute struct VertexAttribute
{ {
// Location / Attribute Index // Location / Attribute Index
@ -32,6 +34,8 @@ namespace Blah
bool normalized = false; bool normalized = false;
}; };
// Vertex Format information.
// Holds a list of attributes and total stride per-vertex.
struct VertexFormat struct VertexFormat
{ {
// List of Attributes // List of Attributes
@ -44,9 +48,13 @@ namespace Blah
VertexFormat(std::initializer_list<VertexAttribute> attributes, int stride = 0); VertexFormat(std::initializer_list<VertexAttribute> attributes, int stride = 0);
}; };
// Supported Vertex Index formats
enum class IndexFormat enum class IndexFormat
{ {
// Indices are 16 bit unsigned integers
UInt16, UInt16,
// Indices are 32 bit unsigned integers
UInt32 UInt32
}; };

View File

@ -11,6 +11,7 @@
namespace Blah namespace Blah
{ {
// Depth comparison function to use during a draw call
enum class Compare enum class Compare
{ {
None, None,
@ -24,10 +25,16 @@ namespace Blah
GreatorOrEqual GreatorOrEqual
}; };
// Cull mode during a draw call
enum class Cull enum class Cull
{ {
// No Culling enabled
None = 0, None = 0,
// Cull front faces
Front = 1, Front = 1,
// Cull back faces
Back = 2, Back = 2,
}; };

View File

@ -2,24 +2,42 @@
namespace Blah namespace Blah
{ {
// Texture filter
enum class TextureFilter enum class TextureFilter
{ {
// None will fallback to whatever default the driver sets
None, None,
// Linear interpolation
Linear, Linear,
// Nearest Neighbour interpolation
Nearest Nearest
}; };
// Texture Wrap Mode
enum class TextureWrap enum class TextureWrap
{ {
// None will fallback to whatever default the driver sets
None, None,
// Clamps the texture to the edges
Clamp, Clamp,
// Repeats the texture
Repeat Repeat
}; };
// Texture Sampler State, applied during rendering
struct TextureSampler struct TextureSampler
{ {
// Filter Mode
TextureFilter filter; TextureFilter filter;
// Wrap X Mode
TextureWrap wrap_x; TextureWrap wrap_x;
// Wrap Y Mode
TextureWrap wrap_y; TextureWrap wrap_y;
TextureSampler() : TextureSampler() :

View File

@ -72,6 +72,7 @@ namespace Blah
class Shader; class Shader;
typedef std::shared_ptr<Shader> ShaderRef; typedef std::shared_ptr<Shader> ShaderRef;
// A shader used during Rendering
class Shader class Shader
{ {
protected: protected:

View File

@ -2,7 +2,7 @@
#include <blah/core/common.h> #include <blah/core/common.h>
#include <blah/containers/str.h> #include <blah/containers/str.h>
#include <blah/containers/vector.h> #include <blah/containers/vector.h>
#include <blah/drawing/subtexture.h> #include <blah/graphics/subtexture.h>
#include <blah/math/vec2.h> #include <blah/math/vec2.h>
#include <blah/core/filesystem.h> #include <blah/core/filesystem.h>
#include <unordered_map> #include <unordered_map>

View File

@ -5,11 +5,22 @@ namespace Blah
{ {
enum class TextureFormat enum class TextureFormat
{ {
// Invalid Format
None, None,
// Single 8-bit channe;
R, R,
// 2 8-bit channels
RG, RG,
// 4 8-bit channels
RGBA, RGBA,
// Depth 24, Stencil 8
DepthStencil, DepthStencil,
// Total Formats
Count Count
}; };

View File

@ -8,7 +8,8 @@ namespace Blah
{ {
class Stream; class Stream;
// A simple 2D Bitmap // A 2D Bitmap stored on the CPU.
// For drawing images to the screen, use a Texture.
class Image class Image
{ {
public: public:

View File

@ -11,7 +11,7 @@
namespace Blah namespace Blah
{ {
// Texture Packer, which takes source images and combines // Texture Packer, which takes source images and combines
// them into a single large texture. // them into a single large texture. Useful for 2D sprite batching.
class Packer class Packer
{ {
public: public:

View File

@ -1,4 +1,4 @@
#include <blah/drawing/batch.h> #include <blah/graphics/batch.h>
#include <blah/graphics/texture.h> #include <blah/graphics/texture.h>
#include <blah/graphics/framebuffer.h> #include <blah/graphics/framebuffer.h>
#include <blah/graphics/mesh.h> #include <blah/graphics/mesh.h>

View File

@ -1,4 +1,4 @@
#include <blah/drawing/spritefont.h> #include <blah/graphics/spritefont.h>
#include <blah/images/font.h> #include <blah/images/font.h>
#include <blah/images/packer.h> #include <blah/images/packer.h>
#include <blah/core/common.h> #include <blah/core/common.h>

View File

@ -1,4 +1,4 @@
#include <blah/drawing/subtexture.h> #include <blah/graphics/subtexture.h>
#include <blah/math/calc.h> #include <blah/math/calc.h>
using namespace Blah; using namespace Blah;