17#if defined(WIN32) || defined(__APPLE__)
61 std::cout <<
"timer1, time=" << int(time) <<
"\n";
65 GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GLint teeth, GLfloat tooth_depth)
73 r1 = outer_radius - tooth_depth / 2.0;
74 r2 = outer_radius + tooth_depth / 2.0;
76 const double pi = 3.14159264;
77 da = 2.0 * pi / teeth / 4.0;
79 glShadeModel(GL_FLAT);
80 glNormal3f(0.0, 0.0, 1.0);
83 glBegin(GL_QUAD_STRIP);
84 for (
i = 0;
i <= teeth;
i++) {
85 angle =
i * 2.0 * pi / teeth;
95 da = 2.0 * pi / teeth / 4.0;
96 for (
i = 0;
i < teeth;
i++) {
97 angle =
i * 2.0 * pi / teeth;
100 glVertex3f(r2 *
cos(
angle + 2 * da), r2 *
sin(
angle + 2 * da), width * 0.5);
101 glVertex3f(r1 *
cos(
angle + 3 * da), r1 *
sin(
angle + 3 * da), width * 0.5);
105 glNormal3f(0.0, 0.0, -1.0);
108 glBegin(GL_QUAD_STRIP);
109 for (
i = 0;
i <= teeth;
i++) {
110 angle =
i * 2.0 * pi / teeth;
113 glVertex3f(r1 *
cos(
angle + 3 * da), r1 *
sin(
angle + 3 * da), -width * 0.5);
120 da = 2.0 * pi / teeth / 4.0;
121 for (
i = 0;
i < teeth;
i++) {
122 angle =
i * 2.0 * pi / teeth;
123 glVertex3f(r1 *
cos(
angle + 3 * da), r1 *
sin(
angle + 3 * da), -width * 0.5);
124 glVertex3f(r2 *
cos(
angle + 2 * da), r2 *
sin(
angle + 2 * da), -width * 0.5);
131 glBegin(GL_QUAD_STRIP);
132 for (
i = 0;
i < teeth;
i++) {
133 angle =
i * 2.0 * pi / teeth;
141 glNormal3f(
v, -u, 0.0);
145 glVertex3f(r2 *
cos(
angle + 2 * da), r2 *
sin(
angle + 2 * da), width * 0.5);
146 glVertex3f(r2 *
cos(
angle + 2 * da), r2 *
sin(
angle + 2 * da), -width * 0.5);
149 glNormal3f(
v, -u, 0.0);
150 glVertex3f(r1 *
cos(
angle + 3 * da), r1 *
sin(
angle + 3 * da), width * 0.5);
151 glVertex3f(r1 *
cos(
angle + 3 * da), r1 *
sin(
angle + 3 * da), -width * 0.5);
154 glVertex3f(r1 *
cos(0.0), r1 *
sin(0.0), width * 0.5);
155 glVertex3f(r1 *
cos(0.0), r1 *
sin(0.0), -width * 0.5);
158 glShadeModel(GL_SMOOTH);
161 glBegin(GL_QUAD_STRIP);
162 for (
i = 0;
i <= teeth;
i++) {
163 angle =
i * 2.0 * pi / teeth;
173 static GLfloat
pos[4] = {5.0f, 5.0f, 10.0f, 1.0f};
174 static GLfloat ared[4] = {0.8f, 0.1f, 0.0f, 1.0f};
175 static GLfloat agreen[4] = {0.0f, 0.8f, 0.2f, 1.0f};
176 static GLfloat ablue[4] = {0.2f, 0.2f, 1.0f, 1.0f};
178 glLightfv(GL_LIGHT0, GL_POSITION,
pos);
179 glEnable(GL_CULL_FACE);
180 glEnable(GL_LIGHTING);
182 glEnable(GL_DEPTH_TEST);
186 glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ared);
187 gearGL(1.0f, 4.0f, 1.0f, 20, 0.7f);
190 glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, agreen);
191 gearGL(0.5f, 2.0f, 2.0f, 10, 0.7f);
194 glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ablue);
195 gearGL(1.3f, 2.0f, 0.5f, 10, 0.7f);
200 glEnable(GL_NORMALIZE);
213 glTranslatef(-3.0, -2.0, 0.0);
214 glRotatef(
fAngle, 0.0, 0.0, 1.0);
219 glTranslatef(3.1f, -2.0f, 0.0f);
220 glRotatef(-2.0 *
fAngle - 9.0, 0.0, 0.0, 1.0);
225 glTranslatef(-3.1f, 2.2f, -1.8f);
226 glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
227 glRotatef(2.0 *
fAngle - 2.0, 0.0, 0.0, 1.0);
236 int noOfScanlines = 0, lowerScanline = 0;
238 int verticalBlankingInterval = 32;
239 float left, right, bottom,
top;
240 float nearplane, farplane, zeroPlane,
distance;
241 float eyeSeparation = 0.62f;
252 noOfScanlines = (bnds.
getHeight() - verticalBlankingInterval) / 2;
256 lowerScanline = bnds.
getHeight() - noOfScanlines;
270 glViewport(0, lowerScanline, bnds.
getWidth(), noOfScanlines);
293 -eyeSeparation / 2.0);
304 eyeSeparation / 2.0);
313 glMatrixMode(GL_PROJECTION);
315 glFrustum(
left, right, bottom,
top, 5.0, 60.0);
316 glMatrixMode(GL_MODELVIEW);
318 glTranslatef(0.0, 0.0, -40.0);
321 glClearColor(.2f, 0.0f, 0.0f, 0.0f);
357 float xmid, ymid, clip_near, clip_far, topw, bottomw, leftw, rightw, dx, dy, n_over_d;
362 xmid = (right +
left) / 2.0;
363 ymid = (
top + bottom) / 2.0;
365 clip_near = dist + zero_plane - nearplane;
366 clip_far = dist + zero_plane - farplane;
368 n_over_d = clip_near / dist;
370 topw = n_over_d * dy / 2.0;
372 rightw = n_over_d * (dx / 2.0 - eye);
373 leftw = n_over_d * (-dx / 2.0 - eye);
377 glFrustum(leftw, rightw, bottomw, topw, clip_near, clip_far);
379 glTranslatef(-xmid - eye, -ymid, -zero_plane - dist);
409 gpu_settings.
context_type = GHOST_kDrawingContextTypeOpenGL;
417 std::cout <<
"could not create main window\n";
425 std::cout <<
"could not create secondary window\n";
453 case GHOST_kEventCursorButton:
454 std::cout <<
"GHOST_kEventCursorButton";
457 std::cout <<
"GHOST_kEventCursorMove";
462 if (wheelData->
value > 0) {
475 switch (keyData->
key) {
488 int x = 200,
y = 200;
501 std::cout <<
"left shift down\n";
505 std::cout <<
"right shift down\n";
509 std::cout <<
"left Alt down\n";
513 std::cout <<
"right Alt down\n";
517 std::cout <<
"left control down\n";
521 std::cout <<
"right control down\n";
571 system_->disposeWindow(window2);
586 if (!
system_->validWindow(window2)) {
590 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
642 lresult = regkey.Open(HKEY_LOCAL_MACHINE,
643 "SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable",
646 if (lresult == ERROR_SUCCESS) {
647 printf(
"Successfully opened key\n");
650 lresult = regkey.QueryValue(&keyValue,
"StereoEnable");
651 if (lresult == ERROR_SUCCESS) {
652 printf(
"Successfully queried key\n");
655 lresult = regkey.SetValue(
656 HKEY_LOCAL_MACHINE,
"SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable",
"1");
657 if (lresult == ERROR_SUCCESS) {
658 printf(
"Successfully set value for key\n");
661 if (lresult == ERROR_SUCCESS) {
662 printf(
"Successfully closed key\n");
677 fSystem->addEventConsumer(&app);
687 fSystem->removeEventConsumer(&app);
701 if (
fSystem->validWindow(window)) {
static void gearsTimerProc(GHOST_ITimerTask *task, uint64_t time)
static GHOST_ISystem * fSystem
void StereoProjection(float left, float right, float bottom, float top, float nearplane, float farplane, float zero_plane, float dist, float eye)
static void gearGL(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GLint teeth, GLfloat tooth_depth)
static void testTimerProc(GHOST_ITimerTask *, uint64_t time)
static bool nVidiaWindows
static void drawGearGL(int id)
static void View(GHOST_IWindow *window, bool stereo, int eye=0)
static class Application * fApp
@ GHOST_kWindowStateNormal
#define GHOST_kStandardCursorNumCursors
@ GHOST_kEventWindowClose
@ GHOST_kEventWindowActivate
@ GHOST_kEventWindowUpdate
@ GHOST_kEventWindowDeactivate
#define GHOST_kStandardCursorFirstCursor
@ GHOST_kModifierKeyRightControl
@ GHOST_kModifierKeyLeftControl
@ GHOST_kModifierKeyRightAlt
@ GHOST_kModifierKeyRightShift
@ GHOST_kModifierKeyLeftAlt
@ GHOST_kModifierKeyLeftShift
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
ATTR_WARN_UNUSED_RESULT const BMVert * v
unsigned long long int uint64_t
GHOST_ITimerTask * gears_timer_
Application(GHOST_ISystem *system)
GHOST_IWindow * secondary_window_
GHOST_ITimerTask * test_timer_
virtual bool processEvent(GHOST_IEvent *event)
GHOST_IWindow * main_window_
GHOST_TStandardCursor cursor_
virtual GHOST_TEventType getType() const =0
virtual GHOST_TEventDataPtr getData() const =0
static GHOST_ISystem * getSystem()
virtual GHOST_IWindow * createWindow(const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, GHOST_GPUSettings gpu_settings, const bool exclusive=false, const bool is_dialog=false, const GHOST_IWindow *parent_window=nullptr)=0
virtual GHOST_ITimerTask * installTimer(uint64_t delay, uint64_t interval, GHOST_TimerProcPtr timer_proc, GHOST_TUserDataPtr user_data=nullptr)=0
static GHOST_TSuccess createSystem(bool verbose, bool background)
static GHOST_TSuccess disposeSystem()
virtual GHOST_TUserDataPtr getUserData() const =0
virtual void getClientBounds(GHOST_Rect &bounds) const =0
virtual GHOST_TSuccess activateDrawingContext()=0
virtual GHOST_TSuccess setCursorShape(GHOST_TStandardCursor cursor_shape)=0
virtual GHOST_TSuccess swapBufferRelease()=0
virtual GHOST_TSuccess setCursorVisibility(bool visible)=0
virtual bool getCursorVisibility() const =0
virtual GHOST_TSuccess invalidate()=0
virtual int32_t getHeight() const
virtual int32_t getWidth() const
float distance(VecOp< float, D >, VecOp< float, D >) RET
GHOST_TDrawingContextType context_type