This example shows how to customize the 3D view of RoboDK using RoboDK OpenGL shaders (method 1).
There are 2 ways of drawing OpenGL with RoboDK:
-
If you are using the default version of RoboDK (C:/RoboDK/bin/RoboDK.exe) you can directly use RoboDK shaders. To draw primitives such as Triangles, Lines or points you should call RDK->DrawGeometry.
-
If you prefer using Desktop OpenGL (fixed pipeline without shaders), you should use the GL2 compatible binary: C:/RoboDK/bin/RoboDK-GL2.exe. This binary allows you to use OpenGL functions like PushMatrix(), MulMatrix(), PopMatrix(), GLBegin(), GLEnd(), etc. The example PluginOpenGL shows how to draw OpenGL commands using OpenGL's fixed pipeline.
Important: Make sure you select Tools-Options-Set default settings when you switch from RoboDK-GL2.exe and RoboDK.exe binaries.
-
PluginEvent with event type DrawGeometry is triggered when we need to redraw the 3D view: pPlugin->PluginEvent. This function is called with the OpenGL context active.
-
Use RDK->DrawGeometry to display primitives such as triangles, lines or points when the context is active.
-
Use RDK->Render to schedule redrawing the OpenGL scene.
It is also possible to simulate cameras with custom shaders (creating a plugin is not required): https://robodk.com/blog/realistic-camera-simulation-shaders/
The following configuration is required in the PRO file to build with support for OpenGL:
- QT += opengl
- LIBS += opengl32.lib
You should enter the following information in the Projects-Run settings window:
- Executable: C:/RoboDK/bin/RoboDK.exe
- Arguments: -PLUGINSUNLOAD -PLUGINLOAD=%{CurrentProject:FileBaseName}
