分析程式並計算,請看下面的一段程式,並計算三個頂點1、2和3處的光照的顏色值。必須寫出過程,只有結果不得分。
#include void init(void)
; glfloat mat_diffuse = ;
glfloat mat_emission = ;
glfloat mat_specular = ;
glfloat mat_shininess = ;
glfloat light_position = ;
glfloat light_ambient = ;
glfloat light_diffuse = ;
glfloat light_specular =;
glfloat lmodel_ambient = ;
glclearcolor (0.0, 0.0, 0.0, 0.0);
glshademodel (gl_smooth);
glmaterialfv(gl_front, gl_ambient, mat_ambient);
glmaterialfv(gl_front, gl_diffuse, mat_diffuse);
glmaterialfv(gl_front, gl_specular, mat_specular);
glmaterialfv(gl_front, gl_emission, mat_emission);
glmaterialfv(gl_front, gl_shininess, mat_shininess);
gllightfv(gl_light0, gl_position, light_position);
gllightfv(gl_light0, gl_ambient, light_ambient);
gllightfv(gl_light0, gl_diffuse, light_diffuse);
gllightfv(gl_light0, gl_specular, light_specular);
gllightmodelfv(gl_light_model_ambient, lmodel_ambient);
glenable(gl_lighting);
glenable(gl_light0);
glenable(gl_depth_test);
}void display(void)
void reshape (int w, int h)
int main(int argc, char** argv)
上述程式**執行後,產生了乙個三角形,使用qq截圖獲取頂點1的畫素值(該程式中頂點1的畫素是(0,0,0))。。
使用方法如下圖:
opengl光照方程的計算驗證
include stdafx.h include include using namespace std void init void 光源環境光 glfloat mat diffuse 散射光glfloat mat emission 鏡面光glfloat mat specular 物體自發光 gl...
openGL光照系統
opengl 把光照系統分成了三部分 光源,材質和光照環境。opengl 沒有考慮光的折射 1.控制光源 第乙個引數表示設定哪乙個光源的屬性,第二個引數表示設定這個光源的哪個屬性,第三個引數則表示把該屬性值設定為多少 gllightfv gl light0,gl position,sun light...
Opengl光照(茶壺)
include initialize material property,light source,lighting model,and depth buffer.void init void glfloat mat shininess glfloat light position glfloat ...