new_project - ryzom/ryzomcore GitHub Wiki


title: Set up a new personal NeL project description: published: true date: 2023-05-27T22:10:01.222Z tags: editor: markdown dateCreated: 2023-03-24T10:12:17.136Z

A very minimal game application can be created that will print the text "Hello, World!" in the upper left of the screen.

In this series of tutorials, we will guide you through setting up a personal NeL project, creating an initial main.cpp file, configuring CMake, and initializing the NeL driver to open up a blank window with a basic game loop. After that, you will learn how to create a simple text renderer, render the text, and position it on the screen.

This tutorial assumes you've already succeeded in building the NeL source code using Visual Studio on Windows or using GCC on Linux.

Project Setup

Create your personal CMake project

Create a new CMakeLists.txt text file in the ryzomcore/personal folder. This file will contain the settings used to generate the application executable.

FILE(GLOB SRCS *.cpp)
FILE(GLOB HDRS *.h)
FILE(GLOB RECS *.rc)

SOURCE_GROUP("" FILES ${SRCS} ${HDRS} ${RECS})
ADD_EXECUTABLE(tutorial_game ${SRCS} ${HDRS} ${RECS})

TARGET_LINK_LIBRARIES(tutorial_game nelmisc nel3d nelsound)
NL_DEFAULT_PROPS(tutorial_game "Tutorial Game")
NL_ADD_RUNTIME_FLAGS(tutorial_game)

INSTALL(TARGETS my_game RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT personal)

Add a main source code file

Create a new main.cpp text file inside the same ryzomcore/personal folder. This file will serve as the code entry point for your "My Game" project.

// Driver container class
class CDriver
{
public:
	CDriver();
	~CDriver();
	void run();

protected:
  // The graphic driver
};

// Initialize game resources
CDriver::CDriver()
{
	// Initialize the graphics driver
}

// Release game resources
CDriver::~CDriver()
{
	// Release the driver's resources
}

// Main loop
void CDriver::run()
{
	// Main driver loop
}

// Handle events
// ...

// Main function
int main(int argc, char *argv[])
{
	// Create the application context
	CApplicationContext applicationContext;

	// Defining the game
	CDriver myGame;
  
	// Run the game
	myGame.run();

	return EXIT_SUCCESS;
}

This source files sets up the application singleton context for NeL, and prepares an empty game class to get started.

Reconfigure and build

Reconfigure CMake with the -DWITH_PERSONAL=ON build setting, using your command line terminal from the ryzomcore/build folder. This will add a new "Tutorial Game" project (referenced from ryzomcore/personal) to ryzomcore/build, and regenerate the whole ryzomcore/build/RyzomCore.sln solution.

cmake -DWITH_PERSONAL=ON ..

Or use the CMake GUI to add the option.

Configuring the libraries on Windows

Open the ryzomcore/build/RyzomCore.sln solution, and set "Tutorial Game" as the startup project (right click the project title to open the menu, and select Set as Startup Project). Right click the "Tutorial Game" project again, select Properties to open the Tutorial Game property window. In this property window, select the Debugging header, and locate the Environment line. Open the <Edit...> window option by clicking in the blank value field, and fill the top text edit with the whole PATH text block from below (it's the path to the external packages's binaries):

PATH=C:\2022q2_external_v143_x64\zlib\bin;C:\2022q2_external_v143_x64\curl\bin;C:\2022q2_external_v143_x64\openssl\bin;C:\2022q2_external_v143_x64\libjpeg\bin;C:\2022q2_external_v143_x64\libpng\bin;C:\2022q2_external_v143_x64\libxml2\bin;C:\2022q2_external_v143_x64\freetype\bin;C:\2022q2_external_v143_x64\ogg\bin;C:\2022q2_external_v143_x64\vorbis\bin;C:\2022q2_external_v143_x64\openal-soft\bin;C:\2022q2_external_v143_x64\lua\bin;C:\2022q2_external_v143_x64\luabind\bin;C:\2022q2_external_v143_x64\mariadb-connector-c\bin;C:\2022q2_external_v143_x64\assimp\bin;C:\2022q2_external_v143_x64\ffmpeg\bin;C:\2022q2_external_v143_x64\gles\bin;C:\2022q2_external_v143_x64\msquic\bin;C:\2022q2_external_v143_x64\protobuf\bin;C:\2022q2_external_v143_x64\squish\bin;C:\2022q2_external_v143_x64\qt5\bin;C:\2022q2_external_v143_x64\qt5\plugins;%PATH%
QT_PLUGIN_PATH=C:\2022q2_external_v143_x64\qt5\plugins

Press OK twice to close the modals, then save the "Tutorial Game" project. The external libraries are now fully referenced.

Switch to the Debug build target, and hit the Build Solution button to build your "Tutorial Game" project.

Configuring the libraries on Linux

Just run Ninja to build your new project.

ninja

What's next

  • In the next part of this tutorial series, you will learn how to write a main game loop.
⚠️ **GitHub.com Fallback** ⚠️