[4] | 1 | /****************************************************************************** |
---|
| 2 | * SAGE - Scalable Adaptive Graphics Environment |
---|
| 3 | * |
---|
| 4 | * Copyright (C) 2004 Electronic Visualization Laboratory, |
---|
| 5 | * University of Illinois at Chicago |
---|
| 6 | * |
---|
| 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright |
---|
| 13 | * notice, this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above |
---|
| 15 | * copyright notice, this list of conditions and the following disclaimer |
---|
| 16 | * in the documentation and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the University of Illinois at Chicago nor |
---|
| 18 | * the names of its contributors may be used to endorse or promote |
---|
| 19 | * products derived from this software without specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
| 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
| 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
| 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
---|
| 25 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
---|
| 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
| 27 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
---|
| 28 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
---|
| 29 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
---|
| 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
| 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | * |
---|
| 33 | * Direct questions, comments etc about SAGE to http://www.evl.uic.edu/cavern/forum/ |
---|
| 34 | * |
---|
| 35 | *****************************************************************************/ |
---|
| 36 | |
---|
| 37 | #include "wx/wx.h" |
---|
| 38 | #include "wx/statline.h" |
---|
| 39 | |
---|
| 40 | #include "sail.h" |
---|
| 41 | |
---|
| 42 | #include <stdio.h> |
---|
| 43 | #include <stdlib.h> |
---|
| 44 | #include <string.h> |
---|
| 45 | #include <math.h> |
---|
| 46 | #include <assert.h> |
---|
| 47 | |
---|
| 48 | #include <CoreFoundation/CoreFoundation.h> |
---|
| 49 | #include <ApplicationServices/ApplicationServices.h> |
---|
| 50 | #include <OpenGL/OpenGL.h> |
---|
| 51 | #include <OpenGL/gl.h> |
---|
| 52 | #include <OpenGL/glext.h> |
---|
| 53 | //#include <Carbon/Carbon.h> |
---|
| 54 | |
---|
| 55 | #include <sys/time.h> |
---|
| 56 | |
---|
| 57 | #include "libdxt.h" |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | // headers for SAGE |
---|
| 61 | GLubyte *rgbBuffer = NULL; |
---|
| 62 | GLubyte *dxtBuffer = NULL; |
---|
| 63 | sail sageInf; // sail object |
---|
| 64 | |
---|
| 65 | class MyApp: public wxApp |
---|
| 66 | { |
---|
| 67 | virtual bool OnInit(); |
---|
| 68 | }; |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | class MyFrame: public wxFrame |
---|
| 72 | { |
---|
| 73 | public: |
---|
| 74 | |
---|
| 75 | MyFrame(const wxString& title); |
---|
| 76 | |
---|
| 77 | void OnQuit(wxCommandEvent& event); |
---|
| 78 | void OnAbout(wxCommandEvent& event); |
---|
| 79 | void OnTimer(wxTimerEvent& event); |
---|
| 80 | void OnStream(wxCommandEvent& event); |
---|
| 81 | void OnStop(wxCommandEvent& event); |
---|
| 82 | void OnSlide(wxScrollEvent& event); |
---|
| 83 | void OnAddress(wxCommandEvent& event); |
---|
| 84 | void OnCompressionNo(wxCommandEvent& event); |
---|
| 85 | void OnCompression(wxCommandEvent& event); |
---|
| 86 | |
---|
| 87 | DECLARE_EVENT_TABLE() |
---|
| 88 | |
---|
| 89 | private: |
---|
| 90 | double startt; |
---|
| 91 | int count; |
---|
| 92 | |
---|
| 93 | wxTimer m_timer; |
---|
| 94 | int FrameRate; |
---|
| 95 | wxString Address; |
---|
| 96 | int started; |
---|
| 97 | wxCheckBox *rb1, *rb2; |
---|
| 98 | int Compression; |
---|
| 99 | CGLContextObj glContextObj; |
---|
| 100 | int WW, HH; |
---|
| 101 | void capture(char* m_pFrameRGB,int x,int y,int cx,int cy); |
---|
| 102 | |
---|
| 103 | }; |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | enum |
---|
| 107 | { |
---|
| 108 | ID_Quit = 100, |
---|
| 109 | ID_About, |
---|
| 110 | TIMER_ID, |
---|
| 111 | STREAM_ID, |
---|
| 112 | STOP_ID, |
---|
| 113 | SLIDER_ID, |
---|
| 114 | ADDRESS_ID, |
---|
| 115 | COMPRESS_NO_ID, COMPRESS_ID |
---|
| 116 | }; |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) |
---|
| 120 | EVT_MENU(ID_Quit, MyFrame::OnQuit) |
---|
| 121 | EVT_MENU(ID_About, MyFrame::OnAbout) |
---|
| 122 | EVT_TIMER(TIMER_ID, MyFrame::OnTimer) |
---|
| 123 | EVT_BUTTON(STREAM_ID,MyFrame::OnStream) |
---|
| 124 | EVT_BUTTON(STOP_ID,MyFrame::OnStop) |
---|
| 125 | EVT_COMMAND_SCROLL(SLIDER_ID,MyFrame::OnSlide) |
---|
| 126 | EVT_TEXT(ADDRESS_ID, MyFrame::OnAddress) |
---|
| 127 | EVT_CHECKBOX(COMPRESS_NO_ID, MyFrame::OnCompressionNo) |
---|
| 128 | EVT_CHECKBOX(COMPRESS_ID, MyFrame::OnCompression) |
---|
| 129 | END_EVENT_TABLE() |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | IMPLEMENT_APP(MyApp) |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | bool MyApp::OnInit() |
---|
| 136 | { |
---|
| 137 | MyFrame *frame = new MyFrame( _T("iShare") ); |
---|
| 138 | frame->Show(true); |
---|
| 139 | SetTopWindow(frame); |
---|
| 140 | |
---|
| 141 | char *sageDir = getenv("SAGE_DIRECTORY"); |
---|
| 142 | if (!sageDir) { |
---|
| 143 | std::cout << "sageVirtualDesktop : cannot find the environment variable SAGE_DIRECTORY" << std::endl; |
---|
| 144 | return -1; |
---|
| 145 | } |
---|
| 146 | int len; |
---|
| 147 | char *dir; |
---|
| 148 | len = strlen(sageDir); |
---|
| 149 | dir = (char*)malloc(len+64); |
---|
| 150 | memset(dir, 0, len+64); |
---|
| 151 | sprintf(dir, "%s/bin", sageDir); |
---|
| 152 | chdir(dir); |
---|
| 153 | |
---|
| 154 | |
---|
| 155 | return true; |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | void MyFrame::capture(char* m_pFrameRGB,int x,int y,int cx,int cy) |
---|
| 159 | { |
---|
| 160 | CGLSetCurrentContext( glContextObj ) ; |
---|
| 161 | //CGLSetFullScreen( glContextObj ) ;///UUUUUUUUUUnbelievable |
---|
| 162 | //glReadBuffer(GL_FRONT); |
---|
| 163 | |
---|
| 164 | if (Compression) |
---|
| 165 | glReadPixels(x,y,cx,cy,GL_RGBA,GL_UNSIGNED_BYTE,m_pFrameRGB); |
---|
| 166 | else |
---|
| 167 | glReadPixels(x,y,cx,cy,GL_RGB,GL_UNSIGNED_BYTE,m_pFrameRGB); |
---|
| 168 | |
---|
| 169 | CGLSetCurrentContext( NULL ); |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | void MyFrame::OnTimer(wxTimerEvent& event) |
---|
| 173 | { |
---|
| 174 | if (started) { |
---|
| 175 | if (Compression) |
---|
| 176 | { |
---|
| 177 | capture((char*)rgbBuffer,0,0,WW,HH); |
---|
| 178 | CompressDXT(rgbBuffer, dxtBuffer, WW, HH, FORMAT_DXT1, 1); |
---|
| 179 | sageInf.swapBuffer(); |
---|
| 180 | dxtBuffer = (GLubyte *)sageInf.getBuffer(); |
---|
| 181 | } |
---|
| 182 | else |
---|
| 183 | { |
---|
| 184 | capture((char*)rgbBuffer,0,0,WW,HH); |
---|
| 185 | sageInf.swapBuffer(); |
---|
| 186 | rgbBuffer = (GLubyte *)sageInf.getBuffer(); |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | sageMessage msg; |
---|
| 190 | if (sageInf.checkMsg(msg, false) > 0) { |
---|
| 191 | switch (msg.getCode()) { |
---|
| 192 | case APP_QUIT: |
---|
| 193 | Close(true); |
---|
| 194 | break; |
---|
| 195 | } |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | |
---|
| 199 | wxString str; |
---|
| 200 | double nowt = aTime(); |
---|
| 201 | double fps = 1.0 / (nowt - startt); |
---|
| 202 | startt = nowt; |
---|
| 203 | str.Printf(wxT("Interval %d ms / Rate %.2f / Frame %d / Compression %d / Desktop %dx%d"), |
---|
| 204 | event.GetInterval(),fps,count++, Compression, WW, HH); |
---|
| 205 | SetStatusText( str ); |
---|
| 206 | |
---|
| 207 | } |
---|
| 208 | } |
---|
| 209 | |
---|
| 210 | |
---|
| 211 | void MyFrame::OnStream(wxCommandEvent& event) |
---|
| 212 | { |
---|
| 213 | if (!started) { |
---|
| 214 | |
---|
| 215 | FindWindow(ADDRESS_ID)->Disable(); |
---|
| 216 | FindWindow(STREAM_ID)->Disable(); |
---|
| 217 | FindWindow(COMPRESS_NO_ID)->Disable(); |
---|
| 218 | FindWindow(COMPRESS_ID)->Disable(); |
---|
| 219 | |
---|
| 220 | wxString str; |
---|
| 221 | str.Printf(wxT("Stream !")); |
---|
| 222 | SetStatusText( str ); |
---|
| 223 | started = 1; |
---|
| 224 | |
---|
| 225 | |
---|
| 226 | sageRect ishareImageMap; |
---|
| 227 | ishareImageMap.left = 0.0; |
---|
| 228 | ishareImageMap.right = 1.0; |
---|
| 229 | ishareImageMap.bottom = 0.0; |
---|
| 230 | ishareImageMap.top = 1.0; |
---|
| 231 | |
---|
| 232 | sailConfig scfg; |
---|
| 233 | scfg.init("ishare.conf"); |
---|
| 234 | scfg.setAppName("ishare"); |
---|
| 235 | scfg.rank = 0; |
---|
| 236 | |
---|
| 237 | scfg.resX = WW; |
---|
| 238 | scfg.resY = HH; |
---|
| 239 | scfg.winWidth = 2*WW; |
---|
| 240 | scfg.winHeight = 2*HH; |
---|
| 241 | scfg.imageMap = ishareImageMap; |
---|
| 242 | |
---|
| 243 | if (Compression) |
---|
| 244 | scfg.pixFmt = PIXFMT_DXT; // PIXFMT_888; |
---|
| 245 | else |
---|
| 246 | scfg.pixFmt = PIXFMT_888; |
---|
| 247 | |
---|
| 248 | scfg.rowOrd = BOTTOM_TO_TOP; |
---|
| 249 | scfg.master = true; |
---|
| 250 | |
---|
| 251 | sageInf.init(scfg); |
---|
| 252 | |
---|
| 253 | if (Compression) { |
---|
| 254 | dxtBuffer = (GLubyte *)sageInf.getBuffer(); |
---|
| 255 | if (rgbBuffer) delete [] rgbBuffer; |
---|
| 256 | rgbBuffer = (byte*)memalign(16, WW*HH*4); |
---|
| 257 | memset(rgbBuffer, 0, WW*HH*4); |
---|
| 258 | } |
---|
| 259 | else { |
---|
| 260 | rgbBuffer = (GLubyte *)sageInf.getBuffer(); |
---|
| 261 | } |
---|
| 262 | |
---|
| 263 | // xx second interval |
---|
| 264 | m_timer.Start(1000.0/FrameRate, wxTIMER_CONTINUOUS); |
---|
| 265 | } |
---|
| 266 | } |
---|
| 267 | |
---|
| 268 | void MyFrame::OnStop(wxCommandEvent& event) |
---|
| 269 | { |
---|
| 270 | wxString str; |
---|
| 271 | str.Printf(wxT("Stop !")); |
---|
| 272 | SetStatusText( str ); |
---|
| 273 | started = 0; |
---|
| 274 | } |
---|
| 275 | |
---|
| 276 | void MyFrame::OnSlide(wxScrollEvent& event) |
---|
| 277 | { |
---|
| 278 | FrameRate = event.GetPosition(); |
---|
| 279 | m_timer.Start(1000.0/FrameRate, wxTIMER_CONTINUOUS); |
---|
| 280 | } |
---|
| 281 | |
---|
| 282 | void MyFrame::OnAddress(wxCommandEvent& event) |
---|
| 283 | { |
---|
| 284 | Address = event.GetString(); |
---|
| 285 | SetStatusText( Address ); |
---|
| 286 | } |
---|
| 287 | |
---|
| 288 | void MyFrame::OnCompression(wxCommandEvent& event) |
---|
| 289 | { |
---|
| 290 | if (!started) { |
---|
| 291 | if (event.IsChecked()) { |
---|
| 292 | rb2->SetValue(false); |
---|
| 293 | Compression = 1; |
---|
| 294 | } |
---|
| 295 | else { |
---|
| 296 | rb2->SetValue(true); |
---|
| 297 | Compression = 0; |
---|
| 298 | } |
---|
| 299 | } |
---|
| 300 | } |
---|
| 301 | |
---|
| 302 | void MyFrame::OnCompressionNo(wxCommandEvent& event) |
---|
| 303 | { |
---|
| 304 | if (event.IsChecked()) { |
---|
| 305 | rb1->SetValue(false); |
---|
| 306 | Compression = 0; |
---|
| 307 | } |
---|
| 308 | else { |
---|
| 309 | rb1->SetValue(true); |
---|
| 310 | Compression = 1; |
---|
| 311 | } |
---|
| 312 | } |
---|
| 313 | |
---|
| 314 | |
---|
| 315 | MyFrame::MyFrame(const wxString& title) |
---|
| 316 | : wxFrame((wxFrame *)NULL,wxID_ANY, title, wxDefaultPosition, wxSize(450, 330)), |
---|
| 317 | m_timer(this, TIMER_ID), FrameRate(5), started(0), Compression(1) |
---|
| 318 | { |
---|
| 319 | // Initialize some timing functions and else (DXT) |
---|
| 320 | aInitialize(); |
---|
| 321 | |
---|
| 322 | startt = aTime(); |
---|
| 323 | count = 0; |
---|
| 324 | |
---|
| 325 | wxColour col1, col2; |
---|
| 326 | col1.Set(wxT("#e8e8e8")); |
---|
| 327 | col2.Set(wxT("#e8e8e8")); |
---|
| 328 | |
---|
| 329 | // Main panel |
---|
| 330 | wxPanel *panel = new wxPanel(this, -1); |
---|
| 331 | panel->SetBackgroundColour(col1); |
---|
| 332 | |
---|
| 333 | // Vertical sizer |
---|
| 334 | wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); |
---|
| 335 | |
---|
| 336 | // Panel inside the sizer |
---|
| 337 | wxPanel *midPan = new wxPanel(panel, wxID_ANY); |
---|
| 338 | midPan->SetBackgroundColour(col2); |
---|
| 339 | |
---|
| 340 | vbox->Add(midPan, 1, wxEXPAND | wxALL, 20); |
---|
| 341 | panel->SetSizer(vbox); |
---|
| 342 | |
---|
| 343 | |
---|
| 344 | // Labels with text box |
---|
| 345 | wxGridSizer *hbox1 = new wxGridSizer(2,2, 10,10); |
---|
| 346 | |
---|
| 347 | Address = wxT("131.193.78.203"); |
---|
| 348 | |
---|
| 349 | wxStaticText *st1 = new wxStaticText(midPan, wxID_ANY, wxT("SAGE IP address"), wxDefaultPosition, wxSize(128,20), wxALIGN_RIGHT); |
---|
| 350 | hbox1->Add(st1, 1, wxRIGHT); |
---|
| 351 | wxTextCtrl *tc1 = new wxTextCtrl(midPan, ADDRESS_ID, Address, wxDefaultPosition, wxSize(128,20)); |
---|
| 352 | hbox1->Add(tc1, 1, wxLEFT|wxRIGHT); |
---|
| 353 | hbox1->Add(-1, 0); |
---|
| 354 | hbox1->Add(-1, 0); |
---|
| 355 | |
---|
| 356 | // Slider with text box |
---|
| 357 | wxStaticText *st2 = new wxStaticText(midPan, wxID_ANY, wxT("Frame rate"), wxDefaultPosition, wxSize(128,20), wxALIGN_RIGHT); |
---|
| 358 | hbox1->Add(st2, 1, wxRIGHT); |
---|
| 359 | wxSlider *tc2 = new wxSlider(midPan, SLIDER_ID, FrameRate, 1, 30, wxDefaultPosition, wxSize(128,20), |
---|
| 360 | wxSL_HORIZONTAL|wxSL_AUTOTICKS|wxSL_LABELS); |
---|
| 361 | hbox1->Add(tc2, 1, wxLEFT); |
---|
| 362 | |
---|
| 363 | // Label with text box |
---|
| 364 | wxStaticText *st3 = new wxStaticText(midPan, wxID_ANY, wxT("Compression"), wxDefaultPosition, wxSize(128,20), wxALIGN_RIGHT); |
---|
| 365 | hbox1->Add(-1, 4); |
---|
| 366 | hbox1->Add(-1, 4); |
---|
| 367 | hbox1->Add(st3, 1, wxRIGHT); |
---|
| 368 | |
---|
| 369 | // Radio buttons |
---|
| 370 | wxBoxSizer *hbox4 = new wxBoxSizer(wxHORIZONTAL); |
---|
| 371 | rb1 = new wxCheckBox(midPan, COMPRESS_ID, wxT("On")); |
---|
| 372 | rb1->SetValue(true); |
---|
| 373 | rb2 = new wxCheckBox(midPan, COMPRESS_NO_ID, wxT("Off")); |
---|
| 374 | hbox4->Add(rb1, 1, wxEXPAND); |
---|
| 375 | hbox4->AddSpacer(20); |
---|
| 376 | hbox4->Add(rb2, 1, wxEXPAND); |
---|
| 377 | hbox1->Add(hbox4, 1, wxALIGN_LEFT); |
---|
| 378 | |
---|
| 379 | |
---|
| 380 | |
---|
| 381 | // Line |
---|
| 382 | wxStaticLine *line1 = new wxStaticLine(midPan, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL); |
---|
| 383 | |
---|
| 384 | |
---|
| 385 | // Two buttons |
---|
| 386 | wxBoxSizer *hbox3 = new wxBoxSizer(wxHORIZONTAL); |
---|
| 387 | |
---|
| 388 | wxButton *ok = new wxButton(midPan, STREAM_ID, wxT("Stream")); |
---|
| 389 | wxButton *cancel = new wxButton(midPan, STOP_ID, wxT("Stop")); |
---|
| 390 | |
---|
| 391 | hbox3->Add(ok, 1, wxEXPAND | wxALL, 20); |
---|
| 392 | hbox3->Add(cancel, 1, wxEXPAND | wxALL, 20); |
---|
| 393 | |
---|
| 394 | // Vertical sizer for elements |
---|
| 395 | wxBoxSizer *vbox2 = new wxBoxSizer(wxVERTICAL); |
---|
| 396 | |
---|
| 397 | vbox2->Add(hbox1, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 10); |
---|
| 398 | vbox2->Add(-1, 40); |
---|
| 399 | |
---|
| 400 | vbox2->Add(line1, 0, wxEXPAND | wxLEFT | wxRIGHT, 10); |
---|
| 401 | vbox2->Add(-1, 10); |
---|
| 402 | |
---|
| 403 | vbox2->Add(hbox3, 1, wxEXPAND); |
---|
| 404 | |
---|
| 405 | midPan->SetSizer(vbox2); |
---|
| 406 | |
---|
| 407 | |
---|
| 408 | // Menu |
---|
| 409 | wxMenu *menuFile = new wxMenu; |
---|
| 410 | |
---|
| 411 | menuFile->Append( ID_About, _T("&About...") ); |
---|
| 412 | menuFile->AppendSeparator(); |
---|
| 413 | menuFile->Append( ID_Quit, _T("E&xit") ); |
---|
| 414 | |
---|
| 415 | wxMenuBar *menuBar = new wxMenuBar; |
---|
| 416 | menuBar->Append( menuFile, _T("&File") ); |
---|
| 417 | |
---|
| 418 | SetMenuBar( menuBar ); |
---|
| 419 | |
---|
| 420 | CreateStatusBar(); |
---|
| 421 | SetStatusText( _T("iShare, SAGE desktop sharing for Mac") ); |
---|
| 422 | |
---|
| 423 | wxMessageBox(_T("iShare desktop sharing for Mac v1.0"), |
---|
| 424 | _T("iShare"), wxOK | wxICON_INFORMATION, this); |
---|
| 425 | |
---|
| 426 | ///////////////////////// |
---|
| 427 | // Get the OpenGL context |
---|
| 428 | CGLPixelFormatObj pixelFormatObj ; |
---|
| 429 | GLint numPixelFormats ; |
---|
| 430 | CGDirectDisplayID displayId = CGMainDisplayID(); |
---|
| 431 | CGRect dRect = CGDisplayBounds( displayId ); |
---|
| 432 | WW = dRect.size.width; |
---|
| 433 | HH = dRect.size.height; |
---|
| 434 | CGOpenGLDisplayMask displayMask = CGDisplayIDToOpenGLDisplayMask(displayId); |
---|
| 435 | |
---|
| 436 | CGLPixelFormatAttribute attribs[] = |
---|
| 437 | { |
---|
| 438 | (CGLPixelFormatAttribute)kCGLPFAFullScreen, |
---|
| 439 | (CGLPixelFormatAttribute)kCGLPFADisplayMask, |
---|
| 440 | (CGLPixelFormatAttribute)displayMask, |
---|
| 441 | (CGLPixelFormatAttribute)0 |
---|
| 442 | }; |
---|
| 443 | CGLChoosePixelFormat( attribs, &pixelFormatObj, &numPixelFormats ); |
---|
| 444 | CGLCreateContext( pixelFormatObj, NULL, &glContextObj ) ; |
---|
| 445 | CGLDestroyPixelFormat( pixelFormatObj ) ; |
---|
| 446 | CGLSetCurrentContext( glContextObj ) ; |
---|
| 447 | glReadBuffer(GL_FRONT); |
---|
| 448 | CGLSetFullScreen( glContextObj ) ;///UUUUUUUUUUnbelievable |
---|
| 449 | CGLSetCurrentContext( NULL ); |
---|
| 450 | } |
---|
| 451 | |
---|
| 452 | |
---|
| 453 | void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) |
---|
| 454 | { |
---|
| 455 | CGLClearDrawable( glContextObj ); |
---|
| 456 | CGLDestroyContext( glContextObj ); |
---|
| 457 | |
---|
| 458 | Close(true); |
---|
| 459 | } |
---|
| 460 | |
---|
| 461 | void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) |
---|
| 462 | { |
---|
| 463 | wxMessageBox(_T("iShare desktop sharing for Mac v1.0"), |
---|
| 464 | _T("iShare"), wxOK | wxICON_INFORMATION, this); |
---|
| 465 | } |
---|
| 466 | |
---|
| 467 | |
---|