return 0; case WMJDESTROY:
wglMakeCurrent ( NULL, NULL ); wglDeleteContext ( hrc);

Компьютерная графика. Полигональные модели

KillTimer ( hWnd, timer); PostQuitMessage (0 );
return 0;
}
return DefWindowProc ( hWnd, msg, wParam, IParam );
}
void setDCPixelFormat ( HDC hdc ) {
static PIXELFORMATDESCRIPTOR pfd = {
sizeof ( PIXELFORMATDESCRIPTOR ), // sizeof this structure 1, // version number
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL,
PFD_TYPE_RGBA, // RGBA pixel values
24, // 24-bit color
0, 0, 0, 0, 0, 0, // don't care about these
0, 0, // no alpha buffer
0, 0, 0, 0, 0, // no accumulation buffer
32, // 32-bit depth buffer
0, // no stencil buffer
0, // no auxiliary buffers
PFD_MAIN_PLANE, //layer type
0, // reserved (must be 0)
0, 0, 0 // no layer masks
};
int pixelFormat;
pixelFormat = ChoosePixelFormat ( hdc, &pfd ); SetPixelFormat ( hdc, pixelFormat, &pfd ); DescribePixelFormat ( hdc, pixelFormat,
sizeof (PIXELFORMATDESCRIPTOR), &pfd );
if ( pfd.dwFlags & P F D_ N E E D__P AL ETT E )
MessageBox ( NULL, "Wrong video mode", "Attention", MB_OK );
}
void initializeRC () {
GLfloat lightAmbient 0 = { 0.1, 0.1, 0.1, 1.0}; GLfloat lightDiffuse [] = { 0.7, 0.7, 0.7, 1.0 }; GLfloat lightSpecular 0 = { 0.0, 0.0, 0.0, 1.0 };
gIFrontFace ( GL_CCW ); glCullFace ( GL_BACK ); glEnable ( GL_CULL_FACE );
gIDepthFunc ( GLJ.EQUAL ); glEnable ( GL_DEPTH_TEST ); glClearColor ( 0.0, 0.0, 0.0, 0.0 );
gILightfv ( GL_LIGHT0, GL_AMBIENT, lightAmbient); gILightfv ( GL_LIGHT0, GL_DIFFUSE, lightDiffuse ); gILightfv ( GLJJGHT0, GL_SPECULAR, lightSpecular);

12. Работа с библиотекой OpenGL

glEnable ( GLJJGHTING ); glEnable ( GL_LIGHT0 );
void drawScene ( HDC hDC, int angle ) {
GLfloat blue [] = { 0.0, 0.0, 1.0, 1.0 }; GLfloat yellow [] = {1.0, 1.0, 0.0, 1.0 };
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glMatrixMode ( GL_MODELVIEW ); gILoadldentity (); glTranslatef ( 0.0, 0.0, -64.0 ); gIRotatef ( 30.0, 1.0,0.0,0.0 ); gIRotatef (30.0, 0.0, 1.0,0.0);

⇐ Предыдущая| |Следующая ⇒