Esempio n. 1
0
void FPS_DrawToScreen(SDL_Surface *screen, int rs, int gs, int bs, int as)
{
  if(!isactive) 
  {
    if(FPSSurface)
    {
      SDL_FreeSurface(FPSSurface);
      FPSSurface = NULL;
    }
    return;
  }

  if(!FPSSurface)
  {
    FPSSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, box_width, box_height, 32, 0xFF << rs, 0xFF << gs, 0xFF << bs, 0xFF << as);
    FPSRect.w = box_width;
    FPSRect.h = box_height;
    FPSRect.x = FPSRect.y = 0;
  }

  char virtfps[64], drawnfps[64], blitfps[64];

  CalcFramerates(virtfps, drawnfps, blitfps, 64);

  SDL_FillRect(FPSSurface, NULL, MK_COLOR_A(FPSSurface, 0, 0, 0, 0x80));
  DrawTextTrans((uint32 *)FPSSurface->pixels, FPSSurface->pitch, FPSSurface->w, (UTF8*)virtfps, MK_COLOR_A(FPSSurface, 0xFF, 0xFF, 0xFF, 0xFF), FALSE, TRUE);
  DrawTextTrans((uint32 *)FPSSurface->pixels + 7 * (FPSSurface->pitch >> 2), FPSSurface->pitch, FPSSurface->w, (UTF8*)drawnfps, MK_COLOR_A(FPSSurface, 0xFF, 0xFF, 0xFF, 0xFF), FALSE, TRUE);
  DrawTextTrans((uint32 *)FPSSurface->pixels + 7 * 2 * (FPSSurface->pitch >> 2), FPSSurface->pitch, FPSSurface->w, (UTF8*)blitfps, MK_COLOR_A(FPSSurface, 0xFF, 0xFF, 0xFF, 0xFF), FALSE, TRUE);

  SDL_Rect drect;
  drect.x = 0;
  drect.y = 0;
  drect.w = FPSRect.w;
  drect.h = FPSRect.h;

  BlitRaw(FPSSurface, &FPSRect, &drect);
}
Esempio n. 2
0
// Called from main thread
void Netplay_MT_Draw(const MDFN_PixelFormat& pformat, const int32 screen_w, const int32 screen_h)
{
 if(!viewable) 
  return;

 if(!inputable)
 {
  if((int64)Time::MonoMS() >= (LastTextTime + PopupTime))
  {
   viewable = 0;
   return;
  }
 }
 NetConsole.ShowPrompt(inputable);
 //
 {
  const unsigned fontid = MDFN_GetSettingUI("netplay.console.font");
  const int32 lines = MDFN_GetSettingUI("netplay.console.lines");
  int32 scale = MDFN_GetSettingUI("netplay.console.scale");
  MDFN_Rect srect;
  MDFN_Rect drect;

  if(!scale)
   scale = std::min<int32>(std::max<int32>(1, screen_h / 500), std::max<int32>(1, screen_w / 500));

  srect.x = srect.y = 0;
  srect.w = screen_w / scale;
  srect.h = GetFontHeight(fontid) * lines;

  drect.x = 0;
  drect.y = screen_h - (srect.h * scale);
  drect.w = srect.w * scale;
  drect.h = srect.h * scale;

  BlitRaw(NetConsole.Draw(pformat, srect.w, srect.h, fontid), &srect, &drect);
 }
}
Esempio n. 3
0
void OpenGL_Blitter::BlitRaw(MDFN_Surface *surface, const MDFN_Rect *rect, const MDFN_Rect *dest_rect, const bool source_alpha)
{
 unsigned int tmpwidth;
 unsigned int tmpheight;

 if(SupportNPOT)
 {
  tmpwidth = rect->w;
  tmpheight = rect->h;
 }
 else
 {
  tmpwidth = round_up_pow2(rect->w);
  tmpheight = round_up_pow2(rect->h);
 }

 if(tmpwidth > MaxTextureSize || tmpheight > MaxTextureSize)
 {
  MDFN_Rect neo_rect;
  MDFN_Rect neo_dest_rect;

  for(int32 xseg = 0; xseg < rect->w; xseg += MaxTextureSize)
  {
   for(int32 yseg = 0; yseg < rect->h; yseg += MaxTextureSize)
   {
    neo_rect.x = rect->x + xseg;
    neo_rect.w = rect->w - xseg;

    if(neo_rect.w > MaxTextureSize)
     neo_rect.w = MaxTextureSize;

    neo_rect.y = rect->y + yseg;
    neo_rect.h = rect->h - yseg;

    if(neo_rect.h > MaxTextureSize)
     neo_rect.h = MaxTextureSize;

    neo_dest_rect.x = dest_rect->x + xseg * dest_rect->w / rect->w;
    neo_dest_rect.y = dest_rect->y + yseg * dest_rect->h / rect->h;
    neo_dest_rect.w = neo_rect.w * dest_rect->w / rect->w;
    neo_dest_rect.h = neo_rect.h * dest_rect->h / rect->h;
    BlitRaw(surface, &neo_rect, &neo_dest_rect, source_alpha);
   }
  }
 }
 else
 {
  // Don't move the source_alpha stuff out of this else { }, otherwise it will break the recursion necessary to work around maximum texture size limits.
  if(source_alpha)
  {
   p_glEnable(GL_BLEND);
   p_glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  }

  p_glBindTexture(GL_TEXTURE_2D, textures[3]);
  p_glPixelStorei(GL_UNPACK_ROW_LENGTH, surface->pitchinpix);

  p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tmpwidth, tmpheight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
  p_glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, rect->w, rect->h, PixelFormat, PixelType, surface->pixels + rect->x + rect->y * surface->pitchinpix);

  p_glBegin(GL_QUADS);

  p_glTexCoord2f(0.0f, 1.0f * rect->h / tmpheight);  // Bottom left of our picture.
  p_glVertex2f(dest_rect->x, dest_rect->y + dest_rect->h);

  p_glTexCoord2f((float)rect->w / tmpwidth, 1.0f * rect->h / tmpheight); // Bottom right of our picture.
  p_glVertex2f(dest_rect->x + dest_rect->w, dest_rect->y + dest_rect->h);

  p_glTexCoord2f((float)rect->w / tmpwidth, 0.0f);    // Top right of our picture.
  p_glVertex2f(dest_rect->x + dest_rect->w,  dest_rect->y);

  p_glTexCoord2f(0.0f, 0.0f);     // Top left of our picture.
  p_glVertex2f(dest_rect->x, dest_rect->y);

  p_glEnd();

  if(source_alpha)
  {
   p_glDisable(GL_BLEND);
  }
 }
}
Esempio n. 4
0
void DrawSaveStates(SDL_Surface *screen, double exs, double eys, int rs, int gs, int bs, int as)
{
 StateStatusStruct *tmps;

 if(StateShow < MDFND_GetTime())
 {
  if(PreviewSurface)
  {
   SDL_FreeSurface(PreviewSurface);
   PreviewSurface = NULL;
  }
  if(StateStatus)
  {
   if(StateStatus->gfx)
    free(StateStatus->gfx);
   free(StateStatus);
   StateStatus = NULL;
  }
 }

 if(MovieShow < MDFND_GetTime())
 {
  if(PreviewSurface)
  {
   SDL_FreeSurface(PreviewSurface);
   PreviewSurface = NULL;
  }
  if(MovieStatus)
  {
   if(MovieStatus->gfx)
    free(MovieStatus->gfx);
   free(MovieStatus);
   MovieStatus = NULL;
  }
 }

 tmps = MovieStatus;
 if(StateStatus)
  tmps = StateStatus;

 if(tmps)
 {
  if(PreviewSurface)
  {
   SDL_FreeSurface(PreviewSurface);
   PreviewSurface = NULL;
  }
  PreviewSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, tmps->w + 2, tmps->h + 2, 32, 0xFF << rs, 0xFF << gs, 0xFF << bs, 0xFF << as);
  PreviewRect.x = PreviewRect.y = 0;
  PreviewRect.w = tmps->w + 2;
  PreviewRect.h = tmps->h + 2;
  MDFN_DrawRectangleAlpha((uint32*)PreviewSurface->pixels, PreviewSurface->pitch >> 2, 0, 0, MK_COLOR_A(PreviewSurface, 0x00, 0x00, 0x9F, 0xFF), tmps->w + 2, tmps->h + 2);

  uint32 *psp = (uint32*)PreviewSurface->pixels;

  psp += PreviewSurface->pitch >> 2;
  psp++;

  if(tmps->gfx)
   for(int y = 0; y < tmps->h; y++)
   {
    memcpy(psp, tmps->gfx + y * tmps->pitch, tmps->w * sizeof(uint32));
    psp += PreviewSurface->pitch >> 2;
   }

  if(!TextSurface)
  {
   TextSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, 230, 40, 32, 0xFF << rs, 0xFF << gs, 0xFF << bs, 0xFF << as);
   SDL_SetColorKey(TextSurface, SDL_SRCCOLORKEY, 0);
   SDL_SetAlpha(TextSurface, SDL_SRCALPHA, 0);

   TextRect.x = TextRect.y = 0;
   TextRect.w = 230;
   TextRect.h = 40;
  }
  if(tmps == MovieStatus)
  {
   UTF8 text[256];

   if(tmps->current_movie > 0)
    trio_snprintf((char *)text, 256, _("-recording movie %d-"), tmps->current_movie-1);
   else if (tmps->current_movie < 0)
    trio_snprintf((char *)text, 256, _("-playing movie %d-"),-1 - tmps->current_movie);
   else
    trio_snprintf((char *)text, 256, _("-select movie-"));

   DrawStateMovieRow(TextSurface, tmps->status, tmps->current, tmps->recently_saved, text);
  }
  else
   DrawStateMovieRow(TextSurface, tmps->status, tmps->current, tmps->recently_saved, (UTF8 *)_("-select state-"));
 } 

 if(PreviewSurface)
 {
  SDL_Rect tdrect, drect;

  int meow = ((screen->w / CurGame->width) + 1) / 2;
  if(!meow) meow = 1;

  tdrect.w = TextRect.w * meow;
  tdrect.h = TextRect.h * meow;
  tdrect.x = (screen->w - tdrect.w) / 2;
  tdrect.y = screen->h - tdrect.h;

  BlitRaw(TextSurface, &TextRect, &tdrect);

  drect.w = PreviewRect.w * meow;
  drect.h = PreviewRect.h * meow;
  drect.x = (screen->w - drect.w) / 2;
  drect.y = screen->h - drect.h - tdrect.h - 4;

  BlitRaw(PreviewSurface, &PreviewRect, &drect);

 }

}