⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flashlight.cpp

📁 c++程序
💻 CPP
字号:
// Flashlight.cpp: Implementierung der Klasse CFlashlight.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Flashlight.h"

//////////////////////////////////////////////////////////////////////
// Konstruktion/Destruktion
//////////////////////////////////////////////////////////////////////

CFlashlight::CFlashlight()
{

}

CFlashlight::~CFlashlight()
{
	glDisable(m_GLLightIndex);
}

void CFlashlight::SetupLight(unsigned int iGLLightIndex)
{
	// Setup flashlight

	// Call base class to keep the light index
	CLight::SetupLight(iGLLightIndex);
	
	float fDiffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
	float fDirection[] = { 0.0f, -0.25f, -1.0f};
	glLightfv(iGLLightIndex, GL_DIFFUSE, fDiffuse);

	// Turn it into a spotlight
	glLightf(iGLLightIndex, GL_SPOT_CUTOFF, 15.0f);
	glLightf(iGLLightIndex, GL_SPOT_EXPONENT, 128.0f);

	glEnable(m_GLLightIndex);
}

void CFlashlight::UpdatePosition()
{
	// Update the light's position before the camera transformation
	float SpotLightPos[] = { 0.0f, 0.0f, 1.0f, 1.0f };
	glLightfv(m_GLLightIndex, GL_POSITION, SpotLightPos);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -