Esempio n. 1
0
File: spfx.c Progetto: zid/naev
/**
 * @brief Indicates the end of the spfx loop.
 *
 * Should be called before the HUD.
 */
void spfx_end (void)
{
   GLdouble bx, by, x, y;

   /* Save cycles. */
   if (shake_off == 1)
      return;

   /* set defaults */
   bx = SCREEN_W/2;
   by = SCREEN_H/2;

   /* shake stuff */
   if (!paused) {
      x = shake_pos.x;
      y = shake_pos.y;  
   }
   else {
      x = 0.;
      y = 0.;
   }

   /* set the new viewport */
   gl_defViewport();
}
Esempio n. 2
0
File: spfx.c Progetto: Arakash/naev
/**
 * @brief Indicates the end of the spfx loop.
 *
 * Should be called before the HUD.
 */
void spfx_end (void)
{
   /* Save cycles. */
   if (shake_off == 1)
      return;

   /* set the new viewport */
   gl_defViewport();
}
Esempio n. 3
0
File: toolkit.c Progetto: Delll/naev
/**
 * @brief Creates a window.
 *
 *    @param name Name of the window to create.
 *    @param x X position of the window (-1 centers).
 *    @param y Y position of the window (-1 centers).
 *    @param w Width of the window (-1 fullscreen).
 *    @param h Height of the window (-1 fullscreen).
 *    @return Newly created window's ID.
 */
unsigned int window_create( const char* name,
      const int x, const int y, const int w, const int h )
{
   Window *wcur, *wlast, *wdw;

   /* Allocate memory. */
   wdw = malloc( sizeof(Window) );
   memset( wdw, 0, sizeof(Window) );

   const int wid = (++genwid); /* unique id */

   /* Create the window. */

   wdw->id           = wid;
   wdw->name         = strdup(name);

   /* Sane defaults. */
   wdw->idgen        = -1;
   wdw->focus        = -1;

   /* Dimensions. */
   wdw->w            = (w == -1) ? SCREEN_W : (double) w;
   wdw->h            = (h == -1) ? SCREEN_H : (double) h;
   if ((w == -1) && (h == -1)) {
      window_setFlag( wdw, WINDOW_FULLSCREEN );
      wdw->x = 0.;
      wdw->y = 0.;
   }
   else {
      /* x pos */
      if (x==-1) /* center */
         wdw->x = (SCREEN_W - wdw->w)/2.;
      else if (x < 0)
         wdw->x = SCREEN_W - wdw->w + (double) x;
      else wdw->x = (double) x;
      /* y pos */
      if (y==-1) /* center */
         wdw->y = (SCREEN_H - wdw->h)/2.;
      else if (y < 0)
         wdw->y = SCREEN_H - wdw->h + (double) y;
      else wdw->y = (double) y;
   }

   if (toolkit_open==0) { /* toolkit is on */
      SDL_ShowCursor(SDL_ENABLE);
      toolkit_open = 1; /* enable toolkit */
      pause_game();
      gl_defViewport(); /* Reset the default viewport */
   }

   /* Clear key repeat. */
   toolkit_clearKey();

   /* Add to list. */
   wdw->next = NULL;
   if (windows == NULL)
      windows = wdw;
   else {
      for (wcur = windows; wcur != NULL; wcur = wcur->next)
         wlast = wcur;
      wlast->next = wdw;
   }

   return wid;
}
Esempio n. 4
0
File: opengl.c Progetto: Dinth/naev
/**
 * @brief Initializes SDL/OpenGL and the works.
 *    @return 0 on success.
 */
int gl_init (void)
{
   unsigned int flags;
   int dw, dh;

   /* Defaults. */
   dw = gl_screen.desktop_w;
   dh = gl_screen.desktop_h;
   memset( &gl_screen, 0, sizeof(gl_screen) );
   flags  = SDL_OPENGL;
   gl_screen.desktop_w = dw;
   gl_screen.desktop_h = dh;

   /* Load configuration. */
   if (conf.vsync)
      gl_screen.flags |= OPENGL_VSYNC;
   gl_screen.w = conf.width;
   gl_screen.h = conf.height;
   gl_setScale( conf.scalefactor );
   if (conf.fullscreen) {
      gl_screen.flags |= OPENGL_FULLSCREEN;
      flags |= SDL_FULLSCREEN;
   }

   /* Initializes Video */
   if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
      WARN("Unable to initialize SDL Video: %s", SDL_GetError());
      return -1;
   }

   /* Set opengl flags. */
   gl_setupAttributes();

   /* See if should set up fullscreen. */
   if (conf.fullscreen)
      gl_setupFullscreen( &flags );

   /* Create the window. */
   gl_createWindow( flags );

   /* Some OpenGL options. */
   glClearColor( 0., 0., 0., 1. );

   /* Set default opengl state. */
   gl_defState();

   /* Set up possible scaling. */
   gl_setupScaling();

   /* Handle setting the default viewport. */
   gl_setDefViewport( 0, 0, gl_screen.rw, gl_screen.rh );
   gl_defViewport();

   /* Finishing touches. */
   glClear( GL_COLOR_BUFFER_BIT ); /* must clear the buffer first */
   gl_checkErr();

   /* Load extensions. */
   gl_initExtensions();

   /* Start hinting. */
   gl_hint();

   /* Initialize subsystems.*/
   gl_initMatrix();
   gl_initTextures();
   gl_initVBO();
   gl_initRender();

   /* Get info about the OpenGL window */
   gl_getGLInfo();

   /* Cosmetic new line. */
   DEBUG("");

   return 0;
}