Archived issue #0030429

Samples - add simple glfw 3D Viewer sample

CommunityOCCT:Samplesclosed34 public notes

Search issues

Description

a sample based on GLFW for demonstrating usage of OCCT 3D Viewer

Public activity

34 archived notes

Participants are labeled by their role within this record.

01Author
02Commenter 3
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Thu Jan 3 20:11:22 2019 +0800

    a simple cross-plotform demo for opencascade in glfw
03Author
Commenter 4 I had push a branch CRCR30429 with sample codes.
04Commenter 3
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Thu Jan 3 20:47:21 2019 +0800

    change readme

Author: Author
Date: Thu Jan 3 20:11:22 2019 +0800

    a simple cross-plotform demo for opencascade in glfw

05Commenter 5
If you would like to prepare a proper patch, please take a look onto Coding Rules and Bug Advancement Workflow:
https://dev.opencascade.org/doc/overview/html/occt_dev_guides__coding_rules.html
https://dev.opencascade.org/doc/overview/html/occt_dev_guides__contribution_workflow.html

In particular, indentation should be 2 spaces, figure brackets should be on new line, class members starting with "my", etc. (consider using autoformatting to fix indentation/spacing).

+++ b/samples/glfw/readme.md
@@ -0,0 +1,3 @@
+a simple demo for opencascade in glfw

This looks a little incomplete.

+static void error_callback(int error, const char* description)
+{
+       fprintf(stderr, "Error %d: %s\n", error, description);
+}

The preferred way is redirecting messages to Message::DefaultMessenger()->Send() with proper message gravity.

+       glewInit();

Could you please comment why GLEW is needed here?

+       Handle_V3d_Viewer m_viewer;
+       Handle_V3d_View m_view;
+       Handle_OpenGl_Context m_GLcontext;
+       Handle_AIS_InteractiveContext mContext;

Handle_ syntax is deprecated, Handle() is preferred.

+  void Destroy();
+  ~OccWindow()
+  {
+    Destroy();
+  }

Destroy() is an obsolete alias of class destructor from WOK (CDL class declaration) times.

+    /*** todo cleanup imgui ***/

TODOs related to imgui looks unrelated (as long as you are not going to add them).

+void GlfwOccView::s_onMouseButton(GLFWwindow* window, int button, int action, int mods)
+{
+       GlfwOccView* app = reinterpret_cast<GlfwOccView*>(glfwGetWindowUserPointer(window));
+       app->OnMouseButton(button, action, mods);
+}
+void GlfwOccView::s_onMouseMove(GLFWwindow* window, double xpos, double ypos)
+{
+       GlfwOccView* app = reinterpret_cast<GlfwOccView*>(glfwGetWindowUserPointer(window));
+       app->OnMouseMove(xpos, ypos);
+}

These proxy callbacks are probably will be better inlined within declaration to make code more compact.

