mirror of
https://github.com/NoelFB/blah.git
synced 2025-06-29 19:25:26 +08:00
fixing d3d11 depth buffers, adding depth buffer clear support
This commit is contained in:
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user