How Do You Implement Pen Computing via WinTab on a Surface Book? - pen

I would like to write an application that gets pen input on a Surface Book.
The primary motivation is that the new Surface Pen Platinum advertises tilt and 4096 levels of pressure, but there is no tilt response that I can find (and probably not 4096 levels of sensitivity). I am trying to understand and document this.
The Surface Book uses an N-Trig pen instead of a Wacom pen. I notice that drawing applications like Corel Painter, Krita, and Rebelle provide the option to do either WinTab or use the Windows implementation, and seem to work either way. I am using Photoshop CS5, which is before the days of N-Trig and doesn't have any such option at all, yet still works.
The Wacom drivers are not installed on this Surface Book. In earlier days of Surface computers, you could download WinTab drivers from Microsoft that apparently solved the Photoshop problem. You can still download the drivers, and the current version of these drivers is Wintab_x64_1.0.0.20. They are dated 1-12-2015 and include two DLLs: wintab32,dll and DHid.dll. Neither of these is on this Surface Book.
I downloaded the TiltTest application from the Wacom SDK and got it to work on another computer with Wacom drivers installed and using a Wacom Pen. Having the code, I can see it is providing tilt information (both altitude and azimuth), and 1024 levels of pressure (the values go from 0 to 1023 at least). If I try to run this application on the Surface Book, it just says it cannot find wintab32.dll and does not run, even with the Microsoft wintab32.dll in the same directory as the .exe. With the Wacom wintab32.dll in the directory, it gets past that but can't find the tablet service. It is using the WM_PACKET message, which is apparently Wacom-specific.
I note that one possibility seems to be to use the WM_POINTER API. However, this apparently started with Windows 8.1 and would not have been used by Photoshop CS5.
So the question is how does Photoshop work in this environment and what are the other applications doing to implement either WinTab or something else. And how would I use this in a simple app to see if I am getting tile and what levels of pressure.

The answer is that it doesn't work. I was so busy testing tilt that I didn't notice there was no pressure sensitivity and a warning sign on Shape Dynamics for a brush that says "Control by pressure requires a pressure sensitive tablet". It was acting like a mouse, not a pen. I don't use Photoshop for drawing very much or I would have seen this sooner.
Using Spy++ I determined it was getting no Wintab WT_xxx messages like WT_PACKET. (These are in the range 0x7FF0 to 0x7FFF, the top of the WM_USER range.)
The solution is to install the N-Trig Wintab DLLs, wintab32.dll and NHid.dll, which are available from Microsoft. After that the warning went away, and there was pressure sensitivity. In addition, Spy++ indicated the main Photoshop window is now getting WT_xxx messages.
So, as expected, Photoshop CS5 implemented WinTab and likely doesn't know about the later APIs. N-Trig is simulating WinTab, and the N-Trig wintab32.dll has the same functions, but a different implementation.
As far as tilt and azimuth go, The Surface Book does not provide them, even with the new Surface pen. None of the drawing applications mentioned, including Photoshop, shows tilt or azimuth. I have recently tried the same pen on a Surface Book 2 and a Surface Pro 6, and they do provide tilt and azimuth, although there does not seem to be azimuth with applications using the Real-Time Stylus (RTS) API.

Related

Objects are not as stable as ARKit

