Skip to content

Commit

Permalink
structs removed m_ prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
inanevin committed Jun 15, 2022
1 parent 046d91a commit c9453e7
Show file tree
Hide file tree
Showing 8 changed files with 822 additions and 822 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ add_library(Lina::VG ALIAS ${PROJECT_NAME})
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_compile_definitions(${PROJECT_NAME} PUBLIC LINAVG_VERSION_MAJOR=1)
target_compile_definitions(${PROJECT_NAME} PUBLIC LINAVG_VERSION_MINOR=0)
target_compile_definitions(${PROJECT_NAME} PUBLIC LINAVG_VERSION_PATCH=0)
target_compile_definitions(${PROJECT_NAME} PUBLIC LINAVG_VERSION_PATCH=1)

#--------------------------------------------------------------------
# Subdirectories & linking
Expand Down
2 changes: 1 addition & 1 deletion Examples/src/DemoScreens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ namespace LinaVG
TextOptions controlsText;
controlsText.font = m_descFont;
controlsText.textScale = 0.8f;
LinaVG::DrawTextNormal("Num keys[1-8]: switch screen", Vec2(rectWidth * 0.725f + 20, rectMin.y + 10), controlsText, 0, 4);
LinaVG::DrawTextNormal("Num keys[1-9]: switch screen", Vec2(rectWidth * 0.725f + 20, rectMin.y + 10), controlsText, 0, 4);
LinaVG::DrawTextNormal("P: toggle performance stats.", Vec2(rectWidth * 0.725f + 20, rectMin.y + 30), controlsText, 0, 4);
LinaVG::DrawTextNormal("F: toggle wireframe rendering.", Vec2(rectWidth * 0.725f + 20, rectMin.y + 50), controlsText, 0, 4);
LinaVG::DrawTextNormal("R: start/stop rotation.", Vec2(rectWidth * 0.725f + 20, rectMin.y + 70), controlsText, 0, 4);
Expand Down
56 changes: 28 additions & 28 deletions Examples/src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,22 @@ namespace LinaVG
exampleBackend.InitWindow(static_cast<int>(sizeX), static_cast<int>(sizeY));

// Setup Lina VG config.
LinaVG::Config.m_displayPosX = 0;
LinaVG::Config.m_displayPosY = 0;
LinaVG::Config.m_displayWidth = sizeX;
LinaVG::Config.m_displayHeight = sizeY;
LinaVG::Config.m_clipPosX = LinaVG::Config.m_clipPosY = 0;
LinaVG::Config.m_clipSizeX = sizeX;
LinaVG::Config.m_clipSizeY = sizeY;
LinaVG::Config.m_flipTextureUVs = false;
LinaVG::Config.m_framebufferScale.x = LinaVG::Config.m_framebufferScale.y = exampleBackend.GetFramebufferScale();
LinaVG::Config.m_aaMultiplier = 1.5f;

