当前位置: 首页>>代码示例>>C++>>正文


C++ current_device_rotation函数代码示例

本文整理汇总了C++中current_device_rotation函数的典型用法代码示例。如果您正苦于以下问题:C++ current_device_rotation函数的具体用法?C++ current_device_rotation怎么用?C++ current_device_rotation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了current_device_rotation函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: draw_moebius

ENTRYPOINT void
draw_moebius (ModeInfo * mi)
{
	moebiusstruct *mp;

	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);

        if (moebius == NULL)
	    return;
	mp = &moebius[MI_SCREEN(mi)];

	MI_IS_DRAWN(mi) = True;

	if (!mp->glx_context)
		return;

	glXMakeCurrent(display, window, *(mp->glx_context));

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glPushMatrix();

	glTranslatef(0.0, 0.0, -10.0);

    /* Do it twice because we don't track the device's orientation. */
    glRotatef( current_device_rotation(), 0, 0, 1);
    gltrackball_rotate (mp->trackball);
    glRotatef(-current_device_rotation(), 0, 0, 1);

	if (!MI_IS_ICONIC(mi)) {
		glScalef(Scale4Window * mp->WindH / mp->WindW, Scale4Window, Scale4Window);
	} else {
		glScalef(Scale4Iconic * mp->WindH / mp->WindW, Scale4Iconic, Scale4Iconic);
	}

    {
      double x, y, z;
      get_rotation (mp->rot, &x, &y, &z, !mp->button_down_p);
      glRotatef (x * 360, 1.0, 0.0, 0.0);
      glRotatef (y * 360, 0.0, 1.0, 0.0);
      glRotatef (z * 360, 0.0, 0.0, 1.0);
    }

	/* moebius */
	if (!draw_moebius_strip(mi)) {
		release_moebius(mi);
		return;
	}

	glPopMatrix();

    if (MI_IS_FPS(mi)) do_fps (mi);
	glFlush();

	glXSwapBuffers(display, window);

	mp->step += 0.025;
}
开发者ID:davehorner,项目名称:XScreenSaverWin,代码行数:59,代码来源:moebius.c

示例2: userRot

static void
userRot(gfluxstruct *gp)
{
  /* Do it twice because we don't track the device's orientation. */
  glRotatef( current_device_rotation(), 0, 0, 1);
  gltrackball_rotate (gp->trackball);
  glRotatef(-current_device_rotation(), 0, 0, 1);
}
开发者ID:davehorner,项目名称:XScreenSaverWin,代码行数:8,代码来源:gflux.c

示例3: draw_jigglypuff

ENTRYPOINT void draw_jigglypuff(ModeInfo *mi)
{
    jigglystruct *js = &jss[MI_SCREEN(mi)];

    glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(js->glx_context));

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(0,0,-10);

    glRotatef(js->angle, sin(js->axis), cos(js->axis), -sin(js->axis));
    glTranslatef(0, 0, 5);
    if(!(js->button_down)) {
        if((js->angle += js->speed) >= 360.0f ) {
            js->angle -= 360.0f;
        }
        if((js->axis+=0.01f) >= 2*M_PI ) {
            js->axis -= 2*M_PI;
        }
    }

    /* Do it twice because we don't track the device's orientation. */
    glRotatef( current_device_rotation(), 0, 0, 1);
    gltrackball_rotate(js->trackball);
    glRotatef(-current_device_rotation(), 0, 0, 1);

    if(js->color_style == COLOR_STYLE_CYCLE) {
        int i;
        vector_add(js->jiggly_color, js->color_dir, js->jiggly_color);

        for(i=0; i<3; i++) {
            if(js->jiggly_color[i] > 1.0 || js->jiggly_color[i] < 0.3) {
                js->color_dir[i] = (-js->color_dir[i]);
                js->jiggly_color[i] += js->color_dir[i];
            }
        }
        glColor4fv(js->jiggly_color);
    }

    mi->polygon_count = jigglypuff_render(js);
    if(MI_IS_FPS(mi))
        do_fps(mi);
    glFinish();
    update_shape(js);
    glXSwapBuffers(MI_DISPLAY(mi), MI_WINDOW(mi));
}
开发者ID:rivy,项目名称:XScreenSaverWin,代码行数:48,代码来源:jigglypuff.c

示例4: reshape_spheremonics

/* Window management, etc
 */
