Contained in the Class
The figure object is mostly the interface from Renderer part to the GUI canvas thanks to the RendererProperties class.
Since all object keep a pointer on their parent figure, the figure is also used to keep some state variables. The most common are the strategies. These strategies were made with the graphic export. Because of lower capabilities of GL2PS compared to JOGL (for color interpolation for instance) it is sometimes needed to use different algorithms when using JOGL or GL2PS. The strategies are set to JOGL by default, but when exporting with GL2PS, it is only needed to switch them to their GL2PS counterparts and the rigth algorithms will apply.
For example the ShadeFacetDrawer startegy will be implemented using textures with the JOGLFacetDrawer or cutting polygons in small pieces using the GL2PSShadedFacetDrawer. The two others strategies are hidden in ArcRendererFactory (actually a factory for the right strategy, not really needed) which allows to switch between nurbs and polylines for arc drawing (nurbs are not supported in GL2PS) and TextRendererManager which allows to switch between text drawing for JOGL or GL2PS.
The boolean renderRequested indicates that the graphic hierarchy has been modified. This has an important role since it might not be necessary to repaint the whole figure when this boolean is not true.
This represent a lot of variable, probably too much. Checkstyle complains about the DAC of the class and it would be better to try to split up the class. Maybe create a DrawableFigureGL for real figure actions such as modifying canvas properties and a class containing the state variables.
The initializeDrawing of the figure is important since it's where the remaining objects holding OpenGL ressources will be freed. It's also where the depth buffer is cleared. However, the color buffer is not always cleared depending on the case.
The color buffer is normally cleared but is kept when only a set of objects is displayed (explicit draw of an object) in order to keep already displayed figure.
The useSingleBuffer emulate the use of a single OpenGL buffer if needed. This is needed for the use of rubberbox or when logical operator is on to be sure to work only on the same buffer (otherwise xor mode won't work). This must be used in combination with the swapBuffers methods which should be used instead the GLAutoDrawable one.
This is the only implementation of the GLEventListener used in Scilab. In the init method, most of the instruction are the set up of the default OpenGL state. However, we also clear some already used resources if needed. Also the use of the redrawFigure ensure that the whole figure will be redrawn using the draw methods.
In the reshape methods, some reshape actions might not really come from resize event and might be skipped. This is the case when the canvas is scrolled (if auto resize is not on).
In the display method, to gain speed unecessary draw is avoided. When rendering is not requested, no operations are actually performed and the previous buffer is kept. We may also notice the rubber box mode which actually kept the previous buffer and only draw the new one above.