1 // BEGIN_COPYRIGHT -*- glean -*-
3 // Copyright (C) 1999, 2000 Allen Akin All Rights Reserved.
5 // Permission is hereby granted, free of charge, to any person
6 // obtaining a copy of this software and associated documentation
7 // files (the "Software"), to deal in the Software without
8 // restriction, including without limitation the rights to use,
9 // copy, modify, merge, publish, distribute, sublicense, and/or
10 // sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following
14 // The above copyright notice and this permission notice shall be
15 // included in all copies or substantial portions of the
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 // KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
22 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 // AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 // OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 // DEALINGS IN THE SOFTWARE.
32 // glutils.h: frequently-used OpenGL operations
39 class Environment
; // Forward reference.
43 // Set up projection and modelview matrices so that first-quadrant
44 // object coordinates map directly to screen coordinates (using the
45 // normal Cartesian convention, with (0,0) at lower left).
46 void useScreenCoords(int windowW
, int windowH
);
48 // Check to see if the current rendering context supports a given
49 // extension or set of extensions. (This is here, rather than in
50 // RenderingContext, because it can only be applied to the ``current''
51 // context rather than to any arbitrary context.)
52 bool haveExtensions(const char* required
);
53 inline bool haveExtension(const char* name
) {
54 return haveExtensions(name
);
57 // Get a pointer to a function (usually, an extension function).
58 // Like haveExtension, we have to do this here rather than in
60 void (*getProcAddress(const char* name
))();
62 // Return GL renderer version as a float (1.1, 2.0, etc)
65 // Check for OpenGL errors and log any that have occurred:
66 void logGLErrors(Environment
& env
);
68 // Syntactic sugar for dealing with light source parameters:
73 void ambient(float r
, float g
, float b
, float a
);
74 void diffuse(float r
, float g
, float b
, float a
);
75 void specular(float r
, float g
, float b
, float a
);
76 void position(float x
, float y
, float z
, float w
);
77 void spotDirection(float x
, float y
, float z
);
78 void spotExponent(float e
);
79 void spotCutoff(float c
);
80 void constantAttenuation(float a
);
81 void linearAttenuation(float a
);
82 void quadraticAttenuation(float a
);
87 // Syntactic sugar for dealing with light model:
91 void ambient(float r
, float g
, float b
, float a
);
92 void localViewer(bool v
);
94 void colorControl(GLenum e
);
97 // Syntactic sugar for dealing with material properties:
101 Material(GLenum f
= GL_FRONT_AND_BACK
);
102 void ambient(float r
, float g
, float b
, float a
);
103 void diffuse(float r
, float g
, float b
, float a
);
104 void ambientAndDiffuse(float r
, float g
, float b
, float a
);
105 void specular(float r
, float g
, float b
, float a
);
106 void emission(float r
, float g
, float b
, float a
);
107 void shininess(float s
);
110 } // namespace GLUtils
114 #endif // __glutils_h__