Archive

Posts Tagged ‘DirectX’

Simple2D 1.13 now available

March 28, 2014 4 comments

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

Version 1.13 is a small update with the following main changes:

  • Visual Studio 2013 compatibility and pre-compiled binaries
  • Significant usability updates to the Animation class
  • A small number of new math & time functions
  • Some bug fixes

Read more…

Simple2D 1.12 now available

November 9, 2013 1 comment

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

Read more…

XInput Tutorial Part 2: Mapping gamepad buttons and analog movement to Windows keyboard events

August 30, 2013 3 comments

In part 1 of this mini-series we looked at the basics of the XInput API and how to read the state of all the analog and digital buttons on a gamepad, then wrapped it up into a simple Gamepad class. In this article, we shall look at how to translate button pushes and analog stick/trigger movements into Windows keyboard events for those applications which use the Windows messages WM_KEYDOWN and WM_KEYUP to handle user keyboard input.

The problem

XInput requires you to poll the controller each frame to get changes in state. If you currently use a function like GetAsyncKeyState() to check for keyboard key presses in your game, this is fine, but if you are using the Windows keyboard messages WM_KEYDOWN and WM_KEYUP, this will not fit in with your current model, and the game will require a bit of re-engineering to handle polling as well. Ideally, we would like to avoid this and just funnel controller movements and button presses through WM_KEYDOWN and WM_KEYUP as if they were normal keyboard key presses.

To do this, we will expand upon our basic Gamepad class to include keyboard mapping and event dispatch functions.

NOTE: If you can’t be bothered with the low-level details and just want to shoehorn gamepad support into a game really quickly, my Simple2D library (version 1.11 and above) includes gamepad support – see the Tetris gamepad support article for a quick example on how to use the library to add gamepad support in just a few minutes! Read more…

XInput Tutorial Part 1: Adding gamepad support to your Windows game

August 30, 2013 11 comments

In this game development tutorial we will look at how to add support for gamepads to Windows games written in C++, using the XInput API introduced in DirectX 11. XInput replaces DirectInput from previous DirectX versions and greatly simplifies the task of working with game controllers, as long as they are XInput-compatible. If you don’t normally use a gamepad on your PC but you own an Xbox 360 then you’re in luck: Xbox 360 controllers support XInput, so just plug it into a USB port on your PC and you’re good to go.

Our end goal is to develop a library which allows us to shoehorn in gamepad support to existing games which use the keyboard and mouse for input with almost no extra effort at all (and if you want to cut to the chase and just use such a library, my Simple2D library versions 1.11 and above include all the code in this article and more to do the job for you), To start with though, we’ll have a quick crash course on the basic API.

In this article, you will learn:

  • How to compile applications which use XInput
  • How to check if a controller is connected and on which port
  • How to check for digital button presses
  • How to check the movement positions of the analog thumb sticks and rear triggers
  • How to calibrate deadzones for the analog sticks
  • How to make a class which wraps it all together

NOTE: If you can’t be bothered with the low-level details and just want to shoehorn gamepad support into a game really quickly, my Simple2D library (version 1.11 and above) includes gamepad support – see the Tetris gamepad support article for a quick example on how to use the library to add gamepad support in just a few minutes!

Read more…

Simple2D 1.11 now available

August 29, 2013 9 comments

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

Version 1.11 introduces 49 improvements and bug fixes with an emphasis on user interface coding. Improvements have been made to scene objects, user interface objects and object groups, experimental support for skinning has been added, as well as support for XInput-compatible gamepads. Read more…

C# DirectX API Face-off: SlimDX vs SharpDX – Which should you choose?

August 24, 2013 21 comments

A question I often see asked by beginning game programmers on the internet is:

I want to code my game in C#. Which DirectX wrapper API should I use?

As with most such things, all choices have their pros and cons. Here I will look at the two frameworks most currently in use at the time of writing: SlimDX and SharpDX. Read more…

Categories: DirectX Tags: , , , , ,

Simple2D 1.10 now available

March 14, 2013 3 comments

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

Version 1.10 introduces improved scene management, improved scene objects and user interface objects, object groups, customizable window resize and full-screen behaviour, more logical event dispatch, new time-based animation functions and a number of bug fixes. Read more…

Simple2D 1.07 now available

February 24, 2013 1 comment

The latest version of my Direct2D-based graphics library Simple2D is now available.

This is mostly a bug fix release with a couple of minor enhancements.

Read more…