Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Tuesday, May 12, 2015

Bridges connect the world - iOS and Android on Windows 10. What?

Bridge to Astoria, OR. Nov 2014
Photo from our road trip to Portland
At the //build 2015 conference Microsoft announced their development stories for Windows 10. This also includes bridges to reuse existing iOS, Android and other investments for Windows 10.
The keynote showed how an existing iOS game was ported to Windows 10 without much effort. The shown one-stop porting solutions for Android and iOS raised the concern why anyone should bother to develop natively for Windows 10 anymore and created quite some confusion and uncertainty in the Windows developer community. A few developers at //build were really worried about those announcements as some of their business is mainly porting iOS and Android apps to Windows Phone.

I think at the moment there's just too less knowledge to make decisions based on the announcements and assumptions floating around. There were two sessions at //build about Project Astoria for Android and Project Islandwood for iOS. Keep in mind both projects are in a alpha/beta stage and aren't publicly released at the moment so there's no public hands-on experience and independent in-depth analysis available yet. It's also worth noting that Project Astoria allows one to build Windows apps for phones but not for all Universal Windows Platforms at the moment. More information is expected during Summer 2015 and you could also try to sign up for an early access program for Astoria and Islandwood. There's also a good post by my friend Alan from AdDuplex. Peter Bright published a good Ars Technica article as well.

In my opinion there's one particular really good use case:
Share existing business logic across platforms and build the UI natively for the platform.
This way a common cross-platform app core is reused and the UI is built natively on top of that layer to provide the best UX. Porting an app completely might work for games with a custom UI and some simple apps, but advanced apps usually leverage too much platform-specific features for a one-stop port to work at all and a great app adapts to the UX of the platform.
Sharing core business logic is actually a common use case I see with our larger clients who want to bring their existing apps to Windows or Windows Phone. In the projects I've been involved over the last few years, the shared portion was usually implemented in C/C++ as it is still one of the best cross-platform options since most platforms support C/C++ in some way. Right now it is still quite an effort to get the custom C/C++ libs from other platforms adapted for Windows Phone compilation/linking, even with elevated API access rights. The cross-platform C++ Clang support in Visual Studio 2015 allows us to just recompile the Android or iOS C/C++ code and could help us a lot for such scenarios.
After writing this blog post I came across this excellent post by the Visual C++ team which describes just that. And this post which provides more details about the Visual Studio 2015 cross-platform C++ features.

As I see it, Xamarin will be the best choice for green field cross-platform projects to share as much code as possible and still provide the best UX. The new Visual Studio 2015 tooling for Windows 10 could help to make the reuse of existing iOS and Android business logic easier for Windows 10 when there's not a desire for a green field.

On the last day of //build I had a nice breakfast and roundtable with an executive of the Windows Dev Platform and of course we talked about the //build announcements. There was actually the same vision about the easier reuse of business logic. I think we made it clear that quite some confusion was created in the dev community around Islandwood, Astoria but we were told Microsoft will release more information to make the vision for those porting tools clearer.

In the end I think there's no need to be worried. Porting tools have never been a one-stop solution so I'm confident Islandwood and Astoria won't be the holy grail either. As usual a keynote also contains a good portion of marketing and software development is never that easy, so always consume such announcements with a grain of salt and wait for final decisions until the expected is delivered for real-world scenarios.
If those tools help us to make the porting of existing iOS and Android apps easier and the Store provides the apps which users are looking for, it's good for all Windows developers in the end.
It's just a matter of adapting to leverage the new tooling and helping clients to create great apps.

Don't Worry, Be Happy!

Friday, November 14, 2014

Native Android Application Development with C++ and Visual Studio 2015

Visual Studio 2015 ships the new C++ cross platform support which currently provides native C++ library compilation for Android and Windows platforms. iOS compiler support is supposed to be added as well.
That's not all. VS 2015 even provides a new project type called "Native-Activity Application" for Android app development. This pure C/C++ Android application model is mainly used for game development using full screen OpenGL rendering.
The Native-Activity Application project type allows developers to write native Android apps with C++ and even to run and debug those in the Android emulator only by using Visual Studio 2015.
No Xamarin, no Apache Cordova needed, just VS 2015 and pure C/C++.



How it works

