Drawing primitive geometry in OpenTK? - opentk

I am using OpenTK library to embed an Opengl control onto C++ windows form. However, OpenTK doesn't support GLUT, so I cannot easily create primitive geometry such as cube, sphere, tetrahedron, etc. I actually plan to use all of the platonic solids, so recreating the whole dodecahedron triangles would waste me a lot of time. Is there a way to use GLUT in OpenTK? or is there an alternative functions to drawing platonic solids or primitive geometries in OpenTK?
Thanks

OpenTK can only be used in context with C#. The problem is that there is no Glut library for C# because everybody uses C++ instead. Actually it is not OpenTK that does not support Glut, it's C# that doesn't.
Of course one could use C# with OpenTK and reference Tao.FreeGlut.dll which is a portation of the Glut library onto C#. That way you could use FreeGlut and would still have the advantage of OpenTK (which superseded Tao). OpenTK does not bring a FreeGlut portation itself like Tao does.
If you use C++, just get the regular freeglut.dll as discribed in this post: glut and Visual Studio 2010

Related

Are there any example to use DirectX SwapChainPanel in XAML Control with C++/WinRT and Consume it by C#/.Net using Windows App SDK?

I'm new in WinRT or COM application but now looking for good sample program using C++ SwapChainPanel in XAML for DirectX and operate it in C# as desktop applications using WindowsAppSDK.
I know there are some or few examples showing:
Make Windows Runtime Component using C++/WinRT and consume it in C# (but no XAML) The reflection is used.
Make custom control in C++/WinRT and consume it in C++ on the same project.
Make custom control in C#/WinRT and consume it in C# on the same project.
Use DirectX via DirectN or old sharpDX or such C# wrapper. (but no C++)
Make C++ user control as UWP control and consume it in UWP project.
There many comments UWP and WinUI3 is almost equivalent but I cannot find out exact example doing this. If you know some, please point them out.
Or, should I give it up and go another choice? Once I've made a .Net program using OpenTK but not so good at get performance, then this time I'm trying DirectX.
Thanks for any advise.

Can a C/C++ program be compiled into a .NET portable class library using C++/CLI

I've read the documentation on .NET programming in C++/CLI, and understand at a high level that it can compile C or C++ to .NET MSIL. I also understand that native structures are translated in the process.
The question is, can I compile a C/C++ codebase into a .NET Portable Class Library using C++/CLI? The intention is to use the result across various platforms, e.g. the Xamarin platforms and UWP.
Edit: Is it easier to do this for plain C, rather than C++?
Short answer: AFAIK no.
Long answer:
As far as I know the C++/CLI source code is compiled in "mixed" mode. It means that if you learn C++/CLI language and create managed classes with it, they run in .NET natively. That's good. But if you simply take your existing C++ code and compile it, the result is the native x86/Windows code, which cannot be used on other platforms. It is called "mixed" because the compiler puts native and .NET IL code together to single executable file.
C++/CLI is usually used in situations where you want to use the existing C++ code
as a part of .NET program in Windows. So you create a library in C++/CLI and create an interface for it in managed C++/CLI. This managed C++/CLI interface is a bridge between native C++ code and the rest of your program in .NET.
Also, as far as I know, C++/CLI is generally not supported by CoreCLR.

Integrating Octave in VB

I have a code written for displaying 2D histogram in Octave. I want to build a nice GUI for displaying the demo for the code. I thought of using VB forms (using VS2012) for building this. However I could not call the Octave programs from VB. Can anyone give me some ideas regarding this?
Thanks in advance
The Visual Studio distribution of Octave 3.6.2 for Windows includes some basic UI functionality, which may be enough for your needs, so that you could do it all in Octave without having to get Octave and VB to talk to each other. From Summary of important user-visible changes for version 3.6:
** The following Matlab-compatible handle graphics functions have
been
added:
guidata uipanel uitoolbar
guihandles uipushtool uiwait
uicontextmenu uiresume waitfor
uicontrol uitoggletool
The uiXXX functions above are experimental.
Except for uiwait and uiresume, the uiXXX functions are not
supported with the FLTK+OpenGL graphics toolkit.
The gnuplot graphics toolkit does not support any of the uiXXX
functions nor the waitfor function.
3.6.4 is also out (see http://sourceforge.net/projects/octave/files/Octave%20Windows%20binaries/Octave%203.6.4%20for%20Windows%20Microsoft%20Visual%20Studio/), but I don't know if the UI functionality has been improved or not.

Can OpenTK be used from within Monogame

Is it safe to use OpenTK functions from within a MonoGame project? Do I lose any portability?
The short answer is no and yes respectively. You shouldn't make a habit of using OpenTK functions from within a MonoGame project because you could lose portability.
MonoGame uses OpenTK under the hood to provide support for some (probably most) of it's platforms. However, there's no good reason to believe that all future platforms will support OpenTK or that MonoGame will always use it.
I can see 10 supported platforms based on the solution files on github and at least one of them uses Windows DirectX instead of OpenGL. Although, there is an OpenGL version as well.
That said, if you really need to use OpenTK in your project directly, you could do it the same way MonoGame implements multi-platform support. If you poke around the code for a bit you'll notice various defines for platform specific code like so:
#if ANDROID
// your code here
#endif
#if DIRECTX
// your code here
#endif
#if WINDOWS_PHONE
// your code here
#endif
At the end of the day, you just need to weigh up the risks depending on what platforms you would like to support and the effort you're willing to go to do so. Good luck! :)

DirectX 2D drawing with Vb.net

I'm using using System.Graphics for my latest project (A simple 2D application). Problem is, it gets a horrible FPS and I'm only drawing 8x8 tiles (usually 10-12 is enough to bring it down to 12FPS).
A friend of mine suggested that I use DirectX. He also suggested XNA but I opposed because I don't want my clients to have to install the XNA distributional. DirectX is common enough (to my knowledge) and I can just include the dll's if I need to.
So, my search began. I've been looking only for DirectX 2D tutorials for VB.net. I've had no solid success thus far. In truth, all I need to do is be able to draw bitmap x at position pos.
I've been using System.Graphics and a hacked up bitmap as my buffer thus far so I'll go for any improvement that I can get.
I'm using VB.net so I'll be ok if you give my one for C#, I'm pretty good at being able to read it (and I have a nice converter too). I would just prefer VB.net to save time.
Thanks! :)
This article in MSDN Magazine was in 2003 edition had a nice example of managed DirectX code in action:
http://msdn.microsoft.com/en-us/magazine/cc164112.aspx
Sadly enough, currently, there's no managed library of DirectX (a.k.a. DirectX .NET wrapper) in DX 10 and DX 11. Microsoft only provided managed library for DX 9.0a and DX 9.0b.
In Managed DirectX wikipedia, you'll see that it's being replaced by Microsoft XNA.
If you download current/latest DirectX SDK, you will have samples only in C++ and HLSL codes.
If you really need fancy UI and also nice animation and 3D drawing based on DirectX, you can go use WPF, especially WPF in .NET 3.0 SP2 (or simply download and install .NET 3.5 SP1). WPF is build on top of DirectX 9.0c stack, without worrying to know large libraries of DirectX 9 API. You'll also get 3D primitives support too.
More on WPF, visit this:
http://msdn.microsoft.com/en-us/library/ms754130.aspx