Reputation: 128
I am developing a cross-platform graphics application, which uses OpenTK. On Windows, I can reference OpenTK and OpenTK.GLControl dlls to initialize my rendering context like this, and in particular, request a specific [modern] OpenGL graphics context (in this case, OpenGL 3.3):
int major = 3;
int minor = 3;
var control = new OpenTK.GLControl(GraphicsMode.Default, major, minor, GraphicsContextFlags.Default);
There are some examples on the Xamarin website (Introduction to OpenTK and MonoMacGameView) and they demonstrate using OpenTK for Mac like this:
Game = new MonoMacGameView (ContentView.Frame);
ContentView = Game;
Game.Run();
However, when I do this, and then check the OpenGL version like this:
string version = GL.GetString(StringName.Version); // "2.1 INTEL-10.14.66"
string glsl = GL.GetString(StringName.ShadingLanguageVersion); // "1.20"
...I get what appears to be an obsolete context, and furthermore, I can't seem to specify that I want anything else. My system (OS X 10.11.5, Mac mini (Late 2014) Intel Iris) should be able to support OpenGL 4.1, according to this: https://support.apple.com/en-us/HT202823
Of greater concern, the Xamarin OpenTK examples use Immediate Mode (e.g. GL.Begin), which has long since been removed from the OpenGL core profile specification. So, my questions are:
Any help is greatly appreciated. Thanks.
Upvotes: 0
Views: 1009
Reputation: 8356
You need to ask for a forward compatible profile, replace GraphicsContextFlags.Default
with GraphicsContextFlags.ForwardCompatible
.
I'm using OpenGL 3.3 with OpenTK on Mac by inheriting from GameWindow
class and initializing the context in the constructor like this:
using OpenTK;
using OpenTK.Graphics;
class Program : GameWindow
{
public Program() :
base( width, height, GraphicsMode.Default, "App Name", 0, DisplayDevice.Default, 3, 3, GraphicsContextFlags.ForwardCompatible )
{
...
I use Xamarin Studio and downloaded OpenTK from its website, didn't use NuGet.
Upvotes: 2