- procedure initDraw(hWindow : HWND);
- var rect : TRect;
- clipSizeX,clipSizeY : GLdouble;
- LModelAmbient : Array [0..3] of GLfloat;
- begin
- //aktuelle Fenstergröße ermitteln
- getClientRect(hWindow,rect);
- ClipSizeX:= oglStatus.clipSize;
- ClipSizeY:= oglStatus.clipSize;
- //Seitenverhältnis des Weltkoordinatenbereichs an
- //Viewport anpassen
- if (ClipSizex > ClipSizeY) then
- ClipSizeY:= ClipSizeX * rect.Bottom / rect.Right
- else
- ClipSizeX:= ClipSizeY * rect.Right / Rect.Bottom;
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- //Ansichtstyp auswählen
- if (oglStatus.bOrthogonal = true) then
- glOrtho(-clipSizeX,clipSizeX,
- -clipSizeY,clipSizeY,
- oglStatus.nearPlane,
- oglStatus.farPlane)
- else
- glFrustum(-clipSizeX,clipSizeX,
- -clipSizeY,clipSizeY,
- oglStatus.nearPlane,
- oglStatus.farPlane);
- glViewport(0,0,rect.Right,rect.Bottom); //(0,0,Breite,Höhe)
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- gluLookAt(oglStatus.focalPoint.x,
- oglStatus.focalPoint.y,
- oglStatus.focalPoint.z,
- oglStatus.sceneMP.x,
- oglStatus.sceneMP.y,
- oglStatus.sceneMP.z,
- oglStatus.upVector.x,
- oglStatus.upVector.y,
- oglStatus.upVector.z);
- //Umgebungslicht
- LModelAmbient[0]:= 0.5;
- LModelAmbient[1]:= 0.5;
- LModelAmbient[2]:= 0.5;
- LModelAmbient[3]:= 1;
- glLightModelfv(GL_LIGHT_MODEL_AMBIENT,
- @LModelAmbient);
- glEnable(GL_DEPTH_TEST);
- glShadeModel(GL_SMOOTH);
- glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
- //
- glEnable(GL_COLOR_MATERIAL);
- glLightModeli(GL_LIGHT_MODEL_AMBIENT,1);
- glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,1);
- end;