cross-platform C# graphics library with shaped window support?

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 1374 Views - Last Post: 24 October 2013 - 07:12 PM Rate Topic: -----

#1 Shavais  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 22-October 13

cross-platform C# graphics library with shaped window support?

Posted 22 October 2013 - 11:39 AM

I'm looking for a way (using C#) to launch a user-resizeable shaped window application, in a flash, on Windows, OSX, and Linux, in desktop and laptop (non-mobile) environments, and use hardware accelerated 2D graphics (on each of those platforms, as reliably as possible) after doing so, in a way that involves as little platform-specific code as possible.

I'd like to have access to 3D graphics capabilities, but it seems like 3D contexts take several seconds to load/initialize, and I really want my stuff to launch as close to the launch speed of notepad as possible, at least as long as my app doesn't do any heavy lifting (aside from initializing the graphics system) on start up, so I kind of imagine ending up using vector and bitmap graphics.

Should I be using Mono.Cairo? Does Cairo itself support launching a shaped window, or is that something you have to do separately?

Is This A Good Question/Topic? 0
  • +

Replies To: cross-platform C# graphics library with shaped window support?

#2 Momerath  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1012
  • View blog
  • Posts: 2,444
  • Joined: 04-October 09

Re: cross-platform C# graphics library with shaped window support?

Posted 22 October 2013 - 01:21 PM

Mono.Cairo does graphics, it's not a windowing system. You can use it to draw your windows (and they'd be any shape you wanted) or you can use them to draw on windows.

Since I know nothing about what you are trying to do I can't tell you if Mono.Cairo will do what you want.
Was This Post Helpful? 0
  • +
  • -

#3 Shavais  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 22-October 13

Re: cross-platform C# graphics library with shaped window support?

Posted 22 October 2013 - 06:27 PM

Yeah, that confirms what I've gathered / experienced so far.

The first thing I'm trying to do is get a shaped, skinned window popping up nice and quick on Windows, Linux, and OSX. The next thing I'll be trying to do is draw some vector graphics and bitmaps on that shaped window, in a hardware accelerated way. Then I'll be working on allowing the user to click on part of the window (that I've drawn something on) and drag it to resize the window. Then I'll be trying to repeatedly redraw some of the things that I've drawn on the window, as it is being resized, and do that in as smooth/fast a way as possible. If possible, I'd like to clear, draw and then present whole-window frames, I think, but the important thing is for the resizing/redrawing to be smooth and fast. Then I'll be working on minimize, maximize, and close. I'm hoping to be able to launch and quit very fast. As close to instantaneous as possible.

"Why are you trying to do this? What's your over all goal?" My over all goal is to come up with a way of writing skinned, shaped-window GUI desktop/laptop apps that open in flash, close in a flash, resize/redraw very smoothly, and look and act exactly the same (or as close to exactly the same as possible) across Windows, Linux and OSX, and do it in a way that involves as little platform-specific work as possible. Eventually I'd love to add in some kind of cross-platform 3D capability along with some kind of cross-platform direct-input capability, and turn it into a game development framework, but that's gravy right now. I'm not particularly concerned with mobile platforms or touch screens at the moment, but I might eventually care about them.

"But your users will be unhappy because they won't have their OS-specific things they're used to." That might be a little bit true at first, but they're kind of a captive audience, so. My hope and belief is that once they get used to what I'll give them, they'll actually like it a lot better than what they're currently used to. Right away they'll have some pretty good reasons to like it better, because they're pretty unhappy with what they have right now, and I won't have to work too hard to make my stuff be a lot better for them than that.
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3623
  • View blog
  • Posts: 11,291
  • Joined: 05-May 12

Re: cross-platform C# graphics library with shaped window support?

Posted 22 October 2013 - 07:06 PM

Okay, I must still be missing a piece of the puzzle. How are you going to get a C# program and all its .NET dependencies to run on OSX, Linux, Flash, etc. ? A graphics library is not going to give you the cross platform CLR support. Mono has been abandoned, are you planning on picking it back up? Or are you planning on writing your own C# compiler that compiles to native code for each of your target platforms? And then pick up a snapshot of Mono and also compile that to be native to each target platform so that it can support your program?
Was This Post Helpful? 0
  • +
  • -

#5 Momerath  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1012
  • View blog
  • Posts: 2,444
  • Joined: 04-October 09

Re: cross-platform C# graphics library with shaped window support?

Posted 22 October 2013 - 08:13 PM