+                       mContext->MoveTo((int)xpos,(int)ypos,m_view,Standard_True);
...
+void GlfwOccView::redraw()
+{

Looks like a misconception or at least confusing to have a special redraw() method and not implementing actual redraw with it...

+INCLUDE_DIRECTORIES(/usr/local/include/opencascade/)

Doesn't look correct (multi-platform / flexible).

06Commenter 3
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Sat Jan 5 01:34:44 2019 +0800

    Follow the Coding Rules

07Commenter 3
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Sun Jan 6 14:18:23 2019 +0800

    let codes be more clean

08Author
Commenter 4, thanks your comments, I had modified my codes according to your comments.
09Author
Commenter 4, should I add more function or just keep on making code clean?
10Commenter 3
Branch [archived branch] has been created by Commenter 5.

[revision removed]


Detailed log of new commits:

Author: Commenter 5
Date: Fri Jan 18 11:00:30 2019 +0300

    0030429: Samples - add simple glfw 3D Viewer sample
11Commenter 3
Branch [archived branch] has been updated forcibly by Commenter 5.

[revision removed]
12Commenter 3
Branch [archived branch] has been created by Commenter 5.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Fri Jan 18 11:00:30 2019 +0300

    0030429: Samples - add simple glfw 3D Viewer sample
13Commenter 3
Branch [archived branch] has been updated forcibly by Commenter 5.

[revision removed]
14Commenter 3
Branch [archived branch] has been updated forcibly by Commenter 5.

[revision removed]
15Commenter 3
Branch [archived branch] has been updated forcibly by Commenter 5.

[revision removed]
16Commenter 3
Branch [archived branch] has been updated by Commenter 5.

[revision removed]


Detailed log of new commits:

Author: Commenter 5
Date: Fri Jan 18 19:03:35 2019 +0300

    Aspect_DisplayConnection - provide constructor wrapping existing X Display connection.

17Commenter 3
Branch [archived branch] has been updated by Commenter 5.

[revision removed]


Detailed log of new commits:

Author: Commenter 5
Date: Fri Jan 18 21:48:22 2019 +0300

    # fix macOS compilation

18Commenter 3
Branch [archived branch] has been updated by Commenter 5.

[revision removed]


Detailed log of new commits:

Author: Commenter 5
Date: Fri Jan 18 22:12:37 2019 +0300

    # corrections

19Commenter 3
Branch [archived branch] has been created by Commenter 5.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Fri Jan 18 11:00:30 2019 +0300

    0030429: Samples - add simple glfw 3D Viewer sample
    
    Aspect_DisplayConnection now provides constructor wrapping existing X Display connection.
20Commenter 3
Branch [archived branch] has been updated forcibly by Commenter 5.

[revision removed]
21Commenter 5
The sample has been updated and pushed to branch CR30429_3:
- GLEW dependency has been removed as redundant.
- CMakeLists now uses find_package() for searching OCCT instead of CASROOT.
- The issue with glXSwapBuffers() has been fixed by adding Aspect_DisplayConnection constructor wrapping existing X Display connection.
- Prefer using glfwWaitEvents() instead of glfwPollEvents().
- Code clean up / simplification.

X Error of failed request:  GLXBadContextTag
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  11 (X_GLXSwapBuffers)
  Serial number of failed request:  36
  Current serial number in output stream:  504


Please comment, if you have some objections / questions to changes.

>    glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 3);
>    glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 3);
>    glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
>    glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

Requesting a Forward-Compatible OpenGL profile 3.3 looks like a copy-paste from some another GLFW sample, since it might not the best OpenGL configuration.
Forward-compatible bit is rarely used, and limiting to 3.3 would disable some OCCT features requiring OpenGL 4.x.

22Commenter 3
Branch [archived branch] has been updated forcibly by Commenter 5.

[revision removed]
23Commenter 3
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Sat Jan 19 19:21:09 2019 +0800

    about apple

24Author
Commenter 4 , your codes are amazing!!!

The only thing I can explain about is "glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);"
I add this line because of this reason: https://github.com/glfw/glfw/issues/832 .
I had tested on my Apple computer.

I am so happy having this chance to work on this small demo project.
And I also hope I can have another chance to keep working on Opencascade project.

Thanks again.
25Commenter 5
26Commenter 1
Combination -
OCCT branch : [archived branch] SHA - [revision removed]
Products branch : [archived branch] SHA - [revision removed]
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 16355.260000000095 / 16360.560000000005 [-0.03%]
Products
Total CPU difference: 7172.680000000021 / 7164.9300000000385 [+0.11%]
Windows-64-VC14:
OCCT
Total CPU difference: 17885.171875 / 17757.890625 [+0.72%]
Products
Total CPU difference: 8602.09375 / 8601.296875 [+0.01%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
27Commenter 3
Branch [archived branch] has been updated by Commenter 5.

[revision removed]


Detailed log of new commits:

Author: Commenter 5
Date: Tue Jan 22 15:20:50 2019 +0300

    # compatibility with old gcc

28Commenter 3
Branch [archived branch] has been created by Commenter 5.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Fri Jan 18 11:00:30 2019 +0300

    0030429: Samples - add simple glfw 3D Viewer sample
    
    Aspect_DisplayConnection now provides constructor wrapping existing X Display connection.
29Commenter 3
Branch [archived branch] has been deleted by Participant.

[revision removed]
30Commenter 3
Branch [archived branch] has been deleted by Participant.

[revision removed]
31Commenter 3
Branch [archived branch] has been deleted by Participant.

[revision removed]
32Commenter 3
Branch [archived branch] has been deleted by Participant.

[revision removed]
33Commenter 3
Branch [archived branch] has been deleted by Participant.

[revision removed]
34Author
nice :)

Related records