(Submit loops are used in other contexts as well, such as when saving data to a file, computing a bounding box or sphere, or picking an object at a given location.)
The following example shows C++ code for rendering a scene. Variables such as mView, mObjects, and so on, are member variables defined elsewhere. Note that while the example shows the styles, background, shader, and objects as being separate, they could just as well be combined into a TQ3DisplayGroup and submitted at once.
if (Q3View_StartRendering( mView ) == kQ3Failure) return kQ3Failure;
do {
// submit styles (i.e., rendering preferences)
Q3InterpolationStyle_Submit( mInterpolationStyle, mView );
Q3BackfacingStyle_Submit( mBackfacingStyle, mView );
Q3FillStyle_Submit( mFillStyle, mView );
if (mUseFog) Q3FogStyle_Submit( &mFogStyleData, mView );
// submit things we want to appear with no shading, e.g. the background
Q3Object_Submit( mBackground, mView );
// submit shader
Q3Shader_Submit( mShader, mView );
// submit scene
Q3Object_Submit( mObjects, mView ) ;
// repeat rendering loop while we need to retraverse
} while (kQ3ViewStatusRetraverse == Q3View_EndRendering( mView ));
To transform local coordinates to the canonical viewing frustum, and then to window coordinates, renderers must register for updates to Quesa's transformation matrices. Renderers should register for matrix updates rather than querying the view's camera, as this will also allow them to automatically support the camera transform object.
Several methods are available, however the most common usage is to watch for changes to either:
kQ3XMethodTypeRendererUpdateMatrixLocalToFrustum
or:
kQ3XMethodTypeRendererUpdateMatrixLocalToCamera
kQ3XMethodTypeRendererUpdateMatrixCameraToFrustum
The second approach may be more useful if the underlying rendering API separates the transformation to camera space from the transformation which carries out the projection to the canonical frustum.
The orientation style determines which side of a polygonal surface is considered to be "front facing". Both clockwise and counter-clockwise orientations are available.
The default orientation style for a view is kQ3OrientationStyleCounterClockwise, indicating that the front facing side of polygons are those whose vertices are listed in counter-clockwise order.
When a renderer performs backface culling, it must obtain or calculate a normal for each triangle in the scene. If no normal is supplied for a triangle, the current orientation style will determine which direction the calculated normal will point in.
If you supply triangle normals for the objects in your scene, you must ensure that the orientation style at the time they are submitted matches the orientation that those triangle normals were calculated under.
For example, the correct normal for a counter-clockwise triangle can be found with Q3Point3D_CrossProductTri. This calculates the normal as the cross product of the vectors from vertex 1 to vertex 2 and from vertex 2 to vertex 3. Since the normal for a clockwise triangle points in the opposite direction, this vector should be negated if the triangle is to be submitted under a clockwise orientation style.
The orientation style affects the following geometries:
The orientation style has no effect on the following geometries:
Quesa follows the documented behaviour for QD3D, where the orientation style should only effect explicitly polygonal geometries. This is contrary to QD3D's behaviour in four cases:
Quesa follows the documented behaviour for these four geometries.