Example #1
0
/*!***************************************************************************
 @Function			SetWindowFlags
 @Input				dwWin				Window handle
 @Input				dwFlags				Flags
 @Description		Set flags for window referenced by dwWin.
					A list of flag can be found at the top of this header.
*****************************************************************************/
void CPVRTPrint3D::SetWindowFlags(unsigned int dwWin, unsigned int dwFlags)
{
#if !defined (DISABLE_PRINT3D)

	/* Check if there is need of updating vertex buffers */
	if(	dwFlags & ePVRTPrint3D_ACTIVATE_TITLE ||
		dwFlags & ePVRTPrint3D_DEACTIVATE_TITLE ||
		dwFlags & ePVRTPrint3D_ADJUST_SIZE_ALWAYS)
		m_pWin[dwWin].bNeedUpdated = true;

	/* Set window flags */
	if (dwFlags & ePVRTPrint3D_ACTIVATE_WIN)		m_pWin[dwWin].dwFlags |= Print3D_WIN_ACTIVE;
	if (dwFlags & ePVRTPrint3D_DEACTIVATE_WIN)	m_pWin[dwWin].dwFlags &= ~Print3D_WIN_ACTIVE;
	if (dwFlags & ePVRTPrint3D_ACTIVATE_TITLE)	m_pWin[dwWin].dwFlags |= Print3D_WIN_TITLE;
	if (dwFlags & ePVRTPrint3D_DEACTIVATE_TITLE) m_pWin[dwWin].dwFlags &= ~Print3D_WIN_TITLE;
	if (dwFlags & ePVRTPrint3D_FULL_OPAQUE)		m_pWin[dwWin].dwFlags |= Print3D_FULL_OPAQUE;
	if (dwFlags & ePVRTPrint3D_FULL_TRANS)		m_pWin[dwWin].dwFlags |= Print3D_FULL_TRANS;

	if (dwFlags & ePVRTPrint3D_ADJUST_SIZE_ALWAYS)
	{
		m_pWin[dwWin].dwFlags |= Print3D_ADJUST_SIZE;
		AdjustWindowSize(dwWin, 0);
	}

	if (dwFlags & ePVRTPrint3D_NO_BORDER)	m_pWin[dwWin].dwFlags |= Print3D_NO_BORDER;

#endif
}
Example #2
0
static void I_ToggleFullScreen(void)
{
    unsigned int flags = 0;

    // TODO: Consider implementing fullscreen toggle for SDL_WINDOW_FULLSCREEN
    // (mode-changing) setup. This is hard because we have to shut down and
    // restart again.
    if (fullscreen_width != 0 || fullscreen_height != 0)
    {
        return;
    }

    fullscreen = !fullscreen;

    if (fullscreen)
    {
        flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
    }

    SDL_SetWindowFullscreen(screen, flags);

    if (!fullscreen)
    {
        AdjustWindowSize();
        SDL_SetWindowSize(screen, window_width, window_height);
    }
}
Example #3
0
void CRaster::OnSize(UINT nType, int cx, int cy)                    // REQ #050
   {                                                                // REQ #050
    CFormView::OnSize(nType, cx, cy);                               // REQ #050// REQ #054
                                                                    // REQ #050
    if(c_Unmagnified.GetSafeHwnd() != NULL &&                       // REQ #050
       c_Sample.GetSafeHwnd() != NULL)                              // REQ #050
       { /* resize sample */                                        // REQ #050
        AdjustWindowSize(cx, cy);                                   // REQ #052
       } /* resize sample */                                        // REQ #050
   }                                                                // REQ #050