ENTRYPOINT void
reshape_spheremonics (ModeInfo *mi, int width, int height)
{
    GLfloat h = (GLfloat) height / (GLfloat) width;

    glViewport (0, 0, (GLint) width, (GLint) height);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective (30.0, 1/h, 1.0, 100.0);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt( 0.0, 0.0, 30.0,
               0.0, 0.0, 0.0,
               0.0, 1.0, 0.0);

# ifdef HAVE_MOBILE	/* Keep it the same relative size when rotated. */
    {
        int o = (int) current_device_rotation();
        if (o != 0 && o != 180 && o != -180)
            glScalef (1/h, 1/h, 1/h);
    }

# endif
    glClear(GL_COLOR_BUFFER_BIT);
}
开发者ID:Ro6afF,项目名称:XScreenSaver,代码行数:29,代码来源:spheremonics.c

示例5: draw_bubble3d

ENTRYPOINT void
draw_bubble3d(ModeInfo * mi)
{
	struct context *c = &contexts[MI_SCREEN(mi)];
	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);

	MI_IS_DRAWN(mi) = True;

	if (!c->glx_context)
		return;

	glXMakeCurrent(display, window, *(c->glx_context));

        glb_config.polygon_count = 0;
        glPushMatrix();
        glRotatef(current_device_rotation(), 0, 0, 1);
	do_display(c);
        glPopMatrix();
        mi->polygon_count = glb_config.polygon_count;

        if (mi->fps_p) do_fps (mi);
	glFinish();
	glXSwapBuffers(display, window);
}
开发者ID:BuBuaBu,项目名称:bang-screensaver,代码行数:25,代码来源:b_lockglue.c

示例6: adjust_for_device_rotation

/* Device rotation interacts very strangely with mouse positions.
   I'm not entirely sure this is the right fix.
 */
static void
adjust_for_device_rotation (trackball_state *ts,
                            double *x, double *y, double *w, double *h)
{
  int rot = (int) current_device_rotation();
  int swap;

  if (ts->ignore_device_rotation_p) return;

  while (rot <= -180) rot += 360;
  while (rot >   180) rot -= 360;

  if (rot > 135 || rot < -135)		/* 180 */
    {
      *x = *w - *x;
      *y = *h - *y;
    }
  else if (rot > 45)			/* 90 */
    {
      swap = *x; *x = *y; *y = swap;
      swap = *w; *w = *h; *h = swap;
      *x = *w - *x;
    }
  else if (rot < -45)			/* 270 */
    {
      swap = *x; *x = *y; *y = swap;
      swap = *w; *w = *h; *h = swap;
      *y = *h - *y;
    }
}
开发者ID:Ro6afF,项目名称:XScreenSaver,代码行数:33,代码来源:gltrackball.c

示例7: reshape_slideshow

ENTRYPOINT void
reshape_slideshow (ModeInfo *mi, int width, int height)
{
  slideshow_state *ss = &sss[MI_SCREEN(mi)];
  GLfloat s;
  glViewport (0, 0, width, height);
  glMatrixMode (GL_PROJECTION);
  glLoadIdentity();
  glRotatef (current_device_rotation(), 0, 0, 1);
  glMatrixMode (GL_MODELVIEW);
  glLoadIdentity();

  s = 2;

  if (debug_p)
    {
      s *= (zoom / 100.0) * 0.75;
      if (s < 0.1) s = 0.1;
    }

  glScalef (s, s, s);
  glTranslatef (-0.5, -0.5, 0);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  ss->redisplay_needed_p = True;
}
开发者ID:MaddTheSane,项目名称:xscreensaver,代码行数:27,代码来源:glslideshow.c

示例8: draw_stars

static void
draw_stars (ModeInfo *mi)
{
  sws_configuration *sc = &scs[MI_SCREEN(mi)];

  glMatrixMode (GL_PROJECTION);
  glPushMatrix ();
  {
    glLoadIdentity ();

    glMatrixMode (GL_MODELVIEW);
    glPushMatrix ();
    {
      glLoadIdentity ();
      glOrtho (-0.5 * MI_WIDTH(mi),  0.5 * MI_WIDTH(mi),
               -0.5 * MI_HEIGHT(mi), 0.5 * MI_HEIGHT(mi),
               -100.0, 100.0);
      glRotatef (sc->star_theta, 0.0, 0.0, 1.0);
      if (textures_p) glDisable (GL_TEXTURE_2D);

      /* Keep the stars pointing in the same direction after rotation */
      glRotatef(current_device_rotation(), 0, 0, 1);

      glCallList (sc->star_list);
      if (textures_p) glEnable (GL_TEXTURE_2D);
    }
    glPopMatrix ();
  }
  glMatrixMode (GL_PROJECTION);
  glPopMatrix ();
}
开发者ID:davehorner,项目名称:XScreenSaverWin,代码行数:31,代码来源:starwars.c

示例9: reshape_ball

