Jump to content
  • Advertisement
Sign in to follow this  
Moeller

[.net] Mono and OpenGL on Windows

This topic is 4604 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I try to create an OpenGL device context on a System.Windows.Forms form. As OpenGL binding I use Tao (http://www.mono-project.com/Tao). Creating the OpenGL device context on the form works very well with Microsoft.NET, a simple sample application doing it is Tao/examples/NeHe/Lesson03 (comming with the Tao framework). This application compiles fine and runs without problems on .NET. When I try to run the same sample (binaries) on Mono, I get a runtime error in Mono (!). I dont really know where the problem is, here is what I have been looking at so far: The source line of the Lesson03 sample where the runtime error occurs is (or at least Lesson03 runs fine till this line)
hDC = User.GetDC(form.Handle);     // Attempt To Get A Device Context

(http://svn.myrealbox.com/viewcvs/trunk/tao/examples/NeHe/Lesson03/Lesson03.cs?rev=44968&view=auto) The runtime error I get from Mono is
** ERROR **: file loader.c: line 1408 (mono_method_signature_full): should not be reached aborting ...
if I am right, the corresponding location in the Mono source is here
mono_method_signature_full (MonoMethod *m, MonoGenericContext *context)
{
	int idx;
	int size;
	MonoImage* img;
	const char *sig;
	
	if (m->signature)
		return m->signature;
		
	mono_loader_lock ();
	
	if (m->signature) {
		mono_loader_unlock ();
		return m->signature;
	}
	
	g_assert (mono_metadata_token_table (m->token) == MONO_TABLE_METHOD);
	idx = mono_metadata_token_index (m->token);
	img = m->klass->image;
	
	sig = mono_metadata_blob_heap (img, mono_metadata_decode_row_col (&img->tables [MONO_TABLE_METHOD], idx - 1, MONO_METHOD_SIGNATURE));
	size = mono_metadata_decode_blob_size (sig, &sig);
	
	m->signature = mono_metadata_parse_method_signature_full (img, context, idx, sig, NULL);
	
	if (m->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL)
		m->signature->pinvoke = 1;
	else if ((m->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) && (!(m->iflags & METHOD_IMPL_ATTRIBUTE_NATIVE))) {
		MonoCallConvention conv = 0;
		MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *)m;
		m->signature->pinvoke = 1;
		
		switch (piinfo->piflags & PINVOKE_ATTRIBUTE_CALL_CONV_MASK) {
		case PINVOKE_ATTRIBUTE_CALL_CONV_WINAPI:
			conv = MONO_CALL_DEFAULT;
			break;
		case PINVOKE_ATTRIBUTE_CALL_CONV_CDECL:
			conv = MONO_CALL_C;
			break;
		case PINVOKE_ATTRIBUTE_CALL_CONV_STDCALL:
			conv = MONO_CALL_STDCALL;
			break;
		case PINVOKE_ATTRIBUTE_CALL_CONV_THISCALL:
			conv = MONO_CALL_THISCALL;
			break;
		case PINVOKE_ATTRIBUTE_CALL_CONV_FASTCALL:
			conv = MONO_CALL_FASTCALL;
			break;
		case PINVOKE_ATTRIBUTE_CALL_CONV_GENERIC:
		case PINVOKE_ATTRIBUTE_CALL_CONV_GENERICINST:
		default:
			g_warning ("unsupported calling convention");
			g_assert_not_reached ();
		}	
		m->signature->call_convention = conv;
	}
	
	mono_loader_unlock ();
	return m->signature;
}



(http://svn.myrealbox.com/viewcvs/trunk/mono/mono/metadata/loader.c?rev=47177&view=auto) The funtion GetDC from user32.dll is binded with the following source in Tao
private const CallingConvention CALLING_CONVENTION = CallingConvention.StdCall;

...

[DllImport(USER_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION, SetLastError=true), SuppressUnmanagedCodeSecurity]
        public static extern IntPtr GetDC(IntPtr windowHandle);



(http://svn.myrealbox.com/viewcvs/trunk/tao/src/Tao.Platform.Windows/User.cs?rev=45584&view=auto) I don't really see what I am doing wrong. Some other samples comming with the Tao framework run on both, Mono and .Net, without problems. But those samples use FreeGlut to create the window, and I need a bit more GUI then just a simple bordered window. Any help is very much appreciated. Thx.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!