1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#include "glt_lightm.h"
/*! \file
\ingroup GLT
$Id: lightm.cpp,v 1.5 2002/10/09 15:09:38 nigels Exp $
$Log: lightm.cpp,v $
Revision 1.5 2002/10/09 15:09:38 nigels
Added RCS Id and Log tags
*/
#include "glt_error.h"
#include <cstring>
#include <iostream>
using namespace std;
GltLightModel::GltLightModel(const bool getIt)
{
memset(_ambient,0,sizeof(_ambient));
_localViewer = false;
_twoSide = false;
if (getIt)
get();
}
GltLightModel::~GltLightModel()
{
}
void
GltLightModel::get()
{
GLint localViewer;
GLint twoSide;
GLERROR(std::cerr);
glGetFloatv(GL_LIGHT_MODEL_AMBIENT,_ambient);
glGetIntegerv(GL_LIGHT_MODEL_LOCAL_VIEWER,&localViewer);
glGetIntegerv(GL_LIGHT_MODEL_TWO_SIDE,&twoSide);
GLERROR(std::cerr);
_localViewer = localViewer!=0;
_twoSide = twoSide!=0;
}
void
GltLightModel::set()
{
GLERROR(std::cerr);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,_ambient);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,_localViewer ? 1 : 0);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,_twoSide ? 1 : 0);
GLERROR(std::cerr);
}
void
GltLightModel::setAmbient(const GLfloat r,const GLfloat g,const GLfloat b,const GLfloat a)
{
GLERROR(std::cerr);
_ambient[0] = r;
_ambient[1] = g;
_ambient[2] = b;
_ambient[3] = a;
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,_ambient);
GLERROR(std::cerr);
}
void
GltLightModel::setLocalViewer(const GLboolean localViewer)
{
GLERROR(std::cerr);
_localViewer = localViewer;
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,_localViewer ? 1 : 0);
GLERROR(std::cerr);
}
void
GltLightModel::setTwoSide(const GLboolean twoSide)
{
GLERROR(std::cerr);
_twoSide = twoSide;
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,_twoSide ? 1 : 0);
GLERROR(std::cerr);
}
GLfloat *GltLightModel::ambient() { return _ambient; }
GLboolean &GltLightModel::localViewer() { return _localViewer; }
GLboolean &GltLightModel::twoSide() { return _twoSide; }
|