It's pretty straightforward to get started.
Just install Visual Studio 2015 including its Secondary installer which adds the required Android development tools.
Start VS 2015 and select the Visual C++ -> Cross Platform -> Native-Activity Application (Android) project type:


The generated template code provides the base native Android app code including simple code for cycling the back buffer clear color inside the engine_draw_frame function.

For this sample here I decided to make the Hello World of 3D computer graphics: a rainbow colored rotating cube. Here's how you can achieve this as well:

Add the cube definitions to the beginning of the main.cpp:

static GLint vertices[][3] =
{
 { -0x10000, -0x10000, -0x10000 },
 { 0x10000, -0x10000, -0x10000 },
 { 0x10000,  0x10000, -0x10000 },
 { -0x10000,  0x10000, -0x10000 },
 { -0x10000, -0x10000,  0x10000 },
 { 0x10000, -0x10000,  0x10000 },
 { 0x10000,  0x10000,  0x10000 },
 { -0x10000,  0x10000,  0x10000 }
};

static GLint colors[][4] =
{
 { 0x00000, 0x00000, 0x00000, 0x10000 },
 { 0x10000, 0x00000, 0x00000, 0x10000 },
 { 0x10000, 0x10000, 0x00000, 0x10000 },
 { 0x00000, 0x10000, 0x00000, 0x10000 },
 { 0x00000, 0x00000, 0x10000, 0x10000 },
 { 0x10000, 0x00000, 0x10000, 0x10000 },
 { 0x10000, 0x10000, 0x10000, 0x10000 },
 { 0x00000, 0x10000, 0x10000, 0x10000 }
};

GLubyte indices[] = {
 0, 4, 5,    0, 5, 1,
 1, 5, 6,    1, 6, 2,
 2, 6, 7,    2, 7, 3,
 3, 7, 4,    3, 4, 0,
 4, 7, 6,    4, 6, 5,
 3, 0, 1,    3, 1, 2
};


And replace the // Initialize GL State statements at the end of the engine_init_display function with this:

 // Initialize GL state.
 glDisable(GL_DITHER);
 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
 glClearColor(1.0f, 0.41f, 0.71f, 1.0f); // Hot pink! :D
 glEnable(GL_CULL_FACE);
 glShadeModel(GL_SMOOTH);
 glEnable(GL_DEPTH_TEST);
 glViewport(0, 0, w, h);
 GLfloat ratio = (GLfloat)w / h;
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 glFrustumf(-ratio, ratio, -1, 1, 1, 10);


Finally replace the engine_draw_frame function:

static void engine_draw_frame(struct engine* engine) {
 if (engine->display == NULL) {
  // No display.
  return;
 }

 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

 glMatrixMode(GL_MODELVIEW);
 glLoadIdentity();
 glTranslatef(0, 0, -3.0f);
 glRotatef(engine->state.angle * 0.25f, 1, 0, 0);  // X
 glRotatef(engine->state.angle, 0, 1, 0);          // Y

 glEnableClientState(GL_VERTEX_ARRAY);
 glEnableClientState(GL_COLOR_ARRAY);

 glFrontFace(GL_CW);
 glVertexPointer(3, GL_FIXED, 0, vertices);
 glColorPointer(4, GL_FIXED, 0, colors);
 glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_BYTE, indices);
 
 eglSwapBuffers(engine->display, engine->surface);
}

You also might want to modify the angle increment so the cube rotates a bit faster, like engine.state.angle += 1.f;

Make sure the project is set to compile as x86 in order to use VS' own Android emulator.
Then F5 and enjoy the magic of the rotating cube.


Now try to add a breakpoint in your engine_draw_frame function. Yes, there's native debugging support for Android apps in Visual Studio 2015. Times are definitely changing at Microsoft.


Sample code

You can download the complete VS 2015 sample solution here.


More resources

This blog post is a nice overview of the new Visual C++ cross platform features.
This short Ch9 video gives a quick intro to the new Visual Studio 2015 C++ cross platform support.
NeHe is a quite old resource for OpenGL tutorials but mostly still useful.

Thursday, November 13, 2014

Cross Platform Mobile Development with C++ and Visual Studio 2015