LinaVG::Config.m_errorCallback = [](const std::string& err) {
LinaVG::Config.displayPosX = 0;
LinaVG::Config.displayPosY = 0;
LinaVG::Config.displayWidth = sizeX;
LinaVG::Config.displayHeight = sizeY;
LinaVG::Config.clipPosX = LinaVG::Config.clipPosY = 0;
LinaVG::Config.clipSizeX = sizeX;
LinaVG::Config.clipSizeY = sizeY;
LinaVG::Config.flipTextureUVs = false;
LinaVG::Config.framebufferScale.x = LinaVG::Config.framebufferScale.y = exampleBackend.GetFramebufferScale();
LinaVG::Config.aaMultiplier = 1.5f;

LinaVG::Config.errorCallback = [](const std::string& err) {
std::cerr << err.c_str() << std::endl;
};

LinaVG::Config.m_logCallback = [](const std::string& log) {
LinaVG::Config.logCallback = [](const std::string& log) {
std::cout << log.c_str() << std::endl;
};

Expand Down Expand Up @@ -115,17 +115,17 @@ namespace LinaVG

// Setup style.
StyleOptions style;
style.m_outlineOptions.m_thickness = 2.0f;
style.m_outlineOptions.m_drawDirection = OutlineDrawDirection::Inwards;
style.outlineOptions.thickness = 2.0f;
style.outlineOptions.drawDirection = OutlineDrawDirection::Inwards;

// Same options as style.m_color
style.m_outlineOptions.m_color.m_start = Vec4(1, 0, 0, 1);
style.m_outlineOptions.m_color.m_end = Vec4(0, 0, 1, 1);
style.outlineOptions.color.start = Vec4(1, 0, 0, 1);
style.outlineOptions.color.end = Vec4(0, 0, 1, 1);

// Same options as style.m_textureXXX
style.m_outlineOptions.m_textureHandle = ExampleApp::Get()->GetCheckeredTexture();
style.m_outlineOptions.m_textureUVOffset = Vec2(0.0f, 0.0f);
style.m_outlineOptions.m_textureUVTiling = Vec2(1.0f, 1.0f);
style.outlineOptions.textureHandle = ExampleApp::Get()->GetCheckeredTexture();
style.outlineOptions.textureUVOffset = Vec2(0.0f, 0.0f);
style.outlineOptions.textureUVTiling = Vec2(1.0f, 1.0f);

m_demoScreens.ShowBackground();

Expand Down Expand Up @@ -169,12 +169,12 @@ namespace LinaVG

void ExampleApp::OnHorizontalKeyCallback(float input)
{
LinaVG::Config.m_debugOrthoOffset.x += input * m_deltaTime * 1000;
LinaVG::Config.debugOrthoOffset.x += input * m_deltaTime * 1000;
}

void ExampleApp::OnVerticalKeyCallback(float input)
{
LinaVG::Config.m_debugOrthoOffset.y -= input * m_deltaTime * 1000;
LinaVG::Config.debugOrthoOffset.y -= input * m_deltaTime * 1000;
}

void ExampleApp::OnNumKeyCallback(int key)
Expand All @@ -198,7 +198,7 @@ namespace LinaVG

void ExampleApp::OnFCallback()
{
LinaVG::Config.m_debugWireframeEnabled = !LinaVG::Config.m_debugWireframeEnabled;
LinaVG::Config.debugWireframeEnabled = !LinaVG::Config.debugWireframeEnabled;
}

void ExampleApp::OnCCallback()
Expand All @@ -216,15 +216,15 @@ namespace LinaVG

void ExampleApp::OnMouseScrollCallback(float val)
{
LinaVG::Config.m_debugOrthoProjectionZoom -= val * m_deltaTime * 10;
LinaVG::Config.debugOrthoProjectionZoom -= val * m_deltaTime * 10;
}

void ExampleApp::OnWindowResizeCallback(int width, int height)
{
LinaVG::Config.m_displayWidth = static_cast<BackendHandle>(width);
LinaVG::Config.m_displayHeight = static_cast<BackendHandle>(height);
LinaVG::Config.m_clipSizeX = static_cast<BackendHandle>(width);
LinaVG::Config.m_clipSizeY = static_cast<BackendHandle>(height);
LinaVG::Config.displayWidth = static_cast<BackendHandle>(width);
LinaVG::Config.displayHeight = static_cast<BackendHandle>(height);
LinaVG::Config.clipSizeX = static_cast<BackendHandle>(width);
LinaVG::Config.clipSizeY = static_cast<BackendHandle>(height);
}
void ExampleApp::OnWindowCloseCallback()
{
Expand Down
114 changes: 57 additions & 57 deletions src/Backends/GL/GLBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ namespace LinaVG::Backend
}
catch (const std::runtime_error& err)
{
if (Config.m_errorCallback)
if (Config.errorCallback)
{
Config.m_errorCallback("LinaVG: Backend shader creation failed!");
Config.m_errorCallback(err.what());
Config.errorCallback("LinaVG: Backend shader creation failed!");
Config.errorCallback(err.what());
}
return false;
}
Expand Down Expand Up @@ -213,9 +213,9 @@ namespace LinaVG::Backend

void StartFrame()
{
Config.m_debugCurrentDrawCalls = 0;
Config.m_debugCurrentTriangleCount = 0;
Config.m_debugCurrentVertexCount = 0;
Config.debugCurrentDrawCalls = 0;
Config.debugCurrentTriangleCount = 0;
Config.debugCurrentVertexCount = 0;

// Save GL state
SaveAPIState();
Expand All @@ -229,16 +229,16 @@ namespace LinaVG::Backend
glDisable(GL_STENCIL_TEST);
glEnable(GL_SCISSOR_TEST);

if (Config.m_debugWireframeEnabled)
if (Config.debugWireframeEnabled)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
else
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

glViewport(0, 0, (GLsizei)Config.m_displayWidth, (GLsizei)Config.m_displayHeight);
glViewport(0, 0, (GLsizei)Config.displayWidth, (GLsizei)Config.displayHeight);

// Ortho projection matrix.
int fb_width = (int)(Config.m_displayWidth * Config.m_framebufferScale.x);
int fb_height = (int)(Config.m_displayHeight * Config.m_framebufferScale.y);
int fb_width = (int)(Config.displayWidth * Config.framebufferScale.x);
int fb_height = (int)(Config.displayHeight * Config.framebufferScale.y);
if (fb_width <= 0 || fb_height <= 0)
{
Internal::g_backendData.m_skipDraw = true;
Expand All @@ -247,21 +247,21 @@ namespace LinaVG::Backend

Internal::g_backendData.m_skipDraw = false;

float L = static_cast<float>(Config.m_displayPosX);
float R = static_cast<float>(Config.m_displayPosX + Config.m_displayWidth);
float T = static_cast<float>(Config.m_displayPosY);
float B = static_cast<float>(Config.m_displayPosY + Config.m_displayHeight);
const float zoom = Config.m_debugOrthoProjectionZoom;
float L = static_cast<float>(Config.displayPosX);
float R = static_cast<float>(Config.displayPosX + Config.displayWidth);
float T = static_cast<float>(Config.displayPosY);
float B = static_cast<float>(Config.displayPosY + Config.displayHeight);
const float zoom = Config.debugOrthoProjectionZoom;

L *= zoom;
R *= zoom;
T *= zoom;
B *= zoom;

L += Config.m_debugOrthoOffset.x;
R += Config.m_debugOrthoOffset.x;
T += Config.m_debugOrthoOffset.y;
B += Config.m_debugOrthoOffset.y;
L += Config.debugOrthoOffset.x;
R += Config.debugOrthoOffset.x;
T += Config.debugOrthoOffset.y;
B += Config.debugOrthoOffset.y;

Internal::g_backendData.m_proj[0][0] = 2.0f / (R - L);
Internal::g_backendData.m_proj[0][1] = 0.0f;
Expand Down Expand Up @@ -291,16 +291,16 @@ namespace LinaVG::Backend
if (Internal::g_backendData.m_skipDraw)
return;

SetScissors(buf->m_clipPosX, buf->m_clipPosY, buf->m_clipSizeX, buf->m_clipSizeY);
SetScissors(buf->clipPosX, buf->clipPosY, buf->clipSizeX, buf->clipSizeY);

Internal::ShaderData& data = Internal::g_backendData.m_gradientShaderData;
glUseProgram(data.m_handle);

glUniformMatrix4fv(data.m_uniformMap["proj"], 1, GL_FALSE, &Internal::g_backendData.m_proj[0][0]);
glUniform4f(data.m_uniformMap["startColor"], (GLfloat)buf->m_color.m_start.x, (GLfloat)buf->m_color.m_start.y, (GLfloat)buf->m_color.m_start.z, (GLfloat)buf->m_color.m_start.w);
glUniform4f(data.m_uniformMap["endColor"], (GLfloat)buf->m_color.m_end.x, (GLfloat)buf->m_color.m_end.y, (GLfloat)buf->m_color.m_end.z, (GLfloat)buf->m_color.m_end.w);
glUniform1i(data.m_uniformMap["gradientType"], (GLint)((int)buf->m_color.m_gradientType));
glUniform1f(data.m_uniformMap["radialSize"], (GLfloat)buf->m_color.m_radialSize);
glUniform4f(data.m_uniformMap["startColor"], (GLfloat)buf->m_color.start.x, (GLfloat)buf->m_color.start.y, (GLfloat)buf->m_color.start.z, (GLfloat)buf->m_color.start.w);
glUniform4f(data.m_uniformMap["endColor"], (GLfloat)buf->m_color.end.x, (GLfloat)buf->m_color.end.y, (GLfloat)buf->m_color.end.z, (GLfloat)buf->m_color.end.w);
glUniform1i(data.m_uniformMap["gradientType"], (GLint)((int)buf->m_color.gradientType));
glUniform1f(data.m_uniformMap["radialSize"], (GLfloat)buf->m_color.radialSize);
glUniform1i(data.m_uniformMap["isAABuffer"], (GLint)((int)buf->m_isAABuffer));

glBindBuffer(GL_ARRAY_BUFFER, Internal::g_backendData.m_vbo);
Expand All @@ -311,19 +311,19 @@ namespace LinaVG::Backend

glBindBuffer(GL_ARRAY_BUFFER, 0);
glDrawElements(GL_TRIANGLES, (GLsizei)buf->m_indexBuffer.m_size, sizeof(Index) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, 0);
Config.m_debugCurrentDrawCalls++;
Config.m_debugCurrentTriangleCount += int((float)buf->m_indexBuffer.m_size / 3.0f);
Config.m_debugCurrentVertexCount += buf->m_vertexBuffer.m_size;
Config.debugCurrentDrawCalls++;
Config.debugCurrentTriangleCount += int((float)buf->m_indexBuffer.m_size / 3.0f);
Config.debugCurrentVertexCount += buf->m_vertexBuffer.m_size;
}

void DrawTextured(TextureDrawBuffer* buf)
{
if (Internal::g_backendData.m_skipDraw)
return;

SetScissors(buf->m_clipPosX, buf->m_clipPosY, buf->m_clipSizeX, buf->m_clipSizeY);
SetScissors(buf->clipPosX, buf->clipPosY, buf->clipSizeX, buf->clipSizeY);

const Vec2 uv = Config.m_flipTextureUVs ? Vec2(buf->m_textureUVTiling.x, -buf->m_textureUVTiling.y) : buf->m_textureUVTiling;
const Vec2 uv = Config.flipTextureUVs ? Vec2(buf->m_textureUVTiling.x, -buf->m_textureUVTiling.y) : buf->m_textureUVTiling;
Internal::ShaderData& data = Internal::g_backendData.m_texturedShaderData;
glUseProgram(data.m_handle);
glUniformMatrix4fv(data.m_uniformMap["proj"], 1, GL_FALSE, &Internal::g_backendData.m_proj[0][0]);
Expand All @@ -343,17 +343,17 @@ namespace LinaVG::Backend

glBindBuffer(GL_ARRAY_BUFFER, 0);
glDrawElements(GL_TRIANGLES, (GLsizei)buf->m_indexBuffer.m_size, sizeof(Index) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, 0);
Config.m_debugCurrentDrawCalls++;
Config.m_debugCurrentTriangleCount += int((float)buf->m_indexBuffer.m_size / 3.0f);
Config.m_debugCurrentVertexCount += buf->m_vertexBuffer.m_size;
Config.debugCurrentDrawCalls++;
Config.debugCurrentTriangleCount += int((float)buf->m_indexBuffer.m_size / 3.0f);
Config.debugCurrentVertexCount += buf->m_vertexBuffer.m_size;
}

void DrawDefault(DrawBuffer* buf)
{
if (Internal::g_backendData.m_skipDraw)
return;

SetScissors(buf->m_clipPosX, buf->m_clipPosY, buf->m_clipSizeX, buf->m_clipSizeY);
SetScissors(buf->clipPosX, buf->clipPosY, buf->clipSizeX, buf->clipSizeY);
Internal::ShaderData& data = Internal::g_backendData.m_defaultShaderData;

glUseProgram(data.m_handle);
Expand All @@ -367,17 +367,17 @@ namespace LinaVG::Backend

glBindBuffer(GL_ARRAY_BUFFER, 0);
glDrawElements(GL_TRIANGLES, (GLsizei)buf->m_indexBuffer.m_size, sizeof(Index) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, 0);
Config.m_debugCurrentDrawCalls++;
Config.m_debugCurrentTriangleCount += int((float)buf->m_indexBuffer.m_size / 3.0f);
Config.m_debugCurrentVertexCount += buf->m_vertexBuffer.m_size;
Config.debugCurrentDrawCalls++;
Config.debugCurrentTriangleCount += int((float)buf->m_indexBuffer.m_size / 3.0f);
Config.debugCurrentVertexCount += buf->m_vertexBuffer.m_size;
}

void DrawSimpleText(SimpleTextDrawBuffer* buf)
{
if (Internal::g_backendData.m_skipDraw)
return;

SetScissors(buf->m_clipPosX, buf->m_clipPosY, buf->m_clipSizeX, buf->m_clipSizeY);
SetScissors(buf->clipPosX, buf->clipPosY, buf->clipSizeX, buf->clipSizeY);
Internal::ShaderData& data = Internal::g_backendData.m_simpleTextShaderData;
glUseProgram(data.m_handle);

Expand All @@ -395,17 +395,17 @@ namespace LinaVG::Backend

glBindBuffer(GL_ARRAY_BUFFER, 0);
glDrawElements(GL_TRIANGLES, (GLsizei)buf->m_indexBuffer.m_size, sizeof(Index) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, 0);
Config.m_debugCurrentDrawCalls++;
Config.m_debugCurrentTriangleCount += int((float)buf->m_indexBuffer.m_size / 3.0f);
Config.m_debugCurrentVertexCount += buf->m_vertexBuffer.m_size;
Config.debugCurrentDrawCalls++;
Config.debugCurrentTriangleCount += int((float)buf->m_indexBuffer.m_size / 3.0f);
Config.debugCurrentVertexCount += buf->m_vertexBuffer.m_size;
}

void DrawSDFText(SDFTextDrawBuffer* buf)
{
if (Internal::g_backendData.m_skipDraw)
return;

SetScissors(buf->m_clipPosX, buf->m_clipPosY, buf->m_clipSizeX, buf->m_clipSizeY);
SetScissors(buf->clipPosX, buf->clipPosY, buf->clipSizeX, buf->clipSizeY);
Internal::ShaderData& data = Internal::g_backendData.m_sdfTextShaderData;
glUseProgram(data.m_handle);
glUniformMatrix4fv(data.m_uniformMap["proj"], 1, GL_FALSE, &Internal::g_backendData.m_proj[0][0]);
Expand All @@ -431,22 +431,22 @@ namespace LinaVG::Backend

glBindBuffer(GL_ARRAY_BUFFER, 0);
glDrawElements(GL_TRIANGLES, (GLsizei)buf->m_indexBuffer.m_size, sizeof(Index) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, 0);
Config.m_debugCurrentDrawCalls++;
Config.m_debugCurrentTriangleCount += int((float)buf->m_indexBuffer.m_size / 3.0f);
Config.m_debugCurrentVertexCount += buf->m_vertexBuffer.m_size;
Config.debugCurrentDrawCalls++;
Config.debugCurrentTriangleCount += int((float)buf->m_indexBuffer.m_size / 3.0f);
Config.debugCurrentVertexCount += buf->m_vertexBuffer.m_size;
}

void SetScissors(BackendHandle x, BackendHandle y, BackendHandle width, BackendHandle height)
{
if (width == 0 || height == 0)
{
x = static_cast<BackendHandle>(Config.m_displayPosX);
y = static_cast<BackendHandle>(Config.m_displayPosY);
width = static_cast<BackendHandle>(Config.m_displayWidth);
height = static_cast<BackendHandle>(Config.m_displayHeight);
x = static_cast<BackendHandle>(Config.displayPosX);
y = static_cast<BackendHandle>(Config.displayPosY);
width = static_cast<BackendHandle>(Config.displayWidth);
height = static_cast<BackendHandle>(Config.displayHeight);
}

glScissor(x, static_cast<GLint>(Config.m_displayHeight - (y + height)), static_cast<GLint>(width), static_cast<GLint>(height));
glScissor(x, static_cast<GLint>(Config.displayHeight - (y + height)), static_cast<GLint>(width), static_cast<GLint>(height));
}

void SaveAPIState()
Expand Down Expand Up @@ -559,10 +559,10 @@ namespace LinaVG::Backend
{
glGetShaderInfoLog(vertex, 512, NULL, infoLog);

if (Config.m_errorCallback)
if (Config.errorCallback)
{
Config.m_errorCallback("LinaVG: Backend Error -> Shader vertex compilation failed!");
Config.m_errorCallback(infoLog);
Config.errorCallback("LinaVG: Backend Error -> Shader vertex compilation failed!");
Config.errorCallback(infoLog);
}

throw std::runtime_error("");
Expand All @@ -578,10 +578,10 @@ namespace LinaVG::Backend
{
glGetShaderInfoLog(fragment, 512, NULL, infoLog);

if (Config.m_errorCallback)
if (Config.errorCallback)
{
Config.m_errorCallback("LinaVG: Backend Error -> Shader fragment compilation failed!");
Config.m_errorCallback(infoLog);
Config.errorCallback("LinaVG: Backend Error -> Shader fragment compilation failed!");
Config.errorCallback(infoLog);
}

throw std::runtime_error("");
Expand All @@ -596,8 +596,8 @@ namespace LinaVG::Backend
if (!success)
{
glGetProgramInfoLog(handle, 512, NULL, infoLog);
Config.m_errorCallback("LinaVG: Backend Error -> Could not link shader program!");
Config.m_errorCallback(infoLog);
Config.errorCallback("LinaVG: Backend Error -> Could not link shader program!");
Config.errorCallback(infoLog);
throw std::runtime_error("");
}

Expand Down
Loading

0 comments on commit c9453e7

Please sign in to comment.