Showing posts with label VS2012. Show all posts
Showing posts with label VS2012. Show all posts

Tuesday, July 23, 2013

My travels in graphics programming

DirectX

Early this year I started reading a book about DirectX but quit shortly after.  I wanted to use VS2012, but couldn't get my environment configured properly.  All the issues stem from the fact that VS2012 now comes with DirectX built-in, but this version only works for Metro applications.  If you want to develop for the desktop, you have to install the "June 2010 SDK" for DirectX which is a pain for me as a beginner.  One solution to this problem is to go back to Windows 7 and use Visual Studio 2010, which is something I don't want to do.

OpenGL

About two months ago I strongly considered forgetting DirectX and instead learning OpenGL.  I have to admit that not being able to set up my machine properly has been one of the biggest reasons for the switch.  At the moment, I'm waiting for the latest version of the "OpenGL SuperBible" to be released at the beginning of next month.  This book was highly recommended by a friend who is a graphics programmer, so I have high hopes for it.

Monogame/XNA

In the last couple of weeks I gave DirectX another shot and again and I'm not seeing the progress I expected.  To calm my frustration with DX, I went and researched other alternatives and discovered Monogame which is an open-source port of XNA.  Now, XNA is dead and will no longer be supported by Microsoft, but I found Monogame very promising.  For the type of games I want to code as a beginner I believe is more than capable and satisfies all my requirements.

Yesterday I said what the hell and decided to give it a shot.  Right off the bat, I'm finding it a pain to use VS2012 in my environment again.  To get Monogame to run on Win7 with VS2012 I had to go through a labyrinth of steps:
  1. Install Visual Studio 2010
  2. Install XNA Game Studio
  3. Install Monogame
  4. Create OpenGL Monogame project and have it fail to run.
  5. Fix SDL.dll issue with the way the Monogame VS template works.
  6. Install OpenAl because Monogame didn't install this driver for some reason.
  7. Finally run basic project.
The whole process took me a couple of hours, which isn't too bad.  But I find steps 1 and 2 to be non-ideal.  Why do I need to install VS2010 to code something in VS2012?  The reason is one key part of XNA has not been ported to Monogame, the content creation pipeline.  One way to avoid having VS2010 and XNA installed is by using Windows 8 Phone SDK.  The only problem with that approach is that you can only do that on Windows 8.


Tuesday, June 18, 2013

Getting the Qt Creator debugger to work on Windows

Installing the default Qt package for Windows installs the Qt Creator IDE, and everything else you need to write GUI apps, but once you try to debug your first program you get an unexpected surprise.  Unless you have installed the appropriate Windows SDK, the debugger functionality in Creator won't work.  You will get an error message saying the debugger is not configured.

The following is what I had to do to get the debugger to run on Windows 8 x64 with Qt 5:

  1. Download the Windows SDK for Windows 8.  If you have Visual Studio 2012 and selected the appropriate option during that installation, you won't have to run this.
  2. Run the installer for the SDK, and when prompted select the debuggers checkbox.  This is the only thing you really need.  If you want the full SDK select the other checkboxes.
  3. Open the Qt Creator IDE. Go to Tools -> Options -> Build & Run -> Kits.  In the Auto-detected field you should see an entry for your version of Qt.  Selecting it you should see the debugger has been configured for CDB Engine.  If you see < None > for the debugger, you will have to manually navigate to the CDB executable.  The path on my computer is:

        C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x64\cdb.exe

Thursday, June 13, 2013

Adding a custom slot in Qt Designer and Visual Studio 2012

I was going through the "Getting started" section for Qt using VS2012 as my IDE, and I got stuck when I had to add a slot to a button.  Apparently there is a bug when using the Visual Studio add-in, that the submenu Go to slot doesn't show up in a context menu in Qt Designer (see bug).  Needless to say, I spent more than two hours trying to figure out how to get around this problem.  The following is what I found:

Let's say you have a class called Notepad that has a quit button and you want to handle when the button is clicked.  First create a private slot in the class definition in the header file - Notepad.h in this example.

class Notepad : public QMainWindow
{
...

private slots:
    public void on_quitButton_clicked();

...
}

On the Notepad.cpp add the following:

void Notepad::on_quitButton_clicked();
{
}

Note: from what I read it's good idea to follow the convention on_name_signal() for all your custom slots.

Now open your *.ui file with Qt Designer.  At this point I tried using the Signal/Slot editor to add the slot to the button on the GUI.  The "custom" slot we wrote above however doesn't show up when you click the slot dropdown.


After scouring stackoverflow and the Qt forums I found a couple of ways to get the custom slot to show in the dropdown.

  1. Go to Signal/Slots mode by pressing F4 on your keyboard.
  2. Click on the button so that it changes color.
  3. Left-click and drag it to the top of the main window.

    4.  This brings up the Configure Connection window
    5.  On the left pane select the Signal clicked()
    6.  On the right pane select Edit
    7.  This brings yet another window, select the + button.
    8.  Enter the name of the custom slot, on_quitButton_clicked() in this case.
    9.  Click Ok and now you should be able to see the slot in the dropdown in Signal/Slot editor.



Pretty tedious, but if you want to use Visual Studio as the IDE, this is what you will have to go through until someone fixes the bug, or you decide to use Qt Creator.  If I keep finding issues like this by using Visual Studio I think I'll have to do to the latter.