Screenshot from Herb's video
Beside the Xamarin partnership and their great solutions for C# cross platform development, Microsoft is also heavily investing in C++ cross platform development with Visual Studio 2015.
With VS 2015 it's possible to build shared cross platform C++ libraries or even full native Android apps only with VS 2015. VS 2015 even ships its own Android emulator. iOS compiler support is supposed to be added as well.

Don't get me wrong, Xamarin and C# are without a doubt great for sharing code in native greenfield apps. However, existing code bases are often already built in C++. In fact I was involved in at least two large apps over the last 1.5 year which used already existing shared C++ layers. Most of the backend connectivity and core data logic was implemented in C++ and shared between WP, iOS, Android and BB10. Many large projects follow this shared C++ layers approach including the MS Office and Dropbox mobile apps.
Of course Xamarin C# and shared cross platform C++ libraries can be combined to get the best of all. For example by leveraging an existing code base for the shared C++ core libraries and Xamarin for the UI layer.

Is it the renaissance of C++? I'm not sure. It was always here driving many projects, even on the smallest devices and never gone, but I’m sure the new shared C++ library project support in VS 2015 is a strong commitment to the future of Visual C++.

Here's a good overview of the new C++ cross platform features in VS 2015:
Cross-Platform Mobile Development with Visual C++

And some very nice short videos from the Connect() event. Highly recommended to watch:
Herb's Ch9 video "C++:Conformance And Cross-Platform Mobile Development"
Ch9 video: "Visual C++ for Cross-Platform Mobile Development using Visual Studio 2015"

There's much more to discover in VS 2015 for C++ developers:
Visual Studio 2015 Preview is Now Available

Thursday, October 2, 2014

Not Dead Yet - PDB Inspector

Today I had to analyze some PDB debugging symbols in order to verify if the needed debugging information is properly generated.
Archived PDBs are useful if you want to analyze a dump file like the minidump the Windows Phone Store Crash Reports provides.
To my surprise is there no ready-to-use free tool for inspecting a PDB file and its functions. Fortunately wrote Marc Ochsenmeier a great Codeproject article a few years ago and provided sample code for a nice little tool he calls Pdb Inspector. Unfortunately was there no binary which runs on my Win 8.1 x64 machine and the code did not compile, so I had to modify it a bit and got it compiling. You can grab a binary of a fresh Pdb Inspector here.

Monday, July 5, 2010

The Ultimate Gift Card - Two Visual Studio 2010 Ultimate MSDN Subscriptions To Give Away!

It's over, I picked two people from the comments that deserve the MSDN Subscription cards the most. Thanks!

I recently got three Visual Studio 2010 Ultimate MSDN Subscriptions cards from Microsoft. They are valid for one year, include the whole Ultimate features and can be used for development and testing purposes. Ultimate includes Visual and Expression Studio,Windows, Office, Windows Server, SQL Server, TFS, all other server products, ... and even some Azure benefits are packed in. Only the support and the MSDN magazine are excluded.
The one year Ultimate subscription is worth approximately $12,000! And the best thing, I have two cards left I can give away. What a great gift from Microsoft!

I want to give my two remaining cards to the Windows developer community. If you want one, just write a comment why you should get this great gift and make sure to include some form of contact information. Did I mention that these are full Ultimate subscriptions worth $12,000?
I will prefer people who make significant contributions in the .Net open source world. Of course, your chance is even better if these contributions are for Silverlight or Windows Phone 7.
After July 20th 2010 I'll pick two people that deserve the cards the most.

Here's a photo of the package I got. Yeah, it's real! And free, as in free beer!



Thanks a lot Microsoft!

Thursday, April 15, 2010

Silverlight 4 Up and Running

Woohoo! The final Silverlight 4 runtime and the developer tools for Visual Studio 2010 were released today and exactly three years ago the name Silverlight was officially introduced. A lot of great things happened in the Silverlight world since then and we now have a superb RIA platform at hand.

To get started with the Silverlight 4 development you only need Visual Studio 2010 and the Silverlight 4 Tools for Visual Studio. Don't forget, it's all free with the Visual Studio 2010 Express edition! The end-user runtime is available for Windows and Mac. As usual, Tim Heuer wrote a nice blog post about the Silverlight tools.

