]> git.mxchange.org Git - flightgear.git/blob - docs-mini/README.extensions
Merge branch 'durk/traffic'
[flightgear.git] / docs-mini / README.extensions
1 Using Extensions
2 ----------------
3
4
5 To use an OpenGL extension in the code is is necessary to include a refference
6 to the extensions.hxx header file and add the following to the code (as an
7 example):
8
9
10 /* global variables */
11 glPointParameterfProc glPointParameterfPtr = 0;
12 glPointParameterfvProc glPointParameterfvPtr = 0;
13 bool glPointParameterIsSupported = false;
14
15
16 To be able to use these extensions the functions pointers have to be initialized
17 by something like the following examplde code:
18
19
20 if (SGIsOpenGLExtensionSupported("GL_EXT_point_parameters") )
21 {
22   glPointParameterIsSupported = true;
23   glPointParameterfPtr =  (glPointParameterfProc)
24                           SGLookupFunction("glPointParameterfEXT");
25   glPointParameterfvPtr = (glPointParameterfvProc)
26                           SGLookupFunction("glPointParameterfvEXT");
27
28 } else if ( SGIsOpenGLExtensionSupported("GL_ARB_point_parameters") ) {
29   glPointParameterIsSupported = true;
30   glPointParameterfPtr =  (glPointParameterfProc)
31                           SGLookupFunction("glPointParameterfARB");
32   glPointParameterfvPtr = (glPointParameterfvProc)
33                           SGLookupFunction("glPointParameterfvARB");
34 } else
35   glPointParameterIsSupported = false;
36
37
38 If a function is supported the function pointers are now initialized.
39
40 When using the functions (note that glPointParameterfvPtr() is used instead of
41 glPointParameterfvEXT() )it is important to check whether the
42 glPointParameterIsSupported is set to true:
43
44
45 if ( distance_attenuation && glPointParameterIsSupported )
46 {
47   // Enable states for drawing points with GL_extension
48   glEnable(GL_POINT_SMOOTH);
49
50   float quadratic[3] = {1.0, 0.001, 0.0000001};
51
52   // makes the points fade as they move away
53   glPointParameterfvPtr(GL_DISTANCE_ATTENUATION_EXT, quadratic);
54   glPointParameterfPtr(GL_POINT_SIZE_MIN_EXT, 1.0);
55 }
56
57
58
59 Adding Extensions
60 -----------------
61
62 To add an extension to the SimGear extension support code you normally only need
63 to edit the extensions.hxx header file in the screen directory.
64
65 Currently there are two extensions supported:
66 * glPointParameterf
67 * glActiveTexture
68
69 Adding a new extension involves adding the defines assosiated with the extension
70 (surrounded by the appropriate extension test):
71
72
73 #ifndef GL_EXT_point_parameters
74 # define GL_EXT_point_parameters 1
75 # define GL_POINT_SIZE_MIN_EXT                                  0x8126
76 # define GL_DISTANCE_ATTENUATION_EXT                            0x8129
77 #endif
78
79
80
81 This is needed because not all OpenGL implementations define them correctly.
82 The following step is to add a typedef for the function pointer:
83
84
85 typedef void (APIENTRY * glPointParameterfProc)(GLenum pname, GLfloat param);
86
87
88
89 The APIENTRY refference is only used by windows machines but is defined empty
90 for all other platforms and hence needs to be added for cross platfrom
91 compatibillity.