Home > Releases > Simple2D 1.12 now available

Simple2D 1.12 now available

November 9, 2013 Leave a comment Go to comments

A new major release of Simple2D is now available (the download link can be found at the bottom of the page).

Version 1.12 has a key focus on:

  • An improved, cleaner initialization interface
  • Basic Direct3D support including the ability to draw with both Direct2D and Direct3D onto the same render target
  • Full editing support for text boxes (navigation, editing, selection, Windows clipboard and infinite undo)
  • Some improvements to XInput gamepad support
  • Numerous bug fixes

System requirements

  • Windows 7 Service Pack 1 with Platform Update for Windows 7
  • Windows Server 2008 R2 Service Pack 1 with Platform Update for Windows 7
  • Windows 8

The installer will download and install Platform Update for Windows 7 for you if you don’t have it already.

Migrating your libraries from Simple2D 1.06 or later

Simply run the new installer. Your Simple2D installation will be upgraded automatically to the latest version.

Migrating your libraries from Simple2D 1.05 or earlier

  1. Uninstall Simple2D from Add/Remove Programs in Control Panel
  2. Run the new installer

Migrating your applications from Simple2D 1.10 – 1.11

Migration from Simple2D 1.10: See the Simple2D 1.11 Release Notes.

Simple2D 1.12 has a number of breaking changes that will require small changes to all applications. In particular, the new initialization method requires all applications to be updated. See the migration guide below for further details.

Migration your applications from Simple2D 1.07 or earlier

Please see the section entitled Code Migration from Simple2D 1.07 and earlier in the Simple2D 1.10 Release Notes.

Improvements and bug fixes


  • Breaking change: A new Simple2DStartupInfo struct allows you to pass basic initialization data to the Simple2D constructor Simple2D::Simple2D(Simple2DStartupInfo):
    • ManufacturerName, AppName, Version (all three or none must be supplied) – used for calculating data paths for application local storage
    • ResolutionX, ResolutionY – the starting window resolution
    • MinimumFeatureLevel – the minimum supported Direct3D feature level required by your application
    • Enable3D – enable/disable Direct3D rendering pipeline access and processing
    • IconResource – icon resource ID for the application window (0 for default)
    • WindowName – application window title
    • ResizeBehaviourType – window resize behaviour
    • BackgroundColour – Direct2D render target background colour if clearing is enabled
    • EnableClear – enable/disable Direct2D render target clear at start of each frame
    • EnableFullScreen – enable/disable full-screen operation on user demand
    • FullScreen – start application full-screen or windowed
    • EnableModeSwitch – enable/disable full-screen display mode switching
    • ResizableWindow – enable/disable window resizing
    • MinimumWindowSizeX, MinimumWindowSizeY – the minimum window size
    • EnableMSAA – enable/disable 4x multi-sampling anti-aliasing (MSAA) when Direct3D is used
    • VSyncClamp – vertical sync clamp (0 = no clamp, >0 = a v-sync multiple)
  • After defining a Simple2DStartupInfo struct, start your application as follows: MyProgram(si).Run(). NOTE: Derived application constructors must pass Simple2DStartupInfo to the Simple2D parent object as the only argument. You can still use a non-parameterized constructor to accept all the default settings.
  • Breaking change: The following methods were only usable before the application was initialized and have been removed:
    • SetWindowName
    • SetResolution
    • SetEnableFullScreen
    • SetFullScreen
    • SetEnableModeSwitch
    • SetResizableWindow
    • SetMinimumWindowSize
  • All of these settings can now be configured via Simple2DStartupInfo. The following methods are usable at main runtime and have been retained:
    • SetWindowTitle
    • SetResizeBehaviour
    • SetBackgroundColour
    • SetEnableClear
    • SetShowFps
    • SetVSyncClamp 
  • All of these besides SetShowFps() can also be set via Simple2DStartupInfo.
  • Breaking change: The Simple2D class constructor no longer accepts the 3 optional arguments ManufacturerName, AppName and Version. Specify these via Simple2DStartupInfo and pass this struct to the constructor instead
  • Breaking change: Run() no longer accepts an icon resource ID. Specify it via Simple2DStartupInfo instead (IconResource field)
  • Important change: The application windows are now created (but not displayed) before CreateDeviceIndependentResources is called, instead of when you call Run(). This means that window handles are now available in your class constructor and SetupResources() as well as SetupInitialResources() and SetupApplication().
  • Important change: CreateDeviceResources() now only creates window-size-dependent resources. The rest, ie. Direct3D device and context creation, feature level checking, Direct2D device creation and swap chain creation have been moved from CreateDeviceResources() to CreateDeviceIndependentResources() to remove redundant re-initialization. Corresponding changes have been made to DiscardDeviceResources().
  • Error checking during initialization has been improved and some failures will now cause a Windows error message box to be displayed
  • Bug fix: The initial render target (window) resolution is now available with the correct values in your application’s main constructor if you use Simple2DStartupInfo.
  • Bug fix: CreateDeviceIndependentResources() would re-create IDWriteFactory and WICImagingFactory objects even if they already existed (minor memory leak)

DirectX Accessibility:

  • You can now enable Direct3D features by setting the Enable3D flag in Simple2DStartupInfo. If you set Enable3D, BeginDraw() and EndDraw() will no longer be called automatically on the Direct2D device context when OnRender() executes, so all scenes, objects and DrawScene() must include them when rendering Direct2D objects. To avoid unnecessary overhead, set Enable3D to false when developing 2D-only applications (the default is false)
  • Breaking change: the Direct3D device is renamed from Direct3DDevice to Direct3D
  • Breaking change: the Direct3D device context is renamed from Direct3DContext to Screen3D
  • Simple2D now automatically creates a Direct3D render target view, depth/stencil buffer, depth/stencil view and default viewport, and binds them to the Direct3D pipeline whenever device resources are re-created (in CreateDeviceResources()), and deals with window re-sizing and full-screen behaviour automatically if you enable 3D processing with Enable3D. Accessors: RenderTargetView, DepthStencilView
  • You can now specify the minimum DirectX feature level (D3D_FEATURE_LEVEL) required by your application in Simple2DStartupInfo. Specify a floating point value for MinimumFeatureLevel, eg. 9.1, 10.0, 11.1 for the feature set required
  • You can now specify whether to use 4xMSAA (multisampling) in Simple2DStartupInfo with EnableMSAA (bool)

Interface objects:

  • InterfaceObjects can now extend the main application’s Windows message pump by overriding bool InterfaceObject::doOnWindowsMessage(HWND, UINT, WPARAM, LPARAM). This is called before the application’s main Windows message pump extension (if supplied by the developer) and before Simple2D’s own message processor executes. Returning false will allow the message to propagate to these handlers – return true if you process the message and false if not. (This feature is used to provide clipboard functionality in TextBox)
  • Text boxes now support the following navigation behaviours:
    • Per-character caret navigation (left and right arrow keys)
    • Per-word caret navigation (CTRL+left and right arrow keys)
    • Go to start and end of text (Home and End keys)
    • Caret positioning at end of text when text box gains focus
  • Text boxes now support the following direct editing behaviours:
    • Insert text at caret position instead of just at end of text
    • Delete text before caret position instead of just at end of text (Backspace key)
    • Delete text after caret position (Delete key)
  • Text boxes now support the following selection behaviours:
    • Per-character selection (SHIFT+left and right arrow keys)
    • Per-word selection (SHIFT+CTRL+left and right arrow keys)
    • Select to start or end of line (SHIFT+Home and SHIFT+End keys) with selection inversion when direction of selection is opposite to previous direction of caret movement (same as Windows selection semantics)
    • Navigate without SHIFT to clear the selection; navigating left to clear a selection moves the caret to the left-hand end of the selection before clearing, navigating right to clear a selection moves the caret to the right-hand end of the selection before clearing (same as Windows selection semantics)
    • Delete the selection (Backspace or Delete keys); caret is positioned at start of deleted text
    • Select the entire line (CTRL+A)
    • Selection replacement (type while text is selected to replace it with the selected character)
    • Reducing the selection size to zero characters cancels the selection and re-displays the caret (same as Windows selection semantics)
    • Selection is cleared when control gains or loses focus
  • Text boxes now support the following rendering behaviours:
    • Text is now panned according to caret position, text length and last movement instead of overflowing if it doesn’t fit into the box, using the same caret behaviour semantics as Windows text boxes
    • Caret is not displayed when there is an active selection (same as Windows selection semantics)
    • The selection is painted using its own brushes (see below)
    • The visible part of the selection only will be displayed if part of the selection is outside the text box visible area
    • Backspace visual caret behaviour with text that is longer than the width of the text box:
      • Delete from left-most portion -> caret moves left
      • Delete from last character -> caret is pinned right
      • Delete from middle portions -> caret stays in same position
    • Delete visual caret behaviour with text that is longer than the width of the text box:
      • Delete from left-most portion -> caret stays in same position
      • Delete from middle portions -> caret stays in same position
      • Delete from right-most portion -> caret moves right, box is kept filled with text where possible
  • Note on selection brushes: selection background and text brushes can be set using TextBox::SetSelectionBrushes(textBrush, backgroundBrush). The defaults are black text on a white background.
  • Text boxes now support the following clipboard behaviours:
    • Cut text from text box to Windows clipboard (CTRL+X)
    • Copy text from text box to Windows clibpoard (CTRL+C)
    • Paste text from Windows clipboard to text box at caret position; the selection is replaced if there is one (CTRL+V)
    • Text fields with the IsPassword flag set cannot have any part of their contents cut or copied to the clipboard, but can be pasted into
  • Note on clipboard behaviour: Copies to the clipboard are done in Unicode. Pastes from the clipboard accept Unicode or ASCII text as input; the Unicode format is preferred where available.
  • Text boxes now support the following undo behaviours:
    • Undo last action with infinite undo buffer (CTRL+Z)
    • Redo last undone action (CTRL+Y or SHIFT+CTRL+Z)
  • Note on undo buffers: each text box has its own undo history which persists between focus changes. Undo items are grouped similarly to Windows semantics, ie. groups of edits or deletes in the same area of the text; cuts and pastes etc.
  • Breaking change: TextBoxGroupTemplate now has two extra members, selTextBrush and selBoxBrush appearing as the 6th and 7th fields to correspond with the text selection brushes described above.

