00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "PL_OutputWindow.h"
00019
00020 #include <assert.h>
00021 #ifndef NOGL
00022 #include "opengl/glos.h"
00023 #include <gl/gl.h>
00024 #endif
00025
00026
00027
00028
00029
00030
00031
00032
00033 PL_OutputWindow::~PL_OutputWindow()
00034 {
00035
00036 EndOutput();
00037
00038 }
00039
00040 void PL_OutputWindow::DrawLine (double x0, double y0, double x1, double y1) const
00041 {
00042 #ifndef NOGL
00043 glBegin( GL_LINES );
00044 glVertex2d( static_cast< short int >( x0 ), static_cast< short int >( y0 ) ) ;
00045 glVertex2s( static_cast< short int >( x1 ), static_cast< short int >( y1 ) ) ;
00046 glEnd() ;
00047 #endif
00048 }
00049
00050 void PL_OutputWindow::DrawPoint (double x0, double y0) const
00051 {
00052 #ifndef NOGL
00053 glBegin( GL_POINTS );
00054 glVertex2d( x0, y0 );
00055 glEnd();
00056 #endif
00057 }
00058
00059 void PL_OutputWindow::StartOutput ()
00060 {
00061
00062 #ifdef WIN32
00063 BOOL success;
00064 success = this->DestroyWindow() ;
00065 success = this->Create( IDD_BLANK_DIALOG, NULL ) ;
00066 assert( success == TRUE ) ;
00067
00068
00069 PIXELFORMATDESCRIPTOR pfd =
00070 {
00071 sizeof(PIXELFORMATDESCRIPTOR),
00072 1,
00073 PFD_DRAW_TO_WINDOW |
00074 PFD_SUPPORT_OPENGL ,
00075 PFD_TYPE_RGBA,
00076 24,
00077 0, 0, 0, 0, 0, 0,
00078 0, 0, 0, 0, 0, 0, 0,
00079 32,
00080 0, 0,
00081 PFD_MAIN_PLANE,
00082 0,
00083 0, 0, 0
00084 };
00085 CClientDC clientDC( this );
00086 CDC* cdc = this->GetDC() ;
00087
00088 int pixelFormat = ChoosePixelFormat(clientDC.m_hDC, &pfd);
00089 success = SetPixelFormat(clientDC.m_hDC, pixelFormat, &pfd);
00090
00091 HDC hdc = cdc->m_hDC;
00092 HGLRC hglrc = wglCreateContext (hdc);
00093 this->ReleaseDC( cdc ) ;
00094
00095 pDC = this->GetDC() ;
00096 wglMakeCurrent (pDC->m_hDC, hglrc);
00097 #endif
00098
00099 }
00100
00101 void PL_OutputWindow::EndOutput ()
00102 {
00103 #ifdef WIN32
00104 wglMakeCurrent( NULL, NULL );
00105
00106
00107 BOOL destroySuccess = this->DestroyWindow() ;
00108 assert( destroySuccess == TRUE ) ;
00109 #endif
00110 }
00111
00112 void PL_OutputWindow::NameDialog (const char* name)
00113 {
00114 #ifdef WIN32
00115 this->SetWindowText( name ) ;
00116 #endif
00117 }
00118
00119
00120
00121
00122
00123
00124