Mono was last updated 25 sep 2013, not sure about it being abandoned. But I do think he's going the wrong way with managed code and JIT compilers. Native code if you want speed.
Was This Post Helpful? 1
  • +
  • -

#6 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3623
  • View blog
  • Posts: 11,291
  • Joined: 05-May 12

Re: cross-platform C# graphics library with shaped window support?

Posted 22 October 2013 - 08:36 PM

I read both on ZDNet and Wikipedia that Mono had been abandoned last year. I guess a white knight has come and resurrected it. (Sorry for mixing metaphors. :)/>)
Was This Post Helpful? 0
  • +
  • -

#7 Shavais  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 22-October 13

Re: cross-platform C# graphics library with shaped window support?

Posted 23 October 2013 - 12:57 AM

So I guess you guys are not C# evangelists, lol. The shop I work in is a C# shop, for better or for worse. Otherwise I'd probably be working in Python or something.

I have a hard time imagining that C#/ Mono has been even close to really being dead/abandoned any time in the last few years? Unity 3D uses it, and Unity 3D is used by what.. half of all currently in progress indie game dev efforts? A whole lot. So there's no way it's even close to dead? I guess they forked their own MonoDevelop, but still.

I did some work in scala and java, a short while back, and discovered some things I did not really know.. in as detailed a way.. about jvm's. The stuff I was doing seemed slower than it should be, so I wrote the same thing in Python, and low and behold, it was a lot faster. I timed it, and the python version of this one fairly common seeming, relatively innocuous piece of code was 2 orders of magnitude faster in Python than in Scala. So I did some other little tests, and got similar results. And I was following all the recommended practices I could find for speed / optimization in both language environments. I did some digging and messing around, and found that no matter what options I used, the very best I could do with Scala/Java was get it to optimize on the fly - based on gathered statistics from running the compiled code over and over.. and it would typcially take a jvm 100+ iterations over the same function for the optimized JIT compiled version to almost reach the speed of Python. Which it never quite did. I tried to find a way to freaking save the danged optimally optimized version of the function, and I could not find a way, without altering the jvm. I was beside myself, I couldn't believe it. I'd always heard Java was faster than Python. Everyone says that. Well it sure wasn't in my tests. And I showed them to a hardcore scala/java guy, who'd been involved in training master's degree students and in altering jvm's, and he worked on it a little, but he was not able to improve on my results at all. He wasn't particularly surprised. It didn't matter to him, because his approach is to.. use a bunch of servers and keep them running all the time, and, when they do restart, "heat them up" for a while before turning them loose on the world. Good gawd. That sure as hell doesn't work for the type of stuff I'm working on.

I also tested Python in comparison with C++. What I found was that if you use Boost or the STL or do a significant amount of making things easier on yourself by overloading operators and using class structures / instances that make things easier.. in other words if you do very much to make C++ any more barable than C, it's very easy to end up slower than Python. There are some ways I found to go a bit faster in C than in Python, and you can write C code in C++ if you really want to. But it just wasn't leaps and bounds faster. An STL map is reliably slower than a python dictionary. No matter what compiler options I use or what libraries I link with. At least that's true for every permutation I tried, and I tried a few. Python has gotten to be pretty danged fast for most purposes. And it's a freaking interpretter!

I've compared C# with Python and C++, and found that (at least for my handful of little rudimentary tests) C# is not as fast as either of them, but it's not as slow as java. It JIT compiles, but it does a reasonable job of it a single pass. And if you want to, you can actually precompile your assemblies, and that helps a little, but it it's still not as quick as Python, C or C++. At least not in my tests.

Anyway, C# is fast enough for my purposes. On OSX you can pop a window with C#/XWT just about as fast as you can with Objective-C/Cocoa. If ObjectiveC/Cocoa is any faster at it, it's barely perceptible, at least on my machines. But I don't know how to do a shaped window with XWT or ETO. If I did I would use ETO/Cairo in a heart beat.

I can do a shaped window with GTK#, which works on all three platforms, and I can use Cairo with it, but my problem with GTK# is that right now it requires running X server on OSX. =P Bleah.

Well, if worst comes to worst I guess I can just bind to a native library on each platform for getting the shaped window up quick, and then work out how to use Cairo with each of those libs. What a pain, lol.


Yeah, but in any case I'm super glad not to be working in C/C++. It's just not that much faster anymore, for practical purposes, and the library/build nightmare is 100 times worse.
Was This Post Helpful? 0
  • +
  • -

#8 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3623
  • View blog
  • Posts: 11,291
  • Joined: 05-May 12

Re: cross-platform C# graphics library with shaped window support?

