Add more structure constructor tests.
[piglit/hramrach.git] / tests / glean / glutils.h
blobbc96b59aad7b46d4f07f4439404640aca3a9e42b
1 // BEGIN_COPYRIGHT -*- glean -*-
2 //
3 // Copyright (C) 1999, 2000 Allen Akin All Rights Reserved.
4 //
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
12 // conditions:
13 //
14 // The above copyright notice and this permission notice shall be
15 // included in all copies or substantial portions of the
16 // Software.
17 //
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.
26 //
27 // END_COPYRIGHT
32 // glutils.h: frequently-used OpenGL operations
34 #ifndef __glutils_h__
35 #define __glutils_h__
37 namespace GLEAN {
39 class Environment; // Forward reference.
41 namespace GLUtils {
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
59 // RenderingContext.
60 void (*getProcAddress(const char* name))();
62 // Return GL renderer version as a float (1.1, 2.0, etc)
63 float getVersion();
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:
69 class Light {
70 GLenum lightNumber;
71 public:
72 Light(int l);
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);
83 void enable();
84 void disable();
85 }; // Light
87 // Syntactic sugar for dealing with light model:
88 class LightModel {
89 public:
90 LightModel();
91 void ambient(float r, float g, float b, float a);
92 void localViewer(bool v);
93 void twoSide(bool v);
94 void colorControl(GLenum e);
95 }; // LightModel
97 // Syntactic sugar for dealing with material properties:
98 class Material {
99 GLenum face;
100 public:
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);
108 }; // Material
110 } // namespace GLUtils
112 } // namespace GLEAN
114 #endif // __glutils_h__