Skip to content

Commit

Permalink
Merge pull request #6 from wowvain-dev/application-layer
Browse files Browse the repository at this point in the history
Application layer
  • Loading branch information
wowvain-dev authored Mar 24, 2024
2 parents 88b7bef + 9508227 commit b66b9d0
Show file tree
Hide file tree
Showing 15 changed files with 527 additions and 647 deletions.
27 changes: 12 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ Mostly educational but planning to be serious about it. I would like it to be my

## Components
- **Vane**: The main engine, should compile to a DLL and be used as a library.
- **VaneEditor**: The editor of the engine, will link with Vane. Uses Qt.
- **VaneEditor**: The editor of the engine, will link with Vane. Uses ~~Qt~~ ImGui.
- **Sandbox**: A testbed for the engine.

## Installation

#### INSTALLATION INSTRUCTIONS AREN'T UP-TO-DATE. I AM NOW USING PREMAKE INSTEAD OF CMAKE.
#### Will update soon.

The installation / build process is highly unstable at the moment as I am still figuring some stuff out with CMake and vcpkg. If it doesn't work, create an issue and I might be able to help.
The installation / build process is highly unstable at the moment as I am still figuring some stuff out with Premake5 and vcpkg. If it doesn't work, create an issue and I might be able to help.

### Pre-build binaries

Expand All @@ -35,19 +32,19 @@ The installation / build process is highly unstable at the moment as I am still
#### Windows

1. Clone the repository: `git clone https://github.com/wowvain-dev/VaneEngine`
2. Install `vcpkg` from: `https://github.com/microsoft/vcpkg`
2. Install `vcpkg` from: https://github.com/microsoft/vcpkg
3. Set the `VCPKG_ROOT` environment variable to where you cloned the `vcpkg` repo.
4. Make sure CMake is properly installed. Required version >= 3.24
5. Set up the `CMakePresets.json` according to where you want your buildtree to be (where `vcpkg` installs packages, it must be a really short path, max depth maybe 3-4)
6. Run `cmake --preset=MSVC` in the root directory of VaneEngine (you need Visual Studio 2022 properly installed with the appropriate C++ development build tools)
7. Run `cmake --build build/` in the root directory of VaneEngine.
8. You can now find the binaries in:
- `build/<platform>-<compiler>-<arch>-<rel|dbg>/Vane/`
- `build/<platform>-<compiler>-<arch>-<rel|dbg>/VaneEditor/`
- `build/<platform>-<compiler>-<arch>-<rel|dbg>/VaneSandbox/`
4. Make sure to download `Premake5` from https://premake.github.io/download and Lua from https://www.lua.org/download.html (also make sure to put them somewhere on the %PATH% env variable)
5. Make sure you have the `gcc/g++` compiler installed.
6. Run `premake5 gmake` (haven't tested VS2017 build config yet, will do)
7. Run `make`
8. The binaries will be found in `build/[triplet]/{Sandbox | VaneEngine | Vane}`

#### Linux

Most of the steps are the same as on Windows. Make sure to have `build-essentials` installed before trying to compile the project.
Most of the steps are the same as on Windows.

Extra dependencies: [***WORK IN PROGRESS***]

For now you can just run `premake5 gmake` and see what build fails, find the lib missing which caused the failure, install it, and repeat until it fully builds.

27 changes: 16 additions & 11 deletions Sandbox/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,24 @@

#include <iostream>
#include <entry.h>
#include <Core/Logger.h>
#include <Platform/Platform_Linux.h>

int main(int argc, char** argv) {
Vane::LinuxPlatform platform;
if (platform.startup("Vane Engine Sandbox", 100, 100, 1280, 720)) {
while (true) {
platform.consoleWrite("test\n", Vane::LOG_LEVEL::V_FATAL);
platform.pumpMessages();
}
}
#include <Core/Application.h>

platform.shutdown();
using namespace Vane;

int main(int argc, char **argv)
{
ApplicationConfig config = {
.startPosX = 100,
.startPosY = 100,
.startWidth = 500,
.startHeight = 500,
.name = "Sandbox"};

auto app = new Application;

app->create(&config);
app->run();

return 0;
}
57 changes: 57 additions & 0 deletions Vane/Core/Application.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "Application.h"

using namespace Vane;

bool Application::create(ApplicationConfig* config) {
if (Application::initialised) {
VFATAL("Application::create called more than once.");
return false;
}

Logger::initializeLogging();

// TODO(wowvain-dev): Remove later, used for testing
VFATAL("A test message: %f", 3.14f);
VERROR("A test message: %f", 3.14f);
VWARN("A test message: %f", 3.14f);
VINFO("A test message: %f", 3.14f);
VDEBUG("A test message: %f", 3.14f);
VTRACE("A test message: %f", 3.14f);

isRunning = true;
isSuspended = false;

#ifdef VPLATFORM_WINDOWS
platform = new WindowsPlatform();
#elif VPLATFORM_LINUX
platform = new LinuxPlatform();
#endif

if(!platform->startup(
config->name.c_str(),
config->startPosX,
config->startPosY,
config->startWidth,
config->startHeight)) {
VFATAL("Couldn't startup platform properly!");
return false;
}

Application::initialised = true;

return true;
}

bool Application::run() {
while(isRunning) {
if(!platform->pumpMessages()) {
isRunning = false;
}
}

isRunning = false;

platform->shutdown();

return true;
}
58 changes: 58 additions & 0 deletions Vane/Core/Application.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//////////////////////////////////////////////////////////////////////////////////////////
// Copyright wowvain-dev | Bogdan Stanciu (c) 2024.
//
// MIT License
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////////////////
#pragma once

#include "../Platform/Platform.h"
#include "Logger.h"
#include "Defines.h"
#include <string>

#ifdef VPLATFORM_WINDOWS
#include "../Platform/Platform_Win32.h"
#elif VPLATFORM_LINUX
#include "../Platform/Platform_Linux.h"
#endif

using std::string;

namespace Vane {

struct VAPI ApplicationConfig {
i16 startPosX;
i16 startPosY;
i16 startWidth;
i16 startHeight;

string name;
};

class VAPI Application {
private:
VAPI static bool initialised;
ApplicationConfig startConfig;

bool isRunning;
bool isSuspended;
Platform* platform;
i16 width;
i16 height;
f64 lastTime;


public:
bool create(ApplicationConfig* config);
bool run();

};

bool Application::initialised = false;

};
2 changes: 1 addition & 1 deletion Vane/Core/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Vane {
V_TRACE = 5
};

class VAPI Logger {
class Logger {
public:

private:
Expand Down
4 changes: 4 additions & 0 deletions Vane/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ all: prebuild prelink $(TARGET)
endif

OBJECTS := \
$(OBJDIR)/Application.o \
$(OBJDIR)/Logger.o \
$(OBJDIR)/Platform_Linux.o \
$(OBJDIR)/entry.o \
Expand Down Expand Up @@ -126,6 +127,9 @@ else
$(OBJECTS): | $(OBJDIR)
endif

$(OBJDIR)/Application.o: Core/Application.cpp
@echo $(notdir $<)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/Logger.o: Core/Logger.cpp
@echo $(notdir $<)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
Expand Down
21 changes: 0 additions & 21 deletions VaneEditor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,6 @@
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////////////////

#define SDL_MAIN_HANDLED

#include <SDL2/SDL.h>
#include <Core/Logger.h>
#include <Core/Asserts.h>

int main(int argc, char *argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
VFATAL("Error initialising SDL for the editor interface.");
return 1;
}
SDL_Window* window = SDL_CreateWindow("Vane Engine - Editor",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1000, 1000, 0
);

VDEBUG("Started window...");

VASSERT_DEBUG(1 == 0);

getchar();

return 0;
}
14 changes: 8 additions & 6 deletions build-objs/dbg-linux-x64/Sandbox/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,11 @@
/usr/include/c++/13/bits/basic_ios.tcc \
/usr/include/c++/13/bits/ostream.tcc /usr/include/c++/13/istream \
/usr/include/c++/13/bits/istream.tcc ../Vane/entry.h \
../Vane/Core/Logger.h ../Vane/Core/Defines.h /usr/include/c++/13/cstdint \
../Vane/Core/Application.h ../Vane/Core/../Platform/Platform.h \
../Vane/Core/../Platform/../Core/Defines.h /usr/include/c++/13/cstdint \
/usr/lib/gcc/x86_64-redhat-linux/13/include/stdint.h \
/usr/include/stdint.h /usr/include/bits/stdint-uintn.h \
../Vane/Platform/Platform_Linux.h ../Vane/Platform/Platform.h \
../Vane/Core/Logger.h ../Vane/Core/../Platform/Platform_Linux.h \
/usr/include/xcb/xcb.h /usr/include/sys/uio.h \
/usr/include/bits/types/struct_iovec.h /usr/include/bits/uio_lim.h \
/usr/include/bits/uio-ext.h /usr/include/xcb/xproto.h \
Expand Down Expand Up @@ -339,14 +340,15 @@
/usr/include/c++/13/istream:
/usr/include/c++/13/bits/istream.tcc:
../Vane/entry.h:
../Vane/Core/Logger.h:
../Vane/Core/Defines.h:
../Vane/Core/Application.h:
../Vane/Core/../Platform/Platform.h:
../Vane/Core/../Platform/../Core/Defines.h:
/usr/include/c++/13/cstdint:
/usr/lib/gcc/x86_64-redhat-linux/13/include/stdint.h:
/usr/include/stdint.h:
/usr/include/bits/stdint-uintn.h:
../Vane/Platform/Platform_Linux.h:
../Vane/Platform/Platform.h:
../Vane/Core/Logger.h:
../Vane/Core/../Platform/Platform_Linux.h:
/usr/include/xcb/xcb.h:
/usr/include/sys/uio.h:
/usr/include/bits/types/struct_iovec.h:
Expand Down
Binary file modified build-objs/dbg-linux-x64/Sandbox/main.o
Binary file not shown.
Loading

0 comments on commit b66b9d0

Please sign in to comment.