Posted 23 October 2013 - 05:53 AM

View PostShavais, on 23 October 2013 - 03:57 AM, said:

I can do a shaped window with GTK#, which works on all three platforms, and I can use Cairo with it, but my problem with GTK# is that right now it requires running X server on OSX. =P Bleah.


I thought one of the hallmarks of GTK and its descendants was its flexibility in changing the rendering engine by rebuilding/relinking against a different rendering engine. Can't you rebuild GTK# to use the frame buffer instead of using the X libraries?
Was This Post Helpful? 0
  • +
  • -

#9 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3623
  • View blog
  • Posts: 11,291
  • Joined: 05-May 12

Re: cross-platform C# graphics library with shaped window support?

Posted 23 October 2013 - 06:00 AM

View PostShavais, on 23 October 2013 - 03:57 AM, said:

I have a hard time imagining that C#/ Mono has been even close to really being dead/abandoned any time in the last few years? Unity 3D uses it, and Unity 3D is used by what.. half of all currently in progress indie game dev efforts? A whole lot. So there's no way it's even close to dead? I guess they forked their own MonoDevelop, but still.


XNA was also still being used by a lot of people, but MS officially abandoned it. A lot of people were also using DirectX 9 fixed function vertex pipeline, but MS abandoned that in DirectX 10. A lot of businesses were using Silverlight, but MS officially abandoned it in favor of HTML5. There are still a lot of people who continue to use XNA, DX9, and Silverlight because they are already too far along in their projects to retool.
Was This Post Helpful? 0
  • +
  • -

#10 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 851
  • View blog
  • Posts: 2,605
  • Joined: 29-July 11

Re: cross-platform C# graphics library with shaped window support?

Posted 23 October 2013 - 06:13 AM

c# is a great language, and Mono is definitely alive and kicking. If c# is your main language and you want to be multiplat, there is no good reason to not use Java, most especially if you are one of the few .net programmers who can write winforms by hand :) You will have no problem with Java and Swing.
Was This Post Helpful? 0
  • +
  • -

#11 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2134
  • View blog
  • Posts: 3,272
  • Joined: 21-June 11

Re: cross-platform C# graphics library with shaped window support?

Posted 23 October 2013 - 06:15 AM

View PostSkydiver, on 23 October 2013 - 05:36 AM, said:

I read both on ZDNet and Wikipedia that Mono had been abandoned last year.


You're probably thinking of Moonlight, which has been discontinued last year.
Was This Post Helpful? 0
  • +
  • -

#12 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3623
  • View blog
  • Posts: 11,291
  • Joined: 05-May 12

Re: cross-platform C# graphics library with shaped window support?

Posted 23 October 2013 - 06:24 AM

Yep, very likely.
Was This Post Helpful? 0
  • +
  • -

#13 Shavais  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 22-October 13

Re: cross-platform C# graphics library with shaped window support?

Posted 23 October 2013 - 10:20 AM

View PostSkydiver, on 23 October 2013 - 05:53 AM, said:

View PostShavais, on 23 October 2013 - 03:57 AM, said:

I can do a shaped window with GTK#, which works on all three platforms, and I can use Cairo with it, but my problem with GTK# is that right now it requires running X server on OSX. =P Bleah.


I thought one of the hallmarks of GTK and its descendants was its flexibility in changing the rendering engine by rebuilding/relinking against a different rendering engine. Can't you rebuild GTK# to use the frame buffer instead of using the X libraries?


Wouldn't working directly with the framebuffer interfere with OSX's window management? It seems kind of likely to me that if it were a matter of a bit of build configuring and relinking against different libraries, GTK# on OSX wouldn't be stuck in X11 land. It might be worth looking into. If it were fixed, Gimp on OSX wouldn't have to start an X server, which I think a few people might appreciate a bit. But it would probably take me several hundred hours to figure out how to fix GTK on OSX so it doesn't require X and plays well with OSX's window management, etc. Which I might put in, I guess, but. I think it would probably only take me maybe 10 or 15 hours figure out how to use Mono.Cocoa on OSX and use Mono.Cairo in that context.

View PostSkydiver, on 23 October 2013 - 06:00 AM, said:

View PostShavais, on 23 October 2013 - 03:57 AM, said:

I have a hard time imagining that C#/ Mono has been even close to really being dead/abandoned any time in the last few years? Unity 3D uses it, and Unity 3D is used by what.. half of all currently in progress indie game dev efforts? A whole lot. So there's no way it's even close to dead? I guess they forked their own MonoDevelop, but still.


