[英]Can I use OpenGL in more than one language at the same time?
I have an OpenGL program in C#, but I also want to execute OpenGL functions from a C++ DLL. 我在C#中有一个OpenGL程序,但我也想从C ++ DLL执行OpenGL函数。 Will the changes made by my C++ library take effect on the C# program?
我的C ++库所做的更改会在C#程序上生效吗?
Edit: To be more clear, I want to share the same context of OpenGL for two languages. 编辑:更清楚地说,我想为两种语言共享OpenGL的相同上下文。
I am PInvoking functions of C++ that uses OpenGL from my C# code. 我正在从C#代码中调用使用OpenGL的C ++函数。
Current OpenGL context is a thread-local global state. 当前的OpenGL上下文是线程局部的全局状态。
What this means is that as long as the C++ and C# code are executing in the same thread, then OpenGL commands issued in either will be compatible. 这意味着,只要C ++和C#代码在同一线程中执行,则在任一线程中发出的OpenGL命令都是兼容的。
However, if you are dealing with multiple/different threads, you will need to activate the OpenGL context in C++ (assuming it was created in C#), using wglMakeCurrent()
. 但是,如果要处理多个/不同的线程,则需要使用
wglMakeCurrent()
在C ++中激活OpenGL上下文(假设它是在C#中创建的wglMakeCurrent()
。 In order to do this, you'll have to propagate the proper handles somehow. 为此,您必须以某种方式传播适当的句柄。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.