Example #4
0
void CRaster::setNewFont()
    {
     if(!initialized)
        return;

     CString newname;

     c_Fonts.GetWindowText(newname);  // get new font name

     CFont * font = c_Sample.GetFont();

     if(font == NULL)                                               // REQ #052
         font = CFont::FromHandle((HFONT)::GetStockObject(SYSTEM_FONT));// REQ #052
                                                                    // REQ #052
     LOGFONT lf;                                                    // REQ #052
     font->GetLogFont(&lf);                                         // REQ #052
     lf.lfWidth = 0;                                                // REQ #052

     int size;
     if(c_Raster.GetCheck() == BST_CHECKED)                         // REQ #052
        { /* raster */                                              // REQ #052
         size = (int)c_FontSize.GetItemData(c_FontSize.GetCurSel());// REQ #006// REQ #052
        } /* raster */                                              // REQ #052
     else                                                           // REQ #052
        { /* scaled */                                              // REQ #052
         size = (int)c_SpinScaledHeight.GetPos32();                 // REQ #052
        } /* scaled */                                              // REQ #052

     BYTE newquality = (BYTE)c_Quality.GetItemData(c_Quality.GetCurSel());// REQ #071

     if(lstrcmp(lf.lfFaceName, newname) != 0 || size != lf.lfHeight ||
        lf.lfQuality != newquality)                                 // REQ #071
        { /* need new font */
         lf.lfHeight = size;
         lstrcpy(lf.lfFaceName, newname);

         lf.lfQuality = newquality;                                 // REQ #071

         CFont newfont;
         if(newfont.CreateFontIndirect(&lf))
            { /* success */
             c_Sample.SetFont(&newfont);
             c_Unmagnified.SetFont(&newfont);                       // REQ #052
             c_Sample.Invalidate();                                 // REQ #071
             c_Unmagnified.Invalidate();                            // REQ #071
             TRACE(_T(__FUNCTION__) _T(": DeleteObject(font=%p)\n"), font->m_hObject);// REQ #021
             font->DeleteObject();
             newfont.Detach();

             CRect client;                                          // REQ #050
             GetClientRect(&client);                                // REQ #050
             AdjustWindowSize(client.Width(), client.Height());     // REQ #050
            } /* success */
        } /* need new font */
    }
Example #5
0
////////////////////////////////////////////////////////////
// TBitmap256Control
// -----------------
//
void TBitmap256Control::SetupWindow ()
{
	TControl::SetupWindow();

	// TRect cRect = GetClientRect ();
	// MaxWidth = cRect.Width ();
	// MaxHeight = cRect.Height ();

	// Set window size to maximum (since no bitmap selected yet)
	AdjustWindowSize();
}
Example #6
0
    Window::Window(const string& title, U32 width, U32 height) {
        U32 styleFlags =  WS_OVERLAPPED | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU;// | WS_THICKFRAME;

        AdjustWindowSize(styleFlags, &width, &height);

        this->width = width;
        this->height = height;
        isClosed = false;
        isMinimized = false;
        isInactive = false;

        HINSTANCE instanceHandle = (HINSTANCE)GetModuleHandle(NULL);
        WNDCLASS wc;

        wc.style         = CS_DBLCLKS;
        wc.lpfnWndProc   = (WNDPROC) Window::StaticWndProc;
        wc.cbClsExtra    = 0;
        wc.cbWndExtra    = 0;
        wc.hInstance     = instanceHandle;
        wc.hIcon         = LoadIcon(0, IDI_APPLICATION);
        wc.hCursor       = LoadCursorFromFile("..//Data//Cursors//arrow.cur");
        wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
        wc.lpszMenuName  = 0;
        wc.lpszClassName = "MainWinWindowClass";

        if (!RegisterClass(&wc)) {
            throw WinException(GetLastError());
        }

        // Create window instance

        handle = CreateWindow("MainWinWindowClass",                 // Registered WNDCLASS instance to use.
                                title.c_str(),                      // window title
                                styleFlags,                         // style flags
                                CW_USEDEFAULT,                      // x-coordinate
                                CW_USEDEFAULT,                      // y-coordinate
                                width,                              // width
                                height,                             // height
                                0,                                  // parent window
                                0,                                  // menu handle
                                instanceHandle,                     // app instance
                                0);

        if (!handle) {
            throw WinException(GetLastError());
        }

        SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)this);

        // Show window

        ShowWindow(handle, true);
        UpdateWindow(handle);
    }
Example #7
0
////////////////////////////////////////////////////////////
// TBitmap256Control
// -----------------
//  Select a new bitmap in the control. First build the bitmap
//  data by calling the virtual function BuildBitmapData, then
//  calc. the bitmap palette and create the bitmap GDI object.
//  Then call AdjustWindowSize and DisplayBitmap.
void TBitmap256Control::SelectBitmap (const char *name, SHORT remapPlayer, int palnum)
{
   char buf[MAX_PATH];
   
   assert(pUsedColors != NULL);
   
   // Save GDI object and set WAIT cursor
   SELECT_WAIT_CURSOR();
   
   // Free all previous bitmap ressources
   if ( pBitmapData != NULL )	FreeMemory (pBitmapData);
   if ( pDIBInfo != NULL )		FreeMemory (pDIBInfo);
   delete pBitmapPalette;
   pBitmapPalette = NULL;
   
   // Copy name of the new bitmap
   strcpy(BitmapName, name);
   
   // Delete array of used color entry
   pUsedColors[0] = TRUE; // always use BLACK (for background)
   for (int i = 1; i < 256 ; i++)
      pUsedColors[i] = FALSE;
   
   // call virtual function of derived class to build bitmap data
   // TRACE ("TBitmap256Controll::SelectBitmap(): call BuildBitmapData");
   sprintf(buf, "%s\\%s", BitmapDir, name);
   BuildBitmapData (buf, remapPlayer);
   
   // Maybe there's no bitmap! (EX: sounds in heretic)
   if ( pBitmapData != NULL )
   {
      // Load DOOM palette asked
      LoadDoomPalette (palnum);
      
      // Create logical palette of used colors
      BuildBitmapPalette ();
      
      // Build bitmap GDI object
      BuildBitmap ();
   }
   
   // Adjust window size and scroller range, and display bitmap
   AdjustWindowSize ();
   Invalidate();
   UpdateWindow();     // Repaint NOW!
   
   // Restore cursor
   UNSELECT_WAIT_CURSOR();
}
Example #8
0
void Mapviz::SetResizable(bool on)
{
  if (resizable_ != on)
  {
    resizable_ = on;

    if (resizable_)
    {
      force_720p_ = false;
      force_480p_ = false;
    }

    AdjustWindowSize();
  }
}
Example #9
0
void Mapviz::Force480p(bool on)
{
  if (force_480p_ != on)
  {
    force_480p_ = on;

    if (force_480p_)
    {
      force_720p_ = false;
      resizable_ = false;
    }

    AdjustWindowSize();
  }
}
Example #10
0
////////////////////////////////////////////////////////////
// TBitmap256Control
// -----------------
//  Change the zoom factor
void
TBitmap256Control::SetZoomFactor (UINT factor)
{
	if (factor < 1 || factor > 16)
		return;

	if ( factor == ZoomFactor )
		return;

	ZoomFactor = factor;
	GlobalZoom = ZoomFactor;	// Global to save between calls

	if ( pDIBInfo != NULL )
	{
		AdjustWindowSize();
		Invalidate(FALSE);
		UpdateWindow();     // Repaint NOW!
	}
}
Example #11
0
/*!***************************************************************************
 @Function			SetText
 @Input				dwWin		Window handle
 @Input				Format		Format string
 @Return			PVR_SUCCESS or PVR_FAIL
 @Description		Feed the text buffer of window referenced by dwWin.
					This function accepts formatting in the printf way.
*****************************************************************************/
EPVRTError CPVRTPrint3D::SetText(unsigned int dwWin, const char * const Format, ...)
{
#if !defined (DISABLE_PRINT3D)

	va_list			args;
	unsigned int			i;
	unsigned int			dwBufferSize, dwTotalLength = 0;
	unsigned int			dwPosBx, dwPosBy, dwSpcPos;
	char			bChar;
	unsigned int			dwCursorPos;
	static char	sText[MAX_LETTERS+1];

	/* If window doesn't exist then return from function straight away */
	if (!(m_pWin[dwWin].dwFlags & Print3D_WIN_EXIST))
		return PVR_FAIL;

	// Empty the window buffer
	memset(m_pWin[dwWin].pTextBuffer, 0, m_pWin[dwWin].dwBufferSizeX * m_pWin[dwWin].dwBufferSizeY * sizeof(char));

	/* Reading the arguments to create our Text string */
	va_start(args,Format);
#if defined(__SYMBIAN32__) || defined(UITRON) || defined(_UITRON_)
	vsprintf(sText, Format, args);
#else
	vsnprintf(sText, MAX_LETTERS+1, Format, args);
#endif
	va_end(args);

	dwCursorPos	= 0;

	m_pWin[dwWin].bNeedUpdated = true;

	/* Compute buffer size */
	dwBufferSize = (m_pWin[dwWin].dwBufferSizeX+1) * (m_pWin[dwWin].dwBufferSizeY+1);

	/* Compute length */
	while(dwTotalLength < dwBufferSize && sText[dwTotalLength] != 0)
		dwTotalLength++;

	/* X and Y pointer position */
	dwPosBx = 0;
	dwPosBy = 0;

	/* Process each character */
	for (i=0; i<dwTotalLength; i++)
	{
		/* Get current character in string */
		bChar = sText[i];

		/* Space (for word wrap only) */
		if (bChar == ' ')
		{
			/* Looking for the next space (or return or end) */
			dwSpcPos = 1;
			do
			{
				bChar = sText[i + dwSpcPos++];
			}
			while (bChar==' ' || bChar==0x0A || bChar==0);
			bChar = ' ';

			/*
				Humm, if this word is longer than the buffer don't move it.
				Otherwise check if it is at the end and create a return.
			*/
			if (dwSpcPos<m_pWin[dwWin].dwBufferSizeX && (dwPosBx+dwSpcPos)>m_pWin[dwWin].dwBufferSizeX)
			{
				/* Set NULL character */
				m_pWin[dwWin].pTextBuffer[dwCursorPos++] = 0;

				dwPosBx = 0;
				dwPosBy++;

				/* Set new cursor position */
				dwCursorPos = dwPosBy * m_pWin[dwWin].dwBufferSizeX;

				/* Don't go any further */
				continue;
			}
		}

		/* End of line */
		if (dwPosBx == (m_pWin[dwWin].dwBufferSizeX-1))
		{
			m_pWin[dwWin].pTextBuffer[dwCursorPos++] = 0;
			dwPosBx = 0;
			dwPosBy++;
		}

		/* Vertical Scroll */
		if (dwPosBy >= m_pWin[dwWin].dwBufferSizeY)
		{
			memcpy(m_pWin[dwWin].pTextBuffer,
				m_pWin[dwWin].pTextBuffer + m_pWin[dwWin].dwBufferSizeX,
				(m_pWin[dwWin].dwBufferSizeX-1) * m_pWin[dwWin].dwBufferSizeY);

			dwCursorPos -= m_pWin[dwWin].dwBufferSizeX;

			dwPosBx = 0;
			dwPosBy--;
		}

		/* Return */
		if (bChar == 0x0A)
		{
			/* Set NULL character */
			m_pWin[dwWin].pTextBuffer[dwCursorPos++] = 0;

			dwPosBx = 0;
			dwPosBy++;

			dwCursorPos = dwPosBy * m_pWin[dwWin].dwBufferSizeX;

			/* Don't go any further */
			continue;
		}

		/* Storing our character */
		if (dwCursorPos<dwBufferSize)
		{
			m_pWin[dwWin].pTextBuffer[dwCursorPos++] = bChar;
		}

		/* Increase position */
		dwPosBx++;
	}

	/* Automatic adjust of the window size */
	if (m_pWin[dwWin].dwFlags & Print3D_ADJUST_SIZE)
	{
		AdjustWindowSize(dwWin, 0);
	}

#endif

	return PVR_SUCCESS;
}
Example #12
0
//
// I_FinishUpdate
//
void I_FinishUpdate (void)
{
    static int lasttic;
    int tics;
    int i;

    if (!initialized)
        return;

    if (noblit)
        return;

    if (need_resize)
    {
        if (SDL_GetTicks() > last_resize_time + RESIZE_DELAY)
        {
            int flags;
            // When the window is resized (we're not in fullscreen mode),
            // save the new window size.
            flags = SDL_GetWindowFlags(screen);
            if ((flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == 0)
            {
                SDL_GetWindowSize(screen, &window_width, &window_height);

                // Adjust the window by resizing again so that the window
                // is the right aspect ratio.
                AdjustWindowSize();
                SDL_SetWindowSize(screen, window_width, window_height);
            }
            CreateUpscaledTexture(false);
            need_resize = false;
            palette_to_set = true;
        }
        else
        {
            return;
        }
    }

    UpdateGrab();

#if 0 // SDL2-TODO
    // Don't update the screen if the window isn't visible.
    // Not doing this breaks under Windows when we alt-tab away 
    // while fullscreen.

    if (!(SDL_GetAppState() & SDL_APPACTIVE))
        return;
#endif

    // draws little dots on the bottom of the screen

    if (display_fps_dots)
    {
	i = I_GetTime();
	tics = i - lasttic;
	lasttic = i;
	if (tics > 20) tics = 20;

	for (i=0 ; i<tics*4 ; i+=4)
	    I_VideoBuffer[ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0xff;
	for ( ; i<20*4 ; i+=4)
	    I_VideoBuffer[ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0x0;
    }

    // Draw disk icon before blit, if necessary.
    V_DrawDiskIcon();

    if (palette_to_set)
    {
        SDL_SetPaletteColors(screenbuffer->format->palette, palette, 0, 256);
        palette_to_set = false;

        if (vga_porch_flash)
        {
            // "flash" the pillars/letterboxes with palette changes, emulating
            // VGA "porch" behaviour (GitHub issue #832)
            SDL_SetRenderDrawColor(renderer, palette[0].r, palette[0].g,
                palette[0].b, SDL_ALPHA_OPAQUE);
        }
    }

    // Blit from the paletted 8-bit screen buffer to the intermediate
    // 32-bit RGBA buffer that we can load into the texture.

    SDL_LowerBlit(screenbuffer, &blit_rect, argbbuffer, &blit_rect);

    // Update the intermediate texture with the contents of the RGBA buffer.

    SDL_UpdateTexture(texture, NULL, argbbuffer->pixels, argbbuffer->pitch);

    // Make sure the pillarboxes are kept clear each frame.

    SDL_RenderClear(renderer);

    // Render this intermediate texture into the upscaled texture
    // using "nearest" integer scaling.

    SDL_SetRenderTarget(renderer, texture_upscaled);
    SDL_RenderCopy(renderer, texture, NULL, NULL);

    // Finally, render this upscaled texture to screen using linear scaling.

    SDL_SetRenderTarget(renderer, NULL);
    SDL_RenderCopy(renderer, texture_upscaled, NULL, NULL);

    // Draw!

    SDL_RenderPresent(renderer);

    // Restore background and undo the disk indicator, if it was drawn.
    V_RestoreDiskBackground();
}
Example #13
0
void I_InitGraphics(void)
{
    SDL_Event dummy;
    byte *doompal;
    char *env;

    // Pass through the XSCREENSAVER_WINDOW environment variable to 
    // SDL_WINDOWID, to embed the SDL window into the Xscreensaver
    // window.

    env = getenv("XSCREENSAVER_WINDOW");

    if (env != NULL)
    {
        char winenv[30];
        int winid;

        sscanf(env, "0x%x", &winid);
        M_snprintf(winenv, sizeof(winenv), "SDL_WINDOWID=%i", winid);

        putenv(winenv);
    }

    SetSDLVideoDriver();

    if (SDL_Init(SDL_INIT_VIDEO) < 0) 
    {
        I_Error("Failed to initialize video: %s", SDL_GetError());
    }

    // When in screensaver mode, run full screen and auto detect
    // screen dimensions (don't change video mode)
    if (screensaver_mode)
    {
        fullscreen = true;
    }

    if (aspect_ratio_correct == 1)
    {
        actualheight = SCREENHEIGHT_4_3;
    }
    else
    {
        actualheight = SCREENHEIGHT;
    }

    // Create the game window; this may switch graphic modes depending
    // on configuration.
    AdjustWindowSize();
    SetVideoMode();

    // Start with a clear black screen
    // (screen will be flipped after we set the palette)

    SDL_FillRect(screenbuffer, NULL, 0);

    // Set the palette

    doompal = W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE);
    I_SetPalette(doompal);
    SDL_SetPaletteColors(screenbuffer->format->palette, palette, 0, 256);

    // SDL2-TODO UpdateFocus();
    UpdateGrab();

    // On some systems, it takes a second or so for the screen to settle
    // after changing modes.  We include the option to add a delay when
    // setting the screen mode, so that the game doesn't start immediately
    // with the player unable to see anything.

    if (fullscreen && !screensaver_mode)
    {
        SDL_Delay(startup_delay);
    }

    // The actual 320x200 canvas that we draw to. This is the pixel buffer of
    // the 8-bit paletted screen buffer that gets blit on an intermediate
    // 32-bit RGBA screen buffer that gets loaded into a texture that gets
    // finally rendered into our window or full screen in I_FinishUpdate().

    I_VideoBuffer = screenbuffer->pixels;
    V_RestoreBuffer();

    // Clear the screen to black.

    memset(I_VideoBuffer, 0, SCREENWIDTH * SCREENHEIGHT * sizeof(*I_VideoBuffer));

    // clear out any events waiting at the start and center the mouse
  
    while (SDL_PollEvent(&dummy));

    initialized = true;

    // Call I_ShutdownGraphics on quit

    I_AtExit(I_ShutdownGraphics, true);
}
Example #14
0
void I_GraphicsCheckCommandLine(void)
{
    int i;

    //!
    // @category video
    // @vanilla
    //
    // Disable blitting the screen.
    //

    noblit = M_CheckParm ("-noblit");

    //!
    // @category video 
    //
    // Don't grab the mouse when running in windowed mode.
    //

    nograbmouse_override = M_ParmExists("-nograbmouse");

    // default to fullscreen mode, allow override with command line
    // nofullscreen because we love prboom

    //!
    // @category video 
    //
    // Run in a window.
    //

    if (M_CheckParm("-window") || M_CheckParm("-nofullscreen"))
    {
        fullscreen = false;
    }

    //!
    // @category video 
    //
    // Run in fullscreen mode.
    //

    if (M_CheckParm("-fullscreen"))
    {
        fullscreen = true;
    }

    //!
    // @category video 
    //
    // Disable the mouse.
    //

    nomouse = M_CheckParm("-nomouse") > 0;

    //!
    // @category video
    // @arg <x>
    //
    // Specify the screen width, in pixels. Implies -window.
    //

    i = M_CheckParmWithArgs("-width", 1);

    if (i > 0)
    {
        window_width = atoi(myargv[i + 1]);
        window_height = window_width * 2;
        AdjustWindowSize();
        fullscreen = false;
    }

    //!
    // @category video
    // @arg <y>
    //
    // Specify the screen height, in pixels. Implies -window.
    //

    i = M_CheckParmWithArgs("-height", 1);

    if (i > 0)
    {
        window_height = atoi(myargv[i + 1]);
        window_width = window_height * 2;
        AdjustWindowSize();
        fullscreen = false;
    }

    //!
    // @category video
    // @arg <WxY>
    //
    // Specify the dimensions of the window. Implies -window.
    //

    i = M_CheckParmWithArgs("-geometry", 1);

    if (i > 0)
    {
        int w, h, s;

        s = sscanf(myargv[i + 1], "%ix%i", &w, &h);
        if (s == 2)
        {
            window_width = w;
            window_height = h;
            fullscreen = false;
        }
    }

    //!
    // @category video
    //
    // Don't scale up the screen. Implies -window.
    //

    if (M_CheckParm("-1")) 
    {
        SetScaleFactor(1);
    }

    //!
    // @category video
    //
    // Double up the screen to 2x its normal size. Implies -window.
    //

    if (M_CheckParm("-2")) 
    {
        SetScaleFactor(2);
    }

    //!
    // @category video
    //
    // Double up the screen to 3x its normal size. Implies -window.
    //

    if (M_CheckParm("-3")) 
    {
        SetScaleFactor(3);
    }
}