Skip to content
Snippets Groups Projects
Commit 6a7266d4 authored by Abdulhadi Al-Sayed's avatar Abdulhadi Al-Sayed
Browse files

Added release build for optimized math (around 70 fps), there is a crucial...

Added release build for optimized math (around 70 fps), there is a crucial memory leak in this build, do not run the program for a long time!
parent bb60a857
No related branches found
No related tags found
No related merge requests found
...@@ -70,8 +70,7 @@ target_link_libraries( ...@@ -70,8 +70,7 @@ target_link_libraries(
spdlog spdlog
stb stb
tinyobjloader tinyobjloader
OpenGL::GL OpenGL::GL)
)
# OPTIONS # OPTIONS
......
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": ""
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": []
}
]
}
\ No newline at end of file
...@@ -51,13 +51,13 @@ private: ...@@ -51,13 +51,13 @@ private:
engine::ObjectLibrary* s_ObjectLibrary; engine::ObjectLibrary* s_ObjectLibrary;
engine::ShaderLibrary* s_ShaderLibrary; engine::ShaderLibrary* s_ShaderLibrary;
Pacman* m_Player; engine::s_Ptr<Pacman> m_Player;
std::vector<Ghost*> m_Ghosts; //Initialising an array of ghosts std::vector<engine::s_Ptr<Ghost>> m_Ghosts; //Initialising an array of ghosts
std::vector<Wall*> m_Walls; std::vector<engine::s_Ptr<Wall>> m_Walls;
std::vector<Pellet*> m_Pellets; std::vector<engine::s_Ptr<Pellet>> m_Pellets;
Collision* m_Collision = new Collision(); engine::s_Ptr <Collision> m_Collision = engine::m_SPtr<Collision>();
}; };
Map::Map() { Map::Map() {
...@@ -103,12 +103,12 @@ Map::Map() { ...@@ -103,12 +103,12 @@ Map::Map() {
switch (value) { switch (value) {
case 1: // Wall case 1: // Wall
{ {
m_Walls.push_back(new Wall(i + offsetX + cam.x, j + offsetY + cam.y, 0.f + cam.z, 0.f, 3.f, 3.f)); m_Walls.push_back(engine::m_SPtr<Wall>(i + offsetX + cam.x, j + offsetY + cam.y, 0.f + cam.z, 0.f, 3.f, 3.f));
break; break;
} }
case 2: // Player/Pacman case 2: // Player/Pacman
{ {
m_Player = new Pacman(); m_Player = engine::m_SPtr<Pacman>();
m_Player->setPosition({ i + offsetX + cam.x, j + offsetY + cam.y, 0.f + cam.z }); m_Player->setPosition({ i + offsetX + cam.x, j + offsetY + cam.y, 0.f + cam.z });
m_Player->setNextPosition({ i + offsetX + cam.x, j + offsetY + cam.y, 0.f + cam.z }); m_Player->setNextPosition({ i + offsetX + cam.x, j + offsetY + cam.y, 0.f + cam.z });
m_Player->setSize({ 1.5f, 1.5f, 1.5f }); m_Player->setSize({ 1.5f, 1.5f, 1.5f });
...@@ -116,14 +116,14 @@ Map::Map() { ...@@ -116,14 +116,14 @@ Map::Map() {
break; break;
} }
case 0: // Pellets and Ghosts case 0: // Pellets and Ghosts
m_Pellets.push_back(new Pellet(i + offsetX + cam.x, j + offsetY + cam.y, 0.f + cam.z, 0.5f, 0.5f, 0.5f)); m_Pellets.push_back(engine::m_SPtr<Pellet>(i + offsetX + cam.x, j + offsetY + cam.y, 0.f + cam.z, 0.5f, 0.5f, 0.5f));
// Ghost random position generation // Ghost random position generation
randomNumber = numDistribution(rando); randomNumber = numDistribution(rando);
// Generate new random number for random ghost placement // Generate new random number for random ghost placement
if (randomNumber == 3 && m_Ghosts.size() < 4) { if (randomNumber == 3 && m_Ghosts.size() < 4) {
m_Ghosts.push_back(new Ghost()); m_Ghosts.push_back(engine::m_SPtr<Ghost>());
m_Ghosts.back()->setPosition({ i + offsetX + cam.x, j + offsetY + cam.y, 0.f + cam.z }); m_Ghosts.back()->setPosition({ i + offsetX + cam.x, j + offsetY + cam.y, 0.f + cam.z });
m_Ghosts.back()->setNextPosition({ i + offsetX + cam.x, j + offsetY + cam.y, 0.f + cam.z }); m_Ghosts.back()->setNextPosition({ i + offsetX + cam.x, j + offsetY + cam.y, 0.f + cam.z });
m_Ghosts.back()->setSize({ 1.5f, 1.5f, 1.5f }); m_Ghosts.back()->setSize({ 1.5f, 1.5f, 1.5f });
......
...@@ -8,15 +8,15 @@ ...@@ -8,15 +8,15 @@
class PacmanGame : public engine::AppFrame { class PacmanGame : public engine::AppFrame {
public: public:
PacmanGame() : AppFrame() { PacmanGame() : AppFrame() {
//pushLayer(new ExampleLayer()); //pushLayer(NEW ExampleLayer());
pushLayer(new GameLayer); pushLayer(NEW GameLayer);
} }
PacmanGame(engine::WindowSpecs specs) : AppFrame(specs) { PacmanGame(engine::WindowSpecs specs) : AppFrame(specs) {
setAppIcon("assets/textures/pacman3.png"); // Window icon setAppIcon("assets/textures/pacman3.png"); // Window icon
pushLayer(new GameLayer); pushLayer(NEW GameLayer);
} }
......
...@@ -119,14 +119,14 @@ private: ...@@ -119,14 +119,14 @@ private:
class Sandbox : public engine::AppFrame { class Sandbox : public engine::AppFrame {
public: public:
Sandbox() : engine::AppFrame() { Sandbox() : engine::AppFrame() {
//pushLayer(new ExampleLayer()); //pushLayer(NEW ExampleLayer());
pushLayer(new SandboxLayer); pushLayer(NEW SandboxLayer);
} }
Sandbox(engine::WindowSpecs specs) : engine::AppFrame(specs) { Sandbox(engine::WindowSpecs specs) : engine::AppFrame(specs) {
//pushLayer(new ExampleLayer()); //pushLayer(new ExampleLayer());
pushLayer(new SandboxLayer); pushLayer(NEW SandboxLayer);
} }
......
...@@ -94,7 +94,11 @@ target_compile_definitions(Engine PUBLIC GLFW_INCLUDE_NONE ENABLE_ASSERTS) # Uni ...@@ -94,7 +94,11 @@ target_compile_definitions(Engine PUBLIC GLFW_INCLUDE_NONE ENABLE_ASSERTS) # Uni
if (WIN32 OR CYGWIN) if (WIN32 OR CYGWIN)
# WINDOWS AND CYGWIN COMPILER # WINDOWS AND CYGWIN COMPILER
target_compile_definitions(Engine PUBLIC PLATFORM_WINDOWS) target_compile_definitions(Engine PUBLIC PLATFORM_WINDOWS)
if(CMAKE_BUILD_TYPE STREQUAL "Debug") # Check build type for multithreading application
target_compile_options(Engine PRIVATE /EHsc /MDd /c /MP) # Multithreading for libraries target_compile_options(Engine PRIVATE /EHsc /MDd /c /MP) # Multithreading for libraries
else()
target_compile_options(Engine PRIVATE /EHsc /MD /c /MP) # Multithreading for libraries
endif()
endif (WIN32 OR CYGWIN) endif (WIN32 OR CYGWIN)
if (UNIX) if (UNIX)
# UNIX (including MAC OS X) # UNIX (including MAC OS X)
......
#pragma once #pragma once
#ifdef _DEBUG
#define NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
#else
#define NEW new
#endif
/* /*
* engine.h is the static lib header file to access engine and STL tools * engine.h is the static lib header file to access engine and STL tools
*/ */
......
...@@ -3,19 +3,31 @@ ...@@ -3,19 +3,31 @@
* the application uses the lib as a dependency * the application uses the lib as a dependency
*/ */
#pragma once #pragma once
#define _CRTDBG_MAP_ALLOC
#include <cstdlib>
#include <crtdbg.h>
#include <iostream> #include <iostream>
#include "logger.h" #include "logger.h"
#include "app-frame.h" #include "app-frame.h"
#ifdef _DEBUG
#define NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
// Replace _NORMAL_BLOCK with _CLIENT_BLOCK if you want the
// allocations to be of _CLIENT_BLOCK type
#else
#define NEW new
#endif
// Declare that the createApp function should be defined in the client application // Declare that the createApp function should be defined in the client application
extern engine::u_Ptr<engine::AppFrame> engine::createApp(); extern engine::u_Ptr<engine::AppFrame> engine::createApp();
int main(int argc, char** argv) { int main(int argc, char** argv) {
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
//Intro //Intro
std::cout << "Engine is running ...\n"; std::cout << "Engine is running ...\n";
// Logger // Logger
auto logger = new engine::Logger(); // Define logger auto logger = NEW engine::Logger(); // Define logger
ENGINE_INFO("Logger is running ..."); // Test logger ENGINE_INFO("Logger is running ..."); // Test logger
// Define a base application for the client to run on // Define a base application for the client to run on
......
...@@ -5,6 +5,12 @@ ...@@ -5,6 +5,12 @@
*/ */
#pragma once #pragma once
#ifdef _DEBUG
#define NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
#else
#define NEW new
#endif
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <memory> #include <memory>
......
...@@ -55,8 +55,8 @@ namespace engine { ...@@ -55,8 +55,8 @@ namespace engine {
Static members Static members
*/ */
s_Ptr<RenderAPI> Renderer::s_RenderAPI = m_SPtr<RenderAPI>(); s_Ptr<RenderAPI> Renderer::s_RenderAPI = m_SPtr<RenderAPI>();
engine::ObjectLibrary* Renderer::s_ObjectLibrary = new engine::ObjectLibrary(); engine::ObjectLibrary* Renderer::s_ObjectLibrary = NEW engine::ObjectLibrary();
engine::ShaderLibrary* Renderer::s_ShaderLibrary = new engine::ShaderLibrary(); engine::ShaderLibrary* Renderer::s_ShaderLibrary = NEW engine::ShaderLibrary();
static RendererStorage s_Data; static RendererStorage s_Data;
static RendererStorage3D s_3DData; static RendererStorage3D s_3DData;
...@@ -73,7 +73,7 @@ namespace engine { ...@@ -73,7 +73,7 @@ namespace engine {
DATA DEFINITION FOR QUAD DRAWING DATA DEFINITION FOR QUAD DRAWING
*/ */
s_Data.quadVertexArray = m_SPtr<VertexArray>(); s_Data.quadVertexArray = m_SPtr<VertexArray>();
s_Data.quadVertexBufferStore = new QuadVertex[s_Data.MAXVERTICES]; s_Data.quadVertexBufferStore = NEW QuadVertex[s_Data.MAXVERTICES];
// Vertex default positioning // Vertex default positioning
s_Data.quadVertexPositions[0] = { -0.5f, -0.5f, 0.0f, 1.0f }; s_Data.quadVertexPositions[0] = { -0.5f, -0.5f, 0.0f, 1.0f };
...@@ -93,7 +93,7 @@ namespace engine { ...@@ -93,7 +93,7 @@ namespace engine {
s_Data.quadVertexArray->setVertexBuffer(s_Data.quadVertexBuffer); s_Data.quadVertexArray->setVertexBuffer(s_Data.quadVertexBuffer);
// Index // Index
uint32_t* quadIndices = new uint32_t[s_Data.MAXINDICES]; uint32_t* quadIndices = NEW uint32_t[s_Data.MAXINDICES];
// Set indices to ptr // Set indices to ptr
uint32_t offset = 0; uint32_t offset = 0;
for (uint32_t i = 0; i < s_Data.MAXINDICES; i += 6) { for (uint32_t i = 0; i < s_Data.MAXINDICES; i += 6) {
......
...@@ -59,7 +59,7 @@ namespace engine { ...@@ -59,7 +59,7 @@ namespace engine {
// Context options // Context options
glfwSetWindowUserPointer(m_Window, &m_Specs); // Window context details glfwSetWindowUserPointer(m_Window, &m_Specs); // Window context details
setVSync(true); // Vsync on by default setVSync(false); // Vsync off by default
/* /*
The following callback functions utilize the GLFW library to abstract window events The following callback functions utilize the GLFW library to abstract window events
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment