Code Search for Developers
 
 
  

resize.cpp from NeoEngineNG at Krugle


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

NeoEngineNG

NeoenEngine NG (Next Generation) is the evolution of neoengine one,it\'s a different development from NeoEngine2, it\'s a direct inherits from NeoEngine one.\n

Project homepage: http://sourceforge.net/projects/neoengineng
Programming language(s): C,C++
License: other

  glew/
    bin/
      glew32.dll
      glewinfo.exe
      visualinfo.exe
    doc/
      advanced.html
      basic.html
      credits.html
      glew.css
      glew.html
      glew.png
      glx.txt
      glxew.html
      gpl.txt
      index.html
      install.html
      log.html
      new.png
      ogl_sm.jpg
      sgi.txt
      wglew.html
    include/
      GL/
    lib/
      glew32.lib
      glew32s.lib
  Makefile.am
  SConscript
  base.h
  begin.cpp
  buffermanager.cpp
  buffermanager.h
  bufferregion.cpp
  bufferregion.h
  callback.cpp
  clear.cpp
  close.cpp
  config.cpp
  device.cpp
  device.h
  end.cpp
  execute.cpp
  extensions.cpp
  extensions.h
  flip.cpp
  framebuffertarget.cpp
  framebuffertarget.h
  glext.h
  glue.cpp
  glxext.h
  initialize.cpp
  input.cpp
  light.cpp
  link.h
  mouse.cpp
  neodevopengl-static.dev
  neodevopengl.cbp
  neodevopengl.depend
  neodevopengl.dev
  neodevopengl.dsp
  neodevopengl.layout
  neodevopengl.vcproj
  op.h
  open.cpp
  pixelbuffer.cpp
  pixelbuffer.h
  pixelbuffertarget.cpp
  pixelbuffertarget.h
  polygonbuffer.cpp
  polygonstripbuffer.cpp
  program-glsl.cpp
  program-glsl.h
  projection.cpp
  query.cpp
  render.cpp
  renderqueue.cpp
  renderqueue.h
  rendertarget.cpp
  rendertarget.h
  resize.cpp
  shader.cpp
  shader.h
  shadowmap.cpp
  shadowmap.h
  shutdown.cpp
  statistics.cpp
  statistics.h
  stencilbuffer.cpp
  texture.cpp
  texture.h
  textureunit.cpp
  textureunit.h
  vertexbuffer-glsl.cpp
  vertexbuffer-glsl.h
  vertexbuffer.cpp
  vertexbuffer.h
  vertexbuffermanager-glsl.cpp
  vertexbuffermanager-glsl.h
  vertexbuffermanager-nobs.cpp
  vertexbuffermanager-nobs.h
  vertexbuffermanager.cpp
  vertexbuffermanager.h
  viewport.cpp
  wglext.h
  zbufferstate.cpp
  zbufferstate.h