mirror of
https://github.com/NoelFB/blah.git
synced 2024-11-25 16:18:57 +08:00
removed drawing folder; moved to graphics
This commit is contained in:
parent
a001a61847
commit
9e3f745a38
|
@ -11,13 +11,16 @@ add_library(blah
|
|||
src/core/filesystem.cpp
|
||||
src/core/common.cpp
|
||||
src/core/time.cpp
|
||||
|
||||
|
||||
src/graphics/batch.cpp
|
||||
src/graphics/blend.cpp
|
||||
src/graphics/framebuffer.cpp
|
||||
src/graphics/material.cpp
|
||||
src/graphics/mesh.cpp
|
||||
src/graphics/renderpass.cpp
|
||||
src/graphics/shader.cpp
|
||||
src/graphics/spritefont.cpp
|
||||
src/graphics/subtexture.cpp
|
||||
src/graphics/texture.cpp
|
||||
|
||||
src/input/input.cpp
|
||||
|
@ -25,10 +28,6 @@ add_library(blah
|
|||
src/input/binding_registry.cpp
|
||||
|
||||
src/containers/str.cpp
|
||||
|
||||
src/drawing/batch.cpp
|
||||
src/drawing/spritefont.cpp
|
||||
src/drawing/subtexture.cpp
|
||||
|
||||
src/images/aseprite.cpp
|
||||
src/images/font.cpp
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
#include "blah/containers/stackvector.h"
|
||||
#include "blah/containers/str.h"
|
||||
|
||||
#include "blah/drawing/batch.h"
|
||||
#include "blah/drawing/spritefont.h"
|
||||
#include "blah/drawing/subtexture.h"
|
||||
#include "blah/graphics/batch.h"
|
||||
#include "blah/graphics/spritefont.h"
|
||||
#include "blah/graphics/subtexture.h"
|
||||
|
||||
#include "blah/graphics/blend.h"
|
||||
#include "blah/graphics/framebuffer.h"
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace Blah
|
|||
class StrOf;
|
||||
using String = StrOf<64>;
|
||||
|
||||
// A simple String implementation
|
||||
class Str
|
||||
{
|
||||
public:
|
||||
|
@ -138,8 +139,10 @@ namespace Blah
|
|||
// returns a substring of the string
|
||||
String substr(int start, int end) const;
|
||||
|
||||
// Splits the string into a vector of strings
|
||||
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);
|
||||
|
||||
// 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
|
||||
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))); }
|
||||
|
||||
// assigns the contents of the string
|
||||
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);
|
||||
|
||||
private:
|
||||
|
@ -187,6 +195,7 @@ namespace Blah
|
|||
// combine string
|
||||
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>
|
||||
class StrOf : public Str
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
namespace Blah
|
||||
{
|
||||
// A lightweight Vector implementation
|
||||
template<class T>
|
||||
class Vector
|
||||
{
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include <blah/math/mat3x2.h>
|
||||
#include <blah/math/mat4x4.h>
|
||||
#include <blah/math/color.h>
|
||||
#include <blah/drawing/subtexture.h>
|
||||
#include <blah/drawing/spritefont.h>
|
||||
#include <blah/graphics/subtexture.h>
|
||||
#include <blah/graphics/spritefont.h>
|
||||
#include <blah/containers/vector.h>
|
||||
#include <blah/graphics/blend.h>
|
||||
#include <blah/graphics/sampler.h>
|
||||
|
@ -15,9 +15,14 @@
|
|||
|
||||
namespace Blah
|
||||
{
|
||||
// Spritebatcher Color Mode
|
||||
enum class ColorMode
|
||||
{
|
||||
// Draws textures and shapes normally
|
||||
Normal,
|
||||
|
||||
// Ignores the texture color but still uses transparency, essentially
|
||||
// drawing the "shape" of the texture a solid color
|
||||
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)); }
|
||||
|
||||
// A simple 2D sprite batcher, used for drawing shapes and textures
|
||||
// A 2D sprite batcher, used for drawing shapes and textures
|
||||
class Batch
|
||||
{
|
||||
public:
|
|
@ -46,6 +46,7 @@ namespace Blah
|
|||
RGBA = Red | Green | Blue | Alpha,
|
||||
};
|
||||
|
||||
// BlendMode using for rendering
|
||||
struct BlendMode
|
||||
{
|
||||
// Normal, pre-multiplied, Blend Mode
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
namespace Blah
|
||||
{
|
||||
// Supported Vertex value types
|
||||
enum class VertexType
|
||||
{
|
||||
None,
|
||||
|
@ -20,6 +21,7 @@ namespace Blah
|
|||
UShort4
|
||||
};
|
||||
|
||||
// Vertex Attribute information
|
||||
struct VertexAttribute
|
||||
{
|
||||
// Location / Attribute Index
|
||||
|
@ -32,6 +34,8 @@ namespace Blah
|
|||
bool normalized = false;
|
||||
};
|
||||
|
||||
// Vertex Format information.
|
||||
// Holds a list of attributes and total stride per-vertex.
|
||||
struct VertexFormat
|
||||
{
|
||||
// List of Attributes
|
||||
|
@ -44,9 +48,13 @@ namespace Blah
|
|||
VertexFormat(std::initializer_list<VertexAttribute> attributes, int stride = 0);
|
||||
};
|
||||
|
||||
// Supported Vertex Index formats
|
||||
enum class IndexFormat
|
||||
{
|
||||
// Indices are 16 bit unsigned integers
|
||||
UInt16,
|
||||
|
||||
// Indices are 32 bit unsigned integers
|
||||
UInt32
|
||||
};
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace Blah
|
||||
{
|
||||
// Depth comparison function to use during a draw call
|
||||
enum class Compare
|
||||
{
|
||||
None,
|
||||
|
@ -24,10 +25,16 @@ namespace Blah
|
|||
GreatorOrEqual
|
||||
};
|
||||
|
||||
// Cull mode during a draw call
|
||||
enum class Cull
|
||||
{
|
||||
// No Culling enabled
|
||||
None = 0,
|
||||
|
||||
// Cull front faces
|
||||
Front = 1,
|
||||
|
||||
// Cull back faces
|
||||
Back = 2,
|
||||
};
|
||||
|
||||
|
|
|
@ -2,24 +2,42 @@
|
|||
|
||||
namespace Blah
|
||||
{
|
||||
// Texture filter
|
||||
enum class TextureFilter
|
||||
{
|
||||
// None will fallback to whatever default the driver sets
|
||||
None,
|
||||
|
||||
// Linear interpolation
|
||||
Linear,
|
||||
|
||||
// Nearest Neighbour interpolation
|
||||
Nearest
|
||||
};
|
||||
|
||||
// Texture Wrap Mode
|
||||
enum class TextureWrap
|
||||
{
|
||||
// None will fallback to whatever default the driver sets
|
||||
None,
|
||||
|
||||
// Clamps the texture to the edges
|
||||
Clamp,
|
||||
|
||||
// Repeats the texture
|
||||
Repeat
|
||||
};
|
||||
|
||||
// Texture Sampler State, applied during rendering
|
||||
struct TextureSampler
|
||||
{
|
||||
// Filter Mode
|
||||
TextureFilter filter;
|
||||
|
||||
// Wrap X Mode
|
||||
TextureWrap wrap_x;
|
||||
|
||||
// Wrap Y Mode
|
||||
TextureWrap wrap_y;
|
||||
|
||||
TextureSampler() :
|
||||
|
|
|
@ -72,6 +72,7 @@ namespace Blah
|
|||
class Shader;
|
||||
typedef std::shared_ptr<Shader> ShaderRef;
|
||||
|
||||
// A shader used during Rendering
|
||||
class Shader
|
||||
{
|
||||
protected:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <blah/core/common.h>
|
||||
#include <blah/containers/str.h>
|
||||
#include <blah/containers/vector.h>
|
||||
#include <blah/drawing/subtexture.h>
|
||||
#include <blah/graphics/subtexture.h>
|
||||
#include <blah/math/vec2.h>
|
||||
#include <blah/core/filesystem.h>
|
||||
#include <unordered_map>
|
|
@ -5,11 +5,22 @@ namespace Blah
|
|||
{
|
||||
enum class TextureFormat
|
||||
{
|
||||
// Invalid Format
|
||||
None,
|
||||
|
||||
// Single 8-bit channe;
|
||||
R,
|
||||
|
||||
// 2 8-bit channels
|
||||
RG,
|
||||
|
||||
// 4 8-bit channels
|
||||
RGBA,
|
||||
|
||||
// Depth 24, Stencil 8
|
||||
DepthStencil,
|
||||
|
||||
// Total Formats
|
||||
Count
|
||||
};
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ namespace Blah
|
|||
{
|
||||
class Stream;
|
||||
|
||||
// A simple 2D Bitmap
|
||||
// A 2D Bitmap stored on the CPU.
|
||||
// For drawing images to the screen, use a Texture.
|
||||
class Image
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
namespace Blah
|
||||
{
|
||||
// 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
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <blah/drawing/batch.h>
|
||||
#include <blah/graphics/batch.h>
|
||||
#include <blah/graphics/texture.h>
|
||||
#include <blah/graphics/framebuffer.h>
|
||||
#include <blah/graphics/mesh.h>
|
|
@ -1,4 +1,4 @@
|
|||
#include <blah/drawing/spritefont.h>
|
||||
#include <blah/graphics/spritefont.h>
|
||||
#include <blah/images/font.h>
|
||||
#include <blah/images/packer.h>
|
||||
#include <blah/core/common.h>
|
|
@ -1,4 +1,4 @@
|
|||
#include <blah/drawing/subtexture.h>
|
||||
#include <blah/graphics/subtexture.h>
|
||||
#include <blah/math/calc.h>
|
||||
|
||||
using namespace Blah;
|
Loading…
Reference in New Issue
Block a user