Past
The APIs haven't changed much since the last release candidate (RC) and exactly one month ago I wrote a summary of all the new features that were added since the Silverlight 4 Beta to the Silverlight 4 RC and the breaking changes. The post also contained some details about the CaptureSource's changed capture usage pattern. So if you used the Silverlight 4 Beta and skipped the RC, this post might be helpful.

Present
I installed the Visual Studio 2010 RTM build on Monday after it was released at Devconnections, the final Silverlight 4 Tools for Visual Studio today and recompiled all my Silverlight 4 samples and open source projects. It all worked like a charm and even on this machine were I had several betas of all the tools installed before. Kudos to the Visual Studio and the Silverlight team for making such great products.
My relevant Silverlight 4 blog posts, the SLARToolkit and the FaceLight CodePlex open source projects are now up to date.

Future
The first beta of the next Silverlight version will most certainly see the light this year. Make sure to vote or suggest new features at the silverlight.mswish.net site. The most important feature suggestion for me is the GPU accelerated 3D support that I suggested a while ago and which was consolidated into this suggestion. If you agree with me, you should vote for it.

Have fun with Silverlight 4!

Monday, March 15, 2010

The Silverlight 4 Release Candidate

Scott Guthrie et al. announced many awesome new things during the keynotes at Microsoft's MIX10 conference. One of it was the Silverlight 4 Release Candidate which replaces the beta version and is now available for download. Beside all the great new features that were added, it's now finally possible to use the Visual Studio 2010 RC for Silverlight 4 development. Kudos to the Silverlight team for catching up with Visual Studio 2010 and all the cool new features they implemented. 

The final Silverlight 4 RTW version will be available next month (April 2010). Additonaly the first CTP of the Winows Phone SDK was released and Silverlight is THE platform for Windows Phone 7 series development and it's free! Silverlight for Symbian is also now available for Nokia S60 5th Edition devices like the N97. So Silverlight is becoming more and more a full multi platform technology. Awesome!

This blog post focuses on the Silverlight 4 RC and contains a summary of all the new features that were added since the Silverlight 4 Beta to the Silverlight 4 RC and the breaking changes that naturally come along with betas. Plus some details about the CaptureSource's new capture usage pattern.


New Silverlight 4 RC features

Rich Text
  • RichTextBox rename
  • Text position and selection APIs
  • XAML property for serializing text content
  • XAML clipboard format
  • FlowDirection support on Runs
  • "Format then type" support
  • Thai / Vietnamese / Indic support
  • UI Automation Text pattern
Networking
  • UploadProgress support (Client stack)
  • Caching support (Client stack)
  • Sockets security restrictions removal (Full Trust)
  • Sockets policy file retrieval via HTTP
  • Accept-Language header
Out of Browser (Full Trust)
  • XAP signing
  • Silent install and emulation mode
  • Custom window chrome
  • Better support for COM Automation
  • Cancelable shutdown event
  • Updated security dialogs
Media
  • Pinned full-screen mode on secondary display
  • Webcam / Mic configuration preview
  • More descriptive MediaSourceStream errors
  • Content & Output protection updates
  • Updates to H.264 content protection (ClearNAL)
  • Digital Constraint Token
  • CGMS-A
  • Multicast
  • Graphics card driver validation & revocation
Graphics and Printing
  • Hardware accelerated perspective transformations
  • Ability to query page size and printable area
  • Memory usage and performance improvements
Data
  • Entity-level validation support of INotifyDataErrorInfo for DataGrid
  • XPath support for XML
Parser
  • New architecture enables future innovation
  • Performance and stability improvements
  • XmlnsPrefix & XmlnsDefinition attributes
  • Support setting order-dependent properties
Globalization & Localization
  • Support for 31 new languages
  • Arabic, Hebrew and Thai input on Mac
  • Indic support
More
  • Update to DeepZoom code base with hardware acceleration
  • Support for Private mode browsing
  • Google Chrome support (Windows)
  • FrameworkElement.Unloaded event
  • HTML Hosting accessibility
  • IsoStore performance improvements
  • Native hosting performance improvements (e.g. Bing Toolbar)
  • Consistency with Silverlight for Mobile APIs and Tooling
  • System.Numerics.dll
  • Dynamic XAP support (MEF)
  • Frame / Navigation refresh support
The new webcam and microphone configuration preview is pretty neat. The user can now select the default webcam & microphone device really comfortable and we only need to use CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice() or CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice() to get the selected default video and audio device.


The webcam permission dialog is now consent and can remember if the user has previously allowed that certain application. Tim Heuer's blog post has more details about this handy new feature.


Breaking Changes since the Silverlight 4 beta
The first and most important take away: As usual all Silverlight 4 beta applications have to be updated to the RC and recompiled, otherwise the new RC runtime won't execute them.
  • Renamed RichTextArea to RichTextBox
  • Changes to DRM API
  • TextSelection.SetPropertyValue is now named .ApplyPropertyValue
  • INotifyDataErrorInfo moved to core (System.Windows.dll)
  • WebBrowser.ScriptNotify signature change
  • NotificationWindow.Visible and NotificationWindow.Closed were changed
  • Webcam and output protection change
  • COM Interop API changes (name and namespace)
  • RichTextBox.TextWrapping default value changed
  • Binding declarations in XAML where the target is a DependencyObject
  • HtmlBrush renamed to WebBrowserBrush

The official breaking changes document contains all the details and Koen Zwikstra (@kozw) has made some useful diff lists.

Changed usage pattern for AsyncCaptureImage
The biggest difference in the webcam API besides the renaming of some enums, properties and other members is the change of the AsyncCaptureImage method which was renamed to CaptureImageAsync. Additionally the usage pattern of the CaptureImageAsync method was updated to the standard .Net / Silverlight asynchronous event pattern.

Before the Silverlight 4 RC, AsyncCaptureImage was used like this:
// Initialization
captureSource = new CaptureSource();
captureSource.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();

// Capture image
captureSource.AsyncCaptureImage(bitmap =>
{
   // Process camera snapshot
   Process(bitmap);
});

The new RC CaptureImageAsync usage pattern:
// Initialization
captureSource = new CaptureSource();
captureSource.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
// Wiring the CaptureImageCompleted event handler
captureSource.CaptureImageCompleted += (s, e) =>
{
   // Process camera snapshot (e.Result is a WriteableBitmap)
   Process(e.Result);
};

// CaptureImageAsync fires the CaptureImageCompleted event
captureSource.ImageCaptureAsync();

Although the pre-RC pattern was smaller and easier, it's overall more consistent now and I welcome the changes.

Blog.SL4++
I already updated SLARToolkit and the samples and I will continue to update some of my Silverlight 4 beta samples during the next days. Furthermore I will make a Silverlight 4 RC build of the Matrix3DEx sample that should take advantage of the new hardware accelerated perspective transformations.

Wednesday, November 4, 2009

Classic Rock evolved into Heavy Metal

Mihnea Balta released MetalScroll, a great replacement for the superb Visual Studio Add-In RockScroll:









MetalScroll is an alternative for RockScroll, a Visual Studio add-in which replaces the editor scrollbar with a graphic representation of the code. Compared to the original, this version has a number of improvements:

  • The widget at the top of the scrollbar which splits the editor into two panes is still usable when the add-in is active.
  • You must hold down ALT when double-clicking a word to highlight all its occurrences in the file
  • Lines containing highlighted words are marked with 5x5 color blocks on the right edge of the scrollbar, to make them easier to find (similar to breakpoints and bookmarks).
I have used RockScroll for a while, but encountered some bad Visual Studio crashs if I changed from code view to the Windows Forms Designer and as a consequence I had to uninstall it. Later I asked Scott Hanselman (@shanselman), who released RockScroll on his website, if he could contact the RockScroll author Rocky Downs and ask him for the source code, so I could fix it and might release it as open source, but Scott Hanselman never got an answer from the RockScroll author. You can imagine how pleasantly surprised I was after I had read the MetalScroll news from Johan Andersson (@repi) today.



My favorite feature is not the smart Scrollbar nor the cool splitter, it's the word occurrence highlighting, a feature that I missed since I worked with Eclipse years ago.
MetalScroll works with Visual Studio 2005 and 2008 and it's free and even open source! So don't hesitate, download and install this great Visual Studio add-in now. You won't be disappointed.

Thanks Mihnea Balta for your awesome work!