I have used this tutorial in order to create working example project. But when I move around with device, object is also moving slightly with me (even Lowe's Vision app) but ARKit keeping object a lot more stable than Tango. Is there any guide to fix this issue or Tango is not ready for using in real world applications (other than cases where slightly unstable objects are ok to tolerate, like in games)?
What "Tango" device, if it is the Dev Kit, then that 3 year old Tegra chip and older hardware is probably the bottle-neck as the Phab 2 Pro can compute and track way better then the old Dev Kit as I have compared them next to each other.
I have also compared my Phab 2 Pro with a Tango C API demo to the standard ARKit demo and the Tango has way better tracking since it has the depth camera as ARKit is just good software over a normal RGB camera. But this depth camera loses a lot of its advantage if you are clogging it with the abstraction layer set on Unity.
Also to my knowledge I am not sure how you can really quantify "more stable" as it might be the applications fault, not the hardware

Firemonkey Scrambles graphics on laptop

I have an application that plots quarter degree blocks on a map using Timage stacked on each other. I then add records by drawing them on a separate layer.
The problem I have is that Firemonkey (or Windows) scrambles the graphics, but only on some computers, and I think all the affected computers are laptops. See the following links for screenshots:
The correct image should look like this:
On laptops this scrambling may take 3 repaints of the layers, but sometimes (on exactly the same code) it happens after 1 or two times. While it is inconsistent in exactly how many repaints it takes, it is guaranteed to happen after no more than 3 paints.
So I have come to the conclusion that it must be a Graphics driver issue. I have a NVidia Geforce 950M on my laptop (Asus NJ551 with Windows 10), but if I understand the code correctly I am using the Windows Direct2D acceleration so the Nvidia drivers shouldn't affect things?
I set the following flag by default: GlobalUseDX10Software := true; //Use DirectX to generate graphics, but this does not seem to make any difference as it still scrambles even when set to false.
I would prefer the Windows acceleration as my users may not all have a graphics card installed. A friend using a HP laptop (not sure of the model but running Windows 8) does not experience the issue, yet another friend with a brand new HP laptop (low spec but with Windows 10) is also experiencing the issue.
Can someone please help out here? I am out of ideas, and I'm not even sure what to Google. Is it Windows 10, is it the Graphics driver, etc? Is there a way I can force my laptop to use the Graphics card for testing? While this will not help other users without proper graphics cards, it may help isolate the issue.
Any advice is appreciated!
From the EDN forum, I got the a number of other Graphics related global variables to set. The one that sorted out the issue is:
GlobalUseDXSoftware := True;
It now makes sense, as the issue started happening after moving to XE8 from XE5, and the GlobalUseDX10Software flag is now deprecated

Emulate OpenGL on machine with standard VGA graphics

So, we've got a little graphical doohickey that needs to run in a server environment without a real video card. All it really needs is framebuffer objects and maybe some vector/font anti-aliasing. It will be slow, I know. It just needs to output single frames.
I see this post about how to force software rendering mode, but it seems to apply to machines that already have OpenGL enabled cards (like NVidia).
So, for fear of trying to install OpenGL on a machine three time zones away with a bunch of live production sites on it-- has anybody tried this and/or know how to "emulate" an OpenGL environment? Unfortunately our dev server HAS a video card, so I can't really show "what I've tried".
The relevant code is all in Cinder, but I think our actual OpenGL utilization is lightweight for this purpose.
This would run on windows server 2008 Standard
I see MS has a software implementation for OGL 1.1, but can't seem to find one for 2.0
Build/find some Mesa DLLs.
It will be slow.

Are GDI, GDI+ and OpenGL really obsolete/deprecated? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
If you open the page "Graphics and Gaming (Windows)" on microsoft.com
the last category is described as
Legacy Graphics: Technologies that are obsolete and should not be used in new
applications.
This category includes (among others) the following APIs:
GDI
GDI+
OpenGL
What's your opinion? If i want to roll out a new software today it must support Windows XP (still about 50% of all installed systems). Direct2D requires Windows 7/Vista. What else should be used?
I suspect that Microsoft's definition of "legacy" has little to do with what any sensible developer should do, and is instead based on some Grand Rewrite of the Windows API.
Starting at around Windows Vista, Microsoft has been redesigning many of their API's. We now have MMDevAPI as the One True Sound API, WIC is the One True Image File API, etc. From what I've seen/heard, these new API's are much better than the old ones, and the "legacy" systems all work based on the new ones. In Windows Vista and later, DirectSound is entirely based on MMDevAPI, and components that need to read image files do it via WIC.
Windows 8 will have an ARM version, which it appears will support only a subset of the current Windows API. We won't know for sure until Windows on ARM is released, but, based on the libraries included for the ARM platform in Visual Studio 11 (ref: http://www.winehq.org/pipermail/wine-devel/2012-March/094559.html), it's looking like GDI+ and OpenGL will not be available. GDI is available for linking, but that doesn't necessarily mean it's intact.
This new API's from Vista and later roughly correspond to the libraries in the VS11 ARM target. I'm guessing that anything on that list is there because it's either the latest and greatest way to do what it does, or it's too technically important to discard (for now). Thus, "legacy" is anything that's not the latest and greatest way to do at least one thing.
I'm not sure what is the One True Graphics API. Already we have Direct2D, Direct3D, DirectComposition (which, by the way, is not available until Windows 8), DirectWrite, and DXGI. DXGI seems the closest, but I don't have a deep enough understanding of the graphics API's to say. I suspect gdi32 is technically very difficult to get rid of. How are non-legacy applications meant to find out when part of a window has been revealed and therefore must be painted, without using WM_PAINT, which involves an HDC, and how could a library do that on an application's behalf without replacing its window procedure? How are we meant to make semi-transparent windows without using UpdateLayeredWindow, which takes an HDC? How much does user32 depend on gdi32, and can they really be separated?
From a technical standpoint, Windows can easily get rid of GDI+ and OpenGL, but I'm not convinced that getting rid of OpenGL will work out, even on a new platform that doesn't promise any backward compatibility. It seems too valuable to developers. GDI+ isn't so important, but it's very easy for a third party to provide a replacement.
I would say use any of the API's you listed, and the worst that's likely to happen is that you have to rewrite your UI if you want to port your app to metro or Windows on ARM. GDI is a fine choice if your needs are simple and you'll be coding directly for the Windows API. There aren't many situations where I'd recommend GDI+ over OpenGL as a drawing API. GDI+ is slow, limited, and only available on Windows. The GDI+ API is simpler because it's 2D, so maybe it's worthwhile if you need to do something very simple but with anti-aliasing.
OpenGL isn't deprecated, Microsoft's implementation of it is. Microsoft's implementation is stuck at version 1.1, which is old. The current version of the standard is past version 4. If you want to use OpenGL, it is fully supported by NVidia, ATI, and Intel graphics cards on the Windows desktop, but not in Metro Windows Modern UI apps, is an industry standard, and also works on Mac and Linux. If you need a software fallback implementation, Mesa has got you covered, and it even works on DOS. (Since Mesa can render into memory buffers, there's no reason it won't work in Modern UI apps, but you probably don't want to do this because it can be slow.) One thing of note is that WGL, the API for accessing OpenGL functionality on the Windows desktop, depends on GDI (which is deprecated) so you probably want to use something like FreeGLUT or SDL instead if you want to future-proof your application, which also nets you platform independence.
OpenGL ES is a variant of OpenGL which works on Android and Apple iOS. It is also accessible in JavaScript via WebGL, which Internet Explorer 11 will support (and pretty much every other browser already does.) ANGLE provides a hardware-accelerated implementation of GLES for Windows which piggybacks off of DirectX (version 9 or 11) and thus should work in Modern UI apps as well. Once again, Mesa's got the software implementation covered.
TL;DR: OpenGL is not only not deprecated, it is cross-platform, standard, and has tremendous momentum in the industry. GDI and GDI+, well, not so much.
If you want to support Windows XP, then you're supporting a "legacy" operating system, and as such, using a "legacy" graphics framework is the logical choice.
Even if that weren't true, let's just say that I disagree with the advice given by the linked MSDN article. The "legacy" status here has more to do with which technology the Windows team thinks is cool this week. The status designation of "obsolete" just means that the group responsible is no longer accepting or fulfilling bug reports (except for critical security issues). Not too big of a deal—these technologies have been around long enough that they're fairly feature-complete and stable.
GDI isn't going anywhere, so if you need something rock-solid that is guaranteed to be supported anywhere and everywhere, that's what I would go with.
If you need a bit more 2D capabilities than GDI offers (e.g., alpha channel transparency), then you could consider using GDI+. It's nearly an order of magnitude slower than GDI, but that's not too big of an issue on modern machines with more power than you could ever want. This, too, is going to be supported for a very long time to come.
That said, if I were writing a new app today, I probably wouldn't bother with OpenGL. There's very little that it offers in benefits over Direct2D and DirectWrite, which are both what Microsoft is pushing as the replacements for GDI/GDI+. There might be some benefit to using OpenGL if you absolutely must target Windows XP because as far as I can tell, Direct2D/DirectWrite are only supported on Vista and later, but that's because (as I mentioned originally), Windows XP falls squarely into the "legacy" or "obsolete" camp itself. Alternatively, if you already know OpenGL well and don't have time or the desire to learn Direct2D/DirectWrite, then it might make sense to continue using it in a new application.
Don't let the verbiage of the MSDN article scare you. Choose whatever technology makes the most sense for your specific use case given all of the available information. By the time any of these technologies go away completely, you'll have to re-write the app completely for a dozen other reasons.
Edit: Hmm, it looks like DirectWrite has also been declared (by some people at least) "obsolete" as well, having been replaced by Direct2D. That's funny, it hasn't even been around long enough for me to bother learning it. I guess that only goes to support my earlier argument that "obsolete" simply designates that a particular technology is not what is currently considered to be in vogue by the Microsoft devs.
I'm personally waiting until all the bugs get worked out of this stuff (and we decide on a semi-permanent standard) before I make the switch for any of my applications. Everything I've seen written in DirectDraw or Direct2D has had serious rendering bugs and is a performance nightmare, even on reasonably competent machines. Sure, they only show up sometimes, under the right conditions, but that's too much for me. And I swear, the blurry text shows up all the time. Not being able to read what's on screen is a deal-killer for me and my users. GDI doesn't have this problem, and it's not going anywhere.
Are GDI, GDI+ and OpenGL really obsolete/deprecated?
This is not true for OpenGL. OpenGL 4 allows you to use geometry shaders on winxp. Which isn't possible with DirectX (DirectX 10 and up isn't supported on WInXP). It is also one of the only cross-platform 3D APIs out there.
From a business point of view MS is interested in promoting DirectX since it is their technology that lock Developer into windows platform (they're also interested in making DirectX more attractive for developer, but that's another story). So it makes sense that they aren't keen on promoting OpenGL.
What else should be used?
I'd advise to stop using platform-specific tecnologies when possible. Grab cross-platform framework and use it for your application. There's Qt, GTK, wxWidgets and other toolkits for GUI apps, and SDL(and alternatives) for games. This way when platform developer decide to make ridiculous decision (like not supporting DX10 on WinXP) you dislike, you'll be able to move elsewhere with minimum development cost. Qt is also ridiculously powerful and at the moment I have no reason to use something else for GUI development. Still, situation can change in the future.
In short, while developing for certain platform you should keep in mind that platform developer might have their goals that are not compatible with your wishes. Discovering that your source has become locked into single platform isn't very pleasant experience. Your own goals should be the first priority, and if os developer tries to make you use certain technology you don't like, then you shouldn't support that technology.
Because OpenGL is a standard, it should be considered equally deprecated as C or C++ so it is a matter of time before the entire Windows API -- which today has become a compile once run on every x86 machine API thanks to Wine -- is considered deprecated in favour of .NET and C#.
I use GDI for simple graphics and OpenGL, when I need accelerated 3d.
Another aspect is that Microsoft's build-in implementation of OpenGL is definitely to be considered as deprecated since it is just version 1.1 or something, but that has been for a long time.
Yeah, about OpenGL, it actually outperforms DirectX in many ways both resource and display wise. It will never be promoted by Microsoft because it can't own OpenGL, not to mention most people don't do their research and Microsoft can claim it is old. Truth is opengl is opensource standard and evolves at a much faster rate than closed does because it is more than 1 room of developers paid to work on it. Also Microsoft has contracts with many companies to release using only Microsoft's software, this causes more business for Microsoft and less to use the more advanced OpenGL standard. It is a interesting lock up if you will, Microsoft creates these contracts so that many programs are written in DirectX to keep business for Microsoft, and no company will refuse it because Microsoft has about 80%+ home user market.