/* Window management, etc
 */
ENTRYPOINT void
reshape_ball (ModeInfo *mi, int width, int height)
{
  GLfloat h = (GLfloat) height / (GLfloat) width;
  int y = 0;

  if (width > height * 5) {   /* tiny window: show middle */
    height = width * 9/16;
    y = -height/2;
    h = height / (GLfloat) width;
  }

  glViewport (0, y, (GLint) width, (GLint) height);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective (30.0, 1/h, 1.0, 100.0);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  gluLookAt( 0.0, 0.0, 30.0,
             0.0, 0.0, 0.0,
             0.0, 1.0, 0.0);

# ifdef HAVE_MOBILE	/* Keep it the same relative size when rotated. */
  {
    int o = (int) current_device_rotation();
    if (o != 0 && o != 180 && o != -180)
      glScalef (1/h, 1/h, 1/h);
  }
# endif

  glClear(GL_COLOR_BUFFER_BIT);
}
开发者ID:MaddTheSane,项目名称:xscreensaver,代码行数:36,代码来源:discoball.c

示例10: draw_atlantis

/*
 *-----------------------------------------------------------------------------
 *    Called by the mainline code periodically to update the display.
 *-----------------------------------------------------------------------------
 */
ENTRYPOINT void
draw_atlantis(ModeInfo * mi)
{
	atlantisstruct *ap = &atlantis[MI_SCREEN(mi)];

	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);

	MI_IS_DRAWN(mi) = True;

	if (!ap->glx_context)
		return;

	glXMakeCurrent(display, window, *(ap->glx_context));

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        glPushMatrix();
        glRotatef(current_device_rotation(), 0, 0, 1);
        AllDisplay(ap);
        Animate(ap);
        glPopMatrix();

        if (mi->fps_p) do_fps (mi);
	glXSwapBuffers(display, window);
}
开发者ID:mmarseglia,项目名称:xscreensaver,代码行数:31,代码来源:atlantis.c

示例11: reshape_planet

ENTRYPOINT void
reshape_planet (ModeInfo *mi, int width, int height)
{
  planetstruct *gp = &planets[MI_SCREEN(mi)];
  GLfloat h = (GLfloat) height / (GLfloat) width;

  glXMakeCurrent(MI_DISPLAY(mi), gp->window, *gp->glx_context);

  glViewport(0, 0, (GLint) width, (GLint) height);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glFrustum(-1.0, 1.0, -h, h, 5.0, 200.0);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glTranslatef(0.0, 0.0, -40);

# ifdef HAVE_MOBILE	/* Keep it the same relative size when rotated. */
  {
    int o = (int) current_device_rotation();
    if (o != 0 && o != 180 && o != -180)
      glScalef (h, h, h);
  }
# endif

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
开发者ID:Zygo,项目名称:xscreensaver,代码行数:26,代码来源:glplanet.c

示例12: draw_ball

ENTRYPOINT void
draw_ball (ModeInfo *mi)
{
  ball_configuration *bp = &bps[MI_SCREEN(mi)];
  Display *dpy = MI_DISPLAY(mi);
  Window window = MI_WINDOW(mi);

  if (!bp->glx_context)
    return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));

  glShadeModel(GL_SMOOTH);

  glEnable(GL_DEPTH_TEST);
  glEnable(GL_NORMALIZE);
  glEnable(GL_CULL_FACE);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix ();

  glRotatef(current_device_rotation(), 0, 0, 1);

  {
    double x, y, z;
    get_position (bp->rot, &x, &y, &z, !bp->button_down_p);
    glTranslatef((x - 0.5) * 6,
                 (y - 0.5) * 6,
                 (z - 0.5) * 2);

    gltrackball_rotate (bp->trackball);

    get_rotation (bp->rot, &x, &y, &z, !bp->button_down_p);
    glRotatef (x * 360, 1.0, 0.0, 0.0);
    glRotatef (y * 360, 0.0, 1.0, 0.0);
    glRotatef (z * 360, 0.0, 0.0, 1.0);
  }

  mi->polygon_count = 0;

  glRotatef (50, 1, 0, 0);

  glScalef (4, 4, 4);
  glRotatef (bp->th, 0, 0, 1);
  if (! bp->button_down_p)
    {
      bp->th += (bp->th > 0 ? speed : -speed);
      while (bp->th >  360) bp->th -= 360;
      while (bp->th < -360) bp->th += 360;
    }

  mi->polygon_count += draw_ball_1 (mi);
  glPopMatrix ();

  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(dpy, window);
}
开发者ID:MaddTheSane,项目名称:xscreensaver,代码行数:60,代码来源:discoball.c

