I've struggled a lot with myself over whether I should use OpenGL or Direct3D. There is no blanket answer to this question that anyone can tell you. Both APIs have a very different feel and which one you prefer can only be decided on your own.
Read MoreI just released GLDotNet Version 0.6.0.
Changelog:
- **GLDotNet.Toolkit**: Assembly containing simple app framework.
- **GLDotNet.Objects**: Assembly containing higher level objects such as Texture2D and VertexBuffer.
- More overloads added to GLContext class.
- byte and sbyte are now mapped correctly in generated code.
- Fixed the naming of some functions so as not to include type notation, i.e. Color4u.
- Decreased the number of enum values output.
Today I released a project I've been playing around with for a year or so on Codeplex. It's called GLDotNet. From the project description:
C# wrapper for OpenGL. Partially generated from the OpenGL spec and partially written by hand, the aim is to have a flexible and native feeling C# binding.
I have generated functions from the OpenGL spec excluding 1 or 2 but unfortunately of the generated code is untested. There is a demo project included in the source code. The Github repository is located here: https://github.com/smack0007/GLDotNet
I started experimenting with OpenTK and I had to look in a few places to put this code together, so I'm posting it here for anyone who might be looking for an easy getting started lesson.
I've set up a window similar to what I've been used to in Xna (CornflowerBlue 4 life). I've also set up a 2D projection matrix and drawn a triangle in a 2D fashion. You'll need to add a reference to the OpenTK assembly for your project in Visual Studio.
using System;
using System.Drawing;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
namespace OpenTKApp1
{
public class AppWindow : GameWindow
{
public AppWindow()
{
this.Title = "OpenTK App 1";
this.WindowBorder = WindowBorder.Fixed;
this.ClientSize = new Size(800, 600);
}
protected override void OnRenderFrame(FrameEventArgs e)
{
base.OnRenderFrame(e);
GL.ClearColor(Color.CornflowerBlue);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(0, 800, 600, 0, -1, 1);
GL.Viewport(0, 0, 800, 600);
GL.Begin(BeginMode.Triangles);
GL.Color3(Color.Red);
GL.Vertex3(400, 150, 0);
GL.Color3(Color.Green);
GL.Vertex3(600, 450, 0);
GL.Color3(Color.Blue);
GL.Vertex3(200, 450, 0);
GL.End();
GL.Flush();
this.SwapBuffers();
}
[STAThread]
public static void Main()
{
AppWindow window = new AppWindow();
window.Run();
}
}
}
I wrote my second OpenTK app. This time I'm drawing a sprite which you can move around the screen using the keyboard. I've included the source code after the jump or you can download it.
Read More