Inertia's picture

Tutorials Wishlist

This is a gathering topic for recommendations/requests/contributions of OpenTK Tutorials that should be added. Please keep this sane (noone will port Quake III's source code for a tutorial) and be verbose what the tutorial should achieve, i.e. with that knowledge the reader should end up with after reading the source code.

There's no limit how small or big the tutorial should be, but some things need to be part of a larger tutorial (e.g. load a texture and draw a textured quad - makes little sense separated)

Also note that the tutorials on this list will not necessarily be finished tomorrow, it's more a list of feedback from users to get an idea what is missing and which areas require improvements. Posts like "I second [name]'s suggestion" are very welcome too, as this helps to set priorities! Thank you :)

Free your mind ...

Edit: this topic isn't much for discussion of the suggestion's details, so don't be confused if you get no reply. All suggestions will be read and considered.

Don't be afraid to add wishes that might sound trivial or stupid, the tutorials are supposed to help beginners get a good start with OpenTK and without you voicing the problems there cannot be done anything about this.


Comment viewing options

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

Running through a simple game with a tutorials for each part might be a big help.
Wouldn't have to be anything complicated. Something like a pong clone.
For example:
Tutorial 1: 3 coloured rectangles (2 bats, 1 ball) on the screen, no movement, just general "set up and draw" tutorial.
Tutorial 2: Input example, one bat controlled by keyboard, one by mouse. Have the ball moving as well, so basic collision detection.
Tutorial 3: Add textures.
Tutorial 4: Add scores (text/font tutorial).
Tutorial 5: Add sounds for the ball bouncing, maybe losing and possibly music to demonstrate both WAV and OGG loading.

Possibly it could move 3D and maybe move closer to an "air hockey" table at some point.

For VBOs a possible particle generation example might work.

That's a start anyway. I understand that would be a lot of work, but I think the basic idea of adding bits to a simple game is sound.

objarni's picture

I think the build-a-simple-game idea is great!

3d-pong is also a good idea. Or missile attack (cannon protects city from falling bombs/missiles).

I think it is a good idea to keep such a tutorial to the GameWindow style of OpenTK usage, since it is simpler to use than GLControl IMHO.

Basically, to build such a game, you would need the following "mini tutorials":

1. How to initialize / shutdown a GameWindow in OpenTK
2. How to read keyboard input
3. How to read mouse input
4. How to clear screen / swap buffers / draw colored triangles
5. How to generate sound samples and play them

Notice no files apart from OpenTK.dll is needed by any of 1-5. This is good since it saves the beginner lots of hassle.

After the "mini tutorials" have been read through, you might be ready for "3d pong":

6. Building 3d pong

After that, more intricate topics like texturing, WAVs, ogg, performance etcetera things might be added. I think 1-6 will get very many started with OpenTK development!

I don't think physics/modelling/collision detection/design patterns/performance should be adressed by the "basic game tutorial". That's why Pong is the best bet since it is so simple nothing fancy need to be done.

objarni's picture

Here is my previous wish list:

1) Simple VBO usage (two-three triangles are perfect; more and it becomes unecessarily complex)
2) Loading WAV / other supported formats (don't know which are supported)
3) Loading and displaying an image over the screen
4) Displaying Hello World and responding to any key (exits)
5) Using Mouse (moving triangle or something)
6) Going into / out of Fullscreen

Stevo14's picture


As far as I know, number 2 will be really easy. Something like this:

uint bufferID;
uint sourceID;
AL.GenBuffers(out bufferID);
AL.GenSources(out sourceID);
WaveSound FooSound = new WaveSound("Foo.wav");
AL.BindBufferToSource(sourceID, bufferID);

A total of 8 lines of code (including declarations).

objarni's picture

Inertia: how likely are Stevo14's example of being OpenTK's official way of playing a .WAV? The reason I'm asking, is because I might spend some time trying/putting this example up among the tutorials of then.. (or Steve14 maybe you want to do it?)

Inertia's picture

It's really that simple - his code will compile and play a sound. (assuming a valid ALContext, speakers turned on etc.)

You could change AL.BindBufferToSource into
AL.Source( sourceID, ALSourcei.Buffer, (int)bufferID );
(which is done by the AL.Bind helper internally)

AL.Delete* should be called for cleanup of the reserved handles before exiting and there's no error-checking, but that's it.

PlayStatic.cs demonstrates exactly this functionality, why write another example? I'll edit accordingly to work with AudioContext and WaveSound, once 0.9.1 is there.

Edit: Since I've already broken my plan not to comment in this topic, might aswell mention that an "OpenTK sample game" is in the works. It will come with full source code, and a couple of book pages giving insight into the 'making of'. There is not only 1 single way to make a game, so it's kinda impossible trying to make it a step-by-step tutorial. The book pages will be more about considerations and choices made rather than trying to explain how to draw a textured quad. It will be a little more complex than pong, in order to deal with performance considerations aswell (after all, OpenTK is built around OpenGL)

objarni's picture

Great news about the sample game!

I prefer online samples / documentation of things, that's why I'm asking for it. IntelliSense (what you've sometimes referred to as 'docu') is great for details / reminders while coding. Example programs are great for demonstrations and testing the library on different platforms.

I thought the topic of this thread was "Tutorials Wishlist"?

Inertia's picture

Well it has been a week, and very few requests for tutorials were posted. If anyone has troubles getting started, it's usually the best approach to search/post in the forum to check if anyone has encounter similar difficulties before.

I prefer a 50 lines source code over a 5 page abstract talk about the problem, so the Source/Examples directory helped me getting started with OpenTK way better than if Fiddler had written a dozen tutorials. Guess it depends if you have an academic or autodidact background.

The VBO tutorial is only so verbose, because the topic is neither covered in the red nor orange book, but it's a really important concept to understand for programming GL. VBO questions were frequently asked at the Tao forums, so it was a good candidate to start with.

The term "book" might be misleading in context with OpenTK, at least I do understand it to be more of a manual for things too complex to deal with through Intellisense (which is imho the best thing that could happen to programmers besides home-pizza-delivery ;) ). It was agreed even before the "book" was created, that we won't bother rephrasing or c&p anything from already available resources.

AstroMag's picture

Here is my wish list:

1) How to get computer Total Physical Memory and Free Physical Memory size in MONO/NET?
2) Geting microphone - output (OpenAL)

Mincus's picture

AstroMag: I don't think getting the memory requirements is within the scope of OpenTK.
However under Windows (not tested this under Mono) you can add the reference "Microsoft.VisualBasic" then use the class "Microsoft.VisualBasic.Devices.ComputerInfo" to get the Total/Free RAM amounts.