Simple2D 1.06 now available
The latest version of my Direct2D-based graphics library Simple2D is now available.
The main changes are targeting of Direct2D 1.1 and Direct3D 11.1 (and support of new features provided by these), improvements to geometry and window handling, migration of the library source code to Visual Studio 2012, new demos and a new installer. Run-time support for Windows Vista and compile-time support for Visual Studio 2010 is dropped (although it still compiles with warnings).
IMPORTANT! Uninstall any previous versions of Simple2D you are using first. Simple2D 1.06 introduces a new installer architecture which is not compatible with the previous versions.
- 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.
- Breaking change: The source code to the main library now targets Visual Studio 2012. It will still compile under Visual Studio 2010 but with warnings.
- Breaking change: The pre-compiled .lib files included are now statically linked with the Visual C++ run-time library (versions 1.05 and below used dynamic linking). You must re-build your applications using static linking (/MT or /MTd linker arguments) instead of dynamic linking in order for them to link properly (in Visual Studio, right-click your project, choose Properties and navigate to C++ -> Code Generation -> Runtime Library to configure this option).
- Breaking change: Simple2D now targets Direct2D 1.1 as used in Windows 8 and Windows 7 Service Pack 1 with Platform Update for Windows 7. Windows Vista is no longer supported.
- Breaking change: LastUpdateTime has been removed. Use LastUpdateTime64, LastFrameTime and PerformanceFrequency to retrieve timing information (see below)
- Important change: Rendering is no longer tied to v-sync. Frames will now be rendered as fast as the end-user hardware allows.
- Important change: Simple2D now renders to a Direct3D surface. The behaviour of window re-sizing has changed such that the render target size remains the same and is scaled to the new window client area size.
Improvements and bug fixes
- Position in an animation can now be changed while it is running (Animation::SetPos)
Images, bitmaps and sprites:
- You can now create a blank bitmap with Simple2D::MakeEmptyImage(). You can specify the width, height, Direct2D pixel format (D2D1_PIXEL_FORMAT) and Direct2D bitmap creation options (D2D1_BITMAP_OPTIONS). These items are also added to the constructor of ImageObject.
- ImageObject / Image uses ID2D1Bitmap1 instead of ID2D1Bitmap to allow access to new image-processing features in Direct2D 1.1.
- Bug fix: ImageObject::DrawPart was not respecting the current render target world transform.
- New function Geometry::GetIntersectedGeometry returns a path geometry (Geometry) which is the intersection of the geometry object called and the geometry object supplied in the argument, optionally transformed by a specified matrix.
- The current matrix transform of a geometry can now be retrieved with Geometry::GetTransform().
- Simple2D::MakeRectangleGeometry is now overloaded to accept a D2D1_RECT_F as its creation argument.
- Geometry::ContainsPoint is now overloaded to accept float arguments.
- Geometry::Move is now overloaded to accept float arguments.
- Bug fix: Creating elliptical and rectangular geometries with Simple2D::MakeEllipseGeometry or Simple2D::MakeRectangleGeometry no longer sets the default transform point to the centre or top-left of the object respectively. This was causing problems with matrix transforms later.
- Bug fix: Geometry::Rotate, Geometry::Scale and Geometry::Skew were incorrectly using the un-transformed bounding boxes of the geometry to calculate the transform point instead of the current bounding box.
Helper functions and members:
- StringToWCHAR helper function added
- Use of GetTickCount() for frame-rate and performance timing has been dropped in favour of QueryPerformanceCounter(). LastUpdateTime64 stores the count on the last frame update, PerformanceFrequency stores the number of counts per second on the end-user’s processor, and LastFrameTime stores the number of counts taken to process the previous frame.
- Custom window message processing can now be performed by overriding the new member function OnWindowsMessage() in your derived application class.
- The application window handle HWND can now be fetched via Simple2D::GetWindow().
- The application window title can now be changed with Simple2D::SetWindowTitle().
- Bug fix: Client window now allows standard Windows controls to be rendered on top of the Direct2D surface (they were previously clipped and obscured).
Updates to COM object management:
- The factory objects exposed by Simple2D are updated as follows: Direct2D 1.1 (ID2D1Factory1), DirectWrite 1.1 (IDWriteFactory1), Windows Imaging Component (WIC) 1.2 (IWICImagingFactory2).
- The following additional COM objects are exposed: Direct3D 11.1 device (Simple2D::Direct3DDevice), Direct3D 11.1 device context (Simple2D::Direct3DContext), Direct2D 1.1 device (Simple2D::Direct2DDevice), DXGI 1.1 swap chain (Simple2D::DXGISwapChain), Direct2D rendering surface (bitmap) linked to DXGI back buffer (Simple2D::Direct2DBackBuffer).
New example applications
- Swinging rope demo
- Speculative contacts and penetration resolution demo (see 2D Platform Games Part 1: Collision Detection for Dummies)
- Improved speculative contacts demo
- Pixel-perfect bitmap collision detection demo using the Direct2D 1.1 Effects Framework
NOTE: Starting with Simple2D 1.06, all example applications are statically linked to the Visual C++ run-time library, so you no longer need the Visual C++ Runtime Redistributable Package installed to try the example EXEs if you do not have Visual C++ installed.
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.