Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon
4. September 2015


While on vacation I have been looking at the process of extending the Godot Game engine using C++.  Due to the vacation, this isn’t a proper tutorial, I may do one later on when I have access to video, etc…  There is pretty solid documentation of the process in this post on the Godot wiki beyond that however there is a huge lack of information.  So the following is mostly trial and error.


I worked entirely in Visual Studio for this example and am working from the most recent source from Github.  If you have trouble working in Visual Studio with Godot, be sure to check out this post.


We are going to have to create several files in the modules folder, but don’t worry many can be copy/pasted from an existing module.  I created a new module called modTest inside the modules folder, and the contents end up looking like:




Many I coped directly from gridmap, but I will show the entire contents below.

def can_build(platform):
  return True
def configure(env):







void register_modtest_types();
void unregister_modtest_types();



#include "register_types.h"
#include "object_type_db.h"
#include "modtest.h"
#include "modtest_editor.h"


void register_modtest_types() {


void unregister_modtest_types() {




#ifndef MODTEST_H
#define MODTEST_H

#include "scene/2d/node_2d.h"

class ModTest : public Node2D {
  OBJ_TYPE(ModTest, Node2D);




#include "modtest.h"



#pragma once

#include "tools/editor/editor_plugin.h"
#include "tools/editor/editor_node.h"
#include "tools/editor/pane_drag.h"

class ModtestEditor : public VBoxContainer {
  OBJ_TYPE(ModtestEditor, VBoxContainer);

  ModtestEditor(EditorNode * p_editor);

  VBoxContainer * container;
  Label* label;
  EditorNode* _editor;

class modtest_editor_plugin : public EditorPlugin
  OBJ_TYPE(modtest_editor_plugin, EditorPlugin);

  modtest_editor_plugin(EditorNode *p_editor);

  virtual void make_visible(bool isVisible);
  virtual void edit(Object *p_node);
  virtual bool handles(Object *p_node) const;

  EditorNode * _editor;
  ModtestEditor* modtestEditor;



#include "modtest_editor.h"
#include "tools/editor/plugins/canvas_item_editor_plugin.h"
#include "tools/editor/editor_settings.h"

#include "scene/main/viewport.h"

#include <iostream>

ModtestEditor::ModtestEditor(EditorNode* p_editor){
  std::cout << "New Modtest Editor" << std::endl;

  this->set_size(Size2(600, 600));
  label = new Label();
  label->set_text("Hello World");

  _editor = p_editor;

// **************************** PLUGIN BEGIN ********************************************

modtest_editor_plugin::modtest_editor_plugin(EditorNode * p_editor)
  _editor = p_editor;
  modtestEditor = memnew(ModtestEditor(_editor));
  std::cout << "Editor" << std::endl;


void modtest_editor_plugin::make_visible(bool isVisible){
  std::cout << "Make visible" << std::endl;
  if (isVisible){
    std::cout << "Showing" << std::endl;
    std::cout << "Hiding" << std::endl;

void modtest_editor_plugin::edit(Object *p_object) {
  std::cout << "Edit" << std::endl;

bool modtest_editor_plugin::handles(Object *p_object) const {

  return p_object->is_type("ModTest");

So that was a mountain of examples, but nothing particularly complicated.


The SCSub and files simply tell the Scons build system how to build your module, both of them can be copied in unchanged from the gridmap module.  It’s only if your module doesn’t build for every platform or you need to do something other than compile all the included cpp files that you need to alter either of these files.


Next up are the register_types cpp and h files, which registers your type with Godot.  ModTest is a simple Node2D extension type, it can be registered using ObjectTypeDB::register_type().  Additionally we have an editor we want to show when editing our new type, that is registered using EditorPlugins::add_by_type() .  The TOOLS_ENABLED means that you are building Godot with full tooling support, as opposed to building just a game (without the editor in the generated binary).


Our extension is completely pointless.  It’s inherited from Node2D and well, that’s about it.  Obviously you would add functionality as you go.  The simple fact it inherits from Node2D makes it available in Godot as a Node:



Next we register an editor and a plugin for our ModTest type.  The ModtestEditor class is going to be the editor displayed within Godot.  It’s a simple VBoxContainer.  In this case all we do is add a label with the text Hello World then add it to the editor using the passed in pointer to the EditorNode.  This is generally where the majority of logic will go.


Next up is the modtest_editor_plugin which inherits EditorPlugin.  This class is loaded with Godot by the call EditorPlugins::add_by_type<modtest_editor_plugin>().  The important call is modtest_editor_plugin::handles(), which attaches the editor to the type it edits.  In the constructor, we create an instance of our editor.  The make_visible() method is called each time the editor is needed, or no longer needed and toggles the visibility of our editor.


As you add or select a node of ModTest type, the editor will automatically be shown:



Obviously this is a barebones example.  As I implement a more detailed example I will share the results.


2. June 2015


So a lot has happened in the land of SFML since I created my SFML tutorial series and I decided to check out what’s new.  I happen to be on my Macbook, so Visual Studio wasn’t an option.  Time for a bit of a confession… I hate Xcode, especially for C++ development.  I just find it to be a downright unpleasant, disorganized, unintuitive mess and C++ is a third class citizen.  The alternatives such as Code::Blocks never really appealed to me, and Qt Creator always seems to make you jump through half a hundred extra steps.


Thankfully CLion, a cross platform C++ IDE from JetBrains, the makers of IntelliJ, was recently released.  So I decided to kill two birds with one stone…  check out what’s new with SFML and evaluate CLion all at the same time.  This involves setting up the development environment and probably the area where most new C++ game developers fall flat on their faces.


So, if you are interested in developing using SFML on Mac using CLion… this post is for you!  We are going to walk through installing SFML and configuring your very first project.


Installing SFML

First we need to download and install SFML.  There are two ways to go about this…  first you can head to SFML downloads page, download the Mac OS zip package, extra it, and copy the files to the locations specified in the readme file...


… or you can use homebrew.  This is what I did.  Assuming you have homebrew installed, at a terminal simply type:

brew update
brew install sfml

In theory this will download and install all the requisite parts of SFML.  In theory.  If it fails, go back to the manual process.


Creating a new project in CLion 

I’m going to assume at this point you’ve already got CLion installed.  If not, it’s available here and can be installed as a 30 day trial.

Once installed, fire up CLion, it’s time for us to create a new project.





Select new Project




Name however and wherever you wish, just be sure to remember the location.



In the Project panel, locate CMakeList.txt and double click it.  This file is basically your CMake based project file, which CLion uses for it’s project format, as does SFML.


CMakeList.txt will open in the editor, replace with the follow text:


cmake_minimum_required(VERSION 3.2)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES main.cpp)
add_executable(SFMLDemo ${SOURCE_FILES})

find_package(SFML REQUIRED system window graphics network audio)
    target_link_libraries(SFMLDemo ${SFML_LIBRARIES})


If you’re going to screw up, this is the part you will screw up.  Let me point out the critical portions here.


Ss3 5


Make sure your project name is set correctly everywhere I boxed in red.  Also make sure your cmake_modules directory is set right...


Oh yeah, about that… make a directory called cmake_modules.  We need to copy this file (FindSFML.cmake) into that folder.  Be sure you save as Raw if downloading from Github and make sure the extension stays cmake, not cmake.txt as Mac OS is found of doing.  Or you could just create a new file called FindSFML.cmake in CLion and copy/paste the contents.  The choice is yours, but in the end your project should look like:




Creating a Run Configuration


Now we are ready to run our application.  Select the menu Run->Edit Configuration...




Be sure to set the working directory to you project folder ( or wherever you are going to put assets ), and chose your project as the executable, then hit Apply/OK.


You should now be able to run your application using the pulldown at the top of CLion, like so:


Use the play icon to run, the bug icon to debug.


The default application should run and we should see:



Now let’s try with some actual SFML code.  Replace the contents of main.cpp with the following:

#include <SFML/Graphics.hpp>



int main() {


    sf::RenderWindow window(sf::VideoMode(640,480,32),"Hello SFML");


    sf::Font font;



    sf::Text text("Hello World",font,11);


    text.setPosition(window.getSize().x/2 - text.getGlobalBounds().width/2,

                     window.getSize().y/2 - text.getGlobalBounds().height/2);





        sf::Event event;

        while(window.pollEvent(event)) {

            if(event.type == sf::Event::Closed){









    return 0;



Finally we need the rtf file used in this example, I downloaded it from right here, and copied the file OpenSans-Bold.ttf to the root of our project directory. It is important this matches the run directory you specified earlier.  When run you should now see:





There you go, a fully configured, really to run SFML project on MacOS, without an Xcode in sight!  There is one thing to be aware of though… right now the line:

find_package(SFML REQUIRED system window graphics network audio)

Is linking in every single SFML module, needed or not.

10. May 2015



Just noticed this on Twitter and it proved to be an interesting read.  JetBrains, the makers of IntelliJ, CLion, ReSharper and more, havebook sponsored this free book from O’Reilly Press.  It’s a 74 page book that combines a history lesson, modern introduction and Modern C++ overview all into one.  It’s free and a good read, what’s not to like?




Here is the Table of Contents:


1. The Nature of the Beast. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2. The Origin Story. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3. The Beast Wakes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4. The Beast Roars Back. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5. Digging Deep on Modern C++. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6. The Future of C++. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Bibliography. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65




The book is available as a free PDF download directly at this link.  No other actions are required, simply download and read.


Even if you are just bored and want a bit of a history lesson and look to the future of C++, this is a good read.  Of course, if you are actually a C++ developer, it will be much more useful.


10. May 2015


SFML, the Simple and Fast Media Library, just release version 2.3.  SFML is a cross platform C++ based mostly 2D based game library built over top of OpenGL.  Although getting a bit long in the tooth, GameFromScratch created an SFML C++ game dev tutorial series if you are interested in learning more.


As to release 2.3, here are the announced changes:


SFML 2.3

  • Examples only link against sfml-main in release mode (#610, #766)
  • Replaced unsigned int with std::size_t for array indices and sizes (#739)
  • Fixed some issues with the Doxygen documentation (#750)
  • Added support for EditorConfig (#751)
  • Hide success message for CMake in quiet mode (#753)
  • Improved documentation for statuses with sf::Ftp (#763)
  • Moved stb_image into the extlibs directory (#795)
  • Changed the SOVERSION to major.minor (#812)
  • Fixed warnings about switch-statements (#863)
  • Added missing includes in the general headers (#851)
  • [Android] Updated toolchain file and dependencies (#791)
  • [Linux] Fixed missing pthread dependency (#794)
  • [OS X] Relaxed CMake installation rules regarding framework dependencies (#767)




  • Fixed glXSwapIntervalSGI being broken for some driver implementations (#727, #779)
  • Fixed simultaneous context operations causing crashes on some AMD hardware (#778, #779)
  • Fixed joystick identification (#809, #811)
  • [iOS] Fixed various issues including stencil bits, device orientation and retina support (#748)
  • [iOS] Fixed inconsistency between sf::Touch::getPosition and touch events (#875)
  • [Linux] Fixed Alt+F4 not getting triggered in window mode (#274)
  • [Linux] Fixed Unix joystick stuff (#838)
  • [OS X] Fixed typo in JoystickImpl.cpp to prevent a crash (#762, #765)
  • [OS X] Fixed an issue in InputImpl::getSFOpenGLViewFromSFMLWindow (#782, #792)


  • Replaced GLEW with loader generated by glLoadGen (#779)
  • Added a new constructor to sf::Color that takes an sf::Uint32 (#722)
  • Updated stb_image to v2.02 (#777)
  • Updated FreeType to v2.5.5 (#799, #804)
  • Added checks for software OpenGL (#870)


  • Fixed GL_ARB_compatibility not being detected (#859)
  • Fixed pixel format selection (#862)
  • Bumped back the OpenGL version requirement to 1.1 (#858)


  • Dropped libsndfile and started using Vorbis, FLAC and OGG directly (#604, #757)
  • Added a FLAC file to the sound example (#815)


  • Fixed access violation error in the destructor of sf::AudioDevice (#30, #602)
  • [OS X] Fixed threading issue with sf::SoundStream and OpenAL (#541, #831)


  • Fixed sf::TcpSocket not handling partial sends properly (#749, #796)


22. November 2014



The Urho3D C++ cross platform game engine just released version 1.32.  The following is the change log from this release:



  • Finalized Urho2D functionality, including 2D physics using Box2D, sprite animation and tile maps
  • Threaded background resource loading. Must be manually triggered via ResourceCache or by loading a scene asynchronously
  • Attribute and material shader parameter animation system
  • Customizable onscreen joystick for mobile platforms. Used in examples
  • Touch camera control in examples on mobile platforms
  • Touch emulation by mouse
  • Multi-touch UI drag support
  • Consistent touch ID’s across platforms
  • Absolute, relative and wrap modes for the operating system mouse cursor
  • Support for connecting & removing joysticks during runtime
  • Negative light & light brightness multiplier support
  • Transform spaces for Node’s translate, rotate & lookat functions
  • Scrollable console
  • Selectable console command interpreter (AngelScript, Lua, FileSystem)
  • Touch scroll in ScrollView & ListView
  • UI layout flex scale mode
  • Custom sound streams from C++
  • LogicComponent C++ base class with virtual update functions similar to ScriptObject
  • Signed distance field font support
  • JSON data support
  • Matrix types in Variant & XML data
  • Intermediate rendertarget refactoring: use viewport size to allow consistent UV addressing
  • ParticleEmitter refactoring: use ParticleEffect resource for consistency with ParticleEmitter2D and more optimal net replication
  • Expose LZ4 compression functions
  • Support various cube map layouts contained in a single image file
  • Configurable Bullet physics stepping behavior. Can use elapsed time limiting, or a variable timestep to use less CPU
  • Default construct math objects to zero / identity
  • Mandatory registration for remote events. Check allowed event only when receiving
  • Teapot & torus builtin objects
  • FXAA 3.11 shader
  • Triangle rendering in DebugRenderer (more efficient than 3 lines)
  • Material/texture quality and anisotropy as command line options and engine startup parameters
  • Spline math class, which the SplinePath component uses
  • Console auto-show on error
  • DrawableProxy2D system for optimizing 2D sprite drawing
  • Possibility to decouple BorderImage border UV’s from element size
  • Editor & NinjaSnowWar resources split into subdirectories
  • UI hover start & end events
  • UI drag cancel by pressing ESC
  • Allowed screen orientations can be controlled. Effective only on iOS
  • Rendering sceneless renderpaths
  • Define individual material passes as SM3-only
  • Support for copying ListView text to system clipboard
  • Async system command execution
  • Generic attribute access for Lua script objects
  • Use Lua functions directly as event subscribers
  • Touch gesture recording and load/save
  • AssetImporter option to allow multiple import of identical meshes
  • Automatically create a physics world component to scene when necessary
  • GetSubimage function in the Image class
  • Possibility to clone existing components from another scene node
  • Improve terrain rendering on mobile devices
  • Refactoring of camera facing modes in BillboardSet & Text3D
  • Additive alpha techniques for particle rendering
  • Possibility to use CustomGeometry component for physics triangle mesh collision
  • Access to 2D node coordinates for convenience when using 2D graphics features
  • Save embedded textures in AssetImporter
  • Use best matching fullscreen resolution if no exact match
  • Use SDL_iPhoneSetAnimationCallback instead of blocking main loop
  • Allow fast partial terrain updates by modifying the heightmap image
  • API for setting image pixels by integer colors
  • Refactor to remove the separate ShortStringHash class
  • Deep clone functionality in Model resource
  • Zone can define a texture which is available to shaders. Not used by default
  • Allow logging from outside the main thread
  • Log warnings for improper attempts to use events from outside main thread
  • Improved CustomGeometry dynamic updates
  • ConvexCast function in PhysicsWorld
  • Screen to world space conversion functions in Viewport class
  • Allow sending client rotation to server in addition to position
  • Allow accessing and modifying the engine’s next timestep
  • DeepEnabled mechanism for disabling node or UI element hierarchies and then restoring their own enabled state
  • Allow to prevent closing a modal window with ESC
  • Per-viewport control of whether debug geometry should render
  • Optional interception of resource requests
  • Readded optional slow & robust mode to AreaAllocator
  • Optionally disable RigidBody mass update to allow fast adding of several CollisionShape components to the same node
  • Runtime synchronization of resource packages from server to client
  • Disable multisample antialiasing momentarily during rendering. Used by default for UI & quad rendering
  • Glyph offset support in Font class
  • Font class internal refactoring
  • Allow to create AngelScript script objects by specifying the interface it implements
  • Window position startup parameters
  • Functions to get time since epoch & modify file’s last modified time
  • Optionally auto-disable child elements of a scroll view when touch scrolling
  • Allocate views permanently per viewport to allow querying for drawables, lights etc. reliably
  • Allow to specify material techniques/passes that should not be used on mobile devices
  • Reduced default shadow mapping issues on mobile devices
  • Minor rendering optimizations
  • Build system: possibility to build Urho3D without networking or 2D graphics functionality
  • Build system: improved generated scripting documentation
  • Build system: improved support for IDE’s in CMake scripts
  • Build system: support up to Android NDK r10c and 64-bit ABIs
  • Build system: numerous other improvements
  • Editor: resource browser
  • Editor: spawn window for random-generating objects
  • Editor: allow either zoom or move from mouse wheel
  • Editor: locate object by doubleclicking node in hierarchy
  • Editor: take screenshots with F11, camera panning
  • Editor: button in value edit fields that allows editing by mouse drag
  • Updated SDL to 2.0.3.
  • Updated AngelScript to 2.29.1
  • Updated assimp
  • Updated Recast/Detour
  • Fix MinGW build issues
  • Fix techniques referring to wrong shaders
  • Fix Node::LookAt() misbehaving in certain situations
  • Fix resize event not reporting correct window size if window is maximized at start
  • Fix PhysicsWorld::GetRigidBodies() not using collision mask
  • Fix zone misassignment issues
  • Fix Lua not returning correctly typed object for UIElement::GetChild() & UIElement::GetParent()
  • Fix uninitialized variables in 2D physics components
  • Fix quad rendering not updating elapsed time uniform
  • Fix forward rendering normal mapping issues by switching calculations back to world space
  • Fix wrong logging level on Android
  • Fix multiple subscribes to same event on Lua
  • Fix missing Octree update in headless mode
  • Fix crash when using FreeType to access font kerning tables
  • Fix ReadString() endless loop if the string does not end
  • Fix shadow mapping on OS X systems with Intel GPU
  • Fix manually positioned bones being serialized properly
  • Fix file checksum calculation on Android
  • Fix accelerometer input on Android when device is flipped 180 degrees
  • Fix missing or misbehaving Lua bindings
  • Fix crashes in physics collision handling when objects are removed during it
  • Fix shader live reload if previous compile resulted in error
  • Fix named manual textures not recreating their GPU resource after device loss
  • Fix skeleton-only model not importing in AssetImporter
  • Fix terrain raycast returning incorrect position/normal
  • Fix animation keyframe timing in AssetImporter if start time is not 0
  • Fix storing Image resources to memory unnecessarily during cube/3D texture loading
  • Fix to node transform dirtying mechanism and the TransformChanged() script function
  • Fix returned documents directory not being writable on iOS
  • Fix click to emptiness not closing a menu
  • Fix FileWatcher notifying when file was still being saved. By default delay notification 1 second
  • Fix .txml import in the editor
  • Fix erroneous raycast to triangles behind the ray
  • Fix crash when multiple AnimatedModels exist in a node and the master model is destroyed
  • Fix missing Matrix4 * Matrix3x4 operator in script
  • Fix various compile warnings that leak to applications using Urho3D
  • Fix DebugHud update possibly being late one frame
  • Fix various macros not being usable outside Urho3D namespace
  • Fix erroneous layout with wordwrap text elements
  • Fix debug geometry rendering on flipped OpenGL viewports
  • Fix kNet debug mode assert with zero sized messages
  • Fix not being able to stop and restart kNet server
  • Fix AreaAllocator operation
  • Fix possible crash with parented rigidbodies
  • Fix missing network delta update if only user variables in a Node have been modified
  • Fix to only search for June 2010 DirectX SDK, as earlier SDK’s will fail
  • Fix wrong search order of added resource paths
  • Fix global anisotropic filtering on OpenGL
  • Fix animation triggers not working if trigger is at animation end
  • Fix CopyFramebuffer shader name not being used correctly on case-sensitive systems
  • Fix UI elements not receiving input when the window containing them is partially outside the screen to the left
  • Fix occlusion rendering not working with counterclockwise triangles
  • Fix material shader parameter animations going out of sync with other animations when the object using the material is not in view
  • Fix CPU count functions on Android


You can download the library here.


The project homepage is available here.


GFS On YouTube

See More Tutorials on!

Month List