📄 clightman.h
字号:
/////////////////////////////////////////////////////////////////
// This code was done by HiperBlaster
// Takes care of the gl light parameters
//////////////////////////////////////////////////////////////////
class CLightMan
{
public:
//CLightMan(); //constructor
// self explainatory?
void EnableLights()
{
glEnable(GL_LIGHTING);
}
void DisableLights()
{
glDisable(GL_LIGHTING);
}
//set's "light"'s position
void SetPosition(GLenum light,float x,float y,float z, float fourth);
// oh come on, the function name says it all ;)
void SetDiffuseColor(GLenum light,float r,float g,float b, float fourth);
void SetAmbientColor(GLenum light,float r,float g,float b, float fourth);
void Enable(GLenum light)
{
glEnable(light);
}
void Disable(GLenum light)
{
glDisable(light);
}
private:
float Array4f[4]; //very useful
}LightManager;
/////////////////////////////////////////////////////////////////////////
void CLightMan::SetPosition(GLenum light,float x,float y,float z, float fourth=1.0f)
{
Array4f[0]=x;
Array4f[1]=y;
Array4f[2]=z;
Array4f[3]=fourth;
glLightfv(light,GL_POSITION,Array4f);
//glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER,temp);
}
//////////////////////////////////////////////////////////////////////////
void CLightMan::SetAmbientColor(GLenum light,float r,float g,float b, float fourth=1.0f)
{
Array4f[0]=r;
Array4f[1]=g;
Array4f[2]=b;
Array4f[3]=fourth;
glLightfv(light,GL_AMBIENT,Array4f);
}
//////////////////////////////////////////////////////////////////////////
void CLightMan::SetDiffuseColor(GLenum light,float r,float g,float b,float fourth=1.0f)
{
Array4f[0]=r;
Array4f[1]=g;
Array4f[2]=b;
Array4f[3]=fourth;
glLightfv(light,GL_DIFFUSE,Array4f);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -