mirror of
https://github.com/NoelFB/blah.git
synced 2024-11-25 16:18:57 +08:00
commit
7821b0fcf5
|
@ -63,7 +63,7 @@ namespace Blah
|
||||||
AppEventFn on_render = nullptr;
|
AppEventFn on_render = nullptr;
|
||||||
|
|
||||||
// Callback when the user has requested the application close.
|
// Callback when the user has requested the application close.
|
||||||
// For example, pressing the Close button, ALT+F4, etc
|
// For example, pressing the Close button, ALT+F4, etc.
|
||||||
// By default this calls `App::exit()`
|
// By default this calls `App::exit()`
|
||||||
AppEventFn on_exit_request = nullptr;
|
AppEventFn on_exit_request = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
namespace Blah
|
namespace Blah
|
||||||
{
|
{
|
||||||
|
|
||||||
// A 2D sprite batcher, used for drawing shapes and textures
|
// A 2D sprite batcher, used for drawing shapes and textures
|
||||||
class Batch
|
class Batch
|
||||||
{
|
{
|
||||||
|
|
|
@ -135,7 +135,7 @@ namespace Blah
|
||||||
return Vec4f(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
|
return Vec4f(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convers the Color to a u32
|
// Converts the Color to a u32
|
||||||
constexpr u32 to_rgba() const
|
constexpr u32 to_rgba() const
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
|
@ -145,7 +145,7 @@ namespace Blah
|
||||||
(u32)a;
|
(u32)a;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convers the Color to a u32
|
// Converts the Color to a u32
|
||||||
constexpr u32 to_rgb() const
|
constexpr u32 to_rgb() const
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
|
@ -154,7 +154,7 @@ namespace Blah
|
||||||
(u32)b;
|
(u32)b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a RGBA Color representation of the integer value
|
// Returns an RGBA Color representation of the integer value
|
||||||
static constexpr Color from_rgba(u32 value)
|
static constexpr Color from_rgba(u32 value)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
|
@ -166,7 +166,7 @@ namespace Blah
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a RGB Color representation of the integer value, with Alpha = 255
|
// Returns an RGB Color representation of the integer value, with Alpha = 255
|
||||||
static constexpr Color from_rgb(u32 value)
|
static constexpr Color from_rgb(u32 value)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
|
@ -191,7 +191,7 @@ namespace Blah
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mutliplties the Color
|
// Multiples the Color
|
||||||
constexpr Color operator*(float multiply) const
|
constexpr Color operator*(float multiply) const
|
||||||
{
|
{
|
||||||
return Color(
|
return Color(
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace Blah
|
||||||
LessOrEqual,
|
LessOrEqual,
|
||||||
Greater,
|
Greater,
|
||||||
NotEqual,
|
NotEqual,
|
||||||
GreatorOrEqual
|
GreaterOrEqual
|
||||||
};
|
};
|
||||||
|
|
||||||
// Cull mode during a draw call
|
// Cull mode during a draw call
|
||||||
|
@ -210,7 +210,7 @@ namespace Blah
|
||||||
enum class TextureFormat
|
enum class TextureFormat
|
||||||
{
|
{
|
||||||
None, // Invalid Format
|
None, // Invalid Format
|
||||||
R, // Single 8-bit channe;
|
R, // Single 8-bit channel
|
||||||
RG, // 2 8-bit channels
|
RG, // 2 8-bit channels
|
||||||
RGBA, // 4 8-bit channels
|
RGBA, // 4 8-bit channels
|
||||||
DepthStencil, // Depth 24, Stencil 8
|
DepthStencil, // Depth 24, Stencil 8
|
||||||
|
@ -317,10 +317,10 @@ namespace Blah
|
||||||
// Supported Vertex Index formats
|
// Supported Vertex Index formats
|
||||||
enum class IndexFormat
|
enum class IndexFormat
|
||||||
{
|
{
|
||||||
// Indices are 16 bit unsigned integers
|
// Indices are 16-bit unsigned integers
|
||||||
UInt16,
|
UInt16,
|
||||||
|
|
||||||
// Indices are 32 bit unsigned integers
|
// Indices are 32-bit unsigned integers
|
||||||
UInt32
|
UInt32
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace Blah
|
||||||
int padding;
|
int padding;
|
||||||
|
|
||||||
// generated textures. There can be more than one if the packer was
|
// generated textures. There can be more than one if the packer was
|
||||||
// unable to fit all of the provided subtextures into the max_size.
|
// unable to fit all the provided subtextures into the max_size.
|
||||||
Vector<Image> pages;
|
Vector<Image> pages;
|
||||||
|
|
||||||
Packer();
|
Packer();
|
||||||
|
|
|
@ -14,7 +14,7 @@ using namespace Blah;
|
||||||
|
|
||||||
#define BLAH_ASSERT_RUNNING() BLAH_ASSERT(app_is_running, "The App is not running (call App::run)")
|
#define BLAH_ASSERT_RUNNING() BLAH_ASSERT(app_is_running, "The App is not running (call App::run)")
|
||||||
|
|
||||||
// Interal Platform Pointer
|
// Internal Platform Pointer
|
||||||
Platform* App::Internal::platform = nullptr;
|
Platform* App::Internal::platform = nullptr;
|
||||||
|
|
||||||
// Internal Renderer Pointer
|
// Internal Renderer Pointer
|
||||||
|
|
|
@ -160,7 +160,7 @@ bool Font::get_image(const Font::Character& ch, Color* pixels) const
|
||||||
if (ch.has_glyph)
|
if (ch.has_glyph)
|
||||||
{
|
{
|
||||||
// we actually use the image buffer as our temporary buffer, and fill the pixels out backwards after
|
// we actually use the image buffer as our temporary buffer, and fill the pixels out backwards after
|
||||||
// kinda weird but it works & saves creating more memory
|
// kinda weird, but it works & saves creating more memory
|
||||||
auto* src = (unsigned char*)pixels;
|
auto* src = (unsigned char*)pixels;
|
||||||
stbtt_MakeGlyphBitmap((stbtt_fontinfo*)m_font.get(), src, ch.width, ch.height, ch.width, ch.scale, ch.scale, ch.glyph);
|
stbtt_MakeGlyphBitmap((stbtt_fontinfo*)m_font.get(), src, ch.width, ch.height, ch.width, ch.scale, ch.scale, ch.glyph);
|
||||||
|
|
||||||
|
|
|
@ -230,7 +230,6 @@ MeshRef Mesh::create()
|
||||||
return MeshRef();
|
return MeshRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
int blah_calc_uniform_size(const UniformInfo& uniform)
|
int blah_calc_uniform_size(const UniformInfo& uniform)
|
||||||
|
|
|
@ -256,7 +256,7 @@ bool Image::save_jpg(Stream& stream, int quality) const
|
||||||
|
|
||||||
void Image::get_pixels(Color* dest, const Point& dest_pos, const Point& dest_size, Recti source_rect) const
|
void Image::get_pixels(Color* dest, const Point& dest_pos, const Point& dest_size, Recti source_rect) const
|
||||||
{
|
{
|
||||||
// can't be outside of the source image
|
// can't be outside the source image
|
||||||
if (source_rect.x < 0) source_rect.x = 0;
|
if (source_rect.x < 0) source_rect.x = 0;
|
||||||
if (source_rect.y < 0) source_rect.y = 0;
|
if (source_rect.y < 0) source_rect.y = 0;
|
||||||
if (source_rect.x + source_rect.w > width) source_rect.w = width - source_rect.x;
|
if (source_rect.x + source_rect.w > width) source_rect.w = width - source_rect.x;
|
||||||
|
|
|
@ -423,7 +423,6 @@ StickBindingRef Input::register_binding(const StickBinding& binding_data)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ButtonBinding::TriggerBind::TriggerBind(Axis axis)
|
ButtonBinding::TriggerBind::TriggerBind(Axis axis)
|
||||||
: axis(axis)
|
: axis(axis)
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace Blah
|
||||||
// Gets the Desktop Content Scale. Gui should be scaled by this value
|
// Gets the Desktop Content Scale. Gui should be scaled by this value
|
||||||
virtual float get_content_scale() = 0;
|
virtual float get_content_scale() = 0;
|
||||||
|
|
||||||
// Returns the absoluate path to the directory that the application was started from
|
// Returns the absolute path to the directory that the application was started from
|
||||||
virtual const char* app_path() = 0;
|
virtual const char* app_path() = 0;
|
||||||
|
|
||||||
// Returns the absolute path to the user directory where save data and settings should be stored
|
// Returns the absolute path to the user directory where save data and settings should be stored
|
||||||
|
|
|
@ -439,7 +439,7 @@ void SDL2_Platform::present()
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
|
|
||||||
// display the window
|
// display the window
|
||||||
// this avoids a short black screen on macoS
|
// this avoids a short black screen on macOS
|
||||||
if (!displayed)
|
if (!displayed)
|
||||||
{
|
{
|
||||||
SDL_ShowWindow(window);
|
SDL_ShowWindow(window);
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace Blah
|
||||||
virtual void set_app_flags(u32 flags) { }
|
virtual void set_app_flags(u32 flags) { }
|
||||||
|
|
||||||
// Optional implementation to get the drawable backbuffer size in pixels.
|
// Optional implementation to get the drawable backbuffer size in pixels.
|
||||||
// Not all implementations will use this so it can be up to the Platform.
|
// Not all implementations will use this, so it can be up to the Platform.
|
||||||
virtual bool get_draw_size(int* w, int* h) { return false; }
|
virtual bool get_draw_size(int* w, int* h) { return false; }
|
||||||
|
|
||||||
// Performs a draw call
|
// Performs a draw call
|
||||||
|
|
|
@ -785,7 +785,7 @@ namespace Blah
|
||||||
flags |= D3D11_CREATE_DEVICE_DEBUG;
|
flags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Create D3D device & context & swap cahin
|
// Create D3D device & context & swap chain
|
||||||
D3D_FEATURE_LEVEL feature_level;
|
D3D_FEATURE_LEVEL feature_level;
|
||||||
HRESULT hr = D3D11CreateDeviceAndSwapChain(
|
HRESULT hr = D3D11CreateDeviceAndSwapChain(
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -1625,7 +1625,7 @@ namespace Blah
|
||||||
case Compare::LessOrEqual: desc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; break;
|
case Compare::LessOrEqual: desc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; break;
|
||||||
case Compare::Greater: desc.DepthFunc = D3D11_COMPARISON_GREATER; break;
|
case Compare::Greater: desc.DepthFunc = D3D11_COMPARISON_GREATER; break;
|
||||||
case Compare::NotEqual: desc.DepthFunc = D3D11_COMPARISON_NOT_EQUAL; break;
|
case Compare::NotEqual: desc.DepthFunc = D3D11_COMPARISON_NOT_EQUAL; break;
|
||||||
case Compare::GreatorOrEqual: desc.DepthFunc = D3D11_COMPARISON_GREATER_EQUAL; break;
|
case Compare::GreaterOrEqual: desc.DepthFunc = D3D11_COMPARISON_GREATER_EQUAL; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11DepthStencilState* result;
|
ID3D11DepthStencilState* result;
|
||||||
|
|
|
@ -1448,7 +1448,7 @@ namespace Blah
|
||||||
case Compare::Greater:
|
case Compare::Greater:
|
||||||
renderer->gl.DepthFunc(GL_GREATER);
|
renderer->gl.DepthFunc(GL_GREATER);
|
||||||
break;
|
break;
|
||||||
case Compare::GreatorOrEqual:
|
case Compare::GreaterOrEqual:
|
||||||
renderer->gl.DepthFunc(GL_GEQUAL);
|
renderer->gl.DepthFunc(GL_GEQUAL);
|
||||||
break;
|
break;
|
||||||
case Compare::Less:
|
case Compare::Less:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user