Blender V2.61 - r43446
|
00001 00039 #include <iostream> 00040 #include <math.h> 00041 00042 #if defined(WIN32) || defined(__APPLE__) 00043 #ifdef WIN32 00044 #include <windows.h> 00045 #include <atlbase.h> 00046 00047 #include <GL/gl.h> 00048 #else // WIN32 00049 // __APPLE__ is defined 00050 #include <AGL/gl.h> 00051 #endif // WIN32 00052 #else // defined(WIN32) || defined(__APPLE__) 00053 #include <GL/gl.h> 00054 #endif // defined(WIN32) || defined(__APPLE__) 00055 00056 #include "STR_String.h" 00057 #include "GHOST_Rect.h" 00058 00059 #include "GHOST_ISystem.h" 00060 #include "GHOST_IEvent.h" 00061 #include "GHOST_IEventConsumer.h" 00062 00063 00064 #define LEFT_EYE 0 00065 #define RIGHT_EYE 1 00066 00067 static bool nVidiaWindows; // very dirty but hey, it's for testing only 00068 00069 static void gearsTimerProc(GHOST_ITimerTask* task, GHOST_TUns64 time); 00070 00071 static class Application* fApp; 00072 static GLfloat view_rotx=20.0, view_roty=30.0, view_rotz=0.0; 00073 static GLfloat fAngle = 0.0; 00074 static GHOST_ISystem* fSystem = 0; 00075 00076 00077 void StereoProjection(float left, float right, float bottom, float top, float nearplane, float farplane, 00078 float zero_plane, float dist, 00079 float eye); 00080 00081 00082 static void testTimerProc(GHOST_ITimerTask* /*task*/, GHOST_TUns64 time) 00083 { 00084 std::cout << "timer1, time=" << (int)time << "\n"; 00085 } 00086 00087 00088 static void gearGL(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GLint teeth, GLfloat tooth_depth) 00089 { 00090 GLint i; 00091 GLfloat r0, r1, r2; 00092 GLfloat angle, da; 00093 GLfloat u, v, len; 00094 00095 r0 = inner_radius; 00096 r1 = outer_radius - tooth_depth/2.0; 00097 r2 = outer_radius + tooth_depth/2.0; 00098 00099 const double pi = 3.14159264; 00100 da = 2.0*pi / teeth / 4.0; 00101 00102 glShadeModel(GL_FLAT); 00103 glNormal3f(0.0, 0.0, 1.0); 00104 00105 /* draw front face */ 00106 glBegin(GL_QUAD_STRIP); 00107 for (i=0;i<=teeth;i++) { 00108 angle = i * 2.0*pi / teeth; 00109 glVertex3f(r0*cos(angle), r0*sin(angle), width*0.5); 00110 glVertex3f(r1*cos(angle), r1*sin(angle), width*0.5); 00111 glVertex3f(r0*cos(angle), r0*sin(angle), width*0.5); 00112 glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5); 00113 } 00114 glEnd(); 00115 00116 /* draw front sides of teeth */ 00117 glBegin(GL_QUADS); 00118 da = 2.0*pi / teeth / 4.0; 00119 for (i=0;i<teeth;i++) { 00120 angle = i * 2.0*pi / teeth; 00121 glVertex3f(r1*cos(angle), r1*sin(angle), width*0.5); 00122 glVertex3f(r2*cos(angle+da), r2*sin(angle+da), width*0.5); 00123 glVertex3f(r2*cos(angle+2*da), r2*sin(angle+2*da), width*0.5); 00124 glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5); 00125 } 00126 glEnd(); 00127 00128 glNormal3f(0.0, 0.0, -1.0); 00129 00130 /* draw back face */ 00131 glBegin(GL_QUAD_STRIP); 00132 for (i=0;i<=teeth;i++) { 00133 angle = i * 2.0*pi / teeth; 00134 glVertex3f(r1*cos(angle), r1*sin(angle), -width*0.5); 00135 glVertex3f(r0*cos(angle), r0*sin(angle), -width*0.5); 00136 glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da), -width*0.5); 00137 glVertex3f(r0*cos(angle), r0*sin(angle), -width*0.5); 00138 } 00139 glEnd(); 00140 00141 /* draw back sides of teeth */ 00142 glBegin(GL_QUADS); 00143 da = 2.0*pi / teeth / 4.0; 00144 for (i=0;i<teeth;i++) { 00145 angle = i * 2.0*pi / teeth; 00146 glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da), -width*0.5); 00147 glVertex3f(r2*cos(angle+2*da), r2*sin(angle+2*da), -width*0.5); 00148 glVertex3f(r2*cos(angle+da), r2*sin(angle+da), -width*0.5); 00149 glVertex3f(r1*cos(angle), r1*sin(angle), -width*0.5); 00150 } 00151 glEnd(); 00152 00153 /* draw outward faces of teeth */ 00154 glBegin(GL_QUAD_STRIP); 00155 for (i=0;i<teeth;i++) { 00156 angle = i * 2.0*pi / teeth; 00157 glVertex3f(r1*cos(angle), r1*sin(angle), width*0.5); 00158 glVertex3f(r1*cos(angle), r1*sin(angle), -width*0.5); 00159 u = r2*cos(angle+da) - r1*cos(angle); 00160 v = r2*sin(angle+da) - r1*sin(angle); 00161 len = sqrt(u*u + v*v); 00162 u /= len; 00163 v /= len; 00164 glNormal3f(v, -u, 0.0); 00165 glVertex3f(r2*cos(angle+da), r2*sin(angle+da), width*0.5); 00166 glVertex3f(r2*cos(angle+da), r2*sin(angle+da), -width*0.5); 00167 glNormal3f(cos(angle), sin(angle), 0.0); 00168 glVertex3f(r2*cos(angle+2*da), r2*sin(angle+2*da), width*0.5); 00169 glVertex3f(r2*cos(angle+2*da), r2*sin(angle+2*da), -width*0.5); 00170 u = r1*cos(angle+3*da) - r2*cos(angle+2*da); 00171 v = r1*sin(angle+3*da) - r2*sin(angle+2*da); 00172 glNormal3f(v, -u, 0.0); 00173 glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5); 00174 glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da), -width*0.5); 00175 glNormal3f(cos(angle), sin(angle), 0.0); 00176 } 00177 glVertex3f(r1*cos(0.0), r1*sin(0.0), width*0.5); 00178 glVertex3f(r1*cos(0.0), r1*sin(0.0), -width*0.5); 00179 glEnd(); 00180 00181 glShadeModel(GL_SMOOTH); 00182 00183 /* draw inside radius cylinder */ 00184 glBegin(GL_QUAD_STRIP); 00185 for (i=0;i<=teeth;i++) { 00186 angle = i * 2.0*pi / teeth; 00187 glNormal3f(-cos(angle), -sin(angle), 0.0); 00188 glVertex3f(r0*cos(angle), r0*sin(angle), -width*0.5); 00189 glVertex3f(r0*cos(angle), r0*sin(angle), width*0.5); 00190 } 00191 glEnd(); 00192 } 00193 00194 00195 00196 static void drawGearGL(int id) 00197 { 00198 static GLfloat pos[4] = { 5.0f, 5.0f, 10.0f, 1.0f }; 00199 static GLfloat ared[4] = { 0.8f, 0.1f, 0.0f, 1.0f }; 00200 static GLfloat agreen[4] = { 0.0f, 0.8f, 0.2f, 1.0f }; 00201 static GLfloat ablue[4] = { 0.2f, 0.2f, 1.0f, 1.0f }; 00202 00203 glLightfv(GL_LIGHT0, GL_POSITION, pos); 00204 glEnable(GL_CULL_FACE); 00205 glEnable(GL_LIGHTING); 00206 glEnable(GL_LIGHT0); 00207 glEnable(GL_DEPTH_TEST); 00208 00209 switch (id) 00210 { 00211 case 1: 00212 glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ared); 00213 gearGL(1.0f, 4.0f, 1.0f, 20, 0.7f); 00214 break; 00215 case 2: 00216 glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, agreen); 00217 gearGL(0.5f, 2.0f, 2.0f, 10, 0.7f); 00218 break; 00219 case 3: 00220 glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ablue); 00221 gearGL(1.3f, 2.0f, 0.5f, 10, 0.7f); 00222 break; 00223 default: 00224 break; 00225 } 00226 glEnable(GL_NORMALIZE); 00227 } 00228 00229 00230 void RenderCamera() 00231 { 00232 glRotatef(view_rotx, 1.0, 0.0, 0.0); 00233 glRotatef(view_roty, 0.0, 1.0, 0.0); 00234 glRotatef(view_rotz, 0.0, 0.0, 1.0); 00235 } 00236 00237 00238 void RenderScene() 00239 { 00240 glPushMatrix(); 00241 glTranslatef(-3.0, -2.0, 0.0); 00242 glRotatef(fAngle, 0.0, 0.0, 1.0); 00243 drawGearGL(1); 00244 glPopMatrix(); 00245 00246 glPushMatrix(); 00247 glTranslatef(3.1f, -2.0f, 0.0f); 00248 glRotatef(-2.0 * fAngle - 9.0, 0.0, 0.0, 1.0); 00249 drawGearGL(2); 00250 glPopMatrix(); 00251 00252 glPushMatrix(); 00253 glTranslatef(-3.1f, 2.2f, -1.8f); 00254 glRotatef(90.0f, 1.0f, 0.0f, 0.0f); 00255 glRotatef(2.0 * fAngle - 2.0, 0.0, 0.0, 1.0); 00256 drawGearGL(3); 00257 glPopMatrix(); 00258 } 00259 00260 00261 static void View(GHOST_IWindow* window, bool stereo, int eye = 0) 00262 { 00263 window->activateDrawingContext(); 00264 GHOST_Rect bnds; 00265 int noOfScanlines = 0, lowerScanline = 0; 00266 int verticalBlankingInterval = 32; // hard coded for testing purposes, display device dependant 00267 float left, right, bottom, top; 00268 float nearplane, farplane, zeroPlane, distance; 00269 float eyeSeparation = 0.62f; 00270 window->getClientBounds(bnds); 00271 00272 // viewport 00273 if(stereo) 00274 { 00275 if(nVidiaWindows) 00276 { 00277 // handled by nVidia driver so act as normal (explicitly put here since 00278 // it -is- stereo) 00279 glViewport(0, 0, bnds.getWidth(), bnds.getHeight()); 00280 } 00281 else 00282 { // generic cross platform above-below stereo 00283 noOfScanlines = (bnds.getHeight() - verticalBlankingInterval) / 2; 00284 switch(eye) 00285 { 00286 case LEFT_EYE: 00287 // upper half of window 00288 lowerScanline = bnds.getHeight() - noOfScanlines; 00289 break; 00290 case RIGHT_EYE: 00291 // lower half of window 00292 lowerScanline = 0; 00293 break; 00294 } 00295 } 00296 } 00297 else 00298 { 00299 noOfScanlines = bnds.getHeight(); 00300 lowerScanline = 0; 00301 } 00302 00303 glViewport(0, lowerScanline, bnds.getWidth(), noOfScanlines); 00304 00305 // projection 00306 left = -6.0; 00307 right = 6.0; 00308 bottom = -4.8f; 00309 top = 4.8f; 00310 nearplane = 5.0; 00311 farplane = 60.0; 00312 00313 if(stereo) 00314 { 00315 zeroPlane = 0.0; 00316 distance = 14.5; 00317 switch(eye) 00318 { 00319 case LEFT_EYE: 00320 StereoProjection(left, right, bottom, top, nearplane, farplane, zeroPlane, distance, -eyeSeparation / 2.0); 00321 break; 00322 case RIGHT_EYE: 00323 StereoProjection(left, right, bottom, top, nearplane, farplane, zeroPlane, distance, eyeSeparation / 2.0); 00324 break; 00325 } 00326 } 00327 else 00328 { 00329 // left = -w; 00330 // right = w; 00331 // bottom = -h; 00332 // top = h; 00333 glMatrixMode(GL_PROJECTION); 00334 glLoadIdentity(); 00335 glFrustum(left, right, bottom, top, 5.0, 60.0); 00336 glMatrixMode(GL_MODELVIEW); 00337 glLoadIdentity(); 00338 glTranslatef(0.0, 0.0, -40.0); 00339 00340 } 00341 00342 glClearColor(.2f,0.0f,0.0f,0.0f); 00343 } 00344 00345 00346 void StereoProjection(float left, float right, float bottom, float top, float nearplane, float farplane, 00347 float zero_plane, float dist, 00348 float eye) 00349 /* Perform the perspective projection for one eye's subfield. 00350 The projection is in the direction of the negative z axis. 00351 00352 -6.0, 6.0, -4.8, 4.8, 00353 left, right, bottom, top = the coordinate range, in the plane of zero 00354 parallax setting, which will be displayed on the screen. The 00355 ratio between (right-left) and (top-bottom) should equal the aspect 00356 ratio of the display. 00357 00358 6.0, -6.0, 00359 near, far = the z-coordinate values of the clipping planes. 00360 00361 0.0, 00362 zero_plane = the z-coordinate of the plane of zero parallax setting. 00363 00364 14.5, 00365 dist = the distance from the center of projection to the plane 00366 of zero parallax. 00367 00368 -0.31 00369 eye = half the eye separation; positive for the right eye subfield, 00370 negative for the left eye subfield. 00371 */ 00372 { 00373 float xmid, ymid, clip_near, clip_far, topw, bottomw, leftw, rightw, 00374 dx, dy, n_over_d; 00375 00376 dx = right - left; 00377 dy = top - bottom; 00378 00379 xmid = (right + left) / 2.0; 00380 ymid = (top + bottom) / 2.0; 00381 00382 clip_near = dist + zero_plane - nearplane; 00383 clip_far = dist + zero_plane - farplane; 00384 00385 n_over_d = clip_near / dist; 00386 00387 topw = n_over_d * dy / 2.0; 00388 bottomw = -topw; 00389 rightw = n_over_d * (dx / 2.0 - eye); 00390 leftw = n_over_d *(-dx / 2.0 - eye); 00391 00392 /* Need to be in projection mode for this. */ 00393 glLoadIdentity(); 00394 glFrustum(leftw, rightw, bottomw, topw, clip_near, clip_far); 00395 00396 glTranslatef(-xmid - eye, -ymid, -zero_plane - dist); 00397 return; 00398 } /* stereoproj */ 00399 00400 00401 class Application : public GHOST_IEventConsumer { 00402 public: 00403 Application(GHOST_ISystem* system); 00404 ~Application(void); 00405 virtual bool processEvent(GHOST_IEvent* event); 00406 00407 GHOST_ISystem* m_system; 00408 GHOST_IWindow* m_mainWindow; 00409 GHOST_IWindow* m_secondaryWindow; 00410 GHOST_IWindow* m_fullScreenWindow; 00411 GHOST_ITimerTask* m_gearsTimer, *m_testTimer; 00412 GHOST_TStandardCursor m_cursor; 00413 bool m_exitRequested; 00414 00415 bool stereo; 00416 }; 00417 00418 00419 Application::Application(GHOST_ISystem* system) 00420 : m_system(system), m_mainWindow(0), m_secondaryWindow(0), m_fullScreenWindow(0), 00421 m_gearsTimer(0), m_testTimer(0), m_cursor(GHOST_kStandardCursorFirstCursor), 00422 m_exitRequested(false), stereo(false) 00423 { 00424 fApp = this; 00425 00426 // Create the main window 00427 STR_String title1 ("gears - main window"); 00428 m_mainWindow = system->createWindow(title1, 10, 64, 320, 200, GHOST_kWindowStateNormal, 00429 GHOST_kDrawingContextTypeOpenGL, false, false); 00430 00431 if (!m_mainWindow) { 00432 std::cout << "could not create main window\n"; 00433 exit(-1); 00434 } 00435 00436 // Create a secondary window 00437 STR_String title2 ("gears - secondary window"); 00438 m_secondaryWindow = system->createWindow(title2, 340, 64, 320, 200, GHOST_kWindowStateNormal, 00439 GHOST_kDrawingContextTypeOpenGL, false, false); 00440 if (!m_secondaryWindow) { 00441 cout << "could not create secondary window\n"; 00442 exit(-1); 00443 } 00444 00445 // Install a timer to have the gears running 00446 m_gearsTimer = system->installTimer(0 /*delay*/, 20/*interval*/, gearsTimerProc, m_mainWindow); 00447 } 00448 00449 00450 Application::~Application(void) 00451 { 00452 // Dispose windows 00453 if (m_system->validWindow(m_mainWindow)) { 00454 m_system->disposeWindow(m_mainWindow); 00455 } 00456 if (m_system->validWindow(m_secondaryWindow)) { 00457 m_system->disposeWindow(m_secondaryWindow); 00458 } 00459 } 00460 00461 00462 bool Application::processEvent(GHOST_IEvent* event) 00463 { 00464 GHOST_IWindow* window = event->getWindow(); 00465 bool handled = true; 00466 00467 switch (event->getType()) { 00468 /* case GHOST_kEventUnknown: 00469 break; 00470 case GHOST_kEventCursorButton: 00471 std::cout << "GHOST_kEventCursorButton"; break; 00472 case GHOST_kEventCursorMove: 00473 std::cout << "GHOST_kEventCursorMove"; break; 00474 */ 00475 case GHOST_kEventWheel: 00476 { 00477 GHOST_TEventWheelData* wheelData = (GHOST_TEventWheelData*) event->getData(); 00478 if (wheelData->z > 0) 00479 { 00480 view_rotz += 5.f; 00481 } 00482 else 00483 { 00484 view_rotz -= 5.f; 00485 } 00486 } 00487 break; 00488 00489 case GHOST_kEventKeyUp: 00490 break; 00491 00492 case GHOST_kEventKeyDown: 00493 { 00494 GHOST_TEventKeyData* keyData = (GHOST_TEventKeyData*) event->getData(); 00495 switch (keyData->key) { 00496 case GHOST_kKeyC: 00497 { 00498 int cursor = m_cursor; 00499 cursor++; 00500 if (cursor >= GHOST_kStandardCursorNumCursors) { 00501 cursor = GHOST_kStandardCursorFirstCursor; 00502 } 00503 m_cursor = (GHOST_TStandardCursor)cursor; 00504 window->setCursorShape(m_cursor); 00505 } 00506 break; 00507 00508 case GHOST_kKeyE: 00509 { 00510 int x = 200, y= 200; 00511 m_system->setCursorPosition(x,y); 00512 break; 00513 } 00514 00515 case GHOST_kKeyF: 00516 if (!m_system->getFullScreen()) { 00517 // Begin fullscreen mode 00518 GHOST_DisplaySetting setting; 00519 00520 setting.bpp = 16; 00521 setting.frequency = 50; 00522 setting.xPixels = 640; 00523 setting.yPixels = 480; 00524 m_system->beginFullScreen(setting, &m_fullScreenWindow, false /* stereo flag */); 00525 } 00526 else { 00527 m_system->endFullScreen(); 00528 m_fullScreenWindow = 0; 00529 } 00530 break; 00531 00532 case GHOST_kKeyH: 00533 window->setCursorVisibility(!window->getCursorVisibility()); 00534 break; 00535 00536 case GHOST_kKeyM: 00537 { 00538 bool down = false; 00539 m_system->getModifierKeyState(GHOST_kModifierKeyLeftShift,down); 00540 if (down) { 00541 std::cout << "left shift down\n"; 00542 } 00543 m_system->getModifierKeyState(GHOST_kModifierKeyRightShift,down); 00544 if (down) { 00545 std::cout << "right shift down\n"; } 00546 m_system->getModifierKeyState(GHOST_kModifierKeyLeftAlt,down); 00547 if (down) { 00548 std::cout << "left Alt down\n"; 00549 } 00550 m_system->getModifierKeyState(GHOST_kModifierKeyRightAlt,down); 00551 if (down) { 00552 std::cout << "right Alt down\n"; 00553 } 00554 m_system->getModifierKeyState(GHOST_kModifierKeyLeftControl,down); 00555 if (down) { 00556 std::cout << "left control down\n"; 00557 } 00558 m_system->getModifierKeyState(GHOST_kModifierKeyRightControl,down); 00559 if (down) { 00560 std::cout << "right control down\n"; 00561 } 00562 } 00563 break; 00564 00565 case GHOST_kKeyQ: 00566 if (m_system->getFullScreen()) 00567 { 00568 m_system->endFullScreen(); 00569 m_fullScreenWindow = 0; 00570 } 00571 m_exitRequested = true; 00572 break; 00573 00574 case GHOST_kKeyS: // toggle mono and stereo 00575 if(stereo) 00576 stereo = false; 00577 else 00578 stereo = true; 00579 break; 00580 00581 case GHOST_kKeyT: 00582 if (!m_testTimer) { 00583 m_testTimer = m_system->installTimer(0, 1000, testTimerProc); 00584 } 00585 00586 else { 00587 m_system->removeTimer(m_testTimer); 00588 m_testTimer = 0; 00589 } 00590 00591 break; 00592 00593 case GHOST_kKeyW: 00594 if (m_mainWindow) 00595 { 00596 STR_String title; 00597 m_mainWindow->getTitle(title); 00598 title += "-"; 00599 m_mainWindow->setTitle(title); 00600 00601 } 00602 break; 00603 00604 default: 00605 break; 00606 } 00607 } 00608 break; 00609 00610 case GHOST_kEventWindowClose: 00611 { 00612 GHOST_IWindow* window2 = event->getWindow(); 00613 if (window2 == m_mainWindow) { 00614 m_exitRequested = true; 00615 } 00616 else { 00617 m_system->disposeWindow(window2); 00618 } 00619 } 00620 break; 00621 00622 case GHOST_kEventWindowActivate: 00623 handled = false; 00624 break; 00625 00626 case GHOST_kEventWindowDeactivate: 00627 handled = false; 00628 break; 00629 00630 case GHOST_kEventWindowUpdate: 00631 { 00632 GHOST_IWindow* window2 = event->getWindow(); 00633 if(!m_system->validWindow(window2)) 00634 break; 00635 00636 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00637 00638 if(stereo) 00639 { 00640 View(window2, stereo, LEFT_EYE); 00641 glPushMatrix(); 00642 RenderCamera(); 00643 RenderScene(); 00644 glPopMatrix(); 00645 00646 View(window2, stereo, RIGHT_EYE); 00647 glPushMatrix(); 00648 RenderCamera(); 00649 RenderScene(); 00650 glPopMatrix(); 00651 } 00652 else 00653 { 00654 View(window2, stereo); 00655 glPushMatrix(); 00656 RenderCamera(); 00657 RenderScene(); 00658 glPopMatrix(); 00659 } 00660 window2->swapBuffers(); 00661 } 00662 break; 00663 00664 default: 00665 handled = false; 00666 break; 00667 } 00668 return handled; 00669 } 00670 00671 00672 int main(int /*argc*/, char** /*argv*/) 00673 { 00674 nVidiaWindows = false; 00675 // nVidiaWindows = true; 00676 00677 #ifdef WIN32 00678 /* Set a couple of settings in the registry for the nVidia detonator driver. 00679 * So this is very specific... 00680 */ 00681 if(nVidiaWindows) 00682 { 00683 LONG lresult; 00684 HKEY hkey = 0; 00685 DWORD dwd = 0; 00686 //unsigned char buffer[128]; 00687 00688 CRegKey regkey; 00689 //DWORD keyValue; 00690 // lresult = regkey.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable"); 00691 lresult = regkey.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable", 00692 KEY_ALL_ACCESS); 00693 00694 if(lresult == ERROR_SUCCESS) 00695 printf("Succesfully opened key\n"); 00696 #if 0 00697 lresult = regkey.QueryValue(&keyValue, "StereoEnable"); 00698 if(lresult == ERROR_SUCCESS) 00699 printf("Succesfully queried key\n"); 00700 #endif 00701 lresult = regkey.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable", 00702 "1"); 00703 if(lresult == ERROR_SUCCESS) 00704 printf("Succesfully set value for key\n"); 00705 regkey.Close(); 00706 if(lresult == ERROR_SUCCESS) 00707 printf("Succesfully closed key\n"); 00708 // regkey.Write("2"); 00709 } 00710 #endif // WIN32 00711 00712 // Create the system 00713 GHOST_ISystem::createSystem(); 00714 fSystem = GHOST_ISystem::getSystem(); 00715 00716 if (fSystem) { 00717 // Create an application object 00718 Application app (fSystem); 00719 00720 // Add the application as event consumer 00721 fSystem->addEventConsumer(&app); 00722 00723 // Enter main loop 00724 while (!app.m_exitRequested) { 00725 //printf("main: loop\n"); 00726 fSystem->processEvents(true); 00727 fSystem->dispatchEvents(); 00728 } 00729 } 00730 00731 // Dispose the system 00732 GHOST_ISystem::disposeSystem(); 00733 00734 return 0; 00735 } 00736 00737 00738 static void gearsTimerProc(GHOST_ITimerTask* task, GHOST_TUns64 /*time*/) 00739 { 00740 fAngle += 2.0; 00741 view_roty += 1.0; 00742 GHOST_IWindow* window = (GHOST_IWindow*)task->getUserData(); 00743 if (fApp->m_fullScreenWindow) { 00744 // Running full screen 00745 fApp->m_fullScreenWindow->invalidate(); 00746 } 00747 else { 00748 if (fSystem->validWindow(window)) { 00749 window->invalidate(); 00750 } 00751 } 00752 }