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