Show resize.cpp syntax highlighted
/***************************************************************************
resize.cpp - Resize render window
-------------------
begin : Mon Mar 13 2007
copyright : (C) 2007 by Arcadia Design srl
email : giancarlo.cherchi@arcadiadesign.it
***************************************************************************
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
***************************************************************************/
#define NEEDGDI
#define __NEED_VECTOR_INT
#include "device.h"
#include "framebuffertarget.h"
#include <neoengine/logstream.h>
using namespace std;
using namespace NeoEngine;
namespace NeoOGL
{
bool Device::Resize( const RenderWindow &rkWndData )
{
//Close();
m_kWindow.m_strWindowName = rkWndData.m_strWindowName;
m_kWindow.m_kResolution = rkWndData.m_kResolution;
m_kWindow.m_uiFsaa = rkWndData.m_uiFsaa;
if( m_kWindow.m_kResolution.m_uiBPP < 15 )
m_kWindow.m_kResolution.m_uiBPP = 16;
else if( m_kWindow.m_kResolution.m_uiBPP > 32 )
m_kWindow.m_kResolution.m_uiBPP = 32;
#ifdef WIN32
if( !rkWndData.m_hWnd )
#elif __APPLE__
if( !rkWndData.m_pWindow )
#elif POSIX
if( !rkWndData.m_Window )
#endif
{
neolog << LogLevel( DEBUG ) << "Resizing rendering window" << endl;
//m_kWindow.m_uiFlags |= RenderWindow::DEVICECREATED;
if( rkWndData.m_kCaps.IsSet( RenderCaps::FULLSCREEN ) )
m_kWindow.m_kCaps.Set( RenderCaps::FULLSCREEN );
#ifdef WIN32
RECT kRect;
kRect.left = 0;
kRect.top = 0;
kRect.right = m_kWindow.m_kResolution.m_uiWidth;
kRect.bottom = m_kWindow.m_kResolution.m_uiHeight;
if( !( m_kWindow.m_kCaps.IsSet( RenderCaps::FULLSCREEN ) ) )
{
AdjustWindowRect( &kRect, WS_OVERLAPPEDWINDOW, FALSE );
neolog << LogLevel( DEBUG ) << " rect [ " << kRect.left << " " << kRect.top << " -> " << kRect.right << " " << kRect.bottom << " ]" << endl;
}
/*
m_kWindow.m_hWnd = CreateWindowEx( m_kWindow.m_kCaps.IsSet( RenderCaps::FULLSCREEN ) ? WS_EX_TOPMOST : 0, NEOGLDEVICE_WINDOWCLASSNAME, m_kWindow.m_strWindowName.c_str(), ( !m_kWindow.m_kCaps.IsSet( RenderCaps::FULLSCREEN ) ? WS_OVERLAPPEDWINDOW : WS_POPUP ) | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, kRect.right - kRect.left, kRect.bottom - kRect.top, 0, 0, (HINSTANCE)m_kWindow.m_hInstance, this );
if( !m_kWindow.m_hWnd )
{
neolog << LogLevel( ERROR ) << "*** Unable to create window" << endl;
return false;
}
SetWindowLong( (HWND)m_kWindow.m_hWnd, GWL_USERDATA, (long)this );
SetForegroundWindow( (HWND)m_kWindow.m_hWnd );
//Store desktop resolution
HDC hDeskDC = GetDC( 0 );
m_kWindow.m_kDesktopResolution.m_uiWidth = GetDeviceCaps( hDeskDC, HORZRES );
m_kWindow.m_kDesktopResolution.m_uiHeight = GetDeviceCaps( hDeskDC, VERTRES );
m_kWindow.m_kDesktopResolution.m_uiBPP = GetDeviceCaps( hDeskDC, BITSPIXEL );
ReleaseDC( 0, hDeskDC );
*/
if( m_kWindow.m_kCaps.IsSet( RenderCaps::FULLSCREEN ) )
{
DEVMODE devMode;
memset( &devMode, 0, sizeof( DEVMODE ) );
devMode.dmSize = sizeof( DEVMODE );
devMode.dmDriverExtra = 0;
devMode.dmBitsPerPel = m_kWindow.m_kResolution.m_uiBPP;
devMode.dmPelsWidth = m_kWindow.m_kResolution.m_uiWidth;
devMode.dmPelsHeight = m_kWindow.m_kResolution.m_uiHeight;
devMode.dmDisplayFrequency = m_kWindow.m_kResolution.m_uiRefreshRate;
devMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
ChangeDisplaySettings( &devMode, CDS_FULLSCREEN | CDS_SET_PRIMARY );
}
#elif __APPLE__
if( !m_kWindow.m_kCaps.IsSet( RenderCaps::FULLSCREEN ) )
{
Rect rectSize =
{
50, // top offset to avoid menu bar
0,
m_kWindow.m_kResolution.m_uiHeight + 50,
m_kWindow.m_kResolution.m_uiWidth,
};
Str255 strTitle;
CopyCStringToPascal( m_kWindow.m_strWindowName.c_str(), strTitle );
m_kWindow.m_pWindow = NewCWindow( NULL, &rectSize, strTitle, true, kWindowFullZoomGrowDocumentProc, (WindowPtr)-1, true, 0 );
}
#elif POSIX
#endif
}
else
{
#ifdef WIN32
/*
if( !m_kWindow.m_hInstance && !( m_kWindow.m_hInstance = rkWndData.m_hInstance ) )
m_kWindow.m_hInstance = GetModuleHandle( 0 );
m_kWindow.m_hWnd = rkWndData.m_hWnd;
if( !( m_kWindow.m_uiFlags & RenderWindow::USEDIMENSIONS ) )
{
RECT rcWndSize;
GetClientRect( (HWND)m_kWindow.m_hWnd, &rcWndSize );
m_kWindow.m_kResolution.m_uiWidth = rcWndSize.right - rcWndSize.left;
m_kWindow.m_kResolution.m_uiHeight = rcWndSize.bottom - rcWndSize.top;
}
*/
#elif __APPLE__
m_kWindow.m_pWindow = rkWndData.m_pWindow;
#elif POSIX
#endif
}
#ifdef WIN32
// ShowWindow( (HWND)m_kWindow.m_hWnd, SW_NORMAL );
#elif __APPLE__
#elif POSIX
#endif
SetViewport( 0, 0, GetWidth(), GetHeight() );
//return Initialize( &rkWndData.m_kCaps );
return true;
}
};
See more files for this project here