Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting System.Windows.Forms control context #118

Open
katz1 opened this issue Oct 16, 2018 · 4 comments
Open

Setting System.Windows.Forms control context #118

katz1 opened this issue Oct 16, 2018 · 4 comments

Comments

@katz1
Copy link

katz1 commented Oct 16, 2018

Hi!

I am trying to create an OpenGL.GlControl in a WPF window with a 3.3 core OpenGL context, using OpenGL.NET 0.7.1 from NuGet. The wiki here suggests to use the ContextVersion property of the control.

If I try to enter anything to the ContextVersion property via the Properties tab of MSVC 2015, my xaml will be turned to something like this:

<WindowsFormsHost Grid.Column="0" Margin="20">
	<opengl:GlControl ContextCreated="GlControl_ContextCreated" Render="GlControl_Render" >
		<opengl:GlControl.ContextVersion>
			<Khronos:KhronosVersion VersionId="0"/>
		</opengl:GlControl.ContextVersion>
	</opengl:GlControl>
</WindowsFormsHost>

Which gives a compile error:
error MC3065: 'VersionId' property is read-only and cannot be set from markup.

I also tried adding the ContextVersion manually to the xaml like this:

<WindowsFormsHost Grid.Column="0" Margin="20">
	<opengl:GlControl ContextCreated="GlControl_ContextCreated" Render="GlControl_Render" ContextVersion="3.3" />
</WindowsFormsHost>

This does compile, but I don't think I end up with a core context, because I can still draw the example triangle with the fixed function pipeline in the GlControl_Render event handler. The control's ContextProfile property is on the default Core.

Here are a few things I log from the GlControl_ContextCreated event handler:

Gl.CurrentRenderer: GeForce GT 630/PCIe/SSE2
Gl.CurrentVersion: Version=4.6 API=gl
Gl.CurrentShadingVersion: Version=4.60 API=glsl
DeviceContext.CurrentAPI: gl
DeviceContext.Version: Version=1.0 API=wgl
DeviceContext.IsPixelFormatSet: True

@luca-piccioni
Copy link
Owner

luca-piccioni commented Oct 16, 2018

The control's ContextProfile property is on the default Core.

The default value for ContextProfile is Compatibility (source reference)

I think changing it to Core will solve the issue you're facing.

@katz1
Copy link
Author

katz1 commented Oct 17, 2018

Thanks for the quick response.
My properties tab does claim that Core is the default, it looks like this:

openglnet-properties

I did try setting the ContextProfile manually like this:

<WindowsFormsHost Grid.Column="0" Margin="20">
	<opengl:GlControl ContextCreated="GlControl_ContextCreated" Render="GlControl_Render" ContextProfile="Core" ContextVersion="3.3" />
</WindowsFormsHost>

But the same thing happens, I can use the functions from the triangle example which should not be available in a 3.3 core context.

By the way I installed the following packages in NuGet:
OpenGL.Net
OpenGL.Net.CoreProfile
OpenGL.Net.WinForms

@katz1
Copy link
Author

katz1 commented Oct 17, 2018

I also tried making the control from code behind instead of xaml, but I experience the same issue:

var conv = new Khronos.KhronosVersionConverter();
var version = (Khronos.KhronosVersion)conv.ConvertFromString("3.3");
var glControl = new GlControl { ContextProfile = GlControl.ProfileType.Core, ContextVersion = version };

@luca-piccioni
Copy link
Owner

That Debug and Robust properties set to Required smell... They are different from the default values, and could make fail context creation due missing extensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants