سؤال

I just installed MonoGame and OpenTK 1.0 and in Visual Studio 2012 I made a new project of type 'Windows OpenGL Game`...but when I run the project I get the following error:

The type initializer for 'OpenTK.Graphics.GraphicsMode' threw an exception.

The error is right on this line (the consturctor, on the base())

public Game1()
    : base() 
{
    graphics = new GraphicsDeviceManager(this);
    Content.RootDirectory = "Content";
}

My laptop has intel oboard graphics 3000 and I think it supports OpenGL...thats the only thing I can would point to. Any ideas?

هل كانت مفيدة؟

المحلول

We can look at the source code and find where the exception went unhandled. The "type initializer" basically means the static constructor:

static GraphicsMode()
{
    lock (SyncRoot)
    {
        implementation = Platform.Factory.Default.CreateGraphicsMode();
    }
}

Unfortunately digging through CreateGraphicsMode doesn't reveal any single obvious source for an exception.

What you should do now is try to get a stack-trace for that exception, and find out where it originates from within CreateGraphicsMode. The debugger should give you this information when the exception goes unhandled.


With a small amount of digging, without seeing a stack trace (so I'm pretty much guessing), I came across this potential culprit:

throw new GraphicsModeException(
    "No GraphicsMode available. This should never happen, please report a bug at http://www.opentk.com");

Which, of course, is extremely unhelpful. Although, based on its location, it would seem to indicate that it cannot find a suitable graphics mode.

At this stage, I think it would be best to build MonoGame and OpenTK from source so that you can use the debugger to see exactly what they're doing.

نصائح أخرى

This issue was happening to my as well, and I do not believe it's MonoGame's source code issues.

A) You need to make sure openTK is insstalled, http://www.opentk.com/

B) Like craftworkgames said, your machine (laptop I'm assuming) doesn't support OpenGL. I had this issue on my Sufrace Pro, and had to update my Intel drivers to the latest (I used guru3d.com and www.guru3d.com/files_categories/videocards_intel_graphics_drivers.html at this time installed the 15.31 drivers) and then it started working.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top