Text processing:

  • Bug fix: Simple2D::GetTextWidth() now returns the correct width if the string used to create the text layout included newlines


  • You can now clear the transform on a piece of geometry by calling Geometry::ClearTransform(). This is equivalent to calling g.SetTransform(g.None()) or g.SetTransform(D2D1::Matrix3x2F::Identity()).

Gamepad support (XInput):

  • You can now set the polling interval at which the USB ports are checked for a connected controller when no controller is currently connected using Gamepad::SetConnectionCheckInterval(unsigned int ms). The default is every 2 seconds.
  • You can now configure gamepad events to be sent to your own callback functions instead of the Windows message pump with two new parameters: Gamepad::EnableKeyEvents(std::function<void (unsigned int, bool)>, std::function<void (unsigned int)>). The first callback handles button pushes and the second callback handles button releases. The first argument to each callback is the button pressed or released; the bool argument to the first callback specifies whether the button was already depressed or not. Note that keyboard mappings still apply: if you map digital or analog objects to keyboard keys using AddKeyMapping or AddAnalogKeyMapping, the values sent to your callbacks will be Virtual Key codes, otherwise they will be XINPUT_GAMEPAD_* or Gamepad::AnalogButtons values.


  • The new macros HRDieOnFail(function, errortext) and HRReturnOnFail(function, errortext) make dealing with HRESULTs from DirectX simpler. errortext is optional and will be displayed in a Windows error message box if supplied. HRReturnOnFail will return the HRESULT value on failure whereas HRDieOnFail will call exit() and kill the application. To avoid having to specify an empty string when no error message is desired, use HRSilentDieOnFail(function) and HRSilentReturnOnFail(function)


  • Some duplicated code from CreateDeviceResources() and OnResize() was merged
  • Bug fix: The HRESULT from ID2D1DeviceContext::EndDraw() was being overridden by that from DXGISwapChain::Present1() in Simple2D::OnRender(), which could cause a problem in rare cases when the render target has to be re-created (resources not discarded properly)

Compiler issues:

  • Bug fix: The /Zi compiler option was changed to /Z7 for debug builds, so that the (.pdb) symbol information is built into the .lib file to be distributed. This prevents users receiving compile error LNK4099: PDB ‘vc110.pdb’ was not found when creating debug builds

New example applications:

  • Simple3DInitDemo – shows how to initialize and use Direct3D on the same render surface as Direct2D
  • Simple3DBoxDemo – shows how to use the Direct3D rendering pipeline directly from within Simple2D to draw a 3D box whose movement is animated with the Animation class
  • Simple3DBoxSceneDemo – shows how to re-formulate Simple3DBoxDemo into a Scene with multiple cubes by deriving from SceneObject to create a class representing an instance of a single cube, then adding various instances of it to the active scene
  • GamepadCallbackDemo – shows how to configure gamepad support to send gamepad events to your own callback functions using std::bind, and how to map analog movements to digital buttons

NOTE: Simple3DBoxDemo and Simple3DBoxSceneDemo require the Visual C++ Compiler Nov 2012 CTP or Visual C++ 2013 to compile.