XNA was also still being used by a lot of people, but MS officially abandoned it. A lot of people were also using DirectX 9 fixed function vertex pipeline, but MS abandoned that in DirectX 10. A lot of businesses were using Silverlight, but MS officially abandoned it in favor of HTML5. There are still a lot of people who continue to use XNA, DX9, and Silverlight because they are already too far along in their projects to retool.


True, but Microsoft has published C# and .NET as an open standard, and the open source community has taken it up and spread it across the platforms in the form of Mono. Microsoft could abandon C# and .NET entirely
(which seems kind of unlikely to me that they'll do anytime soon) and we could easily find ourselves still having active development going on with Mono. There are probably something like 1 million indie game devs, and what, 500,000 of them use Unity 3D? But then, of those 500,000 indie game devs, I guess maybe only 10 or 100 would actually try to do anything with Mono itself, lol, so. Mono death could certainly happen, I guess.

View Postfarrell2k, on 23 October 2013 - 06:13 AM, said:

c# is a great language, and Mono is definitely alive and kicking. If c# is your main language and you want to be multiplat, there is no good reason to not use Java, most especially if you are one of the few .net programmers who can write winforms by hand :)/>/> You will have no problem with Java and Swing.


Java does have the very nice advantage of having true cross platform solutions. It's pretty common to be able to set things up so that you don't have to write any platform-specific code at all.

But I've had a lot of performance problems, resource greed issues, and library/version nightmares when I've tried to work with Java. I find library call crashes and.. things just not really quite working as advertised to be a pretty common experience. Something is supposed to work, but isn't, in my particular context, for whatever reason. That's one thing I appreciate a lot about Python and C# - library call crashes are pretty rare, and the stable versions of published libraries seem to usually be pretty solid.

It seems like every significant java program I've ever used has been really slow, and a real resource hog, for whatever reason. I once wrote a python program to replace a java program we were using at one place I worked. The java program would slow my whole box down to a crawl for 2 minutes. The python replacement did pretty much the same general job, in about 10 seconds, without having any noticeable impact on the system. I guess it probably has more to do with the algorithms and such than the language, but. It just seems like "java" is one of the most common processes to end up killing off the top of the process list in order to calm a system down. Even though C# and Objective-C both use garbage collection, they just don't tend to produce the sort of resource greed that Java seems to, for whatever reason. At least that's been my experience.

One of my goals is to get a shaped, resizeable initial main window to pop up nice and quick, and I haven't yet managed to get java/swing to do that (but then I haven't tried too hard).

Anyway, I work in a C# shop, so. I'm looking for a C# solution.
Was This Post Helpful? 0
  • +
  • -

#14 Shavais  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 22-October 13

Re: cross-platform C# graphics library with shaped window support?

Posted 24 October 2013 - 12:04 PM

View PostSkydiver, on 22 October 2013 - 07:06 PM, said:

Okay, I must still be missing a piece of the puzzle. How are you going to get a C# program and all its .NET dependencies to run on OSX, Linux, Flash, etc. ? A graphics library is not going to give you the cross platform CLR support. Mono has been abandoned, are you planning on picking it back up? Or are you planning on writing your own C# compiler that compiles to native code for each of your target platforms? And then pick up a snapshot of Mono and also compile that to be native to each target platform so that it can support your program?


Meh, time to shovel crow. I heard someone once say (speaking generally of the importance of code comments and such) "The worst programmer you'll ever meet is you 6 months ago." Sometimes I think it's me 5 minutes ago.

I was happily and naively operating away in my OSX dev environment, having deployed Unity 3D stuff to OSX just fine in the past, under the assumption that Xamarin Studio would piece together an OSX app for me, ready to deploy, and that what that package would have in there would be reasonable enough (.ie, not require basically installing mono and all its stuff on the target box). Mahaha!

Turns out if I want to strip down what I have to deploy to anything that to me resembles reasonable, I have to precompile, and if I precompile, I sacrifice generics. Which to me pretty much completely castrates C#.

Dam. Failing a quick enough C# solution, the folks at work are going to want a web solution. (With IIS/C# on the server.) Bahremu. I guess I'll once again be parting ways between my own stuff and the stuff I do for work.

Alright, well, now my questions are different, and I have a bunch of research to do before I'll have them. Thanks for your responses.
Was This Post Helpful? 0
  • +
  • -

#15 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3623
  • View blog
  • Posts: 11,291
  • Joined: 05-May 12

Re: cross-platform C# graphics library with shaped window support?

Posted 24 October 2013 - 02:04 PM

Well, there is Silverlight. :)
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2