示例13: reshape_splitflap

/* Window management, etc
 */
ENTRYPOINT void
reshape_splitflap (ModeInfo *mi, int width, int height)
{
  GLfloat h = (GLfloat) height / (GLfloat) width;

  glViewport (0, 0, (GLint) width, (GLint) height);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective (40.0, 1/h, 0.5, 25);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  gluLookAt( 0, 0, 3,  /* 10x lower than traditional, for better depth rez */
             0, 0, 0,
             0, 1, 0);

# ifdef HAVE_MOBILE	/* Keep it the same relative size when rotated. */
  {
    int o = (int) current_device_rotation();
    if (o != 0 && o != 180 && o != -180)
      glScalef (h, h, h);
  }
# endif

  glClear(GL_COLOR_BUFFER_BIT);
}
开发者ID:Zygo,项目名称:xscreensaver,代码行数:29,代码来源:splitflap.c

示例14: draw_antinspect

ENTRYPOINT void draw_antinspect(ModeInfo * mi) 
{
  antinspectstruct *mp;
  
  Display    *display = MI_DISPLAY(mi);
  Window      window = MI_WINDOW(mi);
  
  if(!antinspect)
    return;
  mp = &antinspect[MI_SCREEN(mi)];
  
  MI_IS_DRAWN(mi) = True;
  
  if(!mp->glx_context)
	return;
  
  glXMakeCurrent(display, window, *(mp->glx_context));
  
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix();

  mi->polygon_count = 0;

  /* position camera --- this works well, we can peer inside 
     the antbubble */
  glTranslatef(0.0, 0.0, -10.0);

# ifdef HAVE_MOBILE	/* Keep it the same relative size when rotated. */
  {
    GLfloat h = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi);
    int o = (int) current_device_rotation();
    if (o != 0 && o != 180 && o != -180)
      glScalef (1/h, 1/h, 1/h);
    glRotatef(o, 0, 0, 1);
  }
# endif

  gltrackball_rotate(mp->trackball);
  glRotatef((15.0/2.0 + 15.0*sin(mp->ant_step/100.0)), 1.0, 0.0, 0.0);
  glRotatef(30.0, 1.0, 0.0, 0.0);
  glRotatef(180.0, 0.0, 1.0, 0.0);
  
  if (!draw_antinspect_strip(mi)) {
	MI_ABORT(mi);
	return;
  }
  
  glPopMatrix();
  
  if (MI_IS_FPS(mi)) do_fps (mi);
  glFlush();
  
  glXSwapBuffers(display, window);
  
  mp->step += 0.025;
}
开发者ID:MaddTheSane,项目名称:xscreensaver,代码行数:57,代码来源:antinspect.c

示例15: draw_jigglypuff

ENTRYPOINT void draw_jigglypuff(ModeInfo *mi)
{
    jigglystruct *js = &jss[MI_SCREEN(mi)];
    
    glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(js->glx_context));
    
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(0,0,-10);


# ifdef HAVE_MOBILE	/* Keep it the same relative size when rotated. */
    {
      GLfloat h = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi);
      int o = (int) current_device_rotation();
      if (o != 0 && o != 180 && o != -180)
        glScalef (1/h, 1/h, 1/h);
    }
# endif

    glRotatef(js->angle, sin(js->axis), cos(js->axis), -sin(js->axis));
    glTranslatef(0, 0, 5);
    if(!(js->button_down)) {
	if((js->angle += js->speed) >= 360.0f ) {
	    js->angle -= 360.0f;
	}
	if((js->axis+=0.01f) >= 2*M_PI ) {
	    js->axis -= 2*M_PI;
	}
    }

    gltrackball_rotate(js->trackball);

    if(js->color_style == COLOR_STYLE_CYCLE) {
	int i;
	vector_add(js->jiggly_color, js->color_dir, js->jiggly_color);
	
	for(i=0; i<3; i++) {
	    if(js->jiggly_color[i] > 1.0 || js->jiggly_color[i] < 0.3) {
		js->color_dir[i] = (-js->color_dir[i]);
		js->jiggly_color[i] += js->color_dir[i];
	    }
	}
	glColor4fv(js->jiggly_color);
    }
    
    mi->polygon_count = jigglypuff_render(js);
    if(MI_IS_FPS(mi))
	do_fps(mi);
    glFinish();
    update_shape(js);
    glXSwapBuffers(MI_DISPLAY(mi), MI_WINDOW(mi));
}
开发者ID:Ro6afF,项目名称:XScreenSaver,代码行数:55,代码来源:jigglypuff.c


注:本文中的current_device_rotation函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。