- added GZDoom's Windows backend code.

Compiles but doesn't link yet.
This commit is contained in:
Christoph Oelckers 2019-12-22 20:55:47 +01:00
parent 773be7db26
commit 10683e9123
46 changed files with 15629 additions and 95 deletions

View file

@ -442,9 +442,9 @@ endif()
# Ugh... These precompiled dependencies need to go.
if (WIN32)
include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GDTOA_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../platform/windows/include" "${CMAKE_CURRENT_SOURCE_DIR}/../platform/windows/include/vpx" "${CMAKE_CURRENT_SOURCE_DIR}/../platform/windows/include/sdl2")
include_directories( "platform/win32" "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GDTOA_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../platform/windows/include" "${CMAKE_CURRENT_SOURCE_DIR}/../platform/windows/include/vpx" "${CMAKE_CURRENT_SOURCE_DIR}/../platform/windows/include/sdl2")
else ()
include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GDTOA_INCLUDE_DIR}")
include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GDTOA_INCLUDE_DIR}")
endif()
@ -474,8 +474,26 @@ endif()
# Start defining source files for Demolition
set( PLAT_WIN32_SOURCES
glad/src/glad_wgl.c
platform/win32/i_specialpaths.cpp
platform/win32/startwin.game.cpp
platform/win32/base_sysfb.cpp
platform/win32/gl_sysfb.cpp
platform/win32/hardware.cpp
platform/win32/i_crash.cpp
platform/win32/i_dijoy.cpp
platform/win32/i_input.cpp
platform/win32/i_keyboard.cpp
platform/win32/i_main.cpp
platform/win32/i_mouse.cpp
platform/win32/i_rawps2.cpp
platform/win32/i_specialpaths.cpp
platform/win32/i_system.cpp
platform/win32/i_xinput.cpp
platform/win32/startwin.game.cpp
platform/win32/st_start.cpp
platform/win32/st_start_util.cpp
platform/win32/win32basevideo.cpp
platform/win32/win32glvideo.cpp
platform/win32/win32vulkanvideo.cpp
# This needs a rework anyway in order to consolidate the startup dialogs so don't bother to sort in properly.
#startosx.game.mm
@ -616,8 +634,10 @@ file( GLOB HEADER_FILES
common/sound/backend/*.h
common/menu/*.h
common/input/*.h
common/rendering/*.h
build/src/*.h
platform/win32/*.h
thirdparty/include/*.h
thirdparty/include/*.hpp
thirdparty/imgui/*.h
@ -632,6 +652,7 @@ set( NOT_COMPILED_SOURCE_FILES
${OTHER_SYSTEM_SOURCES}
sc_man_scanner.h
common/utility/sc_man_scanner.re
platform/win32/demolition.natvis
)
@ -881,6 +902,7 @@ include_directories(
common/dobject
common/menu
common/input
common/rendering
platform
${CMAKE_BINARY_DIR}/libraries/gdtoa

View file

@ -245,7 +245,23 @@ void I_Error(const char *error, ...)
throw std::runtime_error(errortext);
}
void I_FatalError(const char* error, ...)
{
va_list argptr;
char errortext[MAX_ERRORTEXT];
va_start(argptr, error);
vsnprintf(errortext, MAX_ERRORTEXT, error, argptr);
va_end(argptr);
#ifdef _WIN32
OutputDebugStringA(errortext);
#endif
throw std::runtime_error(errortext);
}
#ifdef _WIN32
# if SDL_MAJOR_VERSION != 1
//

View file

@ -34,6 +34,7 @@
#ifndef __C_DISPATCH_H__
#define __C_DISPATCH_H__
#include <functional>
#include "c_console.h"
#include "zstring.h"
#include "c_commandline.h"

View file

@ -569,3 +569,48 @@ CCMD(snd_reset)
MUS_ResumeSaved();
}
//==========================================================================
//
// S_SetSoundPaused
//
// Called with state non-zero when the app is active, zero when it isn't.
//
//==========================================================================
void S_SetSoundPaused(int state)
{
#if 0
if (state)
{
if (paused == 0)
{
S_ResumeSound(true);
if (GSnd != nullptr)
{
GSnd->SetInactive(SoundRenderer::INACTIVE_Active);
}
}
}
else
{
if (paused == 0)
{
S_PauseSound(false, true);
if (GSnd != nullptr)
{
GSnd->SetInactive(gamestate == GS_LEVEL || gamestate == GS_TITLELEVEL ?
SoundRenderer::INACTIVE_Complete :
SoundRenderer::INACTIVE_Mute);
}
}
}
if (!netgame
#ifdef _DEBUG
&& !demoplayback
#endif
)
{
pauseext = !state;
}
#endif
}

View file

@ -45,6 +45,7 @@ void CONFIG_ReadCombatMacros();
int32_t CONFIG_GetMapBestTime(char const* const mapname, uint8_t const* const mapmd4);
int CONFIG_SetMapBestTime(uint8_t const* const mapmd4, int32_t tm);
int GameMain();
struct UserConfig
{
@ -140,3 +141,4 @@ const char* G_DefaultConFile(void);
const char* G_ConFile(void);
TArray<GrpEntry> GrpScan();
void S_SetSoundPaused(int state);

View file

@ -284,7 +284,6 @@ CUSTOM_CVARD(Int, r_fov, 90, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "change the field o
CVARD(Bool, r_horizcenter, false, CVAR_ARCHIVE|CVAR_FRONTEND_BLOOD, "enable/disable centered horizon line") // only present in Blood, maybe add to others?
CVARD(Bool, in_joystick, false, CVAR_ARCHIVE||CVAR_GLOBALCONFIG|CVAR_NOINITCALL, "enables input from the joystick if it is present")
CVARD(Bool, in_mouse, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL, "enables input from the mouse if it is present")
CVARD(Bool, in_mousemode, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "toggles vertical mouse view")
CVAR(Bool, silentmouseaimtoggle, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)

View file

@ -86,7 +86,7 @@ EXTERN_CVAR(Float, vid_brightness)
EXTERN_CVAR(Bool, in_joystick)
EXTERN_CVAR(Bool, in_mouse)
EXTERN_CVAR(Int, in_mouse)
EXTERN_CVAR(Int, in_mousebias)
EXTERN_CVAR(Int, in_mousedeadzone)
EXTERN_CVAR(Bool, in_mouseflip)

135
source/common/st_start.h Normal file
View file

@ -0,0 +1,135 @@
#pragma once
/*
** st_start.h
** Interface for the startup screen.
**
**---------------------------------------------------------------------------
** Copyright 2006-2007 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
** The startup screen interface is based on a mix of Heretic and Hexen.
** Actual implementation is system-specific.
*/
#include <stdint.h>
class FStartupScreen
{
public:
static FStartupScreen *CreateInstance(int max_progress);
FStartupScreen(int max_progress);
virtual ~FStartupScreen();
virtual void Progress();
virtual void LoadingStatus(const char *message, int colors); // Used by Heretic only
virtual void AppendStatusLine(const char *status); // Used by Heretic only
virtual void NetInit(const char *message, int num_players);
virtual void NetProgress(int count);
virtual void NetMessage(const char *format, ...); // cover for printf
virtual void NetDone();
virtual bool NetLoop(bool (*timer_callback)(void *), void *userdata);
protected:
int MaxPos, CurPos, NotchPos;
};
class FBasicStartupScreen : public FStartupScreen
{
public:
FBasicStartupScreen(int max_progress, bool show_bar);
~FBasicStartupScreen();
void Progress();
void NetInit(const char* message, int num_players);
void NetProgress(int count);
void NetMessage(const char* format, ...); // cover for printf
void NetDone();
bool NetLoop(bool (*timer_callback)(void*), void* userdata);
protected:
long long NetMarqueeMode;
int NetMaxPos, NetCurPos;
};
class FGraphicalStartupScreen : public FBasicStartupScreen
{
public:
FGraphicalStartupScreen(int max_progress);
~FGraphicalStartupScreen();
};
extern FStartupScreen *StartScreen;
void DeleteStartupScreen();
extern void ST_Endoom();
// The entire set of functions here uses native Windows types. These are recreations of those types so that the code doesn't need to be changed more than necessary
struct BitmapInfoHeader
{
uint32_t biSize;
int32_t biWidth;
int32_t biHeight;
uint16_t biPlanes;
uint16_t biBitCount;
uint32_t biCompression;
uint32_t biSizeImage;
int32_t biXPelsPerMeter;
int32_t biYPelsPerMeter;
uint32_t biClrUsed;
uint32_t biClrImportant;
};
struct RgbQuad
{
uint8_t rgbBlue;
uint8_t rgbGreen;
uint8_t rgbRed;
uint8_t rgbReserved;
};
struct BitmapInfo
{
BitmapInfoHeader bmiHeader;
RgbQuad bmiColors[1];
};
void ST_Util_PlanarToChunky4(uint8_t* dest, const uint8_t* src, int width, int height);
void ST_Util_DrawBlock(BitmapInfo* bitmap_info, const uint8_t* src, int x, int y, int bytewidth, int height);
void ST_Util_ClearBlock(BitmapInfo* bitmap_info, uint8_t fill, int x, int y, int bytewidth, int height);
BitmapInfo* ST_Util_CreateBitmap(int width, int height, int color_bits);
uint8_t* ST_Util_BitsForBitmap(BitmapInfo* bitmap_info);
void ST_Util_FreeBitmap(BitmapInfo* bitmap_info);
void ST_Util_BitmapColorsFromPlaypal(BitmapInfo* bitmap_info);
uint8_t* ST_Util_LoadFont(const char* filename);
void ST_Util_FreeFont(uint8_t* font);
BitmapInfo* ST_Util_AllocTextBitmap(const uint8_t* font);
void ST_Util_DrawTextScreen(BitmapInfo* bitmap_info, const uint8_t* text_screen, const uint8_t* font);
void ST_Util_DrawChar(BitmapInfo* screen, const uint8_t* font, int x, int y, uint8_t charnum, uint8_t attrib);
void ST_Util_UpdateTextBlink(BitmapInfo* bitmap_info, const uint8_t* text_screen, const uint8_t* font, bool on);

View file

@ -24,4 +24,6 @@ char(&_ArraySizeHelper(T(&array)[N]))[N];
#define countof( array ) (sizeof( _ArraySizeHelper( array ) ))
using INTBOOL = int;
#endif

View file

@ -293,6 +293,51 @@ bool CheckWildcards (const char *pattern, const char *text)
return (*pattern | *text) == 0;
}
//==========================================================================
//
// FormatGUID
//
// [RH] Print a GUID to a text buffer using the standard format.
//
//==========================================================================
void FormatGUID (char *buffer, size_t buffsize, const GUID &guid)
{
snprintf (buffer, buffsize, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
(uint32_t)guid.Data1, guid.Data2, guid.Data3,
guid.Data4[0], guid.Data4[1],
guid.Data4[2], guid.Data4[3],
guid.Data4[4], guid.Data4[5],
guid.Data4[6], guid.Data4[7]);
}
//==========================================================================
//
// myasctime
//
// [RH] Returns the current local time as ASCII, even if it's too early
//
//==========================================================================
const char *myasctime ()
{
static char readabletime[50];
time_t clock;
struct tm *lt;
time (&clock);
lt = localtime (&clock);
if (lt != NULL)
{
strftime(readabletime, 50, "%F %T", lt);
return readabletime;
}
else
{
return "Unknown\n";
}
}
//==========================================================================
//
// CreatePath
@ -392,33 +437,6 @@ void CreatePath(const char *fn)
}
#endif
//==========================================================================
//
// myasctime
//
// [RH] Returns the current local time as ASCII, even if it's too early
//
//==========================================================================
const char* myasctime()
{
static char readabletime[50];
time_t clock;
struct tm* lt;
time(&clock);
lt = localtime(&clock);
if (lt != NULL)
{
strftime(readabletime, 50, "%F %T", lt);
return readabletime;
}
else
{
return "Unknown Time";
}
}
//==========================================================================
//
// strbin -- In-place version

View file

@ -26,6 +26,8 @@ bool DirEntryExists (const char *pathname, bool *isdir = nullptr);
extern FString progdir;
static void inline FixPathSeperator (FString &path) { path.ReplaceChars('\\', '/'); }
void DefaultExtension (FString &path, const char *extension);
void NormalizeFileName(FString &str);
@ -37,7 +39,10 @@ bool IsNum (const char *str); // [RH] added
bool CheckWildcards (const char *pattern, const char *text);
const char* myasctime();
void FormatGUID (char *buffer, size_t buffsize, const GUID &guid);
const char *myasctime ();
int strbin (char *str);
FString strbin1 (const char *start);

View file

@ -3,6 +3,11 @@
#include <algorithm>
#include <stdint.h>
#ifdef max
#undef min
#undef max
#endif
struct PalEntry
{
PalEntry() = default;

View file

@ -38,6 +38,7 @@ enum
void I_Error(const char *fmt, ...) ATTRIBUTE((format(printf,1,2)));
void I_FatalError(const char* fmt, ...) ATTRIBUTE((format(printf, 1, 2)));
// This really could need some cleanup - the main problem is that it'd create
// lots of potential for merge conflicts.

View file

@ -57,7 +57,7 @@ const char *GetVersionString();
#define WGAMENAME L"Demolition"
#define GAMENAMELOWERCASE "demolition"
#define FORUM_URL "http://forum.zdoom.org/"
//#define BUGS_FORUM_URL "http://forum.zdoom.org/viewforum.php?f=2"
#define BUGS_FORUM_URL "http://forum.zdoom.org/viewforum.php?f=2" // fixme before release!!!
#define SAVESIG_DN3D "Demolition.Duke"
#define SAVESIG_BLD "Demolition.Blood"

View file

@ -0,0 +1,808 @@
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-2001 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#ifndef __AFXRES_H__
#define __AFXRES_H__
#ifdef RC_INVOKED
#ifndef _INC_WINDOWS
#define _INC_WINDOWS
#include "winres.h" // extract from windows header
#endif
#endif
#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, off)
#endif
#ifdef APSTUDIO_INVOKED
#define APSTUDIO_HIDDEN_SYMBOLS
#endif
/////////////////////////////////////////////////////////////////////////////
// MFC resource types (see Technical note TN024 for implementation details)
#ifndef RC_INVOKED
#define RT_DLGINIT MAKEINTRESOURCE(240)
#define RT_TOOLBAR MAKEINTRESOURCE(241)
#endif
/////////////////////////////////////////////////////////////////////////////
#ifdef APSTUDIO_INVOKED
#undef APSTUDIO_HIDDEN_SYMBOLS
#endif
/////////////////////////////////////////////////////////////////////////////
// General style bits etc
// ControlBar styles
#define CBRS_ALIGN_LEFT 0x1000L
#define CBRS_ALIGN_TOP 0x2000L
#define CBRS_ALIGN_RIGHT 0x4000L
#define CBRS_ALIGN_BOTTOM 0x8000L
#define CBRS_ALIGN_ANY 0xF000L
#define CBRS_BORDER_LEFT 0x0100L
#define CBRS_BORDER_TOP 0x0200L
#define CBRS_BORDER_RIGHT 0x0400L
#define CBRS_BORDER_BOTTOM 0x0800L
#define CBRS_BORDER_ANY 0x0F00L
#define CBRS_TOOLTIPS 0x0010L
#define CBRS_FLYBY 0x0020L
#define CBRS_FLOAT_MULTI 0x0040L
#define CBRS_BORDER_3D 0x0080L
#define CBRS_HIDE_INPLACE 0x0008L
#define CBRS_SIZE_DYNAMIC 0x0004L
#define CBRS_SIZE_FIXED 0x0002L
#define CBRS_FLOATING 0x0001L
#define CBRS_GRIPPER 0x00400000L
#define CBRS_ORIENT_HORZ (CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM)
#define CBRS_ORIENT_VERT (CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT)
#define CBRS_ORIENT_ANY (CBRS_ORIENT_HORZ|CBRS_ORIENT_VERT)
#define CBRS_ALL 0x0040FFFFL
// the CBRS_ style is made up of an alignment style and a draw border style
// the alignment styles are mutually exclusive
// the draw border styles may be combined
#define CBRS_NOALIGN 0x00000000L
#define CBRS_LEFT (CBRS_ALIGN_LEFT|CBRS_BORDER_RIGHT)
#define CBRS_TOP (CBRS_ALIGN_TOP|CBRS_BORDER_BOTTOM)
#define CBRS_RIGHT (CBRS_ALIGN_RIGHT|CBRS_BORDER_LEFT)
#define CBRS_BOTTOM (CBRS_ALIGN_BOTTOM|CBRS_BORDER_TOP)
/////////////////////////////////////////////////////////////////////////////
// Standard window components
// Mode indicators in status bar - these are routed like commands
#define ID_INDICATOR_EXT 0xE700 // extended selection indicator
#define ID_INDICATOR_CAPS 0xE701 // cap lock indicator
#define ID_INDICATOR_NUM 0xE702 // num lock indicator
#define ID_INDICATOR_SCRL 0xE703 // scroll lock indicator
#define ID_INDICATOR_OVR 0xE704 // overtype mode indicator
#define ID_INDICATOR_REC 0xE705 // record mode indicator
#define ID_INDICATOR_KANA 0xE706 // kana lock indicator
#define ID_SEPARATOR 0 // special separator value
#ifndef RC_INVOKED // code only
// Standard control bars (IDW = window ID)
#define AFX_IDW_CONTROLBAR_FIRST 0xE800
#define AFX_IDW_CONTROLBAR_LAST 0xE8FF
#define AFX_IDW_TOOLBAR 0xE800 // main Toolbar for window
#define AFX_IDW_STATUS_BAR 0xE801 // Status bar window
#define AFX_IDW_PREVIEW_BAR 0xE802 // PrintPreview Dialog Bar
#define AFX_IDW_RESIZE_BAR 0xE803 // OLE in-place resize bar
#define AFX_IDW_REBAR 0xE804 // COMCTL32 "rebar" Bar
#define AFX_IDW_DIALOGBAR 0xE805 // CDialogBar
// Note: If your application supports docking toolbars, you should
// not use the following IDs for your own toolbars. The IDs chosen
// are at the top of the first 32 such that the bars will be hidden
// while in print preview mode, and are not likely to conflict with
// IDs your application may have used succesfully in the past.
#define AFX_IDW_DOCKBAR_TOP 0xE81B
#define AFX_IDW_DOCKBAR_LEFT 0xE81C
#define AFX_IDW_DOCKBAR_RIGHT 0xE81D
#define AFX_IDW_DOCKBAR_BOTTOM 0xE81E
#define AFX_IDW_DOCKBAR_FLOAT 0xE81F
// Macro for mapping standard control bars to bitmask (limit of 32)
#define AFX_CONTROLBAR_MASK(nIDC) (1L << (nIDC - AFX_IDW_CONTROLBAR_FIRST))
// parts of Main Frame
#define AFX_IDW_PANE_FIRST 0xE900 // first pane (256 max)
#define AFX_IDW_PANE_LAST 0xE9ff
#define AFX_IDW_HSCROLL_FIRST 0xEA00 // first Horz scrollbar (16 max)
#define AFX_IDW_VSCROLL_FIRST 0xEA10 // first Vert scrollbar (16 max)
#define AFX_IDW_SIZE_BOX 0xEA20 // size box for splitters
#define AFX_IDW_PANE_SAVE 0xEA21 // to shift AFX_IDW_PANE_FIRST
#endif //!RC_INVOKED
#ifndef APSTUDIO_INVOKED
// common style for form views
#define AFX_WS_DEFAULT_VIEW (WS_CHILD | WS_VISIBLE | WS_BORDER)
#endif //!APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Standard app configurable strings
// for application title (defaults to EXE name or name in constructor)
#define AFX_IDS_APP_TITLE 0xE000
// idle message bar line
#define AFX_IDS_IDLEMESSAGE 0xE001
// message bar line when in shift-F1 help mode
#define AFX_IDS_HELPMODEMESSAGE 0xE002
// document title when editing OLE embedding
#define AFX_IDS_APP_TITLE_EMBEDDING 0xE003
// company name
#define AFX_IDS_COMPANY_NAME 0xE004
// object name when server is inplace
#define AFX_IDS_OBJ_TITLE_INPLACE 0xE005
/////////////////////////////////////////////////////////////////////////////
// Standard Commands
// File commands
#define ID_FILE_NEW 0xE100
#define ID_FILE_OPEN 0xE101
#define ID_FILE_CLOSE 0xE102
#define ID_FILE_SAVE 0xE103
#define ID_FILE_SAVE_AS 0xE104
#define ID_FILE_PAGE_SETUP 0xE105
#define ID_FILE_PRINT_SETUP 0xE106
#define ID_FILE_PRINT 0xE107
#define ID_FILE_PRINT_DIRECT 0xE108
#define ID_FILE_PRINT_PREVIEW 0xE109
#define ID_FILE_UPDATE 0xE10A
#define ID_FILE_SAVE_COPY_AS 0xE10B
#define ID_FILE_SEND_MAIL 0xE10C
#define ID_FILE_NEW_FRAME 0xE10D
#define ID_FILE_MRU_FIRST 0xE110
#define ID_FILE_MRU_FILE1 0xE110 // range - 16 max
#define ID_FILE_MRU_FILE2 0xE111
#define ID_FILE_MRU_FILE3 0xE112
#define ID_FILE_MRU_FILE4 0xE113
#define ID_FILE_MRU_FILE5 0xE114
#define ID_FILE_MRU_FILE6 0xE115
#define ID_FILE_MRU_FILE7 0xE116
#define ID_FILE_MRU_FILE8 0xE117
#define ID_FILE_MRU_FILE9 0xE118
#define ID_FILE_MRU_FILE10 0xE119
#define ID_FILE_MRU_FILE11 0xE11A
#define ID_FILE_MRU_FILE12 0xE11B
#define ID_FILE_MRU_FILE13 0xE11C
#define ID_FILE_MRU_FILE14 0xE11D
#define ID_FILE_MRU_FILE15 0xE11E
#define ID_FILE_MRU_FILE16 0xE11F
#define ID_FILE_MRU_LAST 0xE11F
// Edit commands
#define ID_EDIT_CLEAR 0xE120
#define ID_EDIT_CLEAR_ALL 0xE121
#define ID_EDIT_COPY 0xE122
#define ID_EDIT_CUT 0xE123
#define ID_EDIT_FIND 0xE124
#define ID_EDIT_PASTE 0xE125
#define ID_EDIT_PASTE_LINK 0xE126
#define ID_EDIT_PASTE_SPECIAL 0xE127
#define ID_EDIT_REPEAT 0xE128
#define ID_EDIT_REPLACE 0xE129
#define ID_EDIT_SELECT_ALL 0xE12A
#define ID_EDIT_UNDO 0xE12B
#define ID_EDIT_REDO 0xE12C
// Window commands
#define ID_WINDOW_NEW 0xE130
#define ID_WINDOW_ARRANGE 0xE131
#define ID_WINDOW_CASCADE 0xE132
#define ID_WINDOW_TILE_HORZ 0xE133
#define ID_WINDOW_TILE_VERT 0xE134
#define ID_WINDOW_SPLIT 0xE135
#ifndef RC_INVOKED // code only
#define AFX_IDM_WINDOW_FIRST 0xE130
#define AFX_IDM_WINDOW_LAST 0xE13F
#define AFX_IDM_FIRST_MDICHILD 0xFF00 // window list starts here
#endif //!RC_INVOKED
// Help and App commands
#define ID_APP_ABOUT 0xE140
#define ID_APP_EXIT 0xE141
#define ID_HELP_INDEX 0xE142
#define ID_HELP_FINDER 0xE143
#define ID_HELP_USING 0xE144
#define ID_CONTEXT_HELP 0xE145 // shift-F1
// special commands for processing help
#define ID_HELP 0xE146 // first attempt for F1
#define ID_DEFAULT_HELP 0xE147 // last attempt
// Misc
#define ID_NEXT_PANE 0xE150
#define ID_PREV_PANE 0xE151
// Format
#define ID_FORMAT_FONT 0xE160
// OLE commands
#define ID_OLE_INSERT_NEW 0xE200
#define ID_OLE_EDIT_LINKS 0xE201
#define ID_OLE_EDIT_CONVERT 0xE202
#define ID_OLE_EDIT_CHANGE_ICON 0xE203
#define ID_OLE_EDIT_PROPERTIES 0xE204
#define ID_OLE_VERB_FIRST 0xE210 // range - 16 max
#ifndef RC_INVOKED // code only
#define ID_OLE_VERB_LAST 0xE21F
#endif //!RC_INVOKED
// for print preview dialog bar
#define AFX_ID_PREVIEW_CLOSE 0xE300
#define AFX_ID_PREVIEW_NUMPAGE 0xE301 // One/Two Page button
#define AFX_ID_PREVIEW_NEXT 0xE302
#define AFX_ID_PREVIEW_PREV 0xE303
#define AFX_ID_PREVIEW_PRINT 0xE304
#define AFX_ID_PREVIEW_ZOOMIN 0xE305
#define AFX_ID_PREVIEW_ZOOMOUT 0xE306
// View commands (same number used as IDW used for control bar)
#define ID_VIEW_TOOLBAR 0xE800
#define ID_VIEW_STATUS_BAR 0xE801
#define ID_VIEW_REBAR 0xE804
#define ID_VIEW_AUTOARRANGE 0xE805
// E810 -> E81F must be kept in order for RANGE macros
#define ID_VIEW_SMALLICON 0xE810
#define ID_VIEW_LARGEICON 0xE811
#define ID_VIEW_LIST 0xE812
#define ID_VIEW_DETAILS 0xE813
#define ID_VIEW_LINEUP 0xE814
#define ID_VIEW_BYNAME 0xE815
#define AFX_ID_VIEW_MINIMUM ID_VIEW_SMALLICON
#define AFX_ID_VIEW_MAXIMUM ID_VIEW_BYNAME
// E800 -> E8FF reserved for other control bar commands
// RecordForm commands
#define ID_RECORD_FIRST 0xE900
#define ID_RECORD_LAST 0xE901
#define ID_RECORD_NEXT 0xE902
#define ID_RECORD_PREV 0xE903
/////////////////////////////////////////////////////////////////////////////
// Standard control IDs
#ifdef IDC_STATIC
#undef IDC_STATIC
#endif
#define IDC_STATIC (-1) // all static controls
/////////////////////////////////////////////////////////////////////////////
// Standard string error/warnings
#ifndef RC_INVOKED // code only
#define AFX_IDS_SCFIRST 0xEF00
#endif //!RC_INVOKED
#define AFX_IDS_SCSIZE 0xEF00
#define AFX_IDS_SCMOVE 0xEF01
#define AFX_IDS_SCMINIMIZE 0xEF02
#define AFX_IDS_SCMAXIMIZE 0xEF03
#define AFX_IDS_SCNEXTWINDOW 0xEF04
#define AFX_IDS_SCPREVWINDOW 0xEF05
#define AFX_IDS_SCCLOSE 0xEF06
#define AFX_IDS_SCRESTORE 0xEF12
#define AFX_IDS_SCTASKLIST 0xEF13
#define AFX_IDS_MDICHILD 0xEF1F
#define AFX_IDS_DESKACCESSORY 0xEFDA
// General strings
#define AFX_IDS_OPENFILE 0xF000
#define AFX_IDS_SAVEFILE 0xF001
#define AFX_IDS_ALLFILTER 0xF002
#define AFX_IDS_UNTITLED 0xF003
#define AFX_IDS_SAVEFILECOPY 0xF004
#define AFX_IDS_PREVIEW_CLOSE 0xF005
#define AFX_IDS_UNNAMED_FILE 0xF006
#define AFX_IDS_HIDE 0xF011
// MFC Standard Exception Error messages
#define AFX_IDP_NO_ERROR_AVAILABLE 0xF020
#define AFX_IDS_NOT_SUPPORTED_EXCEPTION 0xF021
#define AFX_IDS_RESOURCE_EXCEPTION 0xF022
#define AFX_IDS_MEMORY_EXCEPTION 0xF023
#define AFX_IDS_USER_EXCEPTION 0xF024
// Printing and print preview strings
#define AFX_IDS_PRINTONPORT 0xF040
#define AFX_IDS_ONEPAGE 0xF041
#define AFX_IDS_TWOPAGE 0xF042
#define AFX_IDS_PRINTPAGENUM 0xF043
#define AFX_IDS_PREVIEWPAGEDESC 0xF044
#define AFX_IDS_PRINTDEFAULTEXT 0xF045
#define AFX_IDS_PRINTDEFAULT 0xF046
#define AFX_IDS_PRINTFILTER 0xF047
#define AFX_IDS_PRINTCAPTION 0xF048
#define AFX_IDS_PRINTTOFILE 0xF049
// OLE strings
#define AFX_IDS_OBJECT_MENUITEM 0xF080
#define AFX_IDS_EDIT_VERB 0xF081
#define AFX_IDS_ACTIVATE_VERB 0xF082
#define AFX_IDS_CHANGE_LINK 0xF083
#define AFX_IDS_AUTO 0xF084
#define AFX_IDS_MANUAL 0xF085
#define AFX_IDS_FROZEN 0xF086
#define AFX_IDS_ALL_FILES 0xF087
// dynamically changing menu items
#define AFX_IDS_SAVE_MENU 0xF088
#define AFX_IDS_UPDATE_MENU 0xF089
#define AFX_IDS_SAVE_AS_MENU 0xF08A
#define AFX_IDS_SAVE_COPY_AS_MENU 0xF08B
#define AFX_IDS_EXIT_MENU 0xF08C
#define AFX_IDS_UPDATING_ITEMS 0xF08D
// COlePasteSpecialDialog defines
#define AFX_IDS_METAFILE_FORMAT 0xF08E
#define AFX_IDS_DIB_FORMAT 0xF08F
#define AFX_IDS_BITMAP_FORMAT 0xF090
#define AFX_IDS_LINKSOURCE_FORMAT 0xF091
#define AFX_IDS_EMBED_FORMAT 0xF092
// other OLE utility strings
#define AFX_IDS_PASTELINKEDTYPE 0xF094
#define AFX_IDS_UNKNOWNTYPE 0xF095
#define AFX_IDS_RTF_FORMAT 0xF096
#define AFX_IDS_TEXT_FORMAT 0xF097
// OLE datatype format error strings
#define AFX_IDS_INVALID_CURRENCY 0xF098
#define AFX_IDS_INVALID_DATETIME 0xF099
#define AFX_IDS_INVALID_DATETIMESPAN 0xF09A
// General error / prompt strings
#define AFX_IDP_INVALID_FILENAME 0xF100
#define AFX_IDP_FAILED_TO_OPEN_DOC 0xF101
#define AFX_IDP_FAILED_TO_SAVE_DOC 0xF102
#define AFX_IDP_ASK_TO_SAVE 0xF103
#define AFX_IDP_FAILED_TO_CREATE_DOC 0xF104
#define AFX_IDP_FILE_TOO_LARGE 0xF105
#define AFX_IDP_FAILED_TO_START_PRINT 0xF106
#define AFX_IDP_FAILED_TO_LAUNCH_HELP 0xF107
#define AFX_IDP_INTERNAL_FAILURE 0xF108 // general failure
#define AFX_IDP_COMMAND_FAILURE 0xF109 // command failure
#define AFX_IDP_FAILED_MEMORY_ALLOC 0xF10A
#define AFX_IDP_UNREG_DONE 0xF10B
#define AFX_IDP_UNREG_FAILURE 0xF10C
#define AFX_IDP_DLL_LOAD_FAILED 0xF10D
#define AFX_IDP_DLL_BAD_VERSION 0xF10E
// DDV parse errors
#define AFX_IDP_PARSE_INT 0xF110
#define AFX_IDP_PARSE_REAL 0xF111
#define AFX_IDP_PARSE_INT_RANGE 0xF112
#define AFX_IDP_PARSE_REAL_RANGE 0xF113
#define AFX_IDP_PARSE_STRING_SIZE 0xF114
#define AFX_IDP_PARSE_RADIO_BUTTON 0xF115
#define AFX_IDP_PARSE_BYTE 0xF116
#define AFX_IDP_PARSE_UINT 0xF117
#define AFX_IDP_PARSE_DATETIME 0xF118
#define AFX_IDP_PARSE_CURRENCY 0xF119
#define AFX_IDP_PARSE_GUID 0xF11A
#define AFX_IDP_PARSE_TIME 0xF11B
#define AFX_IDP_PARSE_DATE 0xF11C
// CFile/CArchive error strings for user failure
#define AFX_IDP_FAILED_INVALID_FORMAT 0xF120
#define AFX_IDP_FAILED_INVALID_PATH 0xF121
#define AFX_IDP_FAILED_DISK_FULL 0xF122
#define AFX_IDP_FAILED_ACCESS_READ 0xF123
#define AFX_IDP_FAILED_ACCESS_WRITE 0xF124
#define AFX_IDP_FAILED_IO_ERROR_READ 0xF125
#define AFX_IDP_FAILED_IO_ERROR_WRITE 0xF126
// Script errors / prompt strings
#define AFX_IDP_SCRIPT_ERROR 0xF130
#define AFX_IDP_SCRIPT_DISPATCH_EXCEPTION 0xF131
// OLE errors / prompt strings
#define AFX_IDP_STATIC_OBJECT 0xF180
#define AFX_IDP_FAILED_TO_CONNECT 0xF181
#define AFX_IDP_SERVER_BUSY 0xF182
#define AFX_IDP_BAD_VERB 0xF183
#define AFX_IDS_NOT_DOCOBJECT 0xF184
#define AFX_IDP_FAILED_TO_NOTIFY 0xF185
#define AFX_IDP_FAILED_TO_LAUNCH 0xF186
#define AFX_IDP_ASK_TO_UPDATE 0xF187
#define AFX_IDP_FAILED_TO_UPDATE 0xF188
#define AFX_IDP_FAILED_TO_REGISTER 0xF189
#define AFX_IDP_FAILED_TO_AUTO_REGISTER 0xF18A
#define AFX_IDP_FAILED_TO_CONVERT 0xF18B
#define AFX_IDP_GET_NOT_SUPPORTED 0xF18C
#define AFX_IDP_SET_NOT_SUPPORTED 0xF18D
#define AFX_IDP_ASK_TO_DISCARD 0xF18E
#define AFX_IDP_FAILED_TO_CREATE 0xF18F
// MAPI errors / prompt strings
#define AFX_IDP_FAILED_MAPI_LOAD 0xF190
#define AFX_IDP_INVALID_MAPI_DLL 0xF191
#define AFX_IDP_FAILED_MAPI_SEND 0xF192
#define AFX_IDP_FILE_NONE 0xF1A0
#define AFX_IDP_FILE_GENERIC 0xF1A1
#define AFX_IDP_FILE_NOT_FOUND 0xF1A2
#define AFX_IDP_FILE_BAD_PATH 0xF1A3
#define AFX_IDP_FILE_TOO_MANY_OPEN 0xF1A4
#define AFX_IDP_FILE_ACCESS_DENIED 0xF1A5
#define AFX_IDP_FILE_INVALID_FILE 0xF1A6
#define AFX_IDP_FILE_REMOVE_CURRENT 0xF1A7
#define AFX_IDP_FILE_DIR_FULL 0xF1A8
#define AFX_IDP_FILE_BAD_SEEK 0xF1A9
#define AFX_IDP_FILE_HARD_IO 0xF1AA
#define AFX_IDP_FILE_SHARING 0xF1AB
#define AFX_IDP_FILE_LOCKING 0xF1AC
#define AFX_IDP_FILE_DISKFULL 0xF1AD
#define AFX_IDP_FILE_EOF 0xF1AE
#define AFX_IDP_ARCH_NONE 0xF1B0
#define AFX_IDP_ARCH_GENERIC 0xF1B1
#define AFX_IDP_ARCH_READONLY 0xF1B2
#define AFX_IDP_ARCH_ENDOFFILE 0xF1B3
#define AFX_IDP_ARCH_WRITEONLY 0xF1B4
#define AFX_IDP_ARCH_BADINDEX 0xF1B5
#define AFX_IDP_ARCH_BADCLASS 0xF1B6
#define AFX_IDP_ARCH_BADSCHEMA 0xF1B7
#define AFX_IDS_OCC_SCALEUNITS_PIXELS 0xF1C0
// 0xf200-0xf20f reserved
// font names and point sizes
#define AFX_IDS_STATUS_FONT 0xF230
#define AFX_IDS_TOOLTIP_FONT 0xF231
#define AFX_IDS_UNICODE_FONT 0xF232
#define AFX_IDS_MINI_FONT 0xF233
// ODBC Database errors / prompt strings
#ifndef RC_INVOKED // code only
#define AFX_IDP_SQL_FIRST 0xF280
#endif //!RC_INVOKED
#define AFX_IDP_SQL_CONNECT_FAIL 0xF281
#define AFX_IDP_SQL_RECORDSET_FORWARD_ONLY 0xF282
#define AFX_IDP_SQL_EMPTY_COLUMN_LIST 0xF283
#define AFX_IDP_SQL_FIELD_SCHEMA_MISMATCH 0xF284
#define AFX_IDP_SQL_ILLEGAL_MODE 0xF285
#define AFX_IDP_SQL_MULTIPLE_ROWS_AFFECTED 0xF286
#define AFX_IDP_SQL_NO_CURRENT_RECORD 0xF287
#define AFX_IDP_SQL_NO_ROWS_AFFECTED 0xF288
#define AFX_IDP_SQL_RECORDSET_READONLY 0xF289
#define AFX_IDP_SQL_SQL_NO_TOTAL 0xF28A
#define AFX_IDP_SQL_ODBC_LOAD_FAILED 0xF28B
#define AFX_IDP_SQL_DYNASET_NOT_SUPPORTED 0xF28C
#define AFX_IDP_SQL_SNAPSHOT_NOT_SUPPORTED 0xF28D
#define AFX_IDP_SQL_API_CONFORMANCE 0xF28E
#define AFX_IDP_SQL_SQL_CONFORMANCE 0xF28F
#define AFX_IDP_SQL_NO_DATA_FOUND 0xF290
#define AFX_IDP_SQL_ROW_UPDATE_NOT_SUPPORTED 0xF291
#define AFX_IDP_SQL_ODBC_V2_REQUIRED 0xF292
#define AFX_IDP_SQL_NO_POSITIONED_UPDATES 0xF293
#define AFX_IDP_SQL_LOCK_MODE_NOT_SUPPORTED 0xF294
#define AFX_IDP_SQL_DATA_TRUNCATED 0xF295
#define AFX_IDP_SQL_ROW_FETCH 0xF296
#define AFX_IDP_SQL_INCORRECT_ODBC 0xF297
#define AFX_IDP_SQL_UPDATE_DELETE_FAILED 0xF298
#define AFX_IDP_SQL_DYNAMIC_CURSOR_NOT_SUPPORTED 0xF299
#define AFX_IDP_SQL_FIELD_NOT_FOUND 0xF29A
#define AFX_IDP_SQL_BOOKMARKS_NOT_SUPPORTED 0xF29B
#define AFX_IDP_SQL_BOOKMARKS_NOT_ENABLED 0xF29C
// ODBC Database strings
#define AFX_IDS_DELETED 0xF29D
// DAO Database errors / prompt strings
#ifndef RC_INVOKED // code only
#define AFX_IDP_DAO_FIRST 0xF2B0
#endif //!RC_INVOKED
#define AFX_IDP_DAO_ENGINE_INITIALIZATION 0xF2B0
#define AFX_IDP_DAO_DFX_BIND 0xF2B1
#define AFX_IDP_DAO_OBJECT_NOT_OPEN 0xF2B2
// ICDAORecordset::GetRows Errors
// These are not placed in DAO Errors collection
// and must be handled directly by MFC.
#define AFX_IDP_DAO_ROWTOOSHORT 0xF2B3
#define AFX_IDP_DAO_BADBINDINFO 0xF2B4
#define AFX_IDP_DAO_COLUMNUNAVAILABLE 0xF2B5
/////////////////////////////////////////////////////////////////////////////
// Strings for ISAPI support
#define AFX_IDS_HTTP_TITLE 0xF2D1
#define AFX_IDS_HTTP_NO_TEXT 0xF2D2
#define AFX_IDS_HTTP_BAD_REQUEST 0xF2D3
#define AFX_IDS_HTTP_AUTH_REQUIRED 0xF2D4
#define AFX_IDS_HTTP_FORBIDDEN 0xF2D5
#define AFX_IDS_HTTP_NOT_FOUND 0xF2D6
#define AFX_IDS_HTTP_SERVER_ERROR 0xF2D7
#define AFX_IDS_HTTP_NOT_IMPLEMENTED 0xF2D8
/////////////////////////////////////////////////////////////////////////////
// Strings for Accessibility support for CCheckListBox
#define AFX_IDS_CHECKLISTBOX_UNCHECK 0xF2E1
#define AFX_IDS_CHECKLISTBOX_CHECK 0xF2E2
#define AFX_IDS_CHECKLISTBOX_MIXED 0xF2E3
/////////////////////////////////////////////////////////////////////////////
// AFX implementation - control IDs (AFX_IDC)
// Parts of dialogs
#define AFX_IDC_LISTBOX 100
#define AFX_IDC_CHANGE 101
#define AFX_IDC_BROWSER 102
// for print dialog
#define AFX_IDC_PRINT_DOCNAME 201
#define AFX_IDC_PRINT_PRINTERNAME 202
#define AFX_IDC_PRINT_PORTNAME 203
#define AFX_IDC_PRINT_PAGENUM 204
// Property Sheet control id's (determined with Spy++)
#define ID_APPLY_NOW 0x3021
#define ID_WIZBACK 0x3023
#define ID_WIZNEXT 0x3024
#define ID_WIZFINISH 0x3025
#define AFX_IDC_TAB_CONTROL 0x3020
/////////////////////////////////////////////////////////////////////////////
// IDRs for standard components
#ifndef RC_INVOKED // code only
// These are really COMMDLG dialogs, so there usually isn't a resource
// for them, but these IDs are used as help IDs.
#define AFX_IDD_FILEOPEN 28676
#define AFX_IDD_FILESAVE 28677
#define AFX_IDD_FONT 28678
#define AFX_IDD_COLOR 28679
#define AFX_IDD_PRINT 28680
#define AFX_IDD_PRINTSETUP 28681
#define AFX_IDD_FIND 28682
#define AFX_IDD_REPLACE 28683
#endif //!RC_INVOKED
// Standard dialogs app should leave alone (0x7801->)
#define AFX_IDD_NEWTYPEDLG 30721
#define AFX_IDD_PRINTDLG 30722
#define AFX_IDD_PREVIEW_TOOLBAR 30723
// Dialogs defined for OLE2UI library
#define AFX_IDD_INSERTOBJECT 30724
#define AFX_IDD_CHANGEICON 30725
#define AFX_IDD_CONVERT 30726
#define AFX_IDD_PASTESPECIAL 30727
#define AFX_IDD_EDITLINKS 30728
#define AFX_IDD_FILEBROWSE 30729
#define AFX_IDD_BUSY 30730
#define AFX_IDD_OBJECTPROPERTIES 30732
#define AFX_IDD_CHANGESOURCE 30733
// Standard cursors (0x7901->)
// AFX_IDC = Cursor resources
#define AFX_IDC_CONTEXTHELP 30977 // context sensitive help
#define AFX_IDC_MAGNIFY 30978 // print preview zoom
#define AFX_IDC_SMALLARROWS 30979 // splitter
#define AFX_IDC_HSPLITBAR 30980 // splitter
#define AFX_IDC_VSPLITBAR 30981 // splitter
#define AFX_IDC_NODROPCRSR 30982 // No Drop Cursor
#define AFX_IDC_TRACKNWSE 30983 // tracker
#define AFX_IDC_TRACKNESW 30984 // tracker
#define AFX_IDC_TRACKNS 30985 // tracker
#define AFX_IDC_TRACKWE 30986 // tracker
#define AFX_IDC_TRACK4WAY 30987 // tracker
#define AFX_IDC_MOVE4WAY 30988 // resize bar (server only)
// Wheel mouse cursors
// NOTE: values must be in this order! See CScrollView::OnTimer()
#define AFX_IDC_MOUSE_PAN_NW 30998 // pan east
#define AFX_IDC_MOUSE_PAN_N 30999 // pan northeast
#define AFX_IDC_MOUSE_PAN_NE 31000 // pan north
#define AFX_IDC_MOUSE_PAN_W 31001 // pan northwest
#define AFX_IDC_MOUSE_PAN_HV 31002 // pan both axis
#define AFX_IDC_MOUSE_PAN_E 31003 // pan west
#define AFX_IDC_MOUSE_PAN_SW 31004 // pan south-west
#define AFX_IDC_MOUSE_PAN_S 31005 // pan south
#define AFX_IDC_MOUSE_PAN_SE 31006 // pan south-east
#define AFX_IDC_MOUSE_PAN_HORZ 31007 // pan X-axis
#define AFX_IDC_MOUSE_PAN_VERT 31008 // pan Y-axis
// Wheel mouse bitmaps
#define AFX_IDC_MOUSE_ORG_HORZ 31009 // anchor for horz only
#define AFX_IDC_MOUSE_ORG_VERT 31010 // anchor for vert only
#define AFX_IDC_MOUSE_ORG_HV 31011 // anchor for horz/vert
#define AFX_IDC_MOUSE_MASK 31012
// Mini frame window bitmap ID
#define AFX_IDB_MINIFRAME_MENU 30994
// CheckListBox checks bitmap ID
#define AFX_IDB_CHECKLISTBOX_95 30996
// AFX standard accelerator resources
#define AFX_IDR_PREVIEW_ACCEL 30997
// AFX standard ICON IDs (for MFC V1 apps) (0x7A01->)
#define AFX_IDI_STD_MDIFRAME 31233
#define AFX_IDI_STD_FRAME 31234
/////////////////////////////////////////////////////////////////////////////
// AFX OLE control implementation - control IDs (AFX_IDC)
// Font property page
#define AFX_IDC_FONTPROP 1000
#define AFX_IDC_FONTNAMES 1001
#define AFX_IDC_FONTSTYLES 1002
#define AFX_IDC_FONTSIZES 1003
#define AFX_IDC_STRIKEOUT 1004
#define AFX_IDC_UNDERLINE 1005
#define AFX_IDC_SAMPLEBOX 1006
// Color property page
#define AFX_IDC_COLOR_BLACK 1100
#define AFX_IDC_COLOR_WHITE 1101
#define AFX_IDC_COLOR_RED 1102
#define AFX_IDC_COLOR_GREEN 1103
#define AFX_IDC_COLOR_BLUE 1104
#define AFX_IDC_COLOR_YELLOW 1105
#define AFX_IDC_COLOR_MAGENTA 1106
#define AFX_IDC_COLOR_CYAN 1107
#define AFX_IDC_COLOR_GRAY 1108
#define AFX_IDC_COLOR_LIGHTGRAY 1109
#define AFX_IDC_COLOR_DARKRED 1110
#define AFX_IDC_COLOR_DARKGREEN 1111
#define AFX_IDC_COLOR_DARKBLUE 1112
#define AFX_IDC_COLOR_LIGHTBROWN 1113
#define AFX_IDC_COLOR_DARKMAGENTA 1114
#define AFX_IDC_COLOR_DARKCYAN 1115
#define AFX_IDC_COLORPROP 1116
#define AFX_IDC_SYSTEMCOLORS 1117
// Picture porperty page
#define AFX_IDC_PROPNAME 1201
#define AFX_IDC_PICTURE 1202
#define AFX_IDC_BROWSE 1203
#define AFX_IDC_CLEAR 1204
/////////////////////////////////////////////////////////////////////////////
// IDRs for OLE control standard components
// Standard propery page dialogs app should leave alone (0x7E01->)
#define AFX_IDD_PROPPAGE_COLOR 32257
#define AFX_IDD_PROPPAGE_FONT 32258
#define AFX_IDD_PROPPAGE_PICTURE 32259
#define AFX_IDB_TRUETYPE 32384
/////////////////////////////////////////////////////////////////////////////
// Standard OLE control strings
// OLE Control page strings
#define AFX_IDS_PROPPAGE_UNKNOWN 0xFE01
#define AFX_IDS_COLOR_DESKTOP 0xFE04
#define AFX_IDS_COLOR_APPWORKSPACE 0xFE05
#define AFX_IDS_COLOR_WNDBACKGND 0xFE06
#define AFX_IDS_COLOR_WNDTEXT 0xFE07
#define AFX_IDS_COLOR_MENUBAR 0xFE08
#define AFX_IDS_COLOR_MENUTEXT 0xFE09
#define AFX_IDS_COLOR_ACTIVEBAR 0xFE0A
#define AFX_IDS_COLOR_INACTIVEBAR 0xFE0B
#define AFX_IDS_COLOR_ACTIVETEXT 0xFE0C
#define AFX_IDS_COLOR_INACTIVETEXT 0xFE0D
#define AFX_IDS_COLOR_ACTIVEBORDER 0xFE0E
#define AFX_IDS_COLOR_INACTIVEBORDER 0xFE0F
#define AFX_IDS_COLOR_WNDFRAME 0xFE10
#define AFX_IDS_COLOR_SCROLLBARS 0xFE11
#define AFX_IDS_COLOR_BTNFACE 0xFE12
#define AFX_IDS_COLOR_BTNSHADOW 0xFE13
#define AFX_IDS_COLOR_BTNTEXT 0xFE14
#define AFX_IDS_COLOR_BTNHIGHLIGHT 0xFE15
#define AFX_IDS_COLOR_DISABLEDTEXT 0xFE16
#define AFX_IDS_COLOR_HIGHLIGHT 0xFE17
#define AFX_IDS_COLOR_HIGHLIGHTTEXT 0xFE18
#define AFX_IDS_REGULAR 0xFE19
#define AFX_IDS_BOLD 0xFE1A
#define AFX_IDS_ITALIC 0xFE1B
#define AFX_IDS_BOLDITALIC 0xFE1C
#define AFX_IDS_SAMPLETEXT 0xFE1D
#define AFX_IDS_DISPLAYSTRING_FONT 0xFE1E
#define AFX_IDS_DISPLAYSTRING_COLOR 0xFE1F
#define AFX_IDS_DISPLAYSTRING_PICTURE 0xFE20
#define AFX_IDS_PICTUREFILTER 0xFE21
#define AFX_IDS_PICTYPE_UNKNOWN 0xFE22
#define AFX_IDS_PICTYPE_NONE 0xFE23
#define AFX_IDS_PICTYPE_BITMAP 0xFE24
#define AFX_IDS_PICTYPE_METAFILE 0xFE25
#define AFX_IDS_PICTYPE_ICON 0xFE26
#define AFX_IDS_COLOR_PPG 0xFE28
#define AFX_IDS_COLOR_PPG_CAPTION 0xFE29
#define AFX_IDS_FONT_PPG 0xFE2A
#define AFX_IDS_FONT_PPG_CAPTION 0xFE2B
#define AFX_IDS_PICTURE_PPG 0xFE2C
#define AFX_IDS_PICTURE_PPG_CAPTION 0xFE2D
#define AFX_IDS_PICTUREBROWSETITLE 0xFE30
#define AFX_IDS_BORDERSTYLE_0 0xFE31
#define AFX_IDS_BORDERSTYLE_1 0xFE32
// OLE Control verb names
#define AFX_IDS_VERB_EDIT 0xFE40
#define AFX_IDS_VERB_PROPERTIES 0xFE41
// OLE Control internal error messages
#define AFX_IDP_PICTURECANTOPEN 0xFE83
#define AFX_IDP_PICTURECANTLOAD 0xFE84
#define AFX_IDP_PICTURETOOLARGE 0xFE85
#define AFX_IDP_PICTUREREADFAILED 0xFE86
// Standard OLE Control error strings
#define AFX_IDP_E_ILLEGALFUNCTIONCALL 0xFEA0
#define AFX_IDP_E_OVERFLOW 0xFEA1
#define AFX_IDP_E_OUTOFMEMORY 0xFEA2
#define AFX_IDP_E_DIVISIONBYZERO 0xFEA3
#define AFX_IDP_E_OUTOFSTRINGSPACE 0xFEA4
#define AFX_IDP_E_OUTOFSTACKSPACE 0xFEA5
#define AFX_IDP_E_BADFILENAMEORNUMBER 0xFEA6
#define AFX_IDP_E_FILENOTFOUND 0xFEA7
#define AFX_IDP_E_BADFILEMODE 0xFEA8
#define AFX_IDP_E_FILEALREADYOPEN 0xFEA9
#define AFX_IDP_E_DEVICEIOERROR 0xFEAA
#define AFX_IDP_E_FILEALREADYEXISTS 0xFEAB
#define AFX_IDP_E_BADRECORDLENGTH 0xFEAC
#define AFX_IDP_E_DISKFULL 0xFEAD
#define AFX_IDP_E_BADRECORDNUMBER 0xFEAE
#define AFX_IDP_E_BADFILENAME 0xFEAF
#define AFX_IDP_E_TOOMANYFILES 0xFEB0
#define AFX_IDP_E_DEVICEUNAVAILABLE 0xFEB1
#define AFX_IDP_E_PERMISSIONDENIED 0xFEB2
#define AFX_IDP_E_DISKNOTREADY 0xFEB3
#define AFX_IDP_E_PATHFILEACCESSERROR 0xFEB4
#define AFX_IDP_E_PATHNOTFOUND 0xFEB5
#define AFX_IDP_E_INVALIDPATTERNSTRING 0xFEB6
#define AFX_IDP_E_INVALIDUSEOFNULL 0xFEB7
#define AFX_IDP_E_INVALIDFILEFORMAT 0xFEB8
#define AFX_IDP_E_INVALIDPROPERTYVALUE 0xFEB9
#define AFX_IDP_E_INVALIDPROPERTYARRAYINDEX 0xFEBA
#define AFX_IDP_E_SETNOTSUPPORTEDATRUNTIME 0xFEBB
#define AFX_IDP_E_SETNOTSUPPORTED 0xFEBC
#define AFX_IDP_E_NEEDPROPERTYARRAYINDEX 0xFEBD
#define AFX_IDP_E_SETNOTPERMITTED 0xFEBE
#define AFX_IDP_E_GETNOTSUPPORTEDATRUNTIME 0xFEBF
#define AFX_IDP_E_GETNOTSUPPORTED 0xFEC0
#define AFX_IDP_E_PROPERTYNOTFOUND 0xFEC1
#define AFX_IDP_E_INVALIDCLIPBOARDFORMAT 0xFEC2
#define AFX_IDP_E_INVALIDPICTURE 0xFEC3
#define AFX_IDP_E_PRINTERERROR 0xFEC4
#define AFX_IDP_E_CANTSAVEFILETOTEMP 0xFEC5
#define AFX_IDP_E_SEARCHTEXTNOTFOUND 0xFEC6
#define AFX_IDP_E_REPLACEMENTSTOOLONG 0xFEC7
/////////////////////////////////////////////////////////////////////////////
#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, on)
#endif
#endif //__AFXRES_H__
/////////////////////////////////////////////////////////////////////////////

View file

@ -0,0 +1,421 @@
/*
**
**
**---------------------------------------------------------------------------
** Copyright 2003-2005 Tim Stump
** Copyright 2005-2016 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <GL/gl.h>
#include "wglext.h"
#include "palentry.h"
#include "gl_sysfb.h"
#include "hardware.h"
#include "templates.h"
#include "version.h"
#include "c_console.h"
#include "v_video.h"
#include "i_input.h"
#include "i_system.h"
#include "v_text.h"
#include "m_argv.h"
#include "base_sysfb.h"
#include "win32basevideo.h"
#include "c_dispatch.h"
extern HWND Window;
extern "C" {
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
EXTERN_CVAR(Int, vid_defwidth)
EXTERN_CVAR(Int, vid_defheight)
//==========================================================================
//
// Windows framebuffer
//
//==========================================================================
//==========================================================================
//
//
//
//==========================================================================
void SystemBaseFrameBuffer::GetCenteredPos(int in_w, int in_h, int &winx, int &winy, int &winw, int &winh, int &scrwidth, int &scrheight)
{
DEVMODE displaysettings;
RECT rect;
int cx, cy;
memset(&displaysettings, 0, sizeof(displaysettings));
displaysettings.dmSize = sizeof(displaysettings);
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &displaysettings);
scrwidth = (int)displaysettings.dmPelsWidth;
scrheight = (int)displaysettings.dmPelsHeight;
GetWindowRect(Window, &rect);
cx = scrwidth / 2;
cy = scrheight / 2;
if (in_w > 0) winw = in_w;
else winw = rect.right - rect.left;
if (in_h > 0) winh = in_h;
else winh = rect.bottom - rect.top;
winx = cx - winw / 2;
winy = cy - winh / 2;
}
//==========================================================================
//
//
//
//==========================================================================
void SystemBaseFrameBuffer::KeepWindowOnScreen(int &winx, int &winy, int winw, int winh, int scrwidth, int scrheight)
{
// If the window is too large to fit entirely on the screen, at least
// keep its upperleft corner visible.
if (winx + winw > scrwidth)
{
winx = scrwidth - winw;
}
if (winx < 0)
{
winx = 0;
}
if (winy + winh > scrheight)
{
winy = scrheight - winh;
}
if (winy < 0)
{
winy = 0;
}
}
//==========================================================================
//
//
//
//==========================================================================
void SystemBaseFrameBuffer::SaveWindowedPos()
{
// Don't save if we were run with the -0 option.
if (Args->CheckParm("-0"))
{
return;
}
// Make sure we only save the window position if it's not fullscreen.
static const int WINDOW_STYLE = WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX;
if ((GetWindowLong(Window, GWL_STYLE) & WINDOW_STYLE) == WINDOW_STYLE)
{
RECT wrect;
if (GetWindowRect(Window, &wrect))
{
// If (win_x,win_y) specify to center the window, don't change them
// if the window is still centered.
if (win_x < 0 || win_y < 0 || win_w < 0 || win_h < 0)
{
int winx, winy, winw, winh, scrwidth, scrheight;
GetCenteredPos(win_w, win_h, winx, winy, winw, winh, scrwidth, scrheight);
KeepWindowOnScreen(winx, winy, winw, winh, scrwidth, scrheight);
if (win_x < 0 && winx == wrect.left)
{
wrect.left = win_x;
}
if (win_y < 0 && winy == wrect.top)
{
wrect.top = win_y;
}
wrect.right = winw + wrect.left;
wrect.bottom = winh + wrect.top;
}
win_x = wrect.left;
win_y = wrect.top;
win_w = wrect.right - wrect.left;
win_h = wrect.bottom - wrect.top;
}
win_maximized = IsZoomed(Window) == TRUE;
}
}
//==========================================================================
//
//
//
//==========================================================================
void SystemBaseFrameBuffer::RestoreWindowedPos()
{
int winx, winy, winw, winh, scrwidth, scrheight;
GetCenteredPos(win_w, win_h, winx, winy, winw, winh, scrwidth, scrheight);
// Just move to (0,0) if we were run with the -0 option.
if (Args->CheckParm("-0"))
{
winx = winy = 0;
}
else
{
if (win_x >= 0)
{
winx = win_x;
}
if (win_y >= 0)
{
winy = win_y;
}
KeepWindowOnScreen(winx, winy, winw, winh, scrwidth, scrheight);
}
SetWindowPos(Window, nullptr, winx, winy, winw, winh, SWP_NOZORDER | SWP_FRAMECHANGED);
if (win_maximized && !Args->CheckParm("-0"))
ShowWindow(Window, SW_MAXIMIZE);
}
//==========================================================================
//
//
//
//==========================================================================
void SystemBaseFrameBuffer::SetWindowSize(int w, int h)
{
if (w < 0 || h < 0)
{
RestoreWindowedPos();
}
else
{
LONG style = WS_VISIBLE | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW;
LONG exStyle = WS_EX_WINDOWEDGE;
SetWindowLong(Window, GWL_STYLE, style);
SetWindowLong(Window, GWL_EXSTYLE, exStyle);
int winx, winy, winw, winh, scrwidth, scrheight;
RECT r = { 0, 0, w, h };
AdjustWindowRectEx(&r, style, false, exStyle);
w = int(r.right - r.left);
h = int(r.bottom - r.top);
GetCenteredPos(w, h, winx, winy, winw, winh, scrwidth, scrheight);
// Just move to (0,0) if we were run with the -0 option.
if (Args->CheckParm("-0"))
{
winx = winy = 0;
}
else
{
KeepWindowOnScreen(winx, winy, winw, winh, scrwidth, scrheight);
}
if (!vid_fullscreen)
{
ShowWindow(Window, SW_SHOWNORMAL);
SetWindowPos(Window, nullptr, winx, winy, winw, winh, SWP_NOZORDER | SWP_FRAMECHANGED);
win_maximized = false;
SetSize(GetClientWidth(), GetClientHeight());
SaveWindowedPos();
}
else
{
win_x = winx;
win_y = winy;
win_w = winw;
win_h = winh;
win_maximized = false;
vid_fullscreen = false;
}
}
}
//==========================================================================
//
//
//
//==========================================================================
void SystemBaseFrameBuffer::PositionWindow(bool fullscreen, bool initialcall)
{
RECT r;
LONG style, exStyle;
RECT monRect;
if (!m_Fullscreen && fullscreen && !initialcall) SaveWindowedPos();
if (m_Monitor)
{
MONITORINFOEXA mi;
mi.cbSize = sizeof mi;
if (GetMonitorInfoA(HMONITOR(m_Monitor), &mi))
{
strcpy(m_displayDeviceNameBuffer, mi.szDevice);
m_displayDeviceName = m_displayDeviceNameBuffer;
monRect = mi.rcMonitor;
// Set the default windowed size if not specified yet.
if (win_w < 0 || win_h < 0)
{
win_w = int(monRect.right - monRect.left) * 8 / 10;
win_h = int(monRect.bottom - monRect.top) * 8 / 10;
}
}
}
ShowWindow(Window, SW_SHOW);
GetWindowRect(Window, &r);
style = WS_VISIBLE | WS_CLIPSIBLINGS;
exStyle = 0;
if (fullscreen)
style |= WS_POPUP;
else
{
style |= WS_OVERLAPPEDWINDOW;
exStyle |= WS_EX_WINDOWEDGE;
}
SetWindowLong(Window, GWL_STYLE, style);
SetWindowLong(Window, GWL_EXSTYLE, exStyle);
if (fullscreen)
{
SetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
MoveWindow(Window, monRect.left, monRect.top, monRect.right-monRect.left, monRect.bottom-monRect.top, FALSE);
// And now, seriously, it IS in the right place. Promise.
}
else
{
RestoreWindowedPos();
// This doesn't restore the window size properly so we must force a set size the next tic.
if (m_Fullscreen)
{
::vid_fullscreen = false;
}
}
m_Fullscreen = fullscreen;
SetSize(GetClientWidth(), GetClientHeight());
}
//==========================================================================
//
//
//
//==========================================================================
SystemBaseFrameBuffer::SystemBaseFrameBuffer(void *hMonitor, bool fullscreen) : DFrameBuffer(vid_defwidth, vid_defheight)
{
m_Monitor = hMonitor;
m_displayDeviceName = 0;
PositionWindow(fullscreen, true);
HDC hDC = GetDC(Window);
ReleaseDC(Window, hDC);
}
//==========================================================================
//
//
//
//==========================================================================
SystemBaseFrameBuffer::~SystemBaseFrameBuffer()
{
if (!m_Fullscreen) SaveWindowedPos();
ShowWindow (Window, SW_SHOW);
SetWindowLong(Window, GWL_STYLE, WS_VISIBLE | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW);
SetWindowLong(Window, GWL_EXSTYLE, WS_EX_WINDOWEDGE);
SetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
I_GetEvent();
static_cast<Win32BaseVideo *>(Video)->Shutdown();
}
//==========================================================================
//
//
//
//==========================================================================
bool SystemBaseFrameBuffer::IsFullscreen()
{
return m_Fullscreen;
}
//==========================================================================
//
//
//
//==========================================================================
void SystemBaseFrameBuffer::ToggleFullscreen(bool yes)
{
PositionWindow(yes);
}
//==========================================================================
//
//
//
//==========================================================================
int SystemBaseFrameBuffer::GetClientWidth()
{
RECT rect = { 0 };
GetClientRect(Window, &rect);
return rect.right - rect.left;
}
int SystemBaseFrameBuffer::GetClientHeight()
{
RECT rect = { 0 };
GetClientRect(Window, &rect);
return rect.bottom - rect.top;
}

View file

@ -0,0 +1,39 @@
#pragma once
#include "v_video.h"
class SystemBaseFrameBuffer : public DFrameBuffer
{
typedef DFrameBuffer Super;
void SaveWindowedPos();
void RestoreWindowedPos();
public:
SystemBaseFrameBuffer();
// Actually, hMonitor is a HMONITOR, but it's passed as a void * as there
// look to be some cross-platform bits in the way.
SystemBaseFrameBuffer(void *hMonitor, bool fullscreen);
virtual ~SystemBaseFrameBuffer();
int GetClientWidth() override;
int GetClientHeight() override;
bool IsFullscreen() override;
void ToggleFullscreen(bool yes) override;
void SetWindowSize(int client_w, int client_h);
protected:
void GetCenteredPos(int in_w, int in_h, int &winx, int &winy, int &winw, int &winh, int &scrwidth, int &scrheight);
void KeepWindowOnScreen(int &winx, int &winy, int winw, int winh, int scrwidth, int scrheight);
void PositionWindow(bool fullscreen, bool initialcall = false);
float m_Gamma, m_Brightness, m_Contrast;
uint16_t m_origGamma[768];
bool m_Fullscreen = false;
char m_displayDeviceNameBuffer[32/*CCHDEVICENAME*/]; // do not use windows.h constants here!
char *m_displayDeviceName;
void *m_Monitor;
};

View file

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="TArray&lt;*&gt;">
<DisplayString>Size = {Count}</DisplayString>
<Expand>
<Item Name="Size">Count</Item>
<Item Name="Capacity">Most</Item>
<ArrayItems>
<Size>Count</Size>
<ValuePointer>(value_type*)Array</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="TArrayView&lt;*&gt;">
<DisplayString>Size = {Count}</DisplayString>
<Expand>
<Item Name="Size">Count</Item>
<ArrayItems>
<Size>Count</Size>
<ValuePointer>(value_type*)Array</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="TStaticPointedArray&lt;*&gt;">
<DisplayString>Size = {Count}</DisplayString>
<Expand>
<Item Name="Size">Count</Item>
<ArrayItems>
<Size>Count</Size>
<ValuePointer>(value_type*)Array</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="FName">
<DisplayString>{FName::NameData.NameArray[Index].Text, s}</DisplayString>
</Type>
<Type Name="FString">
<DisplayString>{Chars, s}</DisplayString>
<Expand>
<Item Name="Size">((FStringData*)Chars - 1)->Len</Item>
<Item Name="Capacity">((FStringData*)Chars - 1)->AllocLen</Item>
<Item Name="Reference Count">((FStringData*)Chars - 1)->RefCount</Item>
</Expand>
</Type>
<Type Name="TAngle&lt;*&gt;">
<DisplayString>{Degrees}</DisplayString>
</Type>
<Type Name="PClass">
<DisplayString>{TypeName}</DisplayString>
</Type>
<Type Name="DObject">
<DisplayString>{Class->TypeName}</DisplayString>
</Type>
<Type Name="TObjPtr&lt;*&gt;">
<DisplayString Condition="o == nullptr">&lt;NULL&gt;</DisplayString>
<DisplayString Condition="o != nullptr">{o->Class->TypeName}</DisplayString>
</Type>
<Type Name="FTextureID">
<DisplayString Condition="texnum == -1">&lt;None&gt;</DisplayString>
<DisplayString Condition="texnum != -1">{TexMan.Textures[texnum].Texture->Name}</DisplayString>
<Expand>
<Item Name="Index">texnum</Item>
<Item Name="Texture">TexMan.Textures[texnum].Texture</Item>
</Expand>
</Type>
<Type Name="FSoundID">
<DisplayString Condition="soundEngine == nullptr">&lt;No Sound Engine&gt;</DisplayString>
<DisplayString Condition="ID == 0">&lt;None&gt;</DisplayString>
<DisplayString Condition="ID != 0">{soundEngine->S_sfx[ID].name}</DisplayString>
</Type>
</AutoVisualizer>

View file

@ -0,0 +1,126 @@
/*
**
**
**---------------------------------------------------------------------------
** Copyright 2003-2005 Tim Stump
** Copyright 2005-2016 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <GL/gl.h>
#include "wglext.h"
#include "gl_sysfb.h"
#include "hardware.h"
#include "templates.h"
#include "version.h"
#include "c_console.h"
#include "v_video.h"
#include "i_input.h"
#include "i_system.h"
#include "v_text.h"
#include "m_argv.h"
#include "printf.h"
#include "win32glvideo.h"
extern HWND Window;
PFNWGLSWAPINTERVALEXTPROC myWglSwapIntervalExtProc;
//==========================================================================
//
// Windows framebuffer
//
//==========================================================================
//==========================================================================
//
//
//
//==========================================================================
SystemGLFrameBuffer::SystemGLFrameBuffer(void *hMonitor, bool fullscreen) : SystemBaseFrameBuffer(hMonitor, fullscreen)
{
if (!static_cast<Win32GLVideo *>(Video)->InitHardware(Window, 0))
{
I_FatalError("Unable to initialize OpenGL");
return;
}
HDC hDC = GetDC(Window);
const char *wglext = nullptr;
myWglSwapIntervalExtProc = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
auto myWglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
if (myWglGetExtensionsStringARB)
{
wglext = myWglGetExtensionsStringARB(hDC);
}
else
{
auto myWglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)wglGetProcAddress("wglGetExtensionsStringEXT");
if (myWglGetExtensionsStringEXT)
{
wglext = myWglGetExtensionsStringEXT();
}
}
SwapInterval = 1;
if (wglext != nullptr)
{
if (strstr(wglext, "WGL_EXT_swap_control_tear"))
{
SwapInterval = -1;
}
}
ReleaseDC(Window, hDC);
}
//==========================================================================
//
//
//
//==========================================================================
EXTERN_CVAR(Bool, vid_vsync);
CUSTOM_CVAR(Bool, gl_control_tear, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
vid_vsync.Callback();
}
void SystemGLFrameBuffer::SetVSync (bool vsync)
{
if (myWglSwapIntervalExtProc != NULL) myWglSwapIntervalExtProc(vsync ? (gl_control_tear? SwapInterval : 1) : 0);
}
void SystemGLFrameBuffer::SwapBuffers()
{
::SwapBuffers(static_cast<Win32GLVideo *>(Video)->m_hDC);
}

View file

@ -0,0 +1,20 @@
#pragma once
#include "base_sysfb.h"
class SystemGLFrameBuffer : public SystemBaseFrameBuffer
{
typedef SystemBaseFrameBuffer Super;
public:
SystemGLFrameBuffer() {}
// Actually, hMonitor is a HMONITOR, but it's passed as a void * as there
// look to be some cross-platform bits in the way.
SystemGLFrameBuffer(void *hMonitor, bool fullscreen);
void SetVSync (bool vsync);
void SwapBuffers();
protected:
int SwapInterval;
};

View file

@ -0,0 +1,154 @@
/*
** hardware.cpp
** Somewhat OS-independant interface to the screen, mouse, keyboard, and stick
**
**---------------------------------------------------------------------------
** Copyright 1998-2006 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mmsystem.h>
#include "hardware.h"
#include "c_dispatch.h"
#include "v_text.h"
#include "basics.h"
#include "m_argv.h"
#include "version.h"
#include "printf.h"
#include "win32glvideo.h"
#ifdef HAVE_VULKAN
#include "win32vulkanvideo.h"
#endif
#include "i_system.h"
EXTERN_CVAR(Int, vid_preferbackend)
extern HWND Window;
IVideo *Video;
// do not include GL headers here, only declare the necessary functions.
IVideo *gl_CreateVideo();
void I_RestartRenderer();
int currentcanvas = -1;
int currentgpuswitch = -1;
bool changerenderer;
// Optimus/Hybrid switcher
CUSTOM_CVAR(Int, vid_gpuswitch, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
if (self != currentgpuswitch)
{
switch (self)
{
case 0:
Printf("Selecting default GPU...\n");
break;
case 1:
Printf("Selecting high-performance dedicated GPU...\n");
break;
case 2:
Printf("Selecting power-saving integrated GPU...\n");
break;
default:
Printf("Unknown option (%d) - falling back to 'default'\n", *vid_gpuswitch);
self = 0;
break;
}
Printf("You must restart " GAMENAME " for this change to take effect.\n");
}
}
void I_ShutdownGraphics ()
{
if (screen)
{
DFrameBuffer *s = screen;
screen = NULL;
delete s;
}
if (Video)
delete Video, Video = NULL;
}
void I_InitGraphics ()
{
// todo: implement ATI version of this. this only works for nvidia notebooks, for now.
currentgpuswitch = vid_gpuswitch;
if (currentgpuswitch == 1)
putenv("SHIM_MCCOMPAT=0x800000001"); // discrete
else if (currentgpuswitch == 2)
putenv("SHIM_MCCOMPAT=0x800000000"); // integrated
// If the focus window is destroyed, it doesn't go back to the active window.
// (e.g. because the net pane was up, and a button on it had focus)
if (GetFocus() == NULL && GetActiveWindow() == Window)
{
// Make sure it's in the foreground and focused. (It probably is
// already foregrounded but may not be focused.)
SetForegroundWindow(Window);
SetFocus(Window);
// Note that when I start a 2-player game on the same machine, the
// window for the game that isn't focused, active, or foregrounded
// still receives a WM_ACTIVATEAPP message telling it that it's the
// active window. The window that is really the active window does
// not receive a WM_ACTIVATEAPP message, so both games think they
// are the active app. Huh?
}
#ifdef HAVE_VULKAN
else if (vid_preferbackend == 1)
{
// first try Vulkan, if that fails OpenGL
try
{
Video = new Win32VulkanVideo();
}
catch (CVulkanError &error)
{
Printf(TEXTCOLOR_RED "Initialization of Vulkan failed: %s\n", error.what());
Video = new Win32GLVideo();
}
}
#endif
else
{
Video = new Win32GLVideo();
}
// we somehow STILL don't have a display!!
if (Video == NULL)
I_FatalError ("Failed to initialize display");
}

View file

@ -0,0 +1,40 @@
/*
** hardware.h
**
**---------------------------------------------------------------------------
** Copyright 1998-2006 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#ifndef __HARDWARE_H__
#define __HARDWARE_H__
#include "i_video.h"
#include "v_video.h"
#endif // __HARDWARE_H__

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,932 @@
/*
** i_input.cpp
** Handles input from keyboard, mouse, and joystick
**
**---------------------------------------------------------------------------
** Copyright 1998-2009 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
// DI3 only supports up to 4 mouse buttons, and I want the joystick to
// be read using DirectInput instead of winmm.
#define WIN32_LEAN_AND_MEAN
#define __BYTEBOOL__
#ifndef __GNUC__
#define INITGUID
#endif
#define DIRECTINPUT_VERSION 0x800
#include <windows.h>
#include <dbt.h>
#include <dinput.h>
#include <malloc.h>
#ifdef _MSC_VER
#pragma warning(disable:4244)
#endif
// Compensate for w32api's lack
#ifndef WM_WTSSESSION_CHANGE
#define WM_WTSSESSION_CHANGE 0x02B1
#define WTS_CONSOLE_CONNECT 1
#define WTS_CONSOLE_DISCONNECT 2
#define WTS_SESSION_LOCK 7
#define WTS_SESSION_UNLOCK 8
#endif
#ifndef PBT_APMSUSPEND
// w32api does not #define the PBT_ macros in winuser.h like the PSDK does
#include <pbt.h>
#endif
#ifndef GET_RAWINPUT_CODE_WPARAM
#define GET_RAWINPUT_CODE_WPARAM(wParam) ((wParam) & 0xff)
#endif
#include "c_dispatch.h"
#include "m_argv.h"
#include "i_input.h"
#include "v_video.h"
#include "i_sound.h"
#include "d_gui.h"
#include "c_console.h"
#include "s_soundinternal.h"
#include "gameconfigfile.h"
#include "hardware.h"
#include "d_event.h"
#include "v_text.h"
#include "version.h"
#include "i_system.h"
#include "printf.h"
#include "c_console.h"
#include "menu.h"
#include "c_buttons.h"
#include "gamecontrol.h"
// Compensate for w32api's lack
#ifndef GET_XBUTTON_WPARAM
#define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))
#endif
#ifdef _DEBUG
#define INGAME_PRIORITY_CLASS NORMAL_PRIORITY_CLASS
#else
//#define INGAME_PRIORITY_CLASS HIGH_PRIORITY_CLASS
#define INGAME_PRIORITY_CLASS NORMAL_PRIORITY_CLASS
#endif
FJoystickCollection *JoyDevices[NUM_JOYDEVICES];
extern HINSTANCE g_hInst;
extern DWORD SessionID;
static HMODULE DInputDLL;
extern FMouse *Mouse;
extern FKeyboard *Keyboard;
bool ToggleFullscreen;
bool VidResizing;
extern BOOL vidactive;
extern HWND Window, ConWindow;
EXTERN_CVAR (String, language)
EXTERN_CVAR (Bool, lookstrafe)
EXTERN_CVAR (Bool, use_joystick)
EXTERN_CVAR (Bool, use_mouse)
static int WheelDelta;
extern bool CursorState;
extern BOOL paused;
static bool noidle = false;
LPDIRECTINPUT8 g_pdi;
LPDIRECTINPUT g_pdi3;
extern bool AppActive;
int SessionState = 0;
int BlockMouseMove;
static bool EventHandlerResultForNativeMouse;
CVAR (Bool, i_soundinbackground, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR (Bool, k_allowfullscreentoggle, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
extern int chatmodeon;
static void I_CheckGUICapture ()
{
#if 0
bool wantCapt;
if (menuactive == MENU_Off)
{
wantCapt = ConsoleState == c_down || ConsoleState == c_falling || chatmodeon;
}
else
{
wantCapt = (menuactive == MENU_On || menuactive == MENU_OnNoPause);
}
if (wantCapt != GUICapture)
{
GUICapture = wantCapt;
if (wantCapt && Keyboard != NULL)
{
Keyboard->AllKeysUp();
}
}
#endif
}
void I_SetMouseCapture()
{
SetCapture(Window);
}
void I_ReleaseMouseCapture()
{
ReleaseCapture();
}
bool GUIWndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result)
{
event_t ev = { EV_GUI_Event };
*result = 0;
switch (message)
{
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
if (message == WM_KEYUP || message == WM_SYSKEYUP)
{
ev.subtype = EV_GUI_KeyUp;
}
else
{
ev.subtype = (lParam & 0x40000000) ? EV_GUI_KeyRepeat : EV_GUI_KeyDown;
}
if (GetKeyState(VK_SHIFT) & 0x8000) ev.data3 |= GKM_SHIFT;
if (GetKeyState(VK_CONTROL) & 0x8000) ev.data3 |= GKM_CTRL;
if (GetKeyState(VK_MENU) & 0x8000) ev.data3 |= GKM_ALT;
if (wParam == VK_PROCESSKEY)
{ // Use the scan code to determine the real virtual-key code.
// ImmGetVirtualKey() will supposedly do this, but it just returns
// VK_PROCESSKEY again.
wParam = MapVirtualKey((lParam >> 16) & 255, 1);
}
if ( (ev.data1 = MapVirtualKey(wParam, 2)) )
{
D_PostEvent(&ev);
}
else
{
switch (wParam)
{
case VK_PRIOR: ev.data1 = GK_PGUP; break;
case VK_NEXT: ev.data1 = GK_PGDN; break;
case VK_END: ev.data1 = GK_END; break;
case VK_HOME: ev.data1 = GK_HOME; break;
case VK_LEFT: ev.data1 = GK_LEFT; break;
case VK_RIGHT: ev.data1 = GK_RIGHT; break;
case VK_UP: ev.data1 = GK_UP; break;
case VK_DOWN: ev.data1 = GK_DOWN; break;
case VK_DELETE: ev.data1 = GK_DEL; break;
case VK_ESCAPE: ev.data1 = GK_ESCAPE; break;
case VK_F1: ev.data1 = GK_F1; break;
case VK_F2: ev.data1 = GK_F2; break;
case VK_F3: ev.data1 = GK_F3; break;
case VK_F4: ev.data1 = GK_F4; break;
case VK_F5: ev.data1 = GK_F5; break;
case VK_F6: ev.data1 = GK_F6; break;
case VK_F7: ev.data1 = GK_F7; break;
case VK_F8: ev.data1 = GK_F8; break;
case VK_F9: ev.data1 = GK_F9; break;
case VK_F10: ev.data1 = GK_F10; break;
case VK_F11: ev.data1 = GK_F11; break;
case VK_F12: ev.data1 = GK_F12; break;
case VK_BROWSER_BACK: ev.data1 = GK_BACK; break;
}
if (ev.data1 != 0)
{
D_PostEvent(&ev);
}
}
// Return false for key downs so that we can handle special hotkeys
// in the main WndProc.
return ev.subtype == EV_GUI_KeyUp;
case WM_CHAR:
case WM_SYSCHAR:
if (wParam >= ' ') // only send displayable characters
{
ev.subtype = EV_GUI_Char;
ev.data1 = wParam;
ev.data2 = (message == WM_SYSCHAR);
D_PostEvent(&ev);
return true;
}
break;
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_XBUTTONDOWN:
case WM_XBUTTONUP:
case WM_MOUSEMOVE:
if (message >= WM_LBUTTONDOWN && message <= WM_LBUTTONDBLCLK)
{
ev.subtype = message - WM_LBUTTONDOWN + EV_GUI_LButtonDown;
}
else if (message >= WM_RBUTTONDOWN && message <= WM_RBUTTONDBLCLK)
{
ev.subtype = message - WM_RBUTTONDOWN + EV_GUI_RButtonDown;
}
else if (message >= WM_MBUTTONDOWN && message <= WM_MBUTTONDBLCLK)
{
ev.subtype = message - WM_MBUTTONDOWN + EV_GUI_MButtonDown;
}
else if (message >= WM_XBUTTONDOWN && message <= WM_XBUTTONUP)
{
ev.subtype = message - WM_XBUTTONDOWN + EV_GUI_BackButtonDown;
if (GET_XBUTTON_WPARAM(wParam) == 2)
{
ev.subtype += EV_GUI_FwdButtonDown - EV_GUI_BackButtonDown;
}
else if (GET_XBUTTON_WPARAM(wParam) != 1)
{
break;
}
}
else if (message == WM_MOUSEMOVE)
{
ev.subtype = EV_GUI_MouseMove;
if (BlockMouseMove > 0) return true;
}
ev.data1 = LOWORD(lParam);
ev.data2 = HIWORD(lParam);
if (screen != NULL)
{
screen->ScaleCoordsFromWindow(ev.data1, ev.data2);
}
if (wParam & MK_SHIFT) ev.data3 |= GKM_SHIFT;
if (wParam & MK_CONTROL) ev.data3 |= GKM_CTRL;
if (GetKeyState(VK_MENU) & 0x8000) ev.data3 |= GKM_ALT;
if (use_mouse) D_PostEvent(&ev);
return true;
// Note: If the mouse is grabbed, it sends the mouse wheel events itself.
case WM_MOUSEWHEEL:
if (!use_mouse) return false;
if (wParam & MK_SHIFT) ev.data3 |= GKM_SHIFT;
if (wParam & MK_CONTROL) ev.data3 |= GKM_CTRL;
if (GetKeyState(VK_MENU) & 0x8000) ev.data3 |= GKM_ALT;
WheelDelta += (SHORT)HIWORD(wParam);
if (WheelDelta < 0)
{
ev.subtype = EV_GUI_WheelDown;
while (WheelDelta <= -WHEEL_DELTA)
{
D_PostEvent(&ev);
WheelDelta += WHEEL_DELTA;
}
}
else
{
ev.subtype = EV_GUI_WheelUp;
while (WheelDelta >= WHEEL_DELTA)
{
D_PostEvent(&ev);
WheelDelta -= WHEEL_DELTA;
}
}
return true;
}
return false;
}
bool CallHook(FInputDevice *device, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result)
{
if (device == NULL)
{
return false;
}
*result = 0;
return device->WndProcHook(hWnd, message, wParam, lParam, result);
}
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT result;
if (message == WM_INPUT)
{
UINT size;
if (!GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER)) &&
size != 0)
{
uint8_t *buffer = (uint8_t *)alloca(size);
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, buffer, &size, sizeof(RAWINPUTHEADER)) == size)
{
int code = GET_RAWINPUT_CODE_WPARAM(wParam);
if (Keyboard == NULL || !Keyboard->ProcessRawInput((RAWINPUT *)buffer, code))
{
if (Mouse == NULL || !Mouse->ProcessRawInput((RAWINPUT *)buffer, code))
{
if (JoyDevices[INPUT_RawPS2] != NULL)
{
JoyDevices[INPUT_RawPS2]->ProcessRawInput((RAWINPUT *)buffer, code);
}
}
}
}
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
if (CallHook(Keyboard, hWnd, message, wParam, lParam, &result))
{
return result;
}
if (CallHook(Mouse, hWnd, message, wParam, lParam, &result))
{
return result;
}
for (int i = 0; i < NUM_JOYDEVICES; ++i)
{
if (CallHook(JoyDevices[i], hWnd, message, wParam, lParam, &result))
{
return result;
}
}
if (GUICapture && GUIWndProcHook(hWnd, message, wParam, lParam, &result))
{
return result;
}
#if 0
if ((gamestate == GS_DEMOSCREEN || gamestate == GS_TITLELEVEL) && message == WM_LBUTTONDOWN)
{
if (GUIWndProcHook(hWnd, message, wParam, lParam, &result))
{
return result;
}
}
#endif
switch (message)
{
case WM_DESTROY:
SetPriorityClass (GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
PostQuitMessage (0);
break;
case WM_HOTKEY:
break;
case WM_PAINT:
return DefWindowProc (hWnd, message, wParam, lParam);
case WM_SETTINGCHANGE:
// If regional settings were changed, reget preferred languages
if (wParam == 0 && lParam != 0 && strcmp ((const char *)lParam, "intl") == 0)
{
language.Callback ();
}
return 0;
case WM_KILLFOCUS:
I_CheckNativeMouse (true, false); // Make sure mouse gets released right away
break;
case WM_SETFOCUS:
I_CheckNativeMouse (false, EventHandlerResultForNativeMouse); // This cannot call the event handler. Doing it from here is unsafe.
break;
case WM_SETCURSOR:
if (!CursorState)
{
SetCursor(NULL); // turn off window cursor
return TRUE; // Prevent Windows from setting cursor to window class cursor
}
else
{
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_SIZE:
InvalidateRect (Window, NULL, FALSE);
break;
case WM_KEYDOWN:
break;
case WM_SYSKEYDOWN:
// Pressing Alt+Enter can toggle between fullscreen and windowed.
if (wParam == VK_RETURN && k_allowfullscreentoggle && !(lParam & 0x40000000))
{
ToggleFullscreen = !ToggleFullscreen;
}
// Pressing Alt+F4 quits the program.
if (wParam == VK_F4 && !(lParam & 0x40000000))
{
PostQuitMessage(0);
}
break;
case WM_SYSCOMMAND:
// Prevent activation of the window menu with Alt+Space
if ((wParam & 0xFFF0) != SC_KEYMENU)
{
return DefWindowProc (hWnd, message, wParam, lParam);
}
break;
case WM_DISPLAYCHANGE:
case WM_STYLECHANGED:
return DefWindowProc(hWnd, message, wParam, lParam);
case WM_GETMINMAXINFO:
if (screen && !VidResizing)
{
LPMINMAXINFO mmi = (LPMINMAXINFO)lParam;
if (screen->IsFullscreen())
{
RECT rect = { 0, 0, screen->GetWidth(), screen->GetHeight() };
AdjustWindowRectEx(&rect, WS_VISIBLE | WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW);
mmi->ptMinTrackSize.x = rect.right - rect.left;
mmi->ptMinTrackSize.y = rect.bottom - rect.top;
}
else
{
RECT rect = { 0, 0, VID_MIN_WIDTH, VID_MIN_HEIGHT };
AdjustWindowRectEx(&rect, GetWindowLongW(hWnd, GWL_STYLE), FALSE, GetWindowLongW(hWnd, GWL_EXSTYLE));
mmi->ptMinTrackSize.x = rect.right - rect.left;
mmi->ptMinTrackSize.y = rect.bottom - rect.top;
}
return 0;
}
break;
case WM_ACTIVATEAPP:
AppActive = wParam == TRUE;
if (wParam)
{
SetPriorityClass (GetCurrentProcess (), INGAME_PRIORITY_CLASS);
}
#if 0
else if (!noidle && !netgame)
{
SetPriorityClass (GetCurrentProcess (), IDLE_PRIORITY_CLASS);
}
#endif
S_SetSoundPaused ((!!i_soundinbackground) || wParam);
break;
case WM_WTSSESSION_CHANGE:
case WM_POWERBROADCAST:
{
int oldstate = SessionState;
if (message == WM_WTSSESSION_CHANGE && lParam == (LPARAM)SessionID)
{
#ifdef _DEBUG
OutputDebugStringA ("SessionID matched\n");
#endif
// When using fast user switching, XP will lock a session before
// disconnecting it, and the session will be unlocked before reconnecting it.
// For our purposes, video output will only happen when the session is
// both unlocked and connected (that is, SessionState is 0).
switch (wParam)
{
case WTS_SESSION_LOCK:
SessionState |= 1;
break;
case WTS_SESSION_UNLOCK:
SessionState &= ~1;
break;
case WTS_CONSOLE_DISCONNECT:
SessionState |= 2;
break;
case WTS_CONSOLE_CONNECT:
SessionState &= ~2;
break;
}
}
else if (message == WM_POWERBROADCAST)
{
switch (wParam)
{
case PBT_APMSUSPEND:
SessionState |= 4;
break;
case PBT_APMRESUMESUSPEND:
SessionState &= ~4;
break;
}
}
if (GSnd != NULL)
{
#if 0
// Do we actually need this here?
if (!oldstate && SessionState)
{
GSnd->SuspendSound ();
}
#endif
}
#ifdef _DEBUG
char foo[256];
snprintf (foo, countof(foo), "Session Change: %ld %d\n", (long)lParam, (int)wParam);
OutputDebugStringA (foo);
#endif
}
break;
case WM_ERASEBKGND:
return true;
case WM_DEVICECHANGE:
if (wParam == DBT_DEVNODES_CHANGED ||
wParam == DBT_DEVICEARRIVAL ||
wParam == DBT_CONFIGCHANGED)
{
event_t ev = { EV_DeviceChange };
D_PostEvent(&ev);
}
return DefWindowProc (hWnd, message, wParam, lParam);
default:
return DefWindowProc (hWnd, message, wParam, lParam);
}
return 0;
}
bool I_InitInput (void *hwnd)
{
HRESULT hr;
Printf ("I_InitInput\n");
noidle = !!Args->CheckParm ("-noidle");
g_pdi = NULL;
g_pdi3 = NULL;
// Try for DirectInput 8 first, then DirectInput 3 for NT 4's benefit.
DInputDLL = LoadLibraryA("dinput8.dll");
if (DInputDLL != NULL)
{
typedef HRESULT (WINAPI *blah)(HINSTANCE, DWORD, REFIID, LPVOID *, LPUNKNOWN);
blah di8c = (blah)GetProcAddress(DInputDLL, "DirectInput8Create");
if (di8c != NULL)
{
hr = di8c(g_hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&g_pdi, NULL);
if (FAILED(hr))
{
Printf(TEXTCOLOR_ORANGE "DirectInput8Create failed: %08lx\n", hr);
g_pdi = NULL; // Just to be sure DirectInput8Create didn't change it
}
}
else
{
Printf(TEXTCOLOR_ORANGE "Could not find DirectInput8Create in dinput8.dll\n");
}
}
if (g_pdi == NULL)
{
if (DInputDLL != NULL)
{
FreeLibrary(DInputDLL);
}
DInputDLL = LoadLibraryA ("dinput.dll");
if (DInputDLL == NULL)
{
I_FatalError ("Could not load dinput.dll: %08lx", GetLastError());
}
typedef HRESULT (WINAPI *blah)(HINSTANCE, DWORD, LPDIRECTINPUT*, LPUNKNOWN);
#ifdef UNICODE
blah dic = (blah)GetProcAddress (DInputDLL, "DirectInputCreateW");
#else
blah dic = (blah)GetProcAddress(DInputDLL, "DirectInputCreateA");
#endif
if (dic == NULL)
{
I_FatalError ("dinput.dll is corrupt");
}
hr = dic (g_hInst, 0x0300, &g_pdi3, NULL);
if (FAILED(hr))
{
I_FatalError ("DirectInputCreate failed: %08lx", hr);
}
}
Printf ("I_StartupMouse\n");
I_StartupMouse();
Printf ("I_StartupKeyboard\n");
I_StartupKeyboard();
Printf ("I_StartupXInput\n");
I_StartupXInput();
Printf ("I_StartupRawPS2\n");
I_StartupRawPS2();
Printf ("I_StartupDirectInputJoystick\n");
I_StartupDirectInputJoystick();
return TRUE;
}
// Free all input resources
void I_ShutdownInput ()
{
if (Keyboard != NULL)
{
delete Keyboard;
Keyboard = NULL;
}
if (Mouse != NULL)
{
delete Mouse;
Mouse = NULL;
}
for (int i = 0; i < NUM_JOYDEVICES; ++i)
{
if (JoyDevices[i] != NULL)
{
delete JoyDevices[i];
JoyDevices[i] = NULL;
}
}
if (g_pdi)
{
g_pdi->Release ();
g_pdi = NULL;
}
if (g_pdi3)
{
g_pdi3->Release ();
g_pdi3 = NULL;
}
if (DInputDLL != NULL)
{
FreeLibrary (DInputDLL);
DInputDLL = NULL;
}
}
void I_GetEvent ()
{
MSG mess;
// Briefly enter an alertable state so that if a secondary thread
// crashed, we will execute the APC it sent now.
SleepEx (0, TRUE);
while (PeekMessage (&mess, NULL, 0, 0, PM_REMOVE))
{
if (mess.message == WM_QUIT)
throw ExitEvent(mess.wParam);
if (GUICapture)
{
TranslateMessage (&mess);
}
DispatchMessage (&mess);
}
if (Keyboard != NULL)
{
Keyboard->ProcessInput();
}
if (Mouse != NULL)
{
Mouse->ProcessInput();
}
}
//
// I_StartTic
//
void I_StartTic ()
{
BlockMouseMove--;
buttonMap.ResetButtonTriggers ();
I_CheckGUICapture ();
EventHandlerResultForNativeMouse = false;
I_CheckNativeMouse (false, EventHandlerResultForNativeMouse);
I_GetEvent ();
}
//
// I_StartFrame
//
void I_StartFrame ()
{
if (use_joystick)
{
for (int i = 0; i < NUM_JOYDEVICES; ++i)
{
if (JoyDevices[i] != NULL)
{
JoyDevices[i]->ProcessInput();
}
}
}
}
void I_GetAxes(float axes[NUM_JOYAXIS])
{
int i;
for (i = 0; i < NUM_JOYAXIS; ++i)
{
axes[i] = 0;
}
if (use_joystick)
{
for (i = 0; i < NUM_JOYDEVICES; ++i)
{
if (JoyDevices[i] != NULL)
{
JoyDevices[i]->AddAxes(axes);
}
}
}
}
void I_GetJoysticks(TArray<IJoystickConfig *> &sticks)
{
sticks.Clear();
for (int i = 0; i < NUM_JOYDEVICES; ++i)
{
if (JoyDevices[i] != NULL)
{
JoyDevices[i]->GetDevices(sticks);
}
}
}
// If a new controller was added, returns a pointer to it.
IJoystickConfig *I_UpdateDeviceList()
{
IJoystickConfig *newone = NULL;
for (int i = 0; i < NUM_JOYDEVICES; ++i)
{
if (JoyDevices[i] != NULL)
{
IJoystickConfig *thisnewone = JoyDevices[i]->Rescan();
if (newone == NULL)
{
newone = thisnewone;
}
}
}
return newone;
}
void I_PutInClipboard (const char *str)
{
if (str == NULL || !OpenClipboard (Window))
return;
EmptyClipboard ();
auto wstr = WideString(str);
HGLOBAL cliphandle = GlobalAlloc (GMEM_DDESHARE, wstr.length() * 2 + 2);
if (cliphandle != NULL)
{
wchar_t *ptr = (wchar_t *)GlobalLock (cliphandle);
wcscpy (ptr, wstr.c_str());
GlobalUnlock (cliphandle);
SetClipboardData (CF_UNICODETEXT, cliphandle);
}
CloseClipboard ();
}
FString I_GetFromClipboard (bool return_nothing)
{
FString retstr;
HGLOBAL cliphandle;
wchar_t *clipstr;
if (return_nothing || !IsClipboardFormatAvailable (CF_UNICODETEXT) || !OpenClipboard (Window))
return retstr;
cliphandle = GetClipboardData (CF_UNICODETEXT);
if (cliphandle != nullptr)
{
clipstr = (wchar_t *)GlobalLock (cliphandle);
if (clipstr != nullptr)
{
// Convert CR-LF pairs to just LF.
retstr = clipstr;
GlobalUnlock(clipstr);
retstr.Substitute("\r\n", "\n");
}
}
CloseClipboard ();
return retstr;
}
//==========================================================================
//
// FInputDevice - Destructor
//
//==========================================================================
FInputDevice::~FInputDevice()
{
}
//==========================================================================
//
// FInputDevice :: ProcessInput
//
// Gives subclasses an opportunity to do input handling that doesn't involve
// window messages.
//
//==========================================================================
void FInputDevice::ProcessInput()
{
}
//==========================================================================
//
// FInputDevice :: ProcessRawInput
//
// Gives subclasses a chance to handle WM_INPUT messages. This is not part
// of WndProcHook so that we only need to fill the RAWINPUT buffer once
// per message and be sure it gets cleaned up properly.
//
//==========================================================================
bool FInputDevice::ProcessRawInput(RAWINPUT *raw, int code)
{
return false;
}
//==========================================================================
//
// FInputDevice :: WndProcHook
//
// Gives subclasses a chance to intercept window messages.
//
//==========================================================================
bool FInputDevice::WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result)
{
return false;
}

View file

@ -0,0 +1,168 @@
/*
** i_input.h
**
**---------------------------------------------------------------------------
** Copyright 1998-2006 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#ifndef __I_INPUT_H__
#define __I_INPUT_H__
#include "basics.h"
bool I_InitInput (void *hwnd);
void I_ShutdownInput ();
void I_GetEvent();
enum
{
INPUT_DIJoy,
INPUT_XInput,
INPUT_RawPS2,
NUM_JOYDEVICES
};
#ifdef _WIN32
#include "m_joy.h"
// Don't make these definitions available to the main body of the source code.
struct tagRAWINPUT;
class FInputDevice
{
public:
virtual ~FInputDevice() = 0;
virtual bool GetDevice() = 0;
virtual void ProcessInput();
virtual bool ProcessRawInput(tagRAWINPUT *raw, int code);
virtual bool WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result);
};
class FMouse : public FInputDevice
{
public:
FMouse();
virtual void Grab() = 0;
virtual void Ungrab() = 0;
protected:
void PostMouseMove(int x, int y);
void WheelMoved(int axis, int wheelmove);
void PostButtonEvent(int button, bool down);
void ClearButtonState();
int WheelMove[2];
int LastX, LastY; // for m_filter
int ButtonState; // bit mask of current button states (1=down, 0=up)
};
class FKeyboard : public FInputDevice
{
public:
FKeyboard();
~FKeyboard();
void AllKeysUp();
protected:
uint8_t KeyStates[256/8];
int CheckKey(int keynum) const
{
return KeyStates[keynum >> 3] & (1 << (keynum & 7));
}
void SetKey(int keynum, bool down)
{
if (down)
{
KeyStates[keynum >> 3] |= 1 << (keynum & 7);
}
else
{
KeyStates[keynum >> 3] &= ~(1 << (keynum & 7));
}
}
bool CheckAndSetKey(int keynum, INTBOOL down);
void PostKeyEvent(int keynum, INTBOOL down, bool foreground);
};
class /*NOVTABLE*/ FJoystickCollection : public FInputDevice
{
public:
virtual void AddAxes(float axes[NUM_JOYAXIS]) = 0;
virtual void GetDevices(TArray<IJoystickConfig *> &sticks) = 0;
virtual IJoystickConfig *Rescan() = 0;
};
extern FJoystickCollection *JoyDevices[NUM_JOYDEVICES];
void I_StartupMouse();
void I_CheckNativeMouse(bool prefer_native, bool eh);
void I_StartupKeyboard();
void I_StartupXInput();
void I_StartupDirectInputJoystick();
void I_StartupRawPS2();
bool I_IsPS2Adapter(DWORD vidpid);
// USB HID usage page numbers
#define HID_GENERIC_DESKTOP_PAGE 0x01
#define HID_SIMULATION_CONTROLS_PAGE 0x02
#define HID_VR_CONTROLS_PAGE 0x03
#define HID_SPORT_CONTROLS_PAGE 0x04
#define HID_GAME_CONTROLS_PAGE 0x05
#define HID_GENERIC_DEVICE_CONTROLS_PAGE 0x06
#define HID_KEYBOARD_PAGE 0x07
#define HID_LED_PAGE 0x08
#define HID_BUTTON_PAGE 0x09
#define HID_ORDINAL_PAGE 0x0a
#define HID_TELEPHONY_DEVICE_PAGE 0x0b
#define HID_CONSUMER_PAGE 0x0c
#define HID_DIGITIZERS_PAGE 0x0d
#define HID_UNICODE_PAGE 0x10
#define HID_ALPHANUMERIC_DISPLAY_PAGE 0x14
#define HID_MEDICAL_INSTRUMENT_PAGE 0x40
// HID Generic Desktop Page usages
#define HID_GDP_UNDEFINED 0x00
#define HID_GDP_POINTER 0x01
#define HID_GDP_MOUSE 0x02
#define HID_GDP_JOYSTICK 0x04
#define HID_GDP_GAMEPAD 0x05
#define HID_GDP_KEYBOARD 0x06
#define HID_GDP_KEYPAD 0x07
#define HID_GDP_MULTIAXIS_CONTROLLER 0x08
#endif
#endif

View file

@ -0,0 +1,582 @@
/*
**
**
**---------------------------------------------------------------------------
** Copyright 2005-2016 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
// HEADER FILES ------------------------------------------------------------
#define WIN32_LEAN_AND_MEAN
#define DIRECTINPUT_VERSION 0x800
#include <windows.h>
#include <dinput.h>
#include "i_input.h"
#include "d_event.h"
// MACROS ------------------------------------------------------------------
#define DINPUT_BUFFERSIZE 32
// MinGW-w64 (TDM5.1 - 2016/11/21)
#ifndef DIK_PREVTRACK
#define DIK_PREVTRACK DIK_CIRCUMFLEX
#endif
// TYPES -------------------------------------------------------------------
class FDInputKeyboard : public FKeyboard
{
public:
FDInputKeyboard();
~FDInputKeyboard();
bool GetDevice();
void ProcessInput();
protected:
LPDIRECTINPUTDEVICE8 Device;
};
class FRawKeyboard : public FKeyboard
{
public:
FRawKeyboard();
~FRawKeyboard();
bool GetDevice();
bool ProcessRawInput(RAWINPUT *rawinput, int code);
protected:
USHORT E1Prefix;
};
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
extern HWND Window;
extern LPDIRECTINPUT8 g_pdi;
extern LPDIRECTINPUT g_pdi3;
extern bool GUICapture;
// PRIVATE DATA DEFINITIONS ------------------------------------------------
// Convert DIK_* code to ASCII using Qwerty keymap
static const uint8_t Convert[256] =
{
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 8, 9, // 0
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', 13, 0, 'a', 's', // 1
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', 39, '`', 0,'\\', 'z', 'x', 'c', 'v', // 2
'b', 'n', 'm', ',', '.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, // 3
0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', // 4
'2', '3', '0', '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 5
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 6
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 7
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '=', 0, 0, // 8
0, '@', ':', '_', 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, // 9
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // A
0, 0, 0, ',', 0, '/', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // B
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // C
0, 0, 0, 0, 0, 0, 0, 0
};
// PUBLIC DATA DEFINITIONS -------------------------------------------------
FKeyboard *Keyboard;
// Set this to false to make keypad-enter a usable separate key.
CVAR (Bool, k_mergekeys, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
// CODE --------------------------------------------------------------------
//==========================================================================
//
// FKeyboard - Constructor
//
//==========================================================================
FKeyboard::FKeyboard()
{
memset(KeyStates, 0, sizeof(KeyStates));
}
//==========================================================================
//
// FKeyboard - Destructor
//
//==========================================================================
FKeyboard::~FKeyboard()
{
AllKeysUp();
}
//==========================================================================
//
// FKeyboard :: CheckAndSetKey
//
// Returns true if the key was already in the desired state, false if it
// wasn't.
//
//==========================================================================
bool FKeyboard::CheckAndSetKey(int keynum, INTBOOL down)
{
uint8_t *statebyte = &KeyStates[keynum >> 3];
uint8_t mask = 1 << (keynum & 7);
if (down)
{
if (*statebyte & mask)
{
return true;
}
*statebyte |= mask;
return false;
}
else
{
if (*statebyte & mask)
{
*statebyte &= ~mask;
return false;
}
return true;
}
}
//==========================================================================
//
// FKeyboard :: AllKeysUp
//
// For every key currently marked as down, send a key up event and clear it.
//
//==========================================================================
void FKeyboard::AllKeysUp()
{
event_t ev = { 0 };
ev.type = EV_KeyUp;
for (int i = 0; i < 256/8; ++i)
{
if (KeyStates[i] != 0)
{
uint8_t states = KeyStates[i];
int j = 0;
KeyStates[i] = 0;
do
{
if (states & 1)
{
ev.data1 = (i << 3) + j;
ev.data2 = Convert[ev.data1];
D_PostEvent(&ev);
}
states >>= 1;
++j;
}
while (states != 0);
}
}
}
//==========================================================================
//
// FKeyboard :: PostKeyEvent
//
// Posts a keyboard event, but only if the state is different from what we
// currently think it is. (For instance, raw keyboard input sends key
// down events every time the key automatically repeats, so we want to
// discard those.)
//
//==========================================================================
void FKeyboard::PostKeyEvent(int key, INTBOOL down, bool foreground)
{
event_t ev = { 0 };
// Printf("key=%02x down=%02x\n", key, down);
// "Merge" multiple keys that are considered to be the same. If the
// original unmerged key is down, it also needs to go up. (In case
// somebody was holding the key down when they changed this setting.)
if (k_mergekeys)
{
if (key == DIK_NUMPADENTER || key == DIK_RMENU || key == DIK_RCONTROL)
{
k_mergekeys = false;
PostKeyEvent(key, false, foreground);
k_mergekeys = true;
key &= 0x7F;
}
else if (key == DIK_RSHIFT)
{
k_mergekeys = false;
PostKeyEvent(key, false, foreground);
k_mergekeys = true;
key = DIK_LSHIFT;
}
}
if (key == 0x59)
{ // Turn kp= on a Mac keyboard into kp= on a PC98 keyboard.
key = DIK_NUMPADEQUALS;
}
// Generate the event, if appropriate.
if (down)
{
if (!foreground || GUICapture)
{ // Do not generate key down events if we are in the background
// or in "GUI Capture" mode.
return;
}
ev.type = EV_KeyDown;
}
else
{
ev.type = EV_KeyUp;
}
if (CheckAndSetKey(key, down))
{ // Key is already down or up.
return;
}
ev.data1 = key;
ev.data2 = Convert[key];
D_PostEvent(&ev);
}
//==========================================================================
//
// FDInputKeyboard - Constructor
//
//==========================================================================
FDInputKeyboard::FDInputKeyboard()
{
Device = NULL;
}
//==========================================================================
//
// FDInputKeyboard - Destructor
//
//==========================================================================
FDInputKeyboard::~FDInputKeyboard()
{
if (Device != NULL)
{
Device->Release();
Device = NULL;
}
}
//==========================================================================
//
// FDInputKeyboard :: GetDevice
//
// Create the device interface and initialize it.
//
//==========================================================================
bool FDInputKeyboard::GetDevice()
{
HRESULT hr;
if (g_pdi3 != NULL)
{ // DirectInput3 interface
hr = g_pdi3->CreateDevice(GUID_SysKeyboard, (LPDIRECTINPUTDEVICE*)&Device, NULL);
}
else if (g_pdi != NULL)
{ // DirectInput8 interface
hr = g_pdi->CreateDevice(GUID_SysKeyboard, &Device, NULL);
}
else
{
hr = -1;
}
if (FAILED(hr))
{
return false;
}
// Yes, this is a keyboard.
hr = Device->SetDataFormat(&c_dfDIKeyboard);
if (FAILED(hr))
{
ufailit:
Device->Release();
Device = NULL;
return false;
}
hr = Device->SetCooperativeLevel(Window, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND);
if (FAILED(hr))
{
goto ufailit;
}
// Set buffer size so we can use buffered input.
DIPROPDWORD prop;
prop.diph.dwSize = sizeof(prop);
prop.diph.dwHeaderSize = sizeof(prop.diph);
prop.diph.dwObj = 0;
prop.diph.dwHow = DIPH_DEVICE;
prop.dwData = DINPUT_BUFFERSIZE;
hr = Device->SetProperty(DIPROP_BUFFERSIZE, &prop.diph);
if (FAILED(hr))
{
goto ufailit;
}
Device->Acquire();
return true;
}
//==========================================================================
//
// FDInputKeyboard :: ProcessInput
//
//==========================================================================
void FDInputKeyboard::ProcessInput()
{
DIDEVICEOBJECTDATA od;
DWORD dwElements;
HRESULT hr;
bool foreground = (GetForegroundWindow() == Window);
for (;;)
{
DWORD cbObjectData = g_pdi3 ? sizeof(DIDEVICEOBJECTDATA_DX3) : sizeof(DIDEVICEOBJECTDATA);
dwElements = 1;
hr = Device->GetDeviceData(cbObjectData, &od, &dwElements, 0);
if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED)
{
Device->Acquire();
hr = Device->GetDeviceData(cbObjectData, &od, &dwElements, 0);
}
if (FAILED(hr) || !dwElements)
{
break;
}
if (od.dwOfs >= 1 && od.dwOfs <= 255)
{
PostKeyEvent(od.dwOfs, od.dwData & 0x80, foreground);
}
}
}
/**************************************************************************/
/**************************************************************************/
//==========================================================================
//
// FRawKeyboard - Constructor
//
//==========================================================================
FRawKeyboard::FRawKeyboard()
{
E1Prefix = 0;
}
//==========================================================================
//
// FRawKeyboard - Destructor
//
//==========================================================================
FRawKeyboard::~FRawKeyboard()
{
RAWINPUTDEVICE rid;
rid.usUsagePage = HID_GENERIC_DESKTOP_PAGE;
rid.usUsage = HID_GDP_KEYBOARD;
rid.dwFlags = RIDEV_REMOVE;
rid.hwndTarget = NULL;
RegisterRawInputDevices(&rid, 1, sizeof(rid));
}
//==========================================================================
//
// FRawKeyboard :: GetDevice
//
// Ensure the API is present and we can listen for keyboard input.
//
//==========================================================================
bool FRawKeyboard::GetDevice()
{
RAWINPUTDEVICE rid;
rid.usUsagePage = HID_GENERIC_DESKTOP_PAGE;
rid.usUsage = HID_GDP_KEYBOARD;
rid.dwFlags = RIDEV_INPUTSINK;
rid.hwndTarget = Window;
if (!RegisterRawInputDevices(&rid, 1, sizeof(rid)))
{
return false;
}
return true;
}
//==========================================================================
//
// FRawKeyboard :: ProcessRawInput
//
// Convert scan codes to DirectInput key codes. For the most part, this is
// straight forward: Scan codes without any prefix are passed unmodified.
// Scan codes with an 0xE0 prefix byte are generally passed by ORing them
// with 0x80. And scan codes with an 0xE1 prefix are the annoying Pause key
// which will generate another scan code that looks like Num Lock.
//
// This is a bit complicated only because the state of PC key codes is a bit
// of a mess. Keyboards may use simpler codes internally, but for the sake
// of compatibility, programs are presented with XT-compatible codes. This
// means that keys which were originally a shifted form of another key and
// were split off into a separate key all their own, or which were formerly
// a separate key and are now part of another key (most notable PrtScn and
// SysRq), will still generate code sequences that XT-era software will
// still perceive as the original sequences to use those keys.
//
//==========================================================================
bool FRawKeyboard::ProcessRawInput(RAWINPUT *raw, int code)
{
if (raw->header.dwType != RIM_TYPEKEYBOARD)
{
return false;
}
int keycode = raw->data.keyboard.MakeCode;
if (keycode == 0 && (raw->data.keyboard.Flags & RI_KEY_E0))
{ // Even if the make code is 0, we might still be able to extract a
// useful key from the message.
if (raw->data.keyboard.VKey >= VK_BROWSER_BACK && raw->data.keyboard.VKey <= VK_LAUNCH_APP2)
{
static const uint8_t MediaKeys[VK_LAUNCH_APP2 - VK_BROWSER_BACK + 1] =
{
DIK_WEBBACK, DIK_WEBFORWARD, DIK_WEBREFRESH, DIK_WEBSTOP,
DIK_WEBSEARCH, DIK_WEBFAVORITES, DIK_WEBHOME,
DIK_MUTE, DIK_VOLUMEDOWN, DIK_VOLUMEUP,
DIK_NEXTTRACK, DIK_PREVTRACK, DIK_MEDIASTOP, DIK_PLAYPAUSE,
DIK_MAIL, DIK_MEDIASELECT, DIK_MYCOMPUTER, DIK_CALCULATOR
};
keycode = MediaKeys[raw->data.keyboard.VKey - VK_BROWSER_BACK];
}
}
if (keycode < 1 || keycode > 0xFF)
{
return false;
}
if (raw->data.keyboard.Flags & RI_KEY_E1)
{
E1Prefix = raw->data.keyboard.MakeCode;
return false;
}
if (raw->data.keyboard.Flags & RI_KEY_E0)
{
if (keycode == DIK_LSHIFT || keycode == DIK_RSHIFT)
{ // Ignore fake shifts.
return false;
}
keycode |= 0x80;
}
// The sequence for an unshifted pause is E1 1D 45 (E1 Prefix +
// Control + Num Lock).
if (E1Prefix)
{
if (E1Prefix == 0x1D && keycode == DIK_NUMLOCK)
{
keycode = DIK_PAUSE;
E1Prefix = 0;
}
else
{
E1Prefix = 0;
return false;
}
}
// If you press Ctrl+Pause, the keyboard sends the Break make code
// E0 46 instead of the Pause make code.
if (keycode == 0xC6)
{
keycode = DIK_PAUSE;
}
// If you press Ctrl+PrtScn (to get SysRq), the keyboard sends
// the make code E0 37. If you press PrtScn without any modifiers,
// it sends E0 2A E0 37. And if you press Alt+PrtScn, it sends 54
// (which is undefined in the charts I can find.)
if (keycode == 0x54)
{
keycode = DIK_SYSRQ;
}
// If you press any keys in the island between the main keyboard
// and the numeric keypad with Num Lock turned on, they generate
// a fake shift before their actual codes. They do not generate this
// fake shift if Num Lock is off. We unconditionally discard fake
// shifts above, so we don't need to do anything special for these,
// since they are also prefixed by E0 so we can tell them apart from
// their keypad counterparts.
// Okay, we're done translating the keycode. Post it (or ignore it.)
PostKeyEvent(keycode, !(raw->data.keyboard.Flags & RI_KEY_BREAK), code == RIM_INPUT);
return true;
}
//==========================================================================
//
// I_StartupKeyboard
//
//==========================================================================
void I_StartupKeyboard()
{
Keyboard = new FRawKeyboard;
if (Keyboard->GetDevice())
{
return;
}
delete Keyboard;
Keyboard = new FDInputKeyboard;
if (!Keyboard->GetDevice())
{
delete Keyboard;
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -387,62 +387,3 @@ FString M_GetDemoPath()
CreatePath(path);
return path;
}
//==========================================================================
//
// I_FindFirst
//
// Start a pattern matching sequence.
//
//==========================================================================
void *I_FindFirst(const char *filespec, findstate_t *fileinfo)
{
static_assert(sizeof(WIN32_FIND_DATAW) == sizeof(fileinfo->FindData), "Findata size mismatch");
auto widespec = WideString(filespec);
fileinfo->UTF8Name = "";
return FindFirstFileW(widespec.c_str(), (LPWIN32_FIND_DATAW)&fileinfo->FindData);
}
//==========================================================================
//
// I_FindNext
//
// Return the next file in a pattern matching sequence.
//
//==========================================================================
int I_FindNext(void *handle, findstate_t *fileinfo)
{
fileinfo->UTF8Name = "";
return !FindNextFileW((HANDLE)handle, (LPWIN32_FIND_DATAW)&fileinfo->FindData);
}
//==========================================================================
//
// I_FindClose
//
// Finish a pattern matching sequence.
//
//==========================================================================
int I_FindClose(void *handle)
{
return FindClose((HANDLE)handle);
}
//==========================================================================
//
// I_FindName
//
// Returns the name for an entry
//
//==========================================================================
const char *I_FindName(findstate_t *fileinfo)
{
if (fileinfo->UTF8Name.IsEmpty()) fileinfo->UTF8Name = fileinfo->FindData.Name;
return fileinfo->UTF8Name.GetChars();
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,182 @@
//-----------------------------------------------------------------------------
//
// Copyright 1993-1996 id Software
// Copyright 1999-2016 Randy Heit
// Copyright 2002-2016 Christoph Oelckers
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/
//
//-----------------------------------------------------------------------------
//
// DESCRIPTION:
// System specific interface stuff.
//
//-----------------------------------------------------------------------------
#ifndef __I_SYSTEM__
#define __I_SYSTEM__
#include "basics.h"
#include <thread>
#include "tarray.h"
#include "zstring.h"
#include "utf8.h"
struct ticcmd_t;
struct WadStuff;
// [RH] Detects the OS the game is running under.
void I_DetectOS (void);
// Called by DoomMain.
void I_Init (void);
// Return a seed value for the RNG.
unsigned int I_MakeRNGSeed();
//
// Called by D_DoomLoop,
// called before processing any tics in a frame
// (just after displaying a frame).
// Time consuming syncronous operations
// are performed here (joystick reading).
// Can call D_PostEvent.
//
void I_StartFrame (void);
//
// Called by D_DoomLoop,
// called before processing each tic in a frame.
// Quick syncronous operations are performed here.
// Can call D_PostEvent.
void I_StartTic (void);
// Asynchronous interrupt functions should maintain private queues
// that are read by the synchronous functions
// to be converted into events.
// Either returns a null ticcmd,
// or calls a loadable driver to build it.
// This ticcmd will then be modified by the gameloop
// for normal input.
ticcmd_t *I_BaseTiccmd (void);
// Called by M_Responder when quit is selected.
// Clean exit, displays sell blurb.
void I_Quit (void);
void I_Tactile (int on, int off, int total);
// Set the mouse cursor. The texture must be 32x32.
class FTexture;
bool I_SetCursor(FTexture *cursor);
// Repaint the pre-game console
void I_PaintConsole (void);
void I_DebugPrint (const char *cp);
// Print a console string
void I_PrintStr (const char *cp);
// Set the title string of the startup window
void I_SetIWADInfo ();
// Pick from multiple IWADs to use
int I_PickIWad (WadStuff *wads, int numwads, bool queryiwad, int defaultiwad);
// The ini could not be saved at exit
bool I_WriteIniFailed ();
// [RH] Used by the display code to set the normal window procedure
void I_SetWndProc();
// [RH] Checks the registry for Steam's install path, so we can scan its
// directories for IWADs if the user purchased any through Steam.
TArray<FString> I_GetSteamPath();
// [GZ] Same deal for GOG paths
TArray<FString> I_GetGogPaths();
// Damn Microsoft for doing Get/SetWindowLongPtr half-assed. Instead of
// giving them proper prototypes under Win32, they are just macros for
// Get/SetWindowLong, meaning they take LONGs and not LONG_PTRs.
#ifdef _WIN64
typedef long long WLONG_PTR;
#elif _MSC_VER
typedef _W64 long WLONG_PTR;
#else
typedef long WLONG_PTR;
#endif
// Wrapper for GetLongPathName
FString I_GetLongPathName(const FString &shortpath);
// Directory searching routines
// Mirror WIN32_FIND_DATAA in <winbase.h>
#ifndef MAX_PATH
#define MAX_PATH 260
#endif
#ifndef PATH_MAX
#define PATH_MAX 260
#endif
struct findstate_t
{
private:
struct WinData
{
uint32_t Attribs;
uint32_t Times[3 * 2];
uint32_t Size[2];
uint32_t Reserved[2];
wchar_t Name[MAX_PATH];
wchar_t AltName[14];
};
WinData FindData;
FString UTF8Name;
friend void *I_FindFirst(const char *filespec, findstate_t *fileinfo);
friend int I_FindNext(void *handle, findstate_t *fileinfo);
friend const char *I_FindName(findstate_t *fileinfo);
friend int I_FindAttr(findstate_t *fileinfo);
};
void *I_FindFirst (const char *filespec, findstate_t *fileinfo);
int I_FindNext (void *handle, findstate_t *fileinfo);
int I_FindClose (void *handle);
const char *I_FindName(findstate_t *fileinfo);
inline int I_FindAttr(findstate_t *fileinfo)
{
return fileinfo->FindData.Attribs;
}
#define FA_RDONLY 0x00000001
#define FA_HIDDEN 0x00000002
#define FA_SYSTEM 0x00000004
#define FA_DIREC 0x00000010
#define FA_ARCH 0x00000020
int I_GetNumaNodeCount();
int I_GetNumaNodeThreadCount(int numaNode);
void I_SetThreadNumaNode(std::thread &thread, int numaNode);
#endif

View file

@ -0,0 +1,844 @@
/*
**
**
**---------------------------------------------------------------------------
** Copyright 2005-2016 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#ifndef NO_XINPUT
// HEADER FILES ------------------------------------------------------------
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <xinput.h>
#include <limits.h>
#include "i_input.h"
#include "d_event.h"
#include "templates.h"
#include "gameconfigfile.h"
#include "m_argv.h"
#include "keydef.h"
// MACROS ------------------------------------------------------------------
// This macro is defined by newer versions of xinput.h. In case we are
// compiling with an older version, define it here.
#ifndef XUSER_MAX_COUNT
#define XUSER_MAX_COUNT 4
#endif
// MinGW
#ifndef XINPUT_DLL
#define XINPUT_DLL_A "xinput1_3.dll"
#define XINPUT_DLL_W L"xinput1_3.dll"
#ifdef UNICODE
#define XINPUT_DLL XINPUT_DLL_W
#else
#define XINPUT_DLL XINPUT_DLL_A
#endif
#endif
// TYPES -------------------------------------------------------------------
typedef DWORD (WINAPI *XInputGetStateType)(DWORD index, XINPUT_STATE *state);
typedef DWORD (WINAPI *XInputSetStateType)(DWORD index, XINPUT_STATE *state);
typedef DWORD (WINAPI *XInputGetCapabilitiesType)(DWORD index, DWORD flags, XINPUT_CAPABILITIES *caps);
typedef void (WINAPI *XInputEnableType)(BOOL enable);
class FXInputController : public IJoystickConfig
{
public:
FXInputController(int index);
~FXInputController();
void ProcessInput();
void AddAxes(float axes[NUM_JOYAXIS]);
bool IsConnected() { return Connected; }
// IJoystickConfig interface
FString GetName();
float GetSensitivity();
virtual void SetSensitivity(float scale);
int GetNumAxes();
float GetAxisDeadZone(int axis);
EJoyAxis GetAxisMap(int axis);
const char *GetAxisName(int axis);
float GetAxisScale(int axis);
void SetAxisDeadZone(int axis, float deadzone);
void SetAxisMap(int axis, EJoyAxis gameaxis);
void SetAxisScale(int axis, float scale);
bool IsSensitivityDefault();
bool IsAxisDeadZoneDefault(int axis);
bool IsAxisMapDefault(int axis);
bool IsAxisScaleDefault(int axis);
void SetDefaultConfig();
FString GetIdentifier();
protected:
struct AxisInfo
{
float Value;
float DeadZone;
float Multiplier;
EJoyAxis GameAxis;
uint8_t ButtonValue;
};
struct DefaultAxisConfig
{
float DeadZone;
EJoyAxis GameAxis;
float Multiplier;
};
enum
{
AXIS_ThumbLX,
AXIS_ThumbLY,
AXIS_ThumbRX,
AXIS_ThumbRY,
AXIS_LeftTrigger,
AXIS_RightTrigger,
NUM_AXES
};
int Index;
float Multiplier;
AxisInfo Axes[NUM_AXES];
static DefaultAxisConfig DefaultAxes[NUM_AXES];
DWORD LastPacketNumber;
int LastButtons;
bool Connected;
void Attached();
void Detached();
static void ProcessThumbstick(int value1, AxisInfo *axis1, int value2, AxisInfo *axis2, int base);
static void ProcessTrigger(int value, AxisInfo *axis, int base);
};
class FXInputManager : public FJoystickCollection
{
public:
FXInputManager();
~FXInputManager();
bool GetDevice();
void ProcessInput();
bool WndProcHook(HWND hWnd, uint32_t message, WPARAM wParam, LPARAM lParam, LRESULT *result);
void AddAxes(float axes[NUM_JOYAXIS]);
void GetDevices(TArray<IJoystickConfig *> &sticks);
IJoystickConfig *Rescan();
protected:
HMODULE XInputDLL;
FXInputController *Devices[XUSER_MAX_COUNT];
};
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
// PUBLIC DATA DEFINITIONS -------------------------------------------------
CUSTOM_CVAR(Bool, joy_xinput, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_NOINITCALL)
{
I_StartupXInput();
event_t ev = { EV_DeviceChange };
D_PostEvent(&ev);
}
// PRIVATE DATA DEFINITIONS ------------------------------------------------
static XInputGetStateType InputGetState;
static XInputSetStateType InputSetState;
static XInputGetCapabilitiesType InputGetCapabilities;
static XInputEnableType InputEnable;
static const char *AxisNames[] =
{
"Left Thumb X Axis",
"Left Thumb Y Axis",
"Right Thumb X Axis",
"Right Thumb Y Axis",
"Left Trigger",
"Right Trigger"
};
FXInputController::DefaultAxisConfig FXInputController::DefaultAxes[NUM_AXES] =
{
// Dead zone, game axis, multiplier
{ XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE / 32768.f, JOYAXIS_Side, 1 }, // ThumbLX
{ XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE / 32768.f, JOYAXIS_Forward, 1 }, // ThumbLY
{ XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE / 32768.f, JOYAXIS_Yaw, 1 }, // ThumbRX
{ XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE / 32768.f, JOYAXIS_Pitch, 0.75 }, // ThumbRY
{ XINPUT_GAMEPAD_TRIGGER_THRESHOLD / 256.f, JOYAXIS_None, 0 }, // LeftTrigger
{ XINPUT_GAMEPAD_TRIGGER_THRESHOLD / 256.f, JOYAXIS_None, 0 } // RightTrigger
};
// CODE --------------------------------------------------------------------
//==========================================================================
//
// FXInputController - Constructor
//
//==========================================================================
FXInputController::FXInputController(int index)
{
Index = index;
Connected = false;
M_LoadJoystickConfig(this);
}
//==========================================================================
//
// FXInputController - Destructor
//
//==========================================================================
FXInputController::~FXInputController()
{
// Send button up events before destroying this.
ProcessThumbstick(0, &Axes[AXIS_ThumbLX], 0, &Axes[AXIS_ThumbLY], KEY_PAD_LTHUMB_RIGHT);
ProcessThumbstick(0, &Axes[AXIS_ThumbRX], 0, &Axes[AXIS_ThumbRY], KEY_PAD_RTHUMB_RIGHT);
ProcessTrigger(0, &Axes[AXIS_LeftTrigger], KEY_PAD_LTRIGGER);
ProcessTrigger(0, &Axes[AXIS_RightTrigger], KEY_PAD_RTRIGGER);
Joy_GenerateButtonEvents(LastButtons, 0, 16, KEY_PAD_DPAD_UP);
M_SaveJoystickConfig(this);
}
//==========================================================================
//
// FXInputController :: ProcessInput
//
//==========================================================================
void FXInputController::ProcessInput()
{
DWORD res;
XINPUT_STATE state;
res = InputGetState(Index, &state);
if (res == ERROR_DEVICE_NOT_CONNECTED)
{
if (Connected)
{
Detached();
}
return;
}
if (res != ERROR_SUCCESS)
{
return;
}
if (!Connected)
{
Attached();
}
if (state.dwPacketNumber == LastPacketNumber)
{ // Nothing has changed since last time.
return;
}
// There is a hole in the wButtons bitmask where two buttons could fit.
// As per the XInput documentation, "bits that are set but not defined ... are reserved,
// and their state is undefined," so we clear them to make sure they're not set.
// Our keymapping uses these two slots for the triggers as buttons.
state.Gamepad.wButtons &= 0xF3FF;
// Convert axes to floating point and cancel out deadzones.
// XInput's Y axes are reversed compared to DirectInput.
ProcessThumbstick(state.Gamepad.sThumbLX, &Axes[AXIS_ThumbLX],
-state.Gamepad.sThumbLY, &Axes[AXIS_ThumbLY], KEY_PAD_LTHUMB_RIGHT);
ProcessThumbstick(state.Gamepad.sThumbRX, &Axes[AXIS_ThumbRX],
-state.Gamepad.sThumbRY, &Axes[AXIS_ThumbRY], KEY_PAD_RTHUMB_RIGHT);
ProcessTrigger(state.Gamepad.bLeftTrigger, &Axes[AXIS_LeftTrigger], KEY_PAD_LTRIGGER);
ProcessTrigger(state.Gamepad.bRightTrigger, &Axes[AXIS_RightTrigger], KEY_PAD_RTRIGGER);
// Generate events for buttons that have changed.
Joy_GenerateButtonEvents(LastButtons, state.Gamepad.wButtons, 16, KEY_PAD_DPAD_UP);
LastPacketNumber = state.dwPacketNumber;
LastButtons = state.Gamepad.wButtons;
}
//==========================================================================
//
// FXInputController :: ProcessThumbstick STATIC
//
// Converts both axes of a thumb stick to floating point, cancels out the
// deadzone, and generates button up/down events for them.
//
//==========================================================================
void FXInputController::ProcessThumbstick(int value1, AxisInfo *axis1,
int value2, AxisInfo *axis2, int base)
{
uint8_t buttonstate;
double axisval1, axisval2;
axisval1 = (value1 - SHRT_MIN) * 2.0 / 65536 - 1.0;
axisval2 = (value2 - SHRT_MIN) * 2.0 / 65536 - 1.0;
axisval1 = Joy_RemoveDeadZone(axisval1, axis1->DeadZone, NULL);
axisval2 = Joy_RemoveDeadZone(axisval2, axis2->DeadZone, NULL);
axis1->Value = float(axisval1);
axis2->Value = float(axisval2);
// We store all four buttons in the first axis and ignore the second.
buttonstate = Joy_XYAxesToButtons(axisval1, axisval2);
Joy_GenerateButtonEvents(axis1->ButtonValue, buttonstate, 4, base);
axis1->ButtonValue = buttonstate;
}
//==========================================================================
//
// FXInputController :: ProcessTrigger STATIC
//
// Much like ProcessThumbstick, except triggers only go in the positive
// direction and have less precision.
//
//==========================================================================
void FXInputController::ProcessTrigger(int value, AxisInfo *axis, int base)
{
uint8_t buttonstate;
double axisval;
axisval = Joy_RemoveDeadZone(value / 256.0, axis->DeadZone, &buttonstate);
Joy_GenerateButtonEvents(axis->ButtonValue, buttonstate, 1, base);
axis->ButtonValue = buttonstate;
axis->Value = float(axisval);
}
//==========================================================================
//
// FXInputController :: Attached
//
// This controller was just attached. Set all buttons and axes to 0.
//
//==========================================================================
void FXInputController::Attached()
{
int i;
Connected = true;
LastPacketNumber = ~0;
LastButtons = 0;
for (i = 0; i < NUM_AXES; ++i)
{
Axes[i].Value = 0;
Axes[i].ButtonValue = 0;
}
UpdateJoystickMenu(this);
}
//==========================================================================
//
// FXInputController :: Detached
//
// This controller was just detached. Send button ups for buttons that
// were pressed the last time we got input from it.
//
//==========================================================================
void FXInputController::Detached()
{
int i;
Connected = false;
for (i = 0; i < 4; i += 2)
{
ProcessThumbstick(0, &Axes[i], 0, &Axes[i+1], KEY_PAD_LTHUMB_RIGHT + i*2);
}
for (i = 0; i < 2; ++i)
{
ProcessTrigger(0, &Axes[4+i], KEY_PAD_LTRIGGER + i);
}
Joy_GenerateButtonEvents(LastButtons, 0, 16, KEY_PAD_DPAD_UP);
LastButtons = 0;
UpdateJoystickMenu(NULL);
}
//==========================================================================
//
// FXInputController :: AddAxes
//
// Add the values of each axis to the game axes.
//
//==========================================================================
void FXInputController::AddAxes(float axes[NUM_JOYAXIS])
{
// Add to game axes.
for (int i = 0; i < NUM_AXES; ++i)
{
axes[Axes[i].GameAxis] -= float(Axes[i].Value * Multiplier * Axes[i].Multiplier);
}
}
//==========================================================================
//
// FXInputController :: SetDefaultConfig
//
//==========================================================================
void FXInputController::SetDefaultConfig()
{
Multiplier = 1;
for (int i = 0; i < NUM_AXES; ++i)
{
Axes[i].DeadZone = DefaultAxes[i].DeadZone;
Axes[i].GameAxis = DefaultAxes[i].GameAxis;
Axes[i].Multiplier = DefaultAxes[i].Multiplier;
}
}
//==========================================================================
//
// FXInputController :: GetIdentifier
//
//==========================================================================
FString FXInputController::GetIdentifier()
{
char id[16];
snprintf(id, countof(id), "XI:%d", Index);
return id;
}
//==========================================================================
//
// FXInputController :: GetName
//
//==========================================================================
FString FXInputController::GetName()
{
FString res;
res.Format("XInput Controller #%d", Index + 1);
return res;
}
//==========================================================================
//
// FXInputController :: GetSensitivity
//
//==========================================================================
float FXInputController::GetSensitivity()
{
return Multiplier;
}
//==========================================================================
//
// FXInputController :: SetSensitivity
//
//==========================================================================
void FXInputController::SetSensitivity(float scale)
{
Multiplier = scale;
}
//==========================================================================
//
// FXInputController :: IsSensitivityDefault
//
//==========================================================================
bool FXInputController::IsSensitivityDefault()
{
return Multiplier == 1;
}
//==========================================================================
//
// FXInputController :: GetNumAxes
//
//==========================================================================
int FXInputController::GetNumAxes()
{
return NUM_AXES;
}
//==========================================================================
//
// FXInputController :: GetAxisDeadZone
//
//==========================================================================
float FXInputController::GetAxisDeadZone(int axis)
{
if (unsigned(axis) < NUM_AXES)
{
return Axes[axis].DeadZone;
}
return 0;
}
//==========================================================================
//
// FXInputController :: GetAxisMap
//
//==========================================================================
EJoyAxis FXInputController::GetAxisMap(int axis)
{
if (unsigned(axis) < NUM_AXES)
{
return Axes[axis].GameAxis;
}
return JOYAXIS_None;
}
//==========================================================================
//
// FXInputController :: GetAxisName
//
//==========================================================================
const char *FXInputController::GetAxisName(int axis)
{
if (unsigned(axis) < NUM_AXES)
{
return AxisNames[axis];
}
return "Invalid";
}
//==========================================================================
//
// FXInputController :: GetAxisScale
//
//==========================================================================
float FXInputController::GetAxisScale(int axis)
{
if (unsigned(axis) < NUM_AXES)
{
return Axes[axis].Multiplier;
}
return 0;
}
//==========================================================================
//
// FXInputController :: SetAxisDeadZone
//
//==========================================================================
void FXInputController::SetAxisDeadZone(int axis, float deadzone)
{
if (unsigned(axis) < NUM_AXES)
{
Axes[axis].DeadZone = clamp(deadzone, 0.f, 1.f);
}
}
//==========================================================================
//
// FXInputController :: SetAxisMap
//
//==========================================================================
void FXInputController::SetAxisMap(int axis, EJoyAxis gameaxis)
{
if (unsigned(axis) < NUM_AXES)
{
Axes[axis].GameAxis = (unsigned(gameaxis) < NUM_JOYAXIS) ? gameaxis : JOYAXIS_None;
}
}
//==========================================================================
//
// FXInputController :: SetAxisScale
//
//==========================================================================
void FXInputController::SetAxisScale(int axis, float scale)
{
if (unsigned(axis) < NUM_AXES)
{
Axes[axis].Multiplier = scale;
}
}
//===========================================================================
//
// FXInputController :: IsAxisDeadZoneDefault
//
//===========================================================================
bool FXInputController::IsAxisDeadZoneDefault(int axis)
{
if (unsigned(axis) < NUM_AXES)
{
return Axes[axis].DeadZone == DefaultAxes[axis].DeadZone;
}
return true;
}
//===========================================================================
//
// FXInputController :: IsAxisScaleDefault
//
//===========================================================================
bool FXInputController::IsAxisScaleDefault(int axis)
{
if (unsigned(axis) < NUM_AXES)
{
return Axes[axis].Multiplier == DefaultAxes[axis].Multiplier;
}
return true;
}
//===========================================================================
//
// FXInputController :: IsAxisMapDefault
//
//===========================================================================
bool FXInputController::IsAxisMapDefault(int axis)
{
if (unsigned(axis) < NUM_AXES)
{
return Axes[axis].GameAxis == DefaultAxes[axis].GameAxis;
}
return true;
}
//==========================================================================
//
// FXInputManager - Constructor
//
//==========================================================================
FXInputManager::FXInputManager()
{
XInputDLL = LoadLibrary(XINPUT_DLL);
if (XInputDLL != NULL)
{
InputGetState = (XInputGetStateType)GetProcAddress(XInputDLL, "XInputGetState");
InputSetState = (XInputSetStateType)GetProcAddress(XInputDLL, "XInputSetState");
InputGetCapabilities = (XInputGetCapabilitiesType)GetProcAddress(XInputDLL, "XInputGetCapabilities");
InputEnable = (XInputEnableType)GetProcAddress(XInputDLL, "XInputEnable");
// Treat XInputEnable() function as optional
// It is not available in xinput9_1_0.dll which is XINPUT_DLL in modern SDKs
// See https://msdn.microsoft.com/en-us/library/windows/desktop/hh405051(v=vs.85).aspx
if (InputGetState == NULL || InputSetState == NULL || InputGetCapabilities == NULL)
{
FreeLibrary(XInputDLL);
XInputDLL = NULL;
}
}
for (int i = 0; i < XUSER_MAX_COUNT; ++i)
{
Devices[i] = (XInputDLL != NULL) ? new FXInputController(i) : NULL;
}
}
//==========================================================================
//
// FXInputManager - Destructor
//
//==========================================================================
FXInputManager::~FXInputManager()
{
for (int i = 0; i < XUSER_MAX_COUNT; ++i)
{
if (Devices[i] != NULL)
{
delete Devices[i];
}
}
if (XInputDLL != NULL)
{
FreeLibrary(XInputDLL);
}
}
//==========================================================================
//
// FXInputManager :: GetDevice
//
//==========================================================================
bool FXInputManager::GetDevice()
{
return (XInputDLL != NULL);
}
//==========================================================================
//
// FXInputManager :: ProcessInput
//
// Process input for every attached device.
//
//==========================================================================
void FXInputManager::ProcessInput()
{
for (int i = 0; i < XUSER_MAX_COUNT; ++i)
{
Devices[i]->ProcessInput();
}
}
//===========================================================================
//
// FXInputManager :: AddAxes
//
// Adds the state of all attached device axes to the passed array.
//
//===========================================================================
void FXInputManager::AddAxes(float axes[NUM_JOYAXIS])
{
for (int i = 0; i < XUSER_MAX_COUNT; ++i)
{
if (Devices[i]->IsConnected())
{
Devices[i]->AddAxes(axes);
}
}
}
//===========================================================================
//
// FXInputManager :: GetJoysticks
//
// Adds the IJoystick interfaces for each device we created to the sticks
// array, if they are detected as connected.
//
//===========================================================================
void FXInputManager::GetDevices(TArray<IJoystickConfig *> &sticks)
{
for (int i = 0; i < XUSER_MAX_COUNT; ++i)
{
if (Devices[i]->IsConnected())
{
sticks.Push(Devices[i]);
}
}
}
//===========================================================================
//
// FXInputManager :: WndProcHook
//
// Enable and disable XInput as our window is (de)activated.
//
//===========================================================================
bool FXInputManager::WndProcHook(HWND hWnd, uint32_t message, WPARAM wParam, LPARAM lParam, LRESULT *result)
{
if (nullptr != InputEnable && message == WM_ACTIVATE)
{
if (LOWORD(wParam) == WA_INACTIVE)
{
InputEnable(FALSE);
}
else
{
InputEnable(TRUE);
}
}
return false;
}
//===========================================================================
//
// FXInputManager :: Rescan
//
//===========================================================================
IJoystickConfig *FXInputManager::Rescan()
{
return NULL;
}
//===========================================================================
//
// I_StartupXInput
//
//===========================================================================
void I_StartupXInput()
{
if (!joy_xinput || !use_joystick || Args->CheckParm("-nojoy"))
{
if (JoyDevices[INPUT_XInput] != NULL)
{
delete JoyDevices[INPUT_XInput];
JoyDevices[INPUT_XInput] = NULL;
UpdateJoystickMenu(NULL);
}
}
else
{
if (JoyDevices[INPUT_XInput] == NULL)
{
FJoystickCollection *joys = new FXInputManager;
if (joys->GetDevice())
{
JoyDevices[INPUT_XInput] = joys;
}
else
{
delete joys;
}
}
}
}
#else // NO_XINPUT
#include "i_input.h"
void I_StartupXInput()
{
JoyDevices[INPUT_XInput] = NULL;
}
#endif

View file

@ -0,0 +1,168 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by zdoom.rc
//
#define IDC_SAVEREPORT 8
#define IDNO2 9
#define IDI_ICON1 101
#define IDD_MIDASINITERROR 108
#define IDD_IWADDIALOG 112
#define IDC_INVISIBLECURSOR 114
#define IDD_CRASHDIALOG 122
#define IDD_EAXPROPERTYLIST 123
#define IDD_DIALOG1 124
#define IDD_EAXEDIT 124
#define IDD_DIALOG2 125
#define IDD_NEWEAX 125
#define IDD_DIALOG3 127
#define IDD_DIALOG4 128
#define IDD_SAVEEAX 128
#define IDB_BITMAP1 131
#define IDB_DEADGUY 131
#define IDD_CRASHDETAILS 133
#define IDD_CRASHOVERVIEW 147
#define IDD_ERRORPANE 148
#define IDD_NETSTARTPANE 149
#define IDC_ERRORMESSAGE 1004
#define IDQUIT 1005
#define IDC_IWADLIST 1006
#define IDC_DONTASKIWAD 1007
#define IDC_SPIN1 1010
#define IDC_SPINID1 1010
#define IDC_CRASHINFO 1011
#define IDC_SPINID2 1011
#define IDC_TOOLTIP1 1012
#define IDCE_ENVIRONMENTSIZE 1025
#define IDCS_ENVIRONMENTSIZE 1026
#define IDC_DECAYTIMESCALE 1027
#define IDC_REFLECTIONSSCALE 1028
#define IDC_REFLECTIONSDELAYSCALE 1029
#define IDC_REVERBSCALE 1030
#define IDC_REVERBDELAYSCALE 1031
#define IDC_DECAYHFLIMIT 1032
#define IDC_ECHOTIMESCALE 1033
#define IDC_MODULATIONTIMESCALE 1034
#define IDC_DUMMY 1035
#define IDC_NEW 1036
#define IDC_SAVE 1037
#define IDC_REVERT 1038
#define IDC_CURRENTENVIRONMENT 1039
#define IDC_ID2 1040
#define IDC_ID1 1041
#define IDC_SHOWIDS 1043
#define IDC_LIST3 1047
#define IDC_ENVIRONMENTLIST 1047
#define IDC_SIZEBOX 1048
#define IDC_EDIT1 1049
#define IDC_NEWENVNAME 1049
#define IDC_CRASHFILECONTENTS 1049
#define IDC_BOINGEDIT 1049
#define IDC_EDITID1 1050
#define IDC_EDITID2 1051
#define IDC_HOTKEY1 1053
#define IDC_LIST1 1054
#define IDC_ENVLIST 1054
#define IDC_CRASHFILES 1054
#define IDC_SELECTALL 1055
#define IDC_SELECTNONE 1056
#define IDC_SAVEGROUP 1057
#define IDC_TESTEAX 1058
#define IDC_RICHEDIT21 1059
#define IDC_CRASHHEADER 1059
#define IDC_RICHEDIT22 1061
#define IDC_PLEASETELLUS 1061
#define IDC_BUTTON2 1062
#define IDC_CRASHDETAILS 1062
#define IDC_DEADGUYVIEWER 1063
#define IDC_CRASHFILESIZE 1066
#define IDC_BUTTON1 1071
#define IDC_BOINGSTATUS 1072
#define IDC_BOINGPROGRESS 1073
#define IDC_TAB1 1074
#define IDC_CRASHTAB 1074
#define IDC_RICHEDIT23 1075
#define IDC_CRASHSUMMARY 1075
#define IDC_ERRORTEXT 1076
#define IDC_ICONPIC 1077
#define IDC_DIVIDERBAR 1078
#define IDC_PROGRESS1 1079
#define IDC_NETSTARTPROGRESS 1079
#define IDC_NETSTARTMESSAGE 1080
#define IDC_NETSTARTCOUNT 1081
#define IDC_STATIC_TITLE 1082
#define IDC_STATIC_STARTUP 1083
#define IDCE_ENVIRONMENTDIFFUSION 1085
#define IDCS_ENVIRONMENTDIFFUSION 1086
#define IDCE_ROOM 1087
#define IDCS_ROOM 1088
#define IDCE_ROOMHF 1089
#define IDCS_ROOMHF 1090
#define IDCE_ROOMLF 1091
#define IDCS_ROOMLF 1092
#define IDCE_DECAYTIME 1093
#define IDCS_DECAYTIME 1094
#define IDCE_DECAYHFRATIO 1095
#define IDCS_DECAYHFRATIO 1096
#define IDCE_DECAYLFRATIO 1097
#define IDCS_DECAYLFRATIO 1098
#define IDCE_REFLECTIONS 1099
#define IDCS_REFLECTIONS 1100
#define IDCE_REFLECTIONSDELAY 1101
#define IDCS_REFLECTIONSDELAY 1102
#define IDCE_REFLECTIONSPANX 1103
#define IDCS_REFLECTIONSPANX 1104
#define IDCE_REFLECTIONSPANY 1105
#define IDCS_REFLECTIONSPANY 1106
#define IDCE_REFLECTIONSPANZ 1107
#define IDCS_REFLECTIONSPANZ 1108
#define IDCE_REVERB 1109
#define IDCS_REVERB 1110
#define IDCE_REVERBDELAY 1111
#define IDCS_REVERBDELAY 1112
#define IDCE_REVERBPANX 1113
#define IDCS_REVERBPANX 1114
#define IDCE_REVERBPANY 1115
#define IDCS_REVERBPANY 1116
#define IDCE_REVERBPANZ 1117
#define IDCS_REVERBPANZ 1118
#define IDCE_ECHOTIME 1119
#define IDCS_ECHOTIME 1120
#define IDCE_ECHODEPTH 1121
#define IDCS_ECHODEPTH 1122
#define IDCE_MODULATIONTIME 1123
#define IDCS_MODULATIONTIME 1124
#define IDCE_MODULATIONDEPTH 1125
#define IDCS_MODULATIONDEPTH 1126
#define IDCE_AIRABSORPTIONHF 1127
#define IDCS_AIRABSORPTIONHF 1128
#define IDCE_HFREFERENCE 1129
#define IDCS_HFREFERENCE 1130
#define IDCE_LFREFERENCE 1131
#define IDCS_LFREFERENCE 1132
#define IDCE_ROOMROLLOFFFACTOR 1133
#define IDCS_ROOMROLLOFFFACTOR 1134
#define IDCS_REFLECTIONSDELAY2 1135
#define IDCE_MODULATIONTIME2 1135
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 151
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1084
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
// [SP] Upstreamed from Zandronum
#define IDC_WELCOME_VERSION 4019 // [RC] "Welcome" screen.
#define IDC_WELCOME_OPENGL 4020
#define IDC_WELCOME_SOFTWARE 4021
#define IDC_WELCOME_FULLSCREEN 4022
// [SP] This is our's.
#define IDC_WELCOME_NOAUTOLOAD 4023
#define IDC_WELCOME_LIGHTS 4024
#define IDC_WELCOME_BRIGHTMAPS 4025
#define IDC_WELCOME_VULKAN 4026

View file

@ -0,0 +1,448 @@
/*
** st_start.cpp
** Handles the startup screen.
**
**---------------------------------------------------------------------------
** Copyright 2006-2007 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
// HEADER FILES ------------------------------------------------------------
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <commctrl.h>
#include "resource.h"
#include "st_start.h"
#include "templates.h"
#include "i_system.h"
#include "i_input.h"
#include "hardware.h"
#include "m_argv.h"
#include "s_music.h"
#include "printf.h"
// MACROS ------------------------------------------------------------------
// How many ms elapse between blinking text flips. On a standard VGA
// adapter, the characters are on for 16 frames and then off for another 16.
// The number here therefore corresponds roughly to the blink rate on a
// 60 Hz display.
#define BLINK_PERIOD 267
#define TEXT_FONT_NAME "vga-rom-font.16"
// TYPES -------------------------------------------------------------------
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
void RestoreConView();
void LayoutMainWindow (HWND hWnd, HWND pane);
int LayoutNetStartPane (HWND pane, int w);
bool ST_Util_CreateStartupWindow ();
void ST_Util_SizeWindowForBitmap (int scale);
void ST_Util_InvalidateRect (HWND hwnd, BitmapInfo *bitmap_info, int left, int top, int right, int bottom);
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
static INT_PTR CALLBACK NetStartPaneProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
extern HINSTANCE g_hInst;
extern HWND Window, ConWindow, ProgressBar, NetStartPane, StartupScreen, GameTitleWindow;
// PUBLIC DATA DEFINITIONS -------------------------------------------------
FStartupScreen *StartScreen;
CUSTOM_CVAR(Int, showendoom, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
{
if (self < 0) self = 0;
else if (self > 2) self=2;
}
// PRIVATE DATA DEFINITIONS ------------------------------------------------
// CODE --------------------------------------------------------------------
//==========================================================================
//
// FStartupScreen :: CreateInstance
//
// Initializes the startup screen for the detected game.
// Sets the size of the progress bar and displays the startup screen.
//
//==========================================================================
FStartupScreen *FStartupScreen::CreateInstance(int max_progress)
{
FStartupScreen *scr = NULL;
scr = new FBasicStartupScreen(max_progress, true);
return scr;
}
//==========================================================================
//
// FBasicStartupScreen Constructor
//
// Shows a progress bar at the bottom of the window.
//
//==========================================================================
FBasicStartupScreen::FBasicStartupScreen(int max_progress, bool show_bar)
: FStartupScreen(max_progress)
{
if (show_bar)
{
ProgressBar = CreateWindowEx(0, PROGRESS_CLASS,
NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
0, 0, 0, 0,
Window, 0, g_hInst, NULL);
SendMessage (ProgressBar, PBM_SETRANGE, 0, MAKELPARAM(0,MaxPos));
LayoutMainWindow (Window, NULL);
}
NetMaxPos = 0;
NetCurPos = 0;
}
//==========================================================================
//
// FBasicStartupScreen Destructor
//
// Called just before entering graphics mode to deconstruct the startup
// screen.
//
//==========================================================================
FBasicStartupScreen::~FBasicStartupScreen()
{
if (ProgressBar != NULL)
{
DestroyWindow (ProgressBar);
ProgressBar = NULL;
LayoutMainWindow (Window, NULL);
}
KillTimer(Window, 1337);
}
//==========================================================================
//
// FBasicStartupScreen :: Progress
//
// Bumps the progress meter one notch.
//
//==========================================================================
void FBasicStartupScreen::Progress()
{
if (CurPos < MaxPos)
{
CurPos++;
SendMessage (ProgressBar, PBM_SETPOS, CurPos, 0);
}
}
//==========================================================================
//
// FBasicStartupScreen :: NetInit
//
// Shows the network startup pane if it isn't visible. Sets the message in
// the pane to the one provided. If numplayers is 0, then the progress bar
// is a scrolling marquee style. If numplayers is 1, then the progress bar
// is just a full bar. If numplayers is >= 2, then the progress bar is a
// normal one, and a progress count is also shown in the pane.
//
//==========================================================================
void FBasicStartupScreen::NetInit(const char *message, int numplayers)
{
NetMaxPos = numplayers;
if (NetStartPane == NULL)
{
NetStartPane = CreateDialogParam (g_hInst, MAKEINTRESOURCE(IDD_NETSTARTPANE), Window, NetStartPaneProc, 0);
// We don't need two progress bars.
if (ProgressBar != NULL)
{
DestroyWindow (ProgressBar);
ProgressBar = NULL;
}
RECT winrect;
GetWindowRect (Window, &winrect);
SetWindowPos (Window, NULL, 0, 0,
winrect.right - winrect.left, winrect.bottom - winrect.top + LayoutNetStartPane (NetStartPane, 0),
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER);
LayoutMainWindow (Window, NULL);
SetFocus (NetStartPane);
}
if (NetStartPane != NULL)
{
HWND ctl;
std::wstring wmessage = WideString(message);
SetDlgItemTextW (NetStartPane, IDC_NETSTARTMESSAGE, wmessage.c_str());
ctl = GetDlgItem (NetStartPane, IDC_NETSTARTPROGRESS);
if (numplayers == 0)
{
// PBM_SETMARQUEE is only available under XP and above, so this might fail.
NetMarqueeMode = SendMessage (ctl, PBM_SETMARQUEE, TRUE, 100);
if (NetMarqueeMode == FALSE)
{
SendMessage (ctl, PBM_SETRANGE, 0, MAKELPARAM(0,16));
}
else
{
// If we don't set the PBS_MARQUEE style, then the marquee will never show up.
SetWindowLong (ctl, GWL_STYLE, GetWindowLong (ctl, GWL_STYLE) | PBS_MARQUEE);
}
SetDlgItemTextW (NetStartPane, IDC_NETSTARTCOUNT, L"");
}
else
{
NetMarqueeMode = FALSE;
SendMessage (ctl, PBM_SETMARQUEE, FALSE, 0);
// Make sure the marquee really is turned off.
SetWindowLong (ctl, GWL_STYLE, GetWindowLong (ctl, GWL_STYLE) & (~PBS_MARQUEE));
SendMessage (ctl, PBM_SETRANGE, 0, MAKELPARAM(0,numplayers));
if (numplayers == 1)
{
SendMessage (ctl, PBM_SETPOS, 1, 0);
SetDlgItemTextW (NetStartPane, IDC_NETSTARTCOUNT, L"");
}
}
}
NetMaxPos = numplayers;
NetCurPos = 0;
NetProgress(1); // You always know about yourself
}
//==========================================================================
//
// FBasicStartupScreen :: NetDone
//
// Removes the network startup pane.
//
//==========================================================================
void FBasicStartupScreen::NetDone()
{
if (NetStartPane != NULL)
{
DestroyWindow (NetStartPane);
NetStartPane = NULL;
LayoutMainWindow (Window, NULL);
}
}
//==========================================================================
//
// FBasicStartupScreen :: NetMessage
//
// Call this between NetInit() and NetDone() instead of Printf() to
// display messages, in case the progress meter is mixed in the same output
// stream as normal messages.
//
//==========================================================================
void FBasicStartupScreen::NetMessage(const char *format, ...)
{
FString str;
va_list argptr;
va_start (argptr, format);
str.VFormat (format, argptr);
va_end (argptr);
Printf ("%s\n", str.GetChars());
}
//==========================================================================
//
// FBasicStartupScreen :: NetProgress
//
// Sets the network progress meter. If count is 0, it gets bumped by 1.
// Otherwise, it is set to count.
//
//==========================================================================
void FBasicStartupScreen :: NetProgress(int count)
{
if (count == 0)
{
NetCurPos++;
}
else
{
NetCurPos = count;
}
if (NetStartPane == NULL)
{
return;
}
if (NetMaxPos == 0 && !NetMarqueeMode)
{
// PBM_SETMARQUEE didn't work, so just increment the progress bar endlessly.
SendDlgItemMessage (NetStartPane, IDC_NETSTARTPROGRESS, PBM_SETPOS, NetCurPos & 15, 0);
}
else if (NetMaxPos > 1)
{
char buf[16];
snprintf (buf, countof(buf), "%d/%d", NetCurPos, NetMaxPos);
SetDlgItemTextA (NetStartPane, IDC_NETSTARTCOUNT, buf);
SendDlgItemMessage (NetStartPane, IDC_NETSTARTPROGRESS, PBM_SETPOS, std::min(NetCurPos, NetMaxPos), 0);
}
}
//==========================================================================
//
// FBasicStartupScreen :: NetLoop
//
// The timer_callback function is called at least two times per second
// and passed the userdata value. It should return true to stop the loop and
// return control to the caller or false to continue the loop.
//
// ST_NetLoop will return true if the loop was halted by the callback and
// false if the loop was halted because the user wants to abort the
// network synchronization.
//
//==========================================================================
bool FBasicStartupScreen::NetLoop(bool (*timer_callback)(void *), void *userdata)
{
BOOL bRet;
MSG msg;
if (SetTimer (Window, 1337, 500, NULL) == 0)
{
I_FatalError ("Could not set network synchronization timer.");
}
while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
{
if (bRet == -1)
{
KillTimer (Window, 1337);
return false;
}
else
{
if (msg.message == WM_TIMER && msg.hwnd == Window && msg.wParam == 1337)
{
if (timer_callback (userdata))
{
KillTimer (NetStartPane, 1);
return true;
}
}
if (!IsDialogMessage (NetStartPane, &msg))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
}
KillTimer (Window, 1337);
return false;
}
//==========================================================================
//
// NetStartPaneProc
//
// DialogProc for the network startup pane. It just waits for somebody to
// click a button, and the only button available is the abort one.
//
//==========================================================================
static INT_PTR CALLBACK NetStartPaneProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDCANCEL)
{
PostQuitMessage (0);
return TRUE;
}
return FALSE;
}
//==========================================================================
//
// FGraphicalStartupScreen Constructor
//
// This doesn't really do anything. The subclass is responsible for
// creating the resources that will be freed by this class's destructor.
//
//==========================================================================
FGraphicalStartupScreen::FGraphicalStartupScreen(int max_progress)
: FBasicStartupScreen(max_progress, false)
{
}
//==========================================================================
//
// FGraphicalStartupScreen Destructor
//
//==========================================================================
FGraphicalStartupScreen::~FGraphicalStartupScreen()
{
if (StartupScreen != NULL)
{
DestroyWindow (StartupScreen);
StartupScreen = NULL;
}
}
//==========================================================================
//
// ST_Util_CreateStartupWindow
//
// Creates the static control that will draw the startup screen.
//
//==========================================================================
bool ST_Util_CreateStartupWindow ()
{
StartupScreen = CreateWindowEx (WS_EX_NOPARENTNOTIFY, L"STATIC", NULL,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SS_OWNERDRAW,
0, 0, 0, 0, Window, NULL, g_hInst, NULL);
if (StartupScreen == NULL)
{
return false;
}
SetWindowLong (StartupScreen, GWL_ID, IDC_STATIC_STARTUP);
return true;
}

View file

View file

@ -0,0 +1,840 @@
#ifndef __wglext_h_
#define __wglext_h_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2013-2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/*
** This header is generated from the Khronos OpenGL / OpenGL ES XML
** API Registry. The current version of the Registry, generator scripts
** used to make the header, and the header can be found at
** http://www.opengl.org/registry/
**
** Khronos $Revision: 27684 $ on $Date: 2014-08-11 01:21:35 -0700 (Mon, 11 Aug 2014) $
*/
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif
#define WGL_WGLEXT_VERSION 20140810
/* Generated C header for:
* API: wgl
* Versions considered: .*
* Versions emitted: _nomatch_^
* Default extensions included: wgl
* Additional extensions included: _nomatch_^
* Extensions removed: _nomatch_^
*/
#ifndef WGL_ARB_buffer_region
#define WGL_ARB_buffer_region 1
#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002
#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004
#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008
typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType);
typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion);
typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height);
typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
#ifdef WGL_WGLEXT_PROTOTYPES
HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType);
VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion);
BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height);
BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
#endif
#endif /* WGL_ARB_buffer_region */
#ifndef WGL_ARB_context_flush_control
#define WGL_ARB_context_flush_control 1
#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
#endif /* WGL_ARB_context_flush_control */
#ifndef WGL_ARB_create_context
#define WGL_ARB_create_context 1
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
#define WGL_CONTEXT_FLAGS_ARB 0x2094
#define ERROR_INVALID_VERSION_ARB 0x2095
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);
#ifdef WGL_WGLEXT_PROTOTYPES
HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList);
#endif
#endif /* WGL_ARB_create_context */
#ifndef WGL_ARB_create_context_profile
#define WGL_ARB_create_context_profile 1
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
#define ERROR_INVALID_PROFILE_ARB 0x2096
#endif /* WGL_ARB_create_context_profile */
#ifndef WGL_ARB_create_context_robustness
#define WGL_ARB_create_context_robustness 1
#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
#endif /* WGL_ARB_create_context_robustness */
#ifndef WGL_ARB_extensions_string
#define WGL_ARB_extensions_string 1
typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
#ifdef WGL_WGLEXT_PROTOTYPES
const char *WINAPI wglGetExtensionsStringARB (HDC hdc);
#endif
#endif /* WGL_ARB_extensions_string */
#ifndef WGL_ARB_framebuffer_sRGB
#define WGL_ARB_framebuffer_sRGB 1
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
#endif /* WGL_ARB_framebuffer_sRGB */
#ifndef WGL_ARB_make_current_read
#define WGL_ARB_make_current_read 1
#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
HDC WINAPI wglGetCurrentReadDCARB (void);
#endif
#endif /* WGL_ARB_make_current_read */
#ifndef WGL_ARB_multisample
#define WGL_ARB_multisample 1
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
#define WGL_SAMPLES_ARB 0x2042
#endif /* WGL_ARB_multisample */
#ifndef WGL_ARB_pbuffer
#define WGL_ARB_pbuffer 1
DECLARE_HANDLE(HPBUFFERARB);
#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
#define WGL_PBUFFER_LARGEST_ARB 0x2033
#define WGL_PBUFFER_WIDTH_ARB 0x2034
#define WGL_PBUFFER_HEIGHT_ARB 0x2035
#define WGL_PBUFFER_LOST_ARB 0x2036
typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
#ifdef WGL_WGLEXT_PROTOTYPES
HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer);
int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC);
BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer);
BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
#endif
#endif /* WGL_ARB_pbuffer */
#ifndef WGL_ARB_pixel_format
#define WGL_ARB_pixel_format 1
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
#define WGL_ACCELERATION_ARB 0x2003
#define WGL_NEED_PALETTE_ARB 0x2004
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
#define WGL_SWAP_METHOD_ARB 0x2007
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
#define WGL_TRANSPARENT_ARB 0x200A
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
#define WGL_SHARE_DEPTH_ARB 0x200C
#define WGL_SHARE_STENCIL_ARB 0x200D
#define WGL_SHARE_ACCUM_ARB 0x200E
#define WGL_SUPPORT_GDI_ARB 0x200F
#define WGL_SUPPORT_OPENGL_ARB 0x2010
#define WGL_DOUBLE_BUFFER_ARB 0x2011
#define WGL_STEREO_ARB 0x2012
#define WGL_PIXEL_TYPE_ARB 0x2013
#define WGL_COLOR_BITS_ARB 0x2014
#define WGL_RED_BITS_ARB 0x2015
#define WGL_RED_SHIFT_ARB 0x2016
#define WGL_GREEN_BITS_ARB 0x2017
#define WGL_GREEN_SHIFT_ARB 0x2018
#define WGL_BLUE_BITS_ARB 0x2019
#define WGL_BLUE_SHIFT_ARB 0x201A
#define WGL_ALPHA_BITS_ARB 0x201B
#define WGL_ALPHA_SHIFT_ARB 0x201C
#define WGL_ACCUM_BITS_ARB 0x201D
#define WGL_ACCUM_RED_BITS_ARB 0x201E
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
#define WGL_DEPTH_BITS_ARB 0x2022
#define WGL_STENCIL_BITS_ARB 0x2023
#define WGL_AUX_BUFFERS_ARB 0x2024
#define WGL_NO_ACCELERATION_ARB 0x2025
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
#define WGL_FULL_ACCELERATION_ARB 0x2027
#define WGL_SWAP_EXCHANGE_ARB 0x2028
#define WGL_SWAP_COPY_ARB 0x2029
#define WGL_SWAP_UNDEFINED_ARB 0x202A
#define WGL_TYPE_RGBA_ARB 0x202B
#define WGL_TYPE_COLORINDEX_ARB 0x202C
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#endif
#endif /* WGL_ARB_pixel_format */
#ifndef WGL_ARB_pixel_format_float
#define WGL_ARB_pixel_format_float 1
#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0
#endif /* WGL_ARB_pixel_format_float */
#ifndef WGL_ARB_render_texture
#define WGL_ARB_render_texture 1
#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070
#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071
#define WGL_TEXTURE_FORMAT_ARB 0x2072
#define WGL_TEXTURE_TARGET_ARB 0x2073
#define WGL_MIPMAP_TEXTURE_ARB 0x2074
#define WGL_TEXTURE_RGB_ARB 0x2075
#define WGL_TEXTURE_RGBA_ARB 0x2076
#define WGL_NO_TEXTURE_ARB 0x2077
#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078
#define WGL_TEXTURE_1D_ARB 0x2079
#define WGL_TEXTURE_2D_ARB 0x207A
#define WGL_MIPMAP_LEVEL_ARB 0x207B
#define WGL_CUBE_MAP_FACE_ARB 0x207C
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082
#define WGL_FRONT_LEFT_ARB 0x2083
#define WGL_FRONT_RIGHT_ARB 0x2084
#define WGL_BACK_LEFT_ARB 0x2085
#define WGL_BACK_RIGHT_ARB 0x2086
#define WGL_AUX0_ARB 0x2087
#define WGL_AUX1_ARB 0x2088
#define WGL_AUX2_ARB 0x2089
#define WGL_AUX3_ARB 0x208A
#define WGL_AUX4_ARB 0x208B
#define WGL_AUX5_ARB 0x208C
#define WGL_AUX6_ARB 0x208D
#define WGL_AUX7_ARB 0x208E
#define WGL_AUX8_ARB 0x208F
#define WGL_AUX9_ARB 0x2090
typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList);
#endif
#endif /* WGL_ARB_render_texture */
#ifndef WGL_ARB_robustness_application_isolation
#define WGL_ARB_robustness_application_isolation 1
#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008
#endif /* WGL_ARB_robustness_application_isolation */
#ifndef WGL_ARB_robustness_share_group_isolation
#define WGL_ARB_robustness_share_group_isolation 1
#endif /* WGL_ARB_robustness_share_group_isolation */
#ifndef WGL_3DFX_multisample
#define WGL_3DFX_multisample 1
#define WGL_SAMPLE_BUFFERS_3DFX 0x2060
#define WGL_SAMPLES_3DFX 0x2061
#endif /* WGL_3DFX_multisample */
#ifndef WGL_3DL_stereo_control
#define WGL_3DL_stereo_control 1
#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055
#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056
#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057
#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058
typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState);
#endif
#endif /* WGL_3DL_stereo_control */
#ifndef WGL_AMD_gpu_association
#define WGL_AMD_gpu_association 1
#define WGL_GPU_VENDOR_AMD 0x1F00
#define WGL_GPU_RENDERER_STRING_AMD 0x1F01
#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02
#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2
#define WGL_GPU_RAM_AMD 0x21A3
#define WGL_GPU_CLOCK_AMD 0x21A4
#define WGL_GPU_NUM_PIPES_AMD 0x21A5
#define WGL_GPU_NUM_SIMD_AMD 0x21A6
#define WGL_GPU_NUM_RB_AMD 0x21A7
#define WGL_GPU_NUM_SPI_AMD 0x21A8
typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids);
typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data);
typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc);
typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id);
typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList);
typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc);
typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc);
typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);
typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#ifdef WGL_WGLEXT_PROTOTYPES
UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids);
INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data);
UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc);
HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id);
HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList);
BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc);
BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc);
HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void);
VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#endif
#endif /* WGL_AMD_gpu_association */
#ifndef WGL_ATI_pixel_format_float
#define WGL_ATI_pixel_format_float 1
#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0
#endif /* WGL_ATI_pixel_format_float */
#ifndef WGL_EXT_create_context_es2_profile
#define WGL_EXT_create_context_es2_profile 1
#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
#endif /* WGL_EXT_create_context_es2_profile */
#ifndef WGL_EXT_create_context_es_profile
#define WGL_EXT_create_context_es_profile 1
#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004
#endif /* WGL_EXT_create_context_es_profile */
#ifndef WGL_EXT_depth_float
#define WGL_EXT_depth_float 1
#define WGL_DEPTH_FLOAT_EXT 0x2040
#endif /* WGL_EXT_depth_float */
#ifndef WGL_EXT_display_color_table
#define WGL_EXT_display_color_table 1
typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id);
typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length);
typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id);
typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id);
#ifdef WGL_WGLEXT_PROTOTYPES
GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id);
GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length);
GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id);
VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id);
#endif
#endif /* WGL_EXT_display_color_table */
#ifndef WGL_EXT_extensions_string
#define WGL_EXT_extensions_string 1
typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void);
#ifdef WGL_WGLEXT_PROTOTYPES
const char *WINAPI wglGetExtensionsStringEXT (void);
#endif
#endif /* WGL_EXT_extensions_string */
#ifndef WGL_EXT_framebuffer_sRGB
#define WGL_EXT_framebuffer_sRGB 1
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9
#endif /* WGL_EXT_framebuffer_sRGB */
#ifndef WGL_EXT_make_current_read
#define WGL_EXT_make_current_read 1
#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
HDC WINAPI wglGetCurrentReadDCEXT (void);
#endif
#endif /* WGL_EXT_make_current_read */
#ifndef WGL_EXT_multisample
#define WGL_EXT_multisample 1
#define WGL_SAMPLE_BUFFERS_EXT 0x2041
#define WGL_SAMPLES_EXT 0x2042
#endif /* WGL_EXT_multisample */
#ifndef WGL_EXT_pbuffer
#define WGL_EXT_pbuffer 1
DECLARE_HANDLE(HPBUFFEREXT);
#define WGL_DRAW_TO_PBUFFER_EXT 0x202D
#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E
#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F
#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030
#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031
#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032
#define WGL_PBUFFER_LARGEST_EXT 0x2033
#define WGL_PBUFFER_WIDTH_EXT 0x2034
#define WGL_PBUFFER_HEIGHT_EXT 0x2035
typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer);
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC);
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer);
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
#ifdef WGL_WGLEXT_PROTOTYPES
HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer);
int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC);
BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer);
BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
#endif
#endif /* WGL_EXT_pbuffer */
#ifndef WGL_EXT_pixel_format
#define WGL_EXT_pixel_format 1
#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000
#define WGL_DRAW_TO_WINDOW_EXT 0x2001
#define WGL_DRAW_TO_BITMAP_EXT 0x2002
#define WGL_ACCELERATION_EXT 0x2003
#define WGL_NEED_PALETTE_EXT 0x2004
#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005
#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006
#define WGL_SWAP_METHOD_EXT 0x2007
#define WGL_NUMBER_OVERLAYS_EXT 0x2008
#define WGL_NUMBER_UNDERLAYS_EXT 0x2009
#define WGL_TRANSPARENT_EXT 0x200A
#define WGL_TRANSPARENT_VALUE_EXT 0x200B
#define WGL_SHARE_DEPTH_EXT 0x200C
#define WGL_SHARE_STENCIL_EXT 0x200D
#define WGL_SHARE_ACCUM_EXT 0x200E
#define WGL_SUPPORT_GDI_EXT 0x200F
#define WGL_SUPPORT_OPENGL_EXT 0x2010
#define WGL_DOUBLE_BUFFER_EXT 0x2011
#define WGL_STEREO_EXT 0x2012
#define WGL_PIXEL_TYPE_EXT 0x2013
#define WGL_COLOR_BITS_EXT 0x2014
#define WGL_RED_BITS_EXT 0x2015
#define WGL_RED_SHIFT_EXT 0x2016
#define WGL_GREEN_BITS_EXT 0x2017
#define WGL_GREEN_SHIFT_EXT 0x2018
#define WGL_BLUE_BITS_EXT 0x2019
#define WGL_BLUE_SHIFT_EXT 0x201A
#define WGL_ALPHA_BITS_EXT 0x201B
#define WGL_ALPHA_SHIFT_EXT 0x201C
#define WGL_ACCUM_BITS_EXT 0x201D
#define WGL_ACCUM_RED_BITS_EXT 0x201E
#define WGL_ACCUM_GREEN_BITS_EXT 0x201F
#define WGL_ACCUM_BLUE_BITS_EXT 0x2020
#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021
#define WGL_DEPTH_BITS_EXT 0x2022
#define WGL_STENCIL_BITS_EXT 0x2023
#define WGL_AUX_BUFFERS_EXT 0x2024
#define WGL_NO_ACCELERATION_EXT 0x2025
#define WGL_GENERIC_ACCELERATION_EXT 0x2026
#define WGL_FULL_ACCELERATION_EXT 0x2027
#define WGL_SWAP_EXCHANGE_EXT 0x2028
#define WGL_SWAP_COPY_EXT 0x2029
#define WGL_SWAP_UNDEFINED_EXT 0x202A
#define WGL_TYPE_RGBA_EXT 0x202B
#define WGL_TYPE_COLORINDEX_EXT 0x202C
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#endif
#endif /* WGL_EXT_pixel_format */
#ifndef WGL_EXT_pixel_format_packed_float
#define WGL_EXT_pixel_format_packed_float 1
#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8
#endif /* WGL_EXT_pixel_format_packed_float */
#ifndef WGL_EXT_swap_control
#define WGL_EXT_swap_control 1
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);
typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglSwapIntervalEXT (int interval);
int WINAPI wglGetSwapIntervalEXT (void);
#endif
#endif /* WGL_EXT_swap_control */
#ifndef WGL_EXT_swap_control_tear
#define WGL_EXT_swap_control_tear 1
#endif /* WGL_EXT_swap_control_tear */
#ifndef WGL_I3D_digital_video_control
#define WGL_I3D_digital_video_control 1
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051
#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052
#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053
typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue);
BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue);
#endif
#endif /* WGL_I3D_digital_video_control */
#ifndef WGL_I3D_gamma
#define WGL_I3D_gamma 1
#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E
#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue);
BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue);
BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
#endif
#endif /* WGL_I3D_gamma */
#ifndef WGL_I3D_genlock
#define WGL_I3D_genlock 1
#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044
#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045
#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046
#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047
#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048
#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049
#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A
#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B
#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C
typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC);
typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC);
typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag);
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource);
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge);
typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate);
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay);
typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglEnableGenlockI3D (HDC hDC);
BOOL WINAPI wglDisableGenlockI3D (HDC hDC);
BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag);
BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource);
BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource);
BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge);
BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge);
BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate);
BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate);
BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay);
BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay);
BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
#endif
#endif /* WGL_I3D_genlock */
#ifndef WGL_I3D_image_buffer
#define WGL_I3D_image_buffer 1
#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001
#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002
typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags);
typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress);
typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count);
#ifdef WGL_WGLEXT_PROTOTYPES
LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags);
BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress);
BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count);
#endif
#endif /* WGL_I3D_image_buffer */
#ifndef WGL_I3D_swap_frame_lock
#define WGL_I3D_swap_frame_lock 1
typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag);
typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglEnableFrameLockI3D (void);
BOOL WINAPI wglDisableFrameLockI3D (void);
BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag);
BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag);
#endif
#endif /* WGL_I3D_swap_frame_lock */
#ifndef WGL_I3D_swap_frame_usage
#define WGL_I3D_swap_frame_usage 1
typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage);
typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglGetFrameUsageI3D (float *pUsage);
BOOL WINAPI wglBeginFrameTrackingI3D (void);
BOOL WINAPI wglEndFrameTrackingI3D (void);
BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
#endif
#endif /* WGL_I3D_swap_frame_usage */
#ifndef WGL_NV_DX_interop
#define WGL_NV_DX_interop 1
#define WGL_ACCESS_READ_ONLY_NV 0x00000000
#define WGL_ACCESS_READ_WRITE_NV 0x00000001
#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002
typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle);
typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice);
typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice);
typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject);
typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access);
typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle);
HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice);
BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice);
HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject);
BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access);
BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
#endif
#endif /* WGL_NV_DX_interop */
#ifndef WGL_NV_DX_interop2
#define WGL_NV_DX_interop2 1
#endif /* WGL_NV_DX_interop2 */
#ifndef WGL_NV_copy_image
#define WGL_NV_copy_image 1
typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
#endif
#endif /* WGL_NV_copy_image */
#ifndef WGL_NV_delay_before_swap
#define WGL_NV_delay_before_swap 1
typedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglDelayBeforeSwapNV (HDC hDC, GLfloat seconds);
#endif
#endif /* WGL_NV_delay_before_swap */
#ifndef WGL_NV_float_buffer
#define WGL_NV_float_buffer 1
#define WGL_FLOAT_COMPONENTS_NV 0x20B0
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4
#define WGL_TEXTURE_FLOAT_R_NV 0x20B5
#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6
#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7
#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8
#endif /* WGL_NV_float_buffer */
#ifndef WGL_NV_gpu_affinity
#define WGL_NV_gpu_affinity 1
DECLARE_HANDLE(HGPUNV);
struct _GPU_DEVICE {
DWORD cb;
CHAR DeviceName[32];
CHAR DeviceString[128];
DWORD Flags;
RECT rcVirtualScreen;
};
typedef struct _GPU_DEVICE *PGPU_DEVICE;
#define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0
#define ERROR_MISSING_AFFINITY_MASK_NV 0x20D1
typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu);
typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList);
typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu);
BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList);
BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
BOOL WINAPI wglDeleteDCNV (HDC hdc);
#endif
#endif /* WGL_NV_gpu_affinity */
#ifndef WGL_NV_multisample_coverage
#define WGL_NV_multisample_coverage 1
#define WGL_COVERAGE_SAMPLES_NV 0x2042
#define WGL_COLOR_SAMPLES_NV 0x20B9
#endif /* WGL_NV_multisample_coverage */
#ifndef WGL_NV_present_video
#define WGL_NV_present_video 1
DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0
typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);
typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue);
#ifdef WGL_WGLEXT_PROTOTYPES
int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);
BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue);
#endif
#endif /* WGL_NV_present_video */
#ifndef WGL_NV_render_depth_texture
#define WGL_NV_render_depth_texture 1
#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3
#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4
#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5
#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6
#define WGL_DEPTH_COMPONENT_NV 0x20A7
#endif /* WGL_NV_render_depth_texture */
#ifndef WGL_NV_render_texture_rectangle
#define WGL_NV_render_texture_rectangle 1
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1
#define WGL_TEXTURE_RECTANGLE_NV 0x20A2
#endif /* WGL_NV_render_texture_rectangle */
#ifndef WGL_NV_swap_group
#define WGL_NV_swap_group 1
typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group);
typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier);
typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier);
typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count);
typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group);
BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier);
BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier);
BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count);
BOOL WINAPI wglResetFrameCountNV (HDC hDC);
#endif
#endif /* WGL_NV_swap_group */
#ifndef WGL_NV_vertex_array_range
#define WGL_NV_vertex_array_range 1
typedef void *(WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer);
#ifdef WGL_WGLEXT_PROTOTYPES
void *WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
void WINAPI wglFreeMemoryNV (void *pointer);
#endif
#endif /* WGL_NV_vertex_array_range */
#ifndef WGL_NV_video_capture
#define WGL_NV_video_capture 1
DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
#define WGL_UNIQUE_ID_NV 0x20CE
#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF
typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
#endif
#endif /* WGL_NV_video_capture */
#ifndef WGL_NV_video_output
#define WGL_NV_video_output 1
DECLARE_HANDLE(HPVIDEODEV);
#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0
#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1
#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2
#define WGL_VIDEO_OUT_COLOR_NV 0x20C3
#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4
#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5
#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6
#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7
#define WGL_VIDEO_OUT_FRAME 0x20C8
#define WGL_VIDEO_OUT_FIELD_1 0x20C9
#define WGL_VIDEO_OUT_FIELD_2 0x20CA
#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB
#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC
typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice);
typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer);
typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice);
BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer);
BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
#endif
#endif /* WGL_NV_video_output */
#ifndef WGL_OML_sync_control
#define WGL_OML_sync_control 1
typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator);
typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
#ifdef WGL_WGLEXT_PROTOTYPES
BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator);
INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
#endif
#endif /* WGL_OML_sync_control */
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,206 @@
/*
** win32video.cpp
** Code to let ZDoom draw to the screen
**
**---------------------------------------------------------------------------
** Copyright 1998-2006 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#include <windows.h>
#include <GL/gl.h>
#include "wglext.h"
#include "gl_sysfb.h"
#include "hardware.h"
#include "templates.h"
#include "version.h"
#include "c_console.h"
#include "v_video.h"
#include "i_input.h"
#include "i_system.h"
#include "v_text.h"
#include "m_argv.h"
#include "printf.h"
#include "win32basevideo.h"
#include "gl/system/gl_framebuffer.h"
CVAR(Int, vid_adapter, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
//==========================================================================
//
//
//
//==========================================================================
Win32BaseVideo::Win32BaseVideo()
{
I_SetWndProc();
GetDisplayDeviceName();
}
//==========================================================================
//
//
//
//==========================================================================
struct MonitorEnumState
{
int curIdx;
HMONITOR hFoundMonitor;
};
static BOOL CALLBACK GetDisplayDeviceNameMonitorEnumProc(HMONITOR hMonitor, HDC, LPRECT, LPARAM dwData)
{
MonitorEnumState *state = reinterpret_cast<MonitorEnumState *>(dwData);
MONITORINFOEX mi;
mi.cbSize = sizeof mi;
GetMonitorInfo(hMonitor, &mi);
// This assumes the monitors are returned by EnumDisplayMonitors in the
// order they're found in the Direct3D9 adapters list. Fingers crossed...
if (state->curIdx == vid_adapter || state->hFoundMonitor == nullptr)
{
state->hFoundMonitor = hMonitor;
// Don't stop enumeration; this makes EnumDisplayMonitors fail. I like
// proper fails.
}
++state->curIdx;
return TRUE;
}
//==========================================================================
//
//
//
//==========================================================================
void Win32BaseVideo::GetDisplayDeviceName()
{
// If anything goes wrong, anything at all, everything uses the primary
// monitor.
m_DisplayDeviceName = 0;
m_hMonitor = 0;
MonitorEnumState mes;
mes.curIdx = 1;
mes.hFoundMonitor = nullptr;
// Could also use EnumDisplayDevices, I guess. That might work.
if (EnumDisplayMonitors(0, 0, &GetDisplayDeviceNameMonitorEnumProc, LPARAM(&mes)))
{
if (mes.hFoundMonitor)
{
MONITORINFOEXA mi;
mi.cbSize = sizeof mi;
if (GetMonitorInfoA(mes.hFoundMonitor, &mi))
{
strcpy(m_DisplayDeviceBuffer, mi.szDevice);
m_DisplayDeviceName = m_DisplayDeviceBuffer;
m_hMonitor = mes.hFoundMonitor;
}
}
}
}
//==========================================================================
//
//
//
//==========================================================================
struct DumpAdaptersState
{
unsigned index;
char *displayDeviceName;
};
static BOOL CALLBACK DumpAdaptersMonitorEnumProc(HMONITOR hMonitor, HDC, LPRECT, LPARAM dwData)
{
DumpAdaptersState *state = reinterpret_cast<DumpAdaptersState *>(dwData);
MONITORINFOEXA mi;
mi.cbSize = sizeof mi;
char moreinfo[64] = "";
bool active = true;
if (GetMonitorInfoA(hMonitor, &mi))
{
bool primary = !!(mi.dwFlags & MONITORINFOF_PRIMARY);
snprintf(moreinfo, countof(moreinfo), " [%ldx%ld @ (%ld,%ld)]%s",
mi.rcMonitor.right - mi.rcMonitor.left,
mi.rcMonitor.bottom - mi.rcMonitor.top,
mi.rcMonitor.left, mi.rcMonitor.top,
primary ? " (Primary)" : "");
if (!state->displayDeviceName && !primary)
active = false;//primary selected, but this ain't primary
else if (state->displayDeviceName && strcmp(state->displayDeviceName, mi.szDevice) != 0)
active = false;//this isn't the selected one
}
Printf("%s%u. %s\n",
active ? TEXTCOLOR_BOLD : "",
state->index,
moreinfo);
++state->index;
return TRUE;
}
//==========================================================================
//
//
//
//==========================================================================
void Win32BaseVideo::DumpAdapters()
{
DumpAdaptersState das;
das.index = 1;
das.displayDeviceName = m_DisplayDeviceName;
EnumDisplayMonitors(0, 0, DumpAdaptersMonitorEnumProc, LPARAM(&das));
}

View file

@ -0,0 +1,33 @@
#pragma once
#include "v_video.h"
//==========================================================================
//
//
//
//==========================================================================
class Win32BaseVideo : public IVideo
{
public:
Win32BaseVideo();
void DumpAdapters();
HDC m_hDC;
protected:
HMODULE hmRender;
char m_DisplayDeviceBuffer[CCHDEVICENAME];
char *m_DisplayDeviceName;
HMONITOR m_hMonitor;
HWND m_Window;
void GetDisplayDeviceName();
public:
virtual void Shutdown() = 0;
};

View file

@ -0,0 +1,474 @@
/*
** win32video.cpp
** Code to let ZDoom draw to the screen
**
**---------------------------------------------------------------------------
** Copyright 1998-2006 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#include <windows.h>
#include <GL/gl.h>
#include "wglext.h"
#include "gl_sysfb.h"
#include "hardware.h"
#include "templates.h"
#include "version.h"
#include "c_console.h"
#include "v_video.h"
#include "i_input.h"
#include "i_system.h"
#include "v_text.h"
#include "m_argv.h"
#include "printf.h"
#include "win32glvideo.h"
#include "gl/system/gl_framebuffer.h"
EXTERN_CVAR(Int, vid_adapter)
EXTERN_CVAR(Bool, vid_hdr)
CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
Printf("This won't take effect until " GAMENAME " is restarted.\n");
}
// For broadest GL compatibility, require user to explicitly enable quad-buffered stereo mode.
// Setting vr_enable_quadbuffered_stereo does not automatically invoke quad-buffered stereo,
// but makes it possible for subsequent "vr_mode 7" to invoke quad-buffered stereo
CUSTOM_CVAR(Bool, vr_enable_quadbuffered, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
Printf("You must restart " GAMENAME " to switch quad stereo mode\n");
}
extern bool vid_hdr_active;
// these get used before GLEW is initialized so we have to use separate pointers with different names
PFNWGLCHOOSEPIXELFORMATARBPROC myWglChoosePixelFormatARB; // = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
PFNWGLCREATECONTEXTATTRIBSARBPROC myWglCreateContextAttribsARB;
//==========================================================================
//
//
//
//==========================================================================
Win32GLVideo::Win32GLVideo()
{
SetPixelFormat();
}
//==========================================================================
//
//
//
//==========================================================================
DFrameBuffer *Win32GLVideo::CreateFrameBuffer()
{
SystemGLFrameBuffer *fb;
fb = new OpenGLRenderer::OpenGLFrameBuffer(m_hMonitor, vid_fullscreen);
return fb;
}
//==========================================================================
//
//
//
//==========================================================================
HWND Win32GLVideo::InitDummy()
{
HMODULE g_hInst = GetModuleHandle(NULL);
HWND dummy;
//Create a rect structure for the size/position of the window
RECT windowRect;
windowRect.left = 0;
windowRect.right = 64;
windowRect.top = 0;
windowRect.bottom = 64;
//Window class structure
WNDCLASS wc;
//Fill in window class struct
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = (WNDPROC)DefWindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = g_hInst;
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = L"GZDoomOpenGLDummyWindow";
//Register window class
if (!RegisterClass(&wc))
{
return 0;
}
//Set window style & extended style
DWORD style, exStyle;
exStyle = WS_EX_CLIENTEDGE;
style = WS_SYSMENU | WS_BORDER | WS_CAPTION;// | WS_VISIBLE;
//Adjust the window size so that client area is the size requested
AdjustWindowRectEx(&windowRect, style, false, exStyle);
//Create Window
if (!(dummy = CreateWindowExW(exStyle,
L"GZDoomOpenGLDummyWindow",
WGAMENAME,
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | style,
0, 0,
windowRect.right - windowRect.left,
windowRect.bottom - windowRect.top,
NULL, NULL,
g_hInst,
NULL)))
{
UnregisterClassW(L"GZDoomOpenGLDummyWindow", g_hInst);
return 0;
}
ShowWindow(dummy, SW_HIDE);
return dummy;
}
//==========================================================================
//
//
//
//==========================================================================
void Win32GLVideo::ShutdownDummy(HWND dummy)
{
DestroyWindow(dummy);
UnregisterClassW(L"GZDoomOpenGLDummyWindow", GetModuleHandle(NULL));
}
//==========================================================================
//
//
//
//==========================================================================
bool Win32GLVideo::SetPixelFormat()
{
HDC hDC;
HGLRC hRC;
HWND dummy;
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
32, // color depth
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
16, // z depth
0, // stencil buffer
0,
PFD_MAIN_PLANE,
0,
0, 0, 0
};
int pixelFormat;
// we have to create a dummy window to init stuff from or the full init stuff fails
dummy = InitDummy();
hDC = GetDC(dummy);
pixelFormat = ChoosePixelFormat(hDC, &pfd);
DescribePixelFormat(hDC, pixelFormat, sizeof(pfd), &pfd);
::SetPixelFormat(hDC, pixelFormat, &pfd);
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);
myWglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
myWglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
// any extra stuff here?
wglMakeCurrent(NULL, NULL);
wglDeleteContext(hRC);
ReleaseDC(dummy, hDC);
ShutdownDummy(dummy);
return true;
}
//==========================================================================
//
//
//
//==========================================================================
static void append(std::vector<int> &list1, std::initializer_list<int> list2)
{
list1.insert(list1.end(), list2);
}
bool Win32GLVideo::SetupPixelFormat(int multisample)
{
int colorDepth;
HDC deskDC;
std::vector<int> attributes;
int pixelFormat;
unsigned int numFormats;
float attribsFloat[] = { 0.0f, 0.0f };
deskDC = GetDC(GetDesktopWindow());
colorDepth = GetDeviceCaps(deskDC, BITSPIXEL);
ReleaseDC(GetDesktopWindow(), deskDC);
if (myWglChoosePixelFormatARB)
{
again:
append(attributes, { WGL_DEPTH_BITS_ARB, 24 });
append(attributes, { WGL_STENCIL_BITS_ARB, 8 });
//required to be true
append(attributes, { WGL_DRAW_TO_WINDOW_ARB, GL_TRUE });
append(attributes, { WGL_SUPPORT_OPENGL_ARB, GL_TRUE });
append(attributes, { WGL_DOUBLE_BUFFER_ARB, GL_TRUE });
if (multisample > 0)
{
append(attributes, { WGL_SAMPLE_BUFFERS_ARB, GL_TRUE });
append(attributes, { WGL_SAMPLES_ARB, multisample });
}
append(attributes, { WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB }); //required to be FULL_ACCELERATION_ARB
if (vr_enable_quadbuffered)
{
// [BB] Starting with driver version 314.07, NVIDIA GeForce cards support OpenGL quad buffered
// stereo rendering with 3D Vision hardware. Select the corresponding attribute here.
append(attributes, { WGL_STEREO_ARB, GL_TRUE });
}
size_t bitsPos = attributes.size();
if (vid_hdr)
{
append(attributes, { WGL_RED_BITS_ARB, 16 });
append(attributes, { WGL_GREEN_BITS_ARB, 16 });
append(attributes, { WGL_BLUE_BITS_ARB, 16 });
append(attributes, { WGL_ALPHA_BITS_ARB, 16 });
append(attributes, { WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_FLOAT_ARB });
}
else
{
append(attributes, { WGL_RED_BITS_ARB, 8 });
append(attributes, { WGL_GREEN_BITS_ARB, 8 });
append(attributes, { WGL_BLUE_BITS_ARB, 8 });
append(attributes, { WGL_ALPHA_BITS_ARB, 8 });
}
append(attributes, { 0, 0 });
if (!myWglChoosePixelFormatARB(m_hDC, attributes.data(), attribsFloat, 1, &pixelFormat, &numFormats))
{
Printf("R_OPENGL: Couldn't choose pixel format. Retrying in compatibility mode\n");
goto oldmethod;
}
if (vid_hdr && numFormats == 0) // This card/driver doesn't support the rgb16f pixel format. Fall back to 8bpc
{
Printf("R_OPENGL: This card/driver does not support RGBA16F. HDR will not work.\n");
attributes.erase(attributes.begin() + bitsPos, attributes.end());
append(attributes, { WGL_RED_BITS_ARB, 8 });
append(attributes, { WGL_GREEN_BITS_ARB, 8 });
append(attributes, { WGL_BLUE_BITS_ARB, 8 });
append(attributes, { WGL_ALPHA_BITS_ARB, 8 });
append(attributes, { 0, 0 });
if (!myWglChoosePixelFormatARB(m_hDC, attributes.data(), attribsFloat, 1, &pixelFormat, &numFormats))
{
Printf("R_OPENGL: Couldn't choose pixel format. Retrying in compatibility mode\n");
goto oldmethod;
}
}
else if (vid_hdr)
{
vid_hdr_active = true;
}
if (numFormats == 0)
{
if (vr_enable_quadbuffered)
{
Printf("R_OPENGL: No valid pixel formats found for VR quadbuffering. Retrying without this feature\n");
vr_enable_quadbuffered = false;
goto again;
}
Printf("R_OPENGL: No valid pixel formats found. Retrying in compatibility mode\n");
goto oldmethod;
}
}
else
{
oldmethod:
// If wglChoosePixelFormatARB is not found we have to do it the old fashioned way.
static PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
32, // color depth
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
32, // z depth
8, // stencil buffer
0,
PFD_MAIN_PLANE,
0,
0, 0, 0
};
pixelFormat = ChoosePixelFormat(m_hDC, &pfd);
DescribePixelFormat(m_hDC, pixelFormat, sizeof(pfd), &pfd);
if (pfd.dwFlags & PFD_GENERIC_FORMAT)
{
I_Error("R_OPENGL: OpenGL driver not accelerated!");
return false;
}
}
if (!::SetPixelFormat(m_hDC, pixelFormat, NULL))
{
I_Error("R_OPENGL: Couldn't set pixel format.\n");
return false;
}
return true;
}
//==========================================================================
//
//
//
//==========================================================================
bool Win32GLVideo::InitHardware(HWND Window, int multisample)
{
m_Window = Window;
m_hDC = GetDC(Window);
if (!SetupPixelFormat(multisample))
{
return false;
}
int prof = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
const char *version = Args->CheckValue("-glversion");
if (version != nullptr && strtod(version, nullptr) < 3.0) prof = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
for (; prof <= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; prof++)
{
m_hRC = NULL;
if (myWglCreateContextAttribsARB != NULL)
{
// let's try to get the best version possible. Some drivers only give us the version we request
// which breaks all version checks for feature support. The highest used features we use are from version 4.4, and 3.0 is a requirement.
static int versions[] = { 46, 45, 44, 43, 42, 41, 40, 33, 32, 31, 30, -1 };
for (int i = 0; versions[i] > 0; i++)
{
int ctxAttribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, versions[i] / 10,
WGL_CONTEXT_MINOR_VERSION_ARB, versions[i] % 10,
WGL_CONTEXT_FLAGS_ARB, gl_debug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0,
WGL_CONTEXT_PROFILE_MASK_ARB, prof,
0
};
m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs);
if (m_hRC != NULL) break;
}
}
if (m_hRC == NULL && prof == WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB)
{
m_hRC = wglCreateContext(m_hDC);
if (m_hRC == NULL)
{
I_Error("R_OPENGL: Unable to create an OpenGL render context.\n");
return false;
}
}
if (m_hRC != NULL)
{
wglMakeCurrent(m_hDC, m_hRC);
return true;
}
}
// We get here if the driver doesn't support the modern context creation API which always means an old driver.
I_Error("R_OPENGL: Unable to create an OpenGL render context. Insufficient driver support for context creation\n");
return false;
}
//==========================================================================
//
//
//
//==========================================================================
void Win32GLVideo::Shutdown()
{
if (m_hRC)
{
wglMakeCurrent(0, 0);
wglDeleteContext(m_hRC);
}
if (m_hDC) ReleaseDC(m_Window, m_hDC);
}

View file

@ -0,0 +1,27 @@
#pragma once
#include "win32basevideo.h"
//==========================================================================
//
//
//
//==========================================================================
class Win32GLVideo : public Win32BaseVideo
{
public:
Win32GLVideo();
DFrameBuffer *CreateFrameBuffer() override;
bool InitHardware(HWND Window, int multisample);
void Shutdown();
protected:
HGLRC m_hRC;
HWND InitDummy();
void ShutdownDummy(HWND dummy);
bool SetPixelFormat();
bool SetupPixelFormat(int multisample);
};

View file

@ -0,0 +1,77 @@
#include <assert.h>
#include <algorithm>
#ifdef _WIN32
#define VK_USE_PLATFORM_WIN32_KHR
#endif
#if 0
#include "volk/volk.h"
extern HWND Window;
void I_GetVulkanDrawableSize(int *width, int *height)
{
assert(Window);
RECT clientRect = { 0 };
GetClientRect(Window, &clientRect);
if (width != nullptr)
{
*width = clientRect.right;
}
if (height != nullptr)
{
*height = clientRect.bottom;
}
}
bool I_GetVulkanPlatformExtensions(unsigned int *count, const char **names)
{
static const char* extensions[] =
{
VK_KHR_SURFACE_EXTENSION_NAME,
VK_KHR_WIN32_SURFACE_EXTENSION_NAME
};
static const unsigned int extensionCount = static_cast<unsigned int>(sizeof extensions / sizeof extensions[0]);
if (count == nullptr && names == nullptr)
{
return false;
}
else if (names == nullptr)
{
*count = extensionCount;
return true;
}
else
{
const bool result = *count >= extensionCount;
*count = std::min<unsigned int>(*count, extensionCount);
for (unsigned int i = 0; i < *count; ++i)
{
names[i] = extensions[i];
}
return result;
}
}
bool I_CreateVulkanSurface(VkInstance instance, VkSurfaceKHR *surface)
{
VkWin32SurfaceCreateInfoKHR windowCreateInfo;
windowCreateInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
windowCreateInfo.pNext = nullptr;
windowCreateInfo.flags = 0;
windowCreateInfo.hwnd = Window;
windowCreateInfo.hinstance = GetModuleHandle(nullptr);
const VkResult result = vkCreateWin32SurfaceKHR(instance, &windowCreateInfo, nullptr, surface);
return result == VK_SUCCESS;
}
#endif

View file

@ -0,0 +1,43 @@
#pragma once
#include "win32basevideo.h"
#include "c_cvars.h"
#include "rendering/vulkan/system/vk_framebuffer.h"
EXTERN_CVAR(Bool, fullscreen)
//==========================================================================
//
//
//
//==========================================================================
class Win32VulkanVideo : public Win32BaseVideo
{
VulkanDevice *device = nullptr;
public:
Win32VulkanVideo()
{
device = new VulkanDevice();
}
~Win32VulkanVideo()
{
delete device;
}
void Shutdown() override
{
delete device;
device = nullptr;
}
DFrameBuffer *CreateFrameBuffer() override
{
auto fb = new VulkanFrameBuffer(m_hMonitor, fullscreen, device);
return fb;
}
protected:
};

View file

@ -0,0 +1,50 @@
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-2001 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
// winres.h - Windows resource definitions
// extracted from WINUSER.H and COMMCTRL.H
#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, off)
#endif
#define VS_VERSION_INFO 1
#ifdef APSTUDIO_INVOKED
#define APSTUDIO_HIDDEN_SYMBOLS // Ignore following symbols
#endif
#ifndef WINVER
#define WINVER 0x0500 // default to Windows Version 4.0
#endif
#include <winresrc.h>
// operation messages sent to DLGINIT
#ifndef __GNUC__
#define LB_ADDSTRING (WM_USER+1)
#define CB_ADDSTRING (WM_USER+3)
#else
#define RT_MANIFEST 24
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
#endif
#ifdef APSTUDIO_INVOKED
#undef APSTUDIO_HIDDEN_SYMBOLS
#endif
#ifdef IDC_STATIC
#undef IDC_STATIC
#endif
#define IDC_STATIC (-1)
#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, on)
#endif

View file

@ -920,7 +920,7 @@ OptionString "Cursors"
OptionMenu "MouseOptions" //protected
{
Title "$MOUSEMNU_TITLE"
Option "$MOUSEMNU_ENABLEMOUSE", "in_mouse", "YesNo"
//Option "$MOUSEMNU_ENABLEMOUSE", "in_mouse", "YesNo"
Option "$MOUSEMNU_MOUSEINMENU", "m_use_mouse", "MenuMouse", "use_mouse"
Option "$MOUSEMNU_SHOWBACKBUTTON", "m_show_backbutton", "Corners", "use_mouse"
// todo Option "$MOUSEMNU_CURSOR", "vid_cursor", "Cursors"