PIXELFORMATDESCRIPTOR in OpenGlContext creation

I'm trying to get a light weight version of Open Cascade working in a GLFW window, however I'm having an error 'pixel format is invalid'.

I've followed this suggestion to create a PixelFormatDescriptor as done here https://stackoverflow.com/questions/50014602/wglcreatecontext-fails-with-error-the-pixel-format-is-invalid . However this involves creating a new OpenGL Context through windows wglCreateContext(), rather than use the OpenGl library in OpenCascade, using OpenGl_Context myContext = new OpenGl_Context().

For windows I'm sure I need to set the pixel format, but I'm unsure if I can create a context with these specifications through Open Cascade.
Source code is here. https://github.com/AliHasl/GLFW_OccT

Thanks

Attachments: 
Kirill Gavrilov's picture

Have you already tried glfw sample coming with OCCT 7.4.0?

U1773783_151328's picture

No I have not. I was unaware that there was a glfw sample with 7.4.0, I thought there was only MFC, QT and the tcl Draw program. I am using the OpenSource core that I built. Is it a recent addition? Sorry for the n00bish question.

Also I have managed to somewhat fix the issue with the Aspect_NeutralWindow::SetNativeHandle(HDC) as the device context, but it seems to be the setting the view HandleV3d_View::SetWindow(Handle<Aspect_Window>, Aspect_RenderingContext) that throws an exception.

Thanks

Kirill Gavrilov's picture

> I am using the OpenSource core that I built.
There is no "ClosedSource" version that I'm aware of.
The last release is available here:
https://www.opencascade.com/content/latest-release

The sample source code is located within samples/glfw folder.

U1773783_151328's picture

To further specify the exception is an Aspect_GraphicDeviceDefinitionError which occurs straight after the call to ::SetWindow(). This happens when I leave the second argument as default (which should get the current context), but also if I try to specify the Aspect_RenderingContext (typedef of a pointer) to point to a GLContext or window I get a null pointer exception (failed to find 0x00000).

I'll have a look at the glfw sample.

Thanks

U1773783_151328's picture

Just installed the newest release of OpenCascade 7.4.0 using the windows installer, and there is no GLFW folder. Could it have been removed from an earlier version or not in the current release yet? I built a version with CMake and that was the same.
Thanks

U1773783_151328's picture

Got the sample GLFW built and running. I went to the source repository and picked out the sample project. It is not included in a full install of OccT for windows, and is not an option as far as I can tell in CMake. Possibly it is missed out?

Either way thank you for your help, I'm sure I can work out my problem now that I have this up and running.

Kirill Gavrilov's picture

Yeah, this is a new Sample, so that it has been probably missed by installation package creation routines.