V-ART
pointlight.cpp
Go to the documentation of this file.
1 
5 #include "vart/pointlight.h"
6 
7 #ifdef WIN32
8 #include <windows.h>
9 #endif
10 #ifdef VART_OGL
11 #include <GL/gl.h>
12 #endif
13 
14 VART::PointLight::PointLight(Point4D loc, float constantAtt, float linearAtt, float quadraticAtt){
15  SetLocation(loc);
16  SetAttenuation(constantAtt, linearAtt, quadraticAtt);
17 }
18 
19 void VART::PointLight::SetAttenuation(float constant, float linear, float quadratic){
20  constantAttenuation = constant;
21  linearAttenuation = linear;
22  quadraticAttenuation = quadratic;
23 }
24 
25 bool VART::PointLight::DrawOGL(unsigned int oglLightID) const {
26 #ifdef VART_OGL
27  GLenum realID = (GLenum) getOpenGLID(oglLightID);
28 
29  GLfloat pos[4];
30  pos[0] = location.GetX();
31  pos[1] = location.GetY();
32  pos[2] = location.GetZ();
33  pos[3] = location.GetW();
34 
35  glLightfv(realID, GL_POSITION, pos);
36  glLightf(realID, GL_CONSTANT_ATTENUATION, constantAttenuation);
37  glLightf(realID, GL_LINEAR_ATTENUATION, linearAttenuation);
38  glLightf(realID, GL_QUADRATIC_ATTENUATION, quadraticAttenuation);
39 
40  VART::Light::DrawOGL(oglLightID);
41 
42  return true;
43 #else
44  return false;
45 #endif
46 }
Points and vectors using homogeneous coordinates.
Definition: point4d.h:22
void SetAttenuation(float constant=1.0, float linear=0.0, float quadratic=0.0)
Sets the three attenuation factors, described on OpenGL Red Book, Chapter 5: Lighting, section Creating Light Sources.
Definition: pointlight.cpp:19
Header file for V-ART class "PointLight".
virtual bool DrawOGL() const
Recursive drawing using OpenGL commands.
Definition: scenenode.cpp:76
void SetLocation(const Point4D &newLocation)
Definition: pointlight.h:41