tailieunhanh - 3D Graphics with OpenGL ES and M3G- P22
3D Graphics with OpenGL ES and M3G- P22:Mobile phones are the new vehicle for bringing interactive graphics technologies to consumers. Graphics that in the 1980s was only seen in industrial flight simulators and at the turn of the millennium in desktop PCs and game consoles is now in the hands of billions of people. This book is about the technology underpinnings of mobile threedimensional graphics, the newest and most rapidly advancing area of computer graphics. | 194 OPENGL ES TRANSFORMATION AND LIGHTING CHAPTER 8 Scene ambient light and single-sided lighting glLightModelfv GL_LIGHT_MODEL_AMBIENT dark_red glLightModelf GL_LIGHT_MODEL_TWO_SIDE GL_FALSE Set up the directi onal light glLightfv GL_LIGHT0 GL_POSITION dir_light glLightfv GL_LIGHT0 GL_AMBIENT dark_gray glLightfv GL_LIGHT0 GL_DIFFUSE white glLightfv GL_LIGHT0 GL_SPECULAR red_transp glLightf GL_LIGHT0 GL_CONSTANT_ATTENUATION glLightf GL_LIGHT0 GL_LINEAR_ATTENUATION glLightf GL_LIGHT0 GL_QUADRATIC_ATTENUATION glLightf GL_LIGHT0 GL_SPOT_CUTOFF Set up glLightfv the spot li GL_LIGHT1 ght GL_POSITION spot_light glLightfv GL_LIGHT1 GL_AMBIENT white glLightfv GL_LIGHT1 GL_DIFFUSE white glLightfv GL_LIGHT1 GL_SPECULAR white glLightf GL_LIGHT1 GL_CONSTANT_ATTENUATION glLightf GL_LIGHT1 GL_LINEAR_ATTENUATION glLightf GL_LIGHT1 GL_QUADRATIC_ATTENUATION glLightf GL_LIGHT1 GL_SPOT_CUTOFF glLightf GL_LIGHT1 GL_SPOT_EXPONENT glLightfv GL_LIGHT1 GL_SPOT_DIRECTION spot_ dir Set up materials glMaterialfv GL_FRONT_AND_BACK glMaterialfv GL_FRONT_AND_BACK glMaterialfv GL_FRONT_AND_BACK glMaterialfv GL_FRONT_AND_BACK glMaterialf GL_FRONT_AND_BACK GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_EMISSION GL_SHININESS blueish blueish red_transp black Don t forget to normalize normals Faster if already normalized. glDisable GL_NORMALIZE glEnable glEnable glEnable GL_LIGHT0 GL_LIGHT1 GL_LIGHTING We use normalized coordinates - can be used also as normals glVertexPointer 3 GL_FIXED 0 vertices glNormalPointer GL_FIXED 0 vertices glEnableClientState GL_VERTEX_ARRAY glEnableClientState GL_NORMAL_ARRAY glDrawArrays GL_TRIANGLES 0 512 3 9 cc LU ZE U OPENGL ES RASTERIZATION AND FRAGMENT PROCESSING This chapter covers everything that happens after the transformation and lighting pipeline. First the primitives are clipped and culled and the surviving ones are rasterized into fragments. Clipping has already been described in Section and will not be repeated here. .
đang nạp các trang xem trước