Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X

Solkraft Tutorial 1: Basic File Structure

This tutorial will cover how to set up the basic file structure of a new project in the Solkraft Engine.

First go to the Solkraft SVN folder, then go to the SolKraftEngine\projects within. Here you should make a new folder with your project’s name. Within this new folder, create two new folders called “resourcefiles” and “code”. In this “root” folder of your new project, create a .txt file called “CMakeLists.txt” and within it write the text “SUBDIRS(code)” so it looks like this:

SUBDIRS(code)

And your current file structure should look like this:

SolKraftEngine\projects\yourprojectname\CMakeLists.txt
SolKraftEngine\projects\yourprojectname\code
SolKraftEngine\projects\yourprojectname\resourcefiles

Next up is setting up the \code folder. In here, create files so it looks like this:

SolKraftEngine\projects\yourprojectname\code\yourprojectname.cpp
SolKraftEngine\projects\yourprojectname\code\yourprojectname.h
SolKraftEngine\projects\yourprojectname\code\main.cpp
SolKraftEngine\projects\yourprojectname\code\CMakeLists.txt

These files need some code in them. For now just copy-pasting the following will be sufficient. Let’s start with the CMakeLists.txt file, it should look like this:

INCLUDE_DIRECTORIES(
${SOLROOT}/code/Core
${SOLROOT}/code/Manager
)

FILE(GLOB SRC “*.cpp”)
FILE(GLOB HEAD “*.h”)
LIST(APPEND SRCSBASE ${SRC} ${HEAD})
SOURCE_GROUP(“yourprojectname” FILES ${SRCSBASE})

LIST(APPEND COMPLETESRC ${SRCSBASE})

ADD_EXECUTABLE(yourprojectname${ProjRoot} ${COMPLETESRC})

ADD_DEPENDENCIES(yourprojectname${ProjRoot} Core Managers)

target_link_libraries(yourprojectname${ProjRoot} Core Managers)

Take care to replace every “yourprojectname” with your actual project name. Now on to the c++ files, let’s start with main.cpp, copy-paste this:

#include “yourprojectname.h”

int main()
{
yourprojectname t_Game;

t_Game.setEngineRoot(“X:/yourpath/yourpath/SVNfoldername/SolKraftEngine/”);
t_Game.setProjectName(“yourprojectname”);

t_Game.go();
}

Again, make sure to replace every yourprojectname with your actual project name. As for the setEngineRoot function, set it to your own drive letter and file path to the SolKraftEngine folder on your computer. Next up is the .h file that is named after your project name, it should look like this:

#include “Application\Application.h”

class yourprojectname : public Application
{
public:
yourprojectname();
~yourprojectname();

void setupStates();
bool intialize();
};

And then straight on to the .cpp file, which should look like this:

#include”yourprojectname.h”
#include”StateManager.h”

yourprojectname::yourprojectname()
{
}

yourprojectname::~yourprojectname()
{
}

void yourprojectname::setupStates()
{
}

bool yourprojectname::intialize()
{
Application::intialize();

//Init game specific stuff here

this->setupStates();
return true;
}

At this point you should be able to run CMake on your project and compile it without any issues.

Leave a comment  

name*

email*

website

Submit comment