home *** CD-ROM | disk | FTP | other *** search
- (*
-
- *)
- (*******************************************************)
- unit glStereo;
- interface
- (*******************************************************)
- Uses Windows,Classes, opengl, GLFuncs, GLTexWin;
-
- Type
-
- TCustomGLStereo = class(TCustomGLTexture)
- // has all the stereo stuff
- private
- // key to accessing the render stuff
- (* procedure PaintWindow(DC: HDC); override;*)
- // Draw the window called by PaintWindow or the thread
-
- protected
-
- fStereoOn : Boolean ; //signal for stereo mode
- fStereoState : GLStereoState; //Current Stereo State
-
- Procedure GLRenderWindow(DoSwap:Boolean); override;
- Procedure Clearscreen; override;
- //clear all the glbuffers
-
-
- Procedure SetStereoOn(aVal:Boolean);
- Procedure SetStereoMode(aVal:GLStereoState);
-
- Public
- constructor Create(AOwner: TComponent); Override;
-
- Procedure BuildDisplayLists; Override;
- {This procedure builds all the standard display objects for the gl
- session}
-
- Property StereoOn : Boolean Read fStereoOn Write SetStereoOn;
- Property StereoState: GLStereoState Read fStereoState Write SetStereoMode;
- end;
-
- {procedure Register;}
- (*************************************************************)
- (*************************************************************)
- implementation
- (*************************************************************)
- constructor TCustomGLStereo.Create(AOwner: TComponent);
- Begin
- Inherited ;
- fStereoState:=steRedBlue;
- end;
- (******* ******************************************************)
- Procedure TCustomGLStereo.BuildDisplayLists;
- Begin
- If assigned(fShareGL) or not fStdDisplayList then exit;
- Inherited ;
- iF FGENERALlISTS=0 then exit;
- end;
- (*************************************************************)
- Procedure TCustomGLStereo.SetStereoOn(aVal:Boolean);
- Begin
- If fStereoOn=aVal then exit;
- fStereoOn:=aVal;
- If fStereoOn then
- Begin
- LightingOn:=True;
- HeadLightOn:=True;
- Perspective:=True;
- end;
- Repaint;
- end;
- (*************************************************************)
- Procedure TCustomGLStereo.SetStereoMode(aVal:GLStereoState);
- Begin
- If aVal=fStereoState then exit;
- fStereoState:=aVal;
- Repaint;
- end;
- (**************************************************************)
- Procedure TCustomGLStereo.Clearscreen;
- //clear all the glbuffers
- Begin
- glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT or GL_ACCUM_BUFFER_BIT);
- end;
- (*************************************************************)
- Procedure TCustomGLStereo.GLRenderWindow(DoSwap:Boolean);
- // Draw the window called by PaintWindow or the thread
- Procedure DoRedBlue;
- Var amb:tGLLightVal;
- aDist:Double;
- Begin
- ClearScreen;
- aDist:=viewer.Range;
- Viewer.ShiftLookAt(aDist);
- //setup left eye
- With amb do
- Begin
- R:=1;G:=0;B:=0;A:=1//Default values
- end;
- SetGlobalAmbient(amb);
- Viewer.SetViewPoint(vLeftEye);
- Inherited GLRenderWindow(false);
- // add to accumulation buffer
- glAccum(GL_accum,1);
-
- fRebuildNeeded:=True;
-
- //setup Right eye
- With amb do
- Begin
- R:=0;G:=1;B:=1;A:=1//Default values
- end;
- SetGlobalAmbient(amb);
- Viewer.SetViewPoint(vRightEye);
- Inherited GLRenderWindow(false);
- glAccum(GL_Accum,1);
-
- // put it all together and swap in
- glAccum(GL_Return,1);
-
- If not fDrawToOther then
- Begin
- If SwapBuffers(fRenderDC) and fGDIGeneric and fpfd_Swap_Copy
- then fValidBuffer:=True;
- end;
- With amb do
- Begin
- R:=1;G:=1;B:=1;A:=1.0//Default values
- end;
- fLights[0].SetLightColor(amb);
- Viewer.SetViewPoint(vCentrePt);
- Viewer.ShiftLookAt(-aDist);
- end;
- Begin
- If not fStereoOn then inherited
- else
- Case fStereoState of
- steNone:Inherited;
- steRedBlue:DoRedBlue;
- steBuffer:inherited;
- end;
- end;
- (*************************************************************)
- (*
- procedure TCustomGLStereo.PaintWindow(DC: HDC);
- Begin
- Inherited;
- end;
- *)
- (*************************************************************)
-
- end.
-