Changes to example applications:

  • All applications have been updated to use Simple2DStartupInfo.
  • GamepadTextDemo – now shows how to change the controller connection polling interval from the default
  • TextInputDemo – no changes to the demo, but can be used to test out the new TextBox functionality

Known issues in Simple2D 1.12

No known issues.

Notes on the use of Direct3D

Applications using run-time shader compilation must link to d3dcompiler.lib and d3dcompiler_46.dll must be in the system DLL paths at runtime. The DLL is re-distributable and included with Simple2D in the redist folder.

Applications using the DirectX Effects Framework must include d3dx11effect.h and link to Effects11d.lib (debug) or Effects11.lib (release). The source code for these is re-distributable and the header plus compiled 32-bit binaries are included with Simple2D in the redist folder.

Migration Guide


The main breaking change is in initialization. By way of illustration, an application that was started like this:

void Simple2DStart()
  MyProgram app;
  app.SetResolution(1024, 768);
  app.SetWindowName(L"My application");

will now be started like this from Simple2D 1.12 onwards:

void Simple2DStart()
  Simple2DStartupInfo si;
  si.ResolutionX = 1024;
  si.ResolutionY = 768;
  si.WindowName = "My application";
  si.BackgroundColour = D2D1::ColorF(Colour::Black);
  si.ResizeBehaviourType = RB_Zoom;
  si.ResizableWindow = true;
  si.IconResource = IDI_APPICON;

Applications deriving from the Simple2D class need to supply a constructor which passes the Simple2DStartupInfo struct to the base class as follows:

MyProgram(Simple2DStartupInfo si) : Simple2D(si)
  // your initialization code here

Note that:

  • Simple2D::Run() no longer accepts an icon resource as its only argument
  • The Simple2D base constructor no longer accepts ManufacturerName, AppName or Version as arguments
  • The Simple2D::Set* methods that are only applicable to initialization of the application have been removed

The following find/replace list can be applied in Visual Studio to automate the changes for the most part. Note they use the new find/replace regex syntax first used in Visual Studio 2012; they need to be adapted for Visual Studio 2010 and earlier. For each item, the search phrase is listed on the first line, followed by the replace phrase.

Default constructor declaration


External default constructor definition

MyProgram::MyProgram(Simple2DStartupInfo si) : Simple2D(si)

In-class default constructor definition (regex)

MyProgram(Simple2DStartupInfo si) : Simple2D(si)

Startup parameter construction block in Simple2DStart (regex)

MyProgram (.*);\r?\n((.*\r?\n)*).*Run\(\);
Simple2DStartupInfo si;\n$2\tMyProgram(si).Run();

In-class default constructor definition with initializer list (regex)

MyProgram\(\) : (.*)\r?$
MyProgram(Simple2DStartupInfo si) : Simple2D(si), $1

SetWindowName (regex)

\tsi.WindowName = "$2";

SetBackgroundColour (regex)

\tsi.BackgroundColour = D2D1::ColorF(Colour::$1);

SetReolution (regex)

^.*\.SetResolution\(([0-9]+), ([0-9]+)\);
\tsi.ResolutionX = $1;\n\tsi.ResolutionY = $2;

SetResizeBehaviour (regex)

\tsi.ResizeBehaviourType = $1;

SetMinimumWindowSize (regex)

^.*\.SetMinimumWindowSize\(([0-9]+), ([0-9]+)\);
\tsi.MinimumWindowSizeX = $1;\n\tsi.MinimumWindowSizeY = $2;

Various flags (regex)

\tsi.$1 = $2;

Remove SetShowFps (add this back inside your class constructor)


Fix destructors from above changes (1) (regex)


Fix destructors from above changes (2)

~MyProgram\(Simple2DStartupInfo si\) : Simple2D\(si\) (regex)
Other breaking changes

The other changes are minor and can be found in bold in the change list above.


Download link (always download the latest version)

Please be aware that Simple2D is very much a work in progress, and that changes from version to version can break older code, although I try to maintain backwards compatibility as much as possible. The code is currently undergoing significant re-factoring with each new version.

I hope you find Simple2D useful!

For setup and installation instructions, follow the Simple2D Installation Tutorial.

Previous version release notes (1.11)

  1. No comments yet.
  1. March 28, 2014 at 13:11

Share your thoughts! Note: to post source code, enclose it in [code lang=...] [/code] tags. Valid values for 'lang' are cpp, csharp, xml, javascript, php etc. To post compiler errors or other text that is best read monospaced, use 'text' as the value for lang.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: