OpenGL 2D Independent Resolution Rendering

Around two years ago I made a tutorial for XNA in which you could render 2D games scaled to the current window resolution with proper letter-boxes or pillar-boxes. As many know since then I moved to C++ and OpenGL, and ocasionally people ask me “Can you still do that independent resolution thing?”, and yes it’s perfectly possible. I’ve used this on all latest Windows, Mac and iOS, in case you are wondering. ...

April 22, 2013 · 3 min · 539 words · David Amador

Detecting C++ memory leaks in Visual Studio - again

I made a small post about detecting C++ memory leaks in Visual Studio in 2010. At the time that seemed to suffice, but some months ago someone told me about Visual Leak Detector and boy does it work. According to the website itself Visual Leak Detector is a free, robust, open-source memory leak detection system for Visual C++. It’s pretty easy to use. After installing it, you just need to tell Visual C++ where to find the included header and library file. ...

June 3, 2012 · 1 min · 154 words · David Amador

Xbox 360 Controller Input in C++ via XInput

So you have that Xbox360 controller laying around and want to connect it to your game? On XNA this is an out of the box option but if you’re using C++ you have a bit more work to do first. First of all, you will need the DirecX 9.0+ sdk. The includes. #define WIN32_LEAN_AND_MEAN // We don't want the extra stuff like MFC and such #include <windows> #include <XInput.h> // XInput API #pragma comment(lib, "XInput.lib") // Library. If your compiler doesn't support this type of lib include change to the corresponding one Let’s define the buttons ...

April 15, 2012 · 4 min · 842 words · David Amador

Cross-Platform engine progress

If you read my recent posts you know I’ve been bringing Basalt to C++. The plan is to support both DirectX and OpenGL render API’s and OpenGLES for iOS devices. I’m tired of porting stuff so I want to make a better framework for future projects and I’ll leave the XNA branch for Xbox360 and Windows Phone 7. I really wished I had this before. Since the iPhone branch is stable I move on to making it compatible with Win32 and MacOSX. ...

October 11, 2010 · 2 min · 272 words · David Amador

Developers log stardate 26082010

It’s been awhile since I last updated this, I’ve have my hands full with Vizati iPhone. Ever since I got an IPod Touch 2G it was easier for Rita to get a sense of the screen size (although we knew to be 320×480) it’s different when you are testing on the real thing, text looks smaller, other stuff looks way too big. Here’s a picture she took after a few adjustments. ...

August 26, 2010 · 4 min · 760 words · David Amador

Instance based Callbacks in C++

One of the things that was probably forgotten but the dudes who made C++ standard were callbacks, there’s no out of the box solution for Instance based Callbacks, just for functions. When I moved to C# I was really happy with the way delegates work, it’s simple, easy and most of all, it works. On game development one of the things callbacks are usually used is for Buttons, you have a menu and want to attribute a function to each button. Sure you can point it to the same one and make a bunch of if’s and then point to a Global var which does the correct action, but this is not elegant and sure as hell not easy to add/modify stuff. ...

July 14, 2010 · 2 min · 296 words · David Amador

How to do a Xna Log file

Although the title says XNA log file this is actually a C# log file, I’ve just thrown this title cause lot’s of people search for xna log instead of C# log file. Many have asked me why take time to do a log file when you can throw exceptions when something goes wrong. Well the answer is simple, to keep track of what’s happening, log steps, write to the file exactly what when wrong even if you are on Release mode, and more, if someone complains the game is crashing you simply ask for the log file and see what when wrong. ...

November 20, 2009 · 2 min · 350 words · David Amador

Building an 2D Game Engine in XNA - Part 1

I decided to starting writing a series of tutorials for building an 2d XNA game engine. Keep in mind that while the main focus is 2d nothing prevents us from adding the 3d stuff later but for now we will stick to 2D. It’s not very original but I’ll call this the Bay Engine. If anyone else has a better idea let me know. Requirements: You must have some Object Oriented Programming background to full understand what we will do here. XNA 3.1 Visual C# Express or Professional 2008 This is it for the first part. It just covers the basic structure, next week I’ll talk about objects2d, scene and screens management. ...

October 16, 2009 · 1 min · 112 words · David Amador

Cloning Objects in C#

After trying to manually clone some classes, but making a sort of copy constructor I was always ending up with lot’s of code and worse, if I add another variable to my class I would sometimes forgot to also clone it. Luckily and after a search I discovered that C# has a cool thing, Reflection. So you can do something like this: using System.Reflection; class MyClass { public int a; public float x; MyClass() { // default constructor } MyClass (MyClass my) { FieldInfo[] fields = typeof(MyClass).GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach(FieldInfo f in fields) { f.SetValue(this,f.GetValue(oth)); } } } MyClass obj1 = new MyClass(); obj1.a = 1; obj1.x = 2.0f; MyClass obj2 = new MyClass(obj1); // Obj2 will have same values as obj1 and you // can now use them independently. I hope this is helpful. Let me know if you know a better way ...

October 12, 2009 · 1 min · 146 words · David Amador

The amazing lands of C++

I’m sure every programmer will like this

October 5, 2009 · 1 min · 7 words · David Amador