Abstract
In this chapter, we will see how we can write graphics programs that are more or less independent of the hardware that is used. If we want to adapt these programs to different kinds of computers, we only have to change a few lines in one of the include files and in the system-dependent module.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Even though the variable poly is a pointer, any change of poly is undone outside the function fill-poly(). We can only change *poly, i.e., the contents of the vector.
For the macros G_move_area() and G-draw_area(), it does not make any difference whether poly is a two-dimensional Vector2 or a three-dimensional Vector, because both types are interpreted as pointers to a float and only the first two elements of the array are taken.
Now we must not write *poly any more, because this would be a float, whereas the macro expects a Vector, i.e., a pointer to a float.
This requires at least 8-bit planes for single buffering and 16-bit planes for double buffering (page flipping).
This requires at least 8-bit planes for single buffering and 16-bit planes for double buffering (page nipping).
The C preprocessor will replace the constant MAX-PAL by the result of the division (MAX-COLORS-COLOR.OFFSET)/PALSIZEevery time it appears in the code. The constants PALSIZEand COLOR-OFFSET aie system-dependent and have to be defined in G_macros.h.
For less experienced C programmers: the operation ++ is done after vertex has been assigned, because ++ stands after prt. Be careful with such abbreviations of the code when you use macros! A typical example of an error that is hard to be found is the line Add_vec(a, a, *b++); (Where a and *b are Vectors.) The value of b will increase by 3 instead of 1 at the end of the line, because the macro Add_vec() will replace this line by 3 lines.
If z points to the coordinate of a vertex stored in coord.pool, z+3 points to the z-coordinate of the following vertex.
Usually, the shift operator works much faster than an ordinary division. If you shift an integer value to the right by 1, this is equivalent to dividing it by 2.
If we deal with large polygons or with polyhedra that approximate smooth surfaces, we can also calculate a shade value for each vertex and interpolate the shades of the pixels between the vertices (see “Gouraud shading” in Section 4.6).
The use of the constant c like in Equation 2 represents a very rough simplification of the law of reflection. It will not place highlighted spots exactly
In our simplified model, the colors of the light sources axe all white.
Since InvRot is a global variable, InvRot[SCREEN.SYST][2] is a constant address, which is evaluated during the compilation.
With this function it does not make any difference whether p and q are of the type Vector2 or of the type Vector. Both types are interpreted as pointers to a float and only the first two elements of the array are used.
It is also possible to use the type Ubyte for the shade. In this case, however, sizeof(Vertex) will be 15 instead of 16. The program runs faster when the size of the structure can be divided by 4.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 1994 Springer Science+Business Media New York
About this chapter
Cite this chapter
Glaeser, G. (1994). Graphics Output. In: Fast Algorithms for 3D-Graphics. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-662-25798-2_4
Download citation
DOI: https://doi.org/10.1007/978-3-662-25798-2_4
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-94288-7
Online ISBN: 978-3-662-25798-2
eBook Packages: Springer Book Archive