fixing d3d11 depth buffers, adding depth buffer clear support

This commit is contained in:
Noel Berry
2021-02-21 23:00:37 -08:00
parent a72cd5cab6
commit 2de541fb18
10 changed files with 198 additions and 27 deletions

View File

@ -14,6 +14,15 @@ namespace Blah
class FrameBuffer;
typedef std::shared_ptr<FrameBuffer> FrameBufferRef;
enum class ClearMask
{
None = 0,
Color = 1,
Depth = 2,
Stencil = 4,
All = (int)Color | (int)Depth | (int)Stencil
};
class FrameBuffer
{
protected:
@ -56,7 +65,7 @@ namespace Blah
virtual int height() const = 0;
// Clears the FrameBuffer
virtual void clear(Color color) = 0;
virtual void clear(Color color = Color::black, float depth = 1.0f, uint8_t stencil = 0, ClearMask mask = ClearMask::All) = 0;
};
}

View File

@ -61,6 +61,8 @@ namespace Blah
float cos(float x);
float tan(float x);
float atan2(float y, float x);
float pow(float x, float n);

View File

@ -1,4 +1,5 @@
#pragma once
#include "vec3.h"
namespace Blah
{
@ -36,8 +37,11 @@ namespace Blah
static Mat4x4 create_ortho(float width, float height, float z_near_plane, float z_far_plane);
static Mat4x4 create_ortho_offcenter(float left, float right, float bottom, float top, float z_near_plane, float z_far_plane);
static Mat4x4 create_perspective(float field_of_view, float ratio, float z_near_plane, float z_far_plane);
static Mat4x4 create_translation(float x, float y, float z);
static Mat4x4 create_scale(float x, float y, float z);
static Mat4x4 create_lookat(Vec3 position, Vec3 target, Vec3 up);
Mat4x4 operator* (const Mat4x4& rhs);
};

View File

@ -1,4 +1,5 @@
#pragma once
#include "calc.h"
namespace Blah
{
@ -19,5 +20,37 @@ namespace Blah
, y(y)
, z(z)
{}
inline Vec3 operator +(const Vec3 rhs) const
{
return Vec3(x + rhs.x, y + rhs.y, z + rhs.z);
}
inline Vec3 operator -(const Vec3 rhs) const
{
return Vec3(x + rhs.x, y + rhs.y, z + rhs.z);
}
inline Vec3 normal() const
{
float ls = x * x + y * y + z * z;
float length = (float)Calc::sqrt(ls);
return Vec3(x / length, y / length, z / length);
}
static inline float dot(Vec3 a, Vec3 b)
{
return a.x * b.x +
a.y * b.y +
a.z * b.z;
}
static inline Vec3 cross(Vec3 a, Vec3 b)
{
return Vec3(
a.y * b.z - a.z * b.y,
a.z * b.x - a.x * b.z,
a.x * b.y - a.y * b.x);
}
};
}