Show shutdown.cpp syntax highlighted
/***************************************************************************
shutdown.cpp - Terminate OpenGL
-------------------
begin : Tue Apr 1 2003
copyright : (C) 2003 by Reality Rift Studios
email : mattias@realityrift.com
***************************************************************************
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.
The Original Code is the NeoEngine, NeoDevOpenGL, shutdown.cpp
The Initial Developer of the Original Code is Mattias Jansson.
Portions created by Mattias Jansson are Copyright (C) 2003
Reality Rift Studios. All Rights Reserved.
***************************************************************************/
#define NEEDGDI
#include "device.h"
#include "pixelbuffertarget.h"
#include "framebuffertarget.h"
#include "textureunit.h"
#include "zbufferstate.h"
#include "vertexbuffermanager.h"
#include <neoengine/console.h>
#include <neoengine/logstream.h>
using namespace std;
using namespace NeoEngine;
namespace NeoOGL
{
void Device::Shutdown()
{
#ifdef WIN32
m_bIgnoreKill = true;
#endif
NeoEngine::Console::UnloadDefaultFont();
m_pkDefaultMaterial = 0;
for( unsigned int uiTMU = 0; uiTMU < m_uiNumTMUs; ++uiTMU )
delete m_ppkTMU[ uiTMU ];
delete [] m_ppkTMU;
m_uiNumTMUs = 0;
m_ppkTMU = 0;
if( m_pkCurTarget )
m_pkCurTarget->Deactivate(), m_pkCurTarget = 0;
delete m_pkPixelBufferTarget, m_pkPixelBufferTarget = 0;
delete m_pkFrameBufferTarget, m_pkFrameBufferTarget = 0;
delete m_pkVertexBufferManager, m_pkVertexBufferManager = 0;
#ifdef WIN32
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_uiOrgBPP;
devMode.dmPelsWidth = m_kWindow.m_uiOrgWidth;
devMode.dmPelsHeight = m_kWindow.m_uiOrgHeight;
devMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
ChangeDisplaySettings( &devMode, CDS_FULLSCREEN | CDS_SET_PRIMARY );
*/
ChangeDisplaySettings( 0, 0 );
ShowCursor( TRUE );
}
if( m_kWindow.m_uiFlags & RenderWindow::DEVICECREATED )
DestroyWindow( (HWND)m_kWindow.m_hWnd );
#elif defined( __APPLE__ )
if( m_kWindow.m_uiFlags & RenderWindow::DEVICECREATED )
DisposeWindow( (WindowPtr)m_kWindow.m_pWindow );
#elif defined( POSIX )
XUngrabPointer( (Display*)m_kWindow.m_pDisplay, CurrentTime );
if( m_kWindow.m_kCaps.IsSet( RenderCaps::FULLSCREEN ) )
{
XF86VidModeModeLine mode;
int Foo;
XF86VidModeLockModeSwitch( (Display*)m_kWindow.m_pDisplay, DefaultScreen( (Display*)m_kWindow.m_pDisplay ), false );
XReparentWindow( (Display*)m_kWindow.m_pDisplay, (Window)m_kWindow.m_Window, m_FSWindow, 0, 0 );
/* Restore resolution */
XF86VidModeGetModeLine( (Display*)m_kWindow.m_pDisplay, DefaultScreen( (Display*)m_kWindow.m_pDisplay ), &Foo, &mode );
if( ( m_OldMode.hdisplay != mode.hdisplay ) || ( m_OldMode.vdisplay != mode.vdisplay ) ) {
XF86VidModeSwitchToMode( (Display*)m_kWindow.m_pDisplay, DefaultScreen( (Display*)m_kWindow.m_pDisplay ), &m_OldMode );
}
if( m_kWindow.m_kDesktopResolution.m_uiWidth || m_kWindow.m_kDesktopResolution.m_uiHeight )
XF86VidModeSetViewPort( (Display*)m_kWindow.m_pDisplay, DefaultScreen( (Display*)m_kWindow.m_pDisplay ), m_kWindow.m_kDesktopResolution.m_uiWidth, m_kWindow.m_kDesktopResolution.m_uiHeight );
XUnmapWindow( (Display*)m_kWindow.m_pDisplay, m_FSWindow );
XSync( (Display*)m_kWindow.m_pDisplay, true );
}
#else
# error "Platform not implemented"
#endif
m_kWindow.Reset();
}
}; // namespace NeoOGL
See more files for this project here