version 1.9 | | version 1.10 |
---|
| | |
#include "digi.h" | | #include "digi.h" |
#include "args.h" | | #include "args.h" |
/*#include "event.h"*/ | | /*#include "event.h"*/ |
| | #include <stdio.h> |
| | |
| | //not defined in cygwin, needed to keep windows from resizing everything to fit the fullscreen res. |
| | #ifndef CDS_FULLSCREEN |
| | #define CDS_FULLSCREEN 0x4 |
| | #endif |
| | |
| | DEVMODE devmode;//global so the activate proc can reset the screen mode. |
HINSTANCE hInst=NULL; | | HINSTANCE hInst=NULL; |
HWND g_hWnd=NULL; | | HWND g_hWnd=NULL; |
| | |
| | |
} | | } |
| | |
| | |
| | int vid_susp=0; |
| | int wgl_game_activate(int active,int min){ |
| | int i=0;//do_game_activate(active,min); |
| | if (!gl_initialized) return -1; |
| | // printf("****** wgl_game_activate: %i %i,%i %i *******\n",GLPREF_windowed,active,min,vid_susp); |
| | if (!active){ |
| | mouse_close(); |
| | if (!GLPREF_windowed) |
| | if (!vid_susp){ |
| | ChangeDisplaySettings(NULL,0); |
| | vid_susp=1; |
| | } |
| | }else{ |
| | mouse_init(0); |
| | if (!GLPREF_windowed) |
| | if (vid_susp){ |
| | ChangeDisplaySettings(&devmode,CDS_FULLSCREEN); |
| | ShowWindow(g_hWnd,SW_SHOWNORMAL); |
| | SetWindowPos(g_hWnd,HWND_TOPMOST,0,0,GLPREF_width,GLPREF_height,SWP_FRAMECHANGED);//if you don't set the pos, it comes up half off the screen, or just shows the desktop |
| | UpdateWindow(g_hWnd); |
| | wglMakeCurrent(NULL, NULL); |
| | wglMakeCurrent(hDC,GL_ResourceContext);//this seems to fix some glitches that appear when you alt-tab back in. |
| | vid_susp=0; |
| | } |
| | } |
| | // printf("****** -----------------: %i %i,%i %i *******\n",GLPREF_windowed,active,min,vid_susp); |
| | return i; |
| | } |
long PASCAL DescentWndProc(HWND hWnd,UINT message, | | long PASCAL DescentWndProc(HWND hWnd,UINT message, |
WPARAM wParam,LPARAM lParam ) | | WPARAM wParam,LPARAM lParam ) |
{ | | { |
| | |
case WM_PALETTECHANGED: | | case WM_PALETTECHANGED: |
case WM_PALETTEISCHANGING: | | case WM_PALETTEISCHANGING: |
return 0; | | return 0; |
| | case WM_KILLFOCUS: |
| | if (!GLPREF_windowed) |
| | ShowWindow(g_hWnd, SW_SHOWMINNOACTIVE);//this minimizes the game after you alt-tab out. |
| | break; |
| | case WM_ACTIVATE: |
| | wgl_game_activate((!(LOWORD(wParam) == WA_INACTIVE)),(BOOL) HIWORD(wParam)); |
| | break; |
case WM_ACTIVATEAPP: | | case WM_ACTIVATEAPP: |
// Win32_Key_Hook(wParam); | | // Win32_Key_Hook(wParam); |
// DPH: This doesn't work... no idea why not... | | // DPH: This doesn't work... no idea why not... |
| | |
finiObjects(); | | finiObjects(); |
PostQuitMessage(0); | | PostQuitMessage(0); |
break; | | break; |
} | | default: |
return DefWindowProc(hWnd,message,wParam,lParam); | | return DefWindowProc(hWnd,message,wParam,lParam); |
} | | } |
| | return 1; |
| | } |
| | |
| | |
| | |
| | |
} | | } |
| | |
if (ogl_fullscreen) | | if (ogl_fullscreen) |
flags=WS_POPUP | WS_SYSMENU; | | flags=WS_POPUP;//uh.. don't remember if removing sysmenu did anything or not.. but it works. |
| | //flags=WS_POPUP | WS_SYSMENU; |
else | | else |
flags=WS_OVERLAPPED | WS_BORDER | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; | | flags=WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;//let us minimize it. |
| | //flags=WS_OVERLAPPED | WS_BORDER | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; |
| | |
if (!ogl_fullscreen){ | | if (!ogl_fullscreen){ |
x+=get_win_x_bs();y+=get_win_y_bs(); | | x+=get_win_x_bs();y+=get_win_y_bs(); |
| | |
ShowWindow(g_hWnd,SW_SHOWNORMAL); | | ShowWindow(g_hWnd,SW_SHOWNORMAL); |
UpdateWindow(g_hWnd); | | UpdateWindow(g_hWnd); |
| | |
| | OpenGL_Initialize(); |
| | |
if (ogl_fullscreen){ | | if (ogl_fullscreen){ |
ShowCursor(FALSE); | | ShowCursor(FALSE); |
mouse_hidden = 1; | | mouse_hidden = 1; |
} | | } |
| | |
key_init(); | | key_init(); |
if (!FindArg( "-nomouse" )) | | |
mouse_init(0); | | mouse_init(0); |
if (!FindArg( "-nojoystick" )) | | |
joy_init(JOYSTICKID1); | | joy_init(JOYSTICKID1); |
if (!FindArg( "-nosound" )) | | if (!FindArg( "-nosound" )) |
digi_init(); | | digi_init(); |
// printf("arch_init successfully completed\n"); | | // printf("arch_init successfully completed\n"); |
| | |
OpenGL_Initialize(); | | |
| | |
gl_initialized=1; | | gl_initialized=1; |
} | | } |
void ogl_destroy_window(void){ | | void ogl_destroy_window(void){ |
if (gl_initialized){ | | if (gl_initialized){ |
ogl_smash_texture_list_internal(); | | ogl_smash_texture_list_internal(); |
OpenGL_Shutdown(); | | |
if (mouse_hidden){ | | if (mouse_hidden){ |
ShowCursor(TRUE); | | ShowCursor(TRUE); |
mouse_hidden = 0; | | mouse_hidden = 0; |
} | | } |
if (g_hWnd){ | | if (g_hWnd){ |
key_close(); | | key_close(); |
if (!FindArg( "-nomouse" )) | | |
mouse_close(); | | mouse_close(); |
if (!FindArg( "-nojoystick" )) | | |
joy_close(); | | joy_close(); |
if (!FindArg( "-nosound" )) | | if (!FindArg( "-nosound" )) |
digi_close(); | | digi_close(); |
| | OpenGL_Shutdown(); |
DestroyWindow(g_hWnd); | | DestroyWindow(g_hWnd); |
}else | | }else |
Error("ogl_destroy_window: no g_hWnd?\n"); | | Error("ogl_destroy_window: no g_hWnd?\n"); |
| | |
{ | | { |
// First set our display mode | | // First set our display mode |
// Create direct draw surface | | // Create direct draw surface |
DEVMODE devmode; | | |
int retval; | | int retval; |
| | |
devmode.dmSize=sizeof(devmode); | | devmode.dmSize=sizeof(devmode); |
| | |
devmode.dmPelsWidth=GLPREF_width; | | devmode.dmPelsWidth=GLPREF_width; |
devmode.dmPelsHeight=GLPREF_height; | | devmode.dmPelsHeight=GLPREF_height; |
devmode.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; | | devmode.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; |
| | if ((retval=FindArg("-gl_refresh"))){ |
| | devmode.dmDisplayFrequency=atoi(Args[retval+1]); |
| | if (devmode.dmDisplayFrequency>=60)//uhh, I hope no one actually wants a refresh lower than 60.. gag. |
| | devmode.dmFields|=DM_DISPLAYFREQUENCY; |
| | printf("trying refresh %i hz\n",devmode.dmDisplayFrequency); |
| | } |
| | |
retval=ChangeDisplaySettings(&devmode,0); | | retval=ChangeDisplaySettings(&devmode,CDS_FULLSCREEN); |
| | |
if (retval!=DISP_CHANGE_SUCCESSFUL) | | if (retval!=DISP_CHANGE_SUCCESSFUL) |
{ | | { |
| | |
devmode.dmPelsHeight=480; | | devmode.dmPelsHeight=480; |
devmode.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; | | devmode.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; |
| | |
retval=ChangeDisplaySettings(&devmode,0); | | retval=ChangeDisplaySettings(&devmode,CDS_FULLSCREEN); |
if (retval!=DISP_CHANGE_SUCCESSFUL) | | if (retval!=DISP_CHANGE_SUCCESSFUL) |
{ | | { |
errstr="ChangeDisplaySettings"; | | errstr="ChangeDisplaySettings"; |
| | |
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; | | pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; |
// pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_GENERIC_ACCELERATED; | | // pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_GENERIC_ACCELERATED; |
pfd.iPixelType = PFD_TYPE_RGBA; | | pfd.iPixelType = PFD_TYPE_RGBA; |
pfd.cColorBits = 16; | | //let the ogl driver decide. (fixes no hw accel in 16bit mode in w2k with tnt2) |
pfd.cAlphaBits = 8; | | // pfd.cColorBits = 16; |
pfd.cDepthBits = 0; | | // pfd.cAlphaBits = 8; |
pfd.cAccumBits = 0; | | // pfd.cDepthBits = 0; |
pfd.cStencilBits = 0; | | // pfd.cAccumBits = 0; |
| | // pfd.cStencilBits = 0; |
pfd.iLayerType = PFD_MAIN_PLANE; | | pfd.iLayerType = PFD_MAIN_PLANE; |
pfd.dwLayerMask = PFD_MAIN_PLANE; | | pfd.dwLayerMask = PFD_MAIN_PLANE; |
| | |