SFML 2.5.0 Update (Or how I learned to hate RenderTextures)

 

 

On May 6th, the C++ Simple and Fast Media Library (or SFML for short) was updated to stable version 2.5.0, adding various updates including more optimial iOS support, bug fixes, added functionality for Text and Audio and various optimizations. For such a big release, it made sense to upgrade and get my Vigilante Game Framework updated, and why not update Gemstone Keeper while I’m at it?

Well it took nearly a month, but I did manage it in the end. Gemstone Keeper 1.0.5 has been uploaded to Steam, both for Windows and Linux!

As the title suggest, a lot of the work had to do with the updates to the sf::RenderTexture object. However, I don’t absolutely hate them, they are extremely useful for rendering a scene to an area of the screen, or to apply post-processing effects to. However the problem lied in how I was using them, and how the fixes done in the latest update effectively broke my engine’s rendering system.

The initial update showed promise, as my most recent game worked fine, but moving onto the framework’s examples and Gemstone Keeper showed that a lot of things weren’t rendering at all.

Vigilante Framework currently renders 3D models using Modern OpenGL, and while it was working fine with SFML 2.4.2, it rendered nothing with SFML 2.5.0. The solution was embarrassingly simple despite the amount of effort put into fixing it, including implementing my own version of SFML’s glCheck function and re-writing SFML’s own OpenGL example to run with modern OpenGL. When rendering the 3D scene, I modified some of the OpenGL states, which wouldn’t be an issue before but now those OpenGL states carry over into other contexts. The solution was to simply make sure that the GL states were reset BEFORE rendering the scene using a sprite object.

 ///Render 3D scene and apply to a sprite.
 RenderTarget.resetGLStates(); //Reset the GL states to the default for SFML
 Sprite->Draw(RenderTarget); //Render the sprite.

Gemstone Keeper however uses legacy OpenGL, and while I could have updated the VFrame source code but that could take more time to fix. Regardless, I was able to get it working by rearranging other objects that define sf::RenderTexture, including the bloom post processing effect and the help popup terminal.

Gemstone Keeper’s other graphics were another story. The approached I had been using up to this point was to render text objects onto a single rendertexture, and then store the generated texture to be used as a sprite, particle or tilemap. While this was okay for the time, but it is rather inefficient and bad for graphical memory.

I wanted to do a single-texture approach, where all the graphics are rendered onto a single texture, and a rectangle area is specified when creating renderable objects, for a while but I kept putting it off. SFML’s update, causing any newly created render textures to dereference generated textures, it was time to take this approach on. The best part is that most of the work was already done by myself with the additional code of Jukka Jylänki’s MaxRectBinPacker algorithm, all that needed doing was to change how I defined renderables from setting the texture to whatever the name of the genrated texture is to the name of one texture sheet, and to get the correct rectangle from a map/dictionary, searching by string ID.

CaptureCaptureCapture

Now this doesn’t mean the entire game’s visuals are rendered from one texture. Including the 3D gemstones, any assets that use a repeated texture grabs a subsection of the main texture as a copy, same applies to the VBackdrop as well. Getting the icon was a more painful looking process of converting the entire texture sheet to an sf::Image, so I can load in a subsection to a new sf::Texture object, and then convert the new texture object to an sf::Image in order to set it to be the application icon.

sf::IntRect iconArea = TextureData::p()->GetTextureRect(TextureData::p()->GetPortalTextureName(true));
 sf::Image image = VGlobal::p()->Content->LoadTexture("TextureSheet").copyToImage();
 sf::Texture tex;
 tex.loadFromImage(image, iconArea);
 VGlobal::p()->App->setIcon(iconArea.width, iconArea.height, tex.copyToImage().getPixelsPtr());

Like I said, not pretty.

So enjoy Gemstone Keeper, the number of you who own it. Now back to doing more stuff in C++…

First Hands-On Preview: SpriteLamp

Hello everyone! Hope you all are preparing for Christmas! I have received an early Christmas treat that I wish to talk about: the 2D Dynamic Lighting Tool, Sprite Lamp!

Continue reading

The Windows Games Ambassadors Website!

If you are interested in developing for Windows 8, make sure to check out www.windowsgamesambassadors.co.uk.

Not only is it the official website for the Windows Games Ambassadors, where you can find updates on what ambassadors like me are up to, but it is also a great starting point for finding all information on what you can use to make Windows 8 games, as well as how to implement Windows 8 Application features and services like Azure!

Stafford Windows Games Jam

Stafford Windows Games Jam

Yes, you heard it. I am running a Games Jam for students at Staffordshire University, taking place on Stafford Campus. Students will be working solo or in teams to make fun and short games made for Windows platforms, and the two best games will win either a Windows Phone 8 or a Microsoft Kinect for Windows! Games will be made using easily available game development tools such as MonoGame, Unity, Construct2 and Game Maker Studio, or for the more tech savvy, can be made using pure code to run on Windows 8/Phone 8 via HTML5 or C#, and can use the free platform starter kit to get them going.

Information on the Jam is on the Official Facebook Events Page.

 

Show us your Game Changer

As a Windows Games Ambassador, I think it’s write for me to tell you this!

Show us that you’re a game changer and collect points every step of the way to redeem rewards like a brand new Windows 8 RT Slate. Create the next app phenomenon by building your original and unique Windows Store and/or Windows Phone App.

Get recognised and rewarded for building your original apps. Further, get bonus rewards for migrating your Windows Phone app to Windows Store and vice versa or incorporating one or more Windows Azure Services.

Follow these 4 Simple Steps to Start Earning Points for your Awesome Apps:

1. Register yourself on the UK App Builder Reward Programme website.

2. Build & publish your original & unique app.

3. Claim points by telling us about the app you’ve published and we’ll award points to you accordingly.

4. Referrer your Windows Game Ambassador (which is me)

5. Redeem your points for a range of fantastic prizes and gadgets.

Introducing Our First Ever One Day Special

On Tuesday 19 March 2013, we will be announcing a special one day deal for the Rewards Programme. To make sure you can take advantage of this special one day deal, publish your apps and ensure you claim your points before Thursday 14 March 2013 (less than 2 weeks away) so you will have your all of your eligible points in your account to use. You do not want to miss this one day special! Look out for the announcement for the One Day Special on Tuesday 19 March.

Don’t forget about our Bonus Rewards

The bonus rewards are limited deals where you must fulfil the stated criteria. Once you have fulfilled the criteria, you will be notified by our team and delivery of your bonus reward will be arranged. The bonus reward is exactly that and it will not affect the balance of your points therefore, you will still be able to use your points to claim for your reward(s) of your choice. Nokia have generously sponsored the first set of bonus rewards. You have to be quick to take advantage of this special bonus reward.

Bonus Reward 1: Receive a Nokia Lumia 620 Windows Phone 8 Handset if you are one of the first 20 App Builders who accumulate 100 points from Windows Phone Apps published.

Bonus Reward 2: Receive a Nokia Lumia 920 Windows Phone 8 Developer Handset if you are one of the first 10 App Builders who accumulate 200 points for publishing Windows Phone apps.