mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 14:43:34 +00:00
fixing vicious bug in scene code
This commit is contained in:
2
Makefile
2
Makefile
@@ -38,7 +38,7 @@ GCH = runtime/Includes/PreCompiled.h.gch
|
|||||||
CCH = runtime/Includes/PreCompiled.h.pch
|
CCH = runtime/Includes/PreCompiled.h.pch
|
||||||
PCH =
|
PCH =
|
||||||
|
|
||||||
NZRRC ?= nzslc
|
NZSLC ?= nzslc
|
||||||
|
|
||||||
ifeq ($(TOOLCHAIN), gcc)
|
ifeq ($(TOOLCHAIN), gcc)
|
||||||
CXX = g++
|
CXX = g++
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ int main(void)
|
|||||||
mlx.logo_jpg = mlx_new_image_from_file(mlx.mlx, "42_logo.jpg", &dummy, &dummy);
|
mlx.logo_jpg = mlx_new_image_from_file(mlx.mlx, "42_logo.jpg", &dummy, &dummy);
|
||||||
|
|
||||||
mlx_pixel_put(mlx.mlx, mlx.win, 200, 10, (mlx_color){ .rgba = 0xFF00FFFF });
|
mlx_pixel_put(mlx.mlx, mlx.win, 200, 10, (mlx_color){ .rgba = 0xFF00FFFF });
|
||||||
mlx_put_image_to_window(mlx.mlx, mlx.win, mlx.logo_png, 10, 190);
|
mlx_put_image_to_window(mlx.mlx, mlx.win, mlx.logo_png, 0, 0);
|
||||||
|
|
||||||
mlx.img = create_image(&mlx);
|
mlx.img = create_image(&mlx);
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ namespace mlx
|
|||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
NonOwningPtr<Sprite> sprite = p_scene->GetSpriteFromTexturePositionScaleRotation(texture, Vec2f{ static_cast<float>(x), static_cast<float>(y) }, scale_x, scale_y, angle);
|
NonOwningPtr<Sprite> sprite = p_scene->GetSpriteFromTexturePositionScaleRotation(texture, Vec2f{ static_cast<float>(x), static_cast<float>(y) }, scale_x, scale_y, angle);
|
||||||
|
std::cout << sprite.Get() << std::endl;
|
||||||
if(!sprite)
|
if(!sprite)
|
||||||
{
|
{
|
||||||
if(m_pixelput_called)
|
if(m_pixelput_called)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ external
|
|||||||
[entry(vert)]
|
[entry(vert)]
|
||||||
fn main(input: VertIn) -> VertOut
|
fn main(input: VertIn) -> VertOut
|
||||||
{
|
{
|
||||||
let position: vec4[f32] = vec4[f32](input.pos.xy, 1.0, 1.0);
|
let position: vec4[f32] = vec4[f32](input.pos.xy, 0.0, 1.0);
|
||||||
input.uv *= -1.0;
|
input.uv *= -1.0;
|
||||||
let output: VertOut;
|
let output: VertOut;
|
||||||
output.uv = input.uv;
|
output.uv = input.uv;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
3,2,35,7,0,0,1,0,39,0,0,0,70,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,14,0,
|
3,2,35,7,0,0,1,0,39,0,0,0,71,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,14,0,
|
||||||
3,0,0,0,0,0,1,0,0,0,15,0,10,0,0,0,0,0,34,0,0,0,109,97,105,110,0,0,0,0,
|
3,0,0,0,0,0,1,0,0,0,15,0,10,0,0,0,0,0,35,0,0,0,109,97,105,110,0,0,0,0,
|
||||||
13,0,0,0,19,0,0,0,25,0,0,0,27,0,0,0,28,0,0,0,3,0,3,0,0,0,0,0,100,0,
|
13,0,0,0,19,0,0,0,25,0,0,0,27,0,0,0,28,0,0,0,3,0,3,0,0,0,0,0,100,0,
|
||||||
0,0,5,0,5,0,4,0,0,0,86,105,101,119,101,114,68,97,116,97,0,0,6,0,8,0,4,0,0,0,
|
0,0,5,0,5,0,4,0,0,0,86,105,101,119,101,114,68,97,116,97,0,0,6,0,8,0,4,0,0,0,
|
||||||
0,0,0,0,112,114,111,106,101,99,116,105,111,110,95,109,97,116,114,105,120,0,0,0,5,0,5,0,7,0,
|
0,0,0,0,112,114,111,106,101,99,116,105,111,110,95,109,97,116,114,105,120,0,0,0,5,0,5,0,7,0,
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
5,0,6,0,0,0,118,105,101,119,101,114,95,100,97,116,97,0,5,0,4,0,9,0,0,0,109,111,100,101,
|
5,0,6,0,0,0,118,105,101,119,101,114,95,100,97,116,97,0,5,0,4,0,9,0,0,0,109,111,100,101,
|
||||||
108,0,0,0,5,0,3,0,13,0,0,0,112,111,115,0,5,0,3,0,19,0,0,0,117,118,0,0,5,0,
|
108,0,0,0,5,0,3,0,13,0,0,0,112,111,115,0,5,0,3,0,19,0,0,0,117,118,0,0,5,0,
|
||||||
4,0,25,0,0,0,99,111,108,111,114,0,0,0,5,0,3,0,27,0,0,0,117,118,0,0,5,0,5,0,
|
4,0,25,0,0,0,99,111,108,111,114,0,0,0,5,0,3,0,27,0,0,0,117,118,0,0,5,0,5,0,
|
||||||
28,0,0,0,112,111,115,105,116,105,111,110,0,0,0,0,5,0,4,0,34,0,0,0,109,97,105,110,0,0,
|
28,0,0,0,112,111,115,105,116,105,111,110,0,0,0,0,5,0,4,0,35,0,0,0,109,97,105,110,0,0,
|
||||||
0,0,71,0,4,0,6,0,0,0,33,0,0,0,0,0,0,0,71,0,4,0,6,0,0,0,34,0,0,0,
|
0,0,71,0,4,0,6,0,0,0,33,0,0,0,0,0,0,0,71,0,4,0,6,0,0,0,34,0,0,0,
|
||||||
0,0,0,0,71,0,4,0,28,0,0,0,11,0,0,0,0,0,0,0,71,0,4,0,13,0,0,0,30,0,
|
0,0,0,0,71,0,4,0,28,0,0,0,11,0,0,0,0,0,0,0,71,0,4,0,13,0,0,0,30,0,
|
||||||
0,0,0,0,0,0,71,0,4,0,19,0,0,0,30,0,0,0,1,0,0,0,71,0,4,0,25,0,0,0,
|
0,0,0,0,0,0,71,0,4,0,19,0,0,0,30,0,0,0,1,0,0,0,71,0,4,0,25,0,0,0,
|
||||||
@@ -37,35 +37,36 @@
|
|||||||
2,0,0,0,17,0,0,0,32,0,4,0,23,0,0,0,7,0,0,0,22,0,0,0,32,0,4,0,24,0,
|
2,0,0,0,17,0,0,0,32,0,4,0,23,0,0,0,7,0,0,0,22,0,0,0,32,0,4,0,24,0,
|
||||||
0,0,3,0,0,0,2,0,0,0,32,0,4,0,26,0,0,0,3,0,0,0,17,0,0,0,30,0,5,0,
|
0,0,3,0,0,0,2,0,0,0,32,0,4,0,26,0,0,0,3,0,0,0,17,0,0,0,30,0,5,0,
|
||||||
29,0,0,0,2,0,0,0,17,0,0,0,2,0,0,0,43,0,4,0,1,0,0,0,30,0,0,0,0,0,
|
29,0,0,0,2,0,0,0,17,0,0,0,2,0,0,0,43,0,4,0,1,0,0,0,30,0,0,0,0,0,
|
||||||
128,63,43,0,4,0,1,0,0,0,31,0,0,0,0,0,128,191,32,0,4,0,32,0,0,0,7,0,0,0,
|
0,0,43,0,4,0,1,0,0,0,31,0,0,0,0,0,128,63,43,0,4,0,1,0,0,0,32,0,0,0,
|
||||||
29,0,0,0,43,0,4,0,14,0,0,0,33,0,0,0,2,0,0,0,32,0,4,0,52,0,0,0,9,0,
|
0,0,128,191,32,0,4,0,33,0,0,0,7,0,0,0,29,0,0,0,43,0,4,0,14,0,0,0,34,0,
|
||||||
0,0,2,0,0,0,32,0,4,0,56,0,0,0,2,0,0,0,3,0,0,0,32,0,4,0,59,0,0,0,
|
0,0,2,0,0,0,32,0,4,0,53,0,0,0,9,0,0,0,2,0,0,0,32,0,4,0,57,0,0,0,
|
||||||
9,0,0,0,3,0,0,0,59,0,4,0,5,0,0,0,6,0,0,0,2,0,0,0,59,0,4,0,8,0,
|
2,0,0,0,3,0,0,0,32,0,4,0,60,0,0,0,9,0,0,0,3,0,0,0,59,0,4,0,5,0,
|
||||||
0,0,9,0,0,0,9,0,0,0,59,0,4,0,12,0,0,0,13,0,0,0,1,0,0,0,59,0,4,0,
|
0,0,6,0,0,0,2,0,0,0,59,0,4,0,8,0,0,0,9,0,0,0,9,0,0,0,59,0,4,0,
|
||||||
18,0,0,0,19,0,0,0,1,0,0,0,59,0,4,0,24,0,0,0,25,0,0,0,3,0,0,0,59,0,
|
12,0,0,0,13,0,0,0,1,0,0,0,59,0,4,0,18,0,0,0,19,0,0,0,1,0,0,0,59,0,
|
||||||
4,0,26,0,0,0,27,0,0,0,3,0,0,0,59,0,4,0,24,0,0,0,28,0,0,0,3,0,0,0,
|
4,0,24,0,0,0,25,0,0,0,3,0,0,0,59,0,4,0,26,0,0,0,27,0,0,0,3,0,0,0,
|
||||||
54,0,5,0,10,0,0,0,34,0,0,0,0,0,0,0,11,0,0,0,248,0,2,0,35,0,0,0,59,0,
|
59,0,4,0,24,0,0,0,28,0,0,0,3,0,0,0,54,0,5,0,10,0,0,0,35,0,0,0,0,0,
|
||||||
4,0,16,0,0,0,36,0,0,0,7,0,0,0,59,0,4,0,32,0,0,0,37,0,0,0,7,0,0,0,
|
0,0,11,0,0,0,248,0,2,0,36,0,0,0,59,0,4,0,16,0,0,0,37,0,0,0,7,0,0,0,
|
||||||
59,0,4,0,23,0,0,0,38,0,0,0,7,0,0,0,65,0,5,0,16,0,0,0,39,0,0,0,38,0,
|
59,0,4,0,33,0,0,0,38,0,0,0,7,0,0,0,59,0,4,0,23,0,0,0,39,0,0,0,7,0,
|
||||||
0,0,15,0,0,0,63,0,3,0,39,0,0,0,13,0,0,0,65,0,5,0,21,0,0,0,40,0,0,0,
|
0,0,65,0,5,0,16,0,0,0,40,0,0,0,39,0,0,0,15,0,0,0,63,0,3,0,40,0,0,0,
|
||||||
38,0,0,0,20,0,0,0,63,0,3,0,40,0,0,0,19,0,0,0,65,0,5,0,16,0,0,0,41,0,
|
13,0,0,0,65,0,5,0,21,0,0,0,41,0,0,0,39,0,0,0,20,0,0,0,63,0,3,0,41,0,
|
||||||
0,0,38,0,0,0,15,0,0,0,61,0,4,0,2,0,0,0,42,0,0,0,41,0,0,0,79,0,7,0,
|
0,0,19,0,0,0,65,0,5,0,16,0,0,0,42,0,0,0,39,0,0,0,15,0,0,0,61,0,4,0,
|
||||||
17,0,0,0,43,0,0,0,42,0,0,0,42,0,0,0,0,0,0,0,1,0,0,0,80,0,6,0,2,0,
|
2,0,0,0,43,0,0,0,42,0,0,0,79,0,7,0,17,0,0,0,44,0,0,0,43,0,0,0,43,0,
|
||||||
0,0,44,0,0,0,43,0,0,0,30,0,0,0,30,0,0,0,62,0,3,0,36,0,0,0,44,0,0,0,
|
0,0,0,0,0,0,1,0,0,0,80,0,6,0,2,0,0,0,45,0,0,0,44,0,0,0,30,0,0,0,
|
||||||
65,0,5,0,21,0,0,0,45,0,0,0,38,0,0,0,20,0,0,0,61,0,4,0,17,0,0,0,46,0,
|
31,0,0,0,62,0,3,0,37,0,0,0,45,0,0,0,65,0,5,0,21,0,0,0,46,0,0,0,39,0,
|
||||||
0,0,45,0,0,0,142,0,5,0,17,0,0,0,47,0,0,0,46,0,0,0,31,0,0,0,65,0,5,0,
|
0,0,20,0,0,0,61,0,4,0,17,0,0,0,47,0,0,0,46,0,0,0,142,0,5,0,17,0,0,0,
|
||||||
21,0,0,0,48,0,0,0,38,0,0,0,20,0,0,0,62,0,3,0,48,0,0,0,47,0,0,0,65,0,
|
48,0,0,0,47,0,0,0,32,0,0,0,65,0,5,0,21,0,0,0,49,0,0,0,39,0,0,0,20,0,
|
||||||
5,0,21,0,0,0,49,0,0,0,38,0,0,0,20,0,0,0,61,0,4,0,17,0,0,0,50,0,0,0,
|
0,0,62,0,3,0,49,0,0,0,48,0,0,0,65,0,5,0,21,0,0,0,50,0,0,0,39,0,0,0,
|
||||||
49,0,0,0,65,0,5,0,21,0,0,0,51,0,0,0,37,0,0,0,20,0,0,0,62,0,3,0,51,0,
|
20,0,0,0,61,0,4,0,17,0,0,0,51,0,0,0,50,0,0,0,65,0,5,0,21,0,0,0,52,0,
|
||||||
0,0,50,0,0,0,65,0,5,0,52,0,0,0,53,0,0,0,9,0,0,0,20,0,0,0,61,0,4,0,
|
0,0,38,0,0,0,20,0,0,0,62,0,3,0,52,0,0,0,51,0,0,0,65,0,5,0,53,0,0,0,
|
||||||
2,0,0,0,54,0,0,0,53,0,0,0,65,0,5,0,16,0,0,0,55,0,0,0,37,0,0,0,15,0,
|
54,0,0,0,9,0,0,0,20,0,0,0,61,0,4,0,2,0,0,0,55,0,0,0,54,0,0,0,65,0,
|
||||||
0,0,62,0,3,0,55,0,0,0,54,0,0,0,65,0,5,0,56,0,0,0,57,0,0,0,6,0,0,0,
|
5,0,16,0,0,0,56,0,0,0,38,0,0,0,15,0,0,0,62,0,3,0,56,0,0,0,55,0,0,0,
|
||||||
15,0,0,0,61,0,4,0,3,0,0,0,58,0,0,0,57,0,0,0,65,0,5,0,59,0,0,0,60,0,
|
65,0,5,0,57,0,0,0,58,0,0,0,6,0,0,0,15,0,0,0,61,0,4,0,3,0,0,0,59,0,
|
||||||
0,0,9,0,0,0,15,0,0,0,61,0,4,0,3,0,0,0,61,0,0,0,60,0,0,0,146,0,5,0,
|
0,0,58,0,0,0,65,0,5,0,60,0,0,0,61,0,0,0,9,0,0,0,15,0,0,0,61,0,4,0,
|
||||||
3,0,0,0,62,0,0,0,58,0,0,0,61,0,0,0,61,0,4,0,2,0,0,0,63,0,0,0,36,0,
|
3,0,0,0,62,0,0,0,61,0,0,0,146,0,5,0,3,0,0,0,63,0,0,0,59,0,0,0,62,0,
|
||||||
0,0,145,0,5,0,2,0,0,0,64,0,0,0,62,0,0,0,63,0,0,0,65,0,5,0,16,0,0,0,
|
0,0,61,0,4,0,2,0,0,0,64,0,0,0,37,0,0,0,145,0,5,0,2,0,0,0,65,0,0,0,
|
||||||
65,0,0,0,37,0,0,0,33,0,0,0,62,0,3,0,65,0,0,0,64,0,0,0,61,0,4,0,29,0,
|
63,0,0,0,64,0,0,0,65,0,5,0,16,0,0,0,66,0,0,0,38,0,0,0,34,0,0,0,62,0,
|
||||||
0,0,66,0,0,0,37,0,0,0,81,0,5,0,2,0,0,0,67,0,0,0,66,0,0,0,0,0,0,0,
|
3,0,66,0,0,0,65,0,0,0,61,0,4,0,29,0,0,0,67,0,0,0,38,0,0,0,81,0,5,0,
|
||||||
62,0,3,0,25,0,0,0,67,0,0,0,81,0,5,0,17,0,0,0,68,0,0,0,66,0,0,0,1,0,
|
2,0,0,0,68,0,0,0,67,0,0,0,0,0,0,0,62,0,3,0,25,0,0,0,68,0,0,0,81,0,
|
||||||
0,0,62,0,3,0,27,0,0,0,68,0,0,0,81,0,5,0,2,0,0,0,69,0,0,0,66,0,0,0,
|
5,0,17,0,0,0,69,0,0,0,67,0,0,0,1,0,0,0,62,0,3,0,27,0,0,0,69,0,0,0,
|
||||||
2,0,0,0,62,0,3,0,28,0,0,0,69,0,0,0,253,0,1,0,56,0,1,0
|
81,0,5,0,2,0,0,0,70,0,0,0,67,0,0,0,2,0,0,0,62,0,3,0,28,0,0,0,70,0,
|
||||||
|
0,0,253,0,1,0,56,0,1,0
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace mlx
|
|||||||
{
|
{
|
||||||
if(!drawable || drawable->GetType() != DrawableType::Sprite)
|
if(!drawable || drawable->GetType() != DrawableType::Sprite)
|
||||||
return false;
|
return false;
|
||||||
return static_cast<Sprite*>(drawable.get())->GetTexture() == texture &&
|
return static_cast<Sprite*>(drawable.get())->GetTexture().Get() == texture.Get() &&
|
||||||
drawable->GetPosition() == position &&
|
drawable->GetPosition() == position &&
|
||||||
drawable->GetScale() == Vec2f{ scale_x, scale_y } &&
|
drawable->GetScale() == Vec2f{ scale_x, scale_y } &&
|
||||||
drawable->GetRotation().ToEulerAngles() == EulerAnglesf{ 0.0f, 0.0f, rotation };
|
drawable->GetRotation().ToEulerAngles() == EulerAnglesf{ 0.0f, 0.0f, rotation };
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ namespace mlx
|
|||||||
void Texture::Clear(VkCommandBuffer cmd, Vec4f color)
|
void Texture::Clear(VkCommandBuffer cmd, Vec4f color)
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
Image::Clear(cmd, std::move(color));
|
Image::Clear(cmd, color);
|
||||||
if(m_staging_buffer.has_value())
|
if(m_staging_buffer.has_value())
|
||||||
{
|
{
|
||||||
mlx_color processed_color;
|
mlx_color processed_color;
|
||||||
@@ -324,7 +324,7 @@ namespace mlx
|
|||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
if(!m_has_been_modified)
|
if(!m_has_been_modified)
|
||||||
return;
|
return;
|
||||||
std::memcpy(m_staging_buffer->GetMap(), m_cpu_buffer.data(), m_cpu_buffer.size() * kvfFormatSize(m_format));
|
std::memcpy(m_staging_buffer->GetMap(), m_cpu_buffer.data(), m_cpu_buffer.size() * sizeof(mlx_color));
|
||||||
|
|
||||||
VkImageLayout old_layout = m_layout;
|
VkImageLayout old_layout = m_layout;
|
||||||
TransitionLayout(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, cmd);
|
TransitionLayout(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, cmd);
|
||||||
@@ -362,7 +362,7 @@ namespace mlx
|
|||||||
kvfDestroyFence(RenderCore::Get().GetDevice(), fence);
|
kvfDestroyFence(RenderCore::Get().GetDevice(), fence);
|
||||||
|
|
||||||
m_cpu_buffer.resize(m_width * m_height);
|
m_cpu_buffer.resize(m_width * m_height);
|
||||||
std::memcpy(m_cpu_buffer.data(), m_staging_buffer->GetMap(), m_cpu_buffer.size());
|
std::memcpy(m_cpu_buffer.data(), m_staging_buffer->GetMap(), m_cpu_buffer.size() * sizeof(mlx_color));
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture* StbTextureLoad(const std::filesystem::path& file, int* w, int* h)
|
Texture* StbTextureLoad(const std::filesystem::path& file, int* w, int* h)
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ namespace mlx
|
|||||||
drawable_data.model_matrix = Mat4f::Identity();
|
drawable_data.model_matrix = Mat4f::Identity();
|
||||||
drawable_data.model_matrix.ApplyTranslation(Vec3f{ -drawable->GetCenter() / 2.0f, 0.0f });
|
drawable_data.model_matrix.ApplyTranslation(Vec3f{ -drawable->GetCenter() / 2.0f, 0.0f });
|
||||||
drawable_data.model_matrix.ApplyRotation(drawable->GetRotation());
|
drawable_data.model_matrix.ApplyRotation(drawable->GetRotation());
|
||||||
drawable_data.model_matrix.ApplyTranslation(Vec3f{ drawable->GetPosition() + drawable->GetCenter(), 0.0f });
|
drawable_data.model_matrix.ApplyTranslation(Vec3f{ drawable->GetPosition() + drawable->GetCenter() / 2.0f, 0.0f });
|
||||||
drawable_data.model_matrix.ApplyScale(Vec3f{ drawable->GetScale(), 1.0f });
|
drawable_data.model_matrix.ApplyScale(Vec3f{ drawable->GetScale(), 1.0f });
|
||||||
|
|
||||||
drawable->Bind(frame_index, cmd);
|
drawable->Bind(frame_index, cmd);
|
||||||
|
|||||||
Reference in New Issue
Block a user