Archived issue #0030429
Samples - add simple glfw 3D Viewer sample
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.
almost finished, try to push codes https://www.opencascade.com/content/it-possible-initialize-v3dview-glfw%EF%BC%88-lightweight-utility-library-use-opengl%EF%BC%89
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
[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
Commenter 4 I had push a branch CRCR30429 with sample codes.
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
[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
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).
This looks a little incomplete.
The preferred way is redirecting messages to Message::DefaultMessenger()->Send() with proper message gravity.
Could you please comment why GLEW is needed here?
Handle_ syntax is deprecated, Handle() is preferred.
Destroy() is an obsolete alias of class destructor from WOK (CDL class declaration) times.
TODOs related to imgui looks unrelated (as long as you are not going to add them).
These proxy callbacks are probably will be better inlined within declaration to make code more compact.
Looks like a misconception or at least confusing to have a special redraw() method and not implementing actual redraw with it...
Doesn't look correct (multi-platform / flexible).
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).
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
[revision removed]
Detailed log of new commits:
Author: Author
Date: Sat Jan 5 01:34:44 2019 +0800
Follow the Coding Rules
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
[revision removed]
Detailed log of new commits:
Author: Author
Date: Sun Jan 6 14:18:23 2019 +0800
let codes be more clean
Commenter 4, thanks your comments, I had modified my codes according to your comments.
Commenter 4, should I add more function or just keep on making code clean?
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
[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
Branch [archived branch] has been updated forcibly by Commenter 5.
[revision removed]
[revision removed]
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
[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
Branch [archived branch] has been updated forcibly by Commenter 5.
[revision removed]
[revision removed]
Branch [archived branch] has been updated forcibly by Commenter 5.
[revision removed]
[revision removed]
Branch [archived branch] has been updated forcibly by Commenter 5.
[revision removed]
[revision removed]
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.
[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.
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
[revision removed]
Detailed log of new commits:
Author: Commenter 5
Date: Fri Jan 18 21:48:22 2019 +0300
# fix macOS compilation
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
[revision removed]
Detailed log of new commits:
Author: Commenter 5
Date: Fri Jan 18 22:12:37 2019 +0300
# corrections
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.
[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.
Branch [archived branch] has been updated forcibly by Commenter 5.
[revision removed]
[revision removed]
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.
Please comment, if you have some objections / questions to changes.
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.
- 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.
Branch [archived branch] has been updated forcibly by Commenter 5.
[revision removed]
[revision removed]
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
[revision removed]
Detailed log of new commits:
Author: Author
Date: Sat Jan 19 19:21:09 2019 +0800
about apple
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.
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.
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
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
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
[revision removed]
Detailed log of new commits:
Author: Commenter 5
Date: Tue Jan 22 15:20:50 2019 +0300
# compatibility with old gcc
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.
[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.
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
nice :)
Related records