windows phone 7 device compatibility

I noticed windows phone 7 only has one hardware standard now.
I just wonder if the compatibilities of wp7 devices provided by different hardware vendors are better than the complex and headache android devices?
Welcome any comment
Microsoft's standards for the WP7 make it so that app compatibility is now solid (unlike past version of WinMo). If you have an app that runs on one phone, it will run on them all.
When the original specs came out it was intended that there would be 2 chassis specs. The first with a screen resolution of 480x800 and another, coming later, with a resolution of 320x480.
Since the Nokia deal it is very unlikely that devices with a 320x480 screen, and other features as previously described, will now be released. Other chassis specs are expected but we'd only be guessing at what these would be.
The current templates include hard coded margins, etc. which are appropriate for the 480x800 resolution. Until we know what, if any other resolutions the platform will support it's not known if just hard coded values will still be appropriate.
The most recent recommendations I've had from the WP7 development and design teams are to focus purely on the 800x480 resolution devices and worry about other resolutions as and when they're announced.
It has been suggested that if devices with smaller screens are released then the framework will include the ability to automatically scale the apps/pages for such resolutions. I imagine there will also be the ability to adjust the sceen design based on the resolution but this is currently just a guess. If other resolutions don't support the same ratios then this will be particularly important.
To do anything else, before details of what other resolutions may need to be supported is additional work for now and is based purely on guesswork. I'd recommend following the advice and just sticking to creating apps which are designed for 480x800. If and when the need to support other resolutions arises we can worry about how best to do so then.

Resources