Code standardtization pass. Fixed a bunch of warnings.

This commit is contained in:
Antoine Pilote
2023-03-04 17:50:02 -05:00
parent dfd8c0c57d
commit 8be7695d1e
28 changed files with 133 additions and 106 deletions
+2
View File
@@ -202,5 +202,7 @@ namespace Nuake
}
}
}
return nullptr;
}
}
+3 -1
View File
@@ -12,7 +12,9 @@ namespace Nuake
{
char buff[100];
time_t now = time(0);
strftime(buff, 100, "%H:%M:%S", localtime(&now));
struct tm timeinfo;
localtime_s(&timeinfo, &now);
strftime(buff, 100, "%H:%M:%S", &timeinfo);
LogEntry newLog = {
type,
+1 -1
View File
@@ -7,7 +7,7 @@ namespace Nuake
public:
static int GetTime()
{
return std::chrono::system_clock::now().time_since_epoch().count();
return static_cast<int>(std::chrono::system_clock::now().time_since_epoch().count());
}
};
}
@@ -44,7 +44,7 @@ namespace Nuake
if (m_hittingWall)
{
for (unsigned int i = 0, size = m_surfaceHitNormals.size(); i < size; i++)
for (size_t i = 0, size = m_surfaceHitNormals.size(); i < size; i++)
{
// Cancel velocity across normal
glm::vec3 velInNormalDir(glm::reflect(m_manualVelocity, m_surfaceHitNormals[i]));
+1 -1
View File
@@ -23,7 +23,7 @@ namespace Nuake {
{
const auto& element = elements[i];
RenderCommand::EnableVertexAttribArray(i);
RenderCommand::VertexAttribPointer(i, element.count, element.type, element.normalized, layout.GetStride(), (const void*)offset);
RenderCommand::VertexAttribPointer(i, element.count, element.type, element.normalized, layout.GetStride(), (const void*)(uintptr_t)offset);
offset += element.count * VertexBufferElement::GetSizeOfType(element.type);
}
}
+1 -1
View File
@@ -36,7 +36,7 @@ namespace Nuake
m_Type = type;
}
void Camera::OnWindowResize(int x, int y)
void Camera::OnWindowResize(float x, float y)
{
AspectRatio = (float)x / (float)y;
float width = (float)y * (16.0f * 9.0f);
+1 -1
View File
@@ -41,7 +41,7 @@ namespace Nuake
Camera(CAMERA_TYPE type, Vector3 position);
void SetType(CAMERA_TYPE type);
void OnWindowResize(int x, int y);
void OnWindowResize(float x, float y);
void SetDirection(Vector3 direction);
+2 -2
View File
@@ -97,7 +97,7 @@ namespace Nuake
m_Material->Bind(shader);
m_VertexArray->Bind();
RenderCommand::DrawElements(RendererEnum::TRIANGLES, m_Indices.size(), RendererEnum::UINT, 0);
RenderCommand::DrawElements(RendererEnum::TRIANGLES, (int)m_Indices.size(), RendererEnum::UINT, 0);
}
void Mesh::DebugDraw()
@@ -106,7 +106,7 @@ namespace Nuake
Renderer::m_DebugShader->SetUniform4f("u_Color", 1.0f, 0.0f, 0.0f, 1.f);
m_VertexArray->Bind();
RenderCommand::DrawElements(RendererEnum::TRIANGLES, m_Indices.size(), RendererEnum::UINT, 0);
RenderCommand::DrawElements(RendererEnum::TRIANGLES, (int)m_Indices.size(), RendererEnum::UINT, 0);
}
json Mesh::Serialize()
+7 -7
View File
@@ -39,7 +39,7 @@ namespace Nuake
m_VBlurFB = std::vector<Ref<FrameBuffer>>();
Vector2 currentSize = m_Size / 2.0f;
for (int i = 0; i < m_Iteration; i++)
for (uint32_t i = 0; i < m_Iteration; i++)
{
Ref<FrameBuffer> fb = CreateRef<FrameBuffer>(false, currentSize);
fb->SetTexture(CreateRef<Texture>(currentSize, GL_RGBA, GL_RGBA16F, GL_FLOAT));
@@ -48,7 +48,7 @@ namespace Nuake
currentSize *= DownsamplingScale;
}
for (int i = 0; i < m_Iteration; i++)
for (uint32_t i = 0; i < m_Iteration; i++)
{
Ref<FrameBuffer> fb = CreateRef<FrameBuffer>(false, currentSize);
fb->SetTexture(CreateRef<Texture>(currentSize, GL_RGBA, GL_RGBA16F, GL_FLOAT));
@@ -86,7 +86,7 @@ namespace Nuake
Renderer::DrawQuad(Matrix4());
}
for (int i = 0; i < m_Iteration; i++)
for (uint32_t i = 0; i < m_Iteration; i++)
{
m_DownSampleFB[i]->Bind();
m_DownSampleFB[i]->Clear();
@@ -103,7 +103,7 @@ namespace Nuake
m_DownSampleFB[i]->Unbind();
}
for (int i = 0; i < m_Iteration; i++)
for (uint32_t i = 0; i < m_Iteration; i++)
{
// Horizontal blur
m_HBlurFB[i]->Bind();
@@ -115,7 +115,7 @@ namespace Nuake
Ref<Texture> blurTexture = m_DownSampleFB[m_Iteration - i - 1]->GetTexture();
blurTexture->Bind(1);
shader->SetUniform1i("u_Source", 1);
shader->SetUniform2f("u_SourceSize", blurTexture->GetWidth(), blurTexture->GetHeight());
shader->SetUniform2f("u_SourceSize", (float)blurTexture->GetWidth(), (float)blurTexture->GetHeight());
Renderer::DrawQuad(Matrix4());
m_HBlurFB[i]->Unbind();
@@ -129,7 +129,7 @@ namespace Nuake
m_HBlurFB[i]->GetTexture()->Bind(1);
shader->SetUniform1i("u_Source", 1);
shader->SetUniform2f("u_SourceSize", m_HBlurFB[i]->GetTexture()->GetWidth(), m_HBlurFB[i]->GetTexture()->GetHeight());
shader->SetUniform2f("u_SourceSize", (float)m_HBlurFB[i]->GetTexture()->GetWidth(), (float)m_HBlurFB[i]->GetTexture()->GetHeight());
Renderer::DrawQuad(Matrix4());
m_VBlurFB[i]->Unbind();
@@ -153,7 +153,7 @@ namespace Nuake
m_UpSampleFB[i - 1]->GetTexture()->Bind(2);
shader->SetUniform1i("u_Source2", 2);
shader->SetUniform2f("u_Source2Size", m_UpSampleFB[i]->GetTexture()->GetWidth(), m_UpSampleFB[i]->GetTexture()->GetHeight());
shader->SetUniform2f("u_Source2Size", (float)m_UpSampleFB[i]->GetTexture()->GetWidth(), (float)m_UpSampleFB[i]->GetTexture()->GetHeight());
}
Renderer::DrawQuad(Matrix4());
m_UpSampleFB[i]->Unbind();
+3 -3
View File
@@ -153,7 +153,7 @@ namespace Nuake
deferredShader->Bind();
m_Lights.push_back({ transform , light });
int idx = m_Lights.size();
size_t idx = m_Lights.size();
Vector3 direction = light.GetDirection();
Vector3 pos = transform.GetGlobalPosition();
@@ -174,7 +174,7 @@ namespace Nuake
shadowmapAmount += CSM_AMOUNT;
}
deferredShader->SetUniform1i("LightCount", idx);
deferredShader->SetUniform1i("LightCount", (int)idx);
deferredShader->SetUniform1i("Lights[" + std::to_string(idx - 1) + "].Type", light.Type);
deferredShader->SetUniform3f("Lights[" + std::to_string(idx - 1) + "].Position", pos.x, pos.y, pos.z);
deferredShader->SetUniform3f("Lights[" + std::to_string(idx - 1) + "].Direction", direction.x, direction.y, direction.z);
@@ -200,7 +200,7 @@ namespace Nuake
VertexArray lineVertexArray = VertexArray();
lineVertexArray.Bind();
VertexBuffer lineVertexBuffer = VertexBuffer(&vertices, size(vertices));
VertexBuffer lineVertexBuffer = VertexBuffer(&vertices, static_cast<int>(size(vertices)));
VertexBufferLayout vblayout = VertexBufferLayout();
vblayout.Push<float>(3);
+1 -1
View File
@@ -6,7 +6,7 @@
namespace Nuake
{
class TextStyle;
struct TextStyle;
class Renderer2D
{
private:
+1 -1
View File
@@ -45,7 +45,7 @@ namespace Nuake
0, // Has metalness
0.f, // Metalness value
0, // u_HasRoughness
0.f, // u_RoughnessValue
1.f, // u_RoughnessValue
0, // u_HasAO
1.f, // u_AOValue
0, // u_HasNormal
+4
View File
@@ -72,6 +72,8 @@ namespace Nuake {
if (name == b.Name)
return b;
}
assert(false && "Brush entity not found!");
}
FGDPointEntity& GetPointEntity(const std::string& name)
@@ -81,6 +83,8 @@ namespace Nuake {
if (name == p.Name)
return p;
}
assert(false && "Point entity not found!");
}
EntityType GetTypeOfEntity(const std::string& className)
+2
View File
@@ -84,6 +84,8 @@ namespace Nuake {
line += "]";
FileSystem::WriteLine(line);
return true;
}
bool FGDSerializer::SerializeBrush(FGDBrushEntity fgdClass)
+1 -1
View File
@@ -156,7 +156,7 @@ namespace Nuake
// Store SplitDistance and ViewProjection-Matrix
mCascadeSplitDepth[cascade] = (nearClip + splitDist * clipRange) * 1.0f;
mViewProjections[cascade] = lightProjectionMatrix * lightViewMatrix;
mViewProjections[cascade] = shadowMatrix;
lastSplitDist = mCascadeSplits[cascade];
// -----------------------Debug only-----------------------
+1 -1
View File
@@ -13,7 +13,7 @@ public:
ImGui::PushID(label.c_str());
float availWidth = (ImGui::GetContentRegionAvailWidth() / 3.0) - 9.0;
float availWidth = (ImGui::GetContentRegionAvailWidth() / 3.0f) - 9.0f;
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2{ 0, 0 });
float lineHeight = GImGui->Font->FontSize + GImGui->Style.FramePadding.y * 2.0f;
+1 -1
View File
@@ -14,7 +14,7 @@ namespace Nuake
float AtmosphereRadius = 6380e3f;
Vector3 RayleighScattering = Vector3(58e-7f, 135e-7f, 331e-7f);
Vector3 MieScattering = Vector3(2e-5f);
float SunIntensity = 100.0;
float SunIntensity = 10.0;
Vector3 CenterPoint = Vector3(0.f, -SurfaceRadius, 0.f);
Vector3 SunDirection = Vector3(0.20000f, 0.95917f, 0.20000f);
+2 -2
View File
@@ -294,8 +294,8 @@ namespace Nuake {
for (unsigned int mip = 0; mip < maxMipLevels; ++mip)
{
// reisze framebuffer according to mip-level size.
unsigned int mipWidth = 1024 * std::pow(0.5, mip);
unsigned int mipHeight = 1024 * std::pow(0.5, mip);
unsigned int mipWidth = unsigned int(1024 * std::pow(0.5f, mip));
unsigned int mipHeight = unsigned int(1024 * std::pow(0.5f, mip));
glBindRenderbuffer(GL_RENDERBUFFER, captureRBO);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, mipWidth, mipHeight);
glViewport(0, 0, mipWidth, mipHeight);
+4 -1
View File
@@ -75,11 +75,14 @@ namespace Nuake {
Entity Scene::GetEntityByID(int id)
{
auto idView = m_Registry.view<NameComponent>();
for (auto e : idView) {
for (auto e : idView)
{
NameComponent& nameC = idView.get<NameComponent>(e);
if (nameC.ID == id)
return Entity{ e, this };
}
assert("Not found");
}
+2 -2
View File
@@ -386,7 +386,7 @@ namespace Nuake {
geo_generator_run();
DefaultMaterial = MaterialManager::Get()->GetMaterial("default");
for (uint32_t e = 0; e < entity_count; ++e)
for (uint32_t e = 0; e < (uint32_t)entity_count; ++e)
{
entity* entity_inst = &entities[e];
entity_geometry* entity_geo_inst = &entity_geo[e];
@@ -598,7 +598,7 @@ namespace Nuake {
for (auto& index : pm.Indices)
batchedIndices.push_back(indexOffset + index);
indexOffset += pm.Vertices.size();
indexOffset += static_cast<uint32_t>(pm.Vertices.size());
}
Ref<Mesh> mesh = CreateRef<Mesh>();
+6 -6
View File
@@ -47,8 +47,8 @@ namespace Nuake {
static void IsMouseButtonDown(WrenVM* vm)
{
int key = wrenGetSlotDouble(vm, 1);
bool result = Input::IsMouseButtonDown(key);
double key = wrenGetSlotDouble(vm, 1);
bool result = Input::IsMouseButtonDown((int)key);
wrenSetSlotBool(vm, 0, result);
}
@@ -61,28 +61,28 @@ namespace Nuake {
static void IsMouseButtonReleased(WrenVM* vm)
{
int key = wrenGetSlotDouble(vm, 1);
int key = (int)wrenGetSlotDouble(vm, 1);
bool result = Input::IsMouseButtonReleased(key);
wrenSetSlotBool(vm, 0, result);
}
static void IsKeyDown(WrenVM* vm)
{
int key = wrenGetSlotDouble(vm, 1);
int key = (int)wrenGetSlotDouble(vm, 1);
bool result = Input::IsKeyDown(key);
wrenSetSlotBool(vm, 0, result);
}
static void IsKeyPressed(WrenVM* vm)
{
int key = wrenGetSlotDouble(vm, 1);
int key = (int)wrenGetSlotDouble(vm, 1);
bool result = Input::IsKeyPressed(key);
wrenSetSlotBool(vm, 0, result);
}
static void IsKeyReleased(WrenVM* vm)
{
int key = wrenGetSlotDouble(vm, 1);
int key = (int)wrenGetSlotDouble(vm, 1);
bool result = Input::IsKeyReleased(key);
wrenSetSlotBool(vm, 0, result);
}
+12 -12
View File
@@ -32,38 +32,38 @@ namespace Nuake {
static void Sqrt(WrenVM* vm)
{
float x = wrenGetSlotDouble(vm, 1);
float y = wrenGetSlotDouble(vm, 2);
float z = wrenGetSlotDouble(vm, 3);
float result = glm::sqrt((x * x) + (y * y) + (z * z));
double x = wrenGetSlotDouble(vm, 1);
double y = wrenGetSlotDouble(vm, 2);
double z = wrenGetSlotDouble(vm, 3);
double result = glm::sqrt((x * x) + (y * y) + (z * z));
wrenSetSlotDouble(vm, 0, result);
}
static void Cos(WrenVM* vm)
{
float d = wrenGetSlotDouble(vm, 1);
float result = glm::cos(d);
double d = wrenGetSlotDouble(vm, 1);
double result = glm::cos(d);
wrenSetSlotDouble(vm, 0, result);
}
static void Sin(WrenVM* vm)
{
float d = wrenGetSlotDouble(vm, 1);
float result = glm::sin(d);
double d = wrenGetSlotDouble(vm, 1);
double result = glm::sin(d);
wrenSetSlotDouble(vm, 0, result);
}
static void Radians(WrenVM* vm)
{
float d = wrenGetSlotDouble(vm, 1);
float result = glm::radians(d);
double d = wrenGetSlotDouble(vm, 1);
double result = glm::radians(d);
wrenSetSlotDouble(vm, 0, result);
}
static void Degrees(WrenVM* vm)
{
float d = wrenGetSlotDouble(vm, 1);
float result = glm::degrees(d);
double d = wrenGetSlotDouble(vm, 1);
double result = glm::degrees(d);
wrenSetSlotDouble(vm, 0, result);
}
+35 -35
View File
@@ -63,7 +63,7 @@ namespace Nuake {
static void EntityHasComponent(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
double handle = wrenGetSlotDouble(vm, 1);
std::string name = wrenGetSlotString(vm, 2);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
@@ -106,7 +106,7 @@ namespace Nuake {
static void GetScript(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
double handle = wrenGetSlotDouble(vm, 1);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
if (ent.HasComponent<WrenScriptComponent>())
@@ -117,18 +117,18 @@ namespace Nuake {
static void SetLightIntensity(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
float intensity = wrenGetSlotDouble(vm, 2);
double handle = wrenGetSlotDouble(vm, 1);
double intensity = wrenGetSlotDouble(vm, 2);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
auto& light = ent.GetComponent<LightComponent>();
light.Strength = intensity;
light.Strength = static_cast<float>(intensity);
}
static void GetLightIntensity(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
float intensity = wrenGetSlotDouble(vm, 2);
double handle = wrenGetSlotDouble(vm, 1);
double intensity = wrenGetSlotDouble(vm, 2);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
auto& light = ent.GetComponent<LightComponent>();
@@ -137,10 +137,10 @@ namespace Nuake {
static void SetCameraDirection(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
float x = wrenGetSlotDouble(vm, 2);
float y = wrenGetSlotDouble(vm, 3);
float z = wrenGetSlotDouble(vm, 4);
double handle = wrenGetSlotDouble(vm, 1);
double x = wrenGetSlotDouble(vm, 2);
double y = wrenGetSlotDouble(vm, 3);
double z = wrenGetSlotDouble(vm, 4);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
auto& cam = ent.GetComponent<CameraComponent>();
cam.CameraInstance->SetDirection(Vector3(x, y, z));
@@ -148,7 +148,7 @@ namespace Nuake {
static void GetCameraDirection(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
double handle = wrenGetSlotDouble(vm, 1);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
auto& cam = ent.GetComponent<CameraComponent>();
@@ -171,7 +171,7 @@ namespace Nuake {
static void GetCameraRight(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
double handle = wrenGetSlotDouble(vm, 1);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
auto& cam = ent.GetComponent<CameraComponent>();
@@ -192,7 +192,7 @@ namespace Nuake {
static void IsCharacterControllerOnGround(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
double handle = wrenGetSlotDouble(vm, 1);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
auto& characterController = ent.GetComponent<CharacterControllerComponent>();
bool result = characterController.CharacterController->IsOnGround;
@@ -201,10 +201,10 @@ namespace Nuake {
static void MoveAndSlide(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
float x = wrenGetSlotDouble(vm, 2);
float y = wrenGetSlotDouble(vm, 3);
float z = wrenGetSlotDouble(vm, 4);
double handle = wrenGetSlotDouble(vm, 1);
double x = wrenGetSlotDouble(vm, 2);
double y = wrenGetSlotDouble(vm, 3);
double z = wrenGetSlotDouble(vm, 4);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
auto& characterController = ent.GetComponent<CharacterControllerComponent>();
@@ -213,7 +213,7 @@ namespace Nuake {
static void GetTranslation(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
double handle = wrenGetSlotDouble(vm, 1);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
auto& transform = ent.GetComponent<TransformComponent>();
// set the slots
@@ -231,7 +231,7 @@ namespace Nuake {
static void GetRotation(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
double handle = wrenGetSlotDouble(vm, 1);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
auto& transform = ent.GetComponent<TransformComponent>();
// set the slots
@@ -248,33 +248,33 @@ namespace Nuake {
static void SetRotation(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
double handle = wrenGetSlotDouble(vm, 1);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
auto& transform = ent.GetComponent<TransformComponent>();
// set the slots
float x = wrenGetSlotDouble(vm, 2);
float y = wrenGetSlotDouble(vm, 3);
float z = wrenGetSlotDouble(vm, 4);
float x = (float)wrenGetSlotDouble(vm, 2);
float y = (float)wrenGetSlotDouble(vm, 3);
float z = (float)wrenGetSlotDouble(vm, 4);
transform.SetLocalRotation(QuatFromEuler(x, y, z));
}
static void SetTranslation(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
double handle = wrenGetSlotDouble(vm, 1);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
auto& transform = ent.GetComponent<TransformComponent>();
// set the slots
float x = wrenGetSlotDouble(vm, 2);
float y = wrenGetSlotDouble(vm, 3);
float z = wrenGetSlotDouble(vm, 4);
double x = wrenGetSlotDouble(vm, 2);
double y = wrenGetSlotDouble(vm, 3);
double z = wrenGetSlotDouble(vm, 4);
transform.SetGlobalPosition(Vector3(x, y, z));
}
static void TriggerGetOverlappingBodyCount(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
double handle = wrenGetSlotDouble(vm, 1);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
TriggerZone trigger = ent.GetComponent<TriggerZone>();
@@ -286,14 +286,14 @@ namespace Nuake {
static void TriggerGetOverlappingBodies(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
double handle = wrenGetSlotDouble(vm, 1);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
TriggerZone trigger = ent.GetComponent<TriggerZone>();
std::vector<Entity> entities = trigger.GetOverlappingBodies();
wrenEnsureSlots(vm, entities.size());
wrenEnsureSlots(vm, static_cast<int>(entities.size()));
wrenSetSlotNewList(vm, 0);
int idx = 1;
@@ -307,11 +307,11 @@ namespace Nuake {
static void BrushGetTargets(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
double handle = wrenGetSlotDouble(vm, 1);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
BSPBrushComponent& brush = ent.GetComponent<BSPBrushComponent>();
wrenEnsureSlots(vm, brush.Targets.size());
wrenEnsureSlots(vm, static_cast<int>(brush.Targets.size()));
wrenSetSlotNewList(vm, 0);
int idx = 1;
@@ -324,11 +324,11 @@ namespace Nuake {
}
static void BrushGetTargetsCount(WrenVM* vm) {
int handle = wrenGetSlotDouble(vm, 1);
double handle = wrenGetSlotDouble(vm, 1);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
BSPBrushComponent& brush = ent.GetComponent<BSPBrushComponent>();
wrenSetSlotDouble(vm, 0, brush.Targets.size());
wrenSetSlotDouble(vm, 0, static_cast<int>(brush.Targets.size()));
}
};
}
+4 -4
View File
@@ -82,9 +82,7 @@ namespace Nuake {
path += ".wren";
std::string str = FileSystem::ReadFile(path, true);
char* c = strcpy(new char[str.length() + 1], str.c_str());
result.source = c;
result.source = str.c_str();
return result;
}
@@ -173,7 +171,7 @@ namespace Nuake {
wrenFreeVM(m_WrenVM);
}
WrenForeignMethodFn ScriptingEngine::bindForeignMethod(WrenVM* vm, const char* module, const char* className, bool isStatic, const char* signature)
WrenForeignMethodFn ScriptingEngine::bindForeignMethod(WrenVM* vm, const char* modul, const char* className, bool isStatic, const char* signature)
{
if (Modules.find(className) != Modules.end())
{
@@ -181,6 +179,8 @@ namespace Nuake {
void* ptr = mod->GetMethodPointer(signature);
return (WrenForeignMethodFn)ptr;
}
return nullptr;
}
WrenVM* ScriptingEngine::GetWrenVM()
+4 -4
View File
@@ -9,10 +9,10 @@ namespace Nuake
{
struct CharPos
{
double left;
double right;
double top;
double bottom;
float left;
float right;
float top;
float bottom;
};
struct CharUV
+25 -15
View File
@@ -56,7 +56,7 @@ namespace Nuake
// Setup generator settings
generator.setAttributes(config.generatorAttributes);
generator.setThreadCount(config.threadCount);
generator.generate(glyphs.data(), glyphs.size());
generator.generate(glyphs.data(), static_cast<int>(glyphs.size()));
// Create bitmap
msdfgen::BitmapConstRef<T, N> bitmap = (msdfgen::BitmapConstRef<T, N>) generator.atlasStorage();
@@ -120,11 +120,14 @@ namespace Nuake
atlasPacker.setMiterLimit(config.miterLimit);
// Pack atlas
if (int remaining = atlasPacker.pack(glyphs.data(), glyphs.size())) {
if (remaining < 0) {
if (int remaining = atlasPacker.pack(glyphs.data(), static_cast<int>(glyphs.size())))
{
if (remaining < 0)
{
Logger::Log("Failed to pack atlas.", CRITICAL);
}
else {
else
{
printf("Error: Could not fit %d out of %d glyphs into the atlas.\n", remaining, (int)glyphs.size());
}
@@ -145,30 +148,37 @@ namespace Nuake
// glyph.edgeColoring(config.edgeColoring, config.angleThreshold, glyphSeed);
//}
msdf_atlas::Workload([&glyphs, &config](int i, int threadNo) -> bool {
msdf_atlas::Workload([&glyphs, &config](int i, int threadNo) -> bool
{
unsigned long long glyphSeed = (6364136223846793005ull * (config.coloringSeed ^ i) + 1442695040888963407ull) * !!config.coloringSeed;
glyphs[i].edgeColoring(config.edgeColoring, config.angleThreshold, glyphSeed);
return true;
}, glyphs.size()).finish(config.threadCount);
}, (int)glyphs.size()).finish(config.threadCount);
// Create bitmap and char structure
auto bitmap = makeAtlas<byte, float, 4, msdf_atlas::mtsdfGenerator>(glyphs, fonts, config, font);
for (auto& g : glyphs)
{
CharPos plane = {};
g.getQuadPlaneBounds(plane.left, plane.bottom, plane.right, plane.top);
CharUV box = {};
double planeLeft, planeBottom, planeRight, planeTop;
g.getQuadPlaneBounds(planeLeft, planeBottom, planeRight, planeTop);
CharPos plane {
static_cast<float>(planeLeft),
static_cast<float>(planeRight),
static_cast<float>(planeTop),
static_cast<float>(planeBottom)
};
double x2, y2, z2, w2;
g.getQuadAtlasBounds(x2, y2, z2, w2);
box.Pos.x = x2;
box.Pos.y = y2;
box.Size.x = z2;
box.Size.y = w2;
font->AddChar(g.getCodepoint(), g.getAdvance(), plane, box);
CharUV box {
Vector2{x2, y2},
Vector2{z2, w2}
};
font->AddChar(g.getCodepoint(), static_cast<float>(g.getAdvance()), plane, box);
}
return font;
+2
View File
@@ -166,6 +166,8 @@ namespace Nuake
}
}
}
return Layout::LayoutUnit{ 1.0f, Layout::Unit::AUTO };
}
Layout::LayoutVec4 InterfaceParser::GetVec4Unit(const std::string& value)
+4 -2
View File
@@ -56,7 +56,7 @@ namespace Nuake {
void UserInterface::Calculate(int available_width, int available_height)
{
YGNodeRef root = Root->YogaNode;
YGNodeCalculateLayout(root, available_width, available_height, YGDirectionLTR);
YGNodeCalculateLayout(root, static_cast<float>(available_width), static_cast<float>(available_height), YGDirectionLTR);
}
void UserInterface::CreateYogaLayout()
@@ -109,7 +109,7 @@ namespace Nuake {
void UserInterface::Draw(Vector2 size)
{
Calculate(size.x, size.y);
Calculate((int)size.x, (int)size.y);
Renderer2D::BeginDraw(size);
DrawRecursive(Root, 0);
Renderer2D::EndDraw();
@@ -194,6 +194,8 @@ namespace Nuake {
if (result)
return result;
}
return nullptr;
}
Ref<Node> UserInterface::GetNodeByIDRecurse(Ref<Node> node, const std::string& id)