ADDED fullscreen support to OpenGL
This commit is contained in:
parent
23fe108b5d
commit
9881f8f780
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
//GUI
|
//GUI
|
||||||
#include "MainWnd.h"
|
#include "MainWnd.h"
|
||||||
|
#include "FullscreenSettings.h"
|
||||||
|
|
||||||
// Internals
|
// Internals
|
||||||
#include "../System.h"
|
#include "../System.h"
|
||||||
|
@ -96,6 +97,7 @@ private:
|
||||||
GLFONT font;
|
GLFONT font;
|
||||||
int VertexShader,FragmentShader,textureLocation,ShaderProgram,g_location_grayScaleWeights;
|
int VertexShader,FragmentShader,textureLocation,ShaderProgram,g_location_grayScaleWeights;
|
||||||
char *VertexShaderSource,*FragmentShaderSource;
|
char *VertexShaderSource,*FragmentShaderSource;
|
||||||
|
DWORD currentAdapter;
|
||||||
|
|
||||||
void initializeMatrices( int w, int h );
|
void initializeMatrices( int w, int h );
|
||||||
bool initializeTexture( int w, int h );
|
bool initializeTexture( int w, int h );
|
||||||
|
@ -247,6 +249,7 @@ OpenGLDisplay::OpenGLDisplay()
|
||||||
failed = false;
|
failed = false;
|
||||||
filterData = NULL;
|
filterData = NULL;
|
||||||
shaderFuncInited = false;
|
shaderFuncInited = false;
|
||||||
|
currentAdapter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//OpenHL class destroyer
|
//OpenHL class destroyer
|
||||||
|
@ -297,6 +300,13 @@ void OpenGLDisplay::cleanup()
|
||||||
width = 0;
|
width = 0;
|
||||||
height = 0;
|
height = 0;
|
||||||
size = 0.0f;
|
size = 0.0f;
|
||||||
|
|
||||||
|
DISPLAY_DEVICE dev;
|
||||||
|
ZeroMemory( &dev, sizeof(dev) );
|
||||||
|
dev.cb = sizeof(dev);
|
||||||
|
EnumDisplayDevices( NULL, currentAdapter, &dev, 0 );
|
||||||
|
// restore default video mode
|
||||||
|
ChangeDisplaySettingsEx( dev.DeviceName, NULL, NULL, 0, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
//init renderer
|
//init renderer
|
||||||
|
@ -308,6 +318,32 @@ bool OpenGLDisplay::initialize()
|
||||||
theApp.mode1024Available = FALSE;
|
theApp.mode1024Available = FALSE;
|
||||||
theApp.mode1280Available = FALSE;
|
theApp.mode1280Available = FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
currentAdapter = theApp.fsAdapter;
|
||||||
|
DISPLAY_DEVICE dev;
|
||||||
|
ZeroMemory( &dev, sizeof(dev) );
|
||||||
|
dev.cb = sizeof(dev);
|
||||||
|
EnumDisplayDevices( NULL, currentAdapter, &dev, 0 );
|
||||||
|
if( theApp.videoOption >= VIDEO_320x240 ) {
|
||||||
|
// enter full screen mode
|
||||||
|
DEVMODE mode;
|
||||||
|
ZeroMemory( &mode, sizeof(mode) );
|
||||||
|
mode.dmSize = sizeof(mode);
|
||||||
|
mode.dmBitsPerPel = theApp.fsColorDepth;
|
||||||
|
mode.dmPelsWidth = theApp.fsWidth;
|
||||||
|
mode.dmPelsHeight = theApp.fsHeight;
|
||||||
|
mode.dmDisplayFrequency = theApp.fsFrequency;
|
||||||
|
mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
|
||||||
|
LONG ret = ChangeDisplaySettingsEx( dev.DeviceName, &mode, NULL, CDS_FULLSCREEN, NULL );
|
||||||
|
if( ret != DISP_CHANGE_SUCCESSFUL ) {
|
||||||
|
systemMessage( 0, "Can not change display mode!" );
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// restore default mode
|
||||||
|
ChangeDisplaySettingsEx( dev.DeviceName, NULL, NULL, 0, NULL );
|
||||||
|
}
|
||||||
|
|
||||||
EnableOpenGL();
|
EnableOpenGL();
|
||||||
initializeFont();
|
initializeFont();
|
||||||
glPushAttrib( GL_ENABLE_BIT );
|
glPushAttrib( GL_ENABLE_BIT );
|
||||||
|
@ -362,7 +398,7 @@ bool OpenGLDisplay::initialize()
|
||||||
if(failed)
|
if(failed)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//clear colour buffer
|
//clear colour buffer
|
||||||
|
@ -658,17 +694,32 @@ void OpenGLDisplay::setOption( const char *option, int value )
|
||||||
//set fullscreen mode
|
//set fullscreen mode
|
||||||
bool OpenGLDisplay::selectFullScreenMode( VIDEO_MODE &mode )
|
bool OpenGLDisplay::selectFullScreenMode( VIDEO_MODE &mode )
|
||||||
{
|
{
|
||||||
// TODO: Add display mode enumeration dialog
|
FullscreenSettings dlg;
|
||||||
HWND wnd = GetDesktopWindow();
|
dlg.setAPI( this->getType() );
|
||||||
RECT r;
|
INT_PTR ret = dlg.DoModal();
|
||||||
GetWindowRect( wnd, &r );
|
if( ret == IDOK ) {
|
||||||
mode.width = (unsigned short)( r.right - r.left );
|
mode.adapter = dlg.m_device;
|
||||||
mode.height = (unsigned short)( r.bottom - r.top );
|
switch( dlg.m_colorDepth )
|
||||||
HDC dc = GetDC( wnd );
|
{
|
||||||
mode.bitDepth = GetDeviceCaps( dc, BITSPIXEL );
|
case 30:
|
||||||
ReleaseDC( wnd, dc );
|
// TODO: support
|
||||||
return true;
|
return false;
|
||||||
// return false; when cancel is clicked
|
break;
|
||||||
|
case 24:
|
||||||
|
mode.bitDepth = 32;
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
case 15:
|
||||||
|
mode.bitDepth = 16;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mode.width = dlg.m_width;
|
||||||
|
mode.height = dlg.m_height;
|
||||||
|
mode.frequency = dlg.m_refreshRate;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue