arawnblack's picture

Existing OpenGL program

Alright, I'm a serious nuub, so please tolerate a few stupid questions.

I have a program that currently uses OpenGL. I can get every other part of the program to run in mono, until I try an d enable the part that uses OpenGL and I crash to command line with the "Unhandled Exception: System.EntryPointNotFoundException: GetDC" error.

My question is:

Is there anyway to get my program to use these (OpenTK) binaries to utilize the existing OpenGL code? I'm running Ubuntu 8.04 with mono 1.2.6 (from repos).

The program I use, I compile in windows and then transport the entire directory structure to linux and run the main execute in mono. I can see all the existing OpenGL dlls and I just need to know if I have to rewrite the code to point to the new dlls or if I can 'insert' the OpenTK dlls somehow into the mono libraries. *shrug* I'm too much of a newbie to even know if this is a stupid question so let me know please :-)

A. Black


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Unhandled Exception: System.EntryPointNotFoundException: GetDC
Ouch, this means platform detection in OpenTK is messed up pretty badly - it is trying to use Windows-specific (GetDC) code on Linux. Can you please check the what OpenTK.Configuration.RunningOnWindows and RunningOnLinux return on each platform?

You're probably not doing anything wrong (OpenTK supports using Windows binaries on Linux or vice versa - in fact I do this quite often when developing).

arawnblack's picture

Well first off let me make sure I'm clear. The example.exe works just fine.

I will post those two requests of yours after I get back into the office.

I got the OpenTK source to compile on ubuntu, and deposited those dlls and config files into the program directory I copied from windows. That is what returns the GetDC error, which is the same error I get if I just use mono without OpenTK.

I really suspect that it failed to compile on my system correctly, or I'm not utilizing the dlls that are produced from the compile correctly, though as I said the example.exe works just fine. The program I am using was coded in with OpenGL alone; I've searched through the forums and documentation and I believe all I need to do is drop the binaries in the execution directory and run mono. Do I need to add them to my mono libraries somewhere or is it as you say and its about platform detection?

I understand that GetDC error is a winapi thing and thus means its trying to execute (Device Call?) which is not supported in linux, I guess I just want to know first if I installed the thing correctly :-)

As I said I will check OpenTK.Configuration.RunningOnWindows and RunningOnLinux return either later tonight or first thing tomorrow.

Feel free to post specific questions, and don't assume I know what I'm talking about heh, Thanks for your time and attention btw

A. Black

objarni's picture

The program I am using was coded in with OpenGL alone;

What exactly do you mean by this..? What is "OpenGL alone" in C#/mono? As far as I know, neither mono nor .NET includes the OpenGL API..

arawnblack's picture

The program was written in windows using OpenGL in C#, all of its calls currently point towards the Tao.OpenGL.dll and Tao.Platform.Windows.dll.

the Fiddler's picture

Ahem, Tao != OpenTK :)

This aside, it looks like you are trying to use Tao.Platform.Windows on Linux - and this just won't work (that's why the GetDC call fails).

You are using Windows.Forms, right? In that case, you can swap Tao.Platform.Windows.SimpleOpenGlControl (which is Windows-only) with OpenTK.GLControl (which is cross-platform). You'll need to make some minor alterations in your code (remove simpleOpenGlControl1.InitializeContexts() and search & replace all SimpleOpenGlControl references with GLControl), but most of the code will remain intact (i.e. you can keep using Tao.OpenGl).

Do backup just in case, though!

For the record, OpenTK is something like Tao.OpenGl, Tao.OpenAl, Tao.Platform.Windows and Tao.Platform.X11 combined, with some extra functionality (fonts, input and general utility functions). This is a simplification of course, as OpenTK bindings are closer to C# than Tao bindings, but both projects share code - which is why you can mix OpenTK.GLControl with Tao.OpenGl, for example.

arawnblack's picture

Ah that makes perfect sense, so if I swap out the code the program will still run natively in windows? I just have to download and reference the OpenTK dll in the code and it will compile correctly? (in theory anyway, I understand we are pre-version 1.0)

Excellent, I'll get working on that immediatly. Thank you for your help I will post results when I get that done.

arawnblack's picture

Is 'OpenGLWinFormsControl:Control ' supported under OpenTK?

arawnblack's picture

and (don't worry this is an open source program)

how should I deal with this one: Does OpenGLWinFormsControl work? or should that be replaced as you said to with the simple version?

public partial class GraphicalToothChartControl:CodeBase.OpenGLWinFormsControl{//.SimpleOpenGlControl

the Fiddler's picture

OpenGLWinFormsControl: sorry, but this is the first time I've heard of this!

What OpenTK.GLControl does, is allow you to create an OpenGL "window" inside a WinForms application. This is what SimpleOpenGLControl does and this is probably what OpenGLWinFormsControl does, too. In other words, OpenTK.GLControl *should* be able to replace that. Worth a try, anyway.

OrokuSaki's picture

I am also a noob....

I too would like to see Open Dental have OpenGL in linux. Right now its written using Visual Studio and it shows a tooth chart that is written using OpenGLWinFormsControl which in turn is doing SimpleOpenGLControl... Open Dental also does Scheduling, Insurance, etc, etc... but the only part that uses OpenGL is the tooth chart.

Its written by a Dentist who is also a programer... And its free, except for tech support.

OpenGLWinFormsControl.cs was written by someone named Michael something and it makes it easy to use SimpleOpenGLControl.... using Tao.Platform.Windows but there isnt an equivalent for Tao.Platform.X11 and SimpleOpenGLControl is outdated now....

The tooth chart looks for stuff like AutoFinish which is only in SimpleOpenGLControl.. And doesnt seem to be in OpenTK.GLControl...

The only way to fix this (and right now Open Dental is also using DirectX and OpenGL with Tao)... Is to rewrite Open Dental to stop using the SimpleOpenGLControl and use GLControl which none of us know how to do... because the tooth chart wants to call on OpenGLWinFormsControl for AutoFinish and GetDC and stuff like that...

It would be a LOT easier to have a OpenGLWinFormsControl that is compatible with X11...

Are we at least on the right track? The developer is just too busy revamping other parts of the software...

I DID get the latest version to work on Linux though... We were stuck on getting 6.8 too compile in Mono.
opendentalsoft.com/forum/viewtopic.php?f=2&t=3057

opendentalsoft.com/forum/viewtopic.php?f=2&t=2016&p=8360&hilit=tooth+chart+linux#p8360

And then.. would this work in OSX? Would we need X11 or could we use OpenTK.Platform.OSX?