For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

is it possible initialize v3d_view in GLFW(a lightweight utility library for use with OpenGL)?

haidong ma's picture
Forums: 

I checked the sample codes ,  it initialize view from MFC, IOS, QT. 
But no sample code for simple GLFW. 

The benefit​ from GLFW is that it is light and platform independent .

Kirill Gavrilov's picture

Thank you for your suggestion - if you would like to improve or extend OCCT with new samples, your patches are welcome!
https://dev.opencascade.org/index.php?q=home/get_involved

The main purpose of existing samples is providing new users some guideline for using OCCT in real applications,
so that user interface provided by toolkits like MFC/Qt/WinForms is the essential part of the sample.

At the same time, GLFW is nothing similar - it is a library for managing native windows holding an OpenGL context.
So that a sample based on GLFW can be helpful for demonstrating usage of OCCT 3D Viewer, but not other parts (without inventing a wheel).
It will be also not very helpful for embedding and managing OCCT 3D Viewer into GUI framework, because each framework has its own specifics.

haidong ma's picture

So it is possible to  manage OCCT 3D Viewer into  GLFW, right?
I will try for sure. But I am not sure I can figure it out. 

Kirill Gavrilov's picture

Indeed, Open CASCADE experts have experience embedding OCCT 3D Viewer with many frameworks, and so far I don't see a reason GLFW to be off this list.
Some combinations are much simpler, while others might require expertize in OpenGL.

Damiano Modolo's picture

Yes, is possible. Time ago I'd try occ + glfw + imgui for learning poupose. 

If you want i can share it. 

haidong ma's picture

Hi, Damiano
"occ + glfw + imgui " is exactly what I looking for !
I will really appreciate your sharing.

I tried QT as gui framework first, but  then  I thought QT is too heavy for me. This is where this question came from.

Thanks again.

 

Damiano Modolo's picture

Ok i upload a project. Now i have no time to create a real sample. I hope someone can help in this.

Is uncomment but is easy to understand.

Attachments: 
haidong ma's picture

thanks! 
 

haidong ma's picture

I figure something out :)

A very simple demo inspired by  Damiano Modolo 's code

crossplatform: win10 apple ubuntu 


		m_GLcontext = new OpenGl_Context();
#if defined (__APPLE__)
		if (m_GLcontext->Init((NSOpenGLContext*)glfwGetNSGLContext(window)))
			fprintf(stderr, "opengl_context init success\n");
		m_view = m_viewer->CreateView();
		Handle(OccWindow) hWnd = new OccWindow(window);
			fprintf(stderr, "cocoa_window init success\n");
		m_view->SetWindow(hWnd, (NSOpenGLContext*)glfwGetNSGLContext(window));
#elif defined (_WIN32)
	    if(m_GLcontext->Init(glfwGetWin32Window(window), GetDC(glfwGetWin32Window(window)), glfwGetWGLContext(window)))
			fprintf(stderr, "opengl_context init success\n");
		m_view = m_viewer->CreateView();
		Handle(OccWindow) hWnd = new OccWindow(window);
			fprintf(stderr, "wnt_window init success %d %d %d %d\n", 
				hWnd->myXLeft,hWnd->myXRight, hWnd->myYTop,hWnd->myYBottom);
		m_view->SetWindow(hWnd,glfwGetWGLContext(window));
#else 
        if(m_GLcontext->Init(glfwGetX11Window(window), glfwGetX11Display(), glfwGetGLXContext(window)))
			fprintf(stderr, "opengl_context init success\n");
		m_view = m_viewer->CreateView();
		Handle(OccWindow) hWnd = new OccWindow(window);
			fprintf(stderr, "x11_window init success %d %d %d %d\n", 
				hWnd->myXLeft,hWnd->myXRight, hWnd->myYTop,hWnd->myYBottom);
		m_view->SetWindow(hWnd,glfwGetGLXContext(window));
#endif

Attachments: