objarni's picture

OpenTK in ubuntu

Hello, this is my first post, hope I haven't missed the answer to this under the FAQ or somewhere else.

I must say I think this project is really needed and you seem to have gotten quite far judging by the example programs, which I got running in Vista last night. I prefer C# as a programming language, but have a C++/SDL/OpenGL background so OpenTK fits my needs just wonderfully so far.

Is there any getting-started or HowTo's available for the different environments? How do I start developing Ubuntu games using OpenTK? What package manager should I use to download OpenTK, or should I not use any package manager and go for direct-download? Is it possible to run OpenTK-programs in VirtualBox for easier development (eg. running a ubuntu guest under winxp host)? That kind of thing ... I know this stuff for windows but it is a little shady in a Linux environment. Any pointers? Thanks,


Comments

Comment viewing options

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

Hello and welcome! :)

There is no getting-started guide yet - I am going to add the necessary instructions and sample projects in the next release (next week). No package distribution either, as system-wide installation is not possible yet. For now, it is best to download a prebuilt version and untar it somewhere in your home folder (system-wide installation will come with the first beta version). Ubuntu comes with the Mono runtime pre-installed, so running "mono Examples.exe" will work.

To develop programs with OpenTK, you will have to install the latest version of the gmcs compiler ("sudo apt-get install mono-gmcs" should do the trick for Ubuntu), and if you prefer working with an IDE, "sudo apt-get install monodevelop". Once installed, fire up an instance of MonoDevelop and:

  1. Start a new project (select empty project in the next screen, and leave packaging options to 'off').
  2. You'll need a reference to OpenTK.dll: Expand the solution in the left pane and right click on "References->Edit References". Click the "Assemblies" tab, and add OpenTK.dll.
  3. Before running a project, you'll need to copy the OpenTK.dll.config file to the output directory. Right click the project and select "Add Files" and find OpenTK.dll.config. Select copy file (not link or move), then right click on the imported file and select "Include->Deployment" - we want it to be copied to the output directory, but not get built (it's not a code file).
  4. Finally, in the Solution Options navigate to "Runtime Options" and change the default from 1.1 to 2.0.

At this point you can add a new code file and start coding. The following code will create an empty OpenGL window:

using System;
using OpenTK;
using OpenTK.OpenGL;
 
namespace Quickstart
{
	public class Start : GameWindow
	{
		public Start() : base(new DisplayMode(800, 600))
		{ }
 
		public override void OnRenderFrame (RenderFrameEventArgs e)
		{
			GL.Clear(ClearBufferMask.COLOR_BUFFER_BIT);
			SwapBuffers();
		}
 
		public static void Main()
		{
			using (Start start = new Start())
			{
				start.Run(30.0, 0.0); // 30 updates/sec, unlimited fps.
			}
		}
	}
}

All this is a little hairy, I know. Next release will come with ready-to-use projects :)

Edit: Forgot to mention that it is possible to code under a virtual machine. Moreover, an exe built on Windows will run on Linux and vice versa, no recompilation needed (just don't forget the OpenTK.dll.config file!)

objarni's picture

Great! Will try tonight.

This would not have been possible a year ago! Keep up the good work :)