Creating C++ OpenGL apps for OUYA with Visual Studio

This tutorial shows how to build and debug a simply OpenGL application for the OUYA game console using VIsual Studio. We will create a project based on the San-Angeles sample that is included with Android NDK.

Before you begin, please install VisualGDB 4.0 or later (ensure that "Android Edition" is checked in the installer).

  1. Connect your OUYA console to your development machine over USB:
  2. Download, unpack and start UsbDriverTool. Select "OUYA" in the device list, right-click, and select "Install Android ADB Driver":
  3. When asked whether you want to update adb_usb.ini, select "yes":If you encounter problems with finding your device, try installing the driver manually according to the official OUYA USB driver instructions for Windows if you have not already.
  4. Start Visual Studio. Select File->New project->VisualGDB->Android Project Wizard. Select a name and location for the project, click on 'OK'.screenshot new project
  5. If this is your first time making an Android project with VisualGDB, you are asked to configure the locations for the Android tools beforehand. Click on 'Configure NDK/SDK locations'.screenshot no tools
  6. As you already installed the Android SDK when installing the USB driver, detect or browse to the Android SDK and Java installation directories. Specify the Android NDK and ant installation directories or install them. Press 'OK' when done.screenshot tools
  7. Choose 'Clone a sample from NDK' and press on 'Next'.screenshot clone example
  8. Choose 'san-angeles' and press on 'Next'.screenshot choose san-angeles
  9. Choose 'Android 4.1' and press on 'Finish'.screenshot choose platform
  10. Now the project has been created. Next we make some fixes to be able to build the project. Right-click on both app-linux.c and app-win32.c and choose 'Exclude from Project'.screenshot exclude from project
  11. Build the project Build->Build Solution.screenshot build solution
  12. Now make sure the OUYA is started and connected to the development computer via USB and that a screen is connected to OUYA.
  13. Start debugging. You will see the san-angeles example running on the sceen connected to OUYA:
  14. Set a breakpoint in the _getTime function in app-android.c to test that breakpoints are working.screenshot debug
  15. The breakpoint will hit, however after 5 seconds the app will be terminate.. This happens because OUYA  detects the 'activity not responding' condition and believes the app has frozen. We will now fix it by telling OUYA that the current app is being debugged. In the main OUYA menu select "manage":
  16. In the "manage" menu select "Notifications":
  17. On the next screen select "USB debugging connected":
  18. Scroll down until you see "select debug app" and select this item:
  19. Select the activity you are intending to debug. Note that the activity name is not equal to the application name:
  20. Once the debugged activity is selected, start debugging again and let VisualGDB stop on a breakpoint. You will notice that OUYA will not terminate you app and you will be able to debug it reliably.