diff --git a/mp/game/mod_hl2mp/resource/GameMenu.res b/mp/game/mod_hl2mp/resource/GameMenu.res index 0903397b..b861f693 100644 --- a/mp/game/mod_hl2mp/resource/GameMenu.res +++ b/mp/game/mod_hl2mp/resource/GameMenu.res @@ -34,6 +34,22 @@ "label" "#GameUI_GameMenu_CreateServer" "command" "OpenCreateMultiplayerGameDialog" } + "7" + { + "label" "#GameUI_GameMenu_ActivateVR" + "command" "engine vr_activate" + "InGameOrder" "40" + "OnlyWhenVREnabled" "1" + "OnlyWhenVRInactive" "1" + } + "8" + { + "label" "#GameUI_GameMenu_DeactivateVR" + "command" "engine vr_deactivate" + "InGameOrder" "40" + "OnlyWhenVREnabled" "1" + "OnlyWhenVRActive" "1" + } "10" { "label" "#GameUI_GameMenu_Options" diff --git a/mp/game/mod_hl2mp/resource/TrackerScheme.res b/mp/game/mod_hl2mp/resource/TrackerScheme.res deleted file mode 100644 index e64f4c61..00000000 --- a/mp/game/mod_hl2mp/resource/TrackerScheme.res +++ /dev/null @@ -1,1210 +0,0 @@ -/////////////////////////////////////////////////////////// -// Tracker scheme resource file -// -// sections: -// Colors - all the colors used by the scheme -// BaseSettings - contains settings for app to use to draw controls -// Fonts - list of all the fonts used by app -// Borders - description of all the borders -// -// hit ctrl-alt-shift-R in the app to reload this file -// -/////////////////////////////////////////////////////////// -Scheme -{ - //////////////////////// COLORS /////////////////////////// - // color details - // this is a list of all the colors used by the scheme - Colors - { - // base colors - "BaseText" "216 222 211 255" // used in text windows, lists - "BrightBaseText" "255 255 255 255" // brightest text - "DimBaseText" "150 159 142 255" // dim base text - "SelectedText" "255 255 255 255" // selected text - - "LabelDimText" "160 170 149 255" // slight modification on above, used for info text - // could be just removed and use DimBaseText? - - "ControlText" "216 222 211 255" // used in all text controls - "BrightControlText" "196 181 80 255" // use for selected controls - "DisabledText1" "117 128 111 255" // disabled text - "DisabledText2" "30 30 30 255" // overlay color for disabled text (to give that inset look) - "DimListText" "117 134 102 255" // offline friends, unsubscribed games, etc. - - // background colors - "ControlBG" "76 88 68 255" // background color of controls - "ControlDarkBG" "90 106 80 255" // darker background color; used for background of scrollbars - "WindowBG" "62 70 55 255" // background color of text edit panes (chat, text entries, etc.) - "SelectionBG" "149 136 49 255" // background color of any selected text or menu item - "SelectionBG2" "40 46 34 255" // selection background in window w/o focus - "ListBG" "62 70 55 255" // background of server browser, buddy list, etc. - - // title colors - "TitleText" "255 255 255 255" - "TitleDimText" "120 132 114 255" - "TitleBG" "76 88 68 0" - "TitleDimBG" "76 88 68 0" - - // slider tick colors - "SliderTickColor" "127 140 127 255" - "SliderTrackColor" "31 31 31 255" - - // border colors - "BorderBright" "136 145 128 255" // the lit side of a control - "BorderDark" "45 49 40 255" // the dark/unlit side of a control - "BorderSelection" "0 0 0 255" // the additional border color for displaying the default/selected button - } - - ///////////////////// BASE SETTINGS //////////////////////// - // - // default settings for all panels - // controls use these to determine their settings - BaseSettings - { - "FgColor" "ControlText" - "BgColor" "ControlBG" - "LabelBgColor" "ControlBG" - "SubPanelBgColor" "ControlBG" - - "DisabledFgColor1" "DisabledText1" - "DisabledFgColor2" "DisabledText2" // set this to the BgColor if you don't want it to draw - - "TitleBarFgColor" "TitleText" - "TitleBarDisabledFgColor" "TitleDimText" - "TitleBarBgColor" "TitleBG" - "TitleBarDisabledBgColor" "TitleDimBG" - -// "TitleBarIcon" "resource/icon_steam" -// "TitleBarDisabledIcon" "resource/icon_steam_disabled" - "TitleBarIcon" "resource/icon_hlicon1" - "TitleBarDisabledIcon" "resource/icon_hlicon2" - - "TitleButtonFgColor" "BorderBright" - "TitleButtonBgColor" "ControlBG" - "TitleButtonDisabledFgColor" "TitleDimText" - "TitleButtonDisabledBgColor" "TitleDimBG" - - "TextCursorColor" "BaseText" // color of the blinking text cursor in text entries - "URLTextColor" "BrightBaseText" // color that URL's show up in chat window - - Menu - { - "FgColor" "DimBaseText" - "BgColor" "ControlBG" - "ArmedFgColor" "BrightBaseText" - "ArmedBgColor" "SelectionBG" - "DividerColor" "BorderDark" - - "TextInset" "6" - } - - MenuButton // the little arrow on the side of boxes that triggers drop down menus - { - "ButtonArrowColor" "DimBaseText" // color of arrows - "ButtonBgColor" "WindowBG" // bg color of button. same as background color of text edit panes - - "ArmedArrowColor" "BrightBaseText" // color of arrow when mouse is over button - "ArmedBgColor" "DimBaseText" // bg color of button when mouse is over button - } - - Slider - { - "SliderFgColor" "ControlBG" // handle with which the slider is grabbed - "SliderBgColor" "ControlDarkBG" // area behind handle - "SliderTickColor" "127 140 127 255" // slider tick's color - "SliderTickLabelColor" "127 140 127 255" // color of labels at the ends of the slider tick - } - - ScrollBarSlider - { - "BgColor" "ControlBG" // this isn't really used - - "ScrollBarSliderFgColor" "ControlBG" // handle with which the slider is grabbed - "ScrollBarSliderBgColor" "ControlDarkBG" // area behind handle - - "ButtonFgColor" "DimBaseText" // color of arrows - } - - - // text edit windows - "WindowFgColor" "BaseText" // off-white - "WindowBgColor" "WindowBG" - "WindowDisabledFgColor" "DimBaseText" - "WindowDisabledBgColor" "66 80 60 255" // background of chat conversation - - "SelectionFgColor" "255 255 255 255" // fg color of selected text - "SelectionBgColor" "SelectionBG" - "ListSelectionFgColor" "255 255 255 255" // - - "ListBgColor" "62 70 55 255" // background of server browser control, etc - "BuddyListBgColor" "62 70 55 255" // background of buddy list pane - - // App-specific stuff - "ChatBgColor" "WindowBgColor" - - // status selection - "StatusSelectFgColor" "BrightBaseText" - "StatusSelectFgColor2" "BrightControlText" // this is the color of the friends status - - // checkboxes - "CheckButtonBorder1" "BorderDark" // the left checkbutton border - "CheckButtonBorder2" "BorderBright" // the right checkbutton border - "CheckButtonCheck" "0 0 0 255" // color of the check itself - "CheckBgColor" "158 168 150 255" - - // buttons (default fg/bg colors are used if these are not set) -// "ButtonArmedFgColor" -// "ButtonArmedBgColor" -// "ButtonDepressedFgColor" "BrightControlText" -// "ButtonDepressedBgColor" - - // buddy buttons - BuddyButton - { - "FgColor1" "ControlText" - "FgColor2" "117 134 102 255" - - "ArmedFgColor1" "BrightBaseText" - "ArmedFgColor2" "BrightBaseText" - "ArmedBgColor" "SelectionBG" - } - - Chat - { - "TextColor" "BrightControlText" - "SelfTextColor" "BaseText" - "SeperatorTextColor" "DimBaseText" - } - - InGameDesktop - { - "MenuColor" "200 200 200 255" - "ArmedMenuColor" "255 255 255 255" - "DepressedMenuColor" "192 186 80 255" - "WidescreenBarColor" "0 0 0 0" - "MenuItemVisibilityRate" "0.03" // time it takes for one menu item to appear - "MenuItemHeight" "28" - "GameMenuInset" "32" - } - - "SectionTextColor" "BrightControlText" // text color for IN-GAME, ONLINE, OFFLINE sections of buddy list - "SectionDividerColor" "BorderDark" // color of line that runs under section name in buddy list - - // TF2 HUD - "HudStatusBgColor" "0 0 0 64" - "HudStatusSelectedBgColor" "0 0 0 192" - } - - // - //////////////////////// FONTS ///////////////////////////// - // - // describes all the fonts - Fonts - { - // fonts are used in order that they are listed - // fonts listed later in the order will only be used if they fulfill a range not already filled - // if a font fails to load then the subsequent fonts will replace - // fonts are used in order that they are listed - "DebugFixed" - { - "1" - { - "name" "Courier New" - "tall" "10" - "weight" "500" - "antialias" "1" - "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A - } - } - // fonts are used in order that they are listed - "DebugFixedSmall" - { - "1" - { - "name" "Courier New" - "tall" "7" - "weight" "500" - "antialias" "1" - "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A - } - } - "Default" - { - "1" - { - "name" "Tahoma" - "tall" "16" - "weight" "500" - "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A - } - } - "DefaultUnderline" - { - "1" - { - "name" "Tahoma" - "tall" "16" - "weight" "500" - "underline" "1" - "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A - } - } - "DefaultSmall" - { - "1" - { - "name" "Tahoma" - "tall" "13" - "weight" "0" - "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A - } - } - "DefaultSmallDropShadow" - { - "1" - { - "name" "Tahoma" - "tall" "13" - "weight" "0" - "dropshadow" "1" - "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A - } - } - "DefaultVerySmall" - { - "1" - { - "name" "Tahoma" - "tall" "12" - "weight" "0" - "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A - } - } - - "DefaultLarge" - { - "1" - { - "name" "Tahoma" - "tall" "18" - "weight" "0" - "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A - } - } - - "MenuLarge" - { - "1" - { - "name" "Verdana" - "tall" "20" - "weight" "1000" - "antialias" "1" - } - } - - "ConsoleText" - { - "1" - { - "name" "Tahoma" - "tall" "13" - "weight" "500" - "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A - } - } - - // this is the symbol font - "Marlett" - { - "1" - { - "name" "Marlett" - "tall" "14" - "weight" "0" - "symbol" "1" - "range" "0x0000 0x007F" // Basic Latin - } - } - - "Trebuchet24" - { - "1" - { - "name" "Trebuchet MS" - "tall" "24" - "weight" "900" - "range" "0x0000 0x007F" // Basic Latin - } - } - - - "Trebuchet20" - { - "1" - { - "name" "Trebuchet MS" - "tall" "20" - "weight" "900" - "range" "0x0000 0x007F" // Basic Latin - } - } - - "Trebuchet18" - { - "1" - { - "name" "Trebuchet MS" - "tall" "18" - "weight" "900" - "range" "0x0000 0x007F" // Basic Latin - } - } - - // HUD numbers - // We use multiple fonts to 'pulse' them in the HUD, hence the need for many of near size - "HUDNumber" - { - "1" - { - "name" "Trebuchet MS" - "tall" "40" - "weight" "900" - "range" "0x0000 0x007F" // Basic Latin - } - } - "HUDNumber1" - { - "1" - { - "name" "Trebuchet MS" - "tall" "41" - "weight" "900" - "range" "0x0000 0x007F" // Basic Latin - } - } - "HUDNumber2" - { - "1" - { - "name" "Trebuchet MS" - "tall" "42" - "weight" "900" - "range" "0x0000 0x007F" // Basic Latin - } - } - "HUDNumber3" - { - "1" - { - "name" "Trebuchet MS" - "tall" "43" - "weight" "900" - "range" "0x0000 0x007F" // Basic Latin - } - } - "HUDNumber4" - { - "1" - { - "name" "Trebuchet MS" - "tall" "44" - "weight" "900" - "range" "0x0000 0x007F" // Basic Latin - } - } - "HUDNumber5" - { - "1" - { - "name" "Trebuchet MS" - "tall" "45" - "weight" "900" - "range" "0x0000 0x007F" // Basic Latin - } - } - "DefaultFixed" - { - "1" - { - "name" "Lucida Console" - "tall" "10" - "weight" "0" - "range" "0x0000 0x007F" // Basic Latin - } -// "1" -// { -// "name" "FixedSys" -// "tall" "20" -// "weight" "0" -// "range" "0x0000 0x007F" // Basic Latin -// } - } - - "DefaultFixedDropShadow" - { - "1" - { - "name" "Lucida Console" - "tall" "10" - "weight" "0" - "dropshadow" "1" - "range" "0x0000 0x007F" // Basic Latin - } -// "1" -// { -// "name" "FixedSys" -// "tall" "20" -// "weight" "0" -// "range" "0x0000 0x007F" // Basic Latin -// } - } - - "DefaultFixedOutline" - { - "1" - { - "name" "Lucida Console" - "tall" "10" - "weight" "0" - "outline" "1" - "range" "0x0000 0x007F" // Basic Latin - } -// "1" -// { -// "name" "FixedSys" -// "tall" "20" -// "weight" "0" -// "range" "0x0000 0x007F" // Basic Latin -// } - } - - "CloseCaption_Normal" - { - "1" - { - "name" "Tahoma" - "tall" "16" - "weight" "500" - "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A - } - } - "CloseCaption_Italic" - { - "1" - { - "name" "Tahoma" - "tall" "16" - "weight" "500" - "italic" "1" - "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A - } - } - "CloseCaption_Bold" - { - "1" - { - "name" "Tahoma" - "tall" "16" - "weight" "900" - "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A - } - } - "CloseCaption_BoldItalic" - { - "1" - { - "name" "Tahoma" - "tall" "16" - "weight" "900" - "italic" "1" - "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A - } - } - - TitleFont - { - "1" - { - "name" "HalfLife2" - "tall" "72" - "weight" "400" - "antialias" "1" - } - } - } - - // - //////////////////// BORDERS ////////////////////////////// - // - // describes all the border types - Borders - { - BaseBorder - { - "inset" "0 0 1 1" - Left - { - "1" - { - "color" "BorderDark" - "offset" "0 1" - } - } - - Right - { - "1" - { - "color" "BorderBright" - "offset" "1 0" - } - } - - Top - { - "1" - { - "color" "BorderDark" - "offset" "0 0" - } - } - - Bottom - { - "1" - { - "color" "BorderBright" - "offset" "0 0" - } - } - } - - TitleButtonBorder - { - "inset" "0 0 1 1" - Left - { - "1" - { - "color" "BorderBright" - "offset" "0 1" - } - } - - Right - { - "1" - { - "color" "BorderDark" - "offset" "1 0" - } - } - - Top - { - "4" - { - "color" "BorderBright" - "offset" "0 0" - } - } - - Bottom - { - "1" - { - "color" "BorderDark" - "offset" "0 0" - } - } - } - - TitleButtonDisabledBorder - { - "inset" "0 0 1 1" - Left - { - "1" - { - "color" "BgColor" - "offset" "0 1" - } - } - - Right - { - "1" - { - "color" "BgColor" - "offset" "1 0" - } - } - Top - { - "1" - { - "color" "BgColor" - "offset" "0 0" - } - } - - Bottom - { - "1" - { - "color" "BgColor" - "offset" "0 0" - } - } - } - - TitleButtonDepressedBorder - { - "inset" "1 1 1 1" - Left - { - "1" - { - "color" "BorderDark" - "offset" "0 1" - } - } - - Right - { - "1" - { - "color" "BorderBright" - "offset" "1 0" - } - } - - Top - { - "1" - { - "color" "BorderDark" - "offset" "0 0" - } - } - - Bottom - { - "1" - { - "color" "BorderBright" - "offset" "0 0" - } - } - } - - ScrollBarButtonBorder - { - "inset" "2 2 0 0" - Left - { - "1" - { - "color" "BorderBright" - "offset" "0 1" - } - } - - Right - { - "1" - { - "color" "BorderDark" - "offset" "1 0" - } - } - - Top - { - "1" - { - "color" "BorderBright" - "offset" "0 0" - } - } - - Bottom - { - "1" - { - "color" "BorderDark" - "offset" "0 0" - } - } - } - - ScrollBarButtonDepressedBorder - { - "inset" "2 2 0 0" - Left - { - "1" - { - "color" "BorderDark" - "offset" "0 1" - } - } - - Right - { - "1" - { - "color" "BorderBright" - "offset" "1 0" - } - } - - Top - { - "1" - { - "color" "BorderDark" - "offset" "0 0" - } - } - - Bottom - { - "1" - { - "color" "BorderBright" - "offset" "0 0" - } - } - } - - ButtonBorder - { - "inset" "0 0 1 1" - Left - { - "1" - { - "color" "BorderBright" - "offset" "0 1" - } - } - - Right - { - "1" - { - "color" "BorderDark" - "offset" "0 0" - } - } - - Top - { - "1" - { - "color" "BorderBright" - "offset" "0 1" - } - } - - Bottom - { - "1" - { - "color" "BorderDark" - "offset" "0 0" - } - } - } - - FrameBorder - { - "inset" "0 0 1 1" - Left - { - "1" - { - "color" "BorderBright" - "offset" "0 1" - } - } - - Right - { - "1" - { - "color" "BorderDark" - "offset" "0 0" - } - } - - Top - { - "1" - { - "color" "BorderBright" - "offset" "0 1" - } - } - - Bottom - { - "1" - { - "color" "BorderDark" - "offset" "0 0" - } - } - } - - TabBorder - { - "inset" "0 0 1 1" - Left - { - "1" - { - "color" "BorderBright" - "offset" "0 1" - } - } - - Right - { - "1" - { - "color" "BorderDark" - "offset" "1 0" - } - } - - Top - { - "1" - { - "color" "BorderBright" - "offset" "0 0" - } - } - - Bottom - { - "1" - { - "color" "BorderBright" - "offset" "0 0" - } - } - } - - TabActiveBorder - { - "inset" "0 0 1 0" - Left - { - "1" - { - "color" "BorderBright" - "offset" "0 0" - } - } - - Right - { - "1" - { - "color" "BorderDark" - "offset" "1 0" - } - } - - Top - { - "1" - { - "color" "BorderBright" - "offset" "0 0" - } - } - - Bottom - { - "1" - { - "color" "ControlBG" - "offset" "6 2" - } - } - } - - - ToolTipBorder - { - "inset" "0 0 1 0" - Left - { - "1" - { - "color" "BorderDark" - "offset" "0 0" - } - } - - Right - { - "1" - { - "color" "BorderDark" - "offset" "1 0" - } - } - - Top - { - "1" - { - "color" "BorderDark" - "offset" "0 0" - } - } - - Bottom - { - "1" - { - "color" "BorderDark" - "offset" "0 0" - } - } - } - - // this is the border used for default buttons (the button that gets pressed when you hit enter) - ButtonKeyFocusBorder - { - "inset" "0 0 1 1" - Left - { - "1" - { - "color" "BorderSelection" - "offset" "0 0" - } - "2" - { - "color" "BorderBright" - "offset" "0 1" - } - } - Top - { - "1" - { - "color" "BorderSelection" - "offset" "0 0" - } - "2" - { - "color" "BorderBright" - "offset" "1 0" - } - } - Right - { - "1" - { - "color" "BorderSelection" - "offset" "0 0" - } - "2" - { - "color" "BorderDark" - "offset" "1 0" - } - } - Bottom - { - "1" - { - "color" "BorderSelection" - "offset" "0 0" - } - "2" - { - "color" "BorderDark" - "offset" "0 0" - } - } - } - - ButtonDepressedBorder - { - "inset" "2 1 1 1" - Left - { - "1" - { - "color" "BorderDark" - "offset" "0 1" - } - } - - Right - { - "1" - { - "color" "BorderBright" - "offset" "1 0" - } - } - - Top - { - "1" - { - "color" "BorderDark" - "offset" "0 0" - } - } - - Bottom - { - "1" - { - "color" "BorderBright" - "offset" "0 0" - } - } - } - - ComboBoxBorder - { - "inset" "0 0 1 1" - Left - { - "1" - { - "color" "BorderDark" - "offset" "0 1" - } - } - - Right - { - "1" - { - "color" "BorderBright" - "offset" "1 0" - } - } - - Top - { - "1" - { - "color" "BorderDark" - "offset" "0 0" - } - } - - Bottom - { - "1" - { - "color" "BorderBright" - "offset" "0 0" - } - } - } - - MenuBorder - { - "inset" "1 1 1 1" - Left - { - "1" - { - "color" "BorderBright" - "offset" "0 1" - } - } - - Right - { - "1" - { - "color" "BorderDark" - "offset" "1 0" - } - } - - Top - { - "1" - { - "color" "BorderBright" - "offset" "0 0" - } - } - - Bottom - { - "1" - { - "color" "BorderDark" - "offset" "0 0" - } - } - } - - BrowserBorder - { - "inset" "0 0 0 1" - Left - { - "1" - { - "color" "BorderDark" - "offset" "0 1" - } - } - - Right - { - "1" - { - "color" "BorderBright" - "offset" "0 0" - } - } - - Top - { - "1" - { - "color" "BorderDark" - "offset" "0 0" - } - } - - Bottom - { - "1" - { - "color" "BorderBright" - "offset" "0 0" - } - } - } - } - - //////////////////////// CUSTOM FONT FILES ///////////////////////////// - // - // specifies all the custom (non-system) font files that need to be loaded to service the above described fonts - CustomFontFiles - { - "1" "resource/HALFLIFE2.ttf" - } -} \ No newline at end of file diff --git a/mp/src/common/studiobyteswap.cpp b/mp/src/common/studiobyteswap.cpp index d7723d48..0c4e59d8 100644 --- a/mp/src/common/studiobyteswap.cpp +++ b/mp/src/common/studiobyteswap.cpp @@ -1915,6 +1915,22 @@ int ByteswapMDLFile( void *pDestBase, void *pSrcBase, const int fileSize ) SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, qalignmentindex ) WriteBuffer( &pDataDest, &pDataSrc, 4*numBones ); } + + /** BONE FLEX DRIVERS **/ + if ( pStudioHdr2->m_nBoneFlexDriverIndex ) + { + SET_INDEX_POINTERS_FIXUP( pData, pStudioHdr2, m_nBoneFlexDriverIndex ) + DECLARE_OBJECT_POINTERS( pBoneFlexDriver, pData, mstudioboneflexdriver_t ) + ITERATE_BLOCK( pBoneFlexDriver, pStudioHdr2->m_nBoneFlexDriverCount ) + { + WriteObjects( pBoneFlexDriverDest, pBoneFlexDriverSrc ); + + /** BONE FLEX DRIVER CONTROLS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pBoneFlexDriver, m_nControlIndex ); + WriteObjects< mstudioboneflexdrivercontrol_t >( &pDataDest, &pDataSrc, SrcNative( &pBoneFlexDriver->m_nControlCount ) ); + } + } } } @@ -2516,7 +2532,8 @@ BEGIN_BYTESWAP_DATADESC( studiohdr_t ) DEFINE_INDEX( unused4, FIELD_INTEGER ), DEFINE_FIELD( numflexcontrollerui, FIELD_INTEGER ), DEFINE_INDEX( flexcontrolleruiindex, FIELD_INTEGER ), - DEFINE_ARRAY( unused3, FIELD_INTEGER, 2 ), + DEFINE_FIELD( flVertAnimFixedPointScale, FIELD_FLOAT ), + DEFINE_ARRAY( unused3, FIELD_INTEGER, 1 ), DEFINE_INDEX( studiohdr2index, FIELD_INTEGER ), DEFINE_ARRAY( unused2, FIELD_INTEGER, 1 ), END_BYTESWAP_DATADESC() @@ -2530,7 +2547,9 @@ BEGIN_BYTESWAP_DATADESC( studiohdr2_t ) DEFINE_FIELD( flMaxEyeDeflection, FIELD_FLOAT ), DEFINE_INDEX( linearboneindex, FIELD_INTEGER ), DEFINE_INDEX( sznameindex, FIELD_INTEGER ), - DEFINE_ARRAY( reserved, FIELD_INTEGER, 58 ), + DEFINE_INDEX( m_nBoneFlexDriverCount, FIELD_INTEGER ), + DEFINE_INDEX( m_nBoneFlexDriverIndex, FIELD_INTEGER ), + DEFINE_ARRAY( reserved, FIELD_INTEGER, 56 ), END_BYTESWAP_DATADESC() BEGIN_BYTESWAP_DATADESC( mstudiobone_t ) @@ -2567,6 +2586,20 @@ BEGIN_BYTESWAP_DATADESC( mstudiolinearbone_t ) DEFINE_ARRAY( unused, FIELD_INTEGER, 6 ), END_BYTESWAP_DATADESC() +BEGIN_BYTESWAP_DATADESC( mstudioboneflexdrivercontrol_t ) + DEFINE_INDEX( m_nBoneComponent, FIELD_INTEGER ), + DEFINE_FIELD( m_nFlexControllerIndex, FIELD_INTEGER ), + DEFINE_INDEX( m_flMin, FIELD_FLOAT ), + DEFINE_INDEX( m_flMax, FIELD_FLOAT ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioboneflexdriver_t ) + DEFINE_INDEX( m_nBoneIndex, FIELD_INTEGER ), + DEFINE_FIELD( m_nControlCount, FIELD_INTEGER ), + DEFINE_INDEX( m_nControlIndex, FIELD_FLOAT ), + DEFINE_ARRAY( unused, FIELD_INTEGER, 3 ), +END_BYTESWAP_DATADESC() + BEGIN_BYTESWAP_DATADESC( mstudioaxisinterpbone_t ) DEFINE_FIELD( control, FIELD_INTEGER ), DEFINE_FIELD( axis, FIELD_INTEGER ), diff --git a/mp/src/devtools/bin/linux/ccache b/mp/src/devtools/bin/linux/ccache index 3ef6b8e9..5146484f 100755 Binary files a/mp/src/devtools/bin/linux/ccache and b/mp/src/devtools/bin/linux/ccache differ diff --git a/mp/src/devtools/bin/osx32/ccache b/mp/src/devtools/bin/osx32/ccache index 86afc048..1b6a2e5f 100755 Binary files a/mp/src/devtools/bin/osx32/ccache and b/mp/src/devtools/bin/osx32/ccache differ diff --git a/mp/src/devtools/bin/vpc.exe b/mp/src/devtools/bin/vpc.exe index 2394de95..fcadab1c 100644 Binary files a/mp/src/devtools/bin/vpc.exe and b/mp/src/devtools/bin/vpc.exe differ diff --git a/mp/src/devtools/bin/vpc_linux b/mp/src/devtools/bin/vpc_linux index c69b62f5..47a07ba5 100755 Binary files a/mp/src/devtools/bin/vpc_linux and b/mp/src/devtools/bin/vpc_linux differ diff --git a/mp/src/devtools/bin/vpc_osx b/mp/src/devtools/bin/vpc_osx index 701d780e..d3ab3de6 100755 Binary files a/mp/src/devtools/bin/vpc_osx and b/mp/src/devtools/bin/vpc_osx differ diff --git a/mp/src/dx10sdk/Utilities/dx9_30/dx_proxy.dll b/mp/src/dx10sdk/Utilities/dx9_30/dx_proxy.dll index 7caf4720..12b94b57 100644 Binary files a/mp/src/dx10sdk/Utilities/dx9_30/dx_proxy.dll and b/mp/src/dx10sdk/Utilities/dx9_30/dx_proxy.dll differ diff --git a/mp/src/dx9sdk/utilities/dx_proxy.dll b/mp/src/dx9sdk/utilities/dx_proxy.dll index 26aac742..87ec719d 100644 Binary files a/mp/src/dx9sdk/utilities/dx_proxy.dll and b/mp/src/dx9sdk/utilities/dx_proxy.dll differ diff --git a/mp/src/game/client/c_baseanimating.cpp b/mp/src/game/client/c_baseanimating.cpp index c71d2682..c7cc08b4 100644 --- a/mp/src/game/client/c_baseanimating.cpp +++ b/mp/src/game/client/c_baseanimating.cpp @@ -1013,7 +1013,9 @@ CStudioHdr *C_BaseAnimating::OnNewModel() { // XXX what's authoritative? the model pointer or the model index? what a mess. nNewIndex = modelinfo->GetModelIndex( modelinfo->GetModelName( GetModel() ) ); - Assert( modelinfo->GetModel( nNewIndex ) == GetModel() ); + Assert( nNewIndex < 0 || modelinfo->GetModel( nNewIndex ) == GetModel() ); + if ( nNewIndex < 0 ) + nNewIndex = m_nModelIndex; } m_AutoRefModelIndex = nNewIndex; @@ -5099,7 +5101,7 @@ void C_BaseAnimating::StudioFrameAdvance() SetCycle( flNewCycle ); - m_flGroundSpeed = GetSequenceGroundSpeed( hdr, GetSequence() ); + m_flGroundSpeed = GetSequenceGroundSpeed( hdr, GetSequence() ) * GetModelScale(); #if 0 // I didn't have a test case for this, but it seems like the right thing to do. Check multi-player! @@ -5289,7 +5291,7 @@ void C_BaseAnimating::ResetSequenceInfo( void ) } CStudioHdr *pStudioHdr = GetModelPtr(); - m_flGroundSpeed = GetSequenceGroundSpeed( pStudioHdr, GetSequence() ); + m_flGroundSpeed = GetSequenceGroundSpeed( pStudioHdr, GetSequence() ) * GetModelScale(); m_bSequenceLoops = ((GetSequenceFlags( pStudioHdr, GetSequence() ) & STUDIO_LOOPING) != 0); // m_flAnimTime = gpGlobals->time; m_flPlaybackRate = 1.0; diff --git a/mp/src/game/client/c_baseentity.cpp b/mp/src/game/client/c_baseentity.cpp index 0b09309a..8f40d7ef 100644 --- a/mp/src/game/client/c_baseentity.cpp +++ b/mp/src/game/client/c_baseentity.cpp @@ -894,7 +894,12 @@ C_BaseEntity::C_BaseEntity() : { AddVar( &m_vecOrigin, &m_iv_vecOrigin, LATCH_SIMULATION_VAR ); AddVar( &m_angRotation, &m_iv_angRotation, LATCH_SIMULATION_VAR ); - AddVar( &m_vecVelocity, &m_iv_vecVelocity, LATCH_SIMULATION_VAR ); + // Removing this until we figure out why velocity introduces view hitching. + // One possible fix is removing the player->ResetLatched() call in CGameMovement::FinishDuck(), + // but that re-introduces a third-person hitching bug. One possible cause is the abrupt change + // in player size/position that occurs when ducking, and how prediction tries to work through that. + // + // AddVar( &m_vecVelocity, &m_iv_vecVelocity, LATCH_SIMULATION_VAR ); m_DataChangeEventRef = -1; m_EntClientFlags = 0; diff --git a/mp/src/game/client/c_baseflex.cpp b/mp/src/game/client/c_baseflex.cpp index 0a5db8e5..6146b2dd 100644 --- a/mp/src/game/client/c_baseflex.cpp +++ b/mp/src/game/client/c_baseflex.cpp @@ -1158,6 +1158,33 @@ void C_BaseFlex::SetupWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightC } +//----------------------------------------------------------------------------- +// Purpose: Use the local bone positions to set flex control weights +// via boneflexdrivers specified in the model +//----------------------------------------------------------------------------- +void C_BaseFlex::BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed ) +{ + const int nBoneFlexDriverCount = pStudioHdr->BoneFlexDriverCount(); + + for ( int i = 0; i < nBoneFlexDriverCount; ++i ) + { + const mstudioboneflexdriver_t *pBoneFlexDriver = pStudioHdr->BoneFlexDriver( i ); + const Vector &position = pos[ pBoneFlexDriver->m_nBoneIndex ]; + + const int nControllerCount = pBoneFlexDriver->m_nControlCount; + for ( int j = 0; j < nControllerCount; ++j ) + { + const mstudioboneflexdrivercontrol_t *pController = pBoneFlexDriver->pBoneFlexDriverControl( j ); + Assert( pController->m_nFlexControllerIndex >= 0 && pController->m_nFlexControllerIndex < pStudioHdr->numflexcontrollers() ); + Assert( pController->m_nBoneComponent >= 0 && pController->m_nBoneComponent <= 2 ); + SetFlexWeight( static_cast< LocalFlexController_t >( pController->m_nFlexControllerIndex ), RemapValClamped( position[pController->m_nBoneComponent], pController->m_flMin, pController->m_flMax, 0.0f, 1.0f ) ); + } + } + + BaseClass::BuildTransformations( pStudioHdr, pos, q, cameraTransform, boneMask, boneComputed ); +} + + //----------------------------------------------------------------------------- // Purpose: process the entities networked state, vcd playback, wav file visemes, and blinks into a global shared flex controller array //----------------------------------------------------------------------------- diff --git a/mp/src/game/client/c_baseflex.h b/mp/src/game/client/c_baseflex.h index f99061d1..71cee3d8 100644 --- a/mp/src/game/client/c_baseflex.h +++ b/mp/src/game/client/c_baseflex.h @@ -147,6 +147,7 @@ public: virtual void OnThreadedDrawSetup(); // model specific + virtual void BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed ); static void LinkToGlobalFlexControllers( CStudioHdr *hdr ); virtual void SetupWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightCount, float *pFlexWeights, float *pFlexDelayedWeights ); virtual bool SetupGlobalWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightCount, float *pFlexWeights, float *pFlexDelayedWeights ); diff --git a/mp/src/game/client/c_baseplayer.cpp b/mp/src/game/client/c_baseplayer.cpp index 3b1ac003..942f7a37 100644 --- a/mp/src/game/client/c_baseplayer.cpp +++ b/mp/src/game/client/c_baseplayer.cpp @@ -47,7 +47,7 @@ #include "replay/ienginereplay.h" #endif #include "steam/steam_api.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #include "client_virtualreality.h" #if defined USES_ECON_ITEMS @@ -115,6 +115,13 @@ static ConVar cl_first_person_uses_world_model ( "cl_first_person_uses_world_mod ConVar demo_fov_override( "demo_fov_override", "0", FCVAR_CLIENTDLL | FCVAR_DONTRECORD, "If nonzero, this value will be used to override FOV during demo playback." ); +// This only needs to be approximate - it just controls the distance to the pivot-point of the head ("the neck") of the in-game character, not the player's real-world neck length. +// Ideally we would find this vector by subtracting the neutral-pose difference between the head bone (the pivot point) and the "eyes" attachment point. +// However, some characters don't have this attachment point, and finding the neutral pose is a pain. +// This value is found by hand, and a good value depends more on the in-game models than on actual human shapes. +ConVar cl_meathook_neck_pivot_ingame_up( "cl_meathook_neck_pivot_ingame_up", "7.0" ); +ConVar cl_meathook_neck_pivot_ingame_fwd( "cl_meathook_neck_pivot_ingame_fwd", "3.0" ); + void RecvProxy_LocalVelocityX( const CRecvProxyData *pData, void *pStruct, void *pOut ); void RecvProxy_LocalVelocityY( const CRecvProxyData *pData, void *pStruct, void *pOut ); void RecvProxy_LocalVelocityZ( const CRecvProxyData *pData, void *pStruct, void *pOut ); @@ -429,6 +436,8 @@ C_BasePlayer::C_BasePlayer() : m_iv_vecViewOffset( "C_BasePlayer::m_iv_vecViewOf m_bFiredWeapon = false; m_nForceVisionFilterFlags = 0; + + ListenForGameEvent( "base_player_teleported" ); } //----------------------------------------------------------------------------- @@ -698,6 +707,20 @@ surfacedata_t* C_BasePlayer::GetGroundSurface() return physprops->GetSurfaceData( trace.surface.surfaceProps ); } +void C_BasePlayer::FireGameEvent( IGameEvent *event ) +{ + if ( FStrEq( event->GetName(), "base_player_teleported" ) ) + { + const int index = event->GetInt( "entindex" ); + if ( index == entindex() && IsLocalPlayer() ) + { + // In VR, we want to make sure our head and body + // are aligned after we teleport. + g_ClientVirtualReality.AlignTorsoAndViewToWeapon(); + } + } + +} //----------------------------------------------------------------------------- // returns the player name @@ -1851,11 +1874,9 @@ void C_BasePlayer::ThirdPersonSwitch( bool bThirdperson ) { return !input->CAM_IsThirdPerson() && ( !ToolsEnabled() || !ToolFramework_IsThirdPersonCamera() ); } - else - { - // Not looking at the local player, e.g. in a replay in third person mode or freelook. - return false; - } + + // Not looking at the local player, e.g. in a replay in third person mode or freelook. + return false; } //----------------------------------------------------------------------------- @@ -1867,11 +1888,9 @@ void C_BasePlayer::ThirdPersonSwitch( bool bThirdperson ) { return !LocalPlayerInFirstPersonView() || cl_first_person_uses_world_model.GetBool(); } - else - { - static ConVarRef vr_first_person_uses_world_model( "vr_first_person_uses_world_model" ); - return !LocalPlayerInFirstPersonView() || vr_first_person_uses_world_model.GetBool(); - } + + static ConVarRef vr_first_person_uses_world_model( "vr_first_person_uses_world_model" ); + return !LocalPlayerInFirstPersonView() || vr_first_person_uses_world_model.GetBool(); } @@ -1995,6 +2014,16 @@ void C_BasePlayer::PostThink( void ) if ( IsAlive()) { + // Need to do this on the client to avoid prediction errors + if ( GetFlags() & FL_DUCKING ) + { + SetCollisionBounds( VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX ); + } + else + { + SetCollisionBounds( VEC_HULL_MIN, VEC_HULL_MAX ); + } + if ( !CommentaryModeShouldSwallowInput( this ) ) { // do weapon stuff @@ -2850,7 +2879,13 @@ void C_BasePlayer::BuildFirstPersonMeathookTransformations( CStudioHdr *hdr, Vec m_BoneAccessor.SetWritableBones( BONE_USED_BY_ANYTHING ); - matrix3x4_t &mHeadTransform = GetBoneForWrite( LookupBone( pchHeadBoneName ) ); + int iHead = LookupBone( pchHeadBoneName ); + if ( iHead == -1 ) + { + return; + } + + matrix3x4_t &mHeadTransform = GetBoneForWrite( iHead ); // "up" on the head bone is along the negative Y axis - not sure why. //Vector vHeadTransformUp ( -mHeadTransform[0][1], -mHeadTransform[1][1], -mHeadTransform[2][1] ); @@ -2862,29 +2897,19 @@ void C_BasePlayer::BuildFirstPersonMeathookTransformations( CStudioHdr *hdr, Vec // We can't move this with animations or effects without causing nausea, so we need to move // the whole body so that the animated head is in the right place to match the player-controlled head. Vector vHeadUp; - bool bMeathookEnable = true; Vector vRealPivotPoint; - bool bEnableDecapitation = true; if( UseVR() ) { - static ConVarRef vr_neck_pivot_ingame_up( "vr_neck_pivot_ingame_up" ); - static ConVarRef vr_neck_pivot_ingame_fwd( "vr_neck_pivot_ingame_fwd" ); - static ConVarRef vr_meathook_enable ( "vr_meathook_enable" ); - static ConVarRef vr_decapitation_enable ( "vr_decapitation_enable" ); - VMatrix mWorldFromMideye = g_ClientVirtualReality.GetWorldFromMidEye(); - bMeathookEnable = vr_meathook_enable.GetBool(); - bEnableDecapitation = vr_decapitation_enable.GetBool(); - // What we do here is: // * Take the required eye pos+orn - the actual pose the player is controlling with the HMD. - // * Go downwards in that space by headtrack_neck_pivot_ingame_* - this is now the neck-pivot in the game world of where the player is actually looking. + // * Go downwards in that space by cl_meathook_neck_pivot_ingame_* - this is now the neck-pivot in the game world of where the player is actually looking. // * Now place the body of the animated character so that the head bone is at that position. // The head bone is the neck pivot point of the in-game character. Vector vRealMidEyePos = mWorldFromMideye.GetTranslation(); - vRealPivotPoint = vRealMidEyePos - ( mWorldFromMideye.GetUp() * vr_neck_pivot_ingame_up.GetFloat() ) - ( mWorldFromMideye.GetForward() * vr_neck_pivot_ingame_fwd.GetFloat() ); + vRealPivotPoint = vRealMidEyePos - ( mWorldFromMideye.GetUp() * cl_meathook_neck_pivot_ingame_up.GetFloat() ) - ( mWorldFromMideye.GetForward() * cl_meathook_neck_pivot_ingame_fwd.GetFloat() ); } else { @@ -2892,55 +2917,48 @@ void C_BasePlayer::BuildFirstPersonMeathookTransformations( CStudioHdr *hdr, Vec Vector vForward, vRight, vUp; AngleVectors( MainViewAngles(), &vForward, &vRight, &vUp ); - vRealPivotPoint = MainViewOrigin() - ( vUp * 7.3f ) - ( vForward * 3.f ); + vRealPivotPoint = MainViewOrigin() - ( vUp * cl_meathook_neck_pivot_ingame_up.GetFloat() ) - ( vForward * cl_meathook_neck_pivot_ingame_fwd.GetFloat() ); } Vector vDeltaToAdd = vRealPivotPoint - vHeadTransformTranslation; - if ( bMeathookEnable ) + // Now add this offset to the entire skeleton. + for (int i = 0; i < hdr->numbones(); i++) { - // Now add this offset to the entire skeleton. - for (int i = 0; i < hdr->numbones(); i++) + // Only update bones reference by the bone mask. + if ( !( hdr->boneFlags( i ) & boneMask ) ) { - // Only update bones reference by the bone mask. - if ( !( hdr->boneFlags( i ) & boneMask ) ) - { - continue; - } - matrix3x4_t& bone = GetBoneForWrite( i ); - Vector vBonePos; - MatrixGetTranslation ( bone, vBonePos ); - vBonePos += vDeltaToAdd; - MatrixSetTranslation ( vBonePos, bone ); + continue; } + matrix3x4_t& bone = GetBoneForWrite( i ); + Vector vBonePos; + MatrixGetTranslation ( bone, vBonePos ); + vBonePos += vDeltaToAdd; + MatrixSetTranslation ( vBonePos, bone ); } - if ( bEnableDecapitation ) + // Then scale the head to zero, but leave its position - forms a "neck stub". + // This prevents us rendering junk all over the screen, e.g. inside of mouth, etc. + MatrixScaleByZero( mHeadTransform ); + + // TODO: right now we nuke the hats by shrinking them to nothing, + // but it feels like we should do something more sensible. + // For example, for one sniper taunt he takes his hat off and waves it - would be nice to see it then. + int iHelm = LookupBone( "prp_helmet" ); + if ( iHelm != -1 ) { - // Then scale the head to zero, but leave its position - forms a "neck stub". - // This prevents us rendering junk all over the screen, e.g. inside of mouth, etc. - MatrixScaleByZero ( mHeadTransform ); - - // TODO: right now we nuke the hats by shrinking them to nothing, - // but it feels like we should do something more sensible. - // For example, for one sniper taunt he takes his hat off and waves it - would be nice to see it then. - int iHelm = LookupBone( "prp_helmet" ); - if ( iHelm != -1 ) - { - // Scale the helmet. - matrix3x4_t &transformhelmet = GetBoneForWrite( iHelm ); - MatrixScaleByZero ( transformhelmet ); - } - - iHelm = LookupBone( "prp_hat" ); - if ( iHelm != -1 ) - { - matrix3x4_t &transformhelmet = GetBoneForWrite( iHelm ); - MatrixScaleByZero ( transformhelmet ); - } + // Scale the helmet. + matrix3x4_t &transformhelmet = GetBoneForWrite( iHelm ); + MatrixScaleByZero( transformhelmet ); } + iHelm = LookupBone( "prp_hat" ); + if ( iHelm != -1 ) + { + matrix3x4_t &transformhelmet = GetBoneForWrite( iHelm ); + MatrixScaleByZero( transformhelmet ); + } } diff --git a/mp/src/game/client/c_baseplayer.h b/mp/src/game/client/c_baseplayer.h index 45c282bf..9d3657bf 100644 --- a/mp/src/game/client/c_baseplayer.h +++ b/mp/src/game/client/c_baseplayer.h @@ -23,6 +23,8 @@ #include "hintsystem.h" #include "SoundEmitterSystem/isoundemittersystembase.h" #include "c_env_fog_controller.h" +#include "igameevents.h" +#include "GameEventListener.h" #if defined USES_ECON_ITEMS #include "econ_item.h" @@ -66,7 +68,7 @@ bool IsInFreezeCam( void ); //----------------------------------------------------------------------------- // Purpose: Base Player class //----------------------------------------------------------------------------- -class C_BasePlayer : public C_BaseCombatCharacter +class C_BasePlayer : public C_BaseCombatCharacter, public CGameEventListener { public: DECLARE_CLASS( C_BasePlayer, C_BaseCombatCharacter ); @@ -467,6 +469,8 @@ protected: // used by client side player footsteps surfacedata_t* GetGroundSurface(); + virtual void FireGameEvent( IGameEvent *event ); + protected: // Did we just enter a vehicle this frame? bool JustEnteredVehicle(); diff --git a/mp/src/game/client/c_pixel_visibility.cpp b/mp/src/game/client/c_pixel_visibility.cpp index e379c856..8ff507b1 100644 --- a/mp/src/game/client/c_pixel_visibility.cpp +++ b/mp/src/game/client/c_pixel_visibility.cpp @@ -16,7 +16,7 @@ #include "utlmultilist.h" #include "vprof.h" #include "icommandline.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" static void PixelvisDrawChanged( IConVar *pPixelvisVar, const char *pOld, float flOldValue ); diff --git a/mp/src/game/client/c_prop_vehicle.cpp b/mp/src/game/client/c_prop_vehicle.cpp index 74dbf7f1..d093656f 100644 --- a/mp/src/game/client/c_prop_vehicle.cpp +++ b/mp/src/game/client/c_prop_vehicle.cpp @@ -18,7 +18,7 @@ #include "vgui/ISurface.h" #include "client_virtualreality.h" #include "../hud_crosshair.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" // NVNT haptic utils #include "haptics/haptic_utils.h" diff --git a/mp/src/game/client/cdll_client_int.cpp b/mp/src/game/client/cdll_client_int.cpp index 0f40f2d3..b5a53e72 100644 --- a/mp/src/game/client/cdll_client_int.cpp +++ b/mp/src/game/client/cdll_client_int.cpp @@ -121,7 +121,7 @@ #include "clientsteamcontext.h" #include "renamed_recvtable_compat.h" #include "mouthinfo.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #include "client_virtualreality.h" #include "mumble.h" @@ -148,7 +148,6 @@ #endif extern vgui::IInputInternal *g_InputInternal; -const char *COM_GetModDirectory(); // return the mod dir (rather than the complete -game param, which can be a path) //============================================================================= // HPE_BEGIN @@ -332,6 +331,11 @@ static ConVar s_CV_ShowParticleCounts("showparticlecounts", "0", 0, "Display num static ConVar s_cl_team("cl_team", "default", FCVAR_USERINFO|FCVAR_ARCHIVE, "Default team when joining a game"); static ConVar s_cl_class("cl_class", "default", FCVAR_USERINFO|FCVAR_ARCHIVE, "Default class when joining a game"); +#ifdef HL1MP_CLIENT_DLL +static ConVar s_cl_load_hl1_content("cl_load_hl1_content", "0", FCVAR_ARCHIVE, "Mount the content from Half-Life: Source if possible"); +#endif + + // Physics system bool g_bLevelInitialized; bool g_bTextMode = false; @@ -943,7 +947,7 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi InitFbx(); #endif - // it's ok if this is NULL. That just means the headtrack.dll wasn't found + // it's ok if this is NULL. That just means the sourcevr.dll wasn't found g_pSourceVR = (ISourceVirtualReality *)appSystemFactory(SOURCE_VIRTUAL_REALITY_INTERFACE_VERSION, NULL); factorylist_t factories; @@ -977,17 +981,6 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi g_pcv_ThreadMode = g_pCVar->FindVar( "host_thread_mode" ); - // If we are in VR mode do some initial setup work - if( UseVR() ) - { - int nViewportWidth, nViewportHeight; - - g_pSourceVR->GetViewportBounds( ISourceVirtualReality::VREye_Left, NULL, NULL, &nViewportWidth, &nViewportHeight ); - vgui::surface()->SetFullscreenViewport( 0, 0, nViewportWidth, nViewportHeight ); - - vgui::ivgui()->SetVRMode( true ); - } - if (!Initializer::InitializeAllObjects()) return false; @@ -1091,6 +1084,7 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi #ifndef _X360 HookHapticMessages(); // Always hook the messages #endif + return true; } @@ -1141,29 +1135,23 @@ void CHLClient::PostInit() g_pSixenseInput->PostInit(); #endif - // If we are in VR mode execute headtrack.cfg in PostInit so all the convars will - // already be set up - if( UseVR() ) + g_ClientVirtualReality.StartupComplete(); + +#ifdef HL1MP_CLIENT_DLL + if ( s_cl_load_hl1_content.GetBool() && steamapicontext && steamapicontext->SteamApps() ) { - // general all-game stuff - engine->ExecuteClientCmd( "exec headtrack\\headtrack.cfg" ); + char szPath[ MAX_PATH*2 ]; + int ccFolder= steamapicontext->SteamApps()->GetAppInstallDir( 280, szPath, sizeof(szPath) ); + if ( ccFolder > 0 ) + { + V_AppendSlash( szPath, sizeof(szPath) ); + V_strncat( szPath, "hl1", sizeof( szPath ) ); - // game specific VR config - CUtlString sCmd; - sCmd.Format( "exec headtrack_%s.cfg", COM_GetModDirectory() ); - engine->ExecuteClientCmd( sCmd.Get() ); - - engine->ExecuteClientCmd( "vr_start_tracking" ); - - vgui::surface()->SetSoftwareCursor( true ); -#if defined(POSIX) - ConVarRef m_rawinput( "m_rawinput" ); - m_rawinput.SetValue( 1 ); - - ConVarRef mat_vsync( "mat_vsync" ); - mat_vsync.SetValue( 0 ); -#endif + g_pFullFileSystem->AddSearchPath( szPath, "HL1" ); + g_pFullFileSystem->AddSearchPath( szPath, "GAME" ); + } } +#endif } //----------------------------------------------------------------------------- diff --git a/mp/src/game/client/client_base.vpc b/mp/src/game/client/client_base.vpc index 79a27d5d..52dceb7e 100644 --- a/mp/src/game/client/client_base.vpc +++ b/mp/src/game/client/client_base.vpc @@ -206,6 +206,8 @@ $Project $File "$SRCDIR\game\shared\basegrenade_shared.cpp" $File "$SRCDIR\game\shared\baseparticleentity.cpp" $File "$SRCDIR\game\shared\baseplayer_shared.cpp" + $File "$SRCDIR\game\shared\baseprojectile.cpp" + $File "$SRCDIR\game\shared\baseprojectile.h" $File "$SRCDIR\game\shared\baseviewmodel_shared.cpp" $File "beamdraw.cpp" $File "$SRCDIR\game\shared\beam_shared.cpp" diff --git a/mp/src/game/client/client_virtualreality.cpp b/mp/src/game/client/client_virtualreality.cpp index 1512d7bf..d729210e 100644 --- a/mp/src/game/client/client_virtualreality.cpp +++ b/mp/src/game/client/client_virtualreality.cpp @@ -9,15 +9,21 @@ #include "client_virtualreality.h" #include "materialsystem/itexture.h" +#include "materialsystem/materialsystem_config.h" #include "view_shared.h" +#include "view_scene.h" #include "VGuiMatSurface/IMatSystemSurface.h" #include "vgui_controls/Controls.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #include "ienginevgui.h" #include "cdll_client_int.h" +#include "vgui/IVGui.h" +#include "vgui_controls/Controls.h" #include "tier0/vprof_telemetry.h" #include +const char *COM_GetModDirectory(); // return the mod dir (rather than the complete -game param, which can be a path) + CClientVirtualReality g_ClientVirtualReality; EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CClientVirtualReality, IClientVirtualReality, CLIENTVIRTUALREALITY_INTERFACE_VERSION, g_ClientVirtualReality ); @@ -26,6 +32,9 @@ EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CClientVirtualReality, IClientVirtualReality, // -------------------------------------------------------------------- // A huge pile of VR convars // -------------------------------------------------------------------- +ConVar vr_activate_default( "vr_activate_default", "0", FCVAR_ARCHIVE, "If this is true the game will switch to VR mode once startup is complete." ); + + ConVar vr_moveaim_mode ( "vr_moveaim_mode", "3", FCVAR_ARCHIVE, "0=move+shoot from face. 1=move with torso. 2,3,4=shoot with face+mouse cursor. 5+ are probably not that useful." ); ConVar vr_moveaim_mode_zoom ( "vr_moveaim_mode_zoom", "3", FCVAR_ARCHIVE, "0=move+shoot from face. 1=move with torso. 2,3,4=shoot with face+mouse cursor. 5+ are probably not that useful." ); @@ -54,21 +63,18 @@ ConVar vr_debug_remote_cam_target_z( "vr_debug_remote_cam_target_z", "-50.0" ); ConVar vr_translation_limit( "vr_translation_limit", "10.0", 0, "How far the in-game head will translate before being clamped." ); -ConVar vr_dont_use_calibration_projection ( "vr_dont_use_calibration_projection", "0", 0, "1=use calibrated rotation, but not projection" ); - // HUD config values ConVar vr_render_hud_in_world( "vr_render_hud_in_world", "1" ); ConVar vr_hud_max_fov( "vr_hud_max_fov", "60", FCVAR_ARCHIVE, "Max FOV of the HUD" ); ConVar vr_hud_forward( "vr_hud_forward", "500", FCVAR_ARCHIVE, "Apparent distance of the HUD in inches" ); ConVar vr_hud_display_ratio( "vr_hud_display_ratio", "0.95", FCVAR_ARCHIVE ); +ConVar vr_hud_never_overlay( "vr_hud_never_overlay", "0" ); ConVar vr_hud_axis_lock_to_world( "vr_hud_axis_lock_to_world", "0", FCVAR_ARCHIVE, "Bitfield - locks HUD axes to the world - 0=pitch, 1=yaw, 2=roll" ); // Default distance clips through rocketlauncher, heavy's body, etc. ConVar vr_projection_znear_multiplier( "vr_projection_znear_multiplier", "0.3", 0, "Allows moving the ZNear plane to deal with body clipping" ); -ConVar vr_stat_sample_period ( "vr_stat_sample_period", "1", 0, "Frequency with which to sample motion stats" ); - // Should the viewmodel (weapon) translate with the HMD, or remain fixed to the in-world body (but still rotate with the head)? Purely a graphics effect - no effect on actual bullet aiming. // Has no effect in aim modes where aiming is not controlled by the head. ConVar vr_viewmodel_translate_with_head ( "vr_viewmodel_translate_with_head", "0", 0, "1=translate the viewmodel with the head motion." ); @@ -80,16 +86,9 @@ ConVar vr_zoom_scope_scale ( "vr_zoom_scope_scale", "6.0", 0, "Something to do w ConVar vr_viewmodel_offset_forward( "vr_viewmodel_offset_forward", "-8", 0 ); ConVar vr_viewmodel_offset_forward_large( "vr_viewmodel_offset_forward_large", "-15", 0 ); -ConVar vr_ipdtest_left_t ( "vr_ipdtest_left_t", "260", FCVAR_ARCHIVE ); -ConVar vr_ipdtest_left_b ( "vr_ipdtest_left_b", "530", FCVAR_ARCHIVE ); -ConVar vr_ipdtest_left_i ( "vr_ipdtest_left_i", "550", FCVAR_ARCHIVE ); -ConVar vr_ipdtest_left_o ( "vr_ipdtest_left_o", "200", FCVAR_ARCHIVE ); -ConVar vr_ipdtest_right_t ( "vr_ipdtest_right_t", "260", FCVAR_ARCHIVE ); -ConVar vr_ipdtest_right_b ( "vr_ipdtest_right_b", "530", FCVAR_ARCHIVE ); -ConVar vr_ipdtest_right_i ( "vr_ipdtest_right_i", "550", FCVAR_ARCHIVE ); -ConVar vr_ipdtest_right_o ( "vr_ipdtest_right_o", "200", FCVAR_ARCHIVE ); - +ConVar vr_force_windowed ( "vr_force_windowed", "0", FCVAR_ARCHIVE ); +ConVar vr_first_person_uses_world_model ( "vr_first_person_uses_world_model", "1", 0, "Causes the third person model to be drawn instead of the view model" ); // -------------------------------------------------------------------- // Purpose: Cycle through the aim & move modes. @@ -122,6 +121,32 @@ void CC_VR_Cycle_Aim_Move_Mode ( const CCommand& args ) static ConCommand vr_cycle_aim_move_mode("vr_cycle_aim_move_mode", CC_VR_Cycle_Aim_Move_Mode, "Cycle through the aim & move modes." ); +// -------------------------------------------------------------------- +// Purpose: Switch to/from VR mode. +// -------------------------------------------------------------------- +CON_COMMAND( vr_activate, "Switch to VR mode" ) +{ + g_ClientVirtualReality.Activate(); +} +CON_COMMAND( vr_deactivate, "Switch from VR mode to normal mode" ) +{ + g_ClientVirtualReality.Deactivate(); +} +CON_COMMAND( vr_toggle, "Toggles VR mode" ) +{ + if( g_pSourceVR ) + { + if( g_pSourceVR->ShouldRunInVR() ) + g_ClientVirtualReality.Deactivate(); + else + g_ClientVirtualReality.Activate(); + } + else + { + Msg( "VR Mode is not enabled.\n" ); + } +} + // -------------------------------------------------------------------- // Purpose: Returns true if the matrix is orthonormal @@ -235,11 +260,9 @@ CClientVirtualReality::CClientVirtualReality() m_rtLastMotionSample = 0; m_bMotionUpdated = false; - m_bIpdTestEnabled = false; - - // Needs to be after the tracker has initted. - m_bIpdTestEnabled = false; - m_IpdTestControl = 0; +#if defined( USE_SDL ) + m_nNonVRSDLDisplayIndex = 0; +#endif } CClientVirtualReality::~CClientVirtualReality() @@ -378,8 +401,8 @@ void CClientVirtualReality::DrawMainMenu() viewEye[STEREO_EYE_RIGHT].y = rightY; viewEye[STEREO_EYE_RIGHT].m_eStereoEye = STEREO_EYE_RIGHT; - // let headtrack.dll tell us where to put the cameras - ProcessCurrentTrackingState( 75.f ); + // let sourcevr.dll tell us where to put the cameras + ProcessCurrentTrackingState( 0 ); Vector vViewModelOrigin; QAngle qViewModelAngles; OverrideView( &viewEye[ STEREO_EYE_MONO ] , &vViewModelOrigin, &qViewModelAngles, HMM_NOOVERRIDE ); @@ -388,23 +411,22 @@ void CClientVirtualReality::DrawMainMenu() // render both eyes for( int nView = STEREO_EYE_LEFT; nView <= STEREO_EYE_RIGHT; nView++ ) { - // clear happens here probably - render->Push3DView( viewEye[nView], VIEW_CLEAR_DEPTH|VIEW_CLEAR_COLOR, NULL, NULL ); - - RenderHUDQuad( true, false ); + CMatRenderContextPtr pRenderContext( materials ); + PIXEvent pixEvent( pRenderContext, nView == STEREO_EYE_LEFT ? "left eye" : "right eye" ); + ITexture *pColor = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(nView-1), ISourceVirtualReality::RT_Color ); + ITexture *pDepth = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(nView-1), ISourceVirtualReality::RT_Depth ); + render->Push3DView( viewEye[nView], VIEW_CLEAR_DEPTH|VIEW_CLEAR_COLOR, pColor, NULL, pDepth ); + RenderHUDQuad( false, false ); render->PopView( NULL ); + + PostProcessFrame( (StereoEye_t)nView ); + + OverlayHUDQuadWithUndistort( viewEye[nView], true, true, false ); } - - vrect_t rect; - rect.x = rect.y = 0; - rect.width = leftW*2; - rect.height = leftH; - PostProcessFrame( &rect ); } - // -------------------------------------------------------------------- // Purpose: // Offset the incoming view appropriately. @@ -449,8 +471,7 @@ bool CClientVirtualReality::OverrideView ( CViewSetup *pViewMiddle, Vector *pVie QAngle torsoAngles = m_PlayerTorsoAngle; VMatrix worldFromTorso; - AngleMatrix ( torsoAngles, worldFromTorso.As3x4() ); - worldFromTorso.SetTranslation ( m_PlayerTorsoOrigin ); + worldFromTorso.SetupMatrixOrgAngles( m_PlayerTorsoOrigin, torsoAngles ); //// Scale translation e.g. to allow big in-game leans with only a small head movement. //// Clamp HMD movement to a reasonable amount to avoid wallhacks, vis problems, etc. @@ -484,16 +505,14 @@ bool CClientVirtualReality::OverrideView ( CViewSetup *pViewMiddle, Vector *pVie // Aim point is independent of view - leave it as it was, just copy it into m_WorldFromWeapon for our use. m_TorsoFromMideye = matMideyeZeroFromMideyeCurrent; m_WorldFromMidEye = worldFromTorso * matMideyeZeroFromMideyeCurrent; - AngleMatrix ( originalMiddleAngles, m_WorldFromWeapon.As3x4() ); - m_WorldFromWeapon.SetTranslation ( originalMiddleOrigin ); + m_WorldFromWeapon.SetupMatrixOrgAngles( originalMiddleOrigin, originalMiddleAngles ); break; case HMM_SHOOTMOVELOOKMOUSE: // HMD is ignored completely, mouse does everything. m_PlayerTorsoAngle = originalMiddleAngles; - AngleMatrix ( originalMiddleAngles, worldFromTorso.As3x4() ); - worldFromTorso.SetTranslation ( m_PlayerTorsoOrigin ); + worldFromTorso.SetupMatrixOrgAngles( m_PlayerTorsoOrigin, originalMiddleAngles ); m_TorsoFromMideye.Identity(); m_WorldFromMidEye = worldFromTorso; @@ -535,9 +554,8 @@ bool CClientVirtualReality::OverrideView ( CViewSetup *pViewMiddle, Vector *pVie Vector vView = vLookat - vOffset; VectorAngles ( vView, m_WorldFromMidEye.GetUp(), pViewMiddle->angles ); - AngleMatrix ( pViewMiddle->angles, m_WorldFromMidEye.As3x4() ); + m_WorldFromMidEye.SetupMatrixOrgAngles( pViewMiddle->origin, pViewMiddle->angles ); - m_WorldFromMidEye.SetTranslation ( pViewMiddle->origin ); m_TorsoFromMideye.Identity(); } @@ -584,47 +602,19 @@ bool CClientVirtualReality::OverrideStereoView( CViewSetup *pViewMiddle, CViewSe return false; } - if ( vr_stereo_swap_eyes.GetBool() ) - { - // Windows likes to randomly rename display numbers which causes eye-swaps, so this tries to cope with that. - CViewSetup *pViewTemp = pViewLeft; - pViewLeft = pViewRight; - pViewRight = pViewTemp; - } + VMatrix matOffsetLeft = g_pSourceVR->GetMidEyeFromEye( ISourceVirtualReality::VREye_Left ); + VMatrix matOffsetRight = g_pSourceVR->GetMidEyeFromEye( ISourceVirtualReality::VREye_Right ); - // Move eyes to calibrated positions. - VMatrix worldFromLeftEye = m_WorldFromMidEye * g_pSourceVR->GetMidEyeFromLeft(); - VMatrix worldFromRightEye = m_WorldFromMidEye * g_pSourceVR->GetMidEyeFromRight(); - - Assert ( IsOrthonormal ( worldFromLeftEye, 0.001f ) ); - Assert ( IsOrthonormal ( worldFromRightEye, 0.001f ) ); - - Vector rightFromLeft = worldFromRightEye.GetTranslation() - worldFromLeftEye.GetTranslation(); - //float calibratedIPD = rightFromLeft.Length(); // THIS IS NOT CORRECT. The positions of the virtual cameras do have any real physical "meaning" with the way we currently calibrate. - float calibratedIPD = g_pSourceVR->GetDisplaySeparationMM() / 25.4f; - - // Scale the eyes closer/further to fit the desired IPD. - // (the calibrated distance is the IPD of whoever calibrated it!) - float desiredIPD = g_pSourceVR->GetUserIPDMM() / 25.4f; - if ( calibratedIPD < 0.000001f ) - { - // No HMD, or a monocular HMD. - } - else - { - float scale = 0.5f * ( desiredIPD - calibratedIPD ) / calibratedIPD; - worldFromLeftEye.SetTranslation ( worldFromLeftEye.GetTranslation() - ( scale * rightFromLeft ) ); - worldFromRightEye.SetTranslation ( worldFromRightEye.GetTranslation() + ( scale * rightFromLeft ) ); - } + // Move eyes to IPD positions. + VMatrix worldFromLeftEye = m_WorldFromMidEye * matOffsetLeft; + VMatrix worldFromRightEye = m_WorldFromMidEye * matOffsetRight; Assert ( IsOrthonormal ( worldFromLeftEye, 0.001f ) ); Assert ( IsOrthonormal ( worldFromRightEye, 0.001f ) ); // Finally convert back to origin+angles. - pViewLeft->origin = worldFromLeftEye.GetTranslation(); - VectorAngles ( worldFromLeftEye.GetForward(), worldFromLeftEye.GetUp(), pViewLeft->angles ); - pViewRight->origin = worldFromRightEye.GetTranslation(); - VectorAngles ( worldFromRightEye.GetForward(), worldFromRightEye.GetUp(), pViewRight->angles ); + MatrixAngles( worldFromLeftEye.As3x4(), pViewLeft->angles, pViewLeft->origin ); + MatrixAngles( worldFromRightEye.As3x4(), pViewRight->angles, pViewRight->origin ); // Find the projection matrices. @@ -645,13 +635,6 @@ bool CClientVirtualReality::OverrideStereoView( CViewSetup *pViewMiddle, CViewSe } } - if ( vr_dont_use_calibration_projection.GetBool() ) - { - pViewLeft ->m_bViewToProjectionOverride = false; - pViewRight ->m_bViewToProjectionOverride = false; - pViewMiddle->m_bViewToProjectionOverride = false; - } - switch ( vr_stereo_mono_set_eye.GetInt() ) { case 0: @@ -683,6 +666,17 @@ bool CClientVirtualReality::OverrideStereoView( CViewSetup *pViewMiddle, CViewSe CalcFovFromProjection ( &(pViewRight ->fov), pViewRight ->m_ViewToProjection ); CalcFovFromProjection ( &(pViewMiddle->fov), pViewMiddle->m_ViewToProjection ); + // if we don't know the HUD FOV, figure that out now + if( m_fHudHorizontalFov == 0.f ) + { + // Figure out the current HUD FOV. + m_fHudHorizontalFov = pViewLeft->fov * vr_hud_display_ratio.GetFloat(); + if( m_fHudHorizontalFov > vr_hud_max_fov.GetFloat() ) + { + m_fHudHorizontalFov = vr_hud_max_fov.GetFloat(); + } + } + // remember the view angles so we can limit the weapon to something near those m_PlayerViewAngle = pViewMiddle->angles; m_PlayerViewOrigin = pViewMiddle->origin; @@ -701,7 +695,6 @@ bool CClientVirtualReality::OverrideStereoView( CViewSetup *pViewMiddle, CViewSe m_fHudHalfHeight = tan( DEG2RAD( fVFOV * 0.5f ) ) * fHudForward * m_WorldZoomScale; QAngle HudAngles; - VMatrix HudUpCorrection; switch ( m_hmmMovementActual ) { case HMM_SHOOTFACE_MOVETORSO: @@ -709,7 +702,6 @@ bool CClientVirtualReality::OverrideStereoView( CViewSetup *pViewMiddle, CViewSe // This helps keep you oriented about where "forwards" is, which is otherwise surprisingly tricky! // TODO: try preserving roll and/or pitch from the view? HudAngles = m_PlayerTorsoAngle; - HudUpCorrection.Identity(); break; case HMM_SHOOTFACE_MOVEFACE: case HMM_SHOOTMOUSE_MOVEFACE: @@ -720,7 +712,6 @@ bool CClientVirtualReality::OverrideStereoView( CViewSetup *pViewMiddle, CViewSe case HMM_SHOOTBOUNDEDMOUSE_LOOKFACE_MOVEMOUSE: // Put the HUD in front of wherever the player is looking. HudAngles = m_PlayerViewAngle; - HudUpCorrection = g_pSourceVR->GetHudUpCorrection(); break; default: Assert ( false ); break; } @@ -742,9 +733,7 @@ bool CClientVirtualReality::OverrideStereoView( CViewSetup *pViewMiddle, CViewSe MatrixAngles( m_WorldFromWeapon.As3x4(), aimAngles ); HudAngles[YAW] = aimAngles[YAW]; } - AngleMatrix ( HudAngles, m_WorldFromHud.As3x4() ); - m_WorldFromHud.SetTranslation ( m_PlayerViewOrigin ); - m_WorldFromHud = m_WorldFromHud * HudUpCorrection; + m_WorldFromHud.SetupMatrixOrgAngles( m_PlayerViewOrigin, HudAngles ); // Remember in source X forwards, Y left, Z up. // We need to transform to a more conventional X right, Y up, Z backwards before doing the projection. @@ -806,8 +795,8 @@ bool CClientVirtualReality::OverridePlayerMotion( float flInputSampleFrametime, { // Figure out what changes were made to the WEAPON by mouse/joystick/etc VMatrix worldFromOldWeapon, worldFromCurWeapon; - AngleMatrix ( oldAngles, worldFromOldWeapon.As3x4() ); - AngleMatrix ( curAngles, worldFromCurWeapon.As3x4() ); + worldFromOldWeapon.SetupMatrixAngles( oldAngles ); + worldFromCurWeapon.SetupMatrixAngles( curAngles ); // We ignore mouse pitch, the mouse can't do rolls, so it's just yaw changes. if( !m_bOverrideTorsoAngle ) @@ -817,7 +806,7 @@ bool CClientVirtualReality::OverridePlayerMotion( float flInputSampleFrametime, m_PlayerTorsoAngle[PITCH] = 0.0f; } - AngleMatrix ( m_PlayerTorsoAngle, worldFromTorso.As3x4() ); + worldFromTorso.SetupMatrixAngles( m_PlayerTorsoAngle ); // Weapon view = mideye view, so apply that to the torso to find the world view direction. m_WorldFromWeapon = worldFromTorso * m_TorsoFromMideye; @@ -846,10 +835,8 @@ bool CClientVirtualReality::OverridePlayerMotion( float flInputSampleFrametime, } // Let every other system know. - AngleMatrix( *pNewAngles, m_WorldFromWeapon.As3x4() ); - AngleMatrix( m_PlayerTorsoAngle, worldFromTorso.As3x4() ); - // Restore the translation. - m_WorldFromWeapon.SetTranslation ( vWeaponOrigin ); + m_WorldFromWeapon.SetupMatrixOrgAngles( vWeaponOrigin, *pNewAngles ); + worldFromTorso.SetupMatrixAngles( m_PlayerTorsoAngle ); } break; case HMM_SHOOTBOUNDEDMOUSE_LOOKFACE_MOVEFACE: @@ -913,10 +900,8 @@ bool CClientVirtualReality::OverridePlayerMotion( float flInputSampleFrametime, } // Let every other system know. - AngleMatrix( *pNewAngles, m_WorldFromWeapon.As3x4() ); - AngleMatrix( m_PlayerTorsoAngle, worldFromTorso.As3x4() ); - // Restore the translation. - m_WorldFromWeapon.SetTranslation ( vWeaponOrigin ); + m_WorldFromWeapon.SetupMatrixOrgAngles( vWeaponOrigin, *pNewAngles ); + worldFromTorso.SetupMatrixAngles( m_PlayerTorsoAngle ); } break; case HMM_SHOOTMOUSE_MOVEFACE: @@ -942,10 +927,8 @@ bool CClientVirtualReality::OverridePlayerMotion( float flInputSampleFrametime, m_PlayerTorsoAngle[ YAW ] += AngleDiff( curAngles[YAW], oldAngles[YAW] ) /2.f; } - AngleMatrix( *pNewAngles, m_WorldFromWeapon.As3x4() ); - AngleMatrix( m_PlayerTorsoAngle, worldFromTorso.As3x4() ); - // Restore the translation. - m_WorldFromWeapon.SetTranslation ( vWeaponOrigin ); + m_WorldFromWeapon.SetupMatrixOrgAngles( vWeaponOrigin, *pNewAngles ); + worldFromTorso.SetupMatrixAngles( m_PlayerTorsoAngle ); } break; default: Assert ( false ); break; @@ -1007,101 +990,6 @@ bool CClientVirtualReality::OverridePlayerMotion( float flInputSampleFrametime, return true; } - -// -------------------------------------------------------------------- -// Purpose: Collects convar and HMD state once a session -// -------------------------------------------------------------------- -bool CClientVirtualReality::CollectSessionStartStats( KeyValues *pkvStats ) -{ - pkvStats->SetName( "TF2VRSessionDetails" ); - - CUtlString sSerialNumber = g_pSourceVR->GetDisplaySerialNumber(); - if( sSerialNumber.IsValid() && !sSerialNumber.IsEmpty() ) - { - pkvStats->SetString( "SerialNumber", sSerialNumber.Get() ); - } - CUtlString sModelNumber = g_pSourceVR->GetDisplayModelNumber(); - if( sModelNumber.IsValid() && !sModelNumber.IsEmpty() ) - { - pkvStats->SetString( "ModelNumberID", sModelNumber.Get() ); - } - - pkvStats->SetFloat( "vr_separation_user_inches", g_pSourceVR->GetUserIPDMM() / 25.4f ); - //pkvStats->SetFloat( "vr_separation_toein_pixels", vr_separation_toein_pixels.GetFloat() ); - //pkvStats->SetInt( "vr_moveaim_mode", vr_moveaim_mode.GetInt() ); - //pkvStats->SetFloat( "vr_moveaim_reticle_yaw_limit", vr_moveaim_reticle_yaw_limit.GetFloat() ); - //pkvStats->SetFloat( "vr_moveaim_reticle_pitch_limit", vr_moveaim_reticle_pitch_limit.GetFloat() ); - //pkvStats->SetInt( "vr_moveaim_mode_zoom", vr_moveaim_mode_zoom.GetInt() ); - //pkvStats->SetFloat( "vr_moveaim_reticle_yaw_limit_zoom", vr_moveaim_reticle_yaw_limit_zoom.GetFloat() ); - //pkvStats->SetFloat( "vr_moveaim_reticle_pitch_limit_zoom", vr_moveaim_reticle_pitch_limit_zoom.GetFloat() ); - //pkvStats->SetFloat( "vr_hud_max_fov", vr_hud_max_fov.GetFloat() ); - //pkvStats->SetFloat( "vr_hud_forward", vr_hud_forward.GetFloat() ); - //pkvStats->SetFloat( "vr_neckmodel_up", vr_neckmodel_up.GetFloat() ); - //pkvStats->SetFloat( "vr_neckmodel_forwards", vr_neckmodel_forwards.GetFloat() ); - //pkvStats->SetInt( "vr_hud_axis_lock_to_world", vr_hud_axis_lock_to_world.GetInt() ); - - //pkvStats->SetInt( "vr_ipdtest_left_t", vr_ipdtest_left_t.GetInt() ); - //pkvStats->SetInt( "vr_ipdtest_left_b", vr_ipdtest_left_b.GetInt() ); - //pkvStats->SetInt( "vr_ipdtest_left_i", vr_ipdtest_left_i.GetInt() ); - //pkvStats->SetInt( "vr_ipdtest_left_o", vr_ipdtest_left_o.GetInt() ); - //pkvStats->SetInt( "vr_ipdtest_right_t", vr_ipdtest_right_t.GetInt() ); - //pkvStats->SetInt( "vr_ipdtest_right_b", vr_ipdtest_right_b.GetInt() ); - //pkvStats->SetInt( "vr_ipdtest_right_i", vr_ipdtest_right_i.GetInt() ); - //pkvStats->SetInt( "vr_ipdtest_right_o", vr_ipdtest_right_o.GetInt() ); - - return true; -} - - -// -------------------------------------------------------------------- -// Purpose: Collects view stats every so often -// -------------------------------------------------------------------- -bool CClientVirtualReality::CollectPeriodicStats( KeyValues *pkvStats ) -{ - // maybe we haven't even been called to get tracking data - if( !m_bMotionUpdated ) - return false; - m_bMotionUpdated = false; - - uint32 unPeriod = (uint32) vr_stat_sample_period.GetInt(); - if( unPeriod == 0 ) - return false; // periodic stats are turned off - - RTime32 rtCurrent = time(NULL); - if( rtCurrent == m_rtLastMotionSample && ( rtCurrent - m_rtLastMotionSample ) < unPeriod ) - return false; // it isn't time to report yet - - pkvStats->SetName( "TF2VRMotionSample" ); - - pkvStats->SetInt( "SampleTime", rtCurrent ); - - Vector vPos; - QAngle viewAngles; - MatrixAngles( m_WorldFromMidEye.As3x4(), viewAngles, vPos ); - - pkvStats->SetFloat( "LookYaw", viewAngles[YAW] ); - pkvStats->SetFloat( "LookPitch", viewAngles[PITCH] ); - pkvStats->SetFloat( "LookRoll", viewAngles[ROLL] ); - pkvStats->SetFloat( "PositionX", vPos.x ); - pkvStats->SetFloat( "PositionY", vPos.y ); - pkvStats->SetFloat( "PositionZ", vPos.z ); - - pkvStats->SetFloat( "VelocityX", m_PlayerLastMovement.x ); - pkvStats->SetFloat( "VelocityY", m_PlayerLastMovement.y ); - pkvStats->SetFloat( "VelocityZ", m_PlayerLastMovement.z ); - - QAngle aimAngles; - MatrixAngles( m_WorldFromWeapon.As3x4(), aimAngles ); - - pkvStats->SetFloat( "AimYaw", aimAngles[YAW] ); - pkvStats->SetFloat( "AimPitch", aimAngles[PITCH] ); - - m_rtLastMotionSample = rtCurrent; - - return true; -} - - // -------------------------------------------------------------------- // Purpose: Returns true if the world is zoomed // -------------------------------------------------------------------- @@ -1154,6 +1042,19 @@ void CClientVirtualReality::CancelTorsoTransformOverride() } +bool CClientVirtualReality::CanOverlayHudQuad() +{ + bool bCanOverlay = true; + + bCanOverlay = bCanOverlay && vr_render_hud_in_world.GetBool(); + bCanOverlay = bCanOverlay && ( ! vr_hud_never_overlay.GetBool() ); + bCanOverlay = bCanOverlay && ( vr_hud_axis_lock_to_world.GetInt() == 0 ); + bCanOverlay = bCanOverlay && ( m_hmmMovementActual != HMM_SHOOTFACE_MOVETORSO ); + + return bCanOverlay; +} + + // -------------------------------------------------------------------- // Purpose: Returns the bounds in world space where the game should // position the HUD. @@ -1177,6 +1078,10 @@ void CClientVirtualReality::GetHUDBounds( Vector *pViewer, Vector *pUL, Vector * // -------------------------------------------------------------------- void CClientVirtualReality::RenderHUDQuad( bool bBlackout, bool bTranslucent ) { + // If we can overlay the HUD directly onto the target later, we'll do that instead (higher image quality). + if ( CanOverlayHudQuad() ) + return; + Vector vHead, vUL, vUR, vLL, vLR; GetHUDBounds ( &vHead, &vUL, &vUR, &vLL, &vLR ); @@ -1304,14 +1209,6 @@ float CClientVirtualReality::GetZoomedModeMagnification() // -------------------------------------------------------------------- bool CClientVirtualReality::ProcessCurrentTrackingState( float fGameFOV ) { - // Figure out the current HUD FOV. - m_fHudHorizontalFov = g_pSourceVR->GetHorizontalFOVDegrees() * vr_hud_display_ratio.GetFloat(); - if( m_fHudHorizontalFov > vr_hud_max_fov.GetFloat() ) - { - m_fHudHorizontalFov = vr_hud_max_fov.GetFloat(); - } - - m_WorldZoomScale = 1.0f; if ( fGameFOV != 0.0f ) { @@ -1397,8 +1294,7 @@ void CClientVirtualReality::AlignTorsoAndViewToWeapon() if( !UseVR() ) return; - VRTrackerState_t state = g_pSourceVR->GetTrackerState(); - if( state.bWillDriftInYaw ) + if( g_pSourceVR->WillDriftInYaw() ) { m_iAlignTorsoAndViewToWeaponCountdown = 2; } @@ -1408,291 +1304,202 @@ void CClientVirtualReality::AlignTorsoAndViewToWeapon() // -------------------------------------------------------------------- // Purpose: Lets VR do stuff at the very end of the rendering process // -------------------------------------------------------------------- -void CClientVirtualReality::PostProcessFrame( const vrect_t *SrcRect ) +void CClientVirtualReality::PostProcessFrame( StereoEye_t eEye ) { if( !UseVR() ) return; - g_pSourceVR->DoDistortionProcessing( SrcRect ); + g_pSourceVR->DoDistortionProcessing( eEye == STEREO_EYE_LEFT ? ISourceVirtualReality::VREye_Left : ISourceVirtualReality::VREye_Right ); +} - if ( m_bIpdTestEnabled ) + +// -------------------------------------------------------------------- +// Pastes the HUD directly onto the backbuffer / render target. +// (higher quality than the RenderHUDQuad() path but can't always be used) +// -------------------------------------------------------------------- +void CClientVirtualReality::OverlayHUDQuadWithUndistort( const CViewSetup &eyeView, bool bDoUndistort, bool bBlackout, bool bTranslucent ) +{ + if ( ! UseVR() ) + return; + + // If we can't overlay the HUD, it will be handled on another path (rendered into the scene with RenderHUDQuad()). + if ( ! CanOverlayHudQuad() ) + return; + + // Get the position of the HUD quad in world space as used by RenderHUDQuad(). Then convert to a rectangle in normalized + // device coordinates. + + Vector vHead, vUL, vUR, vLL, vLR; + GetHUDBounds ( &vHead, &vUL, &vUR, &vLL, &vLR ); + + VMatrix worldToView, viewToProjection, worldToProjection, worldToPixels; + render->GetMatricesForView( eyeView, &worldToView, &viewToProjection, &worldToProjection, &worldToPixels ); + + Vector pUL, pUR, pLL, pLR; + + worldToProjection.V3Mul( vUL, pUL ); + worldToProjection.V3Mul( vUR, pUR ); + worldToProjection.V3Mul( vLL, pLL ); + worldToProjection.V3Mul( vLR, pLR ); + + float ndcHudBounds[4]; + ndcHudBounds[0] = Min ( Min( pUL.x, pUR.x ), Min( pLL.x, pLR.x ) ); + ndcHudBounds[1] = Min ( Min( pUL.y, pUR.y ), Min( pLL.y, pLR.y ) ); + ndcHudBounds[2] = Max ( Max( pUL.x, pUR.x ), Max( pLL.x, pLR.x ) ); + ndcHudBounds[3] = Max ( Max( pUL.y, pUR.y ), Max( pLL.y, pLR.y ) ); + + ISourceVirtualReality::VREye sourceVrEye = ( eyeView.m_eStereoEye == STEREO_EYE_LEFT ) ? ISourceVirtualReality::VREye_Left : ISourceVirtualReality::VREye_Right; + + g_pSourceVR->CompositeHud ( sourceVrEye, ndcHudBounds, bDoUndistort, bBlackout, bTranslucent ); +} + + +// -------------------------------------------------------------------- +// Purpose: Switches to VR mode +// -------------------------------------------------------------------- +void CClientVirtualReality::Activate() +{ + // we can only do this if a headtrack DLL is loaded + if( !g_pSourceVR ) + return; + + // see if VR mode is even enabled + if( materials->GetCurrentConfigForVideoCard().m_nVRModeAdapter == -1 ) { - DrawIpdCalibration ( SrcRect ); + Warning( "Enable VR mode in the video options before trying to use it.\n" ); + return; } -} - -//----------------------------------------------------------------------------- -// Calibration UI -//----------------------------------------------------------------------------- - - -// These control the conversion of IPD from pixels to inches. -ConVar vr_ipdtest_interp_ipd_start_pixels ( "vr_ipdtest_interp_ipd_start_pixels", "491.0", 0 ); -ConVar vr_ipdtest_interp_ipd_start_inches ( "vr_ipdtest_interp_ipd_start_inches", "2.717", 0 ); // 69mm -ConVar vr_ipdtest_interp_ipd_end_pixels ( "vr_ipdtest_interp_ipd_end_pixels", "602.0", 0 ); -ConVar vr_ipdtest_interp_ipd_end_inches ( "vr_ipdtest_interp_ipd_end_inches", "2.205", 0 ); // 56mm - -// These numbers need to be filled in from physical tests. Right now they are placeholder. -ConVar vr_ipdtest_interp_relief_start_pixels ( "vr_ipdtest_interp_relief_start_pixels", "400.0", 0 ); -ConVar vr_ipdtest_interp_relief_start_inches ( "vr_ipdtest_interp_relief_start_inches", "0.0", 0 ); -ConVar vr_ipdtest_interp_relief_end_pixels ( "vr_ipdtest_interp_relief_end_pixels", "600.0", 0 ); -ConVar vr_ipdtest_interp_relief_end_inches ( "vr_ipdtest_interp_relief_end_inches", "1.0", 0 ); - - - - -float Interpolate ( float fIn, float fInStart, float fInEnd, float fOutStart, float fOutEnd ) -{ - float fLamdba = ( fIn - fInStart ) / ( fInEnd - fInStart ); - float fOut = fOutStart + fLamdba * ( fOutEnd - fOutStart ); - return fOut; -} - -void CClientVirtualReality::RecalcEyeCalibration ( TEyeCalibration *p ) -{ - int iDisplayWidth, iDisplayHeight; - bool bSuccess = g_pSourceVR->GetWindowSize ( &iDisplayWidth, &iDisplayHeight ); - Assert ( bSuccess ); - if ( bSuccess ) + // See if we have an actual adapter + int32 nVRModeAdapter = g_pSourceVR->GetVRModeAdapter(); + if( nVRModeAdapter == -1 ) { - // Eye relief. - // Many ways to take the average eye size. But since the top edge is hard to find (strains the eyes, and there's problems with glasses), let's just use the difference between left and right. - p->Left.fSizePixels = (float)( p->Left.iIn - p->Left.iOut ); - p->Right.fSizePixels = (float)( p->Right.iIn - p->Right.iOut ); - // ...not that we have any data yet, nor do we know what to do with it if we had it. - float fLeftInches = Interpolate ( p->Left.fSizePixels, - vr_ipdtest_interp_relief_start_pixels.GetFloat(), - vr_ipdtest_interp_relief_end_pixels.GetFloat(), - vr_ipdtest_interp_relief_start_inches.GetFloat(), - vr_ipdtest_interp_relief_end_inches.GetFloat() ); - p->Left.fReliefInches = fLeftInches; - float fRightInches = Interpolate ( p->Right.fSizePixels, - vr_ipdtest_interp_relief_start_pixels.GetFloat(), - vr_ipdtest_interp_relief_end_pixels.GetFloat(), - vr_ipdtest_interp_relief_start_inches.GetFloat(), - vr_ipdtest_interp_relief_end_inches.GetFloat() ); - p->Right.fReliefInches = fRightInches; - - // Calculate IPD - // In and Out are both measured from the nearest edge of the display, i.e. the left ones from the left edge, the right ones from the right edge. - float fLeftMid = (float)( p->Left.iIn + p->Left.iOut ) * 0.5f; - float fRightMid = (float)( p->Right.iIn + p->Right.iOut ) * 0.5f; - // An outside value of 0 is the first actual pixel on the outer edge of the display. - // So if both values are 0, the two lines are (iDisplayWidth-1) apart. - float fSeparationInPixels = (float)( iDisplayWidth - 1 ) - fLeftMid - fRightMid; - float fIpdInches = Interpolate ( fSeparationInPixels, - vr_ipdtest_interp_ipd_start_pixels.GetFloat(), - vr_ipdtest_interp_ipd_end_pixels.GetFloat(), - vr_ipdtest_interp_ipd_start_inches.GetFloat(), - vr_ipdtest_interp_ipd_end_inches.GetFloat() ); - p->fIpdInches = fIpdInches; - p->fIpdPixels = fSeparationInPixels; + Warning( "Unable to get VRMode adapter from OpenVR. VR mode cannot be enabled. Try restarting and then enabling VR again.\n" ); + return; + } + + // we can only activate if we've got a VR device + if( materials->GetCurrentConfigForVideoCard().m_nVRModeAdapter != nVRModeAdapter ) + { + Warning( "VR Mode expects adapter %d which is different from %d which we are currently using. Try restarting and enabling VR mode again.\n", + nVRModeAdapter, materials->GetCurrentConfigForVideoCard().m_nVRModeAdapter ); + engine->ExecuteClientCmd( "mat_enable_vrmode 0\n" ); + return; } -} -void CClientVirtualReality::GetCurrentEyeCalibration ( TEyeCalibration *p ) -{ - p->Left.iTop = vr_ipdtest_left_t.GetInt(); - p->Left.iBot = vr_ipdtest_left_b.GetInt(); - p->Left.iIn = vr_ipdtest_left_i.GetInt(); - p->Left.iOut = vr_ipdtest_left_o.GetInt(); - p->Right.iTop = vr_ipdtest_right_t.GetInt(); - p->Right.iBot = vr_ipdtest_right_b.GetInt(); - p->Right.iIn = vr_ipdtest_right_i.GetInt(); - p->Right.iOut = vr_ipdtest_right_o.GetInt(); - RecalcEyeCalibration ( p ); - m_IpdTestCurrent = *p; -} + // can't activate twice + if( UseVR() ) + return; -void CClientVirtualReality::SetCurrentEyeCalibration ( TEyeCalibration const &p ) -{ - m_IpdTestCurrent = p; - RecalcEyeCalibration ( &m_IpdTestCurrent ); - g_pSourceVR->SetUserIPDMM( m_IpdTestCurrent.fIpdInches * 25.4f ); - vr_ipdtest_left_t.SetValue ( m_IpdTestCurrent.Left.iTop ); - vr_ipdtest_left_b.SetValue ( m_IpdTestCurrent.Left.iBot ); - vr_ipdtest_left_i.SetValue ( m_IpdTestCurrent.Left.iIn ); - vr_ipdtest_left_o.SetValue ( m_IpdTestCurrent.Left.iOut ); - vr_ipdtest_right_t.SetValue ( m_IpdTestCurrent.Right.iTop ); - vr_ipdtest_right_b.SetValue ( m_IpdTestCurrent.Right.iBot ); - vr_ipdtest_right_i.SetValue ( m_IpdTestCurrent.Right.iIn ); - vr_ipdtest_right_o.SetValue ( m_IpdTestCurrent.Right.iOut ); - -#ifdef _DEBUG - Warning ( " TBIO: left %d %d %d %d: right %d %d %d %d: %f inches\n", // Need the spaces to center it so I can read it! - m_IpdTestCurrent.Left.iTop, - m_IpdTestCurrent.Left.iBot, - m_IpdTestCurrent.Left.iIn, - m_IpdTestCurrent.Left.iOut, - m_IpdTestCurrent.Right.iTop, - m_IpdTestCurrent.Right.iBot, - m_IpdTestCurrent.Right.iIn, - m_IpdTestCurrent.Right.iOut, - m_IpdTestCurrent.fIpdInches ); + // remember where we were + m_bNonVRWindowed = g_pMaterialSystem->GetCurrentConfigForVideoCard().Windowed(); + vgui::surface()->GetScreenSize( m_nNonVRWidth, m_nNonVRHeight ); +#if defined( USE_SDL ) + static ConVarRef sdl_displayindex( "sdl_displayindex" ); + m_nNonVRSDLDisplayIndex = sdl_displayindex.GetInt(); #endif + + if( !g_pSourceVR->Activate() ) + { + // we couldn't activate, so just punt on this whole thing + return; + } + + // general all-game stuff + engine->ExecuteClientCmd( "mat_reset_rendertargets\n" ); + + // game specific VR config + CUtlString sCmd; + sCmd.Format( "exec sourcevr_%s.cfg\n", COM_GetModDirectory() ); + engine->ExecuteClientCmd( sCmd.Get() ); + + vgui::surface()->SetSoftwareCursor( true ); + +#if defined(POSIX) + ConVarRef m_rawinput( "m_rawinput" ); + m_bNonVRRawInput = m_rawinput.GetBool(); + m_rawinput.SetValue( 1 ); + + ConVarRef mat_vsync( "mat_vsync" ); + mat_vsync.SetValue( 0 ); +#endif + + g_pMatSystemSurface->ForceScreenSizeOverride(true, 640, 480 ); + int nViewportWidth, nViewportHeight; + + g_pSourceVR->GetViewportBounds( ISourceVirtualReality::VREye_Left, NULL, NULL, &nViewportWidth, &nViewportHeight ); + vgui::surface()->SetFullscreenViewportAndRenderTarget( 0, 0, nViewportWidth, nViewportHeight, g_pSourceVR->GetRenderTarget( ISourceVirtualReality::VREye_Left, ISourceVirtualReality::RT_Color ) ); + + vgui::ivgui()->SetVRMode( true ); + + VRRect_t rect; + if( g_pSourceVR->GetDisplayBounds( &rect ) ) + { + + // set mode + char szCmd[ 256 ]; + Q_snprintf( szCmd, sizeof( szCmd ), "mat_setvideomode %i %i %i\n", rect.nWidth, rect.nHeight, vr_force_windowed.GetBool()? 1 : 0 ); + engine->ClientCmd_Unrestricted( szCmd ); + } } -void CClientVirtualReality::SetEyeCalibrationDisplayMisc ( int iEditingNum, bool bVisible ) + +void CClientVirtualReality::Deactivate() { - if( bVisible && !m_bIpdTestEnabled ) + // can't deactivate when we aren't active + if( !UseVR() ) + return; + + g_pSourceVR->Deactivate(); + + g_pMatSystemSurface->ForceScreenSizeOverride(false, 0, 0 ); + g_pMaterialSystem->GetRenderContext()->Viewport( 0, 0, m_nNonVRWidth, m_nNonVRHeight ); + vgui::surface()->SetFullscreenViewportAndRenderTarget( 0, 0, m_nNonVRWidth, m_nNonVRHeight, NULL ); + + static ConVarRef cl_software_cursor( "cl_software_cursor" ); + vgui::surface()->SetSoftwareCursor( cl_software_cursor.GetBool() ); + +#if defined( USE_SDL ) + static ConVarRef sdl_displayindex( "sdl_displayindex" ); + sdl_displayindex.SetValue( m_nNonVRSDLDisplayIndex ); +#endif + +#if defined(POSIX) + ConVarRef m_rawinput( "m_rawinput" ); + m_rawinput.SetValue( m_bNonVRRawInput ); +#endif + + // Make sure the client .dll root panel is at the proper point before doing the "SolveTraverse" calls + vgui::VPANEL root = enginevgui->GetPanel( PANEL_CLIENTDLL ); + if ( root != 0 ) { - // if we're being shown, read out the current config from the convars - GetCurrentEyeCalibration ( &m_IpdTestCurrent ); + vgui::ipanel()->SetSize( root, m_nNonVRWidth, m_nNonVRHeight ); + } + // Same for client .dll tools + root = enginevgui->GetPanel( PANEL_CLIENTDLL_TOOLS ); + if ( root != 0 ) + { + vgui::ipanel()->SetSize( root, m_nNonVRWidth, m_nNonVRHeight ); } - m_IpdTestControl = iEditingNum; - m_bIpdTestEnabled = bVisible; + int viewWidth, viewHeight; + vgui::surface()->GetScreenSize( viewWidth, viewHeight ); + + engine->ExecuteClientCmd( "mat_reset_rendertargets\n" ); + + // set mode + char szCmd[ 256 ]; + Q_snprintf( szCmd, sizeof( szCmd ), "mat_setvideomode %i %i %i\n", m_nNonVRWidth, m_nNonVRHeight, m_bNonVRWindowed ? 1 : 0 ); + engine->ClientCmd_Unrestricted( szCmd ); + } -void CClientVirtualReality::DrawIpdCalibration ( const vrect_t *SrcRect ) +// Called when startup is complete +void CClientVirtualReality::StartupComplete() { - int ControlNum = m_IpdTestControl; - int WhichEdges = 0; - bool bShowLeft = false; - bool bShowRight = false; - switch ( ControlNum ) - { - case 0: case 1: case 2: case 3: - bShowLeft = true; - WhichEdges = 1 << ControlNum; - break; - case 4: case 5: case 6: case 7: - bShowRight = true; - WhichEdges = 1 << ControlNum; - break; - case 8: - // Adjust IPD directly. - bShowLeft = true; - bShowRight = true; - WhichEdges = 0x33; - break; - case 9: - // Left relief. - bShowLeft = true; - WhichEdges = 0xff; - break; - case 10: - // Right relief. - bShowRight = true; - WhichEdges = 0xff; - break; - default: - Assert ( false ); - break; - } - - CMatRenderContextPtr pRenderContext( materials ); - - //pRenderContext->ClearColor4ub ( 0, 0, 0, 0 ); - //pRenderContext->ClearBuffers ( true, true ); - - IMaterial *pMaterial = materials->FindMaterial ( "debug/debugtranslucentsinglecolor", TEXTURE_GROUP_OTHER, true ); - pMaterial->ColorModulate( 1.0f, 1.0f, 1.0f ); - pMaterial->AlphaModulate( 1.0f ); - - const int Border = 4; - const int BlueStart = 10; // Well, it used to be blue, now it isn't. - const int BlueSize = 30; - - // You want a pure green for the "current" edge so that it has no chromatic aberration smearing (i.e. white is a terrible choice!) - // The non-current lines can be a different colour because you're not actively tuning them. -#define SET_COLOR1(num) if ( 0 != ( WhichEdges & (1<<(num)) ) ) { pMaterial->ColorModulate( 0.0f, 1.0f, 0.0f ); } else { pMaterial->ColorModulate( 0.25f, 0.25f, 0.25f ); } -#define SET_COLOR2(num) if ( 0 != ( WhichEdges & (1<<(num)) ) ) { pMaterial->ColorModulate( 1.0f, 1.0f, 1.0f ); } else { pMaterial->ColorModulate( 0.0f, 0.0f, 0.0f ); } - - if ( bShowLeft ) - { - int t = m_IpdTestCurrent.Left.iTop; - int b = m_IpdTestCurrent.Left.iBot; - int l = m_IpdTestCurrent.Left.iOut; - int r = m_IpdTestCurrent.Left.iIn; - - // Render a black rect to enhance contrast. - pMaterial->ColorModulate( 0.0f, 0.0f, 0.0f ); - pMaterial->AlphaModulate( 1.0f ); - - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l-Border-1, t-Border-1, r-l+Border*2+3, Border*2+3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l-Border-1, b-Border-1, r-l+Border*2+3, Border*2+3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l-Border-1, t-Border-1, Border*2+3, b-t+Border*2+3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, r-Border-1, t-Border-1, Border*2+3, b-t+Border*2+3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - - int cx = (l+r)/2; - int cy = (t+b)/2; - - // For each side, draw the line along the side, and also a line "pointing to" it from the middle. - // Left - SET_COLOR1(1); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l, t, 1, b-t+1, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - SET_COLOR2(1); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l+BlueStart, cy-1, BlueSize, 3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - - // Right - SET_COLOR1(0); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, r, t, 1, b-t+1, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - SET_COLOR2(0); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, r-BlueStart-BlueSize, cy-1, BlueSize, 3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - - // Top - SET_COLOR1(2); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l, t, r-l+1, 1, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - SET_COLOR2(2); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, cx-1, t+BlueStart, 3, BlueSize, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - - // Bottom - SET_COLOR1(3); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l, b, r-l+1, 1, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - SET_COLOR2(3); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, cx-1, b-BlueStart-BlueSize, 3, BlueSize, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - } - - if ( bShowRight ) - { - int t = m_IpdTestCurrent.Right.iTop; - int b = m_IpdTestCurrent.Right.iBot; - // An outside value of 0 is the first actual pixel on the edge of the display. So if both values are 0, the two lines are (SrcRect->width - 1) apart. - int l = SrcRect->width - 1 - m_IpdTestCurrent.Right.iIn; - int r = SrcRect->width - 1 - m_IpdTestCurrent.Right.iOut; - - // Render a black rect to enhance contrast. - pMaterial->ColorModulate( 0.0f, 0.0f, 0.0f ); - pMaterial->AlphaModulate( 1.0f ); - - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l-Border-1, t-Border-1, r-l+Border*2+3, Border*2+3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l-Border-1, b-Border-1, r-l+Border*2+3, Border*2+3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l-Border-1, t-Border-1, Border*2+3, b-t+Border*2+3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, r-Border-1, t-Border-1, Border*2+3, b-t+Border*2+3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - - int cx = (l+r)/2; - int cy = (t+b)/2; - - // For each side, draw the line along the side, and also a line "pointing to" it from the middle. - // Left - SET_COLOR1(4); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l, t, 1, b-t+1, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - SET_COLOR2(4); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l+BlueStart, cy-1, BlueSize, 3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - - // Right - SET_COLOR1(5); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, r, t, 1, b-t+1, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - SET_COLOR2(5); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, r-BlueStart-BlueSize, cy-1, BlueSize, 3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - - // Top - SET_COLOR1(6); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l, t, r-l+1, 1, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - SET_COLOR2(6); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, cx-1, t+BlueStart, 3, BlueSize, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - - // Bottom - SET_COLOR1(7); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l, b, r-l+1, 1, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - SET_COLOR2(7); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, cx-1, b-BlueStart-BlueSize, 3, BlueSize, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - } - - return; + if( vr_activate_default.GetBool() ) + Activate(); } diff --git a/mp/src/game/client/client_virtualreality.h b/mp/src/game/client/client_virtualreality.h index c06c6527..9aadfeb3 100644 --- a/mp/src/game/client/client_virtualreality.h +++ b/mp/src/game/client/client_virtualreality.h @@ -14,6 +14,7 @@ #include "tier3/tier3.h" #include "iclientvirtualreality.h" +#include "view_shared.h" enum HeadtrackMovementMode_t { @@ -34,20 +35,6 @@ enum HeadtrackMovementMode_t }; -// used for interacting with the calibration UI -struct TEyeCalibration -{ - struct TEyeEdges - { - int iTop, iBot, iIn, iOut; // These are used to calculate everything else. - float fSizePixels; - float fReliefInches; - } Left, Right; - - float fIpdPixels; - float fIpdInches; -}; - //----------------------------------------------------------------------------- // The implementation //----------------------------------------------------------------------------- @@ -77,6 +64,8 @@ public: virtual InitReturnVal_t Init(); virtual void Shutdown(); + // Called when startup is complete + void StartupComplete(); //--------------------------------------------------------- // IClientVirtualReality implementation @@ -94,6 +83,7 @@ public: bool CurrentlyZoomed(); void OverrideTorsoTransform( const Vector & position, const QAngle & angles ) ; void CancelTorsoTransformOverride( ) ; + bool CanOverlayHudQuad(); void GetHUDBounds( Vector *pViewer, Vector *pUL, Vector *pUR, Vector *pLL, Vector *pLR ); void RenderHUDQuad( bool bBlackout, bool bTranslucent ); float GetZoomedModeMagnification(); @@ -105,23 +95,14 @@ public: const VMatrix & GetWorldFromMidEye() const { return m_WorldFromMidEyeNoDebugCam; } void OverrideViewModelTransform( Vector & vmorigin, QAngle & vmangles, bool bUseLargeOverride ); void AlignTorsoAndViewToWeapon(); - void PostProcessFrame( const vrect_t *SrcRect ); + void PostProcessFrame( StereoEye_t eEye ); + void OverlayHUDQuadWithUndistort( const CViewSetup &view, bool bDoUndistort, bool bBlackout, bool bTranslucent ); //--------------------------------------------------------- - // Stat collection + // Enter/leave VR mode //--------------------------------------------------------- - bool CollectSessionStartStats( KeyValues *pkvStats ); - bool CollectPeriodicStats( KeyValues *pkvStats ); - - //--------------------------------------------------------- - // IPD Calibration - //--------------------------------------------------------- - void DrawIpdCalibration ( const vrect_t *SrcRect ); - - void RecalcEyeCalibration ( TEyeCalibration *p ); - void GetCurrentEyeCalibration ( TEyeCalibration *p ); - void SetCurrentEyeCalibration ( TEyeCalibration const &p ); - void SetEyeCalibrationDisplayMisc ( int iEditingNum, bool bVisible ); + void Activate(); + void Deactivate(); private: HeadtrackMovementMode_t m_hmmMovementActual; @@ -169,11 +150,14 @@ private: RTime32 m_rtLastMotionSample; - // IPD test fields - bool m_bIpdTestEnabled; - int m_IpdTestControl; - TEyeCalibration m_IpdTestCurrent; - + // video mode we had before we entered VR mode + bool m_bNonVRWindowed; + int m_nNonVRWidth; + int m_nNonVRHeight; +#if defined( USE_SDL ) + int m_nNonVRSDLDisplayIndex; +#endif + bool m_bNonVRRawInput; }; extern CClientVirtualReality g_ClientVirtualReality; diff --git a/mp/src/game/client/clientmode_shared.cpp b/mp/src/game/client/clientmode_shared.cpp index a1d1127d..b6dee29c 100644 --- a/mp/src/game/client/clientmode_shared.cpp +++ b/mp/src/game/client/clientmode_shared.cpp @@ -36,7 +36,7 @@ #include #include "hud_vote.h" #include "ienginevgui.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #if defined( _X360 ) #include "xbox/xbox_console.h" #endif @@ -208,6 +208,7 @@ static void __MsgFunc_VGUIMenu( bf_read &msg ) if ( count > 0 ) { KeyValues *keys = new KeyValues("data"); + //Msg( "MsgFunc_VGUIMenu:\n" ); for ( int i=0; iSetString( name, data ); } + // !KLUDGE! Whitelist of URL protocols formats for MOTD + if ( + !V_stricmp( panelname, PANEL_INFO ) // MOTD + && keys->GetInt( "type", 0 ) == 2 // URL message type + ) { + const char *pszURL = keys->GetString( "msg", "" ); + if ( Q_strncmp( pszURL, "http://", 7 ) != 0 && Q_strncmp( pszURL, "https://", 8 ) != 0 ) + { + Warning( "Blocking MOTD URL '%s'; must begin with 'http://' or 'https://'\n", pszURL ); + keys->deleteThis(); + return; + } + } + viewport->SetData( keys ); keys->deleteThis(); @@ -496,7 +512,7 @@ bool ClientModeShared::ShouldBlackoutAroundHUD() //----------------------------------------------------------------------------- -// Purpose: Allows the client mode to override mouse control stuff in headtrack +// Purpose: Allows the client mode to override mouse control stuff in sourcevr //----------------------------------------------------------------------------- HeadtrackMovementMode_t ClientModeShared::ShouldOverrideHeadtrackControl() { diff --git a/mp/src/game/client/clientmode_shared.h b/mp/src/game/client/clientmode_shared.h index ae784c00..27336964 100644 --- a/mp/src/game/client/clientmode_shared.h +++ b/mp/src/game/client/clientmode_shared.h @@ -132,6 +132,7 @@ public: virtual bool IsInfoPanelAllowed() OVERRIDE { return true; } virtual void InfoPanelDisplayed() OVERRIDE { } + virtual bool IsHTMLInfoPanelAllowed() OVERRIDE { return true; } protected: CBaseViewport *m_pViewport; diff --git a/mp/src/game/client/game_controls/vguitextwindow.cpp b/mp/src/game/client/game_controls/vguitextwindow.cpp index 450fa07c..5cdc2532 100644 --- a/mp/src/game/client/game_controls/vguitextwindow.cpp +++ b/mp/src/game/client/game_controls/vguitextwindow.cpp @@ -9,6 +9,7 @@ #include "vguitextwindow.h" #include #include +#include #include #include @@ -165,8 +166,15 @@ void CTextWindow::ShowText( const char *text ) void CTextWindow::ShowURL( const char *URL, bool bAllowUserToDisable ) { #if defined( ENABLE_CHROMEHTMLWINDOW ) - if ( bAllowUserToDisable && cl_disablehtmlmotd.GetBool() ) + #ifdef _DEBUG + Msg( "CTextWindow::ShowURL( %s )\n", URL ); + #endif + + ClientModeShared *mode = ( ClientModeShared * )GetClientModeNormal(); + if ( ( bAllowUserToDisable && cl_disablehtmlmotd.GetBool() ) || !mode->IsHTMLInfoPanelAllowed() ) { + Warning( "Blocking HTML info panel '%s'; Using plaintext instead.\n", URL ); + // User has disabled HTML TextWindows. Show the fallback as text only. if ( g_pStringTableInfoPanel ) { @@ -289,7 +297,15 @@ void CTextWindow::Update( void ) } else if ( m_nContentType == TYPE_URL ) { - ShowURL( m_szMessage ); + if ( !Q_strncmp( m_szMessage, "http://", 7 ) || !Q_strncmp( m_szMessage, "https://", 8 ) || !Q_stricmp( m_szMessage, "about:blank" ) ) + { + ShowURL( m_szMessage ); + } + else + { + // We should have trapped this at a higher level + Assert( !"URL protocol is missing or blocked" ); + } } else if ( m_nContentType == TYPE_FILE ) { diff --git a/mp/src/game/client/hl2/hud_autoaim.cpp b/mp/src/game/client/hl2/hud_autoaim.cpp index 3339a72f..aa808acf 100644 --- a/mp/src/game/client/hl2/hud_autoaim.cpp +++ b/mp/src/game/client/hl2/hud_autoaim.cpp @@ -146,6 +146,7 @@ void CHUDAutoAim::VidInit( void ) //----------------------------------------------------------------------------- bool CHUDAutoAim::ShouldDraw( void ) { +#ifndef HL1_CLIENT_DLL C_BaseHLPlayer *pLocalPlayer = (C_BaseHLPlayer *)C_BasePlayer::GetLocalPlayer(); if ( pLocalPlayer ) { @@ -154,6 +155,7 @@ bool CHUDAutoAim::ShouldDraw( void ) return false; } } +#endif return ( (hud_draw_fixed_reticle.GetBool() || hud_draw_active_reticle.GetBool()) && CHudElement::ShouldDraw() && !engine->IsDrawingLoadingImage() ); } diff --git a/mp/src/game/client/hl2/hud_damageindicator.cpp b/mp/src/game/client/hl2/hud_damageindicator.cpp index 86debdf7..48dd9b62 100644 --- a/mp/src/game/client/hl2/hud_damageindicator.cpp +++ b/mp/src/game/client/hl2/hud_damageindicator.cpp @@ -20,7 +20,7 @@ #include "IEffects.h" #include "hudelement.h" #include "clienteffectprecachesystem.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" using namespace vgui; diff --git a/mp/src/game/client/hl2/hud_weaponselection.cpp b/mp/src/game/client/hl2/hud_weaponselection.cpp index 3d857e99..9d223169 100644 --- a/mp/src/game/client/hl2/hud_weaponselection.cpp +++ b/mp/src/game/client/hl2/hud_weaponselection.cpp @@ -451,6 +451,17 @@ void CHudWeaponSelection::Paint() if ( !pSelectedWeapon ) return; + bool bPushedViewport = false; + if( hud_fastswitch.GetInt() == HUDTYPE_FASTSWITCH || hud_fastswitch.GetInt() == HUDTYPE_PLUS ) + { + CMatRenderContextPtr pRenderContext( materials ); + if( pRenderContext->GetRenderTarget() ) + { + surface()->PushFullscreenViewport(); + bPushedViewport = true; + } + } + // interpolate the selected box size between the small box size and the large box size // interpolation has been removed since there is no weapon pickup animation anymore, so it's all at the largest size float percentageDone = 1.0f; //min(1.0f, (gpGlobals->curtime - m_flPickupStartTime) / m_flWeaponPickupGrowTime); @@ -727,6 +738,11 @@ void CHudWeaponSelection::Paint() } break; } + + if( bPushedViewport ) + { + surface()->PopFullscreenViewport(); + } } @@ -1025,8 +1041,6 @@ void CHudWeaponSelection::ApplySchemeSettings(vgui::IScheme *pScheme) { SetBounds( x, y, screenWide - x, screenTall - y ); } - - SetForceStereoRenderToFrameBuffer( true ); } //----------------------------------------------------------------------------- diff --git a/mp/src/game/client/hud_basedeathnotice.cpp b/mp/src/game/client/hud_basedeathnotice.cpp index b3f494b6..d732bd05 100644 --- a/mp/src/game/client/hud_basedeathnotice.cpp +++ b/mp/src/game/client/hud_basedeathnotice.cpp @@ -114,7 +114,8 @@ void CHudBaseDeathNotice::Paint() DeathNoticeItem &msg = m_DeathNotices[i]; CHudTexture *icon = msg.iconDeath; - + CHudTexture *iconPrekiller = msg.iconPreKiller; + wchar_t victim[256]=L""; wchar_t killer[256]=L""; @@ -125,10 +126,15 @@ void CHudBaseDeathNotice::Paint() int iVictimTextWide = UTIL_ComputeStringWidth( m_hTextFont, victim ) + xSpacing; int iDeathInfoTextWide= msg.wzInfoText[0] ? UTIL_ComputeStringWidth( m_hTextFont, msg.wzInfoText ) + xSpacing : 0; + int iDeathInfoEndTextWide= msg.wzInfoTextEnd[0] ? UTIL_ComputeStringWidth( m_hTextFont, msg.wzInfoTextEnd ) + xSpacing : 0; + int iKillerTextWide = killer[0] ? UTIL_ComputeStringWidth( m_hTextFont, killer ) + xSpacing : 0; int iLineTall = m_flLineHeight; int iTextTall = surface()->GetFontTall( m_hTextFont ); int iconWide = 0, iconTall = 0, iDeathInfoOffset = 0, iVictimTextOffset = 0, iconActualWide = 0; + + int iPreKillerTextWide = msg.wzPreKillerText[0] ? UTIL_ComputeStringWidth( m_hTextFont, msg.wzPreKillerText ) - xSpacing : 0; + int iconPrekillerWide = 0, iconPrekillerActualWide = 0, iconPreKillerTall = 0; // Get the local position for this notice if ( icon ) @@ -145,7 +151,25 @@ void CHudBaseDeathNotice::Paint() iconTall *= flScale; iconWide *= flScale; } - int iTotalWide = iKillerTextWide + iconWide + iVictimTextWide + iDeathInfoTextWide + ( xMargin * 2 ); + + if ( iconPrekiller ) + { + iconPrekillerActualWide = iconPrekiller->EffectiveWidth( 1.0f ); + iconPrekillerWide = iconPrekillerActualWide; + iconPreKillerTall = iconPrekiller->EffectiveHeight( 1.0f ); + + int iconTallDesired = iLineTall-YRES(2); + Assert( 0 != iconTallDesired ); + float flScale = (float) iconTallDesired / (float) iconPreKillerTall; + + iconPrekillerActualWide *= flScale; + iconPreKillerTall *= flScale; + iconPrekillerWide *= flScale; + } + + int iTotalWide = iKillerTextWide + iconWide + iVictimTextWide + iDeathInfoTextWide + iDeathInfoEndTextWide + ( xMargin * 2 ); + iTotalWide += iconPrekillerWide + iPreKillerTextWide; + int y = yStart + ( ( iLineTall + m_flLineSpacing ) * i ); int yText = y + ( ( iLineTall - iTextTall ) / 2 ); int yIcon = y + ( ( iLineTall - iconTall ) / 2 ); @@ -160,11 +184,11 @@ void CHudBaseDeathNotice::Paint() Vertex_t vert[NUM_BACKGROUND_COORD]; GetBackgroundPolygonVerts( x, y+1, x+iTotalWide, y+iLineTall-1, ARRAYSIZE( vert ), vert ); surface()->DrawSetTexture( -1 ); - surface()->DrawSetColor( msg.bLocalPlayerInvolved ? m_clrLocalBGColor : m_clrBaseBGColor ); + surface()->DrawSetColor( GetBackgroundColor ( i ) ); surface()->DrawTexturedPolygon( ARRAYSIZE( vert ), vert ); x += xMargin; - + if ( killer[0] ) { // Draw killer's name @@ -172,6 +196,22 @@ void CHudBaseDeathNotice::Paint() x += iKillerTextWide; } + // prekiller text + if ( msg.wzPreKillerText[0] ) + { + x += xSpacing; + DrawText( x + iDeathInfoOffset, yText, m_hTextFont, GetInfoTextColor( i ), msg.wzPreKillerText ); + x += iPreKillerTextWide; + } + + // Prekiller icon + if ( iconPrekiller ) + { + int yPreIconTall = y + ( ( iLineTall - iconPreKillerTall ) / 2 ); + iconPrekiller->DrawSelf( x, yPreIconTall, iconPrekillerActualWide, iconPreKillerTall, m_clrIcon ); + x += iconPrekillerWide + xSpacing; + } + // Draw glow behind weapon icon to show it was a crit death if ( msg.bCrit && msg.iconCritDeath ) { @@ -194,13 +234,19 @@ void CHudBaseDeathNotice::Paint() iVictimTextOffset -= iDeathInfoTextWide; } - DrawText( x + iDeathInfoOffset, yText, m_hTextFont, GetInfoTextColor( msg.bLocalPlayerInvolved ), msg.wzInfoText ); + DrawText( x + iDeathInfoOffset, yText, m_hTextFont, GetInfoTextColor( i ), msg.wzInfoText ); x += iDeathInfoTextWide; } // Draw victims name DrawText( x + iVictimTextOffset, yText, m_hTextFont, GetTeamColor( msg.Victim.iTeam, msg.bLocalPlayerInvolved ), victim ); x += iVictimTextWide; + + // Draw Additional Text on the end of the victims name + if ( msg.wzInfoTextEnd[0] ) + { + DrawText( x , yText, m_hTextFont, GetInfoTextColor( i ), msg.wzInfoTextEnd ); + } } } @@ -358,7 +404,12 @@ void CHudBaseDeathNotice::FireGameEvent( IGameEvent *event ) bLocalPlayerInvolved = true; } - if ( event->GetInt( "damagebits" ) & DMG_CRITICAL ) + if ( event->GetInt( "death_flags" ) & TF_DEATH_AUSTRALIUM ) + { + m_DeathNotices[iMsg].bCrit= true; + m_DeathNotices[iMsg].iconCritDeath = GetIcon( "d_australium", bLocalPlayerInvolved ? kDeathNoticeIcon_Inverted : kDeathNoticeIcon_Standard ); + } + else if ( event->GetInt( "damagebits" ) & DMG_CRITICAL ) { m_DeathNotices[iMsg].bCrit= true; m_DeathNotices[iMsg].iconCritDeath = GetIcon( "d_crit", bLocalPlayerInvolved ? kDeathNoticeIcon_Inverted : kDeathNoticeIcon_Standard ); diff --git a/mp/src/game/client/hud_basedeathnotice.h b/mp/src/game/client/hud_basedeathnotice.h index 7bd3bb56..2a9da0c5 100644 --- a/mp/src/game/client/hud_basedeathnotice.h +++ b/mp/src/game/client/hud_basedeathnotice.h @@ -30,6 +30,7 @@ struct DeathNoticeItem { szIcon[0]=0; wzInfoText[0]=0; + wzInfoTextEnd[0]=0; iconDeath = NULL; iconCritDeath = NULL; bSelfInflicted = false; @@ -40,6 +41,9 @@ struct DeathNoticeItem iWeaponID = -1; iKillerID = -1; iVictimID = -1; + + iconPreKiller = NULL; + wzPreKillerText[0] = 0; } float GetExpiryTime(); @@ -48,8 +52,13 @@ struct DeathNoticeItem DeathNoticePlayer Victim; char szIcon[32]; // name of icon to display wchar_t wzInfoText[32]; // any additional text to display next to icon + wchar_t wzInfoTextEnd[32]; // any additional text to display next to victim name CHudTexture *iconDeath; CHudTexture *iconCritDeath; // crit background icon + + CHudTexture *iconPreKiller; + wchar_t wzPreKillerText[32]; + bool bSelfInflicted; bool bLocalPlayerInvolved; bool bCrit; @@ -104,7 +113,8 @@ protected: virtual int UseExistingNotice( IGameEvent *event ) { return -1; } void GetLocalizedControlPointName( IGameEvent *event, char *namebuf, int namelen ); - virtual Color GetInfoTextColor( bool bLocalPlayerInvolved ){ return Color( 255, 255, 255, 255 ); } + virtual Color GetInfoTextColor( int iDeathNoticeMsg ){ return Color( 255, 255, 255, 255 ); } + virtual Color GetBackgroundColor ( int iDeathNoticeMsg ) { return m_DeathNotices[iDeathNoticeMsg].bLocalPlayerInvolved ? m_clrLocalBGColor : m_clrBaseBGColor; } CPanelAnimationVarAliasType( float, m_flLineHeight, "LineHeight", "16", "proportional_float" ); CPanelAnimationVarAliasType( float, m_flLineSpacing, "LineSpacing", "4", "proportional_float" ); @@ -115,6 +125,7 @@ protected: CPanelAnimationVar( Color, m_clrIcon, "IconColor", "255 80 0 255" ); CPanelAnimationVar( Color, m_clrBaseBGColor, "BaseBackgroundColor", "46 43 42 220" ); CPanelAnimationVar( Color, m_clrLocalBGColor, "LocalBackgroundColor", "245 229 196 200" ); + CPanelAnimationVar( Color, m_clrKillStreakBg, "KillStreakBackgroundColor", "224 223 219 200" ); CUtlVector m_DeathNotices; diff --git a/mp/src/game/client/hud_crosshair.cpp b/mp/src/game/client/hud_crosshair.cpp index 5327d23b..fc7714fe 100644 --- a/mp/src/game/client/hud_crosshair.cpp +++ b/mp/src/game/client/hud_crosshair.cpp @@ -16,7 +16,7 @@ #include "materialsystem/imaterialsystem.h" #include "VGuiMatSurface/IMatSystemSurface.h" #include "client_virtualreality.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #ifdef SIXENSE #include "sixense/in_sixense.h" diff --git a/mp/src/game/client/hud_vote.cpp b/mp/src/game/client/hud_vote.cpp index 7a88bb22..55b8f389 100644 --- a/mp/src/game/client/hud_vote.cpp +++ b/mp/src/game/client/hud_vote.cpp @@ -1059,6 +1059,10 @@ void CHudVote::MsgFunc_CallVoteFailed( bf_read &msg ) case VOTE_FAILED_CANNOT_KICK_DURING_ROUND: m_pCallVoteFailed->SetControlString( "FailedReason", "#GameUI_vote_failed_round_active" ); break; + + case VOTE_FAILED_MODIFICATION_ALREADY_ACTIVE: + m_pCallVoteFailed->SetControlString( "FailedReason", "#GameUI_vote_failed_event_already_active" ); + break; } } diff --git a/mp/src/game/client/iclientmode.h b/mp/src/game/client/iclientmode.h index 5bf7aedb..2b74f625 100644 --- a/mp/src/game/client/iclientmode.h +++ b/mp/src/game/client/iclientmode.h @@ -147,6 +147,7 @@ public: virtual bool IsInfoPanelAllowed() = 0; virtual void InfoPanelDisplayed() = 0; + virtual bool IsHTMLInfoPanelAllowed() = 0; }; extern IClientMode *g_pClientMode; diff --git a/mp/src/game/client/in_main.cpp b/mp/src/game/client/in_main.cpp index 9cb7cd31..21eb30a0 100644 --- a/mp/src/game/client/in_main.cpp +++ b/mp/src/game/client/in_main.cpp @@ -31,7 +31,7 @@ #endif #include "client_virtualreality.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" // NVNT Include #include "haptics/haptic_utils.h" diff --git a/mp/src/game/client/replay/vgui/replayperformanceeditor.cpp b/mp/src/game/client/replay/vgui/replayperformanceeditor.cpp index 781a5c37..99178f6e 100644 --- a/mp/src/game/client/replay/vgui/replayperformanceeditor.cpp +++ b/mp/src/game/client/replay/vgui/replayperformanceeditor.cpp @@ -1185,6 +1185,7 @@ CReplayPerformanceEditorPanel::CReplayPerformanceEditorPanel( Panel *parent, Rep m_nRedBlueSigns[0] = -1; m_nRedBlueSigns[1] = 1; m_iCurPlayerTarget = -1; + m_bCurrentTargetNeedsVisibilityUpdate = false; m_pImageList = new ImageList( false ); @@ -1737,6 +1738,19 @@ void CReplayPerformanceEditorPanel::OnTick() pCamera->SetPrimaryTarget( m_iCurPlayerTarget ); } + // fixes a case where the replay would be paused and the player would cycle cameras but the + // target's visibility wouldn't be updated until the replay was unpaused (they would be invisible) + if ( m_bCurrentTargetNeedsVisibilityUpdate ) + { + C_BaseEntity *pTarget = ClientEntityList().GetEnt( pCamera->GetPrimaryTargetIndex() ); + if ( pTarget ) + { + pTarget->UpdateVisibility(); + } + + m_bCurrentTargetNeedsVisibilityUpdate = false; + } + // If in free-cam mode, add set view event if we're not paused if ( bInAControllableCameraMode && m_bShownAtLeastOnce && bRecording ) { @@ -2444,12 +2458,14 @@ void CReplayPerformanceEditorPanel::OnCommand( const char *command ) { ReplayCamera()->SetMode( OBS_MODE_IN_EYE ); UpdateCameraSelectionPosition( CAM_FIRST ); + m_bCurrentTargetNeedsVisibilityUpdate = true; g_pReplayPerformanceController->AddEvent_Camera_Change_FirstPerson( flCurTime, nEntIndex ); } else if ( !V_stricmp( pCamType, "third" ) ) { ReplayCamera()->SetMode( OBS_MODE_CHASE ); UpdateCameraSelectionPosition( CAM_THIRD ); + m_bCurrentTargetNeedsVisibilityUpdate = true; g_pReplayPerformanceController->AddEvent_Camera_Change_ThirdPerson( flCurTime, nEntIndex ); AddSetViewEvent(); } @@ -2457,6 +2473,7 @@ void CReplayPerformanceEditorPanel::OnCommand( const char *command ) { ReplayCamera()->SetMode( OBS_MODE_ROAMING ); UpdateCameraSelectionPosition( CAM_FREE ); + m_bCurrentTargetNeedsVisibilityUpdate = true; g_pReplayPerformanceController->AddEvent_Camera_Change_Free( flCurTime ); AddSetViewEvent(); DisplayPerformanceTip( "#Replay_PerfTip_EnterFreeCam", &replay_perftip_count_freecam_enter, MAX_TIP_DISPLAYS ); diff --git a/mp/src/game/client/replay/vgui/replayperformanceeditor.h b/mp/src/game/client/replay/vgui/replayperformanceeditor.h index 50a96d09..034843a3 100644 --- a/mp/src/game/client/replay/vgui/replayperformanceeditor.h +++ b/mp/src/game/client/replay/vgui/replayperformanceeditor.h @@ -224,6 +224,8 @@ private: float m_flActiveTimeInEditor; // Will be zero'd out if user is idle (ie if they don't press space bar often enough) CPanelAnimationVarAliasType( int, m_nRightMarginWidth, "right_margin_width", "0", "proportional_xpos" ); + + bool m_bCurrentTargetNeedsVisibilityUpdate; }; //----------------------------------------------------------------------------- diff --git a/mp/src/game/client/sixense/in_sixense.cpp b/mp/src/game/client/sixense/in_sixense.cpp index 2988201f..e0f4ba39 100644 --- a/mp/src/game/client/sixense/in_sixense.cpp +++ b/mp/src/game/client/sixense/in_sixense.cpp @@ -62,7 +62,7 @@ using sixenseMath::Line; #include "iinput.h" #include "game/client/iviewport.h" #include "filesystem.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #ifdef TF_CLIENT_DLL #include "tf_hud_menu_engy_build.h" diff --git a/mp/src/game/client/view.cpp b/mp/src/game/client/view.cpp index b282b5c3..333a2756 100644 --- a/mp/src/game/client/view.cpp +++ b/mp/src/game/client/view.cpp @@ -36,13 +36,14 @@ #include "materialsystem/itexture.h" #include "materialsystem/imaterialsystem.h" #include "materialsystem/materialsystem_config.h" +#include "VGuiMatSurface/IMatSystemSurface.h" #include "toolframework_client.h" #include "tier0/icommandline.h" #include "ienginevgui.h" #include #include #include "ScreenSpaceEffects.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #include "client_virtualreality.h" #if defined( REPLAY_ENABLED ) @@ -84,10 +85,6 @@ extern ConVar sensitivity; ConVar zoom_sensitivity_ratio( "zoom_sensitivity_ratio", "1.0", 0, "Additional mouse sensitivity scale factor applied when FOV is zoomed in." ); -#ifdef STAGING_ONLY -ConVar vr_stereo_debug_viewport( "vr_stereo_debug_viewport", "0" ); -#endif - CViewRender g_DefaultViewRender; IViewRender *view = NULL; // set in cldll_client_init.cpp if no mod creates their own @@ -301,16 +298,6 @@ void CViewRender::Init( void ) m_pDrawEntities = cvar->FindVar( "r_drawentities" ); m_pDrawBrushModels = cvar->FindVar( "r_drawbrushmodels" ); - if( UseVR() ) - { - m_eStartEye = STEREO_EYE_LEFT; - m_eLastEye = STEREO_EYE_RIGHT; - } - else - { - m_eStartEye = m_eLastEye = STEREO_EYE_MONO; - } - beams->InitBeams(); tempents->Init(); @@ -500,12 +487,18 @@ void CViewRender::DriftPitch (void) StereoEye_t CViewRender::GetFirstEye() const { - return m_eStartEye; + if( UseVR() ) + return STEREO_EYE_LEFT; + else + return STEREO_EYE_MONO; } StereoEye_t CViewRender::GetLastEye() const { - return m_eLastEye; + if( UseVR() ) + return STEREO_EYE_RIGHT; + else + return STEREO_EYE_MONO; } @@ -1177,57 +1170,14 @@ void CViewRender::Render( vrect_t *rect ) } break; + case STEREO_EYE_RIGHT: case STEREO_EYE_LEFT: { -#ifdef STAGING_ONLY - if ( vr_stereo_debug_viewport.GetBool() ) - { - // Stress-test for crazy viewports. - view.width = vr.width * flViewportScale * 0.25f; - view.height = vr.height * flViewportScale * 0.75f; - view.x = vr.x * flViewportScale; - view.y = (vr.y + vr.height * 0.20f) * flViewportScale; - - view.m_nUnscaledWidth = vr.width / 2; - } - else -#endif - { - view.width = vr.width * flViewportScale * 0.5f; - view.height = vr.height * flViewportScale; - view.x = vr.x * flViewportScale ; - view.y = vr.y * flViewportScale; - - view.m_nUnscaledWidth = vr.width / 2; - } - } - break; - - case STEREO_EYE_RIGHT: - { -#ifdef STAGING_ONLY - if ( vr_stereo_debug_viewport.GetBool() ) - { - // Stress-test for crazy viewports. - view.width = vr.width * flViewportScale * 0.75f; - view.height = vr.height * flViewportScale * 0.75f; - view.x = vr.x + vr.width * 0.25f; - view.y = vr.y + vr.height * 0.1f; - - view.m_nUnscaledWidth = vr.width / 2; - view.m_nUnscaledX = vr.x + view.m_nUnscaledWidth; - } - else -#endif - { - view.width = vr.width * flViewportScale * 0.5f; - view.height = vr.height * flViewportScale; - view.x = (vr.x + view.width) * flViewportScale; - view.y = vr.y * flViewportScale; - - view.m_nUnscaledWidth = vr.width / 2; - view.m_nUnscaledX = vr.x + view.m_nUnscaledWidth; - } + g_pSourceVR->GetViewportBounds( (ISourceVirtualReality::VREye)(eEye - 1 ), &view.x, &view.y, &view.width, &view.height ); + view.m_nUnscaledWidth = view.width; + view.m_nUnscaledHeight = view.height; + view.m_nUnscaledX = view.x; + view.m_nUnscaledY = view.y; } break; @@ -1302,9 +1252,32 @@ void CViewRender::Render( vrect_t *rect ) // we should use the monitor view from the left eye for both eyes flags |= RENDERVIEW_SUPPRESSMONITORRENDERING; } - RenderView( view, nClearFlags, flags ); - } + RenderView( view, nClearFlags, flags ); + + if ( UseVR() ) + { + bool bDoUndistort = ! engine->IsTakingScreenshot(); + + if ( bDoUndistort ) + { + g_ClientVirtualReality.PostProcessFrame( eEye ); + } + + // logic here all cloned from code in viewrender.cpp around RenderHUDQuad: + + // figure out if we really want to draw the HUD based on freeze cam + bool bInFreezeCam = ( pPlayer && pPlayer->GetObserverMode() == OBS_MODE_FREEZECAM ); + + // draw the HUD after the view model so its "I'm closer" depth queues work right. + if( !bInFreezeCam && g_ClientVirtualReality.ShouldRenderHUDInWorld() ) + { + // TODO - a bit of a shonky test - basically trying to catch the main menu, the briefing screen, the loadout screen, etc. + bool bTranslucent = !g_pMatSystemSurface->IsCursorVisible(); + g_ClientVirtualReality.OverlayHUDQuadWithUndistort( view, bDoUndistort, g_pClientMode->ShouldBlackoutAroundHUD(), bTranslucent ); + } + } + } // TODO: should these be inside or outside the stereo eye stuff? @@ -1334,15 +1307,6 @@ void CViewRender::Render( vrect_t *rect ) } - if ( UseVR() ) - { - if ( !engine->IsTakingScreenshot() ) - { - // Deal with the distortion on the display. - g_ClientVirtualReality.PostProcessFrame( rect ); - } - } - } diff --git a/mp/src/game/client/view_scene.cpp b/mp/src/game/client/view_scene.cpp index 73c05a2b..098e9ae9 100644 --- a/mp/src/game/client/view_scene.cpp +++ b/mp/src/game/client/view_scene.cpp @@ -11,7 +11,7 @@ #include "rendertexture.h" #include "view_scene.h" #include "viewrender.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #include "client_virtualreality.h" // memdbgon must be the last include file in a .cpp file!!! diff --git a/mp/src/game/client/viewpostprocess.cpp b/mp/src/game/client/viewpostprocess.cpp index 7fe7c40d..3f74acdc 100644 --- a/mp/src/game/client/viewpostprocess.cpp +++ b/mp/src/game/client/viewpostprocess.cpp @@ -834,7 +834,7 @@ void CLuminanceHistogramSystem::UpdateLuminanceRanges( void ) s_bFirstTime = false; // This seems like a bad idea but it's fine for now - const char *sModsForOriginalAlgorithm[] = { "dod", "cstrike", "lostcoast" }; + const char *sModsForOriginalAlgorithm[] = { "dod", "cstrike", "lostcoast", "hl1" }; for ( int i=0; i<3; i++ ) { if ( strlen( engine->GetGameDirectory() ) >= strlen( sModsForOriginalAlgorithm[i] ) ) diff --git a/mp/src/game/client/viewrender.cpp b/mp/src/game/client/viewrender.cpp index 7422479b..a9ef4eb8 100644 --- a/mp/src/game/client/viewrender.cpp +++ b/mp/src/game/client/viewrender.cpp @@ -51,7 +51,7 @@ #include "studio_stats.h" #include "con_nprint.h" #include "clientmode_shared.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #include "client_virtualreality.h" #ifdef PORTAL @@ -394,7 +394,7 @@ protected: bool GetSkyboxFogEnable(); void Enable3dSkyboxFog( void ); - void DrawInternal( view_id_t iSkyBoxViewID = VIEW_3DSKY, bool bInvokePreAndPostRender = true, ITexture *pRenderTarget = NULL ); + void DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostRender, ITexture *pRenderTarget, ITexture *pDepthTarget ); sky3dparams_t * PreRender3dSkyboxWorld( SkyboxVisibility_t nSkyboxVisible ); @@ -1055,7 +1055,15 @@ void CViewRender::DrawViewModels( const CViewSetup &view, bool drawViewmodel ) viewModelSetup.fov = view.fovViewmodel; viewModelSetup.m_flAspectRatio = engine->GetScreenAspectRatio(); - render->Push3DView( viewModelSetup, 0, NULL, GetFrustum() ); + ITexture *pRTColor = NULL; + ITexture *pRTDepth = NULL; + if( view.m_eStereoEye != STEREO_EYE_MONO ) + { + pRTColor = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(view.m_eStereoEye-1), ISourceVirtualReality::RT_Color ); + pRTDepth = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(view.m_eStereoEye-1), ISourceVirtualReality::RT_Depth ); + } + + render->Push3DView( viewModelSetup, 0, pRTColor, GetFrustum(), pRTDepth ); #ifdef PORTAL //the depth range hack doesn't work well enough for the portal mod (and messing with the depth hack values makes some models draw incorrectly) //step up to a full depth clear if we're extremely close to a portal (in a portal environment) @@ -1822,7 +1830,15 @@ void CViewRender::SetupMain3DView( const CViewSetup &view, int &nClearFlags ) } else { - render->Push3DView( view, nClearFlags, NULL, GetFrustum() ); + ITexture *pRTColor = NULL; + ITexture *pRTDepth = NULL; + if( view.m_eStereoEye != STEREO_EYE_MONO ) + { + pRTColor = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(view.m_eStereoEye-1), ISourceVirtualReality::RT_Color ); + pRTDepth = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(view.m_eStereoEye-1), ISourceVirtualReality::RT_Depth ); + } + + render->Push3DView( view, nClearFlags, pRTColor, GetFrustum(), pRTDepth ); } // If we didn't clear the depth here, we'll need to clear it later @@ -2155,6 +2171,12 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT pCopyMaterial->DecrementReferenceCount(); } + // if we're in VR mode we might need to override the render target + if( UseVR() ) + { + saveRenderTarget = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(view.m_eStereoEye - 1), ISourceVirtualReality::RT_Color ); + } + // Draw the 2D graphics render->Push2DView( view, 0, saveRenderTarget, GetFrustum() ); @@ -2192,7 +2214,9 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT vgui::surface()->GetScreenSize( viewWidth, viewHeight ); - viewFramebufferX = view.m_eStereoEye == STEREO_EYE_RIGHT ? viewFramebufferWidth : 0; + viewFramebufferX = 0; + if( view.m_eStereoEye == STEREO_EYE_RIGHT && !saveRenderTarget ) + viewFramebufferX = viewFramebufferWidth; viewFramebufferY = 0; } } @@ -2224,7 +2248,7 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT // let vgui know where to render stuff for the forced-to-framebuffer panels if( UseVR() ) { - vgui::surface()->SetFullscreenViewport( viewFramebufferX, viewFramebufferY, viewFramebufferWidth, viewFramebufferHeight ); + vgui::surface()->SetFullscreenViewportAndRenderTarget( viewFramebufferX, viewFramebufferY, viewFramebufferWidth, viewFramebufferHeight, saveRenderTarget ); } // clear the render target if we need to @@ -4703,7 +4727,7 @@ sky3dparams_t *CSkyboxView::PreRender3dSkyboxWorld( SkyboxVisibility_t nSkyboxVi //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostRender, ITexture *pRenderTarget ) +void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostRender, ITexture *pRenderTarget, ITexture *pDepthTarget ) { unsigned char **areabits = render->GetAreaBits(); unsigned char *savebits; @@ -4736,7 +4760,7 @@ void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostR // cluster with sky. Then we could just connect the areas to do our vis. //m_bOverrideVisOrigin could hose us here, so call direct render->ViewSetupVis( false, 1, &m_pSky3dParams->origin.Get() ); - render->Push3DView( (*this), m_ClearFlags, pRenderTarget, GetFrustum() ); + render->Push3DView( (*this), m_ClearFlags, pRenderTarget, GetFrustum(), pDepthTarget ); // Store off view origin and angles SetupCurrentView( origin, angles, iSkyBoxViewID ); @@ -4832,7 +4856,15 @@ void CSkyboxView::Draw() { VPROF_BUDGET( "CViewRender::Draw3dSkyboxworld", "3D Skybox" ); - DrawInternal(); + ITexture *pRTColor = NULL; + ITexture *pRTDepth = NULL; + if( m_eStereoEye != STEREO_EYE_MONO ) + { + pRTColor = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(m_eStereoEye-1), ISourceVirtualReality::RT_Color ); + pRTDepth = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(m_eStereoEye-1), ISourceVirtualReality::RT_Depth ); + } + + DrawInternal(VIEW_3DSKY, true, pRTColor, pRTDepth ); } @@ -4882,7 +4914,7 @@ void CPortalSkyboxView::Draw() bool bInvokePreAndPostRender = ( g_pPortalRender->ShouldUseStencilsToRenderPortals() == false ); - DrawInternal( iSkyBoxViewID, bInvokePreAndPostRender, m_pRenderTarget ); + DrawInternal( iSkyBoxViewID, bInvokePreAndPostRender, m_pRenderTarget, NULL ); pRenderContext->EnableClipping( bClippingEnabled ); diff --git a/mp/src/game/client/viewrender.h b/mp/src/game/client/viewrender.h index d9901237..723c3222 100644 --- a/mp/src/game/client/viewrender.h +++ b/mp/src/game/client/viewrender.h @@ -474,10 +474,6 @@ private: // This stores the current view CViewSetup m_CurrentView; - // these will both be mono or they will be left/right - StereoEye_t m_eStartEye; - StereoEye_t m_eLastEye; - // VIS Overrides // Set to true to turn off client side vis ( !!!! rendering will be slow since everything will draw ) bool m_bForceNoVis; diff --git a/mp/src/game/protobuf_include.vpc b/mp/src/game/protobuf_include.vpc index c7290fe3..c4fe5022 100644 --- a/mp/src/game/protobuf_include.vpc +++ b/mp/src/game/protobuf_include.vpc @@ -10,6 +10,8 @@ $Project { $Folder "Libraries" { - $Libexternal libprotobuf + $Libexternal libprotobuf [!$VS2012 && !$VS2013] + $Libexternal 2012\libprotobuf [$VS2012] + $Libexternal 2013\libprotobuf [$VS2013] } } diff --git a/mp/src/game/server/ai_activity.cpp b/mp/src/game/server/ai_activity.cpp index 463c8942..a476a9f3 100644 --- a/mp/src/game/server/ai_activity.cpp +++ b/mp/src/game/server/ai_activity.cpp @@ -2153,4 +2153,8 @@ void CAI_BaseNPC::InitDefaultActivitySR(void) ADD_ACTIVITY_TO_SR( ACT_THROWABLE_VM_IDLE ); ADD_ACTIVITY_TO_SR( ACT_THROWABLE_VM_FIRE ); + ADD_ACTIVITY_TO_SR( ACT_SPELL_VM_DRAW ); + ADD_ACTIVITY_TO_SR( ACT_SPELL_VM_IDLE ); + ADD_ACTIVITY_TO_SR( ACT_SPELL_VM_ARM ); + ADD_ACTIVITY_TO_SR( ACT_SPELL_VM_FIRE ); } diff --git a/mp/src/game/server/ai_movesolver.cpp b/mp/src/game/server/ai_movesolver.cpp index 1dc81849..101056a7 100644 --- a/mp/src/game/server/ai_movesolver.cpp +++ b/mp/src/game/server/ai_movesolver.cpp @@ -15,7 +15,7 @@ //----------------------------------------------------------------------------- -inline float round( float f ) +inline float V_round( float f ) { return (float)( (int)( f + 0.5 ) ); } @@ -133,7 +133,7 @@ bool CAI_MoveSolver::Solve( const AI_MoveSuggestion_t *pSuggestions, int nSugges // Convert arc values to solution indices relative to right post. Right is angle down, left is angle up. float halfSpan = current.arc.span * 0.5; - int center = round( ( halfSpan * NUM_SOLUTIONS ) / 360 ); + int center = V_round( ( halfSpan * NUM_SOLUTIONS ) / 360 ); int left = ( current.arc.span * NUM_SOLUTIONS ) / 360; float angRight = current.arc.center - halfSpan; diff --git a/mp/src/game/server/ai_networkmanager.cpp b/mp/src/game/server/ai_networkmanager.cpp index 7f6bea61..21a6f9de 100644 --- a/mp/src/game/server/ai_networkmanager.cpp +++ b/mp/src/game/server/ai_networkmanager.cpp @@ -983,7 +983,7 @@ bool CAI_NetworkManager::IsAIFileCurrent ( const char *szMapName ) Q_strncpy( szLoweredGameDir, pGameDir, sizeof( szLoweredGameDir ) ); Q_strlower( szLoweredGameDir ); - if ( !V_stricmp( szLoweredGameDir, "hl2" ) || !V_stricmp( szLoweredGameDir, "episodic" ) || !V_stricmp( szLoweredGameDir, "ep2" ) || !V_stricmp( szLoweredGameDir, "portal" ) || !V_stricmp( szLoweredGameDir, "lostcoast" ) ) + if ( !V_stricmp( szLoweredGameDir, "hl2" ) || !V_stricmp( szLoweredGameDir, "episodic" ) || !V_stricmp( szLoweredGameDir, "ep2" ) || !V_stricmp( szLoweredGameDir, "portal" ) || !V_stricmp( szLoweredGameDir, "lostcoast" ) || !V_stricmp( szLoweredGameDir, "hl1" ) ) { // we shipped good node graphs for our games return true; diff --git a/mp/src/game/server/baseanimating.cpp b/mp/src/game/server/baseanimating.cpp index 2e1e3a22..34bf6378 100644 --- a/mp/src/game/server/baseanimating.cpp +++ b/mp/src/game/server/baseanimating.cpp @@ -210,6 +210,9 @@ BEGIN_DATADESC( CBaseAnimating ) DEFINE_INPUT( m_fadeMaxDist, FIELD_FLOAT, "fademaxdist" ), DEFINE_KEYFIELD( m_flFadeScale, FIELD_FLOAT, "fadescale" ), + DEFINE_KEYFIELD( m_flModelScale, FIELD_FLOAT, "modelscale" ), + DEFINE_INPUTFUNC( FIELD_VECTOR, "SetModelScale", InputSetModelScale ), + DEFINE_FIELD( m_fBoneCacheFlags, FIELD_SHORT ), END_DATADESC() @@ -441,7 +444,7 @@ void CBaseAnimating::StudioFrameAdvanceInternal( CStudioHdr *pStudioHdr, float f m_flAnimTime.Get(), m_flPrevAnimTime, flInterval, GetCycle() ); */ - m_flGroundSpeed = GetSequenceGroundSpeed( pStudioHdr, GetSequence() ); + m_flGroundSpeed = GetSequenceGroundSpeed( pStudioHdr, GetSequence() ) * GetModelScale(); // Msg("%s : %s : %5.1f\n", GetClassname(), GetSequenceName( GetSequence() ), GetCycle() ); InvalidatePhysicsRecursive( ANIMATION_CHANGED ); @@ -610,6 +613,17 @@ void CBaseAnimating::InputSetLightingOrigin( inputdata_t &inputdata ) SetLightingOrigin( strLightingOrigin ); } +//----------------------------------------------------------------------------- +// Purpose: SetModelScale input handler +//----------------------------------------------------------------------------- +void CBaseAnimating::InputSetModelScale( inputdata_t &inputdata ) +{ + Vector vecScale; + inputdata.value.Vector3D( vecScale ); + + SetModelScale( vecScale.x, vecScale.y ); +} + //========================================================= // SelectWeightedSequence @@ -877,7 +891,7 @@ void CBaseAnimating::ResetSequenceInfo ( ) } CStudioHdr *pStudioHdr = GetModelPtr(); - m_flGroundSpeed = GetSequenceGroundSpeed( pStudioHdr, GetSequence() ); + m_flGroundSpeed = GetSequenceGroundSpeed( pStudioHdr, GetSequence() ) * GetModelScale(); m_bSequenceLoops = ((GetSequenceFlags( pStudioHdr, GetSequence() ) & STUDIO_LOOPING) != 0); // m_flAnimTime = gpGlobals->time; m_flPlaybackRate = 1.0; diff --git a/mp/src/game/server/baseanimating.h b/mp/src/game/server/baseanimating.h index 5f8a019a..75300e8e 100644 --- a/mp/src/game/server/baseanimating.h +++ b/mp/src/game/server/baseanimating.h @@ -338,6 +338,7 @@ private: void StudioFrameAdvanceInternal( CStudioHdr *pStudioHdr, float flInterval ); void InputSetLightingOriginRelative( inputdata_t &inputdata ); void InputSetLightingOrigin( inputdata_t &inputdata ); + void InputSetModelScale( inputdata_t &inputdata ); bool CanSkipAnimation( void ); diff --git a/mp/src/game/server/baseentity.cpp b/mp/src/game/server/baseentity.cpp index edc00977..52316924 100644 --- a/mp/src/game/server/baseentity.cpp +++ b/mp/src/game/server/baseentity.cpp @@ -4524,6 +4524,17 @@ void CBaseEntity::Teleport( const Vector *newPosition, const QAngle *newAngles, teleportList[i].pEntity->CollisionRulesChanged(); } + if ( IsPlayer() ) + { + // Tell the client being teleported + IGameEvent *event = gameeventmanager->CreateEvent( "base_player_teleported" ); + if ( event ) + { + event->SetInt( "entindex", entindex() ); + gameeventmanager->FireEventClientSide( event ); + } + } + Assert( g_TeleportStack[index] == this ); g_TeleportStack.FastRemove( index ); diff --git a/mp/src/game/server/basemultiplayerplayer.cpp b/mp/src/game/server/basemultiplayerplayer.cpp index 031282ac..b6ecd44c 100644 --- a/mp/src/game/server/basemultiplayerplayer.cpp +++ b/mp/src/game/server/basemultiplayerplayer.cpp @@ -132,7 +132,15 @@ bool CBaseMultiplayerPlayer::CanHearAndReadChatFrom( CBasePlayer *pPlayer ) //----------------------------------------------------------------------------- bool CBaseMultiplayerPlayer::ShouldRunRateLimitedCommand( const CCommand &args ) { - const char *pcmd = args[0]; + return ShouldRunRateLimitedCommand( args[0] ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CBaseMultiplayerPlayer::ShouldRunRateLimitedCommand( const char *pszCommand ) +{ + const char *pcmd = pszCommand; int i = m_RateLimitLastCommandTimes.Find( pcmd ); if ( i == m_RateLimitLastCommandTimes.InvalidIndex() ) diff --git a/mp/src/game/server/basemultiplayerplayer.h b/mp/src/game/server/basemultiplayerplayer.h index 5f9b9519..06a0e00d 100644 --- a/mp/src/game/server/basemultiplayerplayer.h +++ b/mp/src/game/server/basemultiplayerplayer.h @@ -89,6 +89,7 @@ public: // Command rate limiting. bool ShouldRunRateLimitedCommand( const CCommand &args ); + bool ShouldRunRateLimitedCommand( const char *pszCommand ); protected: virtual CAI_Expresser *CreateExpresser( void ); diff --git a/mp/src/game/server/baseprojectile.cpp b/mp/src/game/server/baseprojectile.cpp deleted file mode 100644 index 30d92fec..00000000 --- a/mp/src/game/server/baseprojectile.cpp +++ /dev/null @@ -1,136 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//============================================================================= - -#include "cbase.h" -#include "baseprojectile.h" - -BEGIN_DATADESC( CBaseProjectile ) - DEFINE_FIELD( m_flDamage, FIELD_FLOAT ), - DEFINE_FIELD( m_iDamageType, FIELD_INTEGER ), - DEFINE_FIELD( m_flDamageScale, FIELD_FLOAT ), - - DEFINE_FUNCTION( ProjectileTouch ), - DEFINE_THINKFUNC( FlyThink ), -END_DATADESC() - -LINK_ENTITY_TO_CLASS( proj_base, CBaseProjectile ); - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -void CBaseProjectile::Spawn( void ) -{ - Precache(); - - SetModel( STRING( GetModelName() ) ); - - SetSolid( SOLID_BBOX ); - SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_CUSTOM ); - AddFlag( FL_OBJECT ); - - UTIL_SetSize( this, -Vector( 1.0f, 1.0f, 1.0f ), Vector( 1.0f, 1.0f, 1.0f ) ); - - // Setup attributes. - SetGravity( 0.001f ); - m_takedamage = DAMAGE_NO; - - // Setup the touch and think functions. - SetTouch( &CBaseProjectile::ProjectileTouch ); - SetThink( &CBaseProjectile::FlyThink ); - SetNextThink( gpGlobals->curtime ); -} - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -void CBaseProjectile::Precache( void ) -{ - BaseClass::Precache(); - - PrecacheModel( STRING( GetModelName() ) ); -} - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -CBaseProjectile *CBaseProjectile::Create( baseprojectilecreate_t &pCreate ) -{ - CBaseProjectile *pProjectile = static_cast( CBaseEntity::CreateNoSpawn( "proj_base", pCreate.vecOrigin, vec3_angle, pCreate.pOwner ) ); - if ( !pProjectile ) - return NULL; - - pProjectile->SetModelName( pCreate.iszModel ); - pProjectile->SetDamage( pCreate.flDamage ); - pProjectile->SetDamageType( pCreate.iDamageType ); - pProjectile->SetDamageScale( pCreate.flDamageScale ); - pProjectile->SetAbsVelocity( pCreate.vecVelocity ); - - // Setup the initial angles. - QAngle angles; - VectorAngles( -pCreate.vecVelocity, angles ); - pProjectile->SetAbsAngles( angles ); - - // Spawn & Activate - DispatchSpawn( pProjectile ); - pProjectile->Activate(); - - return pProjectile; -} - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -unsigned int CBaseProjectile::PhysicsSolidMaskForEntity( void ) const -{ - return BaseClass::PhysicsSolidMaskForEntity() | CONTENTS_HITBOX; -} - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -void CBaseProjectile::ProjectileTouch( CBaseEntity *pOther ) -{ - // Verify a correct "other." - Assert( pOther ); - if ( !pOther->IsSolid() || pOther->IsSolidFlagSet( FSOLID_VOLUME_CONTENTS ) ) - return; - - // Handle hitting skybox (disappear). - const trace_t *pTrace = &CBaseEntity::GetTouchTrace(); - trace_t *pNewTrace = const_cast( pTrace ); - - if( pTrace->surface.flags & SURF_SKY ) - { - UTIL_Remove( this ); - return; - } - - CTakeDamageInfo info; - info.SetAttacker( GetOwnerEntity() ); - info.SetInflictor( this ); - info.SetDamage( GetDamage() ); - info.SetDamageType( GetDamageType() ); - CalculateMeleeDamageForce( &info, GetAbsVelocity(), GetAbsOrigin(), GetDamageScale() ); - - Vector dir; - AngleVectors( GetAbsAngles(), &dir ); - - pOther->DispatchTraceAttack( info, dir, pNewTrace ); - ApplyMultiDamage(); - - UTIL_Remove( this ); -} - -//----------------------------------------------------------------------------- -// Purpose: Orient the projectile along its velocity -//----------------------------------------------------------------------------- -void CBaseProjectile::FlyThink( void ) -{ - QAngle angles; - VectorAngles( -(GetAbsVelocity()), angles ); - SetAbsAngles( angles ); - SetNextThink( gpGlobals->curtime + 0.1f ); -} diff --git a/mp/src/game/server/baseprojectile.h b/mp/src/game/server/baseprojectile.h deleted file mode 100644 index 51bd04f7..00000000 --- a/mp/src/game/server/baseprojectile.h +++ /dev/null @@ -1,61 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//============================================================================= - -#ifndef BASEPROJECTILE_H -#define BASEPROJECTILE_H -#ifdef _WIN32 -#pragma once -#endif - -// Creation. -struct baseprojectilecreate_t -{ - Vector vecOrigin; - Vector vecVelocity; - CBaseEntity *pOwner; - string_t iszModel; - float flDamage; - int iDamageType; - float flDamageScale; -}; - -//============================================================================= -// -// Generic projectile -// -class CBaseProjectile : public CBaseAnimating -{ - DECLARE_CLASS( CBaseProjectile, CBaseAnimating ); -public: - DECLARE_DATADESC(); - - void Spawn( void ); - void Precache( void ); - - static CBaseProjectile *Create( baseprojectilecreate_t &pCreate ); - - void SetDamage( float flDamage ) { m_flDamage = flDamage; } - void SetDamageScale( float &flScale ) { m_flDamageScale = flScale; } - void SetDamageType( int iType ) { m_iDamageType = iType; } - -private: - // Damage - virtual float GetDamage() { return m_flDamage; } - virtual float GetDamageScale( void ) { return m_flDamageScale; } - virtual int GetDamageType( void ) { return m_iDamageType; } - - unsigned int PhysicsSolidMaskForEntity( void ) const; - - virtual void ProjectileTouch( CBaseEntity *pOther ); - void FlyThink( void ); - -protected: - float m_flDamage; - int m_iDamageType; - float m_flDamageScale; -}; - -#endif // BASEPROJECTILE_H diff --git a/mp/src/game/server/basetempentity.cpp b/mp/src/game/server/basetempentity.cpp index 45bd600a..a238397e 100644 --- a/mp/src/game/server/basetempentity.cpp +++ b/mp/src/game/server/basetempentity.cpp @@ -118,7 +118,7 @@ void CBaseTempEntity::PrecacheTempEnts( void ) void CBaseTempEntity::Create( IRecipientFilter& filter, float delay ) { // temp entities can't be reliable or part of the signon message, use real entities instead - Assert( !filter.IsInitMessage() && !filter.IsInitMessage() ); + Assert( !filter.IsReliable() && !filter.IsInitMessage() ); Assert( delay >= -1 && delay <= 1); // 1 second max delay engine->PlaybackTempEntity( filter, delay, diff --git a/mp/src/game/server/entity_tools_server.cpp b/mp/src/game/server/entity_tools_server.cpp index e1888123..5032ca04 100644 --- a/mp/src/game/server/entity_tools_server.cpp +++ b/mp/src/game/server/entity_tools_server.cpp @@ -409,13 +409,39 @@ void CC_Ent_Keyvalue( const CCommand &args ) return; } - int nID = atoi( args[1] ); - - CBaseEntity *pEnt = g_ServerTools.FindEntityByHammerID( nID ); - if ( !pEnt ) + CBasePlayer *pPlayer = ToBasePlayer( UTIL_GetCommandClient() ); + CBaseEntity *pEnt; + if ( FStrEq( args[1], "" ) || FStrEq( args[1], "!picker" ) ) { - Msg( "Entity ID %d not found.\n", nID ); - return; + if (!pPlayer) + return; + + extern CBaseEntity *FindPickerEntity( CBasePlayer *pPlayer ); + pEnt = FindPickerEntity( pPlayer ); + + if ( !pEnt ) + { + ClientPrint( pPlayer, HUD_PRINTCONSOLE, "No entity in front of player.\n" ); + return; + } + } + else if ( FStrEq( args[1], "!self" ) || FStrEq( args[1], "!caller" ) || FStrEq( args[1], "!activator" ) ) + { + if (!pPlayer) + return; + + pEnt = pPlayer; + } + else + { + int nID = atoi( args[1] ); + + pEnt = g_ServerTools.FindEntityByHammerID( nID ); + if ( !pEnt ) + { + Msg( "Entity ID %d not found.\n", nID ); + return; + } } int nArg = 2; diff --git a/mp/src/game/server/hl1_CBaseHelicopter.h b/mp/src/game/server/hl1_CBaseHelicopter.h index 1e3c1044..01586126 100644 --- a/mp/src/game/server/hl1_CBaseHelicopter.h +++ b/mp/src/game/server/hl1_CBaseHelicopter.h @@ -84,7 +84,7 @@ public: int OnTakeDamage_Alive( const CTakeDamageInfo &info ); - void TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr ); + void TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator ); virtual bool FireGun( void ); diff --git a/mp/src/game/server/hl2/hl2_player.cpp b/mp/src/game/server/hl2/hl2_player.cpp index 1659fe31..e7583f5a 100644 --- a/mp/src/game/server/hl2/hl2_player.cpp +++ b/mp/src/game/server/hl2/hl2_player.cpp @@ -169,7 +169,7 @@ bool Flashlight_UseLegacyVersion( void ) g_bUseLegacyFlashlight = ( !Q_strcmp( modDir, "hl2" ) || !Q_strcmp( modDir, "episodic" ) || - !Q_strcmp( modDir, "lostcoast" )); + !Q_strcmp( modDir, "lostcoast" ) || !Q_strcmp( modDir, "hl1" )); g_bCacheLegacyFlashlightStatus = false; } diff --git a/mp/src/game/server/logicrelay.h b/mp/src/game/server/logicrelay.h index a91a456e..8d082acc 100644 --- a/mp/src/game/server/logicrelay.h +++ b/mp/src/game/server/logicrelay.h @@ -36,6 +36,8 @@ public: // Outputs COutputEvent m_OnTrigger; COutputEvent m_OnSpawn; + + bool IsDisabled( void ){ return m_bDisabled; } private: diff --git a/mp/src/game/server/nav_mesh.cpp b/mp/src/game/server/nav_mesh.cpp index eae35c8d..8a15b39e 100644 --- a/mp/src/game/server/nav_mesh.cpp +++ b/mp/src/game/server/nav_mesh.cpp @@ -630,9 +630,10 @@ void CNavMesh::OnRoundRestart( void ) } // attach prerequisites - CFuncNavPrerequisite *prereq = NULL; - while( ( prereq = (CFuncNavPrerequisite *)gEntList.FindEntityByClassname( prereq, "func_nav_prerequisite" ) ) != NULL ) + for ( int i=0; i( IFuncNavPrerequisiteAutoList::AutoList()[i] ); + Extent prereqExtent; prereqExtent.Init( prereq ); diff --git a/mp/src/game/server/player.cpp b/mp/src/game/server/player.cpp index 9ae85cc0..73aab6d6 100644 --- a/mp/src/game/server/player.cpp +++ b/mp/src/game/server/player.cpp @@ -442,6 +442,7 @@ BEGIN_DATADESC( CBasePlayer ) DEFINE_INPUTFUNC( FIELD_INTEGER, "SetHealth", InputSetHealth ), DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetHUDVisibility", InputSetHUDVisibility ), DEFINE_INPUTFUNC( FIELD_STRING, "SetFogController", InputSetFogController ), + DEFINE_INPUTFUNC( FIELD_STRING, "HandleMapEvent", InputHandleMapEvent ), DEFINE_FIELD( m_nNumCrouches, FIELD_INTEGER ), DEFINE_FIELD( m_bDuckToggled, FIELD_BOOLEAN ), @@ -911,7 +912,7 @@ void CBasePlayer::TraceAttack( const CTakeDamageInfo &inputInfo, const Vector &v // Prevent team damage here so blood doesn't appear if ( info.GetAttacker()->IsPlayer() ) { - if ( !g_pGameRules->FPlayerCanTakeDamage( this, info.GetAttacker() ) ) + if ( !g_pGameRules->FPlayerCanTakeDamage( this, info.GetAttacker(), info ) ) return; } } @@ -1121,7 +1122,7 @@ int CBasePlayer::OnTakeDamage( const CTakeDamageInfo &inputInfo ) // go take the damage first - if ( !g_pGameRules->FPlayerCanTakeDamage( this, info.GetAttacker() ) ) + if ( !g_pGameRules->FPlayerCanTakeDamage( this, info.GetAttacker(), inputInfo ) ) { // Refuse the damage return 0; @@ -3311,7 +3312,8 @@ void CBasePlayer::PhysicsSimulate( void ) } #endif // _DEBUG - if ( int numUsrCmdProcessTicksMax = sv_maxusrcmdprocessticks.GetInt() ) + int numUsrCmdProcessTicksMax = sv_maxusrcmdprocessticks.GetInt(); + if ( gpGlobals->maxClients != 1 && numUsrCmdProcessTicksMax ) // don't apply this filter in SP games { // Grant the client some time buffer to execute user commands m_flMovementTimeForUserCmdProcessingRemaining += TICK_INTERVAL; @@ -8641,6 +8643,14 @@ void CBasePlayer::InputSetHealth( inputdata_t &inputdata ) } } +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBasePlayer::InputHandleMapEvent( inputdata_t &inputdata ) +{ + Internal_HandleMapEvent( inputdata ); +} + //----------------------------------------------------------------------------- // Purpose: Hides or displays the HUD // Input : &inputdata - diff --git a/mp/src/game/server/player.h b/mp/src/game/server/player.h index 8cd1d0fa..ddbd4416 100644 --- a/mp/src/game/server/player.h +++ b/mp/src/game/server/player.h @@ -765,6 +765,7 @@ public: //--------------------------------- void InputSetHealth( inputdata_t &inputdata ); void InputSetHUDVisibility( inputdata_t &inputdata ); + void InputHandleMapEvent( inputdata_t &inputdata ); surfacedata_t *GetSurfaceData( void ) { return m_pSurfaceData; } void SetLadderNormal( Vector vecLadderNormal ) { m_vecLadderNormal = vecLadderNormal; } @@ -903,6 +904,8 @@ protected: void CalcObserverView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov ); void CalcViewModelView( const Vector& eyeOrigin, const QAngle& eyeAngles); + virtual void Internal_HandleMapEvent( inputdata_t &inputdata ){} + // FIXME: Make these private! (tf_player uses them) // Secondary point to derive PVS from when zoomed in with binoculars/sniper rifle. The PVS is diff --git a/mp/src/game/server/player_lagcompensation.cpp b/mp/src/game/server/player_lagcompensation.cpp index 0fafb2a7..08503652 100644 --- a/mp/src/game/server/player_lagcompensation.cpp +++ b/mp/src/game/server/player_lagcompensation.cpp @@ -770,10 +770,12 @@ void CLagCompensationManager::FinishLagCompensation( CBasePlayer *player ) // Restore it pPlayer->SetSize( restore->m_vecMinsPreScaled, restore->m_vecMaxsPreScaled ); } +#ifdef STAGING_ONLY else { Warning( "Should we really not restore the size?\n" ); } +#endif } if ( restore->m_fFlags & LC_ANGLES_CHANGED ) diff --git a/mp/src/game/server/server_base.vpc b/mp/src/game/server/server_base.vpc index 6445e07d..f1c3c835 100644 --- a/mp/src/game/server/server_base.vpc +++ b/mp/src/game/server/server_base.vpc @@ -245,6 +245,8 @@ $Project $File "$SRCDIR\game\shared\baseparticleentity.h" $File "$SRCDIR\game\shared\baseplayer_shared.cpp" $File "$SRCDIR\game\shared\baseplayer_shared.h" + $File "$SRCDIR\game\shared\baseprojectile.cpp" + $File "$SRCDIR\game\shared\baseprojectile.h" $File "BasePropDoor.h" $File "basetoggle.h" $File "baseviewmodel.cpp" diff --git a/mp/src/game/server/team_control_point_master.cpp b/mp/src/game/server/team_control_point_master.cpp index f60939a7..8ad9796d 100644 --- a/mp/src/game/server/team_control_point_master.cpp +++ b/mp/src/game/server/team_control_point_master.cpp @@ -841,16 +841,6 @@ void CTeamControlPointMaster::InputRoundSpawn( inputdata_t &input ) FindControlPointRounds(); SetBaseControlPoints(); - - // init the ClientAreas - int index = 0; - - for ( int i=0; i( ITriggerAreaCaptureAutoList::AutoList()[i] ); - pArea->SetAreaIndex( index ); - index++; - } ObjectiveResource()->ResetControlPoints(); } diff --git a/mp/src/game/server/team_train_watcher.cpp b/mp/src/game/server/team_train_watcher.cpp index dba231af..b8ef36c3 100644 --- a/mp/src/game/server/team_train_watcher.cpp +++ b/mp/src/game/server/team_train_watcher.cpp @@ -72,6 +72,7 @@ BEGIN_DATADESC( CTeamTrainWatcher ) DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), DEFINE_INPUTFUNC( FIELD_FLOAT, "SetSpeedForwardModifier", InputSetSpeedForwardModifier ), DEFINE_INPUTFUNC( FIELD_INTEGER, "SetTrainRecedeTime", InputSetTrainRecedeTime ), + DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetTrainCanRecede", InputSetTrainCanRecede ), // Outputs DEFINE_OUTPUT( m_OnTrainStartRecede, "OnTrainStartRecede" ), @@ -141,6 +142,9 @@ END_SEND_TABLE() LINK_ENTITY_TO_CLASS( team_train_watcher, CTeamTrainWatcher ); + +IMPLEMENT_AUTO_LIST( ITFTeamTrainWatcher ); + /* LINK_ENTITY_TO_CLASS( team_train_watcher_master, CTeamTrainWatcherMaster ); PRECACHE_REGISTER( team_train_watcher_master ); @@ -710,6 +714,11 @@ void CTeamTrainWatcher::InputSetTrainRecedeTime( inputdata_t &inputdata ) } } +void CTeamTrainWatcher::InputSetTrainCanRecede( inputdata_t &inputdata ) +{ + m_bTrainCanRecede = inputdata.value.Bool(); +} + void CTeamTrainWatcher::InputOnStartOvertime( inputdata_t &inputdata ) { // recalculate the recede time diff --git a/mp/src/game/server/team_train_watcher.h b/mp/src/game/server/team_train_watcher.h index 0bb9b2a6..22b82c6f 100644 --- a/mp/src/game/server/team_train_watcher.h +++ b/mp/src/game/server/team_train_watcher.h @@ -34,7 +34,9 @@ class CTeamControlPoint; // #define TWMASTER_THINK "CTeamTrainWatcherMasterThink" -class CTeamTrainWatcher : public CBaseEntity, public CGameEventListener +DECLARE_AUTO_LIST( ITFTeamTrainWatcher ); + +class CTeamTrainWatcher : public CBaseEntity, public CGameEventListener, public ITFTeamTrainWatcher { DECLARE_CLASS( CTeamTrainWatcher, CBaseEntity ); public: @@ -55,6 +57,7 @@ public: void InputOnStartOvertime( inputdata_t &inputdata ); void InputSetSpeedForwardModifier( inputdata_t &inputdata ); void InputSetTrainRecedeTime( inputdata_t &inputdata ); + void InputSetTrainCanRecede( inputdata_t &inputdata ); // ========================================================== // given a start node and a list of goal nodes diff --git a/mp/src/game/server/trains.cpp b/mp/src/game/server/trains.cpp index 639523b9..bf01ae6f 100644 --- a/mp/src/game/server/trains.cpp +++ b/mp/src/game/server/trains.cpp @@ -1646,7 +1646,7 @@ static CBaseEntity *FindPhysicsBlockerForHierarchy( CBaseEntity *pParentEntity ) { IPhysicsObject *pOther = pSnapshot->GetObject(1); CBaseEntity *pOtherEntity = static_cast(pOther->GetGameData()); - if ( pOtherEntity->GetMoveType() == MOVETYPE_VPHYSICS ) + if ( pOtherEntity && pOtherEntity->GetMoveType() == MOVETYPE_VPHYSICS ) { Vector normal; pSnapshot->GetSurfaceNormal(normal); diff --git a/mp/src/game/server/trigger_area_capture.cpp b/mp/src/game/server/trigger_area_capture.cpp index 177e7701..2839200b 100644 --- a/mp/src/game/server/trigger_area_capture.cpp +++ b/mp/src/game/server/trigger_area_capture.cpp @@ -43,7 +43,6 @@ BEGIN_DATADESC(CTriggerAreaCapture) // DEFINE_FIELD( m_TeamData, CUtlVector < perteamdata_t > ), // DEFINE_FIELD( m_Blockers, CUtlVector < blockers_t > ), // DEFINE_FIELD( m_bActive, FIELD_BOOLEAN ), -// DEFINE_FIELD( m_iAreaIndex, FIELD_INTEGER ), // DEFINE_FIELD( m_hPoint, CHandle < CTeamControlPoint > ), // DEFINE_FIELD( m_bRequiresObject, FIELD_BOOLEAN ), // DEFINE_FIELD( m_iCapAttemptNumber, FIELD_INTEGER ), @@ -96,8 +95,6 @@ void CTriggerAreaCapture::Spawn( void ) Precache(); - m_iAreaIndex = -1; - SetTouch ( &CTriggerAreaCaptureShim::Touch ); SetThink( &CTriggerAreaCapture::CaptureThink ); SetNextThink( gpGlobals->curtime + AREA_THINK_TIME ); @@ -164,14 +161,6 @@ void CTriggerAreaCapture::Precache( void ) { } -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -void CTriggerAreaCapture::SetAreaIndex( int index ) -{ - m_iAreaIndex = index; -} - //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -231,7 +220,7 @@ void CTriggerAreaCapture::StartTouch(CBaseEntity *pOther) //----------------------------------------------------------------------------- void CTriggerAreaCapture::EndTouch(CBaseEntity *pOther) { - if ( PassesTriggerFilters(pOther) && m_hPoint ) + if ( IsTouching( pOther ) && m_hPoint ) { IGameEvent *event = gameeventmanager->CreateEvent( "controlpoint_endtouch" ); if ( event ) @@ -274,8 +263,6 @@ void CTriggerAreaCapture::AreaTouch( CBaseEntity *pOther ) if ( !TeamplayGameRules()->PointsMayBeCaptured() ) return; - Assert( m_iAreaIndex != -1 ); - // dont touch for non-alive or non-players if( !pOther->IsPlayer() || !pOther->IsAlive() ) return; @@ -771,6 +758,8 @@ void CTriggerAreaCapture::StartCapture( int team, int capmode ) m_nCapturingTeam = team; + OnStartCapture( m_nCapturingTeam ); + UpdateNumPlayers(); if ( CaptureModeScalesWithPlayers() ) diff --git a/mp/src/game/server/trigger_area_capture.h b/mp/src/game/server/trigger_area_capture.h index 2d392755..90e0ed0a 100644 --- a/mp/src/game/server/trigger_area_capture.h +++ b/mp/src/game/server/trigger_area_capture.h @@ -55,13 +55,13 @@ public: // A team has finished capturing the zone. virtual void OnEndCapture( int iTeam ) { return; } + virtual void OnStartCapture( int iTeam ) { return; } public: virtual void Spawn( void ); virtual void Precache( void ); virtual bool KeyValue( const char *szKeyName, const char *szValue ); - void SetAreaIndex( int index ); bool IsActive( void ); bool CheckIfDeathCausesBlock( CBaseMultiplayerPlayer *pVictim, CBaseMultiplayerPlayer *pKiller ); @@ -173,8 +173,6 @@ private: COutputInt m_OnNumCappersChanged; COutputInt m_OnNumCappersChanged2; - int m_iAreaIndex; //index of this area among all other areas - CHandle m_hPoint; //the capture point that we are linked to! bool m_bRequiresObject; diff --git a/mp/src/game/server/triggers.cpp b/mp/src/game/server/triggers.cpp index 8835ab26..295e826a 100644 --- a/mp/src/game/server/triggers.cpp +++ b/mp/src/game/server/triggers.cpp @@ -392,30 +392,37 @@ bool CBaseTrigger::PassesTriggerFilters(CBaseEntity *pOther) bool bOtherIsPlayer = pOther->IsPlayer(); - if ( HasSpawnFlags(SF_TRIGGER_ONLY_CLIENTS_IN_VEHICLES) && bOtherIsPlayer ) + if ( bOtherIsPlayer ) { - if ( !((CBasePlayer*)pOther)->IsInAVehicle() ) + CBasePlayer *pPlayer = (CBasePlayer*)pOther; + if ( !pPlayer->IsAlive() ) return false; - // Make sure we're also not exiting the vehicle at the moment - IServerVehicle *pVehicleServer = ((CBasePlayer*)pOther)->GetVehicle(); - if ( pVehicleServer == NULL ) - return false; - - if ( pVehicleServer->IsPassengerExiting() ) - return false; - } + if ( HasSpawnFlags(SF_TRIGGER_ONLY_CLIENTS_IN_VEHICLES) ) + { + if ( !pPlayer->IsInAVehicle() ) + return false; - if ( HasSpawnFlags(SF_TRIGGER_ONLY_CLIENTS_OUT_OF_VEHICLES) && bOtherIsPlayer ) - { - if ( ((CBasePlayer*)pOther)->IsInAVehicle() ) - return false; - } + // Make sure we're also not exiting the vehicle at the moment + IServerVehicle *pVehicleServer = pPlayer->GetVehicle(); + if ( pVehicleServer == NULL ) + return false; - if ( HasSpawnFlags( SF_TRIGGER_DISALLOW_BOTS ) && bOtherIsPlayer ) - { - if ( ((CBasePlayer*)pOther)->IsFakeClient() ) - return false; + if ( pVehicleServer->IsPassengerExiting() ) + return false; + } + + if ( HasSpawnFlags(SF_TRIGGER_ONLY_CLIENTS_OUT_OF_VEHICLES) ) + { + if ( pPlayer->IsInAVehicle() ) + return false; + } + + if ( HasSpawnFlags( SF_TRIGGER_DISALLOW_BOTS ) ) + { + if ( pPlayer->IsFakeClient() ) + return false; + } } CBaseFilter *pFilter = m_hFilter.Get(); @@ -503,6 +510,14 @@ void CBaseTrigger::EndTouch(CBaseEntity *pOther) { m_hTouchingEntities.Remove( i ); } + else if ( hOther->IsPlayer() && !hOther->IsAlive() ) + { +#ifdef STAGING_ONLY + AssertMsg( 0, CFmtStr( "Dead player [%s] is still touching this trigger at [%f %f %f]", hOther->GetEntityName().ToCStr(), XYZ( hOther->GetAbsOrigin() ) ) ); + Warning( "Dead player [%s] is still touching this trigger at [%f %f %f]", hOther->GetEntityName().ToCStr(), XYZ( hOther->GetAbsOrigin() ) ); +#endif + m_hTouchingEntities.Remove( i ); + } else { bFoundOtherTouchee = true; diff --git a/mp/src/game/server/util.cpp b/mp/src/game/server/util.cpp index b273520a..aba6f327 100644 --- a/mp/src/game/server/util.cpp +++ b/mp/src/game/server/util.cpp @@ -902,7 +902,15 @@ void UTIL_ScreenShakeObject( CBaseEntity *pEnt, const Vector ¢er, float ampl continue; } - localAmplitude = ComputeShakeAmplitude( center, pPlayer->WorldSpaceCenter(), amplitude, radius ); + if ( radius > 0 ) + { + localAmplitude = ComputeShakeAmplitude( center, pPlayer->WorldSpaceCenter(), amplitude, radius ); + } + else + { + // If using a 0 radius, apply to everyone with no falloff + localAmplitude = amplitude; + } // This happens if the player is outside the radius, // in which case we should ignore all commands diff --git a/mp/src/game/server/vote_controller.cpp b/mp/src/game/server/vote_controller.cpp index d052e0f9..316974ad 100644 --- a/mp/src/game/server/vote_controller.cpp +++ b/mp/src/game/server/vote_controller.cpp @@ -616,11 +616,7 @@ void CVoteController::VoteControllerThink( void ) } else { - // Don't track failed dedicated server votes - if ( m_iEntityHoldingVote != DEDICATED_SERVER ) - { - m_potentialIssues[m_iActiveIssueIndex]->OnVoteFailed(); - } + m_potentialIssues[m_iActiveIssueIndex]->OnVoteFailed( m_iEntityHoldingVote ); m_resetVoteTimer.Start( 5.0 ); } } @@ -895,34 +891,38 @@ const char *CBaseIssue::GetVotePassedString( void ) //----------------------------------------------------------------------------- // Purpose: Store failures to prevent vote spam //----------------------------------------------------------------------------- -void CBaseIssue::OnVoteFailed( void ) +void CBaseIssue::OnVoteFailed( int iEntityHoldingVote ) { - // Check for an existing match - for ( int index = 0; index < m_FailedVotes.Count(); index++ ) + // Don't track failed dedicated server votes + if ( BRecordVoteFailureEventForEntity( iEntityHoldingVote ) ) { - FailedVote *pFailedVote = m_FailedVotes[index]; - if ( Q_strcmp( pFailedVote->szFailedVoteParameter, GetDetailsString() ) == 0 ) + // Check for an existing match + for ( int index = 0; index < m_FailedVotes.Count(); index++ ) { - int nTime = sv_vote_failure_timer.GetInt(); + FailedVote *pFailedVote = m_FailedVotes[index]; + if ( Q_strcmp( pFailedVote->szFailedVoteParameter, GetDetailsString() ) == 0 ) + { + int nTime = sv_vote_failure_timer.GetInt(); #ifdef TF_DLL - if ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() ) - { - nTime = sv_vote_failure_timer_mvm.GetInt(); - } + if ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() ) + { + nTime = sv_vote_failure_timer_mvm.GetInt(); + } #endif // TF_DLL - pFailedVote->flLockoutTime = gpGlobals->curtime + nTime; + pFailedVote->flLockoutTime = gpGlobals->curtime + nTime; - return; + return; + } } - } - // Need to create a new one - FailedVote *pNewFailedVote = new FailedVote; - int iIndex = m_FailedVotes.AddToTail( pNewFailedVote ); - Q_strcpy( m_FailedVotes[iIndex]->szFailedVoteParameter, GetDetailsString() ); - m_FailedVotes[iIndex]->flLockoutTime = gpGlobals->curtime + sv_vote_failure_timer.GetFloat(); + // Need to create a new one + FailedVote *pNewFailedVote = new FailedVote; + int iIndex = m_FailedVotes.AddToTail( pNewFailedVote ); + Q_strcpy( m_FailedVotes[iIndex]->szFailedVoteParameter, GetDetailsString() ); + m_FailedVotes[iIndex]->flLockoutTime = gpGlobals->curtime + sv_vote_failure_timer.GetFloat(); + } } //----------------------------------------------------------------------------- @@ -939,7 +939,7 @@ bool CBaseIssue::CanTeamCallVote( int iTeam ) const bool CBaseIssue::CanCallVote( int iEntIndex, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime ) { // Automated server vote - don't bother testing against it - if ( iEntIndex == DEDICATED_SERVER ) + if ( !BRecordVoteFailureEventForEntity( iEntIndex ) ) return true; // Bogus player diff --git a/mp/src/game/server/vote_controller.h b/mp/src/game/server/vote_controller.h index 1bdd0281..0376d6a6 100644 --- a/mp/src/game/server/vote_controller.h +++ b/mp/src/game/server/vote_controller.h @@ -25,7 +25,7 @@ public: const char *GetTypeString( void ); // Connection between console command and specific type of issue virtual const char *GetDetailsString(); virtual void SetIssueDetails( const char *pszDetails ); // We need to know the details part of the con command for later - virtual void OnVoteFailed( void ); // The moment the vote fails, also has some time for feedback before the window goes away + virtual void OnVoteFailed( int iEntityHoldingVote ); // The moment the vote fails, also has some time for feedback before the window goes away virtual void OnVoteStarted( void ) {} // Called as soon as the vote starts virtual bool IsEnabled( void ) { return false; } // Query the issue to see if it's enabled virtual bool CanTeamCallVote( int iTeam ) const; // Can someone on the given team call this vote? @@ -40,6 +40,7 @@ public: virtual bool IsYesNoVote( void ); virtual void SetYesNoVoteCount( int iNumYesVotes, int iNumNoVotes, int iNumPotentialVotes ); virtual bool GetVoteOptions( CUtlVector &vecNames ); // We use this to generate options for voting + virtual bool BRecordVoteFailureEventForEntity( int iVoteCallingEntityIndex ) const { return iVoteCallingEntityIndex != DEDICATED_SERVER; } protected: static void ListStandardNoArgCommand( CBasePlayer *forWhom, const char *issueString ); // List a Yes vote command diff --git a/mp/src/game/shared/activitylist.cpp b/mp/src/game/shared/activitylist.cpp index 94bcff15..2b421252 100644 --- a/mp/src/game/shared/activitylist.cpp +++ b/mp/src/game/shared/activitylist.cpp @@ -2270,6 +2270,11 @@ void ActivityList_RegisterSharedActivities( void ) REGISTER_SHARED_ACTIVITY( ACT_THROWABLE_VM_IDLE ); REGISTER_SHARED_ACTIVITY( ACT_THROWABLE_VM_FIRE ); + REGISTER_SHARED_ACTIVITY( ACT_SPELL_VM_DRAW ); + REGISTER_SHARED_ACTIVITY( ACT_SPELL_VM_IDLE ); + REGISTER_SHARED_ACTIVITY( ACT_SPELL_VM_ARM ); + REGISTER_SHARED_ACTIVITY( ACT_SPELL_VM_FIRE ); + AssertMsg( g_HighestActivity == LAST_SHARED_ACTIVITY - 1, "Not all activities from ai_activity.h registered in activitylist.cpp" ); } diff --git a/mp/src/game/shared/ai_activity.h b/mp/src/game/shared/ai_activity.h index 6c5f05c8..fbd10c39 100644 --- a/mp/src/game/shared/ai_activity.h +++ b/mp/src/game/shared/ai_activity.h @@ -2097,11 +2097,16 @@ typedef enum // Throwable Animations ACT_MP_THROW, - ACT_THROWABLE_VM_DRAW, ACT_THROWABLE_VM_IDLE, ACT_THROWABLE_VM_FIRE, + // Spell Animations + ACT_SPELL_VM_DRAW, + ACT_SPELL_VM_IDLE, + ACT_SPELL_VM_ARM, + ACT_SPELL_VM_FIRE, + // this is the end of the global activities, private per-monster activities start here. LAST_SHARED_ACTIVITY, } Activity; diff --git a/mp/src/game/shared/basecombatweapon_shared.h b/mp/src/game/shared/basecombatweapon_shared.h index d773c0c5..701403a0 100644 --- a/mp/src/game/shared/basecombatweapon_shared.h +++ b/mp/src/game/shared/basecombatweapon_shared.h @@ -248,7 +248,7 @@ public: // but they are out of ammo. The default implementation // either reloads, switches weapons, or plays an empty sound. - virtual bool ShouldBlockPrimaryFire() { return !AutoFiresFullClip(); } + virtual bool ShouldBlockPrimaryFire() { return false; } #ifdef CLIENT_DLL virtual void CreateMove( float flInputSampleTime, CUserCmd *pCmd, const QAngle &vecOldViewAngles ) {} diff --git a/mp/src/game/shared/basegrenade_shared.h b/mp/src/game/shared/basegrenade_shared.h index 79e34801..38bb684d 100644 --- a/mp/src/game/shared/basegrenade_shared.h +++ b/mp/src/game/shared/basegrenade_shared.h @@ -11,6 +11,8 @@ #pragma once #endif +#include "baseprojectile.h" + #if defined( CLIENT_DLL ) #define CBaseGrenade C_BaseGrenade @@ -29,12 +31,12 @@ class CTakeDamageInfo; #if !defined( CLIENT_DLL ) -class CBaseGrenade : public CBaseAnimating, public CDefaultPlayerPickupVPhysics +class CBaseGrenade : public CBaseProjectile, public CDefaultPlayerPickupVPhysics #else -class CBaseGrenade : public CBaseAnimating +class CBaseGrenade : public CBaseProjectile #endif { - DECLARE_CLASS( CBaseGrenade, CBaseAnimating ); + DECLARE_CLASS( CBaseGrenade, CBaseProjectile ); public: CBaseGrenade(void); diff --git a/mp/src/game/shared/baseplayer_shared.cpp b/mp/src/game/shared/baseplayer_shared.cpp index f56e72e4..cba09eb7 100644 --- a/mp/src/game/shared/baseplayer_shared.cpp +++ b/mp/src/game/shared/baseplayer_shared.cpp @@ -22,7 +22,7 @@ #include "view.h" #include "client_virtualreality.h" #define CRecipientFilter C_RecipientFilter - #include "headtrack/isourcevirtualreality.h" + #include "sourcevr/isourcevirtualreality.h" #else diff --git a/mp/src/game/shared/baseprojectile.cpp b/mp/src/game/shared/baseprojectile.cpp new file mode 100644 index 00000000..c695db93 --- /dev/null +++ b/mp/src/game/shared/baseprojectile.cpp @@ -0,0 +1,26 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" +#include "baseprojectile.h" + + +IMPLEMENT_NETWORKCLASS_ALIASED( BaseProjectile, DT_BaseProjectile ) + +BEGIN_NETWORK_TABLE( CBaseProjectile, DT_BaseProjectile ) +END_NETWORK_TABLE() + + +//----------------------------------------------------------------------------- +// Purpose: Constructor. +//----------------------------------------------------------------------------- +CBaseProjectile::CBaseProjectile() +{ +#ifdef GAME_DLL + m_iDestroyableHitCount = 0; +#endif +} diff --git a/mp/src/game/shared/baseprojectile.h b/mp/src/game/shared/baseprojectile.h new file mode 100644 index 00000000..2ff00fc5 --- /dev/null +++ b/mp/src/game/shared/baseprojectile.h @@ -0,0 +1,53 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef BASEPROJECTILE_H +#define BASEPROJECTILE_H +#ifdef _WIN32 +#pragma once +#endif + +#include "cbase.h" + +#ifdef GAME_DLL +#include "baseanimating.h" +#else +#include "c_baseanimating.h" +#endif + +#ifdef CLIENT_DLL +#define CBaseProjectile C_BaseProjectile +#endif // CLIENT_DLL + +//============================================================================= +// +// Base Projectile. +// +//============================================================================= +class CBaseProjectile : public CBaseAnimating +{ +public: + DECLARE_CLASS( CBaseProjectile, CBaseAnimating ); + DECLARE_NETWORKCLASS(); + + CBaseProjectile(); + +#ifdef GAME_DLL + virtual int GetDestroyableHitCount( void ) const { return m_iDestroyableHitCount; } + void IncrementDestroyableHitCount( void ) { ++m_iDestroyableHitCount; } +#endif // GAME_DLL + + virtual bool IsDestroyable( void ) { return false; } + virtual void Destroy( bool bBlinkOut = true, bool bBreakRocket = false ) {} + +protected: +#ifdef GAME_DLL + int m_iDestroyableHitCount; +#endif // GAME_DLL +}; + +#endif // BASEPROJECTILE_H diff --git a/mp/src/game/shared/baseviewmodel_shared.cpp b/mp/src/game/shared/baseviewmodel_shared.cpp index 99c4bfce..20538e8c 100644 --- a/mp/src/game/shared/baseviewmodel_shared.cpp +++ b/mp/src/game/shared/baseviewmodel_shared.cpp @@ -12,7 +12,7 @@ #include "iprediction.h" #include "prediction.h" #include "client_virtualreality.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #else #include "vguiscreen.h" #endif diff --git a/mp/src/game/shared/effect_color_tables.h b/mp/src/game/shared/effect_color_tables.h index 54f6384f..322d0e08 100644 --- a/mp/src/game/shared/effect_color_tables.h +++ b/mp/src/game/shared/effect_color_tables.h @@ -44,6 +44,7 @@ static colorentry_t bloodcolors[] = { BLOOD_COLOR_RED, 72, 0, 0 }, { BLOOD_COLOR_YELLOW, 195, 195, 0 }, { BLOOD_COLOR_MECH, 20, 20, 20 }, + { BLOOD_COLOR_GREEN, 195, 195, 0 }, }; #endif // EFFECT_COLOR_TABLES_H diff --git a/mp/src/game/shared/gamemovement.cpp b/mp/src/game/shared/gamemovement.cpp index 4f1132b1..8de6fc32 100644 --- a/mp/src/game/shared/gamemovement.cpp +++ b/mp/src/game/shared/gamemovement.cpp @@ -55,6 +55,12 @@ ConVar player_limit_jump_speed( "player_limit_jump_speed", "1", FCVAR_REPLICATED // duck controls. Its value is meaningless anytime we don't have the options window open. ConVar option_duck_method("option_duck_method", "1", FCVAR_REPLICATED|FCVAR_ARCHIVE );// 0 = HOLD to duck, 1 = Duck is a toggle +#ifdef STAGING_ONLY +#ifdef CLIENT_DLL +ConVar debug_latch_reset_onduck( "debug_latch_reset_onduck", "1", FCVAR_CHEAT ); +#endif +#endif + // [MD] I'll remove this eventually. For now, I want the ability to A/B the optimizations. bool g_bMovementOptimizations = true; @@ -4108,8 +4114,15 @@ void CGameMovement::FinishUnDuck( void ) mv->SetAbsOrigin( newOrigin ); #ifdef CLIENT_DLL +#ifdef STAGING_ONLY + if ( debug_latch_reset_onduck.GetBool() ) + { + player->ResetLatched(); + } +#else player->ResetLatched(); #endif +#endif // CLIENT_DLL // Recategorize position since ducking can change origin CategorizePosition(); @@ -4207,8 +4220,15 @@ void CGameMovement::FinishDuck( void ) mv->SetAbsOrigin( out ); #ifdef CLIENT_DLL +#ifdef STAGING_ONLY + if ( debug_latch_reset_onduck.GetBool() ) + { + player->ResetLatched(); + } +#else player->ResetLatched(); #endif +#endif // CLIENT_DLL } // See if we are stuck? diff --git a/mp/src/game/shared/gamerules.h b/mp/src/game/shared/gamerules.h index 6d99f64f..4b2f5124 100644 --- a/mp/src/game/shared/gamerules.h +++ b/mp/src/game/shared/gamerules.h @@ -271,7 +271,7 @@ public: // Client damage rules virtual float FlPlayerFallDamage( CBasePlayer *pPlayer ) = 0;// this client just hit the ground after a fall. How much damage? - virtual bool FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ) {return TRUE;};// can this player take damage from this attacker? + virtual bool FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker, const CTakeDamageInfo &info ) {return TRUE;};// can this player take damage from this attacker? virtual bool ShouldAutoAim( CBasePlayer *pPlayer, edict_t *target ) { return TRUE; } virtual float GetAutoAimScale( CBasePlayer *pPlayer ) { return 1.0f; } virtual int GetAutoAimMode() { return AUTOAIM_ON; } diff --git a/mp/src/game/shared/movevars_shared.cpp b/mp/src/game/shared/movevars_shared.cpp index 3ef79945..b5b94c72 100644 --- a/mp/src/game/shared/movevars_shared.cpp +++ b/mp/src/game/shared/movevars_shared.cpp @@ -36,7 +36,7 @@ float GetCurrentGravity( void ) ConVar sv_gravity ( "sv_gravity", DEFAULT_GRAVITY_STRING, FCVAR_NOTIFY | FCVAR_REPLICATED, "World gravity." ); -#if defined( DOD_DLL ) || defined( CSTRIKE_DLL ) +#if defined( DOD_DLL ) || defined( CSTRIKE_DLL ) || defined( HL1MP_DLL ) ConVar sv_stopspeed ( "sv_stopspeed","100", FCVAR_NOTIFY | FCVAR_REPLICATED, "Minimum stopping speed when on ground." ); #else ConVar sv_stopspeed ( "sv_stopspeed","100", FCVAR_NOTIFY | FCVAR_REPLICATED | FCVAR_DEVELOPMENTONLY, "Minimum stopping speed when on ground." ); @@ -48,7 +48,7 @@ ConVar sv_specaccelerate( "sv_specaccelerate", "5", FCVAR_NOTIFY | FCVAR_ARCHIVE ConVar sv_specspeed ( "sv_specspeed", "3", FCVAR_ARCHIVE | FCVAR_NOTIFY | FCVAR_REPLICATED); ConVar sv_specnoclip ( "sv_specnoclip", "1", FCVAR_ARCHIVE | FCVAR_NOTIFY | FCVAR_REPLICATED); -#if defined( CSTRIKE_DLL ) +#if defined( CSTRIKE_DLL ) || defined( HL1MP_DLL ) ConVar sv_maxspeed ( "sv_maxspeed", "320", FCVAR_NOTIFY | FCVAR_REPLICATED); #else ConVar sv_maxspeed ( "sv_maxspeed", "320", FCVAR_NOTIFY | FCVAR_REPLICATED | FCVAR_DEVELOPMENTONLY); @@ -58,7 +58,7 @@ ConVar sv_maxspeed ( "sv_maxspeed", "320", FCVAR_NOTIFY | FCVAR_REPLICATED | FC ConVar sv_accelerate ( "sv_accelerate", "7", FCVAR_NOTIFY | FCVAR_REPLICATED); #else -#if defined( CSTRIKE_DLL ) +#if defined( CSTRIKE_DLL ) || defined( HL1MP_DLL ) ConVar sv_accelerate ( "sv_accelerate", "10", FCVAR_NOTIFY | FCVAR_REPLICATED); #else ConVar sv_accelerate ( "sv_accelerate", "10", FCVAR_NOTIFY | FCVAR_REPLICATED | FCVAR_DEVELOPMENTONLY); @@ -66,7 +66,7 @@ ConVar sv_maxspeed ( "sv_maxspeed", "320", FCVAR_NOTIFY | FCVAR_REPLICATED | FC #endif//_XBOX -#if defined( CSTRIKE_DLL ) +#if defined( CSTRIKE_DLL ) || defined( HL1MP_DLL ) ConVar sv_airaccelerate( "sv_airaccelerate", "10", FCVAR_NOTIFY | FCVAR_REPLICATED); ConVar sv_wateraccelerate( "sv_wateraccelerate", "10", FCVAR_NOTIFY | FCVAR_REPLICATED); ConVar sv_waterfriction( "sv_waterfriction", "1", FCVAR_NOTIFY | FCVAR_REPLICATED); @@ -82,13 +82,13 @@ ConVar sv_rollspeed ( "sv_rollspeed", "200", FCVAR_NOTIFY | FCVAR_REPLICATED | F ConVar sv_rollangle ( "sv_rollangle", "0", FCVAR_NOTIFY | FCVAR_REPLICATED | FCVAR_DEVELOPMENTONLY, "Max view roll angle"); #endif // CSTRIKE_DLL -#if defined( DOD_DLL ) || defined( CSTRIKE_DLL ) +#if defined( DOD_DLL ) || defined( CSTRIKE_DLL ) || defined( HL1MP_DLL ) ConVar sv_friction ( "sv_friction","4", FCVAR_NOTIFY | FCVAR_REPLICATED, "World friction." ); #else ConVar sv_friction ( "sv_friction","4", FCVAR_NOTIFY | FCVAR_REPLICATED | FCVAR_DEVELOPMENTONLY, "World friction." ); #endif // DOD_DLL || CSTRIKE_DLL -#if defined( CSTRIKE_DLL ) +#if defined( CSTRIKE_DLL ) || defined( HL1MP_DLL ) ConVar sv_bounce ( "sv_bounce","0", FCVAR_NOTIFY | FCVAR_REPLICATED, "Bounce multiplier for when physically simulated objects collide with other objects." ); ConVar sv_maxvelocity ( "sv_maxvelocity","3500", FCVAR_REPLICATED, "Maximum speed any ballistically moving object is allowed to attain per axis." ); ConVar sv_stepsize ( "sv_stepsize","18", FCVAR_NOTIFY | FCVAR_REPLICATED ); diff --git a/mp/src/game/shared/mp_shareddefs.cpp b/mp/src/game/shared/mp_shareddefs.cpp index 561ba6fb..b555a88f 100644 --- a/mp/src/game/shared/mp_shareddefs.cpp +++ b/mp/src/game/shared/mp_shareddefs.cpp @@ -103,7 +103,7 @@ const char *g_pszMPConcepts[] = "TLK_TAUNT_REPLAY", // MP_CONCEPT_TAUNT_REPLAY "TLK_TAUNT_LAUGH", // MP_CONCEPT_TAUNT_LAUGH "TLK_TAUNT_HEROIC_POSE", // MP_CONCEPT_TAUNT_HEROIC_POSE - "TLK_HIGHFIVE_READY", // MP_CONCEPT_HIGHFIVE_READY + "TLK_PARTNER_TAUNT_READY", // MP_CONCEPT_PARTNER_TAUNT_READY "TLK_PLAYER_HOLDTAUNT", // MP_CONCEPT_HOLDTAUNT "TLK_TAUNT_PYRO_ARMAGEDDON", // MP_CONCEPT_TAUNT_PYRO_ARMAGEDDON "TLK_ROCKET_DESTOYED", // MP_CONCEPT_ROCKET_DESTOYED @@ -144,16 +144,55 @@ const char *g_pszMPConcepts[] = "TLK_MAGIC_DANCE", // MP_CONCEPT_MAGIC_DANCE "HalloweenLongFall", // MP_CONCEPT_HALLOWEEN_LONGFALL "TLK_TAUNT_GUITAR_RIFF", // MP_CONCEPT_TAUNT_GUITAR_RIFF + + // TF Halloween 2013 shenanigans. + "TLK_PLAYER_CAST_FIREBALL", // MP_CONCEPT_PLAYER_CAST_FIREBALL + "TLK_PLAYER_CAST_MERASMUS_ZAP", // MP_CONCEPT_PLAYER_CAST_MERASMUS_ZAP + "TLK_PLAYER_CAST_SELF_HEAL", // MP_CONCEPT_PLAYER_CAST_SELF_HEAL + "TLK_PLAYER_CAST_MIRV", // MP_CONCEPT_PLAYER_CAST_MIRV + "TLK_PLAYER_CAST_BLAST_JUMP", // MP_CONCEPT_PLAYER_CAST_BLAST_JUMP + "TLK_PLAYER_CAST_STEALTH", // MP_CONCEPT_PLAYER_CAST_STEALTH + "TLK_PLAYER_CAST_TELEPORT", // MP_CONCEPT_PLAYER_CAST_TELEPORT + "TLK_PLAYER_CAST_LIGHTNING_BALL", // MP_CONCEPT_PLAYER_CAST_LIGHTNING_BALL + "TLK_PLAYER_CAST_MOVEMENT_BUFF", // MP_CONCEPT_PLAYER_CAST_MOVEMENT_BUFF + "TLK_PLAYER_CAST_MONOCULOUS", // MP_CONCEPT_PLAYER_CAST_MONOCULOUS + "TLK_PLAYER_CAST_METEOR_SWARM", // MP_CONCEPT_PLAYER_CAST_METEOR_SWARM + "TLK_PLAYER_CAST_SKELETON_HORDE", // MP_CONCEPT_PLAYER_CAST_SKELETON_HORDE + + "TLK_PLAYER_SPELL_FIREBALL", // MP_CONCEPT_PLAYER_SPELL_FIREBALL + "TLK_PLAYER_SPELL_MERASMUS_ZAP", // MP_CONCEPT_PLAYER_SPELL_MERASMUS_ZAP + "TLK_PLAYER_SPELL_SELF_HEAL", // MP_CONCEPT_PLAYER_SPELL_SELF_HEAL + "TLK_PLAYER_SPELL_MIRV", // MP_CONCEPT_PLAYER_SPELL_MIRV + "TLK_PLAYER_SPELL_BLAST_JUMP", // MP_CONCEPT_PLAYER_SPELL_BLAST_JUMP + "TLK_PLAYER_SPELL_STEALTH", // MP_CONCEPT_PLAYER_SPELL_STEALTH + "TLK_PLAYER_SPELL_TELEPORT", // MP_CONCEPT_PLAYER_SPELL_TELEPORT + "TLK_PLAYER_SPELL_LIGHTNING_BALL", // MP_CONCEPT_PLAYER_SPELL_LIGHTNING_BALL + "TLK_PLAYER_SPELL_MOVEMENT_BUFF", // MP_CONCEPT_PLAYER_SPELL_MOVEMENT_BUFF + "TLK_PLAYER_SPELL_MONOCULOUS", // MP_CONCEPT_PLAYER_SPELL_MONOCULOUS + "TLK_PLAYER_SPELL_METEOR_SWARM", // MP_CONCEPT_PLAYER_SPELL_METEOR_SWARM + "TLK_PLAYER_SPELL_SKELETON_HORDE", // MP_CONCEPT_PLAYER_SPELL_SKELETON_HORDE + + // Events. + "TLK_PLAYER_SPELL_PICKUP_COMMON", // MP_CONCEPT_PLAYER_SPELL_PICKUP_COMMON + "TLK_PLAYER_SPELL_PICKUP_RARE", // MP_CONCEPT_PLAYER_SPELL_PICKUP_RARE + "TLK_PLAYER_HELLTOWER_MIDNIGHT", // MP_CONCEPT_PLAYER_HELLTOWER_MIDNIGHT + "TLK_PLAYER_SKELETON_KING_APPEAR", // MP_CONCEPT_PLAYER_SKELETON_KING_APPEAR + + "TLK_MANNHATTAN_GATE_ATK", // MP_CONCEPT_MANNHATTAN_GATE_ATK + "TLK_MANNHATTAN_GATE_TAKE", // MP_CONCEPT_MANNHATTAN_GATE_TAKE + "TLK_RESURRECTED", // MP_CONCEPT_RESURRECTED + "TLK_MVM_LOOT_COMMON", // MP_CONCEPT_MVM_LOOT_COMMON + "TLK_MVM_LOOT_RARE", // MP_CONCEPT_MVM_LOOT_RARE + "TLK_MVM_LOOT_ULTRARARE", // MP_CONCEPT_MVM_LOOT_ULTRARARE + "TLK_MEDIC_HEAL_SHIELD", // MP_CONCEPT_MEDIC_HEAL_SHIELD }; +COMPILE_TIME_ASSERT( ARRAYSIZE( g_pszMPConcepts ) == MP_TF_CONCEPT_COUNT ); //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- int GetMPConceptIndexFromString( const char *pszConcept ) { - // Make sure our concept string and enum arrays are the same length - Assert( ARRAYSIZE( g_pszMPConcepts ) == MP_TF_CONCEPT_COUNT ); - for ( int iConcept = 0; iConcept < ARRAYSIZE( g_pszMPConcepts ); ++iConcept ) { if ( !Q_stricmp( pszConcept, g_pszMPConcepts[iConcept] ) ) diff --git a/mp/src/game/shared/mp_shareddefs.h b/mp/src/game/shared/mp_shareddefs.h index bb173c52..8ad6011b 100644 --- a/mp/src/game/shared/mp_shareddefs.h +++ b/mp/src/game/shared/mp_shareddefs.h @@ -112,7 +112,7 @@ enum MP_CONCEPT_TAUNT_REPLAY, // "TLK_TAUNT_REPLAY" MP_CONCEPT_TAUNT_LAUGH, // "TLK_TAUNT_LAUGH" MP_CONCEPT_TAUNT_HEROIC_POSE, // "TLK_TAUNT_HEROIC_POSE" - MP_CONCEPT_HIGHFIVE_READY, // "TLK_HIGHFIVE_READY" + MP_CONCEPT_PARTNER_TAUNT_READY, // "TLK_PARTNER_TAUNT_READY" MP_CONCEPT_HOLDTAUNT, // "TLK_PLAYER_HOLDTAUNT" MP_CONCEPT_TAUNT_PYRO_ARMAGEDDON, // "TLK_TAUNT_PYRO_ARMAGEDDON" MP_CONCEPT_ROCKET_DESTOYED, // "TLK_ROCKET_DESTOYED" @@ -153,6 +153,48 @@ enum MP_CONCEPT_MAGIC_DANCE, // "TLK_MAGIC_DANCE" MP_CONCEPT_HALLOWEEN_LONGFALL, MP_CONCEPT_TAUNT_GUITAR_RIFF, // "TLK_TAUNT_GUITAR_RIFF" + + // TF Halloween 2013 shenanigans. + MP_CONCEPT_PLAYER_CAST_FIREBALL, // "TLK_PLAYER_CAST_FIREBALL" + MP_CONCEPT_PLAYER_CAST_MERASMUS_ZAP, // "TLK_PLAYER_CAST_MERASMUS_ZAP" + MP_CONCEPT_PLAYER_CAST_SELF_HEAL, // "TLK_PLAYER_CAST_SELF_HEAL" + MP_CONCEPT_PLAYER_CAST_MIRV, // "TLK_PLAYER_CAST_MIRV" + MP_CONCEPT_PLAYER_CAST_BLAST_JUMP, // "TLK_PLAYER_CAST_BLAST_JUMP" + MP_CONCEPT_PLAYER_CAST_STEALTH, // "TLK_PLAYER_CAST_STEALTH" + MP_CONCEPT_PLAYER_CAST_TELEPORT, // "TLK_PLAYER_CAST_TELEPORT" + MP_CONCEPT_PLAYER_CAST_LIGHTNING_BALL, // "TLK_PLAYER_CAST_LIGHTNING_BALL" + MP_CONCEPT_PLAYER_CAST_MOVEMENT_BUFF, // "TLK_PLAYER_CAST_MOVEMENT_BUFF" + MP_CONCEPT_PLAYER_CAST_MONOCULOUS, // "TLK_PLAYER_CAST_MONOCULOUS" + MP_CONCEPT_PLAYER_CAST_METEOR_SWARM, // "TLK_PLAYER_CAST_METEOR_SWARM" + MP_CONCEPT_PLAYER_CAST_SKELETON_HORDE, // "TLK_PLAYER_CAST_SKELETON_HORDE" + + MP_CONCEPT_PLAYER_SPELL_FIREBALL, // "TLK_PLAYER_SPELL_FIREBALL" + MP_CONCEPT_PLAYER_SPELL_MERASMUS_ZAP, // "TLK_PLAYER_SPELL_MERASMUS_ZAP" + MP_CONCEPT_PLAYER_SPELL_SELF_HEAL, // "TLK_PLAYER_SPELL_SELF_HEAL" + MP_CONCEPT_PLAYER_SPELL_MIRV, // "TLK_PLAYER_SPELL_MIRV" + MP_CONCEPT_PLAYER_SPELL_BLAST_JUMP, // "TLK_PLAYER_SPELL_BLAST_JUMP" + MP_CONCEPT_PLAYER_SPELL_STEALTH, // "TLK_PLAYER_SPELL_STEALTH" + MP_CONCEPT_PLAYER_SPELL_TELEPORT, // "TLK_PLAYER_SPELL_TELEPORT" + MP_CONCEPT_PLAYER_SPELL_LIGHTNING_BALL, // "TLK_PLAYER_SPELL_LIGHTNING_BALL" + MP_CONCEPT_PLAYER_SPELL_MOVEMENT_BUFF, // "TLK_PLAYER_SPELL_MOVEMENT_BUFF" + MP_CONCEPT_PLAYER_SPELL_MONOCULOUS, // "TLK_PLAYER_SPELL_MONOCULOUS" + MP_CONCEPT_PLAYER_SPELL_METEOR_SWARM, // "TLK_PLAYER_SPELL_METEOR_SWARM" + MP_CONCEPT_PLAYER_SPELL_SKELETON_HORDE, // "TLK_PLAYER_SPELL_SKELETON_HORDE" + + // Events. + MP_CONCEPT_PLAYER_SPELL_PICKUP_COMMON, // "TLK_PLAYER_SPELL_PICKUP_COMMON" + MP_CONCEPT_PLAYER_SPELL_PICKUP_RARE, // "TLK_PLAYER_SPELL_PICKUP_RARE" + MP_CONCEPT_PLAYER_HELLTOWER_MIDNIGHT, // "TLK_PLAYER_HELLTOWER_MIDNIGHT" + MP_CONCEPT_PLAYER_SKELETON_KING_APPEAR, // "TLK_PLAYER_SKELETON_KING_APPEAR" + + MP_CONCEPT_MANNHATTAN_GATE_ATK, // "TLK_MANNHATTAN_GATE_ATK" + MP_CONCEPT_MANNHATTAN_GATE_TAKE, // "TLK_MANNHATTAN_GATE_TAKE" + MP_CONCEPT_RESURRECTED, // "TLK_RESURRECTED" + MP_CONCEPT_MVM_LOOT_COMMON, // "TLK_MVM_LOOT_COMMON" + MP_CONCEPT_MVM_LOOT_RARE, // "TLK_MVM_LOOT_RARE" + MP_CONCEPT_MVM_LOOT_ULTRARARE, // "TLK_MVM_LOOT_ULTRARARE" + MP_CONCEPT_MEDIC_HEAL_SHIELD, // "TLK_MEDIC_HEAL_SHIELD" + MP_TF_CONCEPT_COUNT // Other MP_CONCEPT_* start he using MP_TF_CONCEPT_COUNT + 1 as start. diff --git a/mp/src/game/shared/multiplay_gamerules.cpp b/mp/src/game/shared/multiplay_gamerules.cpp index 409f2362..07932e92 100644 --- a/mp/src/game/shared/multiplay_gamerules.cpp +++ b/mp/src/game/shared/multiplay_gamerules.cpp @@ -641,7 +641,7 @@ ConVarRef suitcharger( "sk_suitcharger" ); //========================================================= //========================================================= - bool CMultiplayRules::FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ) + bool CMultiplayRules::FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker, const CTakeDamageInfo &info ) { return true; } @@ -834,7 +834,11 @@ ConVarRef suitcharger( "sk_suitcharger" ); // If the inflictor is the killer, then it must be their current weapon doing the damage if ( pScorer->GetActiveWeapon() ) { +#ifdef HL1MP_DLL + killer_weapon_name = pScorer->GetActiveWeapon()->GetClassname(); +#else killer_weapon_name = pScorer->GetActiveWeapon()->GetDeathNoticeName(); +#endif } } else @@ -870,7 +874,9 @@ ConVarRef suitcharger( "sk_suitcharger" ); event->SetInt("attacker", killer_ID ); event->SetInt("customkill", info.GetDamageCustom() ); event->SetInt("priority", 7 ); // HLTV event priority, not transmitted - +#ifdef HL1MP_DLL + event->SetString("weapon", killer_weapon_name ); +#endif gameeventmanager->FireEvent( event ); } @@ -1748,6 +1754,37 @@ ConVarRef suitcharger( "sk_suitcharger" ); } } + void CMultiplayRules::RandomPlayersSpeakConceptIfAllowed( int iConcept, int iNumRandomPlayer /*= 1*/, int iTeam /*= TEAM_UNASSIGNED*/, const char *modifiers /*= NULL*/ ) + { + CUtlVector< CBaseMultiplayerPlayer* > speakCandidates; + + CBaseMultiplayerPlayer *pPlayer; + for ( int i = 1; i <= gpGlobals->maxClients; i++ ) + { + pPlayer = ToBaseMultiplayerPlayer( UTIL_PlayerByIndex( i ) ); + + if ( !pPlayer ) + continue; + + if ( iTeam != TEAM_UNASSIGNED ) + { + if ( pPlayer->GetTeamNumber() != iTeam ) + continue; + } + + speakCandidates.AddToTail( pPlayer ); + } + + int iSpeaker = iNumRandomPlayer; + while ( iSpeaker > 0 && speakCandidates.Count() > 0 ) + { + int iRandomSpeaker = RandomInt( 0, speakCandidates.Count() - 1 ); + speakCandidates[ iRandomSpeaker ]->SpeakConceptIfAllowed( iConcept, modifiers ); + speakCandidates.FastRemove( iRandomSpeaker ); + iSpeaker--; + } + } + void CMultiplayRules::ClientSettingsChanged( CBasePlayer *pPlayer ) { // NVNT see if this user is still or has began using a haptic device diff --git a/mp/src/game/shared/multiplay_gamerules.h b/mp/src/game/shared/multiplay_gamerules.h index 4512c9c9..08e06e4a 100644 --- a/mp/src/game/shared/multiplay_gamerules.h +++ b/mp/src/game/shared/multiplay_gamerules.h @@ -136,7 +136,7 @@ public: // Client damage rules virtual float FlPlayerFallDamage( CBasePlayer *pPlayer ); - virtual bool FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ); + virtual bool FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker, const CTakeDamageInfo &info ); virtual bool AllowDamage( CBaseEntity *pVictim, const CTakeDamageInfo &info ); // Client spawn/respawn control @@ -215,6 +215,7 @@ public: void IncrementMapCycleIndex(); void HaveAllPlayersSpeakConceptIfAllowed( int iConcept, int iTeam = TEAM_UNASSIGNED, const char *modifiers = NULL ); + void RandomPlayersSpeakConceptIfAllowed( int iConcept, int iNumRandomPlayer = 1, int iTeam = TEAM_UNASSIGNED, const char *modifiers = NULL ); virtual void GetTaggedConVarList( KeyValues *pCvarTagList ); diff --git a/mp/src/game/shared/particle_property.cpp b/mp/src/game/shared/particle_property.cpp index e5a5487d..8ddc9784 100644 --- a/mp/src/game/shared/particle_property.cpp +++ b/mp/src/game/shared/particle_property.cpp @@ -557,6 +557,14 @@ void CParticleProperty::UpdateControlPoint( ParticleEffectList_t *pEffect, int i if ( bUseHeadOrigin > 0 ) { int iBone = Studio_BoneIndexByName( pAnimating->GetModelPtr(), "bip_head" ); + if ( iBone < 0 ) + { + iBone = Studio_BoneIndexByName( pAnimating->GetModelPtr(), "prp_helmet" ); + if ( iBone < 0 ) + { + iBone = Studio_BoneIndexByName( pAnimating->GetModelPtr(), "prp_hat" ); + } + } if ( iBone >= 0 ) { bUsingHeadOrigin = true; @@ -587,18 +595,23 @@ void CParticleProperty::UpdateControlPoint( ParticleEffectList_t *pEffect, int i if ( !pAnimating->GetAttachment( pPoint->iAttachmentPoint, attachmentToWorld ) ) { - Warning( "Cannot update control point %d for effect '%s'.\n", pPoint->iAttachmentPoint, pEffect->pParticleEffect->GetEffectName() ); - attachmentToWorld = pAnimating->RenderableToWorldTransform(); + // try C_BaseAnimating if attach point is not on the weapon + if ( !pAnimating->C_BaseAnimating::GetAttachment( pPoint->iAttachmentPoint, attachmentToWorld ) ) + { + Warning( "Cannot update control point %d for effect '%s'.\n", pPoint->iAttachmentPoint, pEffect->pParticleEffect->GetEffectName() ); + attachmentToWorld = pAnimating->RenderableToWorldTransform(); + } } - MatrixVectors( attachmentToWorld, &vecForward, &vecRight, &vecUp ); - MatrixPosition( attachmentToWorld, vecOrigin ); + VMatrix vMat(attachmentToWorld); + MatrixTranslate( vMat, pPoint->vecOriginOffset ); + MatrixVectors( vMat.As3x4(), &vecForward, &vecRight, &vecUp ); + MatrixPosition( vMat.As3x4(), vecOrigin ); if ( pEffect->pParticleEffect->m_pDef->IsViewModelEffect() ) { FormatViewModelAttachment( vecOrigin, true ); } - } } break; diff --git a/mp/src/game/shared/props_shared.cpp b/mp/src/game/shared/props_shared.cpp index 7cf4489b..6d0f9209 100644 --- a/mp/src/game/shared/props_shared.cpp +++ b/mp/src/game/shared/props_shared.cpp @@ -1323,7 +1323,7 @@ CBaseEntity *CreateGibsFromList( CUtlVector &list, int modelindex, if ( !pCollide ) return NULL; - int nSkin = 0; + int nSkin = params.nDefaultSkin; CBaseEntity *pOwnerEntity = pEntity; CBaseAnimating *pOwnerAnim = NULL; if ( pPhysics ) diff --git a/mp/src/game/shared/props_shared.h b/mp/src/game/shared/props_shared.h index ee849ed2..c63cb212 100644 --- a/mp/src/game/shared/props_shared.h +++ b/mp/src/game/shared/props_shared.h @@ -227,6 +227,7 @@ struct breakablepropparams_t impactEnergyScale = 0; defBurstScale = 0; defCollisionGroup = COLLISION_GROUP_NONE; + nDefaultSkin = 0; } const Vector &origin; @@ -236,6 +237,7 @@ struct breakablepropparams_t float impactEnergyScale; float defBurstScale; int defCollisionGroup; + int nDefaultSkin; }; const char *GetMassEquivalent(float flMass); diff --git a/mp/src/game/shared/shareddefs.h b/mp/src/game/shared/shareddefs.h index b7103be3..842d2f06 100644 --- a/mp/src/game/shared/shareddefs.h +++ b/mp/src/game/shared/shareddefs.h @@ -151,8 +151,20 @@ typedef enum VOTE_FAILED_MAP_NOT_VALID, VOTE_FAILED_CANNOT_KICK_FOR_TIME, VOTE_FAILED_CANNOT_KICK_DURING_ROUND, + + // TF-specific? + VOTE_FAILED_MODIFICATION_ALREADY_ACTIVE, } vote_create_failed_t; +enum +{ +#ifdef STAGING_ONLY + SERVER_MODIFICATION_ITEM_DURATION_IN_MINUTES = 2 +#else + SERVER_MODIFICATION_ITEM_DURATION_IN_MINUTES = 120 +#endif +}; + #define MAX_VOTE_DETAILS_LENGTH 64 #define INVALID_ISSUE -1 #define MAX_VOTE_OPTIONS 5 diff --git a/mp/src/game/shared/takedamageinfo.cpp b/mp/src/game/shared/takedamageinfo.cpp index e83878cf..e9062d80 100644 --- a/mp/src/game/shared/takedamageinfo.cpp +++ b/mp/src/game/shared/takedamageinfo.cpp @@ -58,9 +58,9 @@ void CTakeDamageInfo::Init( CBaseEntity *pInflictor, CBaseEntity *pAttacker, CBa m_vecReportedPosition = reportedPosition; m_iAmmoType = -1; m_iDamagedOtherPlayers = 0; - m_iPlayerPenetrationCount = 0; m_flDamageBonus = 0.f; + m_bForceFriendlyFire = false; } CTakeDamageInfo::CTakeDamageInfo() diff --git a/mp/src/game/shared/takedamageinfo.h b/mp/src/game/shared/takedamageinfo.h index a4c01826..702e9322 100644 --- a/mp/src/game/shared/takedamageinfo.h +++ b/mp/src/game/shared/takedamageinfo.h @@ -77,6 +77,8 @@ public: void SetDamageCustom( int iDamageCustom ); int GetDamageStats( void ) const; void SetDamageStats( int iDamageStats ); + void SetForceFriendlyFire( bool bValue ) { m_bForceFriendlyFire = bValue; } + bool IsForceFriendlyFire( void ) const { return m_bForceFriendlyFire; } int GetAmmoType() const; void SetAmmoType( int iAmmoType ); @@ -123,6 +125,7 @@ protected: int m_iDamagedOtherPlayers; int m_iPlayerPenetrationCount; float m_flDamageBonus; // Anything that increases damage (crit) - store the delta + bool m_bForceFriendlyFire; // Ideally this would be a dmg type, but we can't add more DECLARE_SIMPLE_DATADESC(); }; diff --git a/mp/src/game/shared/teamplay_gamerules.cpp b/mp/src/game/shared/teamplay_gamerules.cpp index 1cbe368a..171313b3 100644 --- a/mp/src/game/shared/teamplay_gamerules.cpp +++ b/mp/src/game/shared/teamplay_gamerules.cpp @@ -352,9 +352,9 @@ bool CTeamplayRules::IsTeamplay( void ) return true; } -bool CTeamplayRules::FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ) +bool CTeamplayRules::FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker, const CTakeDamageInfo &info ) { - if ( pAttacker && PlayerRelationship( pPlayer, pAttacker ) == GR_TEAMMATE ) + if ( pAttacker && PlayerRelationship( pPlayer, pAttacker ) == GR_TEAMMATE && !info.IsForceFriendlyFire() ) { // my teammate hit me. if ( (friendlyfire.GetInt() == 0) && (pAttacker != pPlayer) ) @@ -364,7 +364,7 @@ bool CTeamplayRules::FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pA } } - return BaseClass::FPlayerCanTakeDamage( pPlayer, pAttacker ); + return BaseClass::FPlayerCanTakeDamage( pPlayer, pAttacker, info ); } //========================================================= diff --git a/mp/src/game/shared/teamplay_gamerules.h b/mp/src/game/shared/teamplay_gamerules.h index 10f953e1..952895eb 100644 --- a/mp/src/game/shared/teamplay_gamerules.h +++ b/mp/src/game/shared/teamplay_gamerules.h @@ -67,7 +67,7 @@ public: virtual bool ClientCommand( CBaseEntity *pEdict, const CCommand &args ); virtual void ClientSettingsChanged( CBasePlayer *pPlayer ); virtual bool IsTeamplay( void ); - virtual bool FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ); + virtual bool FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker, const CTakeDamageInfo &info ); virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget ); virtual bool PlayerCanHearChat( CBasePlayer *pListener, CBasePlayer *pSpeaker ); virtual const char *GetTeamID( CBaseEntity *pEntity ); diff --git a/mp/src/game/shared/teamplay_round_timer.cpp b/mp/src/game/shared/teamplay_round_timer.cpp index 63098cd6..f993749a 100644 --- a/mp/src/game/shared/teamplay_round_timer.cpp +++ b/mp/src/game/shared/teamplay_round_timer.cpp @@ -636,6 +636,12 @@ const char *CTeamRoundTimer::GetTimeWarningSound( int nWarning ) //----------------------------------------------------------------------------- void CTeamRoundTimer::SendTimeWarning( int nWarning ) { +#if defined( TF_CLIENT_DLL ) + // don't play any time warnings for Helltower + if ( TFGameRules() && TFGameRules()->IsHalloweenScenario( CTFGameRules::HALLOWEEN_SCENARIO_HIGHTOWER ) ) + return; +#endif + // don't play sounds if the level designer has turned them off or if it's during the WaitingForPlayers time if ( !m_bTimerPaused && m_bAutoCountdown && !TeamplayRoundBasedRules()->IsInWaitingForPlayers() ) { diff --git a/mp/src/game/shared/teamplayroundbased_gamerules.cpp b/mp/src/game/shared/teamplayroundbased_gamerules.cpp index 38f1294d..26a75b18 100644 --- a/mp/src/game/shared/teamplayroundbased_gamerules.cpp +++ b/mp/src/game/shared/teamplayroundbased_gamerules.cpp @@ -1267,7 +1267,7 @@ CGameRulesRoundStateInfo* CTeamplayRoundBasedRules::State_LookupInfo( gamerules_ { GR_STATE_INIT, "GR_STATE_INIT", &CTeamplayRoundBasedRules::State_Enter_INIT, NULL, &CTeamplayRoundBasedRules::State_Think_INIT }, { GR_STATE_PREGAME, "GR_STATE_PREGAME", &CTeamplayRoundBasedRules::State_Enter_PREGAME, NULL, &CTeamplayRoundBasedRules::State_Think_PREGAME }, { GR_STATE_STARTGAME, "GR_STATE_STARTGAME", &CTeamplayRoundBasedRules::State_Enter_STARTGAME, NULL, &CTeamplayRoundBasedRules::State_Think_STARTGAME }, - { GR_STATE_PREROUND, "GR_STATE_PREROUND", &CTeamplayRoundBasedRules::State_Enter_PREROUND, NULL, &CTeamplayRoundBasedRules::State_Think_PREROUND }, + { GR_STATE_PREROUND, "GR_STATE_PREROUND", &CTeamplayRoundBasedRules::State_Enter_PREROUND, &CTeamplayRoundBasedRules::State_Leave_PREROUND, &CTeamplayRoundBasedRules::State_Think_PREROUND }, { GR_STATE_RND_RUNNING, "GR_STATE_RND_RUNNING", &CTeamplayRoundBasedRules::State_Enter_RND_RUNNING, NULL, &CTeamplayRoundBasedRules::State_Think_RND_RUNNING }, { GR_STATE_TEAM_WIN, "GR_STATE_TEAM_WIN", &CTeamplayRoundBasedRules::State_Enter_TEAM_WIN, NULL, &CTeamplayRoundBasedRules::State_Think_TEAM_WIN }, { GR_STATE_RESTART, "GR_STATE_RESTART", &CTeamplayRoundBasedRules::State_Enter_RESTART, NULL, &CTeamplayRoundBasedRules::State_Think_RESTART }, @@ -1424,6 +1424,14 @@ void CTeamplayRoundBasedRules::State_Enter_PREROUND( void ) StopWatchModeThink(); } +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CTeamplayRoundBasedRules::State_Leave_PREROUND( void ) +{ + PreRound_End(); +} + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -2159,6 +2167,7 @@ void CTeamplayRoundBasedRules::SetWinningTeam( int team, int iWinReason, bool bF if ( event ) { event->SetInt( "team", team ); + event->SetInt( "winreason", iWinReason ); event->SetBool( "full_round", bForceMapReset ); event->SetFloat( "round_time", gpGlobals->curtime - m_flRoundStartTime ); event->SetBool( "was_sudden_death", bWasSuddenDeath ); @@ -3062,11 +3071,11 @@ void CTeamplayRoundBasedRules::PlayWinSong( int team ) { if ( i == team ) { - BroadcastSound( i, "Game.YourTeamWon" ); + BroadcastSound( i, WinSongName( i ) ); } else { - const char *pchLoseSong = LoseSongName(); + const char *pchLoseSong = LoseSongName( i ); if ( pchLoseSong ) { BroadcastSound( i, pchLoseSong ); @@ -3094,11 +3103,11 @@ void CTeamplayRoundBasedRules::PlaySuddenDeathSong( void ) //----------------------------------------------------------------------------- void CTeamplayRoundBasedRules::PlayStalemateSong( void ) { - BroadcastSound( TEAM_UNASSIGNED, "Game.Stalemate" ); + BroadcastSound( TEAM_UNASSIGNED, GetStalemateSong( TEAM_UNASSIGNED ) ); for ( int i = FIRST_GAME_TEAM; i < GetNumberOfTeams(); i++ ) { - BroadcastSound( i, "Game.Stalemate" ); + BroadcastSound( i, GetStalemateSong( i ) ); } } diff --git a/mp/src/game/shared/teamplayroundbased_gamerules.h b/mp/src/game/shared/teamplayroundbased_gamerules.h index 61567d49..cf584092 100644 --- a/mp/src/game/shared/teamplayroundbased_gamerules.h +++ b/mp/src/game/shared/teamplayroundbased_gamerules.h @@ -297,6 +297,8 @@ public: virtual void BetweenRounds_End( void ) { return; } virtual void BetweenRounds_Think( void ) { return; } + virtual void PreRound_End( void ) { return; } + bool PrevRoundWasWaitingForPlayers() { return m_bPrevRoundWasWaitingForPlayers; } virtual bool ShouldScorePerRound( void ){ return true; } @@ -415,6 +417,7 @@ protected: void State_Think_STARTGAME( void ); void State_Enter_PREROUND( void ); + void State_Leave_PREROUND( void ); void State_Think_PREROUND( void ); void State_Enter_RND_RUNNING( void ); @@ -456,7 +459,9 @@ protected: void PlayStalemateSong( void ); void PlaySuddenDeathSong( void ); - virtual const char* LoseSongName( void ) { return "Game.YourTeamLost"; } + virtual const char* GetStalemateSong( int nTeam ) { return "Game.Stalemate"; } + virtual const char* WinSongName( int nTeam ) { return "Game.YourTeamWon"; } + virtual const char* LoseSongName( int nTeam ) { return "Game.YourTeamLost"; } virtual void RespawnTeam( int iTeam ) { RespawnPlayers( false, true, iTeam ); } diff --git a/mp/src/game/shared/voice_banmgr.cpp b/mp/src/game/shared/voice_banmgr.cpp index 7f4864d7..d362d58f 100644 --- a/mp/src/game/shared/voice_banmgr.cpp +++ b/mp/src/game/shared/voice_banmgr.cpp @@ -54,11 +54,9 @@ bool CVoiceBanMgr::Init(const char *pGameDir) { int version; filesystem->Read(&version, sizeof(version), fh); - if(version == BANMGR_FILEVERSION) + if(version == BANMGR_FILEVERSION && filesystem->Size(fh) > 4 ) { - filesystem->Seek(fh, 0, FILESYSTEM_SEEK_TAIL); - int nIDs = (filesystem->Tell(fh) - sizeof(version)) / SIGNED_GUID_LEN; - filesystem->Seek(fh, sizeof(version), FILESYSTEM_SEEK_CURRENT); + int nIDs = ( filesystem->Size( fh ) - sizeof(version)) / SIGNED_GUID_LEN; for(int i=0; i < nIDs; i++) { diff --git a/mp/src/lib/public/appframework.lib b/mp/src/lib/public/appframework.lib index 73b8e36b..91edb5ab 100644 Binary files a/mp/src/lib/public/appframework.lib and b/mp/src/lib/public/appframework.lib differ diff --git a/mp/src/lib/public/bitmap.lib b/mp/src/lib/public/bitmap.lib index 6c9482e6..a7b09953 100644 Binary files a/mp/src/lib/public/bitmap.lib and b/mp/src/lib/public/bitmap.lib differ diff --git a/mp/src/lib/public/choreoobjects.lib b/mp/src/lib/public/choreoobjects.lib index b1baadfb..7aaab186 100644 Binary files a/mp/src/lib/public/choreoobjects.lib and b/mp/src/lib/public/choreoobjects.lib differ diff --git a/mp/src/lib/public/dmxloader.lib b/mp/src/lib/public/dmxloader.lib index d1cd4019..fa36c08d 100644 Binary files a/mp/src/lib/public/dmxloader.lib and b/mp/src/lib/public/dmxloader.lib differ diff --git a/mp/src/lib/public/fgdlib.lib b/mp/src/lib/public/fgdlib.lib index b17ea30b..e2127279 100644 Binary files a/mp/src/lib/public/fgdlib.lib and b/mp/src/lib/public/fgdlib.lib differ diff --git a/mp/src/lib/public/libz.lib b/mp/src/lib/public/libz.lib index 692f43dd..41afc354 100644 Binary files a/mp/src/lib/public/libz.lib and b/mp/src/lib/public/libz.lib differ diff --git a/mp/src/lib/public/linux32/bitmap.a b/mp/src/lib/public/linux32/bitmap.a index 9e6a44af..82ae893c 100644 Binary files a/mp/src/lib/public/linux32/bitmap.a and b/mp/src/lib/public/linux32/bitmap.a differ diff --git a/mp/src/lib/public/linux32/choreoobjects.a b/mp/src/lib/public/linux32/choreoobjects.a index 5b1da602..91d9c90c 100644 Binary files a/mp/src/lib/public/linux32/choreoobjects.a and b/mp/src/lib/public/linux32/choreoobjects.a differ diff --git a/mp/src/lib/public/linux32/dmxloader.a b/mp/src/lib/public/linux32/dmxloader.a index e344b19f..889405c9 100644 Binary files a/mp/src/lib/public/linux32/dmxloader.a and b/mp/src/lib/public/linux32/dmxloader.a differ diff --git a/mp/src/lib/public/linux32/libSDL2-2.0.so.0 b/mp/src/lib/public/linux32/libSDL2-2.0.so.0 index 5908adb7..4cb32b6a 100644 Binary files a/mp/src/lib/public/linux32/libSDL2-2.0.so.0 and b/mp/src/lib/public/linux32/libSDL2-2.0.so.0 differ diff --git a/mp/src/lib/public/linux32/libtier0.so b/mp/src/lib/public/linux32/libtier0.so index 0431a837..574e0a88 100644 Binary files a/mp/src/lib/public/linux32/libtier0.so and b/mp/src/lib/public/linux32/libtier0.so differ diff --git a/mp/src/lib/public/linux32/libvstdlib.so b/mp/src/lib/public/linux32/libvstdlib.so index 729c1dd0..0a460bb5 100644 Binary files a/mp/src/lib/public/linux32/libvstdlib.so and b/mp/src/lib/public/linux32/libvstdlib.so differ diff --git a/mp/src/lib/public/linux32/matsys_controls.a b/mp/src/lib/public/linux32/matsys_controls.a index a831c48b..9ae25dd0 100644 Binary files a/mp/src/lib/public/linux32/matsys_controls.a and b/mp/src/lib/public/linux32/matsys_controls.a differ diff --git a/mp/src/lib/public/linux32/particles.a b/mp/src/lib/public/linux32/particles.a index d0189664..6d1a8f91 100644 Binary files a/mp/src/lib/public/linux32/particles.a and b/mp/src/lib/public/linux32/particles.a differ diff --git a/mp/src/lib/public/linux32/shaderlib.a b/mp/src/lib/public/linux32/shaderlib.a index da93e3f6..327f13be 100644 Binary files a/mp/src/lib/public/linux32/shaderlib.a and b/mp/src/lib/public/linux32/shaderlib.a differ diff --git a/mp/src/lib/public/linux32/tier2.a b/mp/src/lib/public/linux32/tier2.a index a2af0ed5..1ac5c0c5 100644 Binary files a/mp/src/lib/public/linux32/tier2.a and b/mp/src/lib/public/linux32/tier2.a differ diff --git a/mp/src/lib/public/linux32/tier3.a b/mp/src/lib/public/linux32/tier3.a index c4eb9880..9bc1bf1f 100644 Binary files a/mp/src/lib/public/linux32/tier3.a and b/mp/src/lib/public/linux32/tier3.a differ diff --git a/mp/src/lib/public/linux32/vtf.a b/mp/src/lib/public/linux32/vtf.a index 11713419..30858deb 100644 Binary files a/mp/src/lib/public/linux32/vtf.a and b/mp/src/lib/public/linux32/vtf.a differ diff --git a/mp/src/lib/public/mathlib.lib b/mp/src/lib/public/mathlib.lib index d7e6eef8..bd411d70 100644 Binary files a/mp/src/lib/public/mathlib.lib and b/mp/src/lib/public/mathlib.lib differ diff --git a/mp/src/lib/public/matsys_controls.lib b/mp/src/lib/public/matsys_controls.lib index 2fb462ea..6663600a 100644 Binary files a/mp/src/lib/public/matsys_controls.lib and b/mp/src/lib/public/matsys_controls.lib differ diff --git a/mp/src/lib/public/nvtristrip.lib b/mp/src/lib/public/nvtristrip.lib index afea63d1..ed2478a8 100644 Binary files a/mp/src/lib/public/nvtristrip.lib and b/mp/src/lib/public/nvtristrip.lib differ diff --git a/mp/src/lib/public/osx32/bitmap.a b/mp/src/lib/public/osx32/bitmap.a index 13f58a27..ffc0a58c 100644 Binary files a/mp/src/lib/public/osx32/bitmap.a and b/mp/src/lib/public/osx32/bitmap.a differ diff --git a/mp/src/lib/public/osx32/choreoobjects.a b/mp/src/lib/public/osx32/choreoobjects.a index 2fb14bb8..58fb4a96 100644 Binary files a/mp/src/lib/public/osx32/choreoobjects.a and b/mp/src/lib/public/osx32/choreoobjects.a differ diff --git a/mp/src/lib/public/osx32/dmxloader.a b/mp/src/lib/public/osx32/dmxloader.a index db336f43..53748abc 100644 Binary files a/mp/src/lib/public/osx32/dmxloader.a and b/mp/src/lib/public/osx32/dmxloader.a differ diff --git a/mp/src/lib/public/osx32/libSDL2-2.0.0.dylib b/mp/src/lib/public/osx32/libSDL2-2.0.0.dylib index 3fd8c749..c8dcd704 100644 Binary files a/mp/src/lib/public/osx32/libSDL2-2.0.0.dylib and b/mp/src/lib/public/osx32/libSDL2-2.0.0.dylib differ diff --git a/mp/src/lib/public/osx32/libtier0.dylib b/mp/src/lib/public/osx32/libtier0.dylib index 84180383..b56e4889 100644 Binary files a/mp/src/lib/public/osx32/libtier0.dylib and b/mp/src/lib/public/osx32/libtier0.dylib differ diff --git a/mp/src/lib/public/osx32/libvstdlib.dylib b/mp/src/lib/public/osx32/libvstdlib.dylib index a54a8a7b..fcd2a9f7 100644 Binary files a/mp/src/lib/public/osx32/libvstdlib.dylib and b/mp/src/lib/public/osx32/libvstdlib.dylib differ diff --git a/mp/src/lib/public/osx32/matsys_controls.a b/mp/src/lib/public/osx32/matsys_controls.a index 0a8de4ed..26d42570 100644 Binary files a/mp/src/lib/public/osx32/matsys_controls.a and b/mp/src/lib/public/osx32/matsys_controls.a differ diff --git a/mp/src/lib/public/osx32/particles.a b/mp/src/lib/public/osx32/particles.a index f3332c0d..3745aab4 100644 Binary files a/mp/src/lib/public/osx32/particles.a and b/mp/src/lib/public/osx32/particles.a differ diff --git a/mp/src/lib/public/osx32/shaderlib.a b/mp/src/lib/public/osx32/shaderlib.a index dcc79c72..a9507a01 100644 Binary files a/mp/src/lib/public/osx32/shaderlib.a and b/mp/src/lib/public/osx32/shaderlib.a differ diff --git a/mp/src/lib/public/osx32/tier2.a b/mp/src/lib/public/osx32/tier2.a index c5f77742..ccbbb325 100644 Binary files a/mp/src/lib/public/osx32/tier2.a and b/mp/src/lib/public/osx32/tier2.a differ diff --git a/mp/src/lib/public/osx32/tier3.a b/mp/src/lib/public/osx32/tier3.a index 521e0491..a3a76ccd 100644 Binary files a/mp/src/lib/public/osx32/tier3.a and b/mp/src/lib/public/osx32/tier3.a differ diff --git a/mp/src/lib/public/osx32/vtf.a b/mp/src/lib/public/osx32/vtf.a index 08054ef6..74130122 100644 Binary files a/mp/src/lib/public/osx32/vtf.a and b/mp/src/lib/public/osx32/vtf.a differ diff --git a/mp/src/lib/public/particles.lib b/mp/src/lib/public/particles.lib index df995060..2e6f9359 100644 Binary files a/mp/src/lib/public/particles.lib and b/mp/src/lib/public/particles.lib differ diff --git a/mp/src/lib/public/raytrace.lib b/mp/src/lib/public/raytrace.lib index 8f4fce6d..507ced28 100644 Binary files a/mp/src/lib/public/raytrace.lib and b/mp/src/lib/public/raytrace.lib differ diff --git a/mp/src/lib/public/shaderlib.lib b/mp/src/lib/public/shaderlib.lib index 2047f41a..ee4b05f6 100644 Binary files a/mp/src/lib/public/shaderlib.lib and b/mp/src/lib/public/shaderlib.lib differ diff --git a/mp/src/lib/public/tier0.lib b/mp/src/lib/public/tier0.lib index fa9c6b79..4b3b77d5 100644 Binary files a/mp/src/lib/public/tier0.lib and b/mp/src/lib/public/tier0.lib differ diff --git a/mp/src/lib/public/tier1.lib b/mp/src/lib/public/tier1.lib index 7f0985e1..2b0d8eb7 100644 Binary files a/mp/src/lib/public/tier1.lib and b/mp/src/lib/public/tier1.lib differ diff --git a/mp/src/lib/public/tier2.lib b/mp/src/lib/public/tier2.lib index 9d058f9d..b7cfafbb 100644 Binary files a/mp/src/lib/public/tier2.lib and b/mp/src/lib/public/tier2.lib differ diff --git a/mp/src/lib/public/tier3.lib b/mp/src/lib/public/tier3.lib index 634832e9..ecf4544c 100644 Binary files a/mp/src/lib/public/tier3.lib and b/mp/src/lib/public/tier3.lib differ diff --git a/mp/src/lib/public/vgui_controls.lib b/mp/src/lib/public/vgui_controls.lib index ae56ebcd..c216271e 100644 Binary files a/mp/src/lib/public/vgui_controls.lib and b/mp/src/lib/public/vgui_controls.lib differ diff --git a/mp/src/lib/public/vmpi.lib b/mp/src/lib/public/vmpi.lib index 323dd59e..e9012f2f 100644 Binary files a/mp/src/lib/public/vmpi.lib and b/mp/src/lib/public/vmpi.lib differ diff --git a/mp/src/lib/public/vstdlib.lib b/mp/src/lib/public/vstdlib.lib index 503391aa..f0789a8d 100644 Binary files a/mp/src/lib/public/vstdlib.lib and b/mp/src/lib/public/vstdlib.lib differ diff --git a/mp/src/lib/public/vtf.lib b/mp/src/lib/public/vtf.lib index 88a718bc..c7bf352c 100644 Binary files a/mp/src/lib/public/vtf.lib and b/mp/src/lib/public/vtf.lib differ diff --git a/mp/src/mathlib/mathlib_base.cpp b/mp/src/mathlib/mathlib_base.cpp index a403ccfa..15c51963 100644 --- a/mp/src/mathlib/mathlib_base.cpp +++ b/mp/src/mathlib/mathlib_base.cpp @@ -4244,7 +4244,7 @@ FPExceptionDisabler::FPExceptionDisabler() // Retrieve the current state of the exception flags. This // must be done before changing them. _MCW_EM is a bit // mask representing all available exception masks. - _controlfp_s(&mOldValues, _MCW_EM, _MCW_EM); + _controlfp_s(&mOldValues, 0, 0); // Set all of the exception flags, which suppresses FP // exceptions on the x87 and SSE units. _controlfp_s(0, _MCW_EM, _MCW_EM); @@ -4269,7 +4269,7 @@ FPExceptionEnabler::FPExceptionEnabler(unsigned int enableBits /*= _EM_OVERFLOW // Retrieve the current state of the exception flags. This // must be done before changing them. _MCW_EM is a bit // mask representing all available exception masks. - _controlfp_s(&mOldValues, _MCW_EM, _MCW_EM); + _controlfp_s(&mOldValues, 0, 0); // Make sure no non-exception flags have been specified, // to avoid accidental changing of rounding modes, etc. diff --git a/mp/src/mathlib/vmatrix.cpp b/mp/src/mathlib/vmatrix.cpp index 1cd316f3..e99fae2a 100644 --- a/mp/src/mathlib/vmatrix.cpp +++ b/mp/src/mathlib/vmatrix.cpp @@ -507,7 +507,7 @@ bool VMatrix::IsRotationMatrix() const FloatMakePositive( v2.Dot(v3) ) < 0.01f; } -void VMatrix::SetupMatrixOrgAngles( const Vector &origin, const QAngle &vAngles ) +static void SetupMatrixAnglesInternal( vec_t m[4][4], const QAngle & vAngles ) { float sr, sp, sy, cr, cp, cy; @@ -528,6 +528,11 @@ void VMatrix::SetupMatrixOrgAngles( const Vector &origin, const QAngle &vAngles m[0][3] = 0.f; m[1][3] = 0.f; m[2][3] = 0.f; +} + +void VMatrix::SetupMatrixOrgAngles( const Vector &origin, const QAngle &vAngles ) +{ + SetupMatrixAnglesInternal( m, vAngles ); // Add translation m[0][3] = origin.x; @@ -540,6 +545,21 @@ void VMatrix::SetupMatrixOrgAngles( const Vector &origin, const QAngle &vAngles } +void VMatrix::SetupMatrixAngles( const QAngle &vAngles ) +{ + SetupMatrixAnglesInternal( m, vAngles ); + + // Zero everything else + m[0][3] = 0.0f; + m[1][3] = 0.0f; + m[2][3] = 0.0f; + m[3][0] = 0.0f; + m[3][1] = 0.0f; + m[3][2] = 0.0f; + m[3][3] = 1.0f; +} + + //----------------------------------------------------------------------------- // Sets matrix to identity //----------------------------------------------------------------------------- diff --git a/mp/src/public/VGuiMatSurface/IMatSystemSurface.h b/mp/src/public/VGuiMatSurface/IMatSystemSurface.h index ddc73e69..03ff33b0 100644 --- a/mp/src/public/VGuiMatSurface/IMatSystemSurface.h +++ b/mp/src/public/VGuiMatSurface/IMatSystemSurface.h @@ -105,6 +105,10 @@ public: // Gets a material bound to a surface texture ID virtual IMaterial *DrawGetTextureMaterial( int id ) = 0; + + // The matching method is in ISurface, but we can't add anything there and remain mod-compatible. + // So this goes here instead. + virtual void GetFullscreenViewportAndRenderTarget( int & x, int & y, int & w, int & h, ITexture **ppRenderTarget ) = 0; }; diff --git a/mp/src/public/XUnzip.cpp b/mp/src/public/XUnzip.cpp index bd7dc20e..cea57582 100644 --- a/mp/src/public/XUnzip.cpp +++ b/mp/src/public/XUnzip.cpp @@ -4474,15 +4474,7 @@ bool SafeUnzipMemory( const void *pvZipped, int cubZipped, void *pvDest, int cub int iRes = ZR_CORRUPT; if ( hZip ) { - try - { - iRes = UnzipItem( hZip, 0, pvDest, cubDest, ZIP_MEMORY ); - } - catch ( ... ) - { - // failed to unzip, try to continue - iRes = ZR_CORRUPT; - } + iRes = UnzipItem( hZip, 0, pvDest, cubDest, ZIP_MEMORY ); CloseZip( hZip ); } diff --git a/mp/src/public/bone_setup.cpp b/mp/src/public/bone_setup.cpp index 0cc81c67..250133d5 100644 --- a/mp/src/public/bone_setup.cpp +++ b/mp/src/public/bone_setup.cpp @@ -678,6 +678,12 @@ static void CalcLocalHierarchyAnimation( int boneMask ) { +#ifdef STAGING_ONLY + Assert( iNewParent == -1 || (iNewParent >= 0 && iNewParent < MAXSTUDIOBONES) ); + Assert( iBone > 0 ); + Assert( iBone < MAXSTUDIOBONES ); +#endif // STAGING_ONLY + Vector localPos; Quaternion localQ; @@ -715,12 +721,19 @@ static void CalcLocalHierarchyAnimation( CalcDecompressedAnimation( pHierarchy->pLocalAnim(), iFrame - pHierarchy->iStart, flFraq, localPos, localQ ); BuildBoneChain( pStudioHdr, rootXform, pos, q, iBone, boneToWorld, boneComputed ); - BuildBoneChain( pStudioHdr, rootXform, pos, q, iNewParent, boneToWorld, boneComputed ); matrix3x4_t localXform; AngleMatrix( localQ, localPos, localXform ); - ConcatTransforms( boneToWorld[iNewParent], localXform, boneToWorld[iBone] ); + if ( iNewParent != -1 ) + { + BuildBoneChain( pStudioHdr, rootXform, pos, q, iNewParent, boneToWorld, boneComputed ); + ConcatTransforms( boneToWorld[iNewParent], localXform, boneToWorld[iBone] ); + } + else + { + boneToWorld[iBone] = localXform; + } // back solve Vector p1; @@ -995,10 +1008,17 @@ static void CalcVirtualAnimation( virtualmodel_t *pVModel, const CStudioHdr *pSt int iBone = pAnimGroup->masterBone[pHierarchy->iBone]; if (iBone >= 0 && (pStudioHdr->boneFlags(iBone) & boneMask)) { - int iNewParent = pAnimGroup->masterBone[pHierarchy->iNewParent]; - if (iNewParent >= 0 && (pStudioHdr->boneFlags(iNewParent) & boneMask)) + if ( pHierarchy->iNewParent != -1 ) { - CalcLocalHierarchyAnimation( pStudioHdr, boneToWorld, boneComputed, pos, q, pbone, pHierarchy, iBone, iNewParent, cycle, iFrame, s, boneMask ); + int iNewParent = pAnimGroup->masterBone[pHierarchy->iNewParent]; + if (iNewParent >= 0 && (pStudioHdr->boneFlags(iNewParent) & boneMask)) + { + CalcLocalHierarchyAnimation( pStudioHdr, boneToWorld, boneComputed, pos, q, pbone, pHierarchy, iBone, iNewParent, cycle, iFrame, s, boneMask ); + } + } + else + { + CalcLocalHierarchyAnimation( pStudioHdr, boneToWorld, boneComputed, pos, q, pbone, pHierarchy, iBone, -1, cycle, iFrame, s, boneMask ); } } } @@ -5948,3 +5968,81 @@ bool Studio_PrefetchSequence( const CStudioHdr *pStudioHdr, int iSequence ) // Everything for this sequence is resident? return !pendingload; } + + +//----------------------------------------------------------------------------- +// Purpose: Drive a flex controller from a component of a bone +//----------------------------------------------------------------------------- +void Studio_RunBoneFlexDrivers( float *pflFlexControllerWeights, const CStudioHdr *pStudioHdr, const Vector *pvPositions, const matrix3x4_t *pBoneToWorld, const matrix3x4_t &mRootToWorld ) +{ + bool bRootToWorldInvComputed = false; + matrix3x4_t mRootToWorldInv; + matrix3x4_t mParentInv; + matrix3x4_t mBoneLocal; + + const int nBoneFlexDriverCount = pStudioHdr->BoneFlexDriverCount(); + + for ( int i = 0; i < nBoneFlexDriverCount; ++i ) + { + const mstudioboneflexdriver_t *pBoneFlexDriver = pStudioHdr->BoneFlexDriver( i ); + const mstudiobone_t *pStudioBone = pStudioHdr->pBone( pBoneFlexDriver->m_nBoneIndex ); + + const int nControllerCount = pBoneFlexDriver->m_nControlCount; + + if ( pStudioBone->flags & BONE_USED_BY_BONE_MERGE ) + { + // The local space version of the bone is not available if this is a bonemerged bone + // so do the slow computation of the local version of the bone from boneToWorld + + if ( pStudioBone->parent < 0 ) + { + if ( !bRootToWorldInvComputed ) + { + MatrixInvert( mRootToWorld, mRootToWorldInv ); + bRootToWorldInvComputed = true; + } + + MatrixMultiply( mRootToWorldInv, pBoneToWorld[ pBoneFlexDriver->m_nBoneIndex ], mBoneLocal ); + } + else + { + MatrixInvert( pBoneToWorld[ pStudioBone->parent ], mParentInv ); + MatrixMultiply( mParentInv, pBoneToWorld[ pBoneFlexDriver->m_nBoneIndex ], mBoneLocal ); + } + + for ( int j = 0; j < nControllerCount; ++j ) + { + const mstudioboneflexdrivercontrol_t *pController = pBoneFlexDriver->pBoneFlexDriverControl( j ); + const mstudioflexcontroller_t *pFlexController = pStudioHdr->pFlexcontroller( static_cast< LocalFlexController_t >( pController->m_nFlexControllerIndex ) ); + + if ( pFlexController->localToGlobal < 0 ) + continue; + + Assert( pController->m_nFlexControllerIndex >= 0 && pController->m_nFlexControllerIndex < pStudioHdr->numflexcontrollers() ); + Assert( pController->m_nBoneComponent >= 0 && pController->m_nBoneComponent <= 2 ); + pflFlexControllerWeights[pFlexController->localToGlobal] = + RemapValClamped( mBoneLocal[pController->m_nBoneComponent][3], pController->m_flMin, pController->m_flMax, 0.0f, 1.0f ); + } + } + else + { + // Use the local space version of the bone directly for non-bonemerged bones + + const Vector &position = pvPositions[ pBoneFlexDriver->m_nBoneIndex ]; + + for ( int j = 0; j < nControllerCount; ++j ) + { + const mstudioboneflexdrivercontrol_t *pController = pBoneFlexDriver->pBoneFlexDriverControl( j ); + const mstudioflexcontroller_t *pFlexController = pStudioHdr->pFlexcontroller( static_cast< LocalFlexController_t >( pController->m_nFlexControllerIndex ) ); + + if ( pFlexController->localToGlobal < 0 ) + continue; + + Assert( pController->m_nFlexControllerIndex >= 0 && pController->m_nFlexControllerIndex < pStudioHdr->numflexcontrollers() ); + Assert( pController->m_nBoneComponent >= 0 && pController->m_nBoneComponent <= 2 ); + pflFlexControllerWeights[pFlexController->localToGlobal] = + RemapValClamped( position[pController->m_nBoneComponent], pController->m_flMin, pController->m_flMax, 0.0f, 1.0f ); + } + } + } +} diff --git a/mp/src/public/bone_setup.h b/mp/src/public/bone_setup.h index ebbdfd57..76f00a66 100644 --- a/mp/src/public/bone_setup.h +++ b/mp/src/public/bone_setup.h @@ -444,4 +444,6 @@ void QuaternionMA( const Quaternion &p, float s, const Quaternion &q, Quaternion bool Studio_PrefetchSequence( const CStudioHdr *pStudioHdr, int iSequence ); +void Studio_RunBoneFlexDrivers( float *pFlexController, const CStudioHdr *pStudioHdr, const Vector *pPositions, const matrix3x4_t *pBoneToWorld, const matrix3x4_t &mRootToWorld ); + #endif // BONE_SETUP_H diff --git a/mp/src/public/filesystem_init.cpp b/mp/src/public/filesystem_init.cpp index 08e8da17..36b484f5 100644 --- a/mp/src/public/filesystem_init.cpp +++ b/mp/src/public/filesystem_init.cpp @@ -224,6 +224,7 @@ CFSSearchPathsInit::CFSSearchPathsInit() m_pDirectoryName = NULL; m_pLanguage = NULL; m_ModPath[0] = 0; + m_bMountHDContent = m_bLowViolence = false; } @@ -460,52 +461,6 @@ FSReturnCode_t LoadGameInfoFile( return FS_OK; } -// checks the registry for the low violence setting -// Check "HKEY_CURRENT_USER\Software\Valve\Source\Settings" and "User Token 2" or "User Token 3" -bool IsLowViolenceBuild( void ) -{ -#if defined(_WIN32) - HKEY hKey; - char szValue[64]; - unsigned long len = sizeof(szValue) - 1; - bool retVal = false; - - if ( IsPC() && RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Valve\\Source\\Settings", NULL, KEY_READ, &hKey) == ERROR_SUCCESS ) - { - // User Token 2 - if ( RegQueryValueEx( hKey, "User Token 2", NULL, NULL, (unsigned char*)szValue, &len ) == ERROR_SUCCESS ) - { - if ( Q_strlen( szValue ) > 0 ) - { - retVal = true; - } - } - - if ( !retVal ) - { - // reset "len" for the next check - len = sizeof(szValue) - 1; - - // User Token 3 - if ( RegQueryValueEx( hKey, "User Token 3", NULL, NULL, (unsigned char*)szValue, &len ) == ERROR_SUCCESS ) - { - if ( Q_strlen( szValue ) > 0 ) - { - retVal = true; - } - } - } - - RegCloseKey(hKey); - } - - return retVal; -#elif POSIX - return false; -#else - #error "Fix me" -#endif -} static void FileSystem_AddLoadedSearchPath( CFSSearchPathsInit &initInfo, @@ -519,13 +474,26 @@ static void FileSystem_AddLoadedSearchPath( { // Not in LV build, don't mount - if ( !bLowViolence ) + if ( !initInfo.m_bLowViolence ) return; // Mount, as a game path pPathID = "game"; } + // Check for mounting HD game content if enabled + if ( V_stricmp( pPathID, "game_hd" ) == 0 ) + { + + // Not in LV build, don't mount + if ( !initInfo.m_bMountHDContent ) + return; + + // Mount, as a game path + pPathID = "game"; + } + + // Special processing for ordinary game folders if ( V_stristr( fullLocationPath, ".vpk" ) == NULL && Q_stricmp( pPathID, "game" ) == 0 ) { @@ -600,7 +568,7 @@ FSReturnCode_t FileSystem_LoadSearchPaths( CFSSearchPathsInit &initInfo ) } } - bool bLowViolence = IsLowViolenceBuild(); + bool bLowViolence = initInfo.m_bLowViolence; for ( KeyValues *pCur=pSearchPaths->GetFirstValue(); pCur; pCur=pCur->GetNextValue() ) { const char *pLocation = pCur->GetString(); diff --git a/mp/src/public/filesystem_init.h b/mp/src/public/filesystem_init.h index 182ea411..d95e7c3a 100644 --- a/mp/src/public/filesystem_init.h +++ b/mp/src/public/filesystem_init.h @@ -156,6 +156,9 @@ public: // This is the filesystem FileSystem_LoadSearchPaths is talking to. IFileSystem *m_pFileSystem; + bool m_bMountHDContent; + bool m_bLowViolence; + // Outputs. public: // This is the location of the first search path called "game", which also becomes your "mod" search path. diff --git a/mp/src/public/materialsystem/imaterialsystem.h b/mp/src/public/materialsystem/imaterialsystem.h index 9a16b9db..812eb262 100644 --- a/mp/src/public/materialsystem/imaterialsystem.h +++ b/mp/src/public/materialsystem/imaterialsystem.h @@ -524,7 +524,8 @@ enum RenderTargetSizeMode_t RT_SIZE_FULL_FRAME_BUFFER=4, // Same size as frame buffer, or next lower power of 2 if we can't do that. RT_SIZE_OFFSCREEN=5, // Target of specified size, don't mess with dimensions RT_SIZE_FULL_FRAME_BUFFER_ROUNDED_UP=6, // Same size as the frame buffer, rounded up if necessary for systems that can't do non-power of two textures. - RT_SIZE_REPLAY_SCREENSHOT = 7 // Rounded down to power of 2, essentially... + RT_SIZE_REPLAY_SCREENSHOT = 7, // Rounded down to power of 2, essentially... + RT_SIZE_LITERAL = 8 // Use the size passed in. Don't clamp it to the frame buffer size. Really. }; typedef void (*MaterialBufferReleaseFunc_t)( ); @@ -1028,6 +1029,16 @@ public: #ifdef DX_TO_GL_ABSTRACTION virtual void DoStartupShaderPreloading( void ) = 0; #endif + + // Sets the override sizes for all render target size tests. These replace the frame buffer size. + // Set them when you are rendering primarily to something larger than the frame buffer (as in VR mode). + virtual void SetRenderTargetFrameBufferSizeOverrides( int nWidth, int nHeight ) = 0; + + // Returns the (possibly overridden) framebuffer size for render target sizing. + virtual void GetRenderTargetFrameBufferDimensions( int & nWidth, int & nHeight ) = 0; + + // returns the display device name that matches the adapter index we were started with + virtual char *GetDisplayDeviceName() const = 0; }; @@ -1482,7 +1493,7 @@ public: // Returns whether a pointer is render data. NOTE: passing NULL returns true virtual bool IsRenderData( const void *pData ) const = 0; virtual void PrintfVA( char *fmt, va_list vargs ) = 0; - virtual void Printf( PRINTF_FORMAT_STRING char *fmt, ... ) = 0; + virtual void Printf( PRINTF_FORMAT_STRING const char *fmt, ... ) = 0; virtual float Knob( char *knobname, float *setvalue = NULL ) = 0; // Allows us to override the alpha write setting of a material virtual void OverrideAlphaWriteEnable( bool bEnable, bool bAlphaWriteEnable ) = 0; diff --git a/mp/src/public/materialsystem/materialsystem_config.h b/mp/src/public/materialsystem/materialsystem_config.h index b0fe3a27..2908d2ce 100644 --- a/mp/src/public/materialsystem/materialsystem_config.h +++ b/mp/src/public/materialsystem/materialsystem_config.h @@ -33,6 +33,7 @@ enum MaterialSystem_Config_Flags_t MATSYS_VIDCFG_FLAGS_SCALE_TO_OUTPUT_RESOLUTION = ( 1 << 14 ), MATSYS_VIDCFG_FLAGS_USING_MULTIPLE_WINDOWS = ( 1 << 15 ), MATSYS_VIDCFG_FLAGS_DISABLE_PHONG = ( 1 << 16 ), + MATSYS_VIDCFG_FLAGS_VR_MODE = ( 1 << 17 ), }; struct MaterialSystemHardwareIdentifier_t @@ -64,6 +65,7 @@ struct MaterialSystem_Config_t bool ScaleToOutputResolution() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_SCALE_TO_OUTPUT_RESOLUTION ) != 0; } bool UsingMultipleWindows() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_USING_MULTIPLE_WINDOWS ) != 0; } bool UsePhong() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_DISABLE_PHONG ) == 0; } + bool VRMode() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_VR_MODE) != 0; } bool ShadowDepthTexture() const { return m_bShadowDepthTexture; } bool MotionBlur() const { return m_bMotionBlur; } bool SupportFlashlight() const { return m_bSupportFlashlight; } @@ -140,6 +142,8 @@ struct MaterialSystem_Config_t bool m_bMotionBlur; bool m_bSupportFlashlight; + int m_nVRModeAdapter; + MaterialSystem_Config_t() { memset( this, 0, sizeof( *this ) ); @@ -160,6 +164,7 @@ struct MaterialSystem_Config_t SetFlag( MATSYS_VIDCFG_FLAGS_SCALE_TO_OUTPUT_RESOLUTION, false ); SetFlag( MATSYS_VIDCFG_FLAGS_USING_MULTIPLE_WINDOWS, false ); SetFlag( MATSYS_VIDCFG_FLAGS_DISABLE_PHONG, false ); + SetFlag( MATSYS_VIDCFG_FLAGS_VR_MODE, false ); m_VideoMode.m_Width = 640; m_VideoMode.m_Height = 480; @@ -182,6 +187,8 @@ struct MaterialSystem_Config_t m_bMotionBlur = false; m_bSupportFlashlight = true; + m_nVRModeAdapter = -1; + // misc defaults bAllowCheats = false; bCompressedTextures = true; diff --git a/mp/src/public/mathlib/vector.h b/mp/src/public/mathlib/vector.h index c19261d7..a797da25 100644 --- a/mp/src/public/mathlib/vector.h +++ b/mp/src/public/mathlib/vector.h @@ -1187,7 +1187,7 @@ inline Vector &AllocTempVector() } ThreadPause(); } - return s_vecTemp[nIndex & 0xffff]; + return s_vecTemp[nIndex]; } diff --git a/mp/src/public/mathlib/vmatrix.h b/mp/src/public/mathlib/vmatrix.h index 2c536672..c18e4822 100644 --- a/mp/src/public/mathlib/vmatrix.h +++ b/mp/src/public/mathlib/vmatrix.h @@ -200,6 +200,9 @@ public: // Setup a matrix for origin and angles. void SetupMatrixOrgAngles( const Vector &origin, const QAngle &vAngles ); + // Setup a matrix for angles and no translation. + void SetupMatrixAngles( const QAngle &vAngles ); + // General inverse. This may fail so check the return! bool InverseGeneral(VMatrix &vInverse) const; diff --git a/mp/src/public/matsys_controls/mdlpanel.h b/mp/src/public/matsys_controls/mdlpanel.h index 8f0ccb30..91f936e7 100644 --- a/mp/src/public/matsys_controls/mdlpanel.h +++ b/mp/src/public/matsys_controls/mdlpanel.h @@ -51,6 +51,8 @@ public: virtual void OnTick(); + virtual void Paint(); + // Sets the current mdl virtual void SetMDL( MDLHandle_t handle, void *pProxyData = NULL ); virtual void SetMDL( const char *pMDLName, void *pProxyData = NULL ); @@ -78,6 +80,7 @@ public: void SetSkin( int nSkin ); void SetLookAtCamera( bool bLookAtCamera ); void SetIgnoreDoubleClick( bool bState ); + void SetThumbnailSafeZone( bool bVisible ); // Bounds. bool GetBoundingBox( Vector &vecBoundsMin, Vector &vecBoundsMax ); @@ -103,6 +106,8 @@ public: protected: + virtual void SetupRenderState( int nDisplayWidth, int nDisplayHeight ) OVERRIDE; + struct MDLData_t { CMDL m_MDL; @@ -122,7 +127,7 @@ protected: private: // paint it! - void OnPaint3D(); + virtual void OnPaint3D(); virtual void PrePaint3D( IMatRenderContext *pRenderContext ) { }; virtual void PostPaint3D( IMatRenderContext *pRenderContext ) { }; virtual void RenderingMergedModel( IMatRenderContext *pRenderContext, CStudioHdr *pStudioHdr, MDLHandle_t mdlHandle, matrix3x4_t *pWorldMatrix ) { }; @@ -141,6 +146,7 @@ private: bool m_bWireFrame : 1; bool m_bLookAtCamera : 1; bool m_bIgnoreDoubleClick : 1; + bool m_bThumbnailSafeZone : 1; float m_PoseParameters[ MAXSTUDIOPOSEPARAM ]; }; diff --git a/mp/src/public/matsys_controls/mdlpicker.h b/mp/src/public/matsys_controls/mdlpicker.h index 202167c5..fcacfc9c 100644 --- a/mp/src/public/matsys_controls/mdlpicker.h +++ b/mp/src/public/matsys_controls/mdlpicker.h @@ -101,6 +101,7 @@ private: void WriteBackbackVMTFiles( const char *assetName ); void GenerateBackpackIcons( void ); + CUtlString GetOutputFileSuffix(); MESSAGE_FUNC_PARAMS( OnCheckButtonChecked, "CheckButtonChecked", kv ); MESSAGE_FUNC_PARAMS( OnItemSelected, "ItemSelected", kv ); diff --git a/mp/src/public/matsys_controls/potterywheelpanel.h b/mp/src/public/matsys_controls/potterywheelpanel.h index 8cb41497..47125a3f 100644 --- a/mp/src/public/matsys_controls/potterywheelpanel.h +++ b/mp/src/public/matsys_controls/potterywheelpanel.h @@ -131,8 +131,9 @@ protected: bool m_bRenderToTexture; + virtual void SetupRenderState( int nDisplayWidth, int nDisplayHeight ); + private: - void SetupRenderState( int nDisplayWidth, int nDisplayHeight ); void CreateDefaultLights(); void DestroyLights(); diff --git a/mp/src/public/shaderapi/IShaderDevice.h b/mp/src/public/shaderapi/IShaderDevice.h index 34749de0..832e6ac7 100644 --- a/mp/src/public/shaderapi/IShaderDevice.h +++ b/mp/src/public/shaderapi/IShaderDevice.h @@ -271,6 +271,7 @@ public: #ifdef DX_TO_GL_ABSTRACTION virtual void DoStartupShaderPreloading( void ) = 0; #endif + virtual char *GetDisplayDeviceName() = 0; }; diff --git a/mp/src/public/shaderapi/ishaderapi.h b/mp/src/public/shaderapi/ishaderapi.h index 69782a60..367cd0e9 100644 --- a/mp/src/public/shaderapi/ishaderapi.h +++ b/mp/src/public/shaderapi/ishaderapi.h @@ -603,7 +603,7 @@ public: // debug logging // only implemented in some subclasses virtual void PrintfVA( char *fmt, va_list vargs ) = 0; - virtual void Printf( PRINTF_FORMAT_STRING char *fmt, ... ) = 0; + virtual void Printf( PRINTF_FORMAT_STRING const char *fmt, ... ) = 0; virtual float Knob( char *knobname, float *setvalue = NULL ) = 0; // Allows us to override the alpha write setting of a material virtual void OverrideAlphaWriteEnable( bool bEnable, bool bAlphaWriteEnable ) = 0; diff --git a/sp/src/public/headtrack/isourcevirtualreality.h b/mp/src/public/sourcevr/isourcevirtualreality.h similarity index 64% rename from sp/src/public/headtrack/isourcevirtualreality.h rename to mp/src/public/sourcevr/isourcevirtualreality.h index 291d28a6..3e438455 100644 --- a/sp/src/public/headtrack/isourcevirtualreality.h +++ b/mp/src/public/sourcevr/isourcevirtualreality.h @@ -21,21 +21,19 @@ //----------------------------------------------------------------------------- // forward declarations //----------------------------------------------------------------------------- +class ITexture; +class IMaterialSystem; //----------------------------------------------------------------------------- // important enumeration //----------------------------------------------------------------------------- -struct VRTrackerState_t + +struct VRRect_t { - // Tracker has finished starting up and has produced at least one valid pose. - bool bInitialized; - - // Tracker currently has a valid pose. - bool bHasValidPose; - - // Tracker is in a state where it is likely to suffer from yaw drift. This - // would apply to any gyro-only tracking system. - bool bWillDriftInYaw; + int32 nX; + int32 nY; + int32 nWidth; + int32 nHeight; }; @@ -69,6 +67,14 @@ public: VREye_Right }; + // Which texture is being requested in GetRenderTarget? + enum EWhichRenderTarget + { + RT_Color = 0, + RT_Depth, + }; + + // ---------------------------------------------------------------------- // General utilities // ---------------------------------------------------------------------- @@ -76,24 +82,17 @@ public: // Returns true if the game should run in VR mode virtual bool ShouldRunInVR() = 0; - // The name of the display at which the game should put its window. - // TODO: This is pretty horrible from a "what the game has to do" point - // of view. Make it better. - virtual const char *GetDisplayName() = 0; - - // The size of the window that the game should create - virtual bool GetWindowSize( int *pnWidth, int *pnHeight ) = 0; - - // Lets engine tell headtrack that it's going to use a different size window based - // what the display is actually using. This happens when somebody clones - // their desktop onto the HMD - virtual void OverrideWindowSize( int nWidth, int nHeight ) = 0; + // Returns true if there is a compatible HMD connected + virtual bool IsHmdConnected() = 0; // The size and position of the viewport for the specified eye virtual void GetViewportBounds( VREye eEye, int *pnX, int *pnY, int *pnWidth, int *pnHeight ) = 0; // Performs the distortion post-processing. - virtual bool DoDistortionProcessing ( const vrect_t *SrcRect ) = 0; + virtual bool DoDistortionProcessing ( VREye eEye ) = 0; + + // Composites the HUD directly onto the backbuffer / render target, including undistort. + virtual bool CompositeHud ( VREye eEye, float ndcHudBounds[4], bool bDoUndistort, bool bBlackout, bool bTranslucent ) = 0; // ---------------------------------------------------------------------- // Getting the current pose @@ -102,13 +101,6 @@ public: // returns the pose relative to the zero point virtual VMatrix GetMideyePose() = 0; - // returns the gravity-relative HUD correction matrix (I think) - virtual VMatrix GetHudUpCorrection() = 0; - - // transforms to mid eye form left/right - virtual VMatrix GetMidEyeFromLeft() = 0; - virtual VMatrix GetMidEyeFromRight() = 0; - // All-in-one interfaces (they call GetCameraPoseZeroFromCurrent) // Grabs the current tracking data and sets up state for the Override* calls. virtual bool SampleTrackingState ( float PlayerGameFov, float fPredictionSeconds ) = 0; @@ -117,41 +109,49 @@ public: // Information about the display // ---------------------------------------------------------------------- - // returns the serial number for the display or NULL if no serial number - // could be retrieved - virtual const char *GetDisplaySerialNumber() = 0; - - // returns the model number for the display or NULL if no model number - // could be retrieved - virtual const char *GetDisplayModelNumber() = 0; - - // returns the "ipd" of the display. This is the separation of the centers - // of the two lenses in mm - virtual float GetDisplaySeparationMM() = 0; + // Passes back the bounds of the window that the game should create. This might + // span two displays if we're dealing with a two-input display. Returns true + // if the bounds were set. + virtual bool GetDisplayBounds( VRRect_t *pRect ) = 0; // Computes and returns the projection matrix for the eye virtual bool GetEyeProjectionMatrix ( VMatrix *pResult, VREye, float zNear, float zFar, float fovScale ) = 0; - // Returns the horizontal FOV of the display in degrees - virtual float GetHorizontalFOVDegrees() = 0; - - // ---------------------------------------------------------------------- - // Information about the user - // ---------------------------------------------------------------------- - - // returns the intrapupilar distance of the user in mm - virtual float GetUserIPDMM() = 0; - - // sets the intrapupilar distance of the user in mm - virtual void SetUserIPDMM( float fIPDMM ) = 0; + // Returns the transform from the mid-eye to the specified eye. Multiply this by + // the tweaked (for mouse rotation and WASD translation) mideye position to get the + // view matrix. This matrix takes the user's IPD into account. + virtual VMatrix GetMidEyeFromEye( VREye eEye ) = 0; + // returns the adapter index to use for VR mode + virtual int GetVRModeAdapter() = 0; // ---------------------------------------------------------------------- // Information about the tracker // ---------------------------------------------------------------------- - // returns the state of the tracking system - virtual VRTrackerState_t GetTrackerState() = 0; + virtual bool WillDriftInYaw() = 0; + + // ---------------------------------------------------------------------- + // Methods about oversized offscreen rendering + // ---------------------------------------------------------------------- + + // Sets up the pre-distortion render targets. + virtual void CreateRenderTargets( IMaterialSystem *pMaterialSystem ) = 0; + virtual void ShutdownRenderTargets() = 0; + + // fetches the render target for the specified eye + virtual ITexture *GetRenderTarget( VREye eEye, EWhichRenderTarget eWhich ) = 0; + + // Returns the (possibly overridden) framebuffer size for render target sizing. + virtual void GetRenderTargetFrameBufferDimensions( int & nWidth, int & nHeight ) = 0; + + // ---------------------------------------------------------------------- + // Enter/leave VR mode + // ---------------------------------------------------------------------- + virtual bool Activate() = 0; + virtual void Deactivate() = 0; + + }; diff --git a/mp/src/public/studio.h b/mp/src/public/studio.h index 95f22a36..bcc38d5d 100644 --- a/mp/src/public/studio.h +++ b/mp/src/public/studio.h @@ -313,6 +313,63 @@ private: }; +//----------------------------------------------------------------------------- +// The component of the bone used by mstudioboneflexdriver_t +//----------------------------------------------------------------------------- +enum StudioBoneFlexComponent_t +{ + STUDIO_BONE_FLEX_INVALID = -1, // Invalid + STUDIO_BONE_FLEX_TX = 0, // Translate X + STUDIO_BONE_FLEX_TY = 1, // Translate Y + STUDIO_BONE_FLEX_TZ = 2 // Translate Z +}; + + +//----------------------------------------------------------------------------- +// Component is one of Translate X, Y or Z [0,2] (StudioBoneFlexComponent_t) +//----------------------------------------------------------------------------- +struct mstudioboneflexdrivercontrol_t +{ + DECLARE_BYTESWAP_DATADESC(); + + int m_nBoneComponent; // Bone component that drives flex, StudioBoneFlexComponent_t + int m_nFlexControllerIndex; // Flex controller to drive + float m_flMin; // Min value of bone component mapped to 0 on flex controller + float m_flMax; // Max value of bone component mapped to 1 on flex controller + + mstudioboneflexdrivercontrol_t(){} +private: + // No copy constructors allowed + mstudioboneflexdrivercontrol_t( const mstudioboneflexdrivercontrol_t &vOther ); +}; + + +//----------------------------------------------------------------------------- +// Drive flex controllers from bone components +//----------------------------------------------------------------------------- +struct mstudioboneflexdriver_t +{ + DECLARE_BYTESWAP_DATADESC(); + + int m_nBoneIndex; // Bone to drive flex controller + int m_nControlCount; // Number of flex controllers being driven + int m_nControlIndex; // Index into data where controllers are (relative to this) + + inline mstudioboneflexdrivercontrol_t *pBoneFlexDriverControl( int i ) const + { + Assert( i >= 0 && i < m_nControlCount ); + return (mstudioboneflexdrivercontrol_t *)(((byte *)this) + m_nControlIndex) + i; + } + + int unused[3]; + + mstudioboneflexdriver_t(){} +private: + // No copy constructors allowed + mstudioboneflexdriver_t( const mstudioboneflexdriver_t &vOther ); +}; + + #define BONE_CALCULATE_MASK 0x1F #define BONE_PHYSICALLY_SIMULATED 0x01 // bone is physically simulated when physics are active #define BONE_PHYSICS_PROCEDURAL 0x02 // procedural when physics is active @@ -902,33 +959,6 @@ struct mstudioflexcontrollerui_t }; -// these are the on-disk format vertex anims -struct dstudiovertanim_t -{ - unsigned short index; - byte speed; // 255/max_length_in_flex - byte side; // 255/left_right - Vector48 delta; - Vector48 ndelta; - -private: - // No copy constructors allowed - dstudiovertanim_t(const dstudiovertanim_t& vOther); -}; - - -struct dstudiovertanim_wrinkle_t : public dstudiovertanim_t -{ - short wrinkledelta; // Encodes a range from -1 to 1. NOTE: -32768 == -32767 == -1.0f, 32767 = 1.0f - -private: - // No copy constructors allowed - dstudiovertanim_wrinkle_t( const dstudiovertanim_t& vOther ); -}; - -const float g_VertAnimFixedPointScale = 1.0f / 4096.0f; -const float g_VertAnimFixedPointScaleInv = 1.0f / g_VertAnimFixedPointScale; - // this is the memory image of vertex anims (16-bit fixed point) struct mstudiovertanim_t { @@ -952,21 +982,31 @@ protected: }; public: - inline Vector GetDeltaFixed() + inline void ConvertToFixed( float flVertAnimFixedPointScale ) { - return Vector( delta[0]*g_VertAnimFixedPointScale, delta[1]*g_VertAnimFixedPointScale, delta[2]*g_VertAnimFixedPointScale ); + delta[0] = flDelta[0].GetFloat() / flVertAnimFixedPointScale; + delta[1] = flDelta[1].GetFloat() / flVertAnimFixedPointScale; + delta[2] = flDelta[2].GetFloat() / flVertAnimFixedPointScale; + ndelta[0] = flNDelta[0].GetFloat() / flVertAnimFixedPointScale; + ndelta[1] = flNDelta[1].GetFloat() / flVertAnimFixedPointScale; + ndelta[2] = flNDelta[2].GetFloat() / flVertAnimFixedPointScale; } - inline Vector GetNDeltaFixed() + + inline Vector GetDeltaFixed( float flVertAnimFixedPointScale ) { - return Vector( ndelta[0]*g_VertAnimFixedPointScale, ndelta[1]*g_VertAnimFixedPointScale, ndelta[2]*g_VertAnimFixedPointScale ); + return Vector( delta[0] * flVertAnimFixedPointScale, delta[1] * flVertAnimFixedPointScale, delta[2] * flVertAnimFixedPointScale ); } - inline void GetDeltaFixed4DAligned( Vector4DAligned *vFillIn ) + inline Vector GetNDeltaFixed( float flVertAnimFixedPointScale ) { - vFillIn->Set( delta[0]*g_VertAnimFixedPointScale, delta[1]*g_VertAnimFixedPointScale, delta[2]*g_VertAnimFixedPointScale, 0.0f ); + return Vector( ndelta[0] * flVertAnimFixedPointScale, ndelta[1] * flVertAnimFixedPointScale, ndelta[2] * flVertAnimFixedPointScale ); } - inline void GetNDeltaFixed4DAligned( Vector4DAligned *vFillIn ) + inline void GetDeltaFixed4DAligned( Vector4DAligned *vFillIn, float flVertAnimFixedPointScale ) { - vFillIn->Set( ndelta[0]*g_VertAnimFixedPointScale, ndelta[1]*g_VertAnimFixedPointScale, ndelta[2]*g_VertAnimFixedPointScale, 0.0f ); + vFillIn->Set( delta[0] * flVertAnimFixedPointScale, delta[1] * flVertAnimFixedPointScale, delta[2] * flVertAnimFixedPointScale, 0.0f ); + } + inline void GetNDeltaFixed4DAligned( Vector4DAligned *vFillIn, float flVertAnimFixedPointScale ) + { + vFillIn->Set( ndelta[0] * flVertAnimFixedPointScale, ndelta[1] * flVertAnimFixedPointScale, ndelta[2] * flVertAnimFixedPointScale, 0.0f ); } inline Vector GetDeltaFloat() { @@ -976,17 +1016,17 @@ public: { return Vector (flNDelta[0].GetFloat(), flNDelta[1].GetFloat(), flNDelta[2].GetFloat()); } - inline void SetDeltaFixed( const Vector& vInput ) + inline void SetDeltaFixed( const Vector& vInput, float flVertAnimFixedPointScale ) { - delta[0] = vInput.x * g_VertAnimFixedPointScaleInv; - delta[1] = vInput.y * g_VertAnimFixedPointScaleInv; - delta[2] = vInput.z * g_VertAnimFixedPointScaleInv; + delta[0] = vInput.x / flVertAnimFixedPointScale; + delta[1] = vInput.y / flVertAnimFixedPointScale; + delta[2] = vInput.z / flVertAnimFixedPointScale; } - inline void SetNDeltaFixed( const Vector& vInputNormal ) + inline void SetNDeltaFixed( const Vector& vInputNormal, float flVertAnimFixedPointScale ) { - ndelta[0] = vInputNormal.x * g_VertAnimFixedPointScaleInv; - ndelta[1] = vInputNormal.y * g_VertAnimFixedPointScaleInv; - ndelta[2] = vInputNormal.z * g_VertAnimFixedPointScaleInv; + ndelta[0] = vInputNormal.x / flVertAnimFixedPointScale; + ndelta[1] = vInputNormal.y / flVertAnimFixedPointScale; + ndelta[2] = vInputNormal.z / flVertAnimFixedPointScale; } // Ick...can also force fp16 data into this structure for writing to file in legacy format... @@ -1003,10 +1043,20 @@ public: flNDelta[2].SetFloat( vInputNormal.z ); } + class CSortByIndex + { + public: + bool operator()(const mstudiovertanim_t &left, const mstudiovertanim_t & right)const + { + return left.index < right.index; + } + }; + friend class CSortByIndex; + mstudiovertanim_t(){} -private: - // No copy constructors allowed - mstudiovertanim_t(const mstudiovertanim_t& vOther); +//private: +// No copy constructors allowed, but it's needed for std::sort() +// mstudiovertanim_t(const mstudiovertanim_t& vOther); }; @@ -1017,20 +1067,25 @@ struct mstudiovertanim_wrinkle_t : public mstudiovertanim_t short wrinkledelta; - inline void SetWrinkleFixed( float flWrinkle ) + inline void SetWrinkleFixed( float flWrinkle, float flVertAnimFixedPointScale ) { - int nWrinkleDeltaInt = flWrinkle * g_VertAnimFixedPointScaleInv; + int nWrinkleDeltaInt = flWrinkle / flVertAnimFixedPointScale; wrinkledelta = clamp( nWrinkleDeltaInt, -32767, 32767 ); } - inline Vector4D GetDeltaFixed() + inline Vector4D GetDeltaFixed( float flVertAnimFixedPointScale ) { - return Vector4D( delta[0]*g_VertAnimFixedPointScale, delta[1]*g_VertAnimFixedPointScale, delta[2]*g_VertAnimFixedPointScale, wrinkledelta*g_VertAnimFixedPointScale ); + return Vector4D( delta[0] * flVertAnimFixedPointScale, delta[1] * flVertAnimFixedPointScale, delta[2] * flVertAnimFixedPointScale, wrinkledelta * flVertAnimFixedPointScale ); } - inline void GetDeltaFixed4DAligned( Vector4DAligned *vFillIn ) + inline void GetDeltaFixed4DAligned( Vector4DAligned *vFillIn, float flVertAnimFixedPointScale ) { - vFillIn->Set( delta[0]*g_VertAnimFixedPointScale, delta[1]*g_VertAnimFixedPointScale, delta[2]*g_VertAnimFixedPointScale, wrinkledelta*g_VertAnimFixedPointScale ); + vFillIn->Set( delta[0] * flVertAnimFixedPointScale, delta[1] * flVertAnimFixedPointScale, delta[2] * flVertAnimFixedPointScale, wrinkledelta * flVertAnimFixedPointScale ); + } + + inline float GetWrinkleDeltaFixed( float flVertAnimFixedPointScale ) + { + return wrinkledelta * flVertAnimFixedPointScale; } }; @@ -1959,6 +2014,9 @@ struct vertexFileFixup_t #define STUDIOHDR_FLAGS_CAST_TEXTURE_SHADOWS ( 1 << 18 ) +// flagged on load to indicate no animation events on this model +#define STUDIOHDR_FLAGS_VERT_ANIM_FIXED_POINT_SCALE ( 1 << 21 ) + // NOTE! Next time we up the .mdl file format, remove studiohdr2_t // and insert all fields in this structure into studiohdr_t. struct studiohdr2_t @@ -1982,7 +2040,11 @@ struct studiohdr2_t int sznameindex; inline char *pszName() { return (sznameindex) ? (char *)(((byte *)this) + sznameindex ) : NULL; } - int reserved[58]; + int m_nBoneFlexDriverCount; + int m_nBoneFlexDriverIndex; + inline mstudioboneflexdriver_t *pBoneFlexDriver( int i ) const { Assert( i >= 0 && i < m_nBoneFlexDriverCount ); return (mstudioboneflexdriver_t *)(((byte *)this) + m_nBoneFlexDriverIndex) + i; } + + int reserved[56]; }; struct studiohdr_t @@ -2229,7 +2291,10 @@ struct studiohdr_t int flexcontrolleruiindex; mstudioflexcontrollerui_t *pFlexControllerUI( int i ) const { Assert( i >= 0 && i < numflexcontrollerui); return (mstudioflexcontrollerui_t *)(((byte *)this) + flexcontrolleruiindex) + i; } - int unused3[2]; + float flVertAnimFixedPointScale; + inline float VertAnimFixedPointScale() const { return ( flags & STUDIOHDR_FLAGS_VERT_ANIM_FIXED_POINT_SCALE ) ? flVertAnimFixedPointScale : 1.0f / 4096.0f; } + + int unused3[1]; // FIXME: Remove when we up the model version. Move all fields of studiohdr2_t into studiohdr_t. int studiohdr2index; @@ -2245,6 +2310,9 @@ struct studiohdr_t inline mstudiolinearbone_t *pLinearBones() const { return studiohdr2index ? pStudioHdr2()->pLinearBones() : NULL; } + inline int BoneFlexDriverCount() const { return studiohdr2index ? pStudioHdr2()->m_nBoneFlexDriverCount : 0; } + inline const mstudioboneflexdriver_t* BoneFlexDriver( int i ) const { Assert( i >= 0 && i < BoneFlexDriverCount() ); return studiohdr2index ? pStudioHdr2()->pBoneFlexDriver( i ) : NULL; } + // NOTE: No room to add stuff? Up the .mdl file format version // [and move all fields in studiohdr2_t into studiohdr_t and kill studiohdr2_t], // or add your stuff to studiohdr2_t. See NumSrcBoneTransforms/SrcBoneTransform for the pattern to use. @@ -2404,6 +2472,11 @@ public: inline mstudiolinearbone_t *pLinearBones() const { return m_pStudioHdr->pLinearBones(); } + inline int BoneFlexDriverCount() const { return m_pStudioHdr->BoneFlexDriverCount(); } + inline const mstudioboneflexdriver_t *BoneFlexDriver( int i ) const { return m_pStudioHdr->BoneFlexDriver( i ); } + + inline float VertAnimFixedPointScale() const { return m_pStudioHdr->VertAnimFixedPointScale(); } + public: int IsSequenceLooping( int iSequence ); float GetSequenceCycleRate( int iSequence ); @@ -2971,6 +3044,9 @@ inline void Studio_SetRootLOD( studiohdr_t *pStudioHdr, int rootLOD ) rootLOD = pStudioHdr->numAllowedRootLODs - 1; } + Assert( rootLOD >= 0 && rootLOD < MAX_NUM_LODS ); + Clamp( rootLOD, 0, MAX_NUM_LODS - 1 ); + // run the lod fixups that culls higher detail lods // vertexes are external, fixups ensure relative offsets and counts are cognizant of shrinking data // indexes are built in lodN..lod0 order so higher detail lod data can be truncated at load diff --git a/mp/src/public/tier0/afxmem_override.cpp b/mp/src/public/tier0/afxmem_override.cpp index 425cabd8..f5794b27 100644 --- a/mp/src/public/tier0/afxmem_override.cpp +++ b/mp/src/public/tier0/afxmem_override.cpp @@ -429,8 +429,7 @@ void* __cdecl operator new(size_t nSize, int nType, LPCSTR lpszFileName, int nLi #endif } -#if 0 -#if _MSC_VER >= 1200 +#if _MSC_VER >= 1700 void __cdecl operator delete(void* p, int nType, LPCSTR /* lpszFileName */, int /* nLine */) { #if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG) @@ -440,19 +439,16 @@ void __cdecl operator delete(void* p, int nType, LPCSTR /* lpszFileName */, int #endif } #endif // _MSC_VER >= 1200 -#endif -#if _MSC_VER >= 1210 +#if _MSC_VER >= 1700 void* __cdecl operator new[](size_t nSize, int nType, LPCSTR lpszFileName, int nLine) { return ::operator new(nSize, nType, lpszFileName, nLine); } -#if 0 void __cdecl operator delete[](void* p, int nType, LPCSTR lpszFileName, int nLine) { ::operator delete(p, nType, lpszFileName, nLine); } -#endif #endif // _MSC_VER >= 1210 #endif //_DEBUG diff --git a/mp/src/public/tier0/dbg.h b/mp/src/public/tier0/dbg.h index ac7930a4..5fe45a1c 100644 --- a/mp/src/public/tier0/dbg.h +++ b/mp/src/public/tier0/dbg.h @@ -247,8 +247,8 @@ DBG_INTERFACE struct SDL_Window * GetAssertDialogParent(); if (!(_exp)) \ { \ _SpewInfo( SPEW_ASSERT, __TFILE__, __LINE__ ); \ - SpewRetval_t ret = _SpewMessage("%s", _msg); \ - CallAssertFailedNotifyFunc( __TFILE__, __LINE__, _msg ); \ + SpewRetval_t ret = _SpewMessage("%s", static_cast( _msg )); \ + CallAssertFailedNotifyFunc( __TFILE__, __LINE__, _msg ); \ _executeExp; \ if ( ret == SPEW_DEBUGGER) \ { \ @@ -343,6 +343,9 @@ DBG_INTERFACE struct SDL_Window * GetAssertDialogParent(); #define AssertEquals( _exp, _expectedValue ) AssertMsg2( (_exp) == (_expectedValue), _T("Expected %d but got %d!"), (_expectedValue), (_exp) ) #define AssertFloatEquals( _exp, _expectedValue, _tol ) AssertMsg2( fabs((_exp) - (_expectedValue)) <= (_tol), _T("Expected %f but got %f!"), (_expectedValue), (_exp) ) #define Verify( _exp ) Assert( _exp ) +#define VerifyMsg1( _exp, _msg, a1 ) AssertMsg1( _exp, _msg, a1 ) +#define VerifyMsg2( _exp, _msg, a1, a2 ) AssertMsg2( _exp, _msg, a1, a2 ) +#define VerifyMsg3( _exp, _msg, a1, a2, a3 ) AssertMsg3( _exp, _msg, a1, a2, a3 ) #define VerifyEquals( _exp, _expectedValue ) AssertEquals( _exp, _expectedValue ) #define DbgVerify( _exp ) Assert( _exp ) @@ -366,6 +369,9 @@ DBG_INTERFACE struct SDL_Window * GetAssertDialogParent(); #define AssertEquals( _exp, _expectedValue ) ((void)0) #define AssertFloatEquals( _exp, _expectedValue, _tol ) ((void)0) #define Verify( _exp ) (_exp) +#define VerifyMsg1( _exp, _msg, a1 ) (_exp) +#define VerifyMsg2( _exp, _msg, a1, a2 ) (_exp) +#define VerifyMsg3( _exp, _msg, a1, a2, a3 ) (_exp) #define VerifyEquals( _exp, _expectedValue ) (_exp) #define DbgVerify( _exp ) (_exp) diff --git a/mp/src/public/tier1/fmtstr.h b/mp/src/public/tier1/fmtstr.h index 8c9ccf47..31ee23c7 100644 --- a/mp/src/public/tier1/fmtstr.h +++ b/mp/src/public/tier1/fmtstr.h @@ -125,7 +125,42 @@ public: } void AppendFormatV( const char *pchFormat, va_list args ); - void Append( const char *pchValue ) { AppendFormat( "%s", pchValue ); } + + void Append( const char *pchValue ) + { + // This function is close to the metal to cut down on the CPU cost + // of the previous incantation of Append which was implemented as + // AppendFormat( "%s", pchValue ). This implementation, though not + // as easy to read, instead does a strcpy from the existing end + // point of the CFmtStrN. This brings something like a 10-20x speedup + // in my rudimentary tests. It isn't using V_strncpy because that + // function doesn't return the number of characters copied, which + // we need to adjust m_nLength. Doing the V_strncpy with a V_strlen + // afterwards took twice as long as this implementations in tests, + // so V_strncpy's implementation was used to write this method. + char *pDest = m_szBuf + m_nLength; + const int maxLen = SIZE_BUF - m_nLength; + char *pLast = pDest + maxLen - 1; + while ( (pDest < pLast) && (*pchValue != 0) ) + { + *pDest = *pchValue; + ++pDest; ++pchValue; + } + *pDest = 0; + m_nLength = pDest - m_szBuf; + } + + //optimized version of append for just adding a single character + void Append( char ch ) + { + if( m_nLength < SIZE_BUF - 1 ) + { + m_szBuf[ m_nLength ] = ch; + m_nLength++; + m_szBuf[ m_nLength ] = '\0'; + } + } + void AppendIndent( uint32 unCount, char chIndent = '\t' ); protected: @@ -193,6 +228,84 @@ typedef CFmtStrQuietTruncationN CFmtStrQuietTruncation; typedef CFmtStrN<1024> CFmtStr1024; typedef CFmtStrN<8192> CFmtStrMax; + +//----------------------------------------------------------------------------- +// Purpose: Fast-path number-to-string helper (with optional quoting) +// Derived off of the Steam CNumStr but with a few tweaks, such as +// trimming off the in-our-cases-unnecessary strlen calls (by not +// storing the length in the class). +//----------------------------------------------------------------------------- + +class CNumStr +{ +public: + CNumStr() { m_szBuf[0] = 0; } + + explicit CNumStr( bool b ) { SetBool( b ); } + + explicit CNumStr( int8 n8 ) { SetInt8( n8 ); } + explicit CNumStr( uint8 un8 ) { SetUint8( un8 ); } + explicit CNumStr( int16 n16 ) { SetInt16( n16 ); } + explicit CNumStr( uint16 un16 ) { SetUint16( un16 ); } + explicit CNumStr( int32 n32 ) { SetInt32( n32 ); } + explicit CNumStr( uint32 un32 ) { SetUint32( un32 ); } + explicit CNumStr( int64 n64 ) { SetInt64( n64 ); } + explicit CNumStr( uint64 un64 ) { SetUint64( un64 ); } + +#if defined(COMPILER_GCC) && defined(PLATFORM_64BITS) + explicit CNumStr( lint64 n64 ) { SetInt64( (int64)n64 ); } + explicit CNumStr( ulint64 un64 ) { SetUint64( (uint64)un64 ); } +#endif + + explicit CNumStr( double f ) { SetDouble( f ); } + explicit CNumStr( float f ) { SetFloat( f ); } + + inline void SetBool( bool b ) { Q_memcpy( m_szBuf, b ? "1" : "0", 2 ); } + +#ifdef _WIN32 + inline void SetInt8( int8 n8 ) { _itoa( (int32)n8, m_szBuf, 10 ); } + inline void SetUint8( uint8 un8 ) { _itoa( (int32)un8, m_szBuf, 10 ); } + inline void SetInt16( int16 n16 ) { _itoa( (int32)n16, m_szBuf, 10 ); } + inline void SetUint16( uint16 un16 ) { _itoa( (int32)un16, m_szBuf, 10 ); } + inline void SetInt32( int32 n32 ) { _itoa( n32, m_szBuf, 10 ); } + inline void SetUint32( uint32 un32 ) { _i64toa( (int64)un32, m_szBuf, 10 ); } + inline void SetInt64( int64 n64 ) { _i64toa( n64, m_szBuf, 10 ); } + inline void SetUint64( uint64 un64 ) { _ui64toa( un64, m_szBuf, 10 ); } +#else + inline void SetInt8( int8 n8 ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%d", (int32)n8 ); } + inline void SetUint8( uint8 un8 ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%d", (int32)un8 ); } + inline void SetInt16( int16 n16 ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%d", (int32)n16 ); } + inline void SetUint16( uint16 un16 ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%d", (int32)un16 ); } + inline void SetInt32( int32 n32 ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%d", n32 ); } + inline void SetUint32( uint32 un32 ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%u", un32 ); } + inline void SetInt64( int64 n64 ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%lld", n64 ); } + inline void SetUint64( uint64 un64 ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%llu", un64 ); } +#endif + + inline void SetDouble( double f ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%.18g", f ); } + inline void SetFloat( float f ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%.18g", f ); } + + inline void SetHexUint64( uint64 un64 ) { Q_binarytohex( (byte *)&un64, sizeof( un64 ), m_szBuf, sizeof( m_szBuf ) ); } + + operator const char *() const { return m_szBuf; } + const char* String() const { return m_szBuf; } + + void AddQuotes() + { + Assert( m_szBuf[0] != '"' ); + const int nLength = Q_strlen( m_szBuf ); + Q_memmove( m_szBuf + 1, m_szBuf, nLength ); + m_szBuf[0] = '"'; + m_szBuf[nLength + 1] = '"'; + m_szBuf[nLength + 2] = 0; + } + +protected: + char m_szBuf[28]; // long enough to hold 18 digits of precision, a decimal, a - sign, e+### suffix, and quotes + +}; + + //============================================================================= bool BGetLocalFormattedDateAndTime( time_t timeVal, char *pchDate, int cubDate, char *pchTime, int cubTime ); diff --git a/mp/src/public/togl/osx/cglmbuffer.h b/mp/src/public/togl/osx/cglmbuffer.h index 0b161000..24a0b0fa 100644 --- a/mp/src/public/togl/osx/cglmbuffer.h +++ b/mp/src/public/togl/osx/cglmbuffer.h @@ -1,99 +1,99 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// -// cglmprogram.h -// GLMgr buffers (index / vertex) -// ... maybe add PBO later as well -//=============================================================================== - -#ifndef CGLMBUFFER_H -#define CGLMBUFFER_H - -#pragma once - -// ext links - -// http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt - -//=============================================================================== - -// tokens not in the SDK headers - -//#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT -// #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9 -//#endif - -//=============================================================================== - -// forward declarations - -class GLMContext; - -enum EGLMBufferType -{ - kGLMVertexBuffer, - kGLMIndexBuffer, - kGLMUniformBuffer, // for bindable uniform - kGLMPixelBuffer, // for PBO - - kGLMNumBufferTypes -}; - - // pass this in "options" to constructor to make a dynamic buffer -#define GLMBufferOptionDynamic 0x00000001 - -struct GLMBuffLockParams -{ - uint m_offset; - uint m_size; - bool m_nonblocking; - bool m_discard; -}; - -class CGLMBuffer -{ - -public: - void Lock( GLMBuffLockParams *params, char **addressOut ); - void Unlock( void ); - -//protected: - friend class GLMContext; // only GLMContext can make CGLMBuffer objects - friend class GLMTester; - friend class IDirect3D9; - friend class IDirect3DDevice9; - - CGLMBuffer ( GLMContext *ctx, EGLMBufferType type, uint size, uint options ); - ~CGLMBuffer ( ); - - void SetModes ( bool asyncMap, bool explicitFlush, bool force = false ); - void FlushRange ( uint offset, uint size ); - - GLMContext *m_ctx; // link back to parent context - EGLMBufferType m_type; - uint m_size; - GLenum m_buffGLTarget; // GL_ARRAY_BUFFER_ARB / GL_ELEMENT_BUFFER_ARB - GLuint m_name; // name of this program in the context - uint m_revision; // bump anytime the size changes or buffer is orphaned - bool m_enableAsyncMap; // mirror of the buffer state - bool m_enableExplicitFlush; // mirror of the buffer state - - bool m_bound; // true if bound to context - bool m_mapped; // is it currently mapped - uint m_dirtyMinOffset; // when equal, range is empty - uint m_dirtyMaxOffset; - - float *m_lastMappedAddress; - - // --------------------- pseudo-VBO support below here (explicitly for dynamic index buffers) - bool m_pseudo; // true if the m_name is 0, and the backing is plain RAM - - // in pseudo mode, there is just one RAM buffer that acts as the backing. - // expectation is that this mode would only be used for dynamic indices. - // since indices have to be consumed (copied to command stream) prior to return from a drawing call, - // there's no need to do any fencing or multibuffering. orphaning in particular becomes a no-op. - - char *m_pseudoBuf; // storage for pseudo buffer -}; - - +// +// cglmprogram.h +// GLMgr buffers (index / vertex) +// ... maybe add PBO later as well +//=============================================================================== + +#ifndef CGLMBUFFER_H +#define CGLMBUFFER_H + +#pragma once + +// ext links + +// http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt + +//=============================================================================== + +// tokens not in the SDK headers + +//#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT +// #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9 +//#endif + +//=============================================================================== + +// forward declarations + +class GLMContext; + +enum EGLMBufferType +{ + kGLMVertexBuffer, + kGLMIndexBuffer, + kGLMUniformBuffer, // for bindable uniform + kGLMPixelBuffer, // for PBO + + kGLMNumBufferTypes +}; + + // pass this in "options" to constructor to make a dynamic buffer +#define GLMBufferOptionDynamic 0x00000001 + +struct GLMBuffLockParams +{ + uint m_offset; + uint m_size; + bool m_nonblocking; + bool m_discard; +}; + +class CGLMBuffer +{ + +public: + void Lock( GLMBuffLockParams *params, char **addressOut ); + void Unlock( void ); + +//protected: + friend class GLMContext; // only GLMContext can make CGLMBuffer objects + friend class GLMTester; + friend class IDirect3D9; + friend class IDirect3DDevice9; + + CGLMBuffer ( GLMContext *ctx, EGLMBufferType type, uint size, uint options ); + ~CGLMBuffer ( ); + + void SetModes ( bool asyncMap, bool explicitFlush, bool force = false ); + void FlushRange ( uint offset, uint size ); + + GLMContext *m_ctx; // link back to parent context + EGLMBufferType m_type; + uint m_size; + GLenum m_buffGLTarget; // GL_ARRAY_BUFFER_ARB / GL_ELEMENT_BUFFER_ARB + GLuint m_name; // name of this program in the context + uint m_revision; // bump anytime the size changes or buffer is orphaned + bool m_enableAsyncMap; // mirror of the buffer state + bool m_enableExplicitFlush; // mirror of the buffer state + + bool m_bound; // true if bound to context + bool m_mapped; // is it currently mapped + uint m_dirtyMinOffset; // when equal, range is empty + uint m_dirtyMaxOffset; + + float *m_lastMappedAddress; + + // --------------------- pseudo-VBO support below here (explicitly for dynamic index buffers) + bool m_pseudo; // true if the m_name is 0, and the backing is plain RAM + + // in pseudo mode, there is just one RAM buffer that acts as the backing. + // expectation is that this mode would only be used for dynamic indices. + // since indices have to be consumed (copied to command stream) prior to return from a drawing call, + // there's no need to do any fencing or multibuffering. orphaning in particular becomes a no-op. + + char *m_pseudoBuf; // storage for pseudo buffer +}; + + #endif \ No newline at end of file diff --git a/mp/src/public/togl/osx/cglmfbo.h b/mp/src/public/togl/osx/cglmfbo.h index ccf3e970..c94bac70 100644 --- a/mp/src/public/togl/osx/cglmfbo.h +++ b/mp/src/public/togl/osx/cglmfbo.h @@ -1,91 +1,91 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// -// cglmfbo.h -// GLMgr FBO's (render targets) -// -//=============================================================================== - -#ifndef CGLMFBO_H -#define CGLMFBO_H - -#pragma once - -#include "togl/rendermechanism.h" - -// good FBO references / recaps -// http://www.songho.ca/opengl/gl_fbo.html -// http://www.gamedev.net/reference/articles/article2331.asp - -// ext links - -// http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt -// http://www.opengl.org/registry/specs/EXT/framebuffer_multisample.txt - -//=============================================================================== - -// tokens not in the SDK headers - -#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT - #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9 -#endif - -//=============================================================================== - -// forward declarations - -class GLMContext; - -// implicitly 16 maximum color attachments possible -enum EGLMFBOAttachment { - kAttColor0, kAttColor1, kAttColor2, kAttColor3, - kAttColor4, kAttColor5, kAttColor6, kAttColor7, - kAttColor8, kAttColor9, kAttColor10, kAttColor11, - kAttColor12, kAttColor13, kAttColor14, kAttColor15, - kAttDepth, kAttStencil, kAttDepthStencil, - kAttCount -}; - -struct GLMFBOTexAttachParams -{ - CGLMTex *m_tex; - int m_face; // keep zero if not cube map - int m_mip; // keep zero if notmip mapped - int m_zslice; // keep zero if not a 3D tex -}; - -class CGLMFBO -{ - -public: - -protected: - friend class GLMContext; // only GLMContext can make CGLMFBO objects - friend class GLMTester; - friend class CGLMTex; - - friend class IDirect3D9; - friend class IDirect3DDevice9; - - CGLMFBO( GLMContext *ctx ); - ~CGLMFBO( ); - - void TexAttach( GLMFBOTexAttachParams *params, EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT ); - void TexDetach( EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT ); - // you can also pass GL_READ_FRAMEBUFFER_EXT or GL_DRAW_FRAMEBUFFER_EXT to selectively bind the receiving FBO to one or the other. - - void TexScrub( CGLMTex *tex ); - // search and destroy any attachment for the named texture - - bool IsReady( void ); // aka FBO completeness check - ready to draw - - GLMContext *m_ctx; // link back to parent context - - GLuint m_name; // name of this FBO in the context - - GLMFBOTexAttachParams m_attach[ kAttCount ]; // indexed by EGLMFBOAttachment - - int m_sizeX,m_sizeY; -}; - - -#endif +// +// cglmfbo.h +// GLMgr FBO's (render targets) +// +//=============================================================================== + +#ifndef CGLMFBO_H +#define CGLMFBO_H + +#pragma once + +#include "togl/rendermechanism.h" + +// good FBO references / recaps +// http://www.songho.ca/opengl/gl_fbo.html +// http://www.gamedev.net/reference/articles/article2331.asp + +// ext links + +// http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt +// http://www.opengl.org/registry/specs/EXT/framebuffer_multisample.txt + +//=============================================================================== + +// tokens not in the SDK headers + +#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT + #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9 +#endif + +//=============================================================================== + +// forward declarations + +class GLMContext; + +// implicitly 16 maximum color attachments possible +enum EGLMFBOAttachment { + kAttColor0, kAttColor1, kAttColor2, kAttColor3, + kAttColor4, kAttColor5, kAttColor6, kAttColor7, + kAttColor8, kAttColor9, kAttColor10, kAttColor11, + kAttColor12, kAttColor13, kAttColor14, kAttColor15, + kAttDepth, kAttStencil, kAttDepthStencil, + kAttCount +}; + +struct GLMFBOTexAttachParams +{ + CGLMTex *m_tex; + int m_face; // keep zero if not cube map + int m_mip; // keep zero if notmip mapped + int m_zslice; // keep zero if not a 3D tex +}; + +class CGLMFBO +{ + +public: + +protected: + friend class GLMContext; // only GLMContext can make CGLMFBO objects + friend class GLMTester; + friend class CGLMTex; + + friend class IDirect3D9; + friend class IDirect3DDevice9; + + CGLMFBO( GLMContext *ctx ); + ~CGLMFBO( ); + + void TexAttach( GLMFBOTexAttachParams *params, EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT ); + void TexDetach( EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT ); + // you can also pass GL_READ_FRAMEBUFFER_EXT or GL_DRAW_FRAMEBUFFER_EXT to selectively bind the receiving FBO to one or the other. + + void TexScrub( CGLMTex *tex ); + // search and destroy any attachment for the named texture + + bool IsReady( void ); // aka FBO completeness check - ready to draw + + GLMContext *m_ctx; // link back to parent context + + GLuint m_name; // name of this FBO in the context + + GLMFBOTexAttachParams m_attach[ kAttCount ]; // indexed by EGLMFBOAttachment + + int m_sizeX,m_sizeY; +}; + + +#endif diff --git a/mp/src/public/togl/osx/cglmprogram.h b/mp/src/public/togl/osx/cglmprogram.h index ee7f4de2..3b1b4d86 100644 --- a/mp/src/public/togl/osx/cglmprogram.h +++ b/mp/src/public/togl/osx/cglmprogram.h @@ -1,291 +1,291 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// -// cglmprogram.h -// GLMgr programs (ARBVP/ARBfp) -// -//=============================================================================== - -#ifndef CGLMPROGRAM_H -#define CGLMPROGRAM_H - -#include - -#pragma once - -// good ARB program references -// http://petewarden.com/notes/archives/2005/05/fragment_progra_2.html -// http://petewarden.com/notes/archives/2005/06/fragment_progra_3.html - -// ext links - -// http://www.opengl.org/registry/specs/ARB/vertex_program.txt -// http://www.opengl.org/registry/specs/ARB/fragment_program.txt -// http://www.opengl.org/registry/specs/EXT/gpu_program_parameters.txt - - -//=============================================================================== - -// tokens not in the SDK headers - -//#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT -// #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9 -//#endif - -//=============================================================================== - -// forward declarations - -class GLMContext; -class CGLMShaderPair; -class CGLMShaderPairCache; - -// CGLMProgram can contain two flavors of the same program, one in assembler, one in GLSL. -// these flavors are pretty different in terms of the API's that are used to activate them - -// for example, assembler programs can just get bound to the context, whereas GLSL programs -// have to be linked. To some extent we try to hide that detail inside GLM. - -// for now, make CGLMProgram a container, it does not set policy or hold a preference as to which -// flavor you want to use. GLMContext has to handle that. - -enum EGLMProgramType -{ - kGLMVertexProgram, - kGLMFragmentProgram, - - kGLMNumProgramTypes -}; - -enum EGLMProgramLang -{ - kGLMARB, - kGLMGLSL, - - kGLMNumProgramLangs -}; - -struct GLMShaderDesc -{ - union - { - GLuint arb; // ARB program object name - GLhandleARB glsl; // GLSL shader object handle (void*) - } m_object; - - // these can change if shader text is edited - bool m_textPresent; // is this flavor(lang) of text present in the buffer? - int m_textOffset; // where is it - int m_textLength; // how big - - bool m_compiled; // has this text been through a compile attempt - bool m_valid; // and if so, was the compile successful - - int m_slowMark; // has it been flagged during a non native draw batch before. increment every time it's slow. - - int m_highWater; // vount of vec4's in the major uniform array ("vc" on vs, "pc" on ps) - // written by dxabstract.... gross! -}; - -GLenum GLMProgTypeToARBEnum( EGLMProgramType type ); // map vert/frag to ARB asm bind target -GLenum GLMProgTypeToGLSLEnum( EGLMProgramType type ); // map vert/frag to ARB asm bind target - -class CGLMProgram -{ -public: - friend class CGLMShaderPairCache; - friend class CGLMShaderPair; - friend class GLMContext; // only GLMContext can make CGLMProgram objects - friend class GLMTester; - friend class IDirect3D9; - friend class IDirect3DDevice9; - - //=============================== - - // constructor is very light, it just makes one empty program object per flavor. - CGLMProgram( GLMContext *ctx, EGLMProgramType type ); - ~CGLMProgram( ); - - void SetProgramText ( char *text ); // import text to GLM object - invalidate any prev compiled program - - bool CompileActiveSources ( void ); // compile only the flavors that were provided. - bool Compile ( EGLMProgramLang lang ); - bool CheckValidity ( EGLMProgramLang lang ); - - void LogSlow ( EGLMProgramLang lang ); // detailed spew when called for first time; one liner or perhaps silence after that - - void GetLabelIndexCombo ( char *labelOut, int labelOutMaxChars, int *indexOut, int *comboOut ); - void GetComboIndexNameString ( char *stringOut, int stringOutMaxChars ); // mmmmmmmm-nnnnnnnn-filename - -#if GLMDEBUG - bool PollForChanges( void ); // check mirror for changes. - void ReloadStringFromEditable( void ); // populate m_string from editable item (react to change) - bool SyncWithEditable( void ); -#endif - - //=============================== - - // common stuff - - GLMContext *m_ctx; // link back to parent context - - EGLMProgramType m_type; // vertex or pixel - - uint m_serial; // serial number for hashing - - char *m_text; // copy of text passed into constructor. Can change if editable shaders is enabled. - // note - it can contain multiple flavors, so use CGLMTextSectioner to scan it and locate them -#if GLMDEBUG - CGLMEditableTextItem *m_editable; // editable text item for debugging -#endif - - GLMShaderDesc m_descs[ kGLMNumProgramLangs ]; - - uint m_samplerMask; // (1< + +#pragma once + +// good ARB program references +// http://petewarden.com/notes/archives/2005/05/fragment_progra_2.html +// http://petewarden.com/notes/archives/2005/06/fragment_progra_3.html + +// ext links + +// http://www.opengl.org/registry/specs/ARB/vertex_program.txt +// http://www.opengl.org/registry/specs/ARB/fragment_program.txt +// http://www.opengl.org/registry/specs/EXT/gpu_program_parameters.txt + + +//=============================================================================== + +// tokens not in the SDK headers + +//#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT +// #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9 +//#endif + +//=============================================================================== + +// forward declarations + +class GLMContext; +class CGLMShaderPair; +class CGLMShaderPairCache; + +// CGLMProgram can contain two flavors of the same program, one in assembler, one in GLSL. +// these flavors are pretty different in terms of the API's that are used to activate them - +// for example, assembler programs can just get bound to the context, whereas GLSL programs +// have to be linked. To some extent we try to hide that detail inside GLM. + +// for now, make CGLMProgram a container, it does not set policy or hold a preference as to which +// flavor you want to use. GLMContext has to handle that. + +enum EGLMProgramType +{ + kGLMVertexProgram, + kGLMFragmentProgram, + + kGLMNumProgramTypes +}; + +enum EGLMProgramLang +{ + kGLMARB, + kGLMGLSL, + + kGLMNumProgramLangs +}; + +struct GLMShaderDesc +{ + union + { + GLuint arb; // ARB program object name + GLhandleARB glsl; // GLSL shader object handle (void*) + } m_object; + + // these can change if shader text is edited + bool m_textPresent; // is this flavor(lang) of text present in the buffer? + int m_textOffset; // where is it + int m_textLength; // how big + + bool m_compiled; // has this text been through a compile attempt + bool m_valid; // and if so, was the compile successful + + int m_slowMark; // has it been flagged during a non native draw batch before. increment every time it's slow. + + int m_highWater; // vount of vec4's in the major uniform array ("vc" on vs, "pc" on ps) + // written by dxabstract.... gross! +}; + +GLenum GLMProgTypeToARBEnum( EGLMProgramType type ); // map vert/frag to ARB asm bind target +GLenum GLMProgTypeToGLSLEnum( EGLMProgramType type ); // map vert/frag to ARB asm bind target + +class CGLMProgram +{ +public: + friend class CGLMShaderPairCache; + friend class CGLMShaderPair; + friend class GLMContext; // only GLMContext can make CGLMProgram objects + friend class GLMTester; + friend class IDirect3D9; + friend class IDirect3DDevice9; + + //=============================== + + // constructor is very light, it just makes one empty program object per flavor. + CGLMProgram( GLMContext *ctx, EGLMProgramType type ); + ~CGLMProgram( ); + + void SetProgramText ( char *text ); // import text to GLM object - invalidate any prev compiled program + + bool CompileActiveSources ( void ); // compile only the flavors that were provided. + bool Compile ( EGLMProgramLang lang ); + bool CheckValidity ( EGLMProgramLang lang ); + + void LogSlow ( EGLMProgramLang lang ); // detailed spew when called for first time; one liner or perhaps silence after that + + void GetLabelIndexCombo ( char *labelOut, int labelOutMaxChars, int *indexOut, int *comboOut ); + void GetComboIndexNameString ( char *stringOut, int stringOutMaxChars ); // mmmmmmmm-nnnnnnnn-filename + +#if GLMDEBUG + bool PollForChanges( void ); // check mirror for changes. + void ReloadStringFromEditable( void ); // populate m_string from editable item (react to change) + bool SyncWithEditable( void ); +#endif + + //=============================== + + // common stuff + + GLMContext *m_ctx; // link back to parent context + + EGLMProgramType m_type; // vertex or pixel + + uint m_serial; // serial number for hashing + + char *m_text; // copy of text passed into constructor. Can change if editable shaders is enabled. + // note - it can contain multiple flavors, so use CGLMTextSectioner to scan it and locate them +#if GLMDEBUG + CGLMEditableTextItem *m_editable; // editable text item for debugging +#endif + + GLMShaderDesc m_descs[ kGLMNumProgramLangs ]; + + uint m_samplerMask; // (1< m_layoutMap; -}; - -//=============================================================================== - -// a sampler specifies desired state for drawing on a given sampler index -// this is the combination of a texture choice and a set of sampler parameters -// see http://msdn.microsoft.com/en-us/library/bb172602(VS.85).aspx - - -struct GLMTexSamplingParams -{ - GLenum m_addressModes[3]; // S, T, R - GLfloat m_borderColor[4]; // R,G,B,A - - GLenum m_magFilter; - GLenum m_minFilter; - - GLfloat m_mipmapBias; - GLint m_minMipLevel; - GLint m_maxMipLevel; - GLint m_maxAniso; - GLenum m_compareMode; // only used for depth and stencil type textures - bool m_srgb; // srgb texture read... -}; - -struct GLMTexLockParams -{ - // input params which identify the slice of interest - CGLMTex *m_tex; - int m_face; - int m_mip; - - // identifies the region of the slice - GLMRegion m_region; - - // tells GLM to force re-read of the texels back from GL - // i.e. "I know I stepped on those texels with a draw or blit - the GLM copy is stale" - bool m_readback; -}; - -struct GLMTexLockDesc -{ - GLMTexLockParams m_req; // form of the lock request - - bool m_active; // set true at lock time. cleared at unlock time. - - int m_sliceIndex; // which slice in the layout - int m_sliceBaseOffset; // where is that in the texture data - int m_sliceRegionOffset; // offset to the start (lowest address corner) of the region requested -}; - -//=============================================================================== - -#define GLM_SAMPLER_COUNT 16 - -typedef CBitVec CTexBindMask; - -enum EGLMTexSliceFlag -{ - kSliceValid = 0x01, // slice has been teximage'd in whole at least once - set to 0 initially - kSliceStorageValid = 0x02, // if backing store is available, this slice's data is a valid copy - set to 0 initially - kSliceLocked = 0x04, // are one or more locks outstanding on this slice - kSliceFullyDirty = 0x08, // does the slice need to be fully downloaded at unlock time (disregard dirty rects) -}; - -class CGLMTex -{ - -public: - - void Lock( GLMTexLockParams *params, char** addressOut, int* yStrideOut, int *zStrideOut ); - void Unlock( GLMTexLockParams *params ); - -protected: - friend class GLMContext; // only GLMContext can make CGLMTex objects - friend class GLMTester; - friend class CGLMFBO; - - friend class IDirect3DDevice9; - friend class IDirect3DBaseTexture9; - friend class IDirect3DTexture9; - friend class IDirect3DSurface9; - friend class IDirect3DCubeTexture9; - friend class IDirect3DVolumeTexture9; - - CGLMTex( GLMContext *ctx, GLMTexLayout *layout, GLMTexSamplingParams *sampling, char *debugLabel = NULL ); - ~CGLMTex( ); - - int CalcSliceIndex( int face, int mip ); - void CalcTexelDataOffsetAndStrides( int sliceIndex, int x, int y, int z, int *offsetOut, int *yStrideOut, int *zStrideOut ); - - void ApplySamplingParams( GLMTexSamplingParams *params, bool noCheck=FALSE ); - - void ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice=true ); - void WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice=true, bool noDataWrite=false ); - // last param lets us send NULL data ptr (only legal with uncompressed formats, beware) - // this helps out ResetSRGB. - - void ResetSRGB( bool srgb, bool noDataWrite ); - // re-specify texture format to match desired sRGB form - // noWrite means send NULL for texel source addresses instead of actual data - ideal for RT's - - GLMTexLayout *m_layout; // layout of texture (shared across all tex with same layout) - int m_minActiveMip;//index of lowest mip that has been written. used to drive setting of GL_TEXTURE_MAX_LEVEL. - int m_maxActiveMip;//index of highest mip that has been written. used to drive setting of GL_TEXTURE_MAX_LEVEL. - - GLMTexSamplingParams m_sampling; // mirror of sampling params currently embodied in the texture - // (consult this at draw time, in order to know if changes need to be made) - - GLMContext *m_ctx; // link back to parent context - - GLuint m_texName; // name of this texture in the context - bool m_texClientStorage; // was CS selecetd for texture - bool m_texPreloaded; // has it been kicked into VRAM with GLMContext::PreloadTex yet - - GLuint m_rboName; // name of MSAA RBO backing the tex if MSAA enabled (or zero) - bool m_rboDirty; // has RBO been drawn on - i.e. needs to be blitted back to texture if texture is going to be sampled from - - CTexBindMask m_bindPoints; // true for each place in the parent ctx where currently - // bound (indexed via EGLMTexCtxBindingIndex) - - int m_rtAttachCount; // how many RT's have this texture attached somewhere - - char *m_backing; // backing storage if available - - int m_lockCount; // lock reqs are stored in the GLMContext for tracking - - CUtlVector m_sliceFlags; - - char *m_debugLabel; // strdup() of debugLabel passed in, or NULL -}; - - -#endif +// +// cglmtex.h +// GLMgr textures +// +//=============================================================================== + +#ifndef CGLMTEX_H +#define CGLMTEX_H + +#pragma once + +#include "tier1/utlhash.h" +#include "tier1/utlmap.h" + +//=============================================================================== + +// forward declarations + +class GLMContext; +class GLMTester; +class CGLMTexLayoutTable; +class CGLMTex; +class CGLMFBO; + +class IDirect3DSurface9; + +//=============================================================================== + +struct GLMTexFormatDesc +{ + char *m_formatSummary; // for debug visibility + + D3DFORMAT m_d3dFormat; // what D3D knows it as; see public/bitmap/imageformat.h + + GLenum m_glIntFormat; // GL internal format + GLenum m_glIntFormatSRGB; // internal format if SRGB flavor + GLenum m_glDataFormat; // GL data format + GLenum m_glDataType; // GL data type + + int m_chunkSize; // 1 or 4 - 4 is used for compressed textures + int m_bytesPerSquareChunk; // how many bytes for the smallest quantum (m_chunkSize x m_chunkSize) + // this description lets us calculate size cleanly without conditional logic for compression +}; +const GLMTexFormatDesc *GetFormatDesc( D3DFORMAT format ); + +//=============================================================================== + +// utility function for generating slabs of texels. mostly for test. +typedef struct +{ + // in + D3DFORMAT m_format; + void *m_dest; // dest address + int m_chunkCount; // square chunk count (single texels or compressed blocks) + int m_byteCountLimit; // caller expectation of max number of bytes to write out + float r,g,b,a; // color desired + + // out + int m_bytesWritten; +} GLMGenTexelParams; + +// return true if successful +bool GLMGenTexels( GLMGenTexelParams *params ); + + +//=============================================================================== + +struct GLMTexLayoutSlice +{ + int m_xSize,m_ySize,m_zSize; //texel dimensions of this slice + int m_storageOffset; //where in the storage slab does this slice live + int m_storageSize; //how much storage does this slice occupy +}; + +enum EGLMTexFlags +{ + kGLMTexMipped = 0x01, + kGLMTexMippedAuto = 0x02, + kGLMTexRenderable = 0x04, + kGLMTexIsStencil = 0x08, + kGLMTexIsDepth = 0x10, + kGLMTexSRGB = 0x20, + kGLMTexMultisampled = 0x40, // has an RBO backing it. Cannot combine with Mipped, MippedAuto. One slice maximum, only targeting GL_TEXTURE_2D. + // actually not 100% positive on the mipmapping, the RBO itself can't be mipped, but the resulting texture could + // have mipmaps generated. +}; + +//=============================================================================== + +struct GLMTexLayoutKey +{ + // input values: held const, these are the hash key for the form map + GLenum m_texGLTarget; // flavor of texture: GL_TEXTURE_2D, GL_TEXTURE_3D, GLTEXTURE_CUBE_MAP + D3DFORMAT m_texFormat; // D3D texel format + unsigned long m_texFlags; // mipped, autogen mips, render target, ... ? + unsigned long m_texSamples; // zero for a plain tex, 2/4/6/8 for "MSAA tex" (RBO backed) + int m_xSize,m_ySize,m_zSize; // size of base mip +}; + +bool LessFunc_GLMTexLayoutKey( const GLMTexLayoutKey &a, const GLMTexLayoutKey &b ); + +#define GLM_TEX_MAX_MIPS 14 +#define GLM_TEX_MAX_FACES 6 +#define GLM_TEX_MAX_SLICES (GLM_TEX_MAX_MIPS * GLM_TEX_MAX_FACES) + +struct GLMTexLayout +{ + char *m_layoutSummary; // for debug visibility + + // const inputs used for hashing + GLMTexLayoutKey m_key; + + // refcount + int m_refCount; + + // derived values: + GLMTexFormatDesc *m_format; // format specific info + int m_mipCount; // derived by starying at base size and working down towards 1x1 + int m_faceCount; // 1 for 2d/3d, 6 for cubemap + int m_sliceCount; // product of faces and mips + int m_storageTotalSize; // size of storage slab required + + // slice array + GLMTexLayoutSlice m_slices[0]; // dynamically allocated 2-d array [faces][mips] +}; + + +class CGLMTexLayoutTable +{ +public: + CGLMTexLayoutTable(); + + GLMTexLayout *NewLayoutRef( GLMTexLayoutKey *key ); // pass in a pointer to layout key - receive ptr to completed layout + void DelLayoutRef( GLMTexLayout *layout ); // pass in pointer to completed layout. refcount is dropped. + + void DumpStats( void ); +protected: + CUtlMap< GLMTexLayoutKey, GLMTexLayout* > m_layoutMap; +}; + +//=============================================================================== + +// a sampler specifies desired state for drawing on a given sampler index +// this is the combination of a texture choice and a set of sampler parameters +// see http://msdn.microsoft.com/en-us/library/bb172602(VS.85).aspx + + +struct GLMTexSamplingParams +{ + GLenum m_addressModes[3]; // S, T, R + GLfloat m_borderColor[4]; // R,G,B,A + + GLenum m_magFilter; + GLenum m_minFilter; + + GLfloat m_mipmapBias; + GLint m_minMipLevel; + GLint m_maxMipLevel; + GLint m_maxAniso; + GLenum m_compareMode; // only used for depth and stencil type textures + bool m_srgb; // srgb texture read... +}; + +struct GLMTexLockParams +{ + // input params which identify the slice of interest + CGLMTex *m_tex; + int m_face; + int m_mip; + + // identifies the region of the slice + GLMRegion m_region; + + // tells GLM to force re-read of the texels back from GL + // i.e. "I know I stepped on those texels with a draw or blit - the GLM copy is stale" + bool m_readback; +}; + +struct GLMTexLockDesc +{ + GLMTexLockParams m_req; // form of the lock request + + bool m_active; // set true at lock time. cleared at unlock time. + + int m_sliceIndex; // which slice in the layout + int m_sliceBaseOffset; // where is that in the texture data + int m_sliceRegionOffset; // offset to the start (lowest address corner) of the region requested +}; + +//=============================================================================== + +#define GLM_SAMPLER_COUNT 16 + +typedef CBitVec CTexBindMask; + +enum EGLMTexSliceFlag +{ + kSliceValid = 0x01, // slice has been teximage'd in whole at least once - set to 0 initially + kSliceStorageValid = 0x02, // if backing store is available, this slice's data is a valid copy - set to 0 initially + kSliceLocked = 0x04, // are one or more locks outstanding on this slice + kSliceFullyDirty = 0x08, // does the slice need to be fully downloaded at unlock time (disregard dirty rects) +}; + +class CGLMTex +{ + +public: + + void Lock( GLMTexLockParams *params, char** addressOut, int* yStrideOut, int *zStrideOut ); + void Unlock( GLMTexLockParams *params ); + +protected: + friend class GLMContext; // only GLMContext can make CGLMTex objects + friend class GLMTester; + friend class CGLMFBO; + + friend class IDirect3DDevice9; + friend class IDirect3DBaseTexture9; + friend class IDirect3DTexture9; + friend class IDirect3DSurface9; + friend class IDirect3DCubeTexture9; + friend class IDirect3DVolumeTexture9; + + CGLMTex( GLMContext *ctx, GLMTexLayout *layout, GLMTexSamplingParams *sampling, char *debugLabel = NULL ); + ~CGLMTex( ); + + int CalcSliceIndex( int face, int mip ); + void CalcTexelDataOffsetAndStrides( int sliceIndex, int x, int y, int z, int *offsetOut, int *yStrideOut, int *zStrideOut ); + + void ApplySamplingParams( GLMTexSamplingParams *params, bool noCheck=FALSE ); + + void ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice=true ); + void WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice=true, bool noDataWrite=false ); + // last param lets us send NULL data ptr (only legal with uncompressed formats, beware) + // this helps out ResetSRGB. + + void ResetSRGB( bool srgb, bool noDataWrite ); + // re-specify texture format to match desired sRGB form + // noWrite means send NULL for texel source addresses instead of actual data - ideal for RT's + + GLMTexLayout *m_layout; // layout of texture (shared across all tex with same layout) + int m_minActiveMip;//index of lowest mip that has been written. used to drive setting of GL_TEXTURE_MAX_LEVEL. + int m_maxActiveMip;//index of highest mip that has been written. used to drive setting of GL_TEXTURE_MAX_LEVEL. + + GLMTexSamplingParams m_sampling; // mirror of sampling params currently embodied in the texture + // (consult this at draw time, in order to know if changes need to be made) + + GLMContext *m_ctx; // link back to parent context + + GLuint m_texName; // name of this texture in the context + bool m_texClientStorage; // was CS selecetd for texture + bool m_texPreloaded; // has it been kicked into VRAM with GLMContext::PreloadTex yet + + GLuint m_rboName; // name of MSAA RBO backing the tex if MSAA enabled (or zero) + bool m_rboDirty; // has RBO been drawn on - i.e. needs to be blitted back to texture if texture is going to be sampled from + + CTexBindMask m_bindPoints; // true for each place in the parent ctx where currently + // bound (indexed via EGLMTexCtxBindingIndex) + + int m_rtAttachCount; // how many RT's have this texture attached somewhere + + char *m_backing; // backing storage if available + + int m_lockCount; // lock reqs are stored in the GLMContext for tracking + + CUtlVector m_sliceFlags; + + char *m_debugLabel; // strdup() of debugLabel passed in, or NULL +}; + + +#endif diff --git a/mp/src/public/togl/osx/dxabstract.h b/mp/src/public/togl/osx/dxabstract.h index 92f6bc32..50676e04 100644 --- a/mp/src/public/togl/osx/dxabstract.h +++ b/mp/src/public/togl/osx/dxabstract.h @@ -1,804 +1,804 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// -// -// -//================================================================================================== - -#ifndef DXABSTRACT_H -#define DXABSTRACT_H -#ifdef _WIN32 -#pragma once -#endif - -#include "togl/rendermechanism.h" - -#include "materialsystem/ishader.h" - -// Uncomment this on Windows if you want to compile the Windows GL version. -// #undef USE_ACTUAL_DX - -#ifdef USE_ACTUAL_DX - -#ifndef WIN32 -#error sorry man -#endif -#ifdef _X360 -#include "d3d9.h" -#include "d3dx9.h" -#else -#include -#include "../../dx9sdk/include/d3d9.h" -#include "../../dx9sdk/include/d3dx9.h" -#endif -typedef HWND VD3DHWND; - -#else - -#ifdef WIN32 -#error Gl on win32? -#endif - -#include "tier0/platform.h" - -#ifndef DX_TO_GL_ABSTRACTION -#define DX_TO_GL_ABSTRACTION -#endif - -#include "bitmap/imageformat.h" -#include "togl/rendermechanism.h" - -#ifdef OSX -extern "C" void Debugger(void); -#endif - -// turn this on to get refcount logging from IUnknown -#define IUNKNOWN_ALLOC_SPEW 0 -#define IUNKNOWN_ALLOC_SPEW_MARK_ALL 0 - - -// ------------------------------------------------------------------------------------------------------------------------------ // -// DEFINES -// ------------------------------------------------------------------------------------------------------------------------------ // - -typedef void* VD3DHWND; -typedef void* VD3DHANDLE; - - -TOGL_INTERFACE void toglGetClientRect( VD3DHWND hWnd, RECT *destRect ); - -struct TOGL_CLASS IUnknown -{ - int m_refcount[2]; - bool m_mark; - - IUnknown( void ) - { - m_refcount[0] = 1; - m_refcount[1] = 0; - m_mark = (IUNKNOWN_ALLOC_SPEW_MARK_ALL != 0); // either all are marked, or only the ones that have SetMark(true) called on them - - #if IUNKNOWN_ALLOC_SPEW - if (m_mark) - { - GLMPRINTF(("-A- IUnew (%08x) refc -> (%d,%d) ",this,m_refcount[0],m_refcount[1])); - } - #endif - }; - - virtual ~IUnknown( void ) - { - #if IUNKNOWN_ALLOC_SPEW - if (m_mark) - { - GLMPRINTF(("-A- IUdel (%08x) ",this )); - } - #endif - }; - - void AddRef( int which=0, char *comment = NULL ) - { - Assert( which >= 0 ); - Assert( which < 2 ); - m_refcount[which]++; - - #if IUNKNOWN_ALLOC_SPEW - if (m_mark) - { - GLMPRINTF(("-A- IUAddRef (%08x,%d) refc -> (%d,%d) [%s]",this,which,m_refcount[0],m_refcount[1],comment?comment:"...")) ; - if (!comment) - { - GLMPRINTF(("")) ; // place to hang a breakpoint - } - } - #endif - }; - - ULONG __stdcall Release( int which=0, char *comment = NULL ) - { - Assert( which >= 0 ); - Assert( which < 2 ); - - //int oldrefcs[2] = { m_refcount[0], m_refcount[1] }; - bool deleting = false; - - m_refcount[which]--; - if ( (!m_refcount[0]) && (!m_refcount[1]) ) - { - deleting = true; - } - - #if IUNKNOWN_ALLOC_SPEW - if (m_mark) - { - GLMPRINTF(("-A- IURelease (%08x,%d) refc -> (%d,%d) [%s] %s",this,which,m_refcount[0],m_refcount[1],comment?comment:"...",deleting?"->DELETING":"")); - if (!comment) - { - GLMPRINTF(("")) ; // place to hang a breakpoint - } - } - #endif - - if (deleting) - { - if (m_mark) - { - GLMPRINTF(("")) ; // place to hang a breakpoint - } - delete this; - return 0; - } - else - { - return m_refcount[0]; - } - }; - - void SetMark( bool markValue, char *comment=NULL ) - { - #if IUNKNOWN_ALLOC_SPEW - if (!m_mark && markValue) // leading edge detect - { - // print the same thing that the constructor would have printed if it had been marked from the beginning - // i.e. it's anticipated that callers asking for marking will do so right at create time - GLMPRINTF(("-A- IUSetMark (%08x) refc -> (%d,%d) (%s) ",this,m_refcount[0],m_refcount[1],comment?comment:"...")); - } - #endif - - m_mark = markValue; - } -}; - - -// ------------------------------------------------------------------------------------------------------------------------------ // -// INTERFACES -// ------------------------------------------------------------------------------------------------------------------------------ // - -struct TOGL_CLASS IDirect3DResource9 : public IUnknown -{ - IDirect3DDevice9 *m_device; // parent device - D3DRESOURCETYPE m_restype; - - DWORD SetPriority(DWORD PriorityNew); -}; - -struct TOGL_CLASS IDirect3DBaseTexture9 : public IDirect3DResource9 // "A Texture.." -{ - D3DSURFACE_DESC m_descZero; // desc of top level. - CGLMTex *m_tex; // a CGLMTex can represent all forms of tex - int m_srgbFlipCount; - - virtual ~IDirect3DBaseTexture9(); - D3DRESOURCETYPE GetType(); - DWORD GetLevelCount(); - HRESULT GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc); -}; - -struct TOGL_CLASS IDirect3DTexture9 : public IDirect3DBaseTexture9 // "Texture 2D" -{ - IDirect3DSurface9 *m_surfZero; // surf of top level. - - virtual ~IDirect3DTexture9(); - - HRESULT LockRect(UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags); - HRESULT UnlockRect(UINT Level); - HRESULT GetSurfaceLevel(UINT Level,IDirect3DSurface9** ppSurfaceLevel); -}; - -struct TOGL_CLASS IDirect3DCubeTexture9 : public IDirect3DBaseTexture9 // "Texture Cube Map" -{ - IDirect3DSurface9 *m_surfZero[6]; // surfs of top level. - - virtual ~IDirect3DCubeTexture9(); - - HRESULT GetCubeMapSurface(D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface9** ppCubeMapSurface); - HRESULT GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc); -}; - -struct TOGL_CLASS IDirect3DVolumeTexture9 : public IDirect3DBaseTexture9 // "Texture 3D" -{ - IDirect3DSurface9 *m_surfZero; // surf of top level. - D3DVOLUME_DESC m_volDescZero; // volume desc top level - - virtual ~IDirect3DVolumeTexture9(); - - HRESULT LockBox(UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags); - HRESULT UnlockBox(UINT Level); - HRESULT GetLevelDesc( UINT level, D3DVOLUME_DESC *pDesc ); -}; - - -// for the moment, a "D3D surface" is modeled as a GLM tex, a face, and a mip. -// no Create method, these are filled in by the various create surface methods. - -struct TOGL_CLASS IDirect3DSurface9 : public IDirect3DResource9 -{ - virtual ~IDirect3DSurface9(); - - HRESULT LockRect(D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags); - HRESULT UnlockRect(); - HRESULT GetDesc(D3DSURFACE_DESC *pDesc); - - D3DSURFACE_DESC m_desc; - CGLMTex *m_tex; - int m_face; - int m_mip; -}; - - - -struct TOGL_CLASS IDirect3D9 : public IUnknown -{ -public: - virtual ~IDirect3D9(); - - UINT GetAdapterCount(); //cheese: returns 1 - - HRESULT GetDeviceCaps (UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps); - HRESULT GetAdapterIdentifier (UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier); - HRESULT CheckDeviceFormat (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat); - UINT GetAdapterModeCount (UINT Adapter,D3DFORMAT Format); - HRESULT EnumAdapterModes (UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode); - HRESULT CheckDeviceType (UINT Adapter,D3DDEVTYPE DevType,D3DFORMAT AdapterFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed); - HRESULT GetAdapterDisplayMode (UINT Adapter,D3DDISPLAYMODE* pMode); - HRESULT CheckDepthStencilMatch (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat); - HRESULT CheckDeviceMultiSampleType (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels); - - HRESULT CreateDevice (UINT Adapter,D3DDEVTYPE DeviceType,VD3DHWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface); -}; - -struct TOGL_CLASS IDirect3DSwapChain9 : public IUnknown -{ -}; - - - - // typedef enum D3DDECLUSAGE - // { - // D3DDECLUSAGE_POSITION = 0, - // D3DDECLUSAGE_BLENDWEIGHT = 1, - // D3DDECLUSAGE_BLENDINDICES = 2, - // D3DDECLUSAGE_NORMAL = 3, - // D3DDECLUSAGE_PSIZE = 4, - // D3DDECLUSAGE_TEXCOORD = 5, - // D3DDECLUSAGE_TANGENT = 6, - // D3DDECLUSAGE_BINORMAL = 7, - // D3DDECLUSAGE_TESSFACTOR = 8, - // D3DDECLUSAGE_POSITIONT = 9, - // D3DDECLUSAGE_COLOR = 10, - // D3DDECLUSAGE_FOG = 11, - // D3DDECLUSAGE_DEPTH = 12, - // D3DDECLUSAGE_SAMPLE = 13, - // } D3DDECLUSAGE, *LPD3DDECLUSAGE; - // Constants - // - // D3DDECLUSAGE_POSITION - // Position data ranging from (-1,-1) to (1,1). Use D3DDECLUSAGE_POSITION with - // a usage index of 0 to specify untransformed position for fixed function - // vertex processing and the n-patch tessellator. Use D3DDECLUSAGE_POSITION - // with a usage index of 1 to specify untransformed position in the fixed - // function vertex shader for vertex tweening. - // - // D3DDECLUSAGE_BLENDWEIGHT - // Blending weight data. Use D3DDECLUSAGE_BLENDWEIGHT with a usage index of 0 - // to specify the blend weights used in indexed and nonindexed vertex - // blending. - // - // D3DDECLUSAGE_BLENDINDICES - // Blending indices data. Use D3DDECLUSAGE_BLENDINDICES with a usage index of - // 0 to specify matrix indices for indexed paletted skinning. - // - // D3DDECLUSAGE_NORMAL - // Vertex normal data. Use D3DDECLUSAGE_NORMAL with a usage index of 0 to - // specify vertex normals for fixed function vertex processing and the n-patch - // tessellator. Use D3DDECLUSAGE_NORMAL with a usage index of 1 to specify - // vertex normals for fixed function vertex processing for vertex tweening. - // - // D3DDECLUSAGE_PSIZE - // Point size data. Use D3DDECLUSAGE_PSIZE with a usage index of 0 to specify - // the point-size attribute used by the setup engine of the rasterizer to - // expand a point into a quad for the point-sprite functionality. - // - // D3DDECLUSAGE_TEXCOORD - // Texture coordinate data. Use D3DDECLUSAGE_TEXCOORD, n to specify texture - // coordinates in fixed function vertex processing and in pixel shaders prior - // to ps_3_0. These can be used to pass user defined data. - // - // D3DDECLUSAGE_TANGENT - // Vertex tangent data. - // - // D3DDECLUSAGE_BINORMAL - // Vertex binormal data. - // - // D3DDECLUSAGE_TESSFACTOR - // Single positive floating point value. Use D3DDECLUSAGE_TESSFACTOR with a - // usage index of 0 to specify a tessellation factor used in the tessellation - // unit to control the rate of tessellation. For more information about the - // data type, see D3DDECLTYPE_FLOAT1. - // - // D3DDECLUSAGE_POSITIONT - // Vertex data contains transformed position data ranging from (0,0) to - // (viewport width, viewport height). Use D3DDECLUSAGE_POSITIONT with a usage - // index of 0 to specify transformed position. When a declaration containing - // this is set, the pipeline does not perform vertex processing. - // - // D3DDECLUSAGE_COLOR - // Vertex data contains diffuse or specular color. Use D3DDECLUSAGE_COLOR with - // a usage index of 0 to specify the diffuse color in the fixed function - // vertex shader and pixel shaders prior to ps_3_0. Use D3DDECLUSAGE_COLOR - // with a usage index of 1 to specify the specular color in the fixed function - // vertex shader and pixel shaders prior to ps_3_0. - // - // D3DDECLUSAGE_FOG - // Vertex data contains fog data. Use D3DDECLUSAGE_FOG with a usage index of 0 - // to specify a fog blend value used after pixel shading finishes. This - // applies to pixel shaders prior to version ps_3_0. - // - // D3DDECLUSAGE_DEPTH - // Vertex data contains depth data. - // - // D3DDECLUSAGE_SAMPLE - // Vertex data contains sampler data. Use D3DDECLUSAGE_SAMPLE with a usage - // index of 0 to specify the displacement value to look up. It can be used - // only with D3DDECLUSAGE_LOOKUPPRESAMPLED or D3DDECLUSAGE_LOOKUP. - - //note the form of the list terminator.. - - // #define D3DDECL_END() {0xFF,0,D3DDECLTYPE_UNUSED,0,0,0} - // typedef struct _D3DVERTEXELEMENT9 - // { - // WORD Stream; // Stream index - // WORD Offset; // Offset in the stream in bytes - // BYTE Type; // Data type - // BYTE Method; // Processing method - // BYTE Usage; // Semantics - // BYTE UsageIndex; // Semantic index - // } D3DVERTEXELEMENT9, *LPD3DVERTEXELEMENT9; - -#define MAX_D3DVERTEXELEMENTS 16 - -struct TOGL_CLASS IDirect3DVertexDeclaration9 : public IUnknown -{ -//public: - uint m_elemCount; - D3DVERTEXELEMENT9_GL m_elements[ MAX_D3DVERTEXELEMENTS ]; - - virtual ~IDirect3DVertexDeclaration9(); -}; - -struct TOGL_CLASS IDirect3DQuery9 : public IDirect3DResource9 //was IUnknown -{ -//public: - D3DQUERYTYPE m_type; // D3DQUERYTYPE_OCCLUSION or D3DQUERYTYPE_EVENT - GLMContext *m_ctx; - CGLMQuery *m_query; - - virtual ~IDirect3DQuery9(); - - HRESULT Issue(DWORD dwIssueFlags); - HRESULT GetData(void* pData,DWORD dwSize,DWORD dwGetDataFlags); -}; - -struct TOGL_CLASS IDirect3DVertexBuffer9 : public IDirect3DResource9 //was IUnknown -{ -//public: - GLMContext *m_ctx; - CGLMBuffer *m_vtxBuffer; - D3DVERTEXBUFFER_DESC m_vtxDesc; // to satisfy GetDesc - - virtual ~IDirect3DVertexBuffer9(); - HRESULT Lock(UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags); - HRESULT Unlock(); - HRESULT UnlockActualSize( uint nActualSize, const void *pActualData = NULL ); - -}; - -struct TOGL_CLASS IDirect3DIndexBuffer9 : public IDirect3DResource9 //was IUnknown -{ -//public: - GLMContext *m_ctx; - CGLMBuffer *m_idxBuffer; - D3DINDEXBUFFER_DESC m_idxDesc; // to satisfy GetDesc - - virtual ~IDirect3DIndexBuffer9(); - - HRESULT Lock(UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags); - HRESULT Unlock(); - HRESULT UnlockActualSize( uint nActualSize, const void *pActualData = NULL ); - HRESULT GetDesc(D3DINDEXBUFFER_DESC *pDesc); -}; - -struct TOGL_CLASS IDirect3DPixelShader9 : public IDirect3DResource9 //was IUnknown -{ -//public: - CGLMProgram *m_pixProgram; - uint m_pixHighWater; // count of active constant slots referenced by shader. - uint m_pixSamplerMask; // (1< m_stack; - int m_stackTop; // top of stack is at the highest index, this is that index. push increases, pop decreases. - - HRESULT Create( void ); - - D3DXMATRIX* GetTop(); - void Push(); - void Pop(); - void LoadIdentity(); - void LoadMatrix( const D3DXMATRIX *pMat ); - void MultMatrix( const D3DXMATRIX *pMat ); - void MultMatrixLocal( const D3DXMATRIX *pMat ); - HRESULT ScaleLocal(FLOAT x, FLOAT y, FLOAT z); - - // Left multiply the current matrix with the computed rotation - // matrix, counterclockwise about the given axis with the given angle. - // (rotation is about the local origin of the object) - HRESULT RotateAxisLocal(CONST D3DXVECTOR3* pV, FLOAT Angle); - - // Left multiply the current matrix with the computed translation - // matrix. (transformation is about the local origin of the object) - HRESULT TranslateLocal(FLOAT x, FLOAT y, FLOAT z); -}; -typedef ID3DXMatrixStack* LPD3DXMATRIXSTACK; - -struct TOGL_CLASS IDirect3DDevice9 : public IUnknown -{ -public: - // members - - IDirect3DDevice9Params m_params; // mirror of the creation inputs - - // D3D flavor stuff - IDirect3DSurface9 *m_rtSurfaces[16]; // current color RT surfaces. [0] is initially == m_defaultColorSurface - IDirect3DSurface9 *m_dsSurface; // current DS RT surface. can be changed! - - IDirect3DSurface9 *m_defaultColorSurface; // default color surface. - IDirect3DSurface9 *m_defaultDepthStencilSurface; // queried by GetDepthStencilSurface. - - IDirect3DVertexDeclaration9 *m_vertDecl; // Set by SetVertexDeclaration... - D3DStreamDesc m_streams[ D3D_MAX_STREAMS ]; // Set by SetStreamSource.. - D3DIndexDesc m_indices; // Set by SetIndices.. - - IDirect3DVertexShader9 *m_vertexShader; // Set by SetVertexShader... - IDirect3DPixelShader9 *m_pixelShader; // Set by SetPixelShader... - - IDirect3DBaseTexture9 *m_textures[16]; // set by SetTexture... NULL if stage inactive - D3DSamplerDesc m_samplers[16]; // set by SetSamplerState.. - // GLM flavor stuff - GLMContext *m_ctx; - CGLMFBO *m_drawableFBO; // this FBO should have all the attachments set to match m_rtSurfaces and m_dsSurface. - - // GL state - struct - { - // render state buckets - GLAlphaTestEnable_t m_AlphaTestEnable; - GLAlphaTestFunc_t m_AlphaTestFunc; - - GLAlphaToCoverageEnable_t m_AlphaToCoverageEnable; - - GLDepthTestEnable_t m_DepthTestEnable; - GLDepthMask_t m_DepthMask; - GLDepthFunc_t m_DepthFunc; - - GLClipPlaneEnable_t m_ClipPlaneEnable[kGLMUserClipPlanes]; - GLClipPlaneEquation_t m_ClipPlaneEquation[kGLMUserClipPlanes]; - - GLColorMaskSingle_t m_ColorMaskSingle; - GLColorMaskMultiple_t m_ColorMaskMultiple; - - GLCullFaceEnable_t m_CullFaceEnable; - GLCullFrontFace_t m_CullFrontFace; - GLPolygonMode_t m_PolygonMode; - GLDepthBias_t m_DepthBias; - GLScissorEnable_t m_ScissorEnable; - GLScissorBox_t m_ScissorBox; - GLViewportBox_t m_ViewportBox; - GLViewportDepthRange_t m_ViewportDepthRange; - - GLBlendEnable_t m_BlendEnable; - GLBlendFactor_t m_BlendFactor; - GLBlendEquation_t m_BlendEquation; - GLBlendColor_t m_BlendColor; - GLBlendEnableSRGB_t m_BlendEnableSRGB; - - GLStencilTestEnable_t m_StencilTestEnable; - GLStencilFunc_t m_StencilFunc; - GLStencilOp_t m_StencilOp; - GLStencilWriteMask_t m_StencilWriteMask; - - GLClearColor_t m_ClearColor; - GLClearDepth_t m_ClearDepth; - GLClearStencil_t m_ClearStencil; - - bool m_FogEnable; // not really pushed to GL, just latched here - - // samplers - GLMTexSamplingParams m_samplers[ 16 ]; - - // bindings...hmmm... - - // dirty-bits - uint m_stateDirtyMask; // covers the state blocks, indexed by 1<m_nCurOwnerThreadId; } - -}; - -struct ID3DXInclude -{ - virtual HRESULT Open(D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes) = 0; - virtual HRESULT Close(LPCVOID pData) = 0; -}; -typedef ID3DXInclude* LPD3DXINCLUDE; - - -struct TOGL_CLASS ID3DXBuffer : public IUnknown -{ - void* GetBufferPointer(); - DWORD GetBufferSize(); -}; - -typedef ID3DXBuffer* LPD3DXBUFFER; - -class TOGL_CLASS ID3DXConstantTable : public IUnknown -{ -}; -typedef ID3DXConstantTable* LPD3DXCONSTANTTABLE; - - - -// ------------------------------------------------------------------------------------------------------------------------------ // -// D3DX stuff. -// ------------------------------------------------------------------------------------------------------------------------------ // - -TOGL_INTERFACE const char* D3DXGetPixelShaderProfile( IDirect3DDevice9 *pDevice ); - - -TOGL_INTERFACE D3DXMATRIX* D3DXMatrixMultiply( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); -TOGL_INTERFACE D3DXVECTOR3* D3DXVec3TransformCoord( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - -TOGL_INTERFACE HRESULT D3DXCreateMatrixStack( DWORD Flags, LPD3DXMATRIXSTACK* ppStack); -TOGL_INTERFACE void D3DXMatrixIdentity( D3DXMATRIX * ); - -TOGL_INTERFACE D3DXINLINE D3DXVECTOR3* D3DXVec3Subtract( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ - pOut->x = pV1->x - pV2->x; - pOut->y = pV1->y - pV2->y; - pOut->z = pV1->z - pV2->z; - return pOut; -} - -TOGL_INTERFACE D3DXINLINE D3DXVECTOR3* D3DXVec3Cross( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ - D3DXVECTOR3 v; - - v.x = pV1->y * pV2->z - pV1->z * pV2->y; - v.y = pV1->z * pV2->x - pV1->x * pV2->z; - v.z = pV1->x * pV2->y - pV1->y * pV2->x; - - *pOut = v; - return pOut; -} - -TOGL_INTERFACE D3DXINLINE FLOAT D3DXVec3Dot( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ - return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z; -} - -TOGL_INTERFACE D3DXMATRIX* D3DXMatrixInverse( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); - -TOGL_INTERFACE D3DXMATRIX* D3DXMatrixTranspose( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); - -TOGL_INTERFACE D3DXPLANE* D3DXPlaneNormalize( D3DXPLANE *pOut, CONST D3DXPLANE *pP); - -TOGL_INTERFACE D3DXVECTOR4* D3DXVec4Transform( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); - - -TOGL_INTERFACE D3DXVECTOR4* D3DXVec4Normalize( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); - -TOGL_INTERFACE D3DXMATRIX* D3DXMatrixTranslation( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); - -// Build an ortho projection matrix. (right-handed) -TOGL_INTERFACE D3DXMATRIX* D3DXMatrixOrthoOffCenterRH( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,FLOAT zf ); - -TOGL_INTERFACE D3DXMATRIX* D3DXMatrixPerspectiveRH( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -TOGL_INTERFACE D3DXMATRIX* D3DXMatrixPerspectiveOffCenterRH( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); - -// Transform a plane by a matrix. The vector (a,b,c) must be normal. -// M should be the inverse transpose of the transformation desired. -TOGL_INTERFACE D3DXPLANE* D3DXPlaneTransform( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); - -TOGL_INTERFACE IDirect3D9 *Direct3DCreate9(UINT SDKVersion); - -TOGL_INTERFACE void D3DPERF_SetOptions( DWORD dwOptions ); - -TOGL_INTERFACE HRESULT D3DXCompileShader( - LPCSTR pSrcData, - UINT SrcDataLen, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPCSTR pFunctionName, - LPCSTR pProfile, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs, - LPD3DXCONSTANTTABLE* ppConstantTable); - - -#endif // USE_ACTUAL_DX - -// fake D3D usage constant for SRGB tex creation -#define D3DUSAGE_TEXTURE_SRGB (0x80000000L) - -#endif // DXABSTRACT_H +// +// +// +//================================================================================================== + +#ifndef DXABSTRACT_H +#define DXABSTRACT_H +#ifdef _WIN32 +#pragma once +#endif + +#include "togl/rendermechanism.h" + +#include "materialsystem/ishader.h" + +// Uncomment this on Windows if you want to compile the Windows GL version. +// #undef USE_ACTUAL_DX + +#ifdef USE_ACTUAL_DX + +#ifndef WIN32 +#error sorry man +#endif +#ifdef _X360 +#include "d3d9.h" +#include "d3dx9.h" +#else +#include +#include "../../dx9sdk/include/d3d9.h" +#include "../../dx9sdk/include/d3dx9.h" +#endif +typedef HWND VD3DHWND; + +#else + +#ifdef WIN32 +#error Gl on win32? +#endif + +#include "tier0/platform.h" + +#ifndef DX_TO_GL_ABSTRACTION +#define DX_TO_GL_ABSTRACTION +#endif + +#include "bitmap/imageformat.h" +#include "togl/rendermechanism.h" + +#ifdef OSX +extern "C" void Debugger(void); +#endif + +// turn this on to get refcount logging from IUnknown +#define IUNKNOWN_ALLOC_SPEW 0 +#define IUNKNOWN_ALLOC_SPEW_MARK_ALL 0 + + +// ------------------------------------------------------------------------------------------------------------------------------ // +// DEFINES +// ------------------------------------------------------------------------------------------------------------------------------ // + +typedef void* VD3DHWND; +typedef void* VD3DHANDLE; + + +TOGL_INTERFACE void toglGetClientRect( VD3DHWND hWnd, RECT *destRect ); + +struct TOGL_CLASS IUnknown +{ + int m_refcount[2]; + bool m_mark; + + IUnknown( void ) + { + m_refcount[0] = 1; + m_refcount[1] = 0; + m_mark = (IUNKNOWN_ALLOC_SPEW_MARK_ALL != 0); // either all are marked, or only the ones that have SetMark(true) called on them + + #if IUNKNOWN_ALLOC_SPEW + if (m_mark) + { + GLMPRINTF(("-A- IUnew (%08x) refc -> (%d,%d) ",this,m_refcount[0],m_refcount[1])); + } + #endif + }; + + virtual ~IUnknown( void ) + { + #if IUNKNOWN_ALLOC_SPEW + if (m_mark) + { + GLMPRINTF(("-A- IUdel (%08x) ",this )); + } + #endif + }; + + void AddRef( int which=0, char *comment = NULL ) + { + Assert( which >= 0 ); + Assert( which < 2 ); + m_refcount[which]++; + + #if IUNKNOWN_ALLOC_SPEW + if (m_mark) + { + GLMPRINTF(("-A- IUAddRef (%08x,%d) refc -> (%d,%d) [%s]",this,which,m_refcount[0],m_refcount[1],comment?comment:"...")) ; + if (!comment) + { + GLMPRINTF(("")) ; // place to hang a breakpoint + } + } + #endif + }; + + ULONG __stdcall Release( int which=0, char *comment = NULL ) + { + Assert( which >= 0 ); + Assert( which < 2 ); + + //int oldrefcs[2] = { m_refcount[0], m_refcount[1] }; + bool deleting = false; + + m_refcount[which]--; + if ( (!m_refcount[0]) && (!m_refcount[1]) ) + { + deleting = true; + } + + #if IUNKNOWN_ALLOC_SPEW + if (m_mark) + { + GLMPRINTF(("-A- IURelease (%08x,%d) refc -> (%d,%d) [%s] %s",this,which,m_refcount[0],m_refcount[1],comment?comment:"...",deleting?"->DELETING":"")); + if (!comment) + { + GLMPRINTF(("")) ; // place to hang a breakpoint + } + } + #endif + + if (deleting) + { + if (m_mark) + { + GLMPRINTF(("")) ; // place to hang a breakpoint + } + delete this; + return 0; + } + else + { + return m_refcount[0]; + } + }; + + void SetMark( bool markValue, char *comment=NULL ) + { + #if IUNKNOWN_ALLOC_SPEW + if (!m_mark && markValue) // leading edge detect + { + // print the same thing that the constructor would have printed if it had been marked from the beginning + // i.e. it's anticipated that callers asking for marking will do so right at create time + GLMPRINTF(("-A- IUSetMark (%08x) refc -> (%d,%d) (%s) ",this,m_refcount[0],m_refcount[1],comment?comment:"...")); + } + #endif + + m_mark = markValue; + } +}; + + +// ------------------------------------------------------------------------------------------------------------------------------ // +// INTERFACES +// ------------------------------------------------------------------------------------------------------------------------------ // + +struct TOGL_CLASS IDirect3DResource9 : public IUnknown +{ + IDirect3DDevice9 *m_device; // parent device + D3DRESOURCETYPE m_restype; + + DWORD SetPriority(DWORD PriorityNew); +}; + +struct TOGL_CLASS IDirect3DBaseTexture9 : public IDirect3DResource9 // "A Texture.." +{ + D3DSURFACE_DESC m_descZero; // desc of top level. + CGLMTex *m_tex; // a CGLMTex can represent all forms of tex + int m_srgbFlipCount; + + virtual ~IDirect3DBaseTexture9(); + D3DRESOURCETYPE GetType(); + DWORD GetLevelCount(); + HRESULT GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc); +}; + +struct TOGL_CLASS IDirect3DTexture9 : public IDirect3DBaseTexture9 // "Texture 2D" +{ + IDirect3DSurface9 *m_surfZero; // surf of top level. + + virtual ~IDirect3DTexture9(); + + HRESULT LockRect(UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags); + HRESULT UnlockRect(UINT Level); + HRESULT GetSurfaceLevel(UINT Level,IDirect3DSurface9** ppSurfaceLevel); +}; + +struct TOGL_CLASS IDirect3DCubeTexture9 : public IDirect3DBaseTexture9 // "Texture Cube Map" +{ + IDirect3DSurface9 *m_surfZero[6]; // surfs of top level. + + virtual ~IDirect3DCubeTexture9(); + + HRESULT GetCubeMapSurface(D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface9** ppCubeMapSurface); + HRESULT GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc); +}; + +struct TOGL_CLASS IDirect3DVolumeTexture9 : public IDirect3DBaseTexture9 // "Texture 3D" +{ + IDirect3DSurface9 *m_surfZero; // surf of top level. + D3DVOLUME_DESC m_volDescZero; // volume desc top level + + virtual ~IDirect3DVolumeTexture9(); + + HRESULT LockBox(UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags); + HRESULT UnlockBox(UINT Level); + HRESULT GetLevelDesc( UINT level, D3DVOLUME_DESC *pDesc ); +}; + + +// for the moment, a "D3D surface" is modeled as a GLM tex, a face, and a mip. +// no Create method, these are filled in by the various create surface methods. + +struct TOGL_CLASS IDirect3DSurface9 : public IDirect3DResource9 +{ + virtual ~IDirect3DSurface9(); + + HRESULT LockRect(D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags); + HRESULT UnlockRect(); + HRESULT GetDesc(D3DSURFACE_DESC *pDesc); + + D3DSURFACE_DESC m_desc; + CGLMTex *m_tex; + int m_face; + int m_mip; +}; + + + +struct TOGL_CLASS IDirect3D9 : public IUnknown +{ +public: + virtual ~IDirect3D9(); + + UINT GetAdapterCount(); //cheese: returns 1 + + HRESULT GetDeviceCaps (UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps); + HRESULT GetAdapterIdentifier (UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier); + HRESULT CheckDeviceFormat (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat); + UINT GetAdapterModeCount (UINT Adapter,D3DFORMAT Format); + HRESULT EnumAdapterModes (UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode); + HRESULT CheckDeviceType (UINT Adapter,D3DDEVTYPE DevType,D3DFORMAT AdapterFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed); + HRESULT GetAdapterDisplayMode (UINT Adapter,D3DDISPLAYMODE* pMode); + HRESULT CheckDepthStencilMatch (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat); + HRESULT CheckDeviceMultiSampleType (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels); + + HRESULT CreateDevice (UINT Adapter,D3DDEVTYPE DeviceType,VD3DHWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface); +}; + +struct TOGL_CLASS IDirect3DSwapChain9 : public IUnknown +{ +}; + + + + // typedef enum D3DDECLUSAGE + // { + // D3DDECLUSAGE_POSITION = 0, + // D3DDECLUSAGE_BLENDWEIGHT = 1, + // D3DDECLUSAGE_BLENDINDICES = 2, + // D3DDECLUSAGE_NORMAL = 3, + // D3DDECLUSAGE_PSIZE = 4, + // D3DDECLUSAGE_TEXCOORD = 5, + // D3DDECLUSAGE_TANGENT = 6, + // D3DDECLUSAGE_BINORMAL = 7, + // D3DDECLUSAGE_TESSFACTOR = 8, + // D3DDECLUSAGE_POSITIONT = 9, + // D3DDECLUSAGE_COLOR = 10, + // D3DDECLUSAGE_FOG = 11, + // D3DDECLUSAGE_DEPTH = 12, + // D3DDECLUSAGE_SAMPLE = 13, + // } D3DDECLUSAGE, *LPD3DDECLUSAGE; + // Constants + // + // D3DDECLUSAGE_POSITION + // Position data ranging from (-1,-1) to (1,1). Use D3DDECLUSAGE_POSITION with + // a usage index of 0 to specify untransformed position for fixed function + // vertex processing and the n-patch tessellator. Use D3DDECLUSAGE_POSITION + // with a usage index of 1 to specify untransformed position in the fixed + // function vertex shader for vertex tweening. + // + // D3DDECLUSAGE_BLENDWEIGHT + // Blending weight data. Use D3DDECLUSAGE_BLENDWEIGHT with a usage index of 0 + // to specify the blend weights used in indexed and nonindexed vertex + // blending. + // + // D3DDECLUSAGE_BLENDINDICES + // Blending indices data. Use D3DDECLUSAGE_BLENDINDICES with a usage index of + // 0 to specify matrix indices for indexed paletted skinning. + // + // D3DDECLUSAGE_NORMAL + // Vertex normal data. Use D3DDECLUSAGE_NORMAL with a usage index of 0 to + // specify vertex normals for fixed function vertex processing and the n-patch + // tessellator. Use D3DDECLUSAGE_NORMAL with a usage index of 1 to specify + // vertex normals for fixed function vertex processing for vertex tweening. + // + // D3DDECLUSAGE_PSIZE + // Point size data. Use D3DDECLUSAGE_PSIZE with a usage index of 0 to specify + // the point-size attribute used by the setup engine of the rasterizer to + // expand a point into a quad for the point-sprite functionality. + // + // D3DDECLUSAGE_TEXCOORD + // Texture coordinate data. Use D3DDECLUSAGE_TEXCOORD, n to specify texture + // coordinates in fixed function vertex processing and in pixel shaders prior + // to ps_3_0. These can be used to pass user defined data. + // + // D3DDECLUSAGE_TANGENT + // Vertex tangent data. + // + // D3DDECLUSAGE_BINORMAL + // Vertex binormal data. + // + // D3DDECLUSAGE_TESSFACTOR + // Single positive floating point value. Use D3DDECLUSAGE_TESSFACTOR with a + // usage index of 0 to specify a tessellation factor used in the tessellation + // unit to control the rate of tessellation. For more information about the + // data type, see D3DDECLTYPE_FLOAT1. + // + // D3DDECLUSAGE_POSITIONT + // Vertex data contains transformed position data ranging from (0,0) to + // (viewport width, viewport height). Use D3DDECLUSAGE_POSITIONT with a usage + // index of 0 to specify transformed position. When a declaration containing + // this is set, the pipeline does not perform vertex processing. + // + // D3DDECLUSAGE_COLOR + // Vertex data contains diffuse or specular color. Use D3DDECLUSAGE_COLOR with + // a usage index of 0 to specify the diffuse color in the fixed function + // vertex shader and pixel shaders prior to ps_3_0. Use D3DDECLUSAGE_COLOR + // with a usage index of 1 to specify the specular color in the fixed function + // vertex shader and pixel shaders prior to ps_3_0. + // + // D3DDECLUSAGE_FOG + // Vertex data contains fog data. Use D3DDECLUSAGE_FOG with a usage index of 0 + // to specify a fog blend value used after pixel shading finishes. This + // applies to pixel shaders prior to version ps_3_0. + // + // D3DDECLUSAGE_DEPTH + // Vertex data contains depth data. + // + // D3DDECLUSAGE_SAMPLE + // Vertex data contains sampler data. Use D3DDECLUSAGE_SAMPLE with a usage + // index of 0 to specify the displacement value to look up. It can be used + // only with D3DDECLUSAGE_LOOKUPPRESAMPLED or D3DDECLUSAGE_LOOKUP. + + //note the form of the list terminator.. + + // #define D3DDECL_END() {0xFF,0,D3DDECLTYPE_UNUSED,0,0,0} + // typedef struct _D3DVERTEXELEMENT9 + // { + // WORD Stream; // Stream index + // WORD Offset; // Offset in the stream in bytes + // BYTE Type; // Data type + // BYTE Method; // Processing method + // BYTE Usage; // Semantics + // BYTE UsageIndex; // Semantic index + // } D3DVERTEXELEMENT9, *LPD3DVERTEXELEMENT9; + +#define MAX_D3DVERTEXELEMENTS 16 + +struct TOGL_CLASS IDirect3DVertexDeclaration9 : public IUnknown +{ +//public: + uint m_elemCount; + D3DVERTEXELEMENT9_GL m_elements[ MAX_D3DVERTEXELEMENTS ]; + + virtual ~IDirect3DVertexDeclaration9(); +}; + +struct TOGL_CLASS IDirect3DQuery9 : public IDirect3DResource9 //was IUnknown +{ +//public: + D3DQUERYTYPE m_type; // D3DQUERYTYPE_OCCLUSION or D3DQUERYTYPE_EVENT + GLMContext *m_ctx; + CGLMQuery *m_query; + + virtual ~IDirect3DQuery9(); + + HRESULT Issue(DWORD dwIssueFlags); + HRESULT GetData(void* pData,DWORD dwSize,DWORD dwGetDataFlags); +}; + +struct TOGL_CLASS IDirect3DVertexBuffer9 : public IDirect3DResource9 //was IUnknown +{ +//public: + GLMContext *m_ctx; + CGLMBuffer *m_vtxBuffer; + D3DVERTEXBUFFER_DESC m_vtxDesc; // to satisfy GetDesc + + virtual ~IDirect3DVertexBuffer9(); + HRESULT Lock(UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags); + HRESULT Unlock(); + HRESULT UnlockActualSize( uint nActualSize, const void *pActualData = NULL ); + +}; + +struct TOGL_CLASS IDirect3DIndexBuffer9 : public IDirect3DResource9 //was IUnknown +{ +//public: + GLMContext *m_ctx; + CGLMBuffer *m_idxBuffer; + D3DINDEXBUFFER_DESC m_idxDesc; // to satisfy GetDesc + + virtual ~IDirect3DIndexBuffer9(); + + HRESULT Lock(UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags); + HRESULT Unlock(); + HRESULT UnlockActualSize( uint nActualSize, const void *pActualData = NULL ); + HRESULT GetDesc(D3DINDEXBUFFER_DESC *pDesc); +}; + +struct TOGL_CLASS IDirect3DPixelShader9 : public IDirect3DResource9 //was IUnknown +{ +//public: + CGLMProgram *m_pixProgram; + uint m_pixHighWater; // count of active constant slots referenced by shader. + uint m_pixSamplerMask; // (1< m_stack; + int m_stackTop; // top of stack is at the highest index, this is that index. push increases, pop decreases. + + HRESULT Create( void ); + + D3DXMATRIX* GetTop(); + void Push(); + void Pop(); + void LoadIdentity(); + void LoadMatrix( const D3DXMATRIX *pMat ); + void MultMatrix( const D3DXMATRIX *pMat ); + void MultMatrixLocal( const D3DXMATRIX *pMat ); + HRESULT ScaleLocal(FLOAT x, FLOAT y, FLOAT z); + + // Left multiply the current matrix with the computed rotation + // matrix, counterclockwise about the given axis with the given angle. + // (rotation is about the local origin of the object) + HRESULT RotateAxisLocal(CONST D3DXVECTOR3* pV, FLOAT Angle); + + // Left multiply the current matrix with the computed translation + // matrix. (transformation is about the local origin of the object) + HRESULT TranslateLocal(FLOAT x, FLOAT y, FLOAT z); +}; +typedef ID3DXMatrixStack* LPD3DXMATRIXSTACK; + +struct TOGL_CLASS IDirect3DDevice9 : public IUnknown +{ +public: + // members + + IDirect3DDevice9Params m_params; // mirror of the creation inputs + + // D3D flavor stuff + IDirect3DSurface9 *m_rtSurfaces[16]; // current color RT surfaces. [0] is initially == m_defaultColorSurface + IDirect3DSurface9 *m_dsSurface; // current DS RT surface. can be changed! + + IDirect3DSurface9 *m_defaultColorSurface; // default color surface. + IDirect3DSurface9 *m_defaultDepthStencilSurface; // queried by GetDepthStencilSurface. + + IDirect3DVertexDeclaration9 *m_vertDecl; // Set by SetVertexDeclaration... + D3DStreamDesc m_streams[ D3D_MAX_STREAMS ]; // Set by SetStreamSource.. + D3DIndexDesc m_indices; // Set by SetIndices.. + + IDirect3DVertexShader9 *m_vertexShader; // Set by SetVertexShader... + IDirect3DPixelShader9 *m_pixelShader; // Set by SetPixelShader... + + IDirect3DBaseTexture9 *m_textures[16]; // set by SetTexture... NULL if stage inactive + D3DSamplerDesc m_samplers[16]; // set by SetSamplerState.. + // GLM flavor stuff + GLMContext *m_ctx; + CGLMFBO *m_drawableFBO; // this FBO should have all the attachments set to match m_rtSurfaces and m_dsSurface. + + // GL state + struct + { + // render state buckets + GLAlphaTestEnable_t m_AlphaTestEnable; + GLAlphaTestFunc_t m_AlphaTestFunc; + + GLAlphaToCoverageEnable_t m_AlphaToCoverageEnable; + + GLDepthTestEnable_t m_DepthTestEnable; + GLDepthMask_t m_DepthMask; + GLDepthFunc_t m_DepthFunc; + + GLClipPlaneEnable_t m_ClipPlaneEnable[kGLMUserClipPlanes]; + GLClipPlaneEquation_t m_ClipPlaneEquation[kGLMUserClipPlanes]; + + GLColorMaskSingle_t m_ColorMaskSingle; + GLColorMaskMultiple_t m_ColorMaskMultiple; + + GLCullFaceEnable_t m_CullFaceEnable; + GLCullFrontFace_t m_CullFrontFace; + GLPolygonMode_t m_PolygonMode; + GLDepthBias_t m_DepthBias; + GLScissorEnable_t m_ScissorEnable; + GLScissorBox_t m_ScissorBox; + GLViewportBox_t m_ViewportBox; + GLViewportDepthRange_t m_ViewportDepthRange; + + GLBlendEnable_t m_BlendEnable; + GLBlendFactor_t m_BlendFactor; + GLBlendEquation_t m_BlendEquation; + GLBlendColor_t m_BlendColor; + GLBlendEnableSRGB_t m_BlendEnableSRGB; + + GLStencilTestEnable_t m_StencilTestEnable; + GLStencilFunc_t m_StencilFunc; + GLStencilOp_t m_StencilOp; + GLStencilWriteMask_t m_StencilWriteMask; + + GLClearColor_t m_ClearColor; + GLClearDepth_t m_ClearDepth; + GLClearStencil_t m_ClearStencil; + + bool m_FogEnable; // not really pushed to GL, just latched here + + // samplers + GLMTexSamplingParams m_samplers[ 16 ]; + + // bindings...hmmm... + + // dirty-bits + uint m_stateDirtyMask; // covers the state blocks, indexed by 1<m_nCurOwnerThreadId; } + +}; + +struct ID3DXInclude +{ + virtual HRESULT Open(D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes) = 0; + virtual HRESULT Close(LPCVOID pData) = 0; +}; +typedef ID3DXInclude* LPD3DXINCLUDE; + + +struct TOGL_CLASS ID3DXBuffer : public IUnknown +{ + void* GetBufferPointer(); + DWORD GetBufferSize(); +}; + +typedef ID3DXBuffer* LPD3DXBUFFER; + +class TOGL_CLASS ID3DXConstantTable : public IUnknown +{ +}; +typedef ID3DXConstantTable* LPD3DXCONSTANTTABLE; + + + +// ------------------------------------------------------------------------------------------------------------------------------ // +// D3DX stuff. +// ------------------------------------------------------------------------------------------------------------------------------ // + +TOGL_INTERFACE const char* D3DXGetPixelShaderProfile( IDirect3DDevice9 *pDevice ); + + +TOGL_INTERFACE D3DXMATRIX* D3DXMatrixMultiply( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); +TOGL_INTERFACE D3DXVECTOR3* D3DXVec3TransformCoord( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +TOGL_INTERFACE HRESULT D3DXCreateMatrixStack( DWORD Flags, LPD3DXMATRIXSTACK* ppStack); +TOGL_INTERFACE void D3DXMatrixIdentity( D3DXMATRIX * ); + +TOGL_INTERFACE D3DXINLINE D3DXVECTOR3* D3DXVec3Subtract( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + pOut->z = pV1->z - pV2->z; + return pOut; +} + +TOGL_INTERFACE D3DXINLINE D3DXVECTOR3* D3DXVec3Cross( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ + D3DXVECTOR3 v; + + v.x = pV1->y * pV2->z - pV1->z * pV2->y; + v.y = pV1->z * pV2->x - pV1->x * pV2->z; + v.z = pV1->x * pV2->y - pV1->y * pV2->x; + + *pOut = v; + return pOut; +} + +TOGL_INTERFACE D3DXINLINE FLOAT D3DXVec3Dot( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ + return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z; +} + +TOGL_INTERFACE D3DXMATRIX* D3DXMatrixInverse( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); + +TOGL_INTERFACE D3DXMATRIX* D3DXMatrixTranspose( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); + +TOGL_INTERFACE D3DXPLANE* D3DXPlaneNormalize( D3DXPLANE *pOut, CONST D3DXPLANE *pP); + +TOGL_INTERFACE D3DXVECTOR4* D3DXVec4Transform( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); + + +TOGL_INTERFACE D3DXVECTOR4* D3DXVec4Normalize( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); + +TOGL_INTERFACE D3DXMATRIX* D3DXMatrixTranslation( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); + +// Build an ortho projection matrix. (right-handed) +TOGL_INTERFACE D3DXMATRIX* D3DXMatrixOrthoOffCenterRH( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,FLOAT zf ); + +TOGL_INTERFACE D3DXMATRIX* D3DXMatrixPerspectiveRH( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +TOGL_INTERFACE D3DXMATRIX* D3DXMatrixPerspectiveOffCenterRH( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); + +// Transform a plane by a matrix. The vector (a,b,c) must be normal. +// M should be the inverse transpose of the transformation desired. +TOGL_INTERFACE D3DXPLANE* D3DXPlaneTransform( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); + +TOGL_INTERFACE IDirect3D9 *Direct3DCreate9(UINT SDKVersion); + +TOGL_INTERFACE void D3DPERF_SetOptions( DWORD dwOptions ); + +TOGL_INTERFACE HRESULT D3DXCompileShader( + LPCSTR pSrcData, + UINT SrcDataLen, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pFunctionName, + LPCSTR pProfile, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs, + LPD3DXCONSTANTTABLE* ppConstantTable); + + +#endif // USE_ACTUAL_DX + +// fake D3D usage constant for SRGB tex creation +#define D3DUSAGE_TEXTURE_SRGB (0x80000000L) + +#endif // DXABSTRACT_H diff --git a/mp/src/public/togl/osx/glfuncs.h b/mp/src/public/togl/osx/glfuncs.h index 78184bef..b0be737c 100644 --- a/mp/src/public/togl/osx/glfuncs.h +++ b/mp/src/public/togl/osx/glfuncs.h @@ -1,184 +1,184 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// !!! FIXME: Some of these aren't base OpenGL...pick out the extensions. -// !!! FIXME: Also, look up these -1, -1 versions numbers. -GL_FUNC(OpenGL,true,GLenum,glGetError,(void),()) -GL_FUNC_VOID(OpenGL,true,glActiveTexture,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glAlphaFunc,(GLenum a,GLclampf b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glAttachObjectARB,(GLhandleARB a,GLhandleARB b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glBegin,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glBindAttribLocationARB,(GLhandleARB a,GLuint b,const GLcharARB *c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glBindBufferARB,(GLenum a,GLuint b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glBindProgramARB,(GLenum a,GLuint b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glBindTexture,(GLenum a,GLuint b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glBlendColor,(GLclampf a,GLclampf b,GLclampf c,GLclampf d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glBlendEquation,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glBlendFunc,(GLenum a,GLenum b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glBufferDataARB,(GLenum a,GLsizeiptrARB b,const GLvoid *c,GLenum d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glClear,(GLbitfield a),(a)) -GL_FUNC_VOID(OpenGL,true,glClearColor,(GLclampf a,GLclampf b,GLclampf c,GLclampf d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glClearDepth,(GLclampd a),(a)) -GL_FUNC_VOID(OpenGL,true,glClearStencil,(GLint a),(a)) -GL_FUNC_VOID(OpenGL,true,glClipPlane,(GLenum a,const GLdouble *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glColorMask,(GLboolean a,GLboolean b,GLboolean c,GLboolean d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glCompileShaderARB,(GLhandleARB a),(a)) -GL_FUNC_VOID(OpenGL,true,glCompressedTexImage2D,(GLenum a,GLint b,GLenum c,GLsizei d,GLsizei e,GLint f,GLsizei g,const GLvoid *h),(a,b,c,d,e,f,g,h)) -GL_FUNC_VOID(OpenGL,true,glCompressedTexImage3D,(GLenum a,GLint b,GLenum c,GLsizei d,GLsizei e,GLsizei f,GLint g,GLsizei h,const GLvoid *i),(a,b,c,d,e,f,g,h,i)) -GL_FUNC(OpenGL,true,GLhandleARB,glCreateProgramObjectARB,(void),()) -GL_FUNC(OpenGL,true,GLhandleARB,glCreateShaderObjectARB,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glDeleteBuffersARB,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glDeleteObjectARB,(GLhandleARB a),(a)) -GL_FUNC_VOID(OpenGL,true,glDeleteProgramsARB,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glDeleteQueriesARB,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glDeleteShader,(GLuint a),(a)) -GL_FUNC_VOID(OpenGL,true,glDeleteTextures,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glDepthFunc,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glDepthMask,(GLboolean a),(a)) -GL_FUNC_VOID(OpenGL,true,glDepthRange,(GLclampd a,GLclampd b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glDetachObjectARB,(GLhandleARB a,GLhandleARB b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glDisable,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glDisableVertexAttribArray,(GLuint a),(a)) -GL_FUNC_VOID(OpenGL,true,glDrawArrays,(GLenum a,GLint b,GLsizei c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glDrawBuffer,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glDrawRangeElements,(GLenum a,GLuint b,GLuint c,GLsizei d,GLenum e,const GLvoid *f),(a,b,c,d,e,f)) -GL_FUNC_VOID(OpenGL,true,glEnable,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glEnableVertexAttribArray,(GLuint a),(a)) -GL_FUNC_VOID(OpenGL,true,glEnd,(void),()) -GL_FUNC_VOID(OpenGL,true,glFinish,(void),()) -GL_FUNC_VOID(OpenGL,true,glFlush,(void),()) -GL_FUNC_VOID(OpenGL,true,glFrontFace,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glGenBuffersARB,(GLsizei a,GLuint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glGenProgramsARB,(GLsizei a,GLuint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glGenQueriesARB,(GLsizei a,GLuint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glGenTextures,(GLsizei a,GLuint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glGetBooleanv,(GLenum a,GLboolean *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glGetCompressedTexImage,(GLenum a,GLint b,GLvoid *c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glGetDoublev,(GLenum a,GLdouble *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glGetFloatv,(GLenum a,GLfloat *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glGetInfoLogARB,(GLhandleARB a,GLsizei b,GLsizei *c,GLcharARB *d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glGetIntegerv,(GLenum a,GLint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glGetObjectParameterivARB,(GLhandleARB a,GLenum b,GLint *c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glGetProgramivARB,(GLenum a,GLenum b,GLint *c),(a,b,c)) -GL_FUNC(OpenGL,true,const GLubyte *,glGetString,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glGetTexImage,(GLenum a,GLint b,GLenum c,GLenum d,GLvoid *e),(a,b,c,d,e)) -GL_FUNC(OpenGL,true,GLint,glGetUniformLocationARB,(GLhandleARB a,const GLcharARB *b),(a,b)) -GL_FUNC(OpenGL,true,GLboolean,glIsEnabled,(GLenum a),(a)) -GL_FUNC(OpenGL,true,GLboolean,glIsTexture,(GLuint a),(a)) -GL_FUNC_VOID(OpenGL,true,glLinkProgramARB,(GLhandleARB a),(a)) -GL_FUNC(OpenGL,true,GLvoid*,glMapBufferARB,(GLenum a,GLenum b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glOrtho,(GLdouble a,GLdouble b,GLdouble c,GLdouble d,GLdouble e,GLdouble f),(a,b,c,d,e,f)) -GL_FUNC_VOID(OpenGL,true,glPixelStorei,(GLenum a,GLint b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glPolygonMode,(GLenum a,GLenum b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glPolygonOffset,(GLfloat a,GLfloat b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glPopAttrib,(void),()) -GL_FUNC_VOID(OpenGL,true,glProgramStringARB,(GLenum a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glPushAttrib,(GLbitfield a),(a)) -GL_FUNC_VOID(OpenGL,true,glReadBuffer,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glScissor,(GLint a,GLint b,GLsizei c,GLsizei d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glShaderSourceARB,(GLhandleARB a,GLsizei b,const GLcharARB **c,const GLint *d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glStencilFunc,(GLenum a,GLint b,GLuint c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glStencilMask,(GLuint a),(a)) -GL_FUNC_VOID(OpenGL,true,glStencilOp,(GLenum a,GLenum b,GLenum c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glTexCoord2f,(GLfloat a,GLfloat b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glTexImage2D,(GLenum a,GLint b,GLint c,GLsizei d,GLsizei e,GLint f,GLenum g,GLenum h,const GLvoid *i),(a,b,c,d,e,f,g,h,i)) -GL_FUNC_VOID(OpenGL,true,glTexImage3D,(GLenum a,GLint b,GLint c,GLsizei d,GLsizei e,GLsizei f,GLint g,GLenum h,GLenum i,const GLvoid *j),(a,b,c,d,e,f,g,h,i,j)) -GL_FUNC_VOID(OpenGL,true,glTexParameterfv,(GLenum a,GLenum b,const GLfloat *c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glTexParameteri,(GLenum a,GLenum b,GLint c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glTexSubImage2D,(GLenum a,GLint b,GLint c,GLint d,GLsizei e,GLsizei f,GLenum g,GLenum h,const GLvoid *i),(a,b,c,d,e,f,g,h,i)) -GL_FUNC_VOID(OpenGL,true,glUniform1f,(GLint a,GLfloat b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glUniform1i,(GLint a,GLint b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glUniform1iARB,(GLint a,GLint b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glUniform4fv,(GLint a,GLsizei b,const GLfloat *c),(a,b,c)) -GL_FUNC(OpenGL,true,GLboolean,glUnmapBuffer,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glUseProgram,(GLuint a),(a)) -GL_FUNC_VOID(OpenGL,true,glVertex3f,(GLfloat a,GLfloat b,GLfloat c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glVertexAttribPointer,(GLuint a,GLint b,GLenum c,GLboolean d,GLsizei e,const GLvoid *f),(a,b,c,d,e,f)) -GL_FUNC_VOID(OpenGL,true,glViewport,(GLint a,GLint b,GLsizei c,GLsizei d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glEnableClientState,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glDisableClientState,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glClientActiveTexture,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glVertexPointer,(GLint a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glTexCoordPointer,(GLint a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glProgramEnvParameters4fvEXT,(GLenum a,GLuint b,GLsizei c,const GLfloat *d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glColor4sv,(const GLshort *a),(a)) -GL_FUNC_VOID(OpenGL,true,glStencilOpSeparate,(GLenum a,GLenum b,GLenum c,GLenum d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glStencilFuncSeparate,(GLenum a,GLenum b,GLint c,GLuint d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glGetTexLevelParameteriv,(GLenum a,GLint b,GLenum c,GLint *d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glColor4f,(GLfloat a,GLfloat b,GLfloat c,GLfloat d),(a,b,c,d)) -GL_EXT(GL_EXT_framebuffer_object,-1,-1) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glBindFramebufferEXT,(GLenum a,GLuint b),(a,b)) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glBindRenderbufferEXT,(GLenum a,GLuint b),(a,b)) -GL_FUNC(GL_EXT_framebuffer_object,false,GLenum,glCheckFramebufferStatusEXT,(GLenum a),(a)) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glDeleteRenderbuffersEXT,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glFramebufferRenderbufferEXT,(GLenum a,GLenum b,GLenum c,GLuint d),(a,b,c,d)) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glFramebufferTexture2DEXT,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e),(a,b,c,d,e)) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glFramebufferTexture3DEXT,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e,GLint f),(a,b,c,d,e,f)) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glGenFramebuffersEXT,(GLsizei a,GLuint *b),(a,b)) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glGenRenderbuffersEXT,(GLsizei a,GLuint *b),(a,b)) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glDeleteFramebuffersEXT,(GLsizei a,const GLuint *b),(a,b)) -GL_EXT(GL_EXT_framebuffer_blit,-1,-1) -GL_FUNC_VOID(GL_EXT_framebuffer_blit,false,glBlitFramebufferEXT,(GLint a,GLint b,GLint c,GLint d,GLint e,GLint f,GLint g,GLint h,GLbitfield i,GLenum j),(a,b,c,d,e,f,g,h,i,j)) -GL_EXT(GL_EXT_framebuffer_multisample,-1,-1) -GL_FUNC_VOID(GL_EXT_framebuffer_multisample,false,glRenderbufferStorageMultisampleEXT,(GLenum a,GLsizei b,GLenum c,GLsizei d,GLsizei e),(a,b,c,d,e)) -GL_EXT(GL_APPLE_fence,-1,-1) -GL_FUNC(GL_APPLE_fence,false,GLboolean,glTestFenceAPPLE,(GLuint a),(a)) -GL_FUNC_VOID(GL_APPLE_fence,false,glSetFenceAPPLE,(GLuint a),(a)) -GL_FUNC_VOID(GL_APPLE_fence,false,glFinishFenceAPPLE,(GLuint a),(a)) -GL_FUNC_VOID(GL_APPLE_fence,false,glDeleteFencesAPPLE,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(GL_APPLE_fence,false,glGenFencesAPPLE,(GLsizei a,GLuint *b),(a,b)) -GL_EXT(GL_NV_fence,-1,-1) -GL_FUNC(GL_NV_fence,false,GLboolean,glTestFenceNV,(GLuint a),(a)) -GL_FUNC_VOID(GL_NV_fence,false,glSetFenceNV,(GLuint a,GLenum b),(a,b)) -GL_FUNC_VOID(GL_NV_fence,false,glFinishFenceNV,(GLuint a),(a)) -GL_FUNC_VOID(GL_NV_fence,false,glDeleteFencesNV,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(GL_NV_fence,false,glGenFencesNV,(GLsizei a,GLuint *b),(a,b)) -GL_EXT(GL_ARB_sync,3,2) -#ifdef HAVE_GL_ARB_SYNC -GL_FUNC_VOID(GL_ARB_sync,false,glGetSynciv,(GLsync a, GLenum b, GLsizei c, GLsizei *d, GLint *e),(a,b,c,d,e)) -GL_FUNC(GL_ARB_sync,false,GLenum,glClientWaitSync,(GLsync a, GLbitfield b, GLuint64 c),(a,b,c)) -GL_FUNC_VOID(GL_ARB_sync,false,glWaitSync,(GLsync a, GLbitfield b, GLuint64 c),(a,b,c)) -GL_FUNC_VOID(GL_ARB_sync,false,glDeleteSync,(GLsync a),(a)) -GL_FUNC(GL_ARB_sync,false,GLsync,glFenceSync,(GLenum a, GLbitfield b),(a,b)) -#endif -GL_EXT(GL_EXT_draw_buffers2,-1,-1) -GL_FUNC_VOID(GL_EXT_draw_buffers2,false,glColorMaskIndexedEXT,(GLuint a,GLboolean b,GLboolean c,GLboolean d,GLboolean e),(a,b,c,d,e)) -GL_FUNC_VOID(GL_EXT_draw_buffers2,false,glEnableIndexedEXT,(GLenum a,GLuint b),(a,b)) -GL_FUNC_VOID(GL_EXT_draw_buffers2,false,glDisableIndexedEXT,(GLenum a,GLuint b),(a,b)) -GL_FUNC_VOID(GL_EXT_draw_buffers2,false,glGetBooleanIndexedvEXT,(GLenum a,GLuint b,GLboolean *c),(a,b,c)) -GL_EXT(GL_EXT_bindable_uniform,-1,-1) -GL_FUNC_VOID(GL_EXT_bindable_uniform,false,glUniformBufferEXT,(GLuint a,GLint b,GLuint c),(a,b,c)) -GL_EXT(GL_APPLE_flush_buffer_range,-1,-1) -GL_FUNC_VOID(GL_APPLE_flush_buffer_range,false,glBufferParameteriAPPLE,(GLenum a,GLenum b,GLint c),(a,b,c)) -GL_FUNC_VOID(GL_APPLE_flush_buffer_range,false,glFlushMappedBufferRangeAPPLE,(GLenum a,GLintptr b,GLsizeiptr c),(a,b,c)) -GL_EXT(GL_ARB_map_buffer_range,-1,-1) -GL_FUNC(GL_ARB_map_buffer_range,false,void*,glMapBufferRange,(GLenum a,GLintptr b,GLsizeiptr c,GLbitfield d),(a,b,c,d)) -GL_FUNC_VOID(GL_ARB_map_buffer_range,false,glFlushMappedBufferRange,(GLenum a,GLintptr b,GLsizeiptr c),(a,b,c)) -GL_EXT(GL_ARB_occlusion_query,-1,-1) -GL_FUNC_VOID(GL_ARB_occlusion_query,false,glBeginQueryARB,(GLenum a,GLuint b),(a,b)) -GL_FUNC_VOID(GL_ARB_occlusion_query,false,glEndQueryARB,(GLenum a),(a)) -GL_FUNC_VOID(GL_ARB_occlusion_query,false,glGetQueryObjectivARB,(GLuint a,GLenum b,GLint *c),(a,b,c)) -GL_FUNC_VOID(GL_ARB_occlusion_query,false,glGetQueryObjectuivARB,(GLuint a,GLenum b,GLuint *c),(a,b,c)) -GL_EXT(GL_APPLE_texture_range,-1,-1) -GL_FUNC_VOID(GL_APPLE_texture_range,false,glTextureRangeAPPLE,(GLenum a,GLsizei b,void *c),(a,b,c)) -GL_FUNC_VOID(GL_APPLE_texture_range,false,glGetTexParameterPointervAPPLE,(GLenum a,GLenum b,void* *c),(a,b,c)) -GL_EXT(GL_APPLE_client_storage,-1,-1) -GL_EXT(GL_ARB_uniform_buffer,-1,-1) -GL_EXT(GL_ARB_vertex_array_bgra,-1,-1) -GL_EXT(GL_EXT_vertex_array_bgra,-1,-1) -GL_EXT(GL_ARB_framebuffer_object,3,0) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glBindFramebuffer,(GLenum a,GLuint b),(a,b)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glBindRenderbuffer,(GLenum a,GLuint b),(a,b)) -GL_FUNC(GL_ARB_framebuffer_object,false,GLenum,glCheckFramebufferStatus,(GLenum a),(a)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glDeleteRenderbuffers,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glFramebufferRenderbuffer,(GLenum a,GLenum b,GLenum c,GLuint d),(a,b,c,d)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glFramebufferTexture2D,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e),(a,b,c,d,e)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glFramebufferTexture3D,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e,GLint f),(a,b,c,d,e,f)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glGenFramebuffers,(GLsizei a,GLuint *b),(a,b)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glGenRenderbuffers,(GLsizei a,GLuint *b),(a,b)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glDeleteFramebuffers,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glBlitFramebuffer,(GLint a,GLint b,GLint c,GLint d,GLint e,GLint f,GLint g,GLint h,GLbitfield i,GLenum j),(a,b,c,d,e,f,g,h,i,j)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glRenderbufferStorageMultisample,(GLenum a,GLsizei b,GLenum c,GLsizei d,GLsizei e),(a,b,c,d,e)) -GL_EXT(GL_GREMEDY_string_marker,-1,-1) -GL_FUNC_VOID(GL_GREMEDY_string_marker,false,glStringMarkerGREMEDY,(GLsizei a,const void *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glPushClientAttrib,(GLbitfield a),(a)) -GL_FUNC_VOID(OpenGL,true,glPopClientAttrib,(void),()) - +// !!! FIXME: Some of these aren't base OpenGL...pick out the extensions. +// !!! FIXME: Also, look up these -1, -1 versions numbers. +GL_FUNC(OpenGL,true,GLenum,glGetError,(void),()) +GL_FUNC_VOID(OpenGL,true,glActiveTexture,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glAlphaFunc,(GLenum a,GLclampf b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glAttachObjectARB,(GLhandleARB a,GLhandleARB b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glBegin,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glBindAttribLocationARB,(GLhandleARB a,GLuint b,const GLcharARB *c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glBindBufferARB,(GLenum a,GLuint b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glBindProgramARB,(GLenum a,GLuint b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glBindTexture,(GLenum a,GLuint b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glBlendColor,(GLclampf a,GLclampf b,GLclampf c,GLclampf d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glBlendEquation,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glBlendFunc,(GLenum a,GLenum b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glBufferDataARB,(GLenum a,GLsizeiptrARB b,const GLvoid *c,GLenum d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glClear,(GLbitfield a),(a)) +GL_FUNC_VOID(OpenGL,true,glClearColor,(GLclampf a,GLclampf b,GLclampf c,GLclampf d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glClearDepth,(GLclampd a),(a)) +GL_FUNC_VOID(OpenGL,true,glClearStencil,(GLint a),(a)) +GL_FUNC_VOID(OpenGL,true,glClipPlane,(GLenum a,const GLdouble *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glColorMask,(GLboolean a,GLboolean b,GLboolean c,GLboolean d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glCompileShaderARB,(GLhandleARB a),(a)) +GL_FUNC_VOID(OpenGL,true,glCompressedTexImage2D,(GLenum a,GLint b,GLenum c,GLsizei d,GLsizei e,GLint f,GLsizei g,const GLvoid *h),(a,b,c,d,e,f,g,h)) +GL_FUNC_VOID(OpenGL,true,glCompressedTexImage3D,(GLenum a,GLint b,GLenum c,GLsizei d,GLsizei e,GLsizei f,GLint g,GLsizei h,const GLvoid *i),(a,b,c,d,e,f,g,h,i)) +GL_FUNC(OpenGL,true,GLhandleARB,glCreateProgramObjectARB,(void),()) +GL_FUNC(OpenGL,true,GLhandleARB,glCreateShaderObjectARB,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glDeleteBuffersARB,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glDeleteObjectARB,(GLhandleARB a),(a)) +GL_FUNC_VOID(OpenGL,true,glDeleteProgramsARB,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glDeleteQueriesARB,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glDeleteShader,(GLuint a),(a)) +GL_FUNC_VOID(OpenGL,true,glDeleteTextures,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glDepthFunc,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glDepthMask,(GLboolean a),(a)) +GL_FUNC_VOID(OpenGL,true,glDepthRange,(GLclampd a,GLclampd b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glDetachObjectARB,(GLhandleARB a,GLhandleARB b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glDisable,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glDisableVertexAttribArray,(GLuint a),(a)) +GL_FUNC_VOID(OpenGL,true,glDrawArrays,(GLenum a,GLint b,GLsizei c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glDrawBuffer,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glDrawRangeElements,(GLenum a,GLuint b,GLuint c,GLsizei d,GLenum e,const GLvoid *f),(a,b,c,d,e,f)) +GL_FUNC_VOID(OpenGL,true,glEnable,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glEnableVertexAttribArray,(GLuint a),(a)) +GL_FUNC_VOID(OpenGL,true,glEnd,(void),()) +GL_FUNC_VOID(OpenGL,true,glFinish,(void),()) +GL_FUNC_VOID(OpenGL,true,glFlush,(void),()) +GL_FUNC_VOID(OpenGL,true,glFrontFace,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glGenBuffersARB,(GLsizei a,GLuint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glGenProgramsARB,(GLsizei a,GLuint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glGenQueriesARB,(GLsizei a,GLuint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glGenTextures,(GLsizei a,GLuint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glGetBooleanv,(GLenum a,GLboolean *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glGetCompressedTexImage,(GLenum a,GLint b,GLvoid *c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glGetDoublev,(GLenum a,GLdouble *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glGetFloatv,(GLenum a,GLfloat *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glGetInfoLogARB,(GLhandleARB a,GLsizei b,GLsizei *c,GLcharARB *d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glGetIntegerv,(GLenum a,GLint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glGetObjectParameterivARB,(GLhandleARB a,GLenum b,GLint *c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glGetProgramivARB,(GLenum a,GLenum b,GLint *c),(a,b,c)) +GL_FUNC(OpenGL,true,const GLubyte *,glGetString,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glGetTexImage,(GLenum a,GLint b,GLenum c,GLenum d,GLvoid *e),(a,b,c,d,e)) +GL_FUNC(OpenGL,true,GLint,glGetUniformLocationARB,(GLhandleARB a,const GLcharARB *b),(a,b)) +GL_FUNC(OpenGL,true,GLboolean,glIsEnabled,(GLenum a),(a)) +GL_FUNC(OpenGL,true,GLboolean,glIsTexture,(GLuint a),(a)) +GL_FUNC_VOID(OpenGL,true,glLinkProgramARB,(GLhandleARB a),(a)) +GL_FUNC(OpenGL,true,GLvoid*,glMapBufferARB,(GLenum a,GLenum b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glOrtho,(GLdouble a,GLdouble b,GLdouble c,GLdouble d,GLdouble e,GLdouble f),(a,b,c,d,e,f)) +GL_FUNC_VOID(OpenGL,true,glPixelStorei,(GLenum a,GLint b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glPolygonMode,(GLenum a,GLenum b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glPolygonOffset,(GLfloat a,GLfloat b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glPopAttrib,(void),()) +GL_FUNC_VOID(OpenGL,true,glProgramStringARB,(GLenum a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glPushAttrib,(GLbitfield a),(a)) +GL_FUNC_VOID(OpenGL,true,glReadBuffer,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glScissor,(GLint a,GLint b,GLsizei c,GLsizei d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glShaderSourceARB,(GLhandleARB a,GLsizei b,const GLcharARB **c,const GLint *d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glStencilFunc,(GLenum a,GLint b,GLuint c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glStencilMask,(GLuint a),(a)) +GL_FUNC_VOID(OpenGL,true,glStencilOp,(GLenum a,GLenum b,GLenum c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glTexCoord2f,(GLfloat a,GLfloat b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glTexImage2D,(GLenum a,GLint b,GLint c,GLsizei d,GLsizei e,GLint f,GLenum g,GLenum h,const GLvoid *i),(a,b,c,d,e,f,g,h,i)) +GL_FUNC_VOID(OpenGL,true,glTexImage3D,(GLenum a,GLint b,GLint c,GLsizei d,GLsizei e,GLsizei f,GLint g,GLenum h,GLenum i,const GLvoid *j),(a,b,c,d,e,f,g,h,i,j)) +GL_FUNC_VOID(OpenGL,true,glTexParameterfv,(GLenum a,GLenum b,const GLfloat *c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glTexParameteri,(GLenum a,GLenum b,GLint c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glTexSubImage2D,(GLenum a,GLint b,GLint c,GLint d,GLsizei e,GLsizei f,GLenum g,GLenum h,const GLvoid *i),(a,b,c,d,e,f,g,h,i)) +GL_FUNC_VOID(OpenGL,true,glUniform1f,(GLint a,GLfloat b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glUniform1i,(GLint a,GLint b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glUniform1iARB,(GLint a,GLint b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glUniform4fv,(GLint a,GLsizei b,const GLfloat *c),(a,b,c)) +GL_FUNC(OpenGL,true,GLboolean,glUnmapBuffer,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glUseProgram,(GLuint a),(a)) +GL_FUNC_VOID(OpenGL,true,glVertex3f,(GLfloat a,GLfloat b,GLfloat c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glVertexAttribPointer,(GLuint a,GLint b,GLenum c,GLboolean d,GLsizei e,const GLvoid *f),(a,b,c,d,e,f)) +GL_FUNC_VOID(OpenGL,true,glViewport,(GLint a,GLint b,GLsizei c,GLsizei d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glEnableClientState,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glDisableClientState,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glClientActiveTexture,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glVertexPointer,(GLint a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glTexCoordPointer,(GLint a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glProgramEnvParameters4fvEXT,(GLenum a,GLuint b,GLsizei c,const GLfloat *d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glColor4sv,(const GLshort *a),(a)) +GL_FUNC_VOID(OpenGL,true,glStencilOpSeparate,(GLenum a,GLenum b,GLenum c,GLenum d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glStencilFuncSeparate,(GLenum a,GLenum b,GLint c,GLuint d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glGetTexLevelParameteriv,(GLenum a,GLint b,GLenum c,GLint *d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glColor4f,(GLfloat a,GLfloat b,GLfloat c,GLfloat d),(a,b,c,d)) +GL_EXT(GL_EXT_framebuffer_object,-1,-1) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glBindFramebufferEXT,(GLenum a,GLuint b),(a,b)) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glBindRenderbufferEXT,(GLenum a,GLuint b),(a,b)) +GL_FUNC(GL_EXT_framebuffer_object,false,GLenum,glCheckFramebufferStatusEXT,(GLenum a),(a)) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glDeleteRenderbuffersEXT,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glFramebufferRenderbufferEXT,(GLenum a,GLenum b,GLenum c,GLuint d),(a,b,c,d)) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glFramebufferTexture2DEXT,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e),(a,b,c,d,e)) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glFramebufferTexture3DEXT,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e,GLint f),(a,b,c,d,e,f)) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glGenFramebuffersEXT,(GLsizei a,GLuint *b),(a,b)) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glGenRenderbuffersEXT,(GLsizei a,GLuint *b),(a,b)) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glDeleteFramebuffersEXT,(GLsizei a,const GLuint *b),(a,b)) +GL_EXT(GL_EXT_framebuffer_blit,-1,-1) +GL_FUNC_VOID(GL_EXT_framebuffer_blit,false,glBlitFramebufferEXT,(GLint a,GLint b,GLint c,GLint d,GLint e,GLint f,GLint g,GLint h,GLbitfield i,GLenum j),(a,b,c,d,e,f,g,h,i,j)) +GL_EXT(GL_EXT_framebuffer_multisample,-1,-1) +GL_FUNC_VOID(GL_EXT_framebuffer_multisample,false,glRenderbufferStorageMultisampleEXT,(GLenum a,GLsizei b,GLenum c,GLsizei d,GLsizei e),(a,b,c,d,e)) +GL_EXT(GL_APPLE_fence,-1,-1) +GL_FUNC(GL_APPLE_fence,false,GLboolean,glTestFenceAPPLE,(GLuint a),(a)) +GL_FUNC_VOID(GL_APPLE_fence,false,glSetFenceAPPLE,(GLuint a),(a)) +GL_FUNC_VOID(GL_APPLE_fence,false,glFinishFenceAPPLE,(GLuint a),(a)) +GL_FUNC_VOID(GL_APPLE_fence,false,glDeleteFencesAPPLE,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(GL_APPLE_fence,false,glGenFencesAPPLE,(GLsizei a,GLuint *b),(a,b)) +GL_EXT(GL_NV_fence,-1,-1) +GL_FUNC(GL_NV_fence,false,GLboolean,glTestFenceNV,(GLuint a),(a)) +GL_FUNC_VOID(GL_NV_fence,false,glSetFenceNV,(GLuint a,GLenum b),(a,b)) +GL_FUNC_VOID(GL_NV_fence,false,glFinishFenceNV,(GLuint a),(a)) +GL_FUNC_VOID(GL_NV_fence,false,glDeleteFencesNV,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(GL_NV_fence,false,glGenFencesNV,(GLsizei a,GLuint *b),(a,b)) +GL_EXT(GL_ARB_sync,3,2) +#ifdef HAVE_GL_ARB_SYNC +GL_FUNC_VOID(GL_ARB_sync,false,glGetSynciv,(GLsync a, GLenum b, GLsizei c, GLsizei *d, GLint *e),(a,b,c,d,e)) +GL_FUNC(GL_ARB_sync,false,GLenum,glClientWaitSync,(GLsync a, GLbitfield b, GLuint64 c),(a,b,c)) +GL_FUNC_VOID(GL_ARB_sync,false,glWaitSync,(GLsync a, GLbitfield b, GLuint64 c),(a,b,c)) +GL_FUNC_VOID(GL_ARB_sync,false,glDeleteSync,(GLsync a),(a)) +GL_FUNC(GL_ARB_sync,false,GLsync,glFenceSync,(GLenum a, GLbitfield b),(a,b)) +#endif +GL_EXT(GL_EXT_draw_buffers2,-1,-1) +GL_FUNC_VOID(GL_EXT_draw_buffers2,false,glColorMaskIndexedEXT,(GLuint a,GLboolean b,GLboolean c,GLboolean d,GLboolean e),(a,b,c,d,e)) +GL_FUNC_VOID(GL_EXT_draw_buffers2,false,glEnableIndexedEXT,(GLenum a,GLuint b),(a,b)) +GL_FUNC_VOID(GL_EXT_draw_buffers2,false,glDisableIndexedEXT,(GLenum a,GLuint b),(a,b)) +GL_FUNC_VOID(GL_EXT_draw_buffers2,false,glGetBooleanIndexedvEXT,(GLenum a,GLuint b,GLboolean *c),(a,b,c)) +GL_EXT(GL_EXT_bindable_uniform,-1,-1) +GL_FUNC_VOID(GL_EXT_bindable_uniform,false,glUniformBufferEXT,(GLuint a,GLint b,GLuint c),(a,b,c)) +GL_EXT(GL_APPLE_flush_buffer_range,-1,-1) +GL_FUNC_VOID(GL_APPLE_flush_buffer_range,false,glBufferParameteriAPPLE,(GLenum a,GLenum b,GLint c),(a,b,c)) +GL_FUNC_VOID(GL_APPLE_flush_buffer_range,false,glFlushMappedBufferRangeAPPLE,(GLenum a,GLintptr b,GLsizeiptr c),(a,b,c)) +GL_EXT(GL_ARB_map_buffer_range,-1,-1) +GL_FUNC(GL_ARB_map_buffer_range,false,void*,glMapBufferRange,(GLenum a,GLintptr b,GLsizeiptr c,GLbitfield d),(a,b,c,d)) +GL_FUNC_VOID(GL_ARB_map_buffer_range,false,glFlushMappedBufferRange,(GLenum a,GLintptr b,GLsizeiptr c),(a,b,c)) +GL_EXT(GL_ARB_occlusion_query,-1,-1) +GL_FUNC_VOID(GL_ARB_occlusion_query,false,glBeginQueryARB,(GLenum a,GLuint b),(a,b)) +GL_FUNC_VOID(GL_ARB_occlusion_query,false,glEndQueryARB,(GLenum a),(a)) +GL_FUNC_VOID(GL_ARB_occlusion_query,false,glGetQueryObjectivARB,(GLuint a,GLenum b,GLint *c),(a,b,c)) +GL_FUNC_VOID(GL_ARB_occlusion_query,false,glGetQueryObjectuivARB,(GLuint a,GLenum b,GLuint *c),(a,b,c)) +GL_EXT(GL_APPLE_texture_range,-1,-1) +GL_FUNC_VOID(GL_APPLE_texture_range,false,glTextureRangeAPPLE,(GLenum a,GLsizei b,void *c),(a,b,c)) +GL_FUNC_VOID(GL_APPLE_texture_range,false,glGetTexParameterPointervAPPLE,(GLenum a,GLenum b,void* *c),(a,b,c)) +GL_EXT(GL_APPLE_client_storage,-1,-1) +GL_EXT(GL_ARB_uniform_buffer,-1,-1) +GL_EXT(GL_ARB_vertex_array_bgra,-1,-1) +GL_EXT(GL_EXT_vertex_array_bgra,-1,-1) +GL_EXT(GL_ARB_framebuffer_object,3,0) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glBindFramebuffer,(GLenum a,GLuint b),(a,b)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glBindRenderbuffer,(GLenum a,GLuint b),(a,b)) +GL_FUNC(GL_ARB_framebuffer_object,false,GLenum,glCheckFramebufferStatus,(GLenum a),(a)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glDeleteRenderbuffers,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glFramebufferRenderbuffer,(GLenum a,GLenum b,GLenum c,GLuint d),(a,b,c,d)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glFramebufferTexture2D,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e),(a,b,c,d,e)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glFramebufferTexture3D,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e,GLint f),(a,b,c,d,e,f)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glGenFramebuffers,(GLsizei a,GLuint *b),(a,b)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glGenRenderbuffers,(GLsizei a,GLuint *b),(a,b)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glDeleteFramebuffers,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glBlitFramebuffer,(GLint a,GLint b,GLint c,GLint d,GLint e,GLint f,GLint g,GLint h,GLbitfield i,GLenum j),(a,b,c,d,e,f,g,h,i,j)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glRenderbufferStorageMultisample,(GLenum a,GLsizei b,GLenum c,GLsizei d,GLsizei e),(a,b,c,d,e)) +GL_EXT(GL_GREMEDY_string_marker,-1,-1) +GL_FUNC_VOID(GL_GREMEDY_string_marker,false,glStringMarkerGREMEDY,(GLsizei a,const void *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glPushClientAttrib,(GLbitfield a),(a)) +GL_FUNC_VOID(OpenGL,true,glPopClientAttrib,(void),()) + diff --git a/mp/src/public/togl/osx/glmdisplay.h b/mp/src/public/togl/osx/glmdisplay.h index cf3a3b90..c0d9e10b 100644 --- a/mp/src/public/togl/osx/glmdisplay.h +++ b/mp/src/public/togl/osx/glmdisplay.h @@ -1,177 +1,177 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// -// glmdisplay.h -// display related stuff - used by both GLMgr and the CocoaMgr -// -//=============================================================================== - -#ifndef GLMDISPLAY_H -#define GLMDISPLAY_H - -#pragma once - -#ifdef OSX -#include -#include -#include -#include -#include -#include - -typedef uint32_t CGDirectDisplayID; -typedef uint32_t CGOpenGLDisplayMask; -typedef double CGRefreshRate; - -//#include -#elif defined(LINUX) -#include "tier0/platform.h" -#include -#include -#else -#error -#endif - -typedef void _PseudoNSGLContext; // aka NSOpenGLContext -typedef _PseudoNSGLContext *PseudoNSGLContextPtr; - -struct GLMDisplayModeInfoFields -{ - uint m_modePixelWidth; - uint m_modePixelHeight; - uint m_modeRefreshHz; - // are we even going to talk about bit depth... not yet -}; - -struct GLMDisplayInfoFields -{ -#ifdef OSX - CGDirectDisplayID m_cgDisplayID; - CGOpenGLDisplayMask m_glDisplayMask; // result of CGDisplayIDToOpenGLDisplayMask on the cg_displayID. -#endif - uint m_displayPixelWidth; - uint m_displayPixelHeight; -}; - -struct GLMRendererInfoFields -{ - /*properties of interest and their desired values. - - kCGLRPFullScreen = 54, true - kCGLRPAccelerated = 73, true - kCGLRPWindow = 80, true - - kCGLRPRendererID = 70, informational - kCGLRPDisplayMask = 84, informational - kCGLRPBufferModes = 100, informational - kCGLRPColorModes = 103, informational - kCGLRPAccumModes = 104, informational - kCGLRPDepthModes = 105, informational - kCGLRPStencilModes = 106, informational - kCGLRPMaxAuxBuffers = 107, informational - kCGLRPMaxSampleBuffers = 108, informational - kCGLRPMaxSamples = 109, informational - kCGLRPSampleModes = 110, informational - kCGLRPSampleAlpha = 111, informational - kCGLRPVideoMemory = 120, informational - kCGLRPTextureMemory = 121, informational - kCGLRPRendererCount = 128 number of renderers in the CGLRendererInfoObj under examination - - kCGLRPOffScreen = 53, D/C - kCGLRPRobust = 75, FALSE or D/C - aka we're asking for no-fallback - kCGLRPBackingStore = 76, D/C - kCGLRPMPSafe = 78, D/C - kCGLRPMultiScreen = 81, D/C - kCGLRPCompliant = 83, D/C - */ - - - //--------------------------- info we have from CGL renderer queries, IOKit, Gestalt - //--------------------------- these are set up in the displayDB by CocoaMgr - GLint m_fullscreen; - GLint m_accelerated; - GLint m_windowed; - - GLint m_rendererID; - GLint m_displayMask; - GLint m_bufferModes; - GLint m_colorModes; - GLint m_accumModes; - GLint m_depthModes; - GLint m_stencilModes; - - GLint m_maxAuxBuffers; - GLint m_maxSampleBuffers; - GLint m_maxSamples; - GLint m_sampleModes; - GLint m_sampleAlpha; - - GLint m_vidMemory; - GLint m_texMemory; - - uint m_pciVendorID; - uint m_pciDeviceID; - char m_pciModelString[64]; - char m_driverInfoString[64]; - - //--------------------------- OS version related - set up by CocoaMgr - - // OS version found - uint m_osComboVersion; // 0x00XXYYZZ : XX major, YY minor, ZZ minor minor : 10.6.3 --> 0x000A0603. 10.5.8 --> 0x000A0508. - - //--------------------------- shorthands - also set up by CocoaMgr - driven by vendorid / deviceid - - bool m_ati; - bool m_atiR5xx; - bool m_atiR6xx; - bool m_atiR7xx; - bool m_atiR8xx; - bool m_atiNewer; - - bool m_intel; - bool m_intel95x; - bool m_intel3100; - bool m_intelNewer; - - bool m_nv; - bool m_nvG7x; - bool m_nvG8x; - bool m_nvNewer; - - //--------------------------- context query results - left blank in the display DB - but valid in a GLMContext (call ctx->Caps() to get a const ref) - - // booleans - bool m_hasGammaWrites; // aka glGetBooleanv(GL_FRAMEBUFFER_SRGB_CAPABLE_EXT) / glEnable(GL_FRAMEBUFFER_SRGB_EXT) - bool m_hasMixedAttachmentSizes; // aka ARB_fbo in 10.6.3 - test for min OS vers, then exported ext string - bool m_hasBGRA; // aka GL_BGRA vertex attribs in 10.6.3 - - test for min OS vers, then exported ext string - bool m_hasNewFullscreenMode; // aka 10.6.x "big window" fullscreen mode - bool m_hasNativeClipVertexMode; // aka GLSL gl_ClipVertex does not fall back to SW- OS version and folklore-based - bool m_hasOcclusionQuery; // occlusion query: do you speak it ?! - bool m_hasFramebufferBlit; // framebuffer blit: know what I'm sayin?! - bool m_hasPerfPackage1; // means new MTGL, fast OQ, fast uniform upload, NV can resolve flipped (late summer 2010 post 10.6.4 update) - - // counts - int m_maxAniso; // aniso limit - context query - - // other exts - bool m_hasBindableUniforms; - bool m_hasUniformBuffers; - - // runtime options that aren't negotiable once set - bool m_hasDualShaders; // must supply CLI arg "-glmdualshaders" or we go GLSL only - - //--------------------------- " can'ts " - specific problems that need to be worked around - - bool m_cantBlitReliably; // Intel chipsets have problems blitting sRGB sometimes - bool m_cantAttachSRGB; // NV G8x on 10.5.8 can't have srgb tex on FBO color - separate issue from hasGammaWrites - bool m_cantResolveFlipped; // happens on NV in 10.6.4 and prior - console variable "gl_can_resolve_flipped" can overrule - bool m_cantResolveScaled; // happens everywhere per GL spec but may be relaxed some day - console variable "gl_can_resolve_scaled" can overrule - bool m_costlyGammaFlips; // this means that sRGB sampling state affects shader code gen, resulting in state-dependent code regen - - - //--------------------------- " bads " - known bad drivers - bool m_badDriver1064NV; // this is the bad NVIDIA driver on 10.6.4 - stutter, tex corruption, black screen issues -}; - - - -#endif +// +// glmdisplay.h +// display related stuff - used by both GLMgr and the CocoaMgr +// +//=============================================================================== + +#ifndef GLMDISPLAY_H +#define GLMDISPLAY_H + +#pragma once + +#ifdef OSX +#include +#include +#include +#include +#include +#include + +typedef uint32_t CGDirectDisplayID; +typedef uint32_t CGOpenGLDisplayMask; +typedef double CGRefreshRate; + +//#include +#elif defined(LINUX) +#include "tier0/platform.h" +#include +#include +#else +#error +#endif + +typedef void _PseudoNSGLContext; // aka NSOpenGLContext +typedef _PseudoNSGLContext *PseudoNSGLContextPtr; + +struct GLMDisplayModeInfoFields +{ + uint m_modePixelWidth; + uint m_modePixelHeight; + uint m_modeRefreshHz; + // are we even going to talk about bit depth... not yet +}; + +struct GLMDisplayInfoFields +{ +#ifdef OSX + CGDirectDisplayID m_cgDisplayID; + CGOpenGLDisplayMask m_glDisplayMask; // result of CGDisplayIDToOpenGLDisplayMask on the cg_displayID. +#endif + uint m_displayPixelWidth; + uint m_displayPixelHeight; +}; + +struct GLMRendererInfoFields +{ + /*properties of interest and their desired values. + + kCGLRPFullScreen = 54, true + kCGLRPAccelerated = 73, true + kCGLRPWindow = 80, true + + kCGLRPRendererID = 70, informational + kCGLRPDisplayMask = 84, informational + kCGLRPBufferModes = 100, informational + kCGLRPColorModes = 103, informational + kCGLRPAccumModes = 104, informational + kCGLRPDepthModes = 105, informational + kCGLRPStencilModes = 106, informational + kCGLRPMaxAuxBuffers = 107, informational + kCGLRPMaxSampleBuffers = 108, informational + kCGLRPMaxSamples = 109, informational + kCGLRPSampleModes = 110, informational + kCGLRPSampleAlpha = 111, informational + kCGLRPVideoMemory = 120, informational + kCGLRPTextureMemory = 121, informational + kCGLRPRendererCount = 128 number of renderers in the CGLRendererInfoObj under examination + + kCGLRPOffScreen = 53, D/C + kCGLRPRobust = 75, FALSE or D/C - aka we're asking for no-fallback + kCGLRPBackingStore = 76, D/C + kCGLRPMPSafe = 78, D/C + kCGLRPMultiScreen = 81, D/C + kCGLRPCompliant = 83, D/C + */ + + + //--------------------------- info we have from CGL renderer queries, IOKit, Gestalt + //--------------------------- these are set up in the displayDB by CocoaMgr + GLint m_fullscreen; + GLint m_accelerated; + GLint m_windowed; + + GLint m_rendererID; + GLint m_displayMask; + GLint m_bufferModes; + GLint m_colorModes; + GLint m_accumModes; + GLint m_depthModes; + GLint m_stencilModes; + + GLint m_maxAuxBuffers; + GLint m_maxSampleBuffers; + GLint m_maxSamples; + GLint m_sampleModes; + GLint m_sampleAlpha; + + GLint m_vidMemory; + GLint m_texMemory; + + uint m_pciVendorID; + uint m_pciDeviceID; + char m_pciModelString[64]; + char m_driverInfoString[64]; + + //--------------------------- OS version related - set up by CocoaMgr + + // OS version found + uint m_osComboVersion; // 0x00XXYYZZ : XX major, YY minor, ZZ minor minor : 10.6.3 --> 0x000A0603. 10.5.8 --> 0x000A0508. + + //--------------------------- shorthands - also set up by CocoaMgr - driven by vendorid / deviceid + + bool m_ati; + bool m_atiR5xx; + bool m_atiR6xx; + bool m_atiR7xx; + bool m_atiR8xx; + bool m_atiNewer; + + bool m_intel; + bool m_intel95x; + bool m_intel3100; + bool m_intelNewer; + + bool m_nv; + bool m_nvG7x; + bool m_nvG8x; + bool m_nvNewer; + + //--------------------------- context query results - left blank in the display DB - but valid in a GLMContext (call ctx->Caps() to get a const ref) + + // booleans + bool m_hasGammaWrites; // aka glGetBooleanv(GL_FRAMEBUFFER_SRGB_CAPABLE_EXT) / glEnable(GL_FRAMEBUFFER_SRGB_EXT) + bool m_hasMixedAttachmentSizes; // aka ARB_fbo in 10.6.3 - test for min OS vers, then exported ext string + bool m_hasBGRA; // aka GL_BGRA vertex attribs in 10.6.3 - - test for min OS vers, then exported ext string + bool m_hasNewFullscreenMode; // aka 10.6.x "big window" fullscreen mode + bool m_hasNativeClipVertexMode; // aka GLSL gl_ClipVertex does not fall back to SW- OS version and folklore-based + bool m_hasOcclusionQuery; // occlusion query: do you speak it ?! + bool m_hasFramebufferBlit; // framebuffer blit: know what I'm sayin?! + bool m_hasPerfPackage1; // means new MTGL, fast OQ, fast uniform upload, NV can resolve flipped (late summer 2010 post 10.6.4 update) + + // counts + int m_maxAniso; // aniso limit - context query + + // other exts + bool m_hasBindableUniforms; + bool m_hasUniformBuffers; + + // runtime options that aren't negotiable once set + bool m_hasDualShaders; // must supply CLI arg "-glmdualshaders" or we go GLSL only + + //--------------------------- " can'ts " - specific problems that need to be worked around + + bool m_cantBlitReliably; // Intel chipsets have problems blitting sRGB sometimes + bool m_cantAttachSRGB; // NV G8x on 10.5.8 can't have srgb tex on FBO color - separate issue from hasGammaWrites + bool m_cantResolveFlipped; // happens on NV in 10.6.4 and prior - console variable "gl_can_resolve_flipped" can overrule + bool m_cantResolveScaled; // happens everywhere per GL spec but may be relaxed some day - console variable "gl_can_resolve_scaled" can overrule + bool m_costlyGammaFlips; // this means that sRGB sampling state affects shader code gen, resulting in state-dependent code regen + + + //--------------------------- " bads " - known bad drivers + bool m_badDriver1064NV; // this is the bad NVIDIA driver on 10.6.4 - stutter, tex corruption, black screen issues +}; + + + +#endif diff --git a/mp/src/public/togl/osx/glmgr.h b/mp/src/public/togl/osx/glmgr.h index cdf64206..24f9a00d 100644 --- a/mp/src/public/togl/osx/glmgr.h +++ b/mp/src/public/togl/osx/glmgr.h @@ -1,1088 +1,1088 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// -// glmgr.h -// singleton class, common basis for managing GL contexts -// responsible for tracking adapters and contexts -// -//=============================================================================== - -#ifndef GLMGR_H -#define GLMGR_H - -#pragma once - -#undef HAVE_GL_ARB_SYNC -#ifdef LINUX -#define HAVE_GL_ARB_SYNC 1 -#endif - -#include "glentrypoints.h" -#include "glmdebug.h" -#include "glmdisplay.h" -#include "glmgrext.h" -#include "glmgrbasics.h" -#include "cglmtex.h" -#include "cglmfbo.h" -#include "cglmprogram.h" -#include "cglmbuffer.h" -#include "cglmquery.h" - -#include "tier0/vprof_telemetry.h" -#include "materialsystem/ishader.h" -#include "dxabstract_types.h" - - -#ifdef LINUX -#define Debugger DebuggerBreak -#undef CurrentTime - -// prevent some conflicts in SDL headers... -#undef M_PI -#include -#ifndef _STDINT_H_ -#define _STDINT_H_ 1 -#endif - -#include "SDL/SDL.h" -#endif - -//=============================================================================== -// glue to call out to Obj-C land (these are in glmgrcocoa.mm) -#ifdef OSX -PseudoNSGLContextPtr GetCurrentNSGLContext( ); -CGLContextObj GetCGLContextFromNSGL( PseudoNSGLContextPtr nsglCtx ); -#endif - -#include "tier0/dynfunction.h" - -//=============================================================================== - -// parrot the D3D present parameters, more or less... "adapter" translates into "active display index" per the m_activeDisplayCount below. -class GLMDisplayParams -{ - public: - - // presumption, these indices are in sync with the current display DB that GLMgr has handy - //int m_rendererIndex; // index of renderer (-1 if root context) - //int m_displayIndex; // index of display in renderer - for FS - //int m_modeIndex; // index of mode in display - for FS - - void *m_focusWindow; // (VD3DHWND aka WindowRef) - what window does this context display into - - bool m_fsEnable; // fullscreen on or not - bool m_vsyncEnable; // vsync on or not - - // height and width have to match the display mode info if full screen. - - uint m_backBufferWidth; // pixel width (aka screen h-resolution if full screen) - uint m_backBufferHeight; // pixel height (aka screen v-resolution if full screen) - D3DFORMAT m_backBufferFormat; // pixel format - uint m_multiSampleCount; // 0 means no MSAA, 2 means 2x MSAA, etc - // uint m_multiSampleQuality; // no MSAA quality control yet - - bool m_enableAutoDepthStencil; // generally set to 'TRUE' per CShaderDeviceDx8::SetPresentParameters - D3DFORMAT m_autoDepthStencilFormat; - - uint m_fsRefreshHz; // if full screen, this refresh rate (likely 0 for LCD's) - - //uint m_rootRendererID; // only used if m_rendererIndex is -1. - //uint m_rootDisplayMask; // only used if m_rendererIndex is -1. - - bool m_mtgl; // enable multi threaded GL driver -}; - -//=============================================================================== - -class GLMgr -{ -public: - - //=========================================================================== - // class methods - singleton - static void NewGLMgr( void ); // instantiate singleton.. - static GLMgr *aGLMgr( void ); // return singleton.. - static void DelGLMgr( void ); // tear down singleton.. - - //=========================================================================== - // plain methods - - #if 0 // turned all these off while new approach is coded - void RefreshDisplayDB( void ); // blow away old display DB, make a new one - GLMDisplayDB *GetDisplayDB( void ); // get a ptr to the one GLMgr keeps. only valid til next refresh. - - // eligible renderers will be ranked by desirability starting at index 0 within the db - // within each renderer, eligible displays will be ranked some kind of desirability (area? dist from menu bar?) - // within each display, eligible modes will be ranked by descending areas - - // calls supplying indices are implicitly making reference to the current DB - bool CaptureDisplay( int rendIndex, int displayIndex, bool captureAll ); // capture one display or all displays - void ReleaseDisplays( void ); // release all captures - - int GetDisplayMode( int rendIndex, int displayIndex ); // retrieve current display res (returns modeIndex) - void SetDisplayMode( GLMDisplayParams *params ); // set the display res (only useful for FS) - #endif - - GLMContext *NewContext( GLMDisplayParams *params ); // this will have to change - void DelContext( GLMContext *context ); - - // with usage of CGLMacro.h we could dispense with the "current context" thing - // and just declare a member variable of GLMContext, allowing each glXXX call to be routed directly - // to the correct context - void SetCurrentContext( GLMContext *context ); // make current in calling thread only - GLMContext *GetCurrentContext( void ); - -protected: - friend class GLMContext; - - GLMgr(); - ~GLMgr(); -}; - - -//===========================================================================// - -// helper function to do enable or disable in one step -inline void glSetEnable( GLenum which, bool enable ) -{ - if (enable) - gGL->glEnable(which); - else - gGL->glDisable(which); -} - -// helper function for int vs enum clarity -inline void glGetEnumv( GLenum which, GLenum *dst ) -{ - gGL->glGetIntegerv( which, (int*)dst ); -} - -//===========================================================================// -// -// types to support the GLMContext -// -//===========================================================================// - -// Each state set/get path we are providing caching for, needs its own struct and a comparison operator. -// we also provide an enum of how many such types there are, handy for building dirty masks etc. - -// shorthand macros -#define EQ(fff) ( (src.fff) == (fff) ) - -//rasterizer -struct GLAlphaTestEnable_t { GLint enable; bool operator==(const GLAlphaTestEnable_t& src) const { return EQ(enable); } }; -struct GLAlphaTestFunc_t { GLenum func; GLclampf ref; bool operator==(const GLAlphaTestFunc_t& src) const { return EQ(func) && EQ(ref); } }; -struct GLCullFaceEnable_t { GLint enable; bool operator==(const GLCullFaceEnable_t& src) const { return EQ(enable); } }; -struct GLCullFrontFace_t { GLenum value; bool operator==(const GLCullFrontFace_t& src) const { return EQ(value); } }; -struct GLPolygonMode_t { GLenum values[2]; bool operator==(const GLPolygonMode_t& src) const { return EQ(values[0]) && EQ(values[1]); } }; -struct GLDepthBias_t { GLfloat factor; GLfloat units; bool operator==(const GLDepthBias_t& src) const { return EQ(factor) && EQ(units); } }; -struct GLScissorEnable_t { GLint enable; bool operator==(const GLScissorEnable_t& src) const { return EQ(enable); } }; -struct GLScissorBox_t { GLint x,y; GLsizei width, height; bool operator==(const GLScissorBox_t& src) const { return EQ(x) && EQ(y) && EQ(width) && EQ(height); } }; -struct GLAlphaToCoverageEnable_t{ GLint enable; bool operator==(const GLAlphaToCoverageEnable_t& src) const { return EQ(enable); } }; -struct GLViewportBox_t { GLint x,y; GLsizei width, height; bool operator==(const GLViewportBox_t& src) const { return EQ(x) && EQ(y) && EQ(width) && EQ(height); } }; -struct GLViewportDepthRange_t { GLdouble near,far; bool operator==(const GLViewportDepthRange_t& src) const { return EQ(near) && EQ(far); } }; -struct GLClipPlaneEnable_t { GLint enable; bool operator==(const GLClipPlaneEnable_t& src) const { return EQ(enable); } }; -struct GLClipPlaneEquation_t { GLfloat x,y,z,w; bool operator==(const GLClipPlaneEquation_t& src) const { return EQ(x) && EQ(y) && EQ(z) && EQ(w); } }; - -//blend -struct GLColorMaskSingle_t { char r,g,b,a; bool operator==(const GLColorMaskSingle_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; -struct GLColorMaskMultiple_t { char r,g,b,a; bool operator==(const GLColorMaskMultiple_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; -struct GLBlendEnable_t { GLint enable; bool operator==(const GLBlendEnable_t& src) const { return EQ(enable); } }; -struct GLBlendFactor_t { GLenum srcfactor,dstfactor; bool operator==(const GLBlendFactor_t& src) const { return EQ(srcfactor) && EQ(dstfactor); } }; -struct GLBlendEquation_t { GLenum equation; bool operator==(const GLBlendEquation_t& src) const { return EQ(equation); } }; -struct GLBlendColor_t { GLfloat r,g,b,a; bool operator==(const GLBlendColor_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; -struct GLBlendEnableSRGB_t { GLint enable; bool operator==(const GLBlendEnableSRGB_t& src) const { return EQ(enable); } }; - -//depth -struct GLDepthTestEnable_t { GLint enable; bool operator==(const GLDepthTestEnable_t& src) const { return EQ(enable); } }; -struct GLDepthFunc_t { GLenum func; bool operator==(const GLDepthFunc_t& src) const { return EQ(func); } }; -struct GLDepthMask_t { char mask; bool operator==(const GLDepthMask_t& src) const { return EQ(mask); } }; - -//stencil -struct GLStencilTestEnable_t { GLint enable; bool operator==(const GLStencilTestEnable_t& src) const { return EQ(enable); } }; -struct GLStencilFunc_t { GLenum frontfunc, backfunc; GLint ref; GLuint mask; bool operator==(const GLStencilFunc_t& src) const { return EQ(frontfunc) && EQ(backfunc) && EQ(ref) && EQ(mask); } }; -struct GLStencilOp_t { GLenum sfail; GLenum dpfail; GLenum dppass; bool operator==(const GLStencilOp_t& src) const { return EQ(sfail) && EQ(dpfail) && EQ(dppass); } }; -struct GLStencilWriteMask_t { GLint mask; bool operator==(const GLStencilWriteMask_t& src) const { return EQ(mask); } }; - -//clearing -struct GLClearColor_t { GLfloat r,g,b,a; bool operator==(const GLClearColor_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; -struct GLClearDepth_t { GLdouble d; bool operator==(const GLClearDepth_t& src) const { return EQ(d); } }; -struct GLClearStencil_t { GLint s; bool operator==(const GLClearStencil_t& src) const { return EQ(s); } }; - -#undef EQ - -enum EGLMStateBlockType -{ - kGLAlphaTestEnable, - kGLAlphaTestFunc, - - kGLCullFaceEnable, - kGLCullFrontFace, - - kGLPolygonMode, - - kGLDepthBias, - - kGLScissorEnable, - kGLScissorBox, - - kGLViewportBox, - kGLViewportDepthRange, - - kGLClipPlaneEnable, - kGLClipPlaneEquation, - - kGLColorMaskSingle, - kGLColorMaskMultiple, - - kGLBlendEnable, - kGLBlendFactor, - kGLBlendEquation, - kGLBlendColor, - kGLBlendEnableSRGB, - - kGLDepthTestEnable, - kGLDepthFunc, - kGLDepthMask, - - kGLStencilTestEnable, - kGLStencilFunc, - kGLStencilOp, - kGLStencilWriteMask, - - kGLClearColor, - kGLClearDepth, - kGLClearStencil, - - kGLAlphaToCoverageEnable, - - kGLMStateBlockLimit -}; - -//===========================================================================// - -// templated functions representing GL R/W bottlenecks -// one set of set/get/getdefault is instantiated for each of the GL*** types above. - -// use these from the non array state objects -template void GLContextSet( T *src ); -template void GLContextGet( T *dst ); -template void GLContextGetDefault( T *dst ); - -// use these from the array state objects -template void GLContextSetIndexed( T *src, int index ); -template void GLContextGetIndexed( T *dst, int index ); -template void GLContextGetDefaultIndexed( T *dst, int index ); - -//===========================================================================// - -// caching state object template. One of these is instantiated in the context per unique struct type above -template class GLState -{ - public: - - GLState() - { - dirty = false; - memset( &data, 0, sizeof(data) ); - }; - - // write: client src into cache - // common case is both false. dirty is calculated, context write is deferred. - void Write( T *src, bool noCompare=false, bool noDefer=false ) - { - if (noCompare) - { - dirty = true; - } - else - { - // only == is implemented, so test for equal and negate - // note, you only set dirty if mismatch, you never clear it until flush - if ( !(data == *src) ) - { - dirty = true; - } - } - - data = *src; - - if (noDefer) - { - Flush( true ); // dirty becomes false - } - }; - - // write cache->context if dirty or forced. - void Flush( bool noDefer=false ) - { - if (dirty || noDefer) - { - GLContextSet( &data ); - GLMCheckError(); - // good place for some error checking here - dirty = false; - } - }; - - // default: write default value to cache, optionally write through - void Default( bool noDefer=false ) - { - GLContextGetDefault( &data ); // read default values directly to our cache copy - dirty = true; - Flush(noDefer); - }; - - // read: sel = 0 for cache, 1 for context - void Read( T *dst, int sel ) - { - if (sel==0) - { - *dst = data; - } - else - { - GLContextGet( dst ); - GLMCheckError(); - } - }; - - // check: verify that context equals cache, return true if mismatched or if illegal values seen - bool Check ( void ) - { - T temp; - bool result; - - GLContextGet( &temp ); - GLMCheckError(); - result = !(temp == data); - return result; - }; - - protected: - T data; - bool dirty; -}; - -// caching state object template - with multiple values behind it that are indexed -template class GLStateArray -{ - public: - - GLStateArray() - { - memset( &dirty, 0, sizeof(dirty) ); - memset( &data, 0, sizeof(data) ); - }; - - // write: client src into cache - // common case is both false. dirty is calculated, context write is deferred. - void WriteIndex( T *src, int index, bool noCompare=false, bool noDefer=false ) - { - if (noCompare) - { - dirty[index] = true; - } - else - { - // only == is implemented, so test for equal and negate - // note, you only set dirty if mismatch, you never clear it until flush - if (! (data[index] == *src) ) - { - dirty[index] = true; - } - } - - data[index] = *src; - - if (noDefer) - { - FlushIndex( index, true ); // dirty becomes false - } - }; - - // write cache->context if dirty or forced. - void FlushIndex( int index, bool noDefer=false ) - { - if (dirty[index] || noDefer) - { - GLContextSetIndexed( &data[index], index ); - GLMCheckError(); - dirty[index] = false; - } - }; - - // write all slots in the array - void Flush( bool noDefer=false ) - { - for( int i=0; i m_AlphaTestEnable; - - GLState m_AlphaTestFunc; - - GLState m_CullFaceEnable; - GLState m_CullFrontFace; - GLState m_PolygonMode; - - GLState m_DepthBias; - - GLStateArray m_ClipPlaneEnable; - GLStateArray m_ClipPlaneEquation; // dxabstract puts them directly into param slot 253(0) and 254(1) - - GLState m_ScissorEnable; - GLState m_ScissorBox; - - GLState m_AlphaToCoverageEnable; - - GLState m_ViewportBox; - GLState m_ViewportDepthRange; - - GLState m_ColorMaskSingle; - GLStateArray m_ColorMaskMultiple; // need an official constant for the color buffers limit - - GLState m_BlendEnable; - GLState m_BlendFactor; - GLState m_BlendEquation; - GLState m_BlendColor; - GLState m_BlendEnableSRGB; // write to this one to transmit intent to write SRGB encoded pixels to drawing FB - bool m_FakeBlendEnableSRGB; // writes to above will be shunted here if fake SRGB is in effect. - - GLState m_DepthTestEnable; - GLState m_DepthFunc; - GLState m_DepthMask; - - GLState m_StencilTestEnable; // global stencil test enable - GLState m_StencilFunc; // holds front and back stencil funcs - GLStateArray m_StencilOp; // indexed: 0=front 1=back - GLState m_StencilWriteMask; - - GLState m_ClearColor; - GLState m_ClearDepth; - GLState m_ClearStencil; - - // texture bindings and sampler setup - int m_activeTexture; // mirror for glActiveTexture - GLMTexSampler m_samplers[GLM_SAMPLER_COUNT]; - - // texture lock tracking - CGLMTex objects share usage of this - CUtlVector< GLMTexLockDesc > m_texLocks; - - // render target binding - check before draw - // similar to tex sampler mechanism, we track "bound" from "chosen for drawing" separately, - // so binding for creation/setup need not disrupt any notion of what will be used at draw time - - CGLMFBO *m_boundDrawFBO; // FBO on GL_DRAW_FRAMEBUFFER bind point - CGLMFBO *m_boundReadFBO; // FBO on GL_READ_FRAMEBUFFER bind point - // ^ both are set if you bind to GL_FRAMEBUFFER_EXT - - CGLMFBO *m_drawingFBO; // what FBO should be bound at draw time (to both read/draw bp's). - - CGLMFBO *m_blitReadFBO; - CGLMFBO *m_blitDrawFBO; // scratch FBO's for framebuffer blit - - CGLMFBO *m_scratchFBO[ kGLMScratchFBOCount ]; // general purpose FBO's for internal use - - CUtlVector< CGLMFBO* > m_fboTable; // each live FBO goes in the table - - // program bindings - EGLMProgramLang m_drawingLangAtFrameStart; // selector for start of frame (spills into m_drawingLang) - EGLMProgramLang m_drawingLang; // selector for which language we desire to draw with on the next batch - CGLMProgram *m_drawingProgram[ kGLMNumProgramTypes ]; - - GLMProgramParamsF m_programParamsF[ kGLMNumProgramTypes ]; - GLMProgramParamsB m_programParamsB[ kGLMNumProgramTypes ]; // two banks, but only the vertex one is used - GLMProgramParamsI m_programParamsI[ kGLMNumProgramTypes ]; // two banks, but only the vertex one is used - EGLMParamWriteMode m_paramWriteMode; - - CGLMProgram *m_nullFragmentProgram; // write opaque black. Activate when caller asks for null FP - - CGLMProgram *m_preloadTexVertexProgram; // programs to help preload textures (dummies) - CGLMProgram *m_preload2DTexFragmentProgram; - CGLMProgram *m_preload3DTexFragmentProgram; - CGLMProgram *m_preloadCubeTexFragmentProgram; - - CGLMProgram *m_boundProgram[ kGLMNumProgramTypes ]; - - CGLMShaderPairCache *m_pairCache; // GLSL only - CGLMShaderPair *m_boundPair; // GLSL only - uint m_boundPairRevision; // GLSL only - GLhandleARB m_boundPairProgram; // GLSL only - - // buffer bindings - CGLMBuffer *m_lastKnownBufferBinds[ kGLMNumBufferTypes ]; // tracked per bind point for dupe-bind-absorb - GLMVertexAttributeDesc m_lastKnownVertexAttribs[ kGLMVertexAttributeIndexMax ]; // tracked per attrib for dupe-set-absorb - uint m_lastKnownVertexAttribMask; // tracked for dupe-enable-absorb - - CGLMBuffer *m_drawIndexBuffer; // ... ? do we need dupe tracking for index buffer setup? ? - - GLMVertexSetup m_drawVertexSetup; - - EGLMAttribWriteMode m_attribWriteMode; - - bool m_slowCheckEnable; // turn this on or no native checking is done ("-glmassertslow" or "-glmsspewslow") - bool m_slowAssertEnable; // turn this on to assert on a non-native batch "-glmassertslow" - bool m_slowSpewEnable; // turn this on to log non-native batches to stdout "-glmspewslow" - - // debug font texture - CGLMTex *m_debugFontTex; // might be NULL unless you call GenDebugFontTex - CGLMBuffer *m_debugFontIndices; // up to 1024 indices (256 chars times 4) - CGLMBuffer *m_debugFontVertices; // up to 1024 verts - - // batch/frame debugging support - int m_debugFrameIndex; // init to -1. Increment at BeginFrame - int m_debugBatchIndex; // init to -1. Increment at any draw call - -#if GLMDEBUG - // interactive (DebugHook) debug support - - // using these you can implement frame advance, batch single step, and batch rewind (let it run til next frame and hold on prev batch #) - int m_holdFrameBegin; // -1 if no hold req'd, otherwise # of frame to hold at (at beginframe time) - int m_holdFrameEnd; // -1 if no hold req'd, otherwise # of frame to hold at (at endframe time) - - int m_holdBatch,m_holdBatchFrame; // -1 if no hold, else # of batch&frame to hold at (both must be set) - // these can be expired/cleared to -1 if the frame passes without a hit - // may be desirable to re-pause in that event, as user was expecting a hold to occur - - bool m_debugDelayEnable; // allow sleep delay - uint m_debugDelay; // sleep time per hook call in microseconds (for usleep()) - - // pre-draw global toggles / options - bool m_autoClearColor,m_autoClearDepth,m_autoClearStencil; - float m_autoClearColorValues[4]; - - // debug knobs - int m_selKnobIndex; - float m_selKnobMinValue,m_selKnobMaxValue,m_selKnobIncrement; -#endif - -}; - -struct GLMTestParams -{ - GLMContext *m_ctx; - int *m_testList; // -1 termed - - bool m_glErrToDebugger; - bool m_glErrToConsole; - - bool m_intlErrToDebugger; - bool m_intlErrToConsole; - - int m_frameCount; // how many frames to test. -}; - -class GLMTester -{ - public: - - GLMTester(GLMTestParams *params); - ~GLMTester(); - - - // optionally callable by test routines to get basic drawables wired up - void StdSetup( void ); - void StdCleanup( void ); - - // callable by test routines to clear the frame or present it - void Clear( void ); - void Present( int seed ); - - // error reporting - void CheckGLError( char *comment ); // obey m_params setting for console / debugger response - void InternalError( int errcode, char *comment ); // if errcode!=0, obey m_params setting for console / debugger response - - void RunTests(); - - void RunOneTest( int testindex ); - - // test routines themselves - void Test0(); - void Test1(); - void Test2(); - void Test3(); - - GLMTestParams m_params; // copy of caller's params, do not mutate... - - // std-setup stuff - int m_drawWidth, m_drawHeight; - CGLMFBO *m_drawFBO; - CGLMTex *m_drawColorTex; - CGLMTex *m_drawDepthTex; -}; - -class CShowPixelsParams -{ -public: - GLuint m_srcTexName; - int m_width,m_height; - bool m_vsyncEnable; - bool m_fsEnable; // want receiving view to be full screen. for now, just target the main screen. extend later. - bool m_useBlit; // use FBO blit - sending context says it is available. - bool m_noBlit; // the back buffer has already been populated by the caller (perhaps via direct MSAA resolve from multisampled RT tex) - bool m_onlySyncView; // react to full/windowed state change only, do not present bits -}; - - -#define kMaxCrawlFrames 100 -#define kMaxCrawlText (kMaxCrawlFrames * 256) -class CStackCrawlParams -{ - public: - uint m_frameLimit; // input: max frames to retrieve - uint m_frameCount; // output: frames found - void *m_crawl[kMaxCrawlFrames]; // call site addresses - char *m_crawlNames[kMaxCrawlFrames]; // pointers into text following, one per decoded name - char m_crawlText[kMaxCrawlText]; -}; - -#endif +// +// glmgr.h +// singleton class, common basis for managing GL contexts +// responsible for tracking adapters and contexts +// +//=============================================================================== + +#ifndef GLMGR_H +#define GLMGR_H + +#pragma once + +#undef HAVE_GL_ARB_SYNC +#ifdef LINUX +#define HAVE_GL_ARB_SYNC 1 +#endif + +#include "glentrypoints.h" +#include "glmdebug.h" +#include "glmdisplay.h" +#include "glmgrext.h" +#include "glmgrbasics.h" +#include "cglmtex.h" +#include "cglmfbo.h" +#include "cglmprogram.h" +#include "cglmbuffer.h" +#include "cglmquery.h" + +#include "tier0/vprof_telemetry.h" +#include "materialsystem/ishader.h" +#include "dxabstract_types.h" + + +#ifdef LINUX +#define Debugger DebuggerBreak +#undef CurrentTime + +// prevent some conflicts in SDL headers... +#undef M_PI +#include +#ifndef _STDINT_H_ +#define _STDINT_H_ 1 +#endif + +#include "SDL/SDL.h" +#endif + +//=============================================================================== +// glue to call out to Obj-C land (these are in glmgrcocoa.mm) +#ifdef OSX +PseudoNSGLContextPtr GetCurrentNSGLContext( ); +CGLContextObj GetCGLContextFromNSGL( PseudoNSGLContextPtr nsglCtx ); +#endif + +#include "tier0/dynfunction.h" + +//=============================================================================== + +// parrot the D3D present parameters, more or less... "adapter" translates into "active display index" per the m_activeDisplayCount below. +class GLMDisplayParams +{ + public: + + // presumption, these indices are in sync with the current display DB that GLMgr has handy + //int m_rendererIndex; // index of renderer (-1 if root context) + //int m_displayIndex; // index of display in renderer - for FS + //int m_modeIndex; // index of mode in display - for FS + + void *m_focusWindow; // (VD3DHWND aka WindowRef) - what window does this context display into + + bool m_fsEnable; // fullscreen on or not + bool m_vsyncEnable; // vsync on or not + + // height and width have to match the display mode info if full screen. + + uint m_backBufferWidth; // pixel width (aka screen h-resolution if full screen) + uint m_backBufferHeight; // pixel height (aka screen v-resolution if full screen) + D3DFORMAT m_backBufferFormat; // pixel format + uint m_multiSampleCount; // 0 means no MSAA, 2 means 2x MSAA, etc + // uint m_multiSampleQuality; // no MSAA quality control yet + + bool m_enableAutoDepthStencil; // generally set to 'TRUE' per CShaderDeviceDx8::SetPresentParameters + D3DFORMAT m_autoDepthStencilFormat; + + uint m_fsRefreshHz; // if full screen, this refresh rate (likely 0 for LCD's) + + //uint m_rootRendererID; // only used if m_rendererIndex is -1. + //uint m_rootDisplayMask; // only used if m_rendererIndex is -1. + + bool m_mtgl; // enable multi threaded GL driver +}; + +//=============================================================================== + +class GLMgr +{ +public: + + //=========================================================================== + // class methods - singleton + static void NewGLMgr( void ); // instantiate singleton.. + static GLMgr *aGLMgr( void ); // return singleton.. + static void DelGLMgr( void ); // tear down singleton.. + + //=========================================================================== + // plain methods + + #if 0 // turned all these off while new approach is coded + void RefreshDisplayDB( void ); // blow away old display DB, make a new one + GLMDisplayDB *GetDisplayDB( void ); // get a ptr to the one GLMgr keeps. only valid til next refresh. + + // eligible renderers will be ranked by desirability starting at index 0 within the db + // within each renderer, eligible displays will be ranked some kind of desirability (area? dist from menu bar?) + // within each display, eligible modes will be ranked by descending areas + + // calls supplying indices are implicitly making reference to the current DB + bool CaptureDisplay( int rendIndex, int displayIndex, bool captureAll ); // capture one display or all displays + void ReleaseDisplays( void ); // release all captures + + int GetDisplayMode( int rendIndex, int displayIndex ); // retrieve current display res (returns modeIndex) + void SetDisplayMode( GLMDisplayParams *params ); // set the display res (only useful for FS) + #endif + + GLMContext *NewContext( GLMDisplayParams *params ); // this will have to change + void DelContext( GLMContext *context ); + + // with usage of CGLMacro.h we could dispense with the "current context" thing + // and just declare a member variable of GLMContext, allowing each glXXX call to be routed directly + // to the correct context + void SetCurrentContext( GLMContext *context ); // make current in calling thread only + GLMContext *GetCurrentContext( void ); + +protected: + friend class GLMContext; + + GLMgr(); + ~GLMgr(); +}; + + +//===========================================================================// + +// helper function to do enable or disable in one step +inline void glSetEnable( GLenum which, bool enable ) +{ + if (enable) + gGL->glEnable(which); + else + gGL->glDisable(which); +} + +// helper function for int vs enum clarity +inline void glGetEnumv( GLenum which, GLenum *dst ) +{ + gGL->glGetIntegerv( which, (int*)dst ); +} + +//===========================================================================// +// +// types to support the GLMContext +// +//===========================================================================// + +// Each state set/get path we are providing caching for, needs its own struct and a comparison operator. +// we also provide an enum of how many such types there are, handy for building dirty masks etc. + +// shorthand macros +#define EQ(fff) ( (src.fff) == (fff) ) + +//rasterizer +struct GLAlphaTestEnable_t { GLint enable; bool operator==(const GLAlphaTestEnable_t& src) const { return EQ(enable); } }; +struct GLAlphaTestFunc_t { GLenum func; GLclampf ref; bool operator==(const GLAlphaTestFunc_t& src) const { return EQ(func) && EQ(ref); } }; +struct GLCullFaceEnable_t { GLint enable; bool operator==(const GLCullFaceEnable_t& src) const { return EQ(enable); } }; +struct GLCullFrontFace_t { GLenum value; bool operator==(const GLCullFrontFace_t& src) const { return EQ(value); } }; +struct GLPolygonMode_t { GLenum values[2]; bool operator==(const GLPolygonMode_t& src) const { return EQ(values[0]) && EQ(values[1]); } }; +struct GLDepthBias_t { GLfloat factor; GLfloat units; bool operator==(const GLDepthBias_t& src) const { return EQ(factor) && EQ(units); } }; +struct GLScissorEnable_t { GLint enable; bool operator==(const GLScissorEnable_t& src) const { return EQ(enable); } }; +struct GLScissorBox_t { GLint x,y; GLsizei width, height; bool operator==(const GLScissorBox_t& src) const { return EQ(x) && EQ(y) && EQ(width) && EQ(height); } }; +struct GLAlphaToCoverageEnable_t{ GLint enable; bool operator==(const GLAlphaToCoverageEnable_t& src) const { return EQ(enable); } }; +struct GLViewportBox_t { GLint x,y; GLsizei width, height; bool operator==(const GLViewportBox_t& src) const { return EQ(x) && EQ(y) && EQ(width) && EQ(height); } }; +struct GLViewportDepthRange_t { GLdouble near,far; bool operator==(const GLViewportDepthRange_t& src) const { return EQ(near) && EQ(far); } }; +struct GLClipPlaneEnable_t { GLint enable; bool operator==(const GLClipPlaneEnable_t& src) const { return EQ(enable); } }; +struct GLClipPlaneEquation_t { GLfloat x,y,z,w; bool operator==(const GLClipPlaneEquation_t& src) const { return EQ(x) && EQ(y) && EQ(z) && EQ(w); } }; + +//blend +struct GLColorMaskSingle_t { char r,g,b,a; bool operator==(const GLColorMaskSingle_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; +struct GLColorMaskMultiple_t { char r,g,b,a; bool operator==(const GLColorMaskMultiple_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; +struct GLBlendEnable_t { GLint enable; bool operator==(const GLBlendEnable_t& src) const { return EQ(enable); } }; +struct GLBlendFactor_t { GLenum srcfactor,dstfactor; bool operator==(const GLBlendFactor_t& src) const { return EQ(srcfactor) && EQ(dstfactor); } }; +struct GLBlendEquation_t { GLenum equation; bool operator==(const GLBlendEquation_t& src) const { return EQ(equation); } }; +struct GLBlendColor_t { GLfloat r,g,b,a; bool operator==(const GLBlendColor_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; +struct GLBlendEnableSRGB_t { GLint enable; bool operator==(const GLBlendEnableSRGB_t& src) const { return EQ(enable); } }; + +//depth +struct GLDepthTestEnable_t { GLint enable; bool operator==(const GLDepthTestEnable_t& src) const { return EQ(enable); } }; +struct GLDepthFunc_t { GLenum func; bool operator==(const GLDepthFunc_t& src) const { return EQ(func); } }; +struct GLDepthMask_t { char mask; bool operator==(const GLDepthMask_t& src) const { return EQ(mask); } }; + +//stencil +struct GLStencilTestEnable_t { GLint enable; bool operator==(const GLStencilTestEnable_t& src) const { return EQ(enable); } }; +struct GLStencilFunc_t { GLenum frontfunc, backfunc; GLint ref; GLuint mask; bool operator==(const GLStencilFunc_t& src) const { return EQ(frontfunc) && EQ(backfunc) && EQ(ref) && EQ(mask); } }; +struct GLStencilOp_t { GLenum sfail; GLenum dpfail; GLenum dppass; bool operator==(const GLStencilOp_t& src) const { return EQ(sfail) && EQ(dpfail) && EQ(dppass); } }; +struct GLStencilWriteMask_t { GLint mask; bool operator==(const GLStencilWriteMask_t& src) const { return EQ(mask); } }; + +//clearing +struct GLClearColor_t { GLfloat r,g,b,a; bool operator==(const GLClearColor_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; +struct GLClearDepth_t { GLdouble d; bool operator==(const GLClearDepth_t& src) const { return EQ(d); } }; +struct GLClearStencil_t { GLint s; bool operator==(const GLClearStencil_t& src) const { return EQ(s); } }; + +#undef EQ + +enum EGLMStateBlockType +{ + kGLAlphaTestEnable, + kGLAlphaTestFunc, + + kGLCullFaceEnable, + kGLCullFrontFace, + + kGLPolygonMode, + + kGLDepthBias, + + kGLScissorEnable, + kGLScissorBox, + + kGLViewportBox, + kGLViewportDepthRange, + + kGLClipPlaneEnable, + kGLClipPlaneEquation, + + kGLColorMaskSingle, + kGLColorMaskMultiple, + + kGLBlendEnable, + kGLBlendFactor, + kGLBlendEquation, + kGLBlendColor, + kGLBlendEnableSRGB, + + kGLDepthTestEnable, + kGLDepthFunc, + kGLDepthMask, + + kGLStencilTestEnable, + kGLStencilFunc, + kGLStencilOp, + kGLStencilWriteMask, + + kGLClearColor, + kGLClearDepth, + kGLClearStencil, + + kGLAlphaToCoverageEnable, + + kGLMStateBlockLimit +}; + +//===========================================================================// + +// templated functions representing GL R/W bottlenecks +// one set of set/get/getdefault is instantiated for each of the GL*** types above. + +// use these from the non array state objects +template void GLContextSet( T *src ); +template void GLContextGet( T *dst ); +template void GLContextGetDefault( T *dst ); + +// use these from the array state objects +template void GLContextSetIndexed( T *src, int index ); +template void GLContextGetIndexed( T *dst, int index ); +template void GLContextGetDefaultIndexed( T *dst, int index ); + +//===========================================================================// + +// caching state object template. One of these is instantiated in the context per unique struct type above +template class GLState +{ + public: + + GLState() + { + dirty = false; + memset( &data, 0, sizeof(data) ); + }; + + // write: client src into cache + // common case is both false. dirty is calculated, context write is deferred. + void Write( T *src, bool noCompare=false, bool noDefer=false ) + { + if (noCompare) + { + dirty = true; + } + else + { + // only == is implemented, so test for equal and negate + // note, you only set dirty if mismatch, you never clear it until flush + if ( !(data == *src) ) + { + dirty = true; + } + } + + data = *src; + + if (noDefer) + { + Flush( true ); // dirty becomes false + } + }; + + // write cache->context if dirty or forced. + void Flush( bool noDefer=false ) + { + if (dirty || noDefer) + { + GLContextSet( &data ); + GLMCheckError(); + // good place for some error checking here + dirty = false; + } + }; + + // default: write default value to cache, optionally write through + void Default( bool noDefer=false ) + { + GLContextGetDefault( &data ); // read default values directly to our cache copy + dirty = true; + Flush(noDefer); + }; + + // read: sel = 0 for cache, 1 for context + void Read( T *dst, int sel ) + { + if (sel==0) + { + *dst = data; + } + else + { + GLContextGet( dst ); + GLMCheckError(); + } + }; + + // check: verify that context equals cache, return true if mismatched or if illegal values seen + bool Check ( void ) + { + T temp; + bool result; + + GLContextGet( &temp ); + GLMCheckError(); + result = !(temp == data); + return result; + }; + + protected: + T data; + bool dirty; +}; + +// caching state object template - with multiple values behind it that are indexed +template class GLStateArray +{ + public: + + GLStateArray() + { + memset( &dirty, 0, sizeof(dirty) ); + memset( &data, 0, sizeof(data) ); + }; + + // write: client src into cache + // common case is both false. dirty is calculated, context write is deferred. + void WriteIndex( T *src, int index, bool noCompare=false, bool noDefer=false ) + { + if (noCompare) + { + dirty[index] = true; + } + else + { + // only == is implemented, so test for equal and negate + // note, you only set dirty if mismatch, you never clear it until flush + if (! (data[index] == *src) ) + { + dirty[index] = true; + } + } + + data[index] = *src; + + if (noDefer) + { + FlushIndex( index, true ); // dirty becomes false + } + }; + + // write cache->context if dirty or forced. + void FlushIndex( int index, bool noDefer=false ) + { + if (dirty[index] || noDefer) + { + GLContextSetIndexed( &data[index], index ); + GLMCheckError(); + dirty[index] = false; + } + }; + + // write all slots in the array + void Flush( bool noDefer=false ) + { + for( int i=0; i m_AlphaTestEnable; + + GLState m_AlphaTestFunc; + + GLState m_CullFaceEnable; + GLState m_CullFrontFace; + GLState m_PolygonMode; + + GLState m_DepthBias; + + GLStateArray m_ClipPlaneEnable; + GLStateArray m_ClipPlaneEquation; // dxabstract puts them directly into param slot 253(0) and 254(1) + + GLState m_ScissorEnable; + GLState m_ScissorBox; + + GLState m_AlphaToCoverageEnable; + + GLState m_ViewportBox; + GLState m_ViewportDepthRange; + + GLState m_ColorMaskSingle; + GLStateArray m_ColorMaskMultiple; // need an official constant for the color buffers limit + + GLState m_BlendEnable; + GLState m_BlendFactor; + GLState m_BlendEquation; + GLState m_BlendColor; + GLState m_BlendEnableSRGB; // write to this one to transmit intent to write SRGB encoded pixels to drawing FB + bool m_FakeBlendEnableSRGB; // writes to above will be shunted here if fake SRGB is in effect. + + GLState m_DepthTestEnable; + GLState m_DepthFunc; + GLState m_DepthMask; + + GLState m_StencilTestEnable; // global stencil test enable + GLState m_StencilFunc; // holds front and back stencil funcs + GLStateArray m_StencilOp; // indexed: 0=front 1=back + GLState m_StencilWriteMask; + + GLState m_ClearColor; + GLState m_ClearDepth; + GLState m_ClearStencil; + + // texture bindings and sampler setup + int m_activeTexture; // mirror for glActiveTexture + GLMTexSampler m_samplers[GLM_SAMPLER_COUNT]; + + // texture lock tracking - CGLMTex objects share usage of this + CUtlVector< GLMTexLockDesc > m_texLocks; + + // render target binding - check before draw + // similar to tex sampler mechanism, we track "bound" from "chosen for drawing" separately, + // so binding for creation/setup need not disrupt any notion of what will be used at draw time + + CGLMFBO *m_boundDrawFBO; // FBO on GL_DRAW_FRAMEBUFFER bind point + CGLMFBO *m_boundReadFBO; // FBO on GL_READ_FRAMEBUFFER bind point + // ^ both are set if you bind to GL_FRAMEBUFFER_EXT + + CGLMFBO *m_drawingFBO; // what FBO should be bound at draw time (to both read/draw bp's). + + CGLMFBO *m_blitReadFBO; + CGLMFBO *m_blitDrawFBO; // scratch FBO's for framebuffer blit + + CGLMFBO *m_scratchFBO[ kGLMScratchFBOCount ]; // general purpose FBO's for internal use + + CUtlVector< CGLMFBO* > m_fboTable; // each live FBO goes in the table + + // program bindings + EGLMProgramLang m_drawingLangAtFrameStart; // selector for start of frame (spills into m_drawingLang) + EGLMProgramLang m_drawingLang; // selector for which language we desire to draw with on the next batch + CGLMProgram *m_drawingProgram[ kGLMNumProgramTypes ]; + + GLMProgramParamsF m_programParamsF[ kGLMNumProgramTypes ]; + GLMProgramParamsB m_programParamsB[ kGLMNumProgramTypes ]; // two banks, but only the vertex one is used + GLMProgramParamsI m_programParamsI[ kGLMNumProgramTypes ]; // two banks, but only the vertex one is used + EGLMParamWriteMode m_paramWriteMode; + + CGLMProgram *m_nullFragmentProgram; // write opaque black. Activate when caller asks for null FP + + CGLMProgram *m_preloadTexVertexProgram; // programs to help preload textures (dummies) + CGLMProgram *m_preload2DTexFragmentProgram; + CGLMProgram *m_preload3DTexFragmentProgram; + CGLMProgram *m_preloadCubeTexFragmentProgram; + + CGLMProgram *m_boundProgram[ kGLMNumProgramTypes ]; + + CGLMShaderPairCache *m_pairCache; // GLSL only + CGLMShaderPair *m_boundPair; // GLSL only + uint m_boundPairRevision; // GLSL only + GLhandleARB m_boundPairProgram; // GLSL only + + // buffer bindings + CGLMBuffer *m_lastKnownBufferBinds[ kGLMNumBufferTypes ]; // tracked per bind point for dupe-bind-absorb + GLMVertexAttributeDesc m_lastKnownVertexAttribs[ kGLMVertexAttributeIndexMax ]; // tracked per attrib for dupe-set-absorb + uint m_lastKnownVertexAttribMask; // tracked for dupe-enable-absorb + + CGLMBuffer *m_drawIndexBuffer; // ... ? do we need dupe tracking for index buffer setup? ? + + GLMVertexSetup m_drawVertexSetup; + + EGLMAttribWriteMode m_attribWriteMode; + + bool m_slowCheckEnable; // turn this on or no native checking is done ("-glmassertslow" or "-glmsspewslow") + bool m_slowAssertEnable; // turn this on to assert on a non-native batch "-glmassertslow" + bool m_slowSpewEnable; // turn this on to log non-native batches to stdout "-glmspewslow" + + // debug font texture + CGLMTex *m_debugFontTex; // might be NULL unless you call GenDebugFontTex + CGLMBuffer *m_debugFontIndices; // up to 1024 indices (256 chars times 4) + CGLMBuffer *m_debugFontVertices; // up to 1024 verts + + // batch/frame debugging support + int m_debugFrameIndex; // init to -1. Increment at BeginFrame + int m_debugBatchIndex; // init to -1. Increment at any draw call + +#if GLMDEBUG + // interactive (DebugHook) debug support + + // using these you can implement frame advance, batch single step, and batch rewind (let it run til next frame and hold on prev batch #) + int m_holdFrameBegin; // -1 if no hold req'd, otherwise # of frame to hold at (at beginframe time) + int m_holdFrameEnd; // -1 if no hold req'd, otherwise # of frame to hold at (at endframe time) + + int m_holdBatch,m_holdBatchFrame; // -1 if no hold, else # of batch&frame to hold at (both must be set) + // these can be expired/cleared to -1 if the frame passes without a hit + // may be desirable to re-pause in that event, as user was expecting a hold to occur + + bool m_debugDelayEnable; // allow sleep delay + uint m_debugDelay; // sleep time per hook call in microseconds (for usleep()) + + // pre-draw global toggles / options + bool m_autoClearColor,m_autoClearDepth,m_autoClearStencil; + float m_autoClearColorValues[4]; + + // debug knobs + int m_selKnobIndex; + float m_selKnobMinValue,m_selKnobMaxValue,m_selKnobIncrement; +#endif + +}; + +struct GLMTestParams +{ + GLMContext *m_ctx; + int *m_testList; // -1 termed + + bool m_glErrToDebugger; + bool m_glErrToConsole; + + bool m_intlErrToDebugger; + bool m_intlErrToConsole; + + int m_frameCount; // how many frames to test. +}; + +class GLMTester +{ + public: + + GLMTester(GLMTestParams *params); + ~GLMTester(); + + + // optionally callable by test routines to get basic drawables wired up + void StdSetup( void ); + void StdCleanup( void ); + + // callable by test routines to clear the frame or present it + void Clear( void ); + void Present( int seed ); + + // error reporting + void CheckGLError( char *comment ); // obey m_params setting for console / debugger response + void InternalError( int errcode, char *comment ); // if errcode!=0, obey m_params setting for console / debugger response + + void RunTests(); + + void RunOneTest( int testindex ); + + // test routines themselves + void Test0(); + void Test1(); + void Test2(); + void Test3(); + + GLMTestParams m_params; // copy of caller's params, do not mutate... + + // std-setup stuff + int m_drawWidth, m_drawHeight; + CGLMFBO *m_drawFBO; + CGLMTex *m_drawColorTex; + CGLMTex *m_drawDepthTex; +}; + +class CShowPixelsParams +{ +public: + GLuint m_srcTexName; + int m_width,m_height; + bool m_vsyncEnable; + bool m_fsEnable; // want receiving view to be full screen. for now, just target the main screen. extend later. + bool m_useBlit; // use FBO blit - sending context says it is available. + bool m_noBlit; // the back buffer has already been populated by the caller (perhaps via direct MSAA resolve from multisampled RT tex) + bool m_onlySyncView; // react to full/windowed state change only, do not present bits +}; + + +#define kMaxCrawlFrames 100 +#define kMaxCrawlText (kMaxCrawlFrames * 256) +class CStackCrawlParams +{ + public: + uint m_frameLimit; // input: max frames to retrieve + uint m_frameCount; // output: frames found + void *m_crawl[kMaxCrawlFrames]; // call site addresses + char *m_crawlNames[kMaxCrawlFrames]; // pointers into text following, one per decoded name + char m_crawlText[kMaxCrawlText]; +}; + +#endif diff --git a/mp/src/public/togl/osx/glmgrbasics.h b/mp/src/public/togl/osx/glmgrbasics.h index 78e41464..d446b512 100644 --- a/mp/src/public/togl/osx/glmgrbasics.h +++ b/mp/src/public/togl/osx/glmgrbasics.h @@ -1,299 +1,299 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// -// glmgrbasics.h -// types, common headers, forward declarations, utilities -// -//=============================================================================== - -#ifndef GLMBASICS_H -#define GLMBASICS_H - -#pragma once - -#ifdef OSX -#include -#include -#include -#include -#include -#include -#include -//#include -#elif defined(LINUX) -#include -#include -#else -#error -#endif - -#include "tier0/platform.h" - -#include "bitmap/imageformat.h" -#include "bitvec.h" -#include "tier1/checksum_md5.h" -#include "tier1/utlvector.h" -#include "tier1/convar.h" - -#include - -#include "dxabstract_types.h" - -// types -struct GLMRect; -typedef void *PseudoGLContextPtr; - - - // 3-d integer box (used for texture lock/unlock etc) -struct GLMRegion -{ - int xmin,xmax; - int ymin,ymax; - int zmin,zmax; -}; - -struct GLMRect // follows GL convention - if coming from the D3D rect you will need to fiddle the Y's -{ - int xmin; // left - int ymin; // bottom - int xmax; // right - int ymax; // top -}; - -// macros - -//#define GLMassert(x) assert(x) - -// forward decls -class GLMgr; // singleton -class GLMContext; // GL context -class CGLMContextTester; // testing class -class CGLMTex; -class CGLMFBO; -class CGLMProgram; -class CGLMBuffer; - - -// utilities - -typedef enum -{ - // D3D codes - eD3D_DEVTYPE, - eD3D_FORMAT, - eD3D_RTYPE, - eD3D_USAGE, - eD3D_RSTATE, // render state - eD3D_SIO, // D3D shader bytecode - eD3D_VTXDECLUSAGE, - - // CGL codes - eCGL_RENDID, - - // OpenGL error codes - eGL_ERROR, - - // OpenGL enums - eGL_ENUM, - eGL_RENDERER - -} GLMThing_t; - -const char* GLMDecode( GLMThing_t type, unsigned long value ); // decode a numeric const -const char* GLMDecodeMask( GLMThing_t type, unsigned long value ); // decode a bitmask - -void GLMStop( void ); // aka Debugger() -void GLMCheckError( bool noStop = false, bool noLog= false ); -void GLMEnableTrace( bool on ); - -// expose these in release now -// Mimic PIX events so we can decorate debug spew -void GLMBeginPIXEvent( const char *str ); -void GLMEndPIXEvent( void ); - -//=============================================================================== -// knob twiddling -float GLMKnob( char *knobname, float *setvalue ); // Pass NULL to not-set the knob value -float GLMKnobToggle( char *knobname ); - -//=============================================================================== -// other stuff - -// helpers for CGLSetOption - no op if no profiler -void GLMProfilerClearTrace( void ); -void GLMProfilerEnableTrace( bool enable ); - -// helpers for CGLSetParameter - no op if no profiler -void GLMProfilerDumpState( void ); - - -//=============================================================================== -// classes - -// helper class making function tracking easier to wire up -#if GLMDEBUG -class GLMFuncLogger -{ - public: - - // simple function log - GLMFuncLogger( const char *funcName ) - { - m_funcName = funcName; - m_earlyOut = false; - - GLMPrintf( ">%s", m_funcName ); - }; - - // more advanced version lets you pass args (i.e. called parameters or anything else of interest) - // no macro for this one, since no easy way to pass through the args as well as the funcname - GLMFuncLogger( const char *funcName, char *fmt, ... ) - { - m_funcName = funcName; - m_earlyOut = false; - - // this acts like GLMPrintf here - // all the indent policy is down in GLMPrintfVA - // which means we need to inject a ">" at the front of the format string to make this work... sigh. - - char modifiedFmt[2000]; - modifiedFmt[0] = '>'; - strcpy( modifiedFmt+1, fmt ); - - va_list vargs; - va_start(vargs, fmt); - GLMPrintfVA( modifiedFmt, vargs ); - va_end( vargs ); - } - - ~GLMFuncLogger( ) - { - if (m_earlyOut) - { - GLMPrintf( "<%s (early out)", m_funcName ); - } - else - { - GLMPrintf( "<%s", m_funcName ); - } - }; - - void EarlyOut( void ) - { - m_earlyOut = true; - }; - - const char *m_funcName; // set at construction time - bool m_earlyOut; -}; - -// handy macro to go with the function tracking class -#define GLM_FUNC GLMFuncLogger _logger_ ( __FUNCTION__ ) -#else -#define GLM_FUNC -#endif - - -// class to keep an in-memory mirror of a file which may be getting edited during run -class CGLMFileMirror -{ -public: - CGLMFileMirror( char *fullpath ); // just associates mirror with file. if file exists it will be read. - //if non existent it will be created with size zero - ~CGLMFileMirror( ); - - bool HasData( void ); // see if data avail - void GetData( char **dataPtr, uint *dataSizePtr ); // read it out - void SetData( char *data, uint dataSize ); // put data in (and write it to disk) - bool PollForChanges( void ); // check disk copy. If different, read it back in and return true. - - void UpdateStatInfo( void ); // make sure stat info is current for our file - void ReadFile( void ); - void WriteFile( void ); - - void OpenInEditor( bool foreground=false ); // pass TRUE if you would like the editor to pop to foreground - - /// how about a "wait for change" method.. - - char *m_path; // fullpath to file - bool m_exists; - struct stat m_stat; // stat results for the file (last time checked) - - char *m_data; // content of file - uint m_size; // length of content - -}; - -// class based on the file mirror, that makes it easy to edit them outside the app. - -// it receives an initial block of text from the engine, and hashes it. ("orig") -// it munges it by duplicating all the text after the "!!" line, and appending it in commented form. ("munged") -// a mirror file is activated, using a filename based on the hash from the orig text. -// if there is already content on disk matching that filename, use that content *unless* the 'blitz' parameter is set. -// (i.e. engine is instructing this subsystem to wipe out any old/modified variants of the text) - - -class CGLMEditableTextItem -{ -public: - CGLMEditableTextItem( char *text, uint size, bool forceOverwrite, char *prefix, char *suffix = NULL ); // create a text blob from text source, optional filename suffix - ~CGLMEditableTextItem( ); - - bool HasData( void ); - bool PollForChanges( void ); // return true if stale i.e. you need to get a new edition - void GetCurrentText( char **textOut, uint *sizeOut ); // query for read access to the active blob (could be the original, could be external edited copy) - void OpenInEditor( bool foreground=false ); // call user attention to this text - - // internal methods - void GenHashOfOrigText( void ); - void GenBaseNameAndFullPath( char *prefix, char *suffix ); - void GenMungedText( bool fromMirror ); - - // members - // orig - uint m_origSize; - char *m_origText; // what was submitted - unsigned char m_origDigest[MD5_DIGEST_LENGTH]; // digest of what was submitted - - // munged - uint m_mungedSize; - char *m_mungedText; // re-processed edition, initial content submission to the file mirror - - // mirror - char *m_mirrorBaseName; // generated from the hash of the orig text, plus the label / prefix - char *m_mirrorFullPath; // base name - CGLMFileMirror *m_mirror; // file mirror itself. holds "official" copy for GetCurrentText to return. -}; - - -// debug font -extern unsigned char g_glmDebugFontMap[16384]; - -// class for cracking multi-part text blobs -// sections are demarcated by beginning-of-line markers submitted in a table by the caller - -struct GLMTextSection -{ - int m_markerIndex; // based on table of markers passed in to constructor - uint m_textOffset; // where is the text - offset - int m_textLength; // how big is the section -}; - -class CGLMTextSectioner -{ -public: - CGLMTextSectioner( char *text, int textSize, char **markers ); // constructor finds all the sections - ~CGLMTextSectioner( ); - - int Count( void ); // how many sections found - void GetSection( int index, uint *offsetOut, uint *lengthOut, int *markerIndexOut ); - // find section, size, what marker - // note that more than one section can be marked similarly. - // so policy isn't made here, you walk the sections and decide what to do if there are dupes. - - //members - - //section table - CUtlVector< GLMTextSection > m_sectionTable; -}; - -#endif +// +// glmgrbasics.h +// types, common headers, forward declarations, utilities +// +//=============================================================================== + +#ifndef GLMBASICS_H +#define GLMBASICS_H + +#pragma once + +#ifdef OSX +#include +#include +#include +#include +#include +#include +#include +//#include +#elif defined(LINUX) +#include +#include +#else +#error +#endif + +#include "tier0/platform.h" + +#include "bitmap/imageformat.h" +#include "bitvec.h" +#include "tier1/checksum_md5.h" +#include "tier1/utlvector.h" +#include "tier1/convar.h" + +#include + +#include "dxabstract_types.h" + +// types +struct GLMRect; +typedef void *PseudoGLContextPtr; + + + // 3-d integer box (used for texture lock/unlock etc) +struct GLMRegion +{ + int xmin,xmax; + int ymin,ymax; + int zmin,zmax; +}; + +struct GLMRect // follows GL convention - if coming from the D3D rect you will need to fiddle the Y's +{ + int xmin; // left + int ymin; // bottom + int xmax; // right + int ymax; // top +}; + +// macros + +//#define GLMassert(x) assert(x) + +// forward decls +class GLMgr; // singleton +class GLMContext; // GL context +class CGLMContextTester; // testing class +class CGLMTex; +class CGLMFBO; +class CGLMProgram; +class CGLMBuffer; + + +// utilities + +typedef enum +{ + // D3D codes + eD3D_DEVTYPE, + eD3D_FORMAT, + eD3D_RTYPE, + eD3D_USAGE, + eD3D_RSTATE, // render state + eD3D_SIO, // D3D shader bytecode + eD3D_VTXDECLUSAGE, + + // CGL codes + eCGL_RENDID, + + // OpenGL error codes + eGL_ERROR, + + // OpenGL enums + eGL_ENUM, + eGL_RENDERER + +} GLMThing_t; + +const char* GLMDecode( GLMThing_t type, unsigned long value ); // decode a numeric const +const char* GLMDecodeMask( GLMThing_t type, unsigned long value ); // decode a bitmask + +void GLMStop( void ); // aka Debugger() +void GLMCheckError( bool noStop = false, bool noLog= false ); +void GLMEnableTrace( bool on ); + +// expose these in release now +// Mimic PIX events so we can decorate debug spew +void GLMBeginPIXEvent( const char *str ); +void GLMEndPIXEvent( void ); + +//=============================================================================== +// knob twiddling +float GLMKnob( char *knobname, float *setvalue ); // Pass NULL to not-set the knob value +float GLMKnobToggle( char *knobname ); + +//=============================================================================== +// other stuff + +// helpers for CGLSetOption - no op if no profiler +void GLMProfilerClearTrace( void ); +void GLMProfilerEnableTrace( bool enable ); + +// helpers for CGLSetParameter - no op if no profiler +void GLMProfilerDumpState( void ); + + +//=============================================================================== +// classes + +// helper class making function tracking easier to wire up +#if GLMDEBUG +class GLMFuncLogger +{ + public: + + // simple function log + GLMFuncLogger( const char *funcName ) + { + m_funcName = funcName; + m_earlyOut = false; + + GLMPrintf( ">%s", m_funcName ); + }; + + // more advanced version lets you pass args (i.e. called parameters or anything else of interest) + // no macro for this one, since no easy way to pass through the args as well as the funcname + GLMFuncLogger( const char *funcName, char *fmt, ... ) + { + m_funcName = funcName; + m_earlyOut = false; + + // this acts like GLMPrintf here + // all the indent policy is down in GLMPrintfVA + // which means we need to inject a ">" at the front of the format string to make this work... sigh. + + char modifiedFmt[2000]; + modifiedFmt[0] = '>'; + strcpy( modifiedFmt+1, fmt ); + + va_list vargs; + va_start(vargs, fmt); + GLMPrintfVA( modifiedFmt, vargs ); + va_end( vargs ); + } + + ~GLMFuncLogger( ) + { + if (m_earlyOut) + { + GLMPrintf( "<%s (early out)", m_funcName ); + } + else + { + GLMPrintf( "<%s", m_funcName ); + } + }; + + void EarlyOut( void ) + { + m_earlyOut = true; + }; + + const char *m_funcName; // set at construction time + bool m_earlyOut; +}; + +// handy macro to go with the function tracking class +#define GLM_FUNC GLMFuncLogger _logger_ ( __FUNCTION__ ) +#else +#define GLM_FUNC +#endif + + +// class to keep an in-memory mirror of a file which may be getting edited during run +class CGLMFileMirror +{ +public: + CGLMFileMirror( char *fullpath ); // just associates mirror with file. if file exists it will be read. + //if non existent it will be created with size zero + ~CGLMFileMirror( ); + + bool HasData( void ); // see if data avail + void GetData( char **dataPtr, uint *dataSizePtr ); // read it out + void SetData( char *data, uint dataSize ); // put data in (and write it to disk) + bool PollForChanges( void ); // check disk copy. If different, read it back in and return true. + + void UpdateStatInfo( void ); // make sure stat info is current for our file + void ReadFile( void ); + void WriteFile( void ); + + void OpenInEditor( bool foreground=false ); // pass TRUE if you would like the editor to pop to foreground + + /// how about a "wait for change" method.. + + char *m_path; // fullpath to file + bool m_exists; + struct stat m_stat; // stat results for the file (last time checked) + + char *m_data; // content of file + uint m_size; // length of content + +}; + +// class based on the file mirror, that makes it easy to edit them outside the app. + +// it receives an initial block of text from the engine, and hashes it. ("orig") +// it munges it by duplicating all the text after the "!!" line, and appending it in commented form. ("munged") +// a mirror file is activated, using a filename based on the hash from the orig text. +// if there is already content on disk matching that filename, use that content *unless* the 'blitz' parameter is set. +// (i.e. engine is instructing this subsystem to wipe out any old/modified variants of the text) + + +class CGLMEditableTextItem +{ +public: + CGLMEditableTextItem( char *text, uint size, bool forceOverwrite, char *prefix, char *suffix = NULL ); // create a text blob from text source, optional filename suffix + ~CGLMEditableTextItem( ); + + bool HasData( void ); + bool PollForChanges( void ); // return true if stale i.e. you need to get a new edition + void GetCurrentText( char **textOut, uint *sizeOut ); // query for read access to the active blob (could be the original, could be external edited copy) + void OpenInEditor( bool foreground=false ); // call user attention to this text + + // internal methods + void GenHashOfOrigText( void ); + void GenBaseNameAndFullPath( char *prefix, char *suffix ); + void GenMungedText( bool fromMirror ); + + // members + // orig + uint m_origSize; + char *m_origText; // what was submitted + unsigned char m_origDigest[MD5_DIGEST_LENGTH]; // digest of what was submitted + + // munged + uint m_mungedSize; + char *m_mungedText; // re-processed edition, initial content submission to the file mirror + + // mirror + char *m_mirrorBaseName; // generated from the hash of the orig text, plus the label / prefix + char *m_mirrorFullPath; // base name + CGLMFileMirror *m_mirror; // file mirror itself. holds "official" copy for GetCurrentText to return. +}; + + +// debug font +extern unsigned char g_glmDebugFontMap[16384]; + +// class for cracking multi-part text blobs +// sections are demarcated by beginning-of-line markers submitted in a table by the caller + +struct GLMTextSection +{ + int m_markerIndex; // based on table of markers passed in to constructor + uint m_textOffset; // where is the text - offset + int m_textLength; // how big is the section +}; + +class CGLMTextSectioner +{ +public: + CGLMTextSectioner( char *text, int textSize, char **markers ); // constructor finds all the sections + ~CGLMTextSectioner( ); + + int Count( void ); // how many sections found + void GetSection( int index, uint *offsetOut, uint *lengthOut, int *markerIndexOut ); + // find section, size, what marker + // note that more than one section can be marked similarly. + // so policy isn't made here, you walk the sections and decide what to do if there are dupes. + + //members + + //section table + CUtlVector< GLMTextSection > m_sectionTable; +}; + +#endif diff --git a/mp/src/public/togl/osx/glmgrext.h b/mp/src/public/togl/osx/glmgrext.h index 02939bb6..ace2c666 100644 --- a/mp/src/public/togl/osx/glmgrext.h +++ b/mp/src/public/togl/osx/glmgrext.h @@ -1,93 +1,93 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// -// glmgrext.h -// helper file for extension testing and runtime importing of entry points -// -//=============================================================================== - -#pragma once - -#ifdef OSX -#include -#include -#elif defined(LINUX) -#include -#include -#else -#error -#endif - -#ifndef GL_EXT_framebuffer_sRGB - #define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 - #define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA -#endif - -#ifndef ARB_texture_rg - #define GL_COMPRESSED_RED 0x8225 - #define GL_COMPRESSED_RG 0x8226 - #define GL_RG 0x8227 - #define GL_RG_INTEGER 0x8228 - #define GL_R8 0x8229 - #define GL_R16 0x822A - #define GL_RG8 0x822B - #define GL_RG16 0x822C - #define GL_R16F 0x822D - #define GL_R32F 0x822E - #define GL_RG16F 0x822F - #define GL_RG32F 0x8230 - #define GL_R8I 0x8231 - #define GL_R8UI 0x8232 - #define GL_R16I 0x8233 - #define GL_R16UI 0x8234 - #define GL_R32I 0x8235 - #define GL_R32UI 0x8236 - #define GL_RG8I 0x8237 - #define GL_RG8UI 0x8238 - #define GL_RG16I 0x8239 - #define GL_RG16UI 0x823A - #define GL_RG32I 0x823B - #define GL_RG32UI 0x823C -#endif - -#ifndef GL_EXT_bindable_uniform - #define GL_UNIFORM_BUFFER_EXT 0x8DEE -#endif - -// unpublished extension enums (thus the "X") - -// from EXT_framebuffer_multisample_blit_scaled.. -#define XGL_SCALED_RESOLVE_FASTEST_EXT 0x90BA -#define XGL_SCALED_RESOLVE_NICEST_EXT 0x90BB - -#ifndef GL_TEXTURE_MINIMIZE_STORAGE_APPLE -#define GL_TEXTURE_MINIMIZE_STORAGE_APPLE 0x85B6 -#endif - -#ifndef GL_ALL_COMPLETED_NV -#define GL_ALL_COMPLETED_NV 0x84F2 -#endif - -#ifndef GL_MAP_READ_BIT -#define GL_MAP_READ_BIT 0x0001 -#endif - -#ifndef GL_MAP_WRITE_BIT -#define GL_MAP_WRITE_BIT 0x0002 -#endif - -#ifndef GL_MAP_INVALIDATE_RANGE_BIT -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#endif - -#ifndef GL_MAP_INVALIDATE_BUFFER_BIT -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#endif - -#ifndef GL_MAP_FLUSH_EXPLICIT_BIT -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#endif - -#ifndef GL_MAP_UNSYNCHRONIZED_BIT -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 -#endif - +// +// glmgrext.h +// helper file for extension testing and runtime importing of entry points +// +//=============================================================================== + +#pragma once + +#ifdef OSX +#include +#include +#elif defined(LINUX) +#include +#include +#else +#error +#endif + +#ifndef GL_EXT_framebuffer_sRGB + #define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 + #define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif + +#ifndef ARB_texture_rg + #define GL_COMPRESSED_RED 0x8225 + #define GL_COMPRESSED_RG 0x8226 + #define GL_RG 0x8227 + #define GL_RG_INTEGER 0x8228 + #define GL_R8 0x8229 + #define GL_R16 0x822A + #define GL_RG8 0x822B + #define GL_RG16 0x822C + #define GL_R16F 0x822D + #define GL_R32F 0x822E + #define GL_RG16F 0x822F + #define GL_RG32F 0x8230 + #define GL_R8I 0x8231 + #define GL_R8UI 0x8232 + #define GL_R16I 0x8233 + #define GL_R16UI 0x8234 + #define GL_R32I 0x8235 + #define GL_R32UI 0x8236 + #define GL_RG8I 0x8237 + #define GL_RG8UI 0x8238 + #define GL_RG16I 0x8239 + #define GL_RG16UI 0x823A + #define GL_RG32I 0x823B + #define GL_RG32UI 0x823C +#endif + +#ifndef GL_EXT_bindable_uniform + #define GL_UNIFORM_BUFFER_EXT 0x8DEE +#endif + +// unpublished extension enums (thus the "X") + +// from EXT_framebuffer_multisample_blit_scaled.. +#define XGL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define XGL_SCALED_RESOLVE_NICEST_EXT 0x90BB + +#ifndef GL_TEXTURE_MINIMIZE_STORAGE_APPLE +#define GL_TEXTURE_MINIMIZE_STORAGE_APPLE 0x85B6 +#endif + +#ifndef GL_ALL_COMPLETED_NV +#define GL_ALL_COMPLETED_NV 0x84F2 +#endif + +#ifndef GL_MAP_READ_BIT +#define GL_MAP_READ_BIT 0x0001 +#endif + +#ifndef GL_MAP_WRITE_BIT +#define GL_MAP_WRITE_BIT 0x0002 +#endif + +#ifndef GL_MAP_INVALIDATE_RANGE_BIT +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#endif + +#ifndef GL_MAP_INVALIDATE_BUFFER_BIT +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#endif + +#ifndef GL_MAP_FLUSH_EXPLICIT_BIT +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#endif + +#ifndef GL_MAP_UNSYNCHRONIZED_BIT +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#endif + diff --git a/mp/src/public/vgui/ISurface.h b/mp/src/public/vgui/ISurface.h index b1e39bd4..0ccc8157 100644 --- a/mp/src/public/vgui/ISurface.h +++ b/mp/src/public/vgui/ISurface.h @@ -32,6 +32,7 @@ #endif class Color; +class ITexture; namespace vgui { @@ -386,7 +387,7 @@ public: virtual IHTMLChromeController *AccessChromeHTMLController() = 0; // the origin of the viewport on the framebuffer (Which might not be 0,0 for stereo) - virtual void SetFullscreenViewport( int x, int y, int w, int h ) = 0; + virtual void SetFullscreenViewportAndRenderTarget( int x, int y, int w, int h, ITexture *pRenderTarget ) = 0; virtual void GetFullscreenViewport( int & x, int & y, int & w, int & h ) = 0; virtual void PushFullscreenViewport() = 0; virtual void PopFullscreenViewport() = 0; @@ -394,6 +395,12 @@ public: // handles support for software cursors virtual void SetSoftwareCursor( bool bUseSoftwareCursor ) = 0; virtual void PaintSoftwareCursor() = 0; + + + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // !! WARNING! YOU MUST NOT ADD YOUR NEW METHOD HERE OR YOU WILL BREAK MODS !! + // !! Add your new stuff to the bottom of IMatSystemSurface instead. !! + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! }; } diff --git a/mp/src/public/windows_default.manifest b/mp/src/public/windows_default.manifest index 19973c57..31ec6d82 100644 --- a/mp/src/public/windows_default.manifest +++ b/mp/src/public/windows_default.manifest @@ -8,6 +8,8 @@ + + diff --git a/mp/src/thirdparty/protobuf-2.3.0/gtest/msvc/gtest.vcxproj b/mp/src/thirdparty/protobuf-2.3.0/gtest/msvc/gtest.vcxproj index 6e8f970e..a2bbc119 100644 --- a/mp/src/thirdparty/protobuf-2.3.0/gtest/msvc/gtest.vcxproj +++ b/mp/src/thirdparty/protobuf-2.3.0/gtest/msvc/gtest.vcxproj @@ -18,10 +18,12 @@ StaticLibrary MultiByte + v110_xp StaticLibrary MultiByte + v110_xp diff --git a/mp/src/thirdparty/protobuf-2.3.0/gtest/msvc/gtest_main.vcxproj b/mp/src/thirdparty/protobuf-2.3.0/gtest/msvc/gtest_main.vcxproj index af13fd33..938e84a2 100644 --- a/mp/src/thirdparty/protobuf-2.3.0/gtest/msvc/gtest_main.vcxproj +++ b/mp/src/thirdparty/protobuf-2.3.0/gtest/msvc/gtest_main.vcxproj @@ -18,10 +18,12 @@ StaticLibrary MultiByte + v110_xp StaticLibrary MultiByte + v110_xp diff --git a/mp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/io/zero_copy_stream_impl_lite.cc b/mp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/io/zero_copy_stream_impl_lite.cc index 79d57452..c2e04600 100644 --- a/mp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/io/zero_copy_stream_impl_lite.cc +++ b/mp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/io/zero_copy_stream_impl_lite.cc @@ -35,6 +35,7 @@ #include #include #include +#include namespace google { namespace protobuf { diff --git a/mp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/repeated_field.cc b/mp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/repeated_field.cc index 68544f34..38ce984e 100644 --- a/mp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/repeated_field.cc +++ b/mp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/repeated_field.cc @@ -34,6 +34,7 @@ #include #include +#include namespace google { namespace protobuf { diff --git a/mp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/wire_format_lite_inl.h b/mp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/wire_format_lite_inl.h index d7b2c302..07b207d0 100644 --- a/mp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/wire_format_lite_inl.h +++ b/mp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/wire_format_lite_inl.h @@ -37,6 +37,7 @@ #define GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_INL_H__ #include +#include #include #include #include diff --git a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotobuf-lite.vcxproj b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotobuf-lite.vcxproj index e2995b8a..b24b8bbe 100644 --- a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotobuf-lite.vcxproj +++ b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotobuf-lite.vcxproj @@ -26,15 +26,19 @@ StaticLibrary + v110_xp StaticLibrary + v110_xp StaticLibrary + v110_xp StaticLibrary + v110_xp @@ -57,15 +61,15 @@ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\$(ProjectName)\ - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) Disabled ../src;.;%(AdditionalIncludeDirectories) _HAS_ITERATOR_DEBUGGING=0;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) @@ -84,11 +88,11 @@ X64 - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) Disabled ../src;.;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug @@ -99,9 +103,9 @@ - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) ../src;.;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;;%(PreprocessorDefinitions) MultiThreaded @@ -115,9 +119,9 @@ X64 - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) ../src;.;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions) MultiThreaded diff --git a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotobuf.vcxproj b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotobuf.vcxproj index ad279452..6afa7a6d 100644 --- a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotobuf.vcxproj +++ b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotobuf.vcxproj @@ -26,15 +26,19 @@ StaticLibrary + v110_xp StaticLibrary + v110_xp StaticLibrary + v110_xp StaticLibrary + v110_xp @@ -57,15 +61,15 @@ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\$(ProjectName)\ - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) Disabled ../src;.;%(AdditionalIncludeDirectories) _HAS_ITERATOR_DEBUGGING=0;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) @@ -84,11 +88,11 @@ X64 - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) Disabled ../src;.;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug @@ -100,9 +104,9 @@ - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) ../src;.;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions) MultiThreaded @@ -116,9 +120,9 @@ X64 - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) ../src;.;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions) MultiThreaded diff --git a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotoc.vcxproj b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotoc.vcxproj index 98b46fce..bc517c70 100644 --- a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotoc.vcxproj +++ b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotoc.vcxproj @@ -25,15 +25,19 @@ StaticLibrary + v110_xp StaticLibrary + v110_xp StaticLibrary + v110_xp StaticLibrary + v110_xp @@ -56,15 +60,15 @@ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\$(ProjectName)\ - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) Disabled ../src;.;%(AdditionalIncludeDirectories) _HAS_ITERATOR_DEBUGGING=0;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBPROTOC_EXPORTS;%(PreprocessorDefinitions) @@ -82,11 +86,11 @@ X64 - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) Disabled ../src;.;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBPROTOC_EXPORTS;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug @@ -97,9 +101,9 @@ - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) ../src;.;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOC_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOC_EXPORTS;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions) MultiThreaded @@ -112,9 +116,9 @@ X64 - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) ../src;.;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOC_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOC_EXPORTS;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions) MultiThreaded diff --git a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/lite-test.vcxproj b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/lite-test.vcxproj index d046a361..ffcb54ce 100644 --- a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/lite-test.vcxproj +++ b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/lite-test.vcxproj @@ -26,15 +26,19 @@ Application + v110_xp Application + v110_xp Application + v110_xp Application + v110_xp @@ -81,7 +85,7 @@ Disabled ../src;.;../gtest/include;%(AdditionalIncludeDirectories) _HAS_ITERATOR_DEBUGGING=0;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug @@ -112,7 +116,7 @@ Disabled ../src;.;../gtest/include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug diff --git a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/make.bat b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/make.bat index 89b257a8..70cc0261 100644 --- a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/make.bat +++ b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/make.bat @@ -4,24 +4,23 @@ setlocal @rem Move to the batch file directory so we can run it from anywhere cd %~dp0 -call "%VS100COMNTOOLS%vsvars32.bat" +call "%VS110COMNTOOLS%vsvars32.bat" +set dirsuffix=\2012 -for /d %%d in (debug release "debug|x64" "release|x64") do ( +@rem Note that we no longer build separate debug libraries +for /d %%d in ( "release|Win32" "release|x64") do ( + @rem Note that this message seems to display out of order for some reason... echo Building %%d devenv protobuf_2010.sln /clean %%d - devenv protobuf_2010.sln /build %%d /project libprotobuf devenv protobuf_2010.sln /build %%d /project libprotobuf-lite + @rem Note that building libprotoc also ensures that libprotobuf builds devenv protobuf_2010.sln /build %%d /project libprotoc ) -p4 edit ..\..\..\lib\win32\debug\VS2010\libproto*.lib -p4 edit ..\..\..\lib\win32\release\VS2010\libproto*.lib -p4 edit ..\..\..\lib\win64\debug\VS2010\libproto*.lib -p4 edit ..\..\..\lib\win64\release\VS2010\libproto*.lib +p4 edit ..\..\..\lib\public%dirsuffix%\libproto*.lib +p4 edit ..\..\..\lib\public\x64%dirsuffix%\libproto*.lib -copy /y Debug\libproto*.lib ..\..\..\lib\win32\debug\VS2010 -copy /y Release\libproto*.lib ..\..\..\lib\win32\Release\VS2010 -copy /y x64\Debug\libproto*.lib ..\..\..\lib\win64\debug\VS2010 -copy /y x64\Release\libproto*.lib ..\..\..\lib\win64\Release\VS2010 +copy /y Release\libproto*.lib ..\..\..\lib\public%dirsuffix% +copy /y x64\Release\libproto*.lib ..\..\..\lib\public\x64%dirsuffix% @echo Check in the changed libraries in src\lib if you are done. diff --git a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/make2013.bat b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/make2013.bat new file mode 100644 index 00000000..f2329b9e --- /dev/null +++ b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/make2013.bat @@ -0,0 +1,54 @@ +@echo off +setlocal + +@rem Move to the batch file directory so we can run it from anywhere +cd %~dp0 + +call "%VS120COMNTOOLS%vsvars32.bat" +set dirsuffix=\2013 + +p4 edit ..\gtest\msvc\*.vcxproj +p4 edit *.vcxproj +p4 edit *.sln + +@rem This will upgrade from v110_xp to v120_xp +devenv protobuf_2010.sln /upgrade +@rem Remove upgrade files +rmdir Backup /s/q +rmdir _UpgradeReport_Files /s/q +del UpgradeLog*.* + +@rem Note that we no longer build separate debug libraries +for /d %%d in ( "release|Win32" "release|x64") do ( + @rem Note that this message seems to display out of order for some reason... + echo Building %%d + devenv protobuf_2010.sln /clean %%d + devenv protobuf_2010.sln /build %%d /project libprotobuf-lite + @rem Note that building libprotoc also ensures that libprotobuf builds + devenv protobuf_2010.sln /build %%d /project libprotoc +) + +@rem Make the destination directories in case they don't already exist. +mkdir ..\..\..\lib\public%dirsuffix% +mkdir ..\..\..\lib\public\x64%dirsuffix% + +@rem Edit the destination files if they do exist +p4 edit ..\..\..\lib\public%dirsuffix%\libproto*.lib +p4 edit ..\..\..\lib\public\x64%dirsuffix%\libproto*.lib + +copy /y Release\libproto*.lib ..\..\..\lib\public%dirsuffix% +copy /y x64\Release\libproto*.lib ..\..\..\lib\public\x64%dirsuffix% + +@rem Auto-add the files if they aren't added yet. Too bad we can't use wildcards here. +p4 add ..\..\..\lib\public%dirsuffix%\libprotobuf-lite.lib +p4 add ..\..\..\lib\public%dirsuffix%\libprotobuf.lib +p4 add ..\..\..\lib\public%dirsuffix%\libprotoc.lib +p4 add ..\..\..\lib\public\x64%dirsuffix%\libprotobuf-lite.lib +p4 add ..\..\..\lib\public\x64%dirsuffix%\libprotobuf.lib +p4 add ..\..\..\lib\public\x64%dirsuffix%\libprotoc.lib + +p4 revert ..\gtest\msvc\*.vcxproj +p4 revert *.vcxproj +p4 revert *.sln + +@echo Check in the changed libraries in src\lib if you are done. diff --git a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/protobuf_2010.sln b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/protobuf_2010.sln index 413793a1..d67098c8 100644 --- a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/protobuf_2010.sln +++ b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/protobuf_2010.sln @@ -1,6 +1,6 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libprotobuf", "libprotobuf.vcxproj", "{3E283F37-A4ED-41B7-A3E6-A2D89D131A30}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libprotoc", "libprotoc.vcxproj", "{B84FF31A-5F9A-46F8-AB22-DBFC9BECE3BE}" @@ -61,20 +61,16 @@ Global {4DF72760-C055-40A5-A77E-30A17E2AC2DB}.Release|x64.Build.0 = Release|x64 {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug|Win32.ActiveCfg = Debug|Win32 {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug|Win32.Build.0 = Debug|Win32 - {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug|x64.ActiveCfg = Debug|x64 - {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug|x64.Build.0 = Debug|x64 + {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug|x64.ActiveCfg = Debug|Win32 {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release|Win32.ActiveCfg = Release|Win32 {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release|Win32.Build.0 = Release|Win32 - {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release|x64.ActiveCfg = Release|x64 - {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release|x64.Build.0 = Release|x64 + {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release|x64.ActiveCfg = Release|Win32 {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug|Win32.ActiveCfg = Debug|Win32 {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug|Win32.Build.0 = Debug|Win32 - {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug|x64.ActiveCfg = Debug|x64 - {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug|x64.Build.0 = Debug|x64 + {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug|x64.ActiveCfg = Debug|Win32 {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release|Win32.ActiveCfg = Release|Win32 {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release|Win32.Build.0 = Release|Win32 - {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release|x64.ActiveCfg = Release|x64 - {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release|x64.Build.0 = Release|x64 + {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release|x64.ActiveCfg = Release|Win32 {49EA010D-706F-4BE2-A397-77854B72A040}.Debug|Win32.ActiveCfg = Debug|Win32 {49EA010D-706F-4BE2-A397-77854B72A040}.Debug|Win32.Build.0 = Debug|Win32 {49EA010D-706F-4BE2-A397-77854B72A040}.Debug|x64.ActiveCfg = Debug|x64 diff --git a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/protoc.vcxproj b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/protoc.vcxproj index f27d9dca..ceb37b42 100644 --- a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/protoc.vcxproj +++ b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/protoc.vcxproj @@ -25,15 +25,19 @@ Application + v110_xp Application + v110_xp Application + v110_xp Application + v110_xp @@ -72,7 +76,7 @@ Disabled ../src;.;%(AdditionalIncludeDirectories) _HAS_ITERATOR_DEBUGGING=0;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug @@ -95,7 +99,7 @@ Disabled ../src;.;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug diff --git a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/test_plugin.vcxproj b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/test_plugin.vcxproj index 894c5fa3..628d197c 100644 --- a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/test_plugin.vcxproj +++ b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/test_plugin.vcxproj @@ -26,15 +26,19 @@ Application + v110_xp Application + v110_xp Application + v110_xp Application + v110_xp @@ -81,7 +85,7 @@ Disabled ../src;.;../gtest/include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug @@ -112,7 +116,7 @@ Disabled ../src;.;../gtest/include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug diff --git a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/tests.vcxproj b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/tests.vcxproj index 0f72ce12..6077d16f 100644 --- a/mp/src/thirdparty/protobuf-2.3.0/vsprojects/tests.vcxproj +++ b/mp/src/thirdparty/protobuf-2.3.0/vsprojects/tests.vcxproj @@ -26,15 +26,19 @@ Application + v110_xp Application + v110_xp Application + v110_xp Application + v110_xp @@ -81,7 +85,7 @@ Disabled ../src;.;../gtest/include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug @@ -112,7 +116,7 @@ Disabled ../src;.;../gtest/include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug diff --git a/mp/src/tier1/qsort_s.cpp b/mp/src/tier1/qsort_s.cpp index 8222b32b..820d151d 100644 --- a/mp/src/tier1/qsort_s.cpp +++ b/mp/src/tier1/qsort_s.cpp @@ -1,112 +1,112 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -/******************************************************************/ -/* qsort.c -- Non-Recursive ANSI Quicksort function */ -/* */ -/* Public domain by Raymond Gardner, Englewood CO February 1991 */ -/* */ -/* Usage: */ -/* qsort(base, nbr_elements, width_bytes, compare_function); */ -/* void *base; */ -/* size_t nbr_elements, width_bytes; */ -/* int (*compare_function)(const void *, const void *); */ -/* */ -/* Sorts an array starting at base, of length nbr_elements, each */ -/* element of size width_bytes, ordered via compare_function, */ -/* which is called as (*compare_function)(ptr_to_element1, */ -/* ptr_to_element2) and returns < 0 if element1 < element2, */ -/* 0 if element1 = element2, > 0 if element1 > element2. */ -/* Most refinements are due to R. Sedgewick. See "Implementing */ -/* Quicksort Programs", Comm. ACM, Oct. 1978, and Corrigendum, */ -/* Comm. ACM, June 1979. */ -/******************************************************************/ - -// modified to take (and use) a context object, ala Microsoft's qsort_s -// "extension" to the stdlib - -#include /* for size_t definition */ - -/* -** swap nbytes between a and b -*/ - -static void swap_bytes(char *a, char *b, size_t nbytes) -{ - char tmp; - do { - tmp = *a; *a++ = *b; *b++ = tmp; - } while ( --nbytes ); -} - -#define SWAP(a, b) (swap_bytes((char *)(a), (char *)(b), size)) - -#define COMP(ctx, a, b) ((*comp)((void *)ctx, (void *)(a), (void *)(b))) - -#define T 7 /* subfiles of T or fewer elements will */ - /* be sorted by a simple insertion sort */ - /* Note! T must be at least 3 */ - -extern "C" void qsort_s(void *basep, size_t nelems, size_t size, - int (*comp)(void *, const void *, const void *), - void *ctx) -{ - char *stack[40], **sp; /* stack and stack pointer */ - char *i, *j, *limit; /* scan and limit pointers */ - size_t thresh; /* size of T elements in bytes */ - char *base; /* base pointer as char * */ - - base = (char *)basep; /* set up char * base pointer */ - thresh = T * size; /* init threshold */ - sp = stack; /* init stack pointer */ - limit = base + nelems * size;/* pointer past end of array */ - for ( ;; ) { /* repeat until break... */ - if ( limit - base > thresh ) { /* if more than T elements */ - /* swap base with middle */ - SWAP((((limit-base)/size)/2)*size+base, base); - i = base + size; /* i scans left to right */ - j = limit - size; /* j scans right to left */ - if ( COMP(ctx, i, j) > 0 ) /* Sedgewick's */ - SWAP(i, j); /* three-element sort */ - if ( COMP(ctx, base, j) > 0 )/* sets things up */ - SWAP(base, j); /* so that */ - if ( COMP(ctx, i, base) > 0 )/* *i <= *base <= *j */ - SWAP(i, base); /* *base is pivot element */ - for ( ;; ) { /* loop until break */ - do /* move i right */ - i += size; /* until *i >= pivot */ - while ( COMP(ctx, i, base) < 0 ); - do /* move j left */ - j -= size; /* until *j <= pivot */ - while ( COMP(ctx, j, base) > 0 ); - if ( i > j ) /* if pointers crossed */ - break; /* break loop */ - SWAP(i, j); /* else swap elements, keep scanning*/ - } - SWAP(base, j); /* move pivot into correct place */ - if ( j - base > limit - i ) { /* if left subfile larger */ - sp[0] = base; /* stack left subfile base */ - sp[1] = j; /* and limit */ - base = i; /* sort the right subfile */ - } else { /* else right subfile larger*/ - sp[0] = i; /* stack right subfile base */ - sp[1] = limit; /* and limit */ - limit = j; /* sort the left subfile */ - } - sp += 2; /* increment stack pointer */ - } else { /* else subfile is small, use insertion sort */ - for ( j = base, i = j+size; i < limit; j = i, i += size ) - for ( ; COMP(ctx, j, j+size) > 0; j -= size ) { - SWAP(j, j+size); - if ( j == base ) - break; - } - if ( sp != stack ) { /* if any entries on stack */ - sp -= 2; /* pop the base and limit */ - base = sp[0]; - limit = sp[1]; - } else /* else stack empty, done */ - break; - } - } -} - - +/******************************************************************/ +/* qsort.c -- Non-Recursive ANSI Quicksort function */ +/* */ +/* Public domain by Raymond Gardner, Englewood CO February 1991 */ +/* */ +/* Usage: */ +/* qsort(base, nbr_elements, width_bytes, compare_function); */ +/* void *base; */ +/* size_t nbr_elements, width_bytes; */ +/* int (*compare_function)(const void *, const void *); */ +/* */ +/* Sorts an array starting at base, of length nbr_elements, each */ +/* element of size width_bytes, ordered via compare_function, */ +/* which is called as (*compare_function)(ptr_to_element1, */ +/* ptr_to_element2) and returns < 0 if element1 < element2, */ +/* 0 if element1 = element2, > 0 if element1 > element2. */ +/* Most refinements are due to R. Sedgewick. See "Implementing */ +/* Quicksort Programs", Comm. ACM, Oct. 1978, and Corrigendum, */ +/* Comm. ACM, June 1979. */ +/******************************************************************/ + +// modified to take (and use) a context object, ala Microsoft's qsort_s +// "extension" to the stdlib + +#include /* for size_t definition */ + +/* +** swap nbytes between a and b +*/ + +static void swap_bytes(char *a, char *b, size_t nbytes) +{ + char tmp; + do { + tmp = *a; *a++ = *b; *b++ = tmp; + } while ( --nbytes ); +} + +#define SWAP(a, b) (swap_bytes((char *)(a), (char *)(b), size)) + +#define COMP(ctx, a, b) ((*comp)((void *)ctx, (void *)(a), (void *)(b))) + +#define T 7 /* subfiles of T or fewer elements will */ + /* be sorted by a simple insertion sort */ + /* Note! T must be at least 3 */ + +extern "C" void qsort_s(void *basep, size_t nelems, size_t size, + int (*comp)(void *, const void *, const void *), + void *ctx) +{ + char *stack[40], **sp; /* stack and stack pointer */ + char *i, *j, *limit; /* scan and limit pointers */ + size_t thresh; /* size of T elements in bytes */ + char *base; /* base pointer as char * */ + + base = (char *)basep; /* set up char * base pointer */ + thresh = T * size; /* init threshold */ + sp = stack; /* init stack pointer */ + limit = base + nelems * size;/* pointer past end of array */ + for ( ;; ) { /* repeat until break... */ + if ( limit - base > thresh ) { /* if more than T elements */ + /* swap base with middle */ + SWAP((((limit-base)/size)/2)*size+base, base); + i = base + size; /* i scans left to right */ + j = limit - size; /* j scans right to left */ + if ( COMP(ctx, i, j) > 0 ) /* Sedgewick's */ + SWAP(i, j); /* three-element sort */ + if ( COMP(ctx, base, j) > 0 )/* sets things up */ + SWAP(base, j); /* so that */ + if ( COMP(ctx, i, base) > 0 )/* *i <= *base <= *j */ + SWAP(i, base); /* *base is pivot element */ + for ( ;; ) { /* loop until break */ + do /* move i right */ + i += size; /* until *i >= pivot */ + while ( COMP(ctx, i, base) < 0 ); + do /* move j left */ + j -= size; /* until *j <= pivot */ + while ( COMP(ctx, j, base) > 0 ); + if ( i > j ) /* if pointers crossed */ + break; /* break loop */ + SWAP(i, j); /* else swap elements, keep scanning*/ + } + SWAP(base, j); /* move pivot into correct place */ + if ( j - base > limit - i ) { /* if left subfile larger */ + sp[0] = base; /* stack left subfile base */ + sp[1] = j; /* and limit */ + base = i; /* sort the right subfile */ + } else { /* else right subfile larger*/ + sp[0] = i; /* stack right subfile base */ + sp[1] = limit; /* and limit */ + limit = j; /* sort the left subfile */ + } + sp += 2; /* increment stack pointer */ + } else { /* else subfile is small, use insertion sort */ + for ( j = base, i = j+size; i < limit; j = i, i += size ) + for ( ; COMP(ctx, j, j+size) > 0; j -= size ) { + SWAP(j, j+size); + if ( j == base ) + break; + } + if ( sp != stack ) { /* if any entries on stack */ + sp -= 2; /* pop the base and limit */ + base = sp[0]; + limit = sp[1]; + } else /* else stack empty, done */ + break; + } + } +} + + diff --git a/mp/src/tier1/snappy-stubs-internal.h b/mp/src/tier1/snappy-stubs-internal.h index 94468ba8..ec5d1018 100644 --- a/mp/src/tier1/snappy-stubs-internal.h +++ b/mp/src/tier1/snappy-stubs-internal.h @@ -138,8 +138,8 @@ class LogMessage { class LogMessageCrash : public LogMessage { public: LogMessageCrash() { } -#if _MSC_VER == 1700 -// Bogus warning from VS 2012: +#if _MSC_VER == 1700 || _MSC_VER == 1800 +// Bogus warning from VS 2012 and VS 2013: // warning C4722: 'snappy::LogMessageCrash::~LogMessageCrash' : destructor never returns, potential memory leak #pragma warning(push) #pragma warning(disable : 4722) @@ -150,7 +150,7 @@ class LogMessageCrash : public LogMessage { abort(); } }; -#if _MSC_VER == 1700 +#if _MSC_VER == 1700 || _MSC_VER == 1800 #pragma warning(pop) #endif diff --git a/mp/src/utils/glview/glview.cpp b/mp/src/utils/glview/glview.cpp index d7da07b3..6d50de7f 100644 --- a/mp/src/utils/glview/glview.cpp +++ b/mp/src/utils/glview/glview.cpp @@ -64,7 +64,7 @@ BOOL g_Update = TRUE; BOOL g_bDisp = FALSE; IPhysicsCollision *physcollision = NULL; // ----------- -static int g_Keys[255]; +static int g_Keys[256]; void AppKeyDown( int key ); void AppKeyUp( int key ); diff --git a/mp/src/utils/height2normal/height2normal.vpc b/mp/src/utils/height2normal/height2normal.vpc index be330ee4..febd9d34 100644 --- a/mp/src/utils/height2normal/height2normal.vpc +++ b/mp/src/utils/height2normal/height2normal.vpc @@ -14,7 +14,7 @@ $Configuration $Compiler { $AdditionalIncludeDirectories "$BASE,..\common" - $PreprocessorDefinitions "_HAS_ITERATOR_DEBUGGING=0;_DEBUG;_WIN32;_CONSOLE" + $PreprocessorDefinitions "_HAS_ITERATOR_DEBUGGING=0;_WIN32;_CONSOLE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions)" } } diff --git a/mp/src/utils/qc_eyes/qc_eyes.vpc b/mp/src/utils/qc_eyes/qc_eyes.vpc index ee3b4e39..a417fd7b 100644 --- a/mp/src/utils/qc_eyes/qc_eyes.vpc +++ b/mp/src/utils/qc_eyes/qc_eyes.vpc @@ -13,10 +13,17 @@ $Configuration { $Compiler { + // Deprecated MBCS MFC libraries for VS 2013 (nafxcw.lib and nafxcwd.lib) can be downloaded from http://go.microsoft.com/?linkid=9832071 + $PreprocessorDefinitions "$BASE;NO_WARN_MBCS_MFC_DEPRECATION" $Create/UsePrecompiledHeader "Use Precompiled Header (/Yu)" $PrecompiledHeaderFile "Debug/QC_Eyes.pch" $EnableC++Exceptions "Yes (/EHsc)" } + + $Linker + { + $AdditionalDependencies "$BASE;windowscodecs.lib" + } } $Project "QC_Eyes" diff --git a/mp/src/utils/vbsp/boundbox.cpp b/mp/src/utils/vbsp/boundbox.cpp index ecb8dfa0..a62e9e2f 100644 --- a/mp/src/utils/vbsp/boundbox.cpp +++ b/mp/src/utils/vbsp/boundbox.cpp @@ -14,7 +14,7 @@ #include "tier0/memdbgon.h" -float rint(float f) +float V_rint(float f) { if (f > 0.0f) { return (float) floor(f + 0.5f); @@ -223,7 +223,7 @@ void BoundBox::GetBoundsSize(Vector& size) //----------------------------------------------------------------------------- static int Snap(/*int*/ float iValue, int iGridSize) { - return (int)(rint(iValue/iGridSize) * iGridSize); + return (int)(V_rint(iValue/iGridSize) * iGridSize); } diff --git a/mp/src/vgui2/chromehtml/html_chrome.cpp b/mp/src/vgui2/chromehtml/html_chrome.cpp index 89874400..37ba4f74 100644 --- a/mp/src/vgui2/chromehtml/html_chrome.cpp +++ b/mp/src/vgui2/chromehtml/html_chrome.cpp @@ -111,18 +111,18 @@ void CCEFThread::WakeThread() //----------------------------------------------------------------------------- #define HTML_MSG_FUNC( eHTMLCommand, bodyType, commandFunc ) \ case eHTMLCommand: \ - { \ - CHTMLProtoBufMsg< bodyType > cmd( pCmd->m_eCmd ); \ - if ( !cmd.BDeserializeCrossProc( &pCmd->m_Buffer ) ) \ - { \ - bError = true; \ - } \ +{ \ + CHTMLProtoBufMsg< bodyType > cmd( pCmd->m_eCmd ); \ + if ( !cmd.BDeserializeCrossProc( &pCmd->m_Buffer ) ) \ +{ \ + bError = true; \ +} \ else \ - { \ +{ \ cmd.Body().set_browser_handle( pCmd->m_iBrowser ); \ - g_CEFThread.commandFunc( cmd ); \ - } \ - } \ + g_CEFThread.commandFunc( cmd ); \ +} \ +} \ break; @@ -204,7 +204,7 @@ void CCEFThread::RunCurrentCommands() HTML_MSG_FUNC( eHTMLCommands_ExitFullScreen, CMsgExitFullScreen, ThreadExitFullScreen ); HTML_MSG_FUNC( eHTMLCommands_CloseFullScreenFlashIfOpen, CMsgCloseFullScreenFlashIfOpen, ThreadCloseFullScreenFlashIfOpen ); HTML_MSG_FUNC( eHTMLCommands_PauseFullScreenFlashMovieIfOpen, CMsgPauseFullScreenFlashMovieIfOpen, ThreadPauseFullScreenFlashMovieIfOpen ); - + default: bError = true; AssertMsg1( false, "Invalid message in browser stream (%d)", pCmd->m_eCmd ); @@ -351,7 +351,7 @@ bool CCEFThread::GetMainThreadCommand( HTMLCommandBuffer_t **pBuf ) return true; } else - return m_tslResponseBuffers.PopItem( pBuf ); + return m_tslResponseBuffers.PopItem( pBuf ); } @@ -376,7 +376,7 @@ bool CCEFThread::GetCEFThreadCommand( HTMLCommandBuffer_t **pBuf ) //----------------------------------------------------------------------------- const char *CCEFThread::PchWebkitUserAgent() { - return "Mozilla/5.0 (%s; U; %s; en-US; %s/%llu; %s) AppleWebKit/535.15 (KHTML, like Gecko) Chrome/18.0.989.0 Safari/535.11"; + return "Mozilla/5.0 (%s; U; %s; en-US; %s/%llu; %s) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19"; } @@ -405,7 +405,6 @@ void CCEFThread::ThreadCreateBrowser( const CHTMLProtoBufMsg CefWindowInfo info; info.SetAsOffScreen( NULL ); info.m_bPopupWindow = htmlCommand.BodyConst().popup(); - CefBrowserSettings settings; settings.fullscreen_enabled = true; settings.threaded_compositing_enabled = true; @@ -416,6 +415,28 @@ void CCEFThread::ThreadCreateBrowser( const CHTMLProtoBufMsg // ports for Mac and Linux have bugs where it is not really disabled, causing havoc settings.drag_drop_disabled = true; +#ifdef LINUX + // Turn off web features here that don't work on Linux + settings.webgl_disabled = true; +#endif + + // CEF HTML local storage, databases, and offline application cache are all busted; + // they live in a temp dir which gets cleaned up on shutdown. There's no point in + // enabling them just to generate extra files to cleanup on shutdown when there's + // no actual disk persistence. we need to upgrade CEF again before they will work. + settings.local_storage_disabled = true; + settings.databases_disabled = true; + settings.application_cache_disabled = true; + settings.java_disabled = true; + + // We don't provide a UI to connect to the WebKit developer tools API + // so there is no point having it suck up CPU and listening on a port. + settings.developer_tools_disabled = true; + + // Drag and drop is supposed to be disabled automatically for offscreen views, but + // ports for Mac and Linux have bugs where it is not really disabled, causing havoc + settings.drag_drop_disabled = true; + #ifdef LINUX // Turn off web features here that don't work on Linux settings.webgl_disabled = true; @@ -479,7 +500,7 @@ void CCEFThread::ThreadBrowserSize( const CHTMLProtoBufMsg &htm GET_BROSWER_FUNC( htmlCommand, SetSize( PET_VIEW, htmlCommand.BodyConst().width(), htmlCommand.BodyConst().height() ) ); if ( BIsValidBrowserHandle( htmlCommand.BodyConst().browser_handle(), iClient ) ) m_listClientHandlers[iClient]->SetSize( htmlCommand.BodyConst().width(), htmlCommand.BodyConst().height() ); -} + } //----------------------------------------------------------------------------- @@ -646,8 +667,8 @@ void CCEFThread::ThreadBrowserHorizontalScrollBarSizeHelper( int iBrowser, bool if ( bForceSendUpdate || 0 != memcmp( &pHandler->m_CachedHScroll, &scroll, sizeof( scroll ) ) ) { pHandler->m_CachedHScroll = scroll; - - CHTMLProtoBufMsg cmd( eHTMLCommands_HorizontalScrollBarSizeResponse ); + + CHTMLProtoBufMsg cmd( eHTMLCommands_HorizontalScrollBarSizeResponse ); cmd.Body().set_x( scroll.m_nX ); cmd.Body().set_y( scroll.m_nY ); cmd.Body().set_wide( scroll.m_nWide ); @@ -655,10 +676,10 @@ void CCEFThread::ThreadBrowserHorizontalScrollBarSizeHelper( int iBrowser, bool cmd.Body().set_scroll_max( scroll.m_nMax ); cmd.Body().set_scroll( scroll.m_nScroll ); cmd.Body().set_visible( scroll.m_bVisible != 0 ); - cmd.Body().set_zoom( flZoom ); - int m_iBrowser = iBrowser; - DISPATCH_MESSAGE( eHTMLCommands_HorizontalScrollBarSizeResponse ); - } + cmd.Body().set_zoom( flZoom ); + int m_iBrowser = iBrowser; + DISPATCH_MESSAGE( eHTMLCommands_HorizontalScrollBarSizeResponse ); +} } } @@ -701,7 +722,7 @@ void CCEFThread::ThreadBrowserVerticalScrollBarSizeHelper( int iBrowser, bool bF { pHandler->m_CachedVScroll = scroll; - CHTMLProtoBufMsg cmd( eHTMLCommands_VerticalScrollBarSizeResponse ); + CHTMLProtoBufMsg cmd( eHTMLCommands_VerticalScrollBarSizeResponse ); cmd.Body().set_x( scroll.m_nX ); cmd.Body().set_y( scroll.m_nY ); cmd.Body().set_wide( scroll.m_nWide ); @@ -709,10 +730,10 @@ void CCEFThread::ThreadBrowserVerticalScrollBarSizeHelper( int iBrowser, bool bF cmd.Body().set_scroll_max( scroll.m_nMax ); cmd.Body().set_scroll( scroll.m_nScroll ); cmd.Body().set_visible( scroll.m_bVisible != 0 ); - cmd.Body().set_zoom( flZoom ); - int m_iBrowser = iBrowser; - DISPATCH_MESSAGE( eHTMLCommands_VerticalScrollBarSizeResponse ); - } + cmd.Body().set_zoom( flZoom ); + int m_iBrowser = iBrowser; + DISPATCH_MESSAGE( eHTMLCommands_VerticalScrollBarSizeResponse ); +} } } @@ -743,7 +764,7 @@ void CCEFThread::ThreadBrowserSetHorizontalScroll( const CHTMLProtoBufMsg &htmlCmd ) //----------------------------------------------------------------------------- void IOT_SetCookie(const CefString& url, CefCookie* cookie, CThreadEvent *pEvent ) { - CefSetCookie(url, *cookie); + CefCookieManager::GetGlobalManager()->SetCookie(url, *cookie); pEvent->Set(); } @@ -936,7 +957,7 @@ private: //----------------------------------------------------------------------------- void IOT_CookiesForURL(const CefString& url, CThreadEvent *pEvent, CUtlVector *pVecCookies ) { - CefVisitUrlCookies( url, false, new CookieVisitor( pVecCookies, pEvent ) ); + CefCookieManager::GetGlobalManager()->VisitUrlCookies( url, false, new CookieVisitor( pVecCookies, pEvent ) ); } @@ -1029,7 +1050,6 @@ void CCEFThread::AppGetSettings(CefSettings& settings, CefRefPtr& app) //#endif } - //----------------------------------------------------------------------------- // Purpose: clean up the temp folders cef can leave around on crash //----------------------------------------------------------------------------- @@ -1092,12 +1112,13 @@ int CCEFThread::Run() // Populate the settings based on command line arguments. AppGetSettings(settings, app); + settings.pack_loading_disabled = true; // Initialize CEF. CefInitialize(settings, app, ""); #if defined( VPROF_ENABLED ) - //CVProfile *pProfile = GetVProfProfileForCurrentThread(); +// CVProfile *pProfile = GetVProfProfileForCurrentThread(); #endif CLimitTimer timer; @@ -1125,8 +1146,8 @@ int CCEFThread::Run() m_bSawUserInputThisFrame = false; #if defined( VPROF_ENABLED ) - //if ( pProfile ) - // pProfile->MarkFrame( "UI CEF HTML Thread" ); +// if ( pProfile ) +// pProfile->MarkFrame( "UI CEF HTML Thread" ); #endif // Limit animation frame rate timer.SetLimit( k_nMillion/m_nTargetFrameRate ); @@ -1138,7 +1159,7 @@ int CCEFThread::Run() } // now let cef think - if ( m_listClientHandlers.Count() || timerLastCefThink.BLimitReached() ) + if ( !m_bExit && ( m_listClientHandlers.Count() || timerLastCefThink.BLimitReached() ) && m_nTargetFrameRate > 0 ) { VPROF_BUDGET( "CCEFThread - CefDoMessageLoopWork()", VPROF_BUDGETGROUP_TENFOOT ); CefDoMessageLoopWork(); @@ -1314,7 +1335,7 @@ void CCEFThread::CheckForFullScreenFlashControl() } SetForegroundWindow( m_flashfullscreenHWND ); - } + } } else { @@ -1360,40 +1381,40 @@ void CCEFThread::Validate( CValidator &validator, const tchar *pchName ) // hacky but reliable way to avoid both vgui and panorama validating all this stuff twice if ( !validator.IsClaimed( m_sHTMLCacheDir.Access() ) ) { - VALIDATE_SCOPE(); - ValidateObj( m_sHTMLCacheDir ); - ValidateObj( m_sCookiePath ); - ValidateObj( m_listClientHandlers ); - FOR_EACH_LL( m_listClientHandlers, i ) - { - ValidatePtr( m_listClientHandlers[i] ); - } - ValidateObj( m_vecQueueCommands ); - FOR_EACH_VEC( m_vecQueueCommands, i ) - { - ValidatePtr( m_vecQueueCommands[i] ); - } + VALIDATE_SCOPE(); + ValidateObj( m_sHTMLCacheDir ); + ValidateObj( m_sCookiePath ); + ValidateObj( m_listClientHandlers ); + FOR_EACH_LL( m_listClientHandlers, i ) + { + ValidatePtr( m_listClientHandlers[i] ); + } + ValidateObj( m_vecQueueCommands ); + FOR_EACH_VEC( m_vecQueueCommands, i ) + { + ValidatePtr( m_vecQueueCommands[i] ); + } ValidateObj( m_vecQueueResponses ); FOR_EACH_VEC( m_vecQueueResponses, i ) { ValidatePtr( m_vecQueueResponses[i] ); } - ValidateObj( m_tslUnsedBuffers ); + ValidateObj( m_tslUnsedBuffers ); + { + CTSList::Node_t *pNode = m_tslUnsedBuffers.Detach(); + while ( pNode ) { - CTSList::Node_t *pNode = m_tslUnsedBuffers.Detach(); - while ( pNode ) - { - CTSList::Node_t *pNext = (CTSList::Node_t *)pNode->Next; - ValidatePtr( pNode->elem ); - m_tslUnsedBuffers.Push( pNode ); - pNode = pNext; - } + CTSList::Node_t *pNext = (CTSList::Node_t *)pNode->Next; + ValidatePtr( pNode->elem ); + m_tslUnsedBuffers.Push( pNode ); + pNode = pNext; } - - ValidateObj( m_tslCommandBuffers ); - ValidateObj( m_tslResponseBuffers ); } + + ValidateObj( m_tslCommandBuffers ); + ValidateObj( m_tslResponseBuffers ); +} } #endif @@ -1567,23 +1588,23 @@ void CChromePainter::OnPaint(CefRefPtr browser, PaintElementType typ { // main browser painting - if ( !m_pParent->IsVisuallyNonEmpty() ) - { - return; - } + if ( !m_pParent->IsVisuallyNonEmpty() ) + { + return; + } // If there were no dirty regions (unlikely), perhaps due to a bug, be conservative and paint all if ( dirtyRects.empty() ) - { + { m_MainTexture.MarkAllDirty(); - } - else - { + } + else + { for ( RectList::const_iterator iter = dirtyRects.begin(); iter != dirtyRects.end(); ++iter ) - { + { m_MainTexture.MarkDirtyRect( iter->x, iter->y, iter->x + iter->width, iter->y + iter->height ); - } - } + } + } // Refresh all dirty main texture pixels from the chromium rendering buffer if ( m_MainTexture.BUpdatePixels( (byte*)buffer, wide, tall ) ) @@ -1629,7 +1650,7 @@ void CChromePainter::SetUpdated( bool state ) // Purpose: move to the next html texture to render into //----------------------------------------------------------------------------- uint32 CChromePainter::FlipTexture() -{ +{ int iTex = m_iNextTexture; m_iTexturesInFlightBits |= ( 1< browser, if ( !frame->IsMain() ) return; - std::wstring sURL = frame->GetURL(); - if ( sURL.empty() ) - return; + std::wstring sURL = frame->GetURL(); + if ( sURL.empty() ) + return; - CStrAutoEncode url( sURL.c_str() ); - m_strCurrentUrl = url.ToString(); + CStrAutoEncode url( sURL.c_str() ); + m_strCurrentUrl = url.ToString(); - if ( m_strCurrentUrl.IsEmpty() ) - return; + if ( m_strCurrentUrl.IsEmpty() ) + return; - bool bIsRedirect = false; - if ( m_strCurrentUrl == m_strLastRedirectURL ) - bIsRedirect = true; + bool bIsRedirect = false; + if ( m_strCurrentUrl == m_strLastRedirectURL ) + bIsRedirect = true; - CHTMLProtoBufMsg cmd( eHTMLCommands_URLChanged ); - cmd.Body().set_url( url.ToString() ); + CHTMLProtoBufMsg cmd( eHTMLCommands_URLChanged ); + cmd.Body().set_url( url.ToString() ); cmd.Body().set_bnewnavigation( bIsNewNavigation ); - - if ( !m_strPostData.IsEmpty() ) + + if ( !m_strPostData.IsEmpty() ) cmd.Body().set_postdata( m_strPostData.String() ); - cmd.Body().set_bisredirect( bIsRedirect ); - CefString frameName = frame->GetName(); - if ( !frameName.empty() ) - cmd.Body().set_pagetitle( frameName.c_str() ); + cmd.Body().set_bisredirect( bIsRedirect ); + CefString frameName = frame->GetName(); + if ( !frameName.empty() ) + cmd.Body().set_pagetitle( frameName.c_str() ); - DISPATCH_MESSAGE( eHTMLCommands_URLChanged ); - } + DISPATCH_MESSAGE( eHTMLCommands_URLChanged ); +} { CHTMLProtoBufMsg cmd( eHTMLCommands_CanGoBackandForward ); @@ -2420,10 +2441,10 @@ bool CClientHandler::OnTooltip(CefRefPtr browser, CefString& text) { m_strToolTip = text.c_str(); - CHTMLProtoBufMsg cmd( eHTMLCommands_UpdateToolTip ); + CHTMLProtoBufMsg cmd( eHTMLCommands_UpdateToolTip ); cmd.Body().set_text( m_strToolTip ); - DISPATCH_MESSAGE( eHTMLCommands_UpdateToolTip ); - } + DISPATCH_MESSAGE( eHTMLCommands_UpdateToolTip ); + } } else if ( m_bShowingToolTip ) { @@ -2612,9 +2633,9 @@ bool CChromePainter::OnFileOpenDialog( CefRefPtr browser, bool bMult { if ( !cmd.BodyConst().files(i).empty() ) { - CPathString path( cmd.BodyConst().files(i).c_str() ); - files.push_back( path.GetWCharPathPrePended() ); - } + CPathString path( cmd.BodyConst().files(i).c_str() ); + files.push_back( path.GetWCharPathPrePended() ); + } } // if you have a DEBUG build and are crashing here it is because @@ -2853,7 +2874,7 @@ void CClientHandler::SetMouseLocation( int nMouseX, int nMouseY ) m_nMouseScrolledY = nMouseY + m_Browser->HorizontalScroll(); m_bMouseFocus = true; m_Browser->SendMouseMoveEvent( m_nMouseX, m_nMouseY, false ); - } +} } //----------------------------------------------------------------------------- @@ -2952,7 +2973,7 @@ const byte *CClientHandler::PComposedTextureData( uint32 iTexture ) VPROF_BUDGET( "CClientHandler::PTextureData", VPROF_BUDGETGROUP_VGUI ); return m_Painter.PComposedTextureData( iTexture ); -} + } //----------------------------------------------------------------------------- @@ -3048,12 +3069,13 @@ void CCEFThread::ThreadLinkAtPosition( const CHTMLProtoBufMsgGetBrowser() ) - pchURL = m_listClientHandlers[iClient]->GetBrowser()->GetLinkAtPosition( htmlCommand.BodyConst().x(), htmlCommand.BodyConst().y(), bLiveLink, bInput ); + m_listClientHandlers[iClient]->GetBrowser()->GetLinkAtPosition( htmlCommand.BodyConst().x(), htmlCommand.BodyConst().y(), + pchURL, bLiveLink, bInput); } CHTMLProtoBufMsg cmd( eHTMLCommands_LinkAtPositionResponse ); @@ -3079,9 +3101,9 @@ void CCEFThread::ThreadZoomToElementAtPosition( const CHTMLProtoBufMsgGetBrowser() ) { CefRect initialRect, finalRect; - float zoomLevel = m_listClientHandlers[iClient]->GetBrowser()->scalePageToFitElementAt( - htmlCommand.BodyConst().x(), htmlCommand.BodyConst().y(), - initialRect, finalRect ); + float zoomLevel = m_listClientHandlers[iClient]->GetBrowser()->scalePageToFitElementAt( + htmlCommand.BodyConst().x(), htmlCommand.BodyConst().y(), + initialRect, finalRect ); int m_iBrowser = htmlCommand.BodyConst().browser_handle(); ThreadBrowserVerticalScrollBarSizeHelper( m_iBrowser, true ); ThreadBrowserHorizontalScrollBarSizeHelper( m_iBrowser, true ); @@ -3100,7 +3122,7 @@ void CCEFThread::ThreadZoomToElementAtPosition( const CHTMLProtoBufMsg &htmlC int nMouseX, nMouseY; m_listClientHandlers[ iClient ]->GetMouseLocation( nMouseX, nMouseY ); - browser->SendMouseWheelEvent( nMouseX, nMouseY, htmlCommand.BodyConst().delta() ); + browser->SendMouseWheelEvent( nMouseX, nMouseY, 0, htmlCommand.BodyConst().delta() ); } } @@ -3374,7 +3396,13 @@ void CCEFThread::ThreadKeyTyped( const CHTMLProtoBufMsg &htmlComman if ( !browser.get() ) return; - browser->SendKeyEvent( KT_CHAR, htmlCommand.BodyConst().unichar(), 0, false, false ); + CefKeyInfo keyInfo; +#ifdef OSX + keyInfo.character = htmlCommand.BodyConst().unichar(); +#else + keyInfo.key = htmlCommand.BodyConst().unichar(); +#endif + browser->SendKeyEvent( KT_CHAR, keyInfo, 0 ); } } @@ -3391,7 +3419,13 @@ void CCEFThread::ThreadKeyDown( const CHTMLProtoBufMsg &htmlCommand if ( !browser.get() ) return; - browser->SendKeyEvent( KT_KEYDOWN, htmlCommand.BodyConst().keycode(), htmlCommand.BodyConst().modifiers(), false, false ); + CefKeyInfo keyInfo; +#ifdef OSX + keyInfo.keyCode = htmlCommand.BodyConst().keycode(); +#else + keyInfo.key = htmlCommand.BodyConst().keycode(); +#endif + browser->SendKeyEvent( KT_KEYDOWN, keyInfo, htmlCommand.BodyConst().modifiers() ); } } @@ -3408,7 +3442,13 @@ void CCEFThread::ThreadKeyUp( const CHTMLProtoBufMsg &htmlCommand ) if ( !browser.get() ) return; - browser->SendKeyEvent( KT_KEYUP, htmlCommand.BodyConst().keycode(), htmlCommand.BodyConst().modifiers(), false, false ); + CefKeyInfo keyInfo; +#ifdef OSX + keyInfo.keyCode = htmlCommand.BodyConst().keycode(); +#else + keyInfo.key = htmlCommand.BodyConst().keycode(); +#endif + browser->SendKeyEvent( KT_KEYUP, keyInfo, htmlCommand.BodyConst().modifiers() ); } } diff --git a/mp/src/vpc_scripts/platform_dirs.vpc b/mp/src/vpc_scripts/platform_dirs.vpc index 60c795c2..65d0b979 100644 --- a/mp/src/vpc_scripts/platform_dirs.vpc +++ b/mp/src/vpc_scripts/platform_dirs.vpc @@ -1,4 +1,4 @@ -$Macro PLATSUBDIR "\." [$WIN32] +$Macro PLATSUBDIR "\." [$WIN32] $Macro PLATSUBDIR "\x64" [$WIN64] $Macro PLATSUBDIR "\." [$X360] $Macro PLATSUBDIR "\linux32" [$LINUX32] diff --git a/mp/src/vpc_scripts/source_dll_win32_base.vpc b/mp/src/vpc_scripts/source_dll_win32_base.vpc index fea67c51..1507687e 100644 --- a/mp/src/vpc_scripts/source_dll_win32_base.vpc +++ b/mp/src/vpc_scripts/source_dll_win32_base.vpc @@ -39,7 +39,7 @@ $Configuration $Compiler [$WIN32] { - $EnableEnhancedInstructionSet "Streaming SIMD Extensions 2 (/arch:SSE2)" + $EnableEnhancedInstructionSet "Streaming SIMD Extensions (/arch:SSE)" } $Linker @@ -103,6 +103,23 @@ $Project } } } + + // Implement __imp__EncodePointer and __imp__DecodePointer so that we can run on XP SP1 + // when building with VS 2010. + $File "$SRCDIR\public\tier0\pointeroverride.asm" [$WIN32 && $VS2010] + { + $Configuration + { + $CustomBuildStep + { + // General + $CommandLine "$QUOTE$(VCInstallDir)bin\ml.exe$QUOTE /safeseh /c /Cp /Zi /Fo$QUOTE$(IntDir)\$(InputName).obj$QUOTE $QUOTE$(InputPath)$QUOTE" + $Description "Compiling pointeroverride.asm" + $Outputs "$(IntDir)\$(InputName).obj" + } + } + } + $File "$SRCDIR\common\debug_dll_check.cpp" [!$SOURCESDK] { $Configuration diff --git a/mp/src/vpc_scripts/source_dll_win32_debug.vpc b/mp/src/vpc_scripts/source_dll_win32_debug.vpc index f6e18696..aa8ebf13 100644 --- a/mp/src/vpc_scripts/source_dll_win32_debug.vpc +++ b/mp/src/vpc_scripts/source_dll_win32_debug.vpc @@ -74,7 +74,7 @@ $Configuration "Debug" $WholeProgramOptimization // Preprocessor - $PreprocessorDefinitions "$BASE;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "$BASE;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions)" $IgnoreStandardIncludePath $GeneratePreprocessedFile $KeepComments @@ -132,8 +132,7 @@ $Configuration "Debug" $OmitDefaultLibraryNames $ErrorReporting "Prompt Immediately (/errorReport:prompt)" - // Command Line (L4D adding /MP) - $AdditionalOptions "/MP /Zm200" + $AdditionalOptions "/Zm200" } $Linker @@ -225,6 +224,8 @@ $Configuration "Debug" $DelaySign $ErrorReporting "Prompt Immediately (/ERRORREPORT:PROMPT)" $CLRUnmanagedCodeCheck + // SAFE_SEH should always be disabled on debug builds. + $ImageHasSafeExceptionHandlers "false" // Command Line $AdditionalOptions @@ -283,7 +284,7 @@ $Configuration "Debug" $Resources { // General - $PreprocessorDefinitions "$BASE;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "$BASE;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)" $Culture "English (United States) (0x409)" $AdditionalIncludeDirectories $IgnoreStandardIncludePath diff --git a/mp/src/vpc_scripts/source_dll_win32_release.vpc b/mp/src/vpc_scripts/source_dll_win32_release.vpc index fb17d0fb..916045f5 100644 --- a/mp/src/vpc_scripts/source_dll_win32_release.vpc +++ b/mp/src/vpc_scripts/source_dll_win32_release.vpc @@ -81,7 +81,7 @@ $Configuration "Release" $WholeProgramOptimization // Preprocessor - $PreprocessorDefinitions "$BASE;WIN32;_WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "$BASE;WIN32;_WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions)" $PreprocessorDefinitions "$BASE;RELEASE_ASSERTS" [$RELEASEASSERTS] $IgnoreStandardIncludePath $GeneratePreprocessedFile @@ -141,8 +141,7 @@ $Configuration "Release" $OmitDefaultLibraryNames $ErrorReporting "Prompt Immediately (/errorReport:prompt)" - // Command Line (L4D adding /MP) - $AdditionalOptions "/MP /Zm200" + $AdditionalOptions "/Zm200" // Enable extra debugging information. $AdditionalOptions "$BASE /d2Zi+" [$VS2010] $AdditionalOptions "$BASE /Oy-" [$NOFPO] @@ -248,6 +247,8 @@ $Configuration "Release" $DelaySign $ErrorReporting "Prompt Immediately (/ERRORREPORT:PROMPT)" $CLRUnmanagedCodeCheck + // Most DLLs cannot yet handle SafeSEH + $ImageHasSafeExceptionHandlers "false" // Command Line $AdditionalOptions @@ -306,7 +307,7 @@ $Configuration "Release" $Resources { // General - $PreprocessorDefinitions "$BASE;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "$BASE;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)" $Culture "English (United States) (0x409)" $AdditionalIncludeDirectories $IgnoreStandardIncludePath diff --git a/mp/src/vpc_scripts/source_exe_win_win32_base.vpc b/mp/src/vpc_scripts/source_exe_win_win32_base.vpc index 9a79a68d..22b3896f 100644 --- a/mp/src/vpc_scripts/source_exe_win_win32_base.vpc +++ b/mp/src/vpc_scripts/source_exe_win_win32_base.vpc @@ -39,7 +39,7 @@ $Configuration $Compiler [$WIN32] { - $EnableEnhancedInstructionSet "Streaming SIMD Extensions 2 (/arch:SSE2)" + $EnableEnhancedInstructionSet "Streaming SIMD Extensions (/arch:SSE)" } $Linker @@ -98,6 +98,22 @@ $Project } } } + + // Implement __imp__EncodePointer and __imp__DecodePointer so that we can run on XP SP1 + // when building with VS 2010. + $File "$SRCDIR\public\tier0\pointeroverride.asm" [$WIN32 && $VS2010] + { + $Configuration + { + $CustomBuildStep + { + // General + $CommandLine "$QUOTE$(VCInstallDir)bin\ml.exe$QUOTE /c /Cp /Zi /Fo$QUOTE$(IntDir)\$(InputName).obj$QUOTE $QUOTE$(InputPath)$QUOTE" + $Description "Compiling pointeroverride.asm" + $Outputs "$(IntDir)\$(InputName).obj" + } + } + } } $Folder "Link Libraries" diff --git a/mp/src/vpc_scripts/source_exe_win_win32_debug.vpc b/mp/src/vpc_scripts/source_exe_win_win32_debug.vpc index 725883ed..302d80e9 100644 --- a/mp/src/vpc_scripts/source_exe_win_win32_debug.vpc +++ b/mp/src/vpc_scripts/source_exe_win_win32_debug.vpc @@ -74,7 +74,7 @@ $Configuration "Debug" $WholeProgramOptimization // Preprocessor - $PreprocessorDefinitions "$BASE;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "$BASE;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions)" $IgnoreStandardIncludePath $GeneratePreprocessedFile $KeepComments @@ -229,6 +229,8 @@ $Configuration "Debug" $DelaySign $ErrorReporting "Prompt Immediately (/ERRORREPORT:PROMPT)" $CLRUnmanagedCodeCheck + // SAFE_SEH should always be disabled on debug builds. + $ImageHasSafeExceptionHandlers "false" // Command Line $AdditionalOptions @@ -287,7 +289,7 @@ $Configuration "Debug" $Resources { // General - $PreprocessorDefinitions "_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)" $Culture "English (United States) (0x409)" $AdditionalIncludeDirectories $IgnoreStandardIncludePath @@ -327,4 +329,4 @@ $Configuration "Debug" $Outputs $AdditionalDependencies } -} \ No newline at end of file +} diff --git a/mp/src/vpc_scripts/source_exe_win_win32_release.vpc b/mp/src/vpc_scripts/source_exe_win_win32_release.vpc index 6f74c508..d3370146 100644 --- a/mp/src/vpc_scripts/source_exe_win_win32_release.vpc +++ b/mp/src/vpc_scripts/source_exe_win_win32_release.vpc @@ -81,7 +81,7 @@ $Configuration "Release" $WholeProgramOptimization // Preprocessor - $PreprocessorDefinitions "$BASE;WIN32;_WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "$BASE;WIN32;_WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions)" $PreprocessorDefinitions "$BASE;RELEASE_ASSERTS" [$RELEASEASSERTS] $IgnoreStandardIncludePath $GeneratePreprocessedFile @@ -247,6 +247,8 @@ $Configuration "Release" $DelaySign $ErrorReporting "Prompt Immediately (/ERRORREPORT:PROMPT)" $CLRUnmanagedCodeCheck + // Most DLLs cannot yet handle SafeSEH + $ImageHasSafeExceptionHandlers "false" // Command Line $AdditionalOptions @@ -305,7 +307,7 @@ $Configuration "Release" $Resources { // General - $PreprocessorDefinitions "NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)" $Culture "English (United States) (0x409)" $AdditionalIncludeDirectories $IgnoreStandardIncludePath diff --git a/mp/src/vpc_scripts/source_lib_win32_base.vpc b/mp/src/vpc_scripts/source_lib_win32_base.vpc index 0eb822ab..c5f8e0b5 100644 --- a/mp/src/vpc_scripts/source_lib_win32_base.vpc +++ b/mp/src/vpc_scripts/source_lib_win32_base.vpc @@ -38,7 +38,7 @@ $Configuration $Compiler [$WIN32] { - $EnableEnhancedInstructionSet "Streaming SIMD Extensions 2 (/arch:SSE2)" + $EnableEnhancedInstructionSet "Streaming SIMD Extensions (/arch:SSE)" } $PreBuildEvent diff --git a/mp/src/vpc_scripts/source_lib_win32_debug.vpc b/mp/src/vpc_scripts/source_lib_win32_debug.vpc index cf82df16..cefc44f4 100644 --- a/mp/src/vpc_scripts/source_lib_win32_debug.vpc +++ b/mp/src/vpc_scripts/source_lib_win32_debug.vpc @@ -75,7 +75,7 @@ $Configuration "Debug" $WholeProgramOptimization // Preprocessor - $PreprocessorDefinitions "$BASE;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "$BASE;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions)" $IgnoreStandardIncludePath $GeneratePreprocessedFile $KeepComments @@ -136,9 +136,6 @@ $Configuration "Debug" $UseFullPaths "Yes (/FC)" $OmitDefaultLibraryNames $ErrorReporting "Prompt Immediately (/errorReport:prompt)" - - // Command Line (L4D adding /MP) - $AdditionalOptions "/MP" [$VS2005] } $Librarian diff --git a/mp/src/vpc_scripts/source_lib_win32_release.vpc b/mp/src/vpc_scripts/source_lib_win32_release.vpc index c87a13b7..b6f54059 100644 --- a/mp/src/vpc_scripts/source_lib_win32_release.vpc +++ b/mp/src/vpc_scripts/source_lib_win32_release.vpc @@ -82,7 +82,7 @@ $Configuration "Release" $WholeProgramOptimization // Preprocessor - $PreprocessorDefinitions "$BASE;WIN32;_WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "$BASE;WIN32;_WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions)" $PreprocessorDefinitions "$BASE;RELEASE_ASSERTS" [$RELEASEASSERTS] $IgnoreStandardIncludePath $GeneratePreprocessedFile @@ -142,10 +142,8 @@ $Configuration "Release" $OmitDefaultLibraryNames $ErrorReporting "Prompt Immediately (/errorReport:prompt)" - // Command Line (L4D adding /MP) - $AdditionalOptions "/MP" // Enable extra debugging information. - $AdditionalOptions "$BASE /d2Zi+" [$VS2010] + $AdditionalOptions "/d2Zi+" [$VS2010] $AdditionalOptions "$BASE /Oy-" [$NOFPO] } diff --git a/mp/src/vpc_scripts/source_win32_base.vpc b/mp/src/vpc_scripts/source_win32_base.vpc index 60968484..3749a07a 100644 --- a/mp/src/vpc_scripts/source_win32_base.vpc +++ b/mp/src/vpc_scripts/source_win32_base.vpc @@ -3,8 +3,10 @@ $Configuration $General { // Request a specific compiler toolset. - $PlatformToolset "v110" [$VS2012] // VS 11 - $PlatformToolset "v120" [$VS2013] // VS 12 + $PlatformToolset "v110_xp" [$VS2012 && !$ANALYZE] // VS 2012 targeting Windows XP - http://msdn.microsoft.com/en-us/library/vstudio/jj851139.aspx + $PlatformToolset "v110" [$VS2012 && $ANALYZE] // VS 2012 for /analyze + $PlatformToolset "v120_xp" [$VS2013 && !$ANALYZE] // VS 2013 targeting Windows XP - http://msdn.microsoft.com/en-us/library/vstudio/jj851139.aspx + $PlatformToolset "v120" [$VS2013 && $ANALYZE] // VS 2013 for /analyze } $General @@ -15,16 +17,17 @@ $Configuration // VS 2012 compiles fine but does not link. We want to redirect to stub versions of // the tools (like link.exe and mt.exe) so that the link stage will be NOPed when // doing /analyze builds. - $ExecutableDirectories "$SRCDIR\devtools\vs_nop_tools;$BASE" [$ANALYZE && ($VS2012 || $VS2013)] + $ExecutableDirectories "$SRCDIR\devtools\vs_nop_tools;$BASE" [$ANALYZE] } $Compiler { + $MultiProcessorCompilation "True" + // warning C4316: object allocated on the heap may not be aligned 16 $DisableSpecificWarnings "$BASE;4316" [$VS2013] - // When using /analyze (triggered with /define:ANALYZE on the vpc command line) we want - // to use /MP but not at its most aggressive setting, and we want to forcibly disable lots + // When using /analyze (triggered with /define:ANALYZE on the vpc command line) we want to forcibly disable lots // of warnings (also disabled in platform.h but not everybody includes that). // See platform.h for the list of warnings with explanations. // warning C6318: Ill-defined __try/__except: use of the constant EXCEPTION_CONTINUE_SEARCH -- bogus @@ -33,7 +36,9 @@ $Configuration // Note that /analyze for VS 2010 only works with the 32-bit compiler, but for VS 2012 it works on 64-bit // as well. $DisableSpecificWarnings "$BASE;6308;6255;6387;6309;6011;6211;6031;6326;6239;6285;6237;6235;6240;6323;6326;6335;6320;6250;6384;6318;6322" [$ANALYZE] - $AdditionalOptions "$BASE /MP3 /analyze /analyze:stacksize100000" [$ANALYZE] + // See http://randomascii.wordpress.com/2011/10/04/analyzecommand-line-options/ for details on these options. + // /analyze:only may result in fewer warnings being reported, but the warnings it misses should show up in the regular build. + $AdditionalOptions "$BASE /analyze /analyze:only /analyze:stacksize100000" [$ANALYZE] // Specify /define:ALLOWSHADOWING to suppress variable shadowing warnings $DisableSpecificWarnings "$BASE;6244;6246" [$ANALYZE && $ALLOWSHADOWING] diff --git a/sp/src/common/studiobyteswap.cpp b/sp/src/common/studiobyteswap.cpp index d7723d48..0c4e59d8 100644 --- a/sp/src/common/studiobyteswap.cpp +++ b/sp/src/common/studiobyteswap.cpp @@ -1915,6 +1915,22 @@ int ByteswapMDLFile( void *pDestBase, void *pSrcBase, const int fileSize ) SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, qalignmentindex ) WriteBuffer( &pDataDest, &pDataSrc, 4*numBones ); } + + /** BONE FLEX DRIVERS **/ + if ( pStudioHdr2->m_nBoneFlexDriverIndex ) + { + SET_INDEX_POINTERS_FIXUP( pData, pStudioHdr2, m_nBoneFlexDriverIndex ) + DECLARE_OBJECT_POINTERS( pBoneFlexDriver, pData, mstudioboneflexdriver_t ) + ITERATE_BLOCK( pBoneFlexDriver, pStudioHdr2->m_nBoneFlexDriverCount ) + { + WriteObjects( pBoneFlexDriverDest, pBoneFlexDriverSrc ); + + /** BONE FLEX DRIVER CONTROLS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pBoneFlexDriver, m_nControlIndex ); + WriteObjects< mstudioboneflexdrivercontrol_t >( &pDataDest, &pDataSrc, SrcNative( &pBoneFlexDriver->m_nControlCount ) ); + } + } } } @@ -2516,7 +2532,8 @@ BEGIN_BYTESWAP_DATADESC( studiohdr_t ) DEFINE_INDEX( unused4, FIELD_INTEGER ), DEFINE_FIELD( numflexcontrollerui, FIELD_INTEGER ), DEFINE_INDEX( flexcontrolleruiindex, FIELD_INTEGER ), - DEFINE_ARRAY( unused3, FIELD_INTEGER, 2 ), + DEFINE_FIELD( flVertAnimFixedPointScale, FIELD_FLOAT ), + DEFINE_ARRAY( unused3, FIELD_INTEGER, 1 ), DEFINE_INDEX( studiohdr2index, FIELD_INTEGER ), DEFINE_ARRAY( unused2, FIELD_INTEGER, 1 ), END_BYTESWAP_DATADESC() @@ -2530,7 +2547,9 @@ BEGIN_BYTESWAP_DATADESC( studiohdr2_t ) DEFINE_FIELD( flMaxEyeDeflection, FIELD_FLOAT ), DEFINE_INDEX( linearboneindex, FIELD_INTEGER ), DEFINE_INDEX( sznameindex, FIELD_INTEGER ), - DEFINE_ARRAY( reserved, FIELD_INTEGER, 58 ), + DEFINE_INDEX( m_nBoneFlexDriverCount, FIELD_INTEGER ), + DEFINE_INDEX( m_nBoneFlexDriverIndex, FIELD_INTEGER ), + DEFINE_ARRAY( reserved, FIELD_INTEGER, 56 ), END_BYTESWAP_DATADESC() BEGIN_BYTESWAP_DATADESC( mstudiobone_t ) @@ -2567,6 +2586,20 @@ BEGIN_BYTESWAP_DATADESC( mstudiolinearbone_t ) DEFINE_ARRAY( unused, FIELD_INTEGER, 6 ), END_BYTESWAP_DATADESC() +BEGIN_BYTESWAP_DATADESC( mstudioboneflexdrivercontrol_t ) + DEFINE_INDEX( m_nBoneComponent, FIELD_INTEGER ), + DEFINE_FIELD( m_nFlexControllerIndex, FIELD_INTEGER ), + DEFINE_INDEX( m_flMin, FIELD_FLOAT ), + DEFINE_INDEX( m_flMax, FIELD_FLOAT ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioboneflexdriver_t ) + DEFINE_INDEX( m_nBoneIndex, FIELD_INTEGER ), + DEFINE_FIELD( m_nControlCount, FIELD_INTEGER ), + DEFINE_INDEX( m_nControlIndex, FIELD_FLOAT ), + DEFINE_ARRAY( unused, FIELD_INTEGER, 3 ), +END_BYTESWAP_DATADESC() + BEGIN_BYTESWAP_DATADESC( mstudioaxisinterpbone_t ) DEFINE_FIELD( control, FIELD_INTEGER ), DEFINE_FIELD( axis, FIELD_INTEGER ), diff --git a/sp/src/devtools/bin/linux/ccache b/sp/src/devtools/bin/linux/ccache index 3ef6b8e9..5146484f 100755 Binary files a/sp/src/devtools/bin/linux/ccache and b/sp/src/devtools/bin/linux/ccache differ diff --git a/sp/src/devtools/bin/osx32/ccache b/sp/src/devtools/bin/osx32/ccache index 86afc048..1b6a2e5f 100755 Binary files a/sp/src/devtools/bin/osx32/ccache and b/sp/src/devtools/bin/osx32/ccache differ diff --git a/sp/src/devtools/bin/vpc.exe b/sp/src/devtools/bin/vpc.exe index 2394de95..fcadab1c 100644 Binary files a/sp/src/devtools/bin/vpc.exe and b/sp/src/devtools/bin/vpc.exe differ diff --git a/sp/src/devtools/bin/vpc_linux b/sp/src/devtools/bin/vpc_linux index c5e72b80..18dd3d7c 100755 Binary files a/sp/src/devtools/bin/vpc_linux and b/sp/src/devtools/bin/vpc_linux differ diff --git a/sp/src/devtools/bin/vpc_osx b/sp/src/devtools/bin/vpc_osx index 1e5dea1c..ed7d57a5 100755 Binary files a/sp/src/devtools/bin/vpc_osx and b/sp/src/devtools/bin/vpc_osx differ diff --git a/sp/src/dx10sdk/Utilities/dx9_30/dx_proxy.dll b/sp/src/dx10sdk/Utilities/dx9_30/dx_proxy.dll index 8cd3b73e..e3f0632c 100644 Binary files a/sp/src/dx10sdk/Utilities/dx9_30/dx_proxy.dll and b/sp/src/dx10sdk/Utilities/dx9_30/dx_proxy.dll differ diff --git a/sp/src/dx9sdk/utilities/dx_proxy.dll b/sp/src/dx9sdk/utilities/dx_proxy.dll index 31c9c73b..3f073157 100644 Binary files a/sp/src/dx9sdk/utilities/dx_proxy.dll and b/sp/src/dx9sdk/utilities/dx_proxy.dll differ diff --git a/sp/src/game/client/c_baseanimating.cpp b/sp/src/game/client/c_baseanimating.cpp index c71d2682..c7cc08b4 100644 --- a/sp/src/game/client/c_baseanimating.cpp +++ b/sp/src/game/client/c_baseanimating.cpp @@ -1013,7 +1013,9 @@ CStudioHdr *C_BaseAnimating::OnNewModel() { // XXX what's authoritative? the model pointer or the model index? what a mess. nNewIndex = modelinfo->GetModelIndex( modelinfo->GetModelName( GetModel() ) ); - Assert( modelinfo->GetModel( nNewIndex ) == GetModel() ); + Assert( nNewIndex < 0 || modelinfo->GetModel( nNewIndex ) == GetModel() ); + if ( nNewIndex < 0 ) + nNewIndex = m_nModelIndex; } m_AutoRefModelIndex = nNewIndex; @@ -5099,7 +5101,7 @@ void C_BaseAnimating::StudioFrameAdvance() SetCycle( flNewCycle ); - m_flGroundSpeed = GetSequenceGroundSpeed( hdr, GetSequence() ); + m_flGroundSpeed = GetSequenceGroundSpeed( hdr, GetSequence() ) * GetModelScale(); #if 0 // I didn't have a test case for this, but it seems like the right thing to do. Check multi-player! @@ -5289,7 +5291,7 @@ void C_BaseAnimating::ResetSequenceInfo( void ) } CStudioHdr *pStudioHdr = GetModelPtr(); - m_flGroundSpeed = GetSequenceGroundSpeed( pStudioHdr, GetSequence() ); + m_flGroundSpeed = GetSequenceGroundSpeed( pStudioHdr, GetSequence() ) * GetModelScale(); m_bSequenceLoops = ((GetSequenceFlags( pStudioHdr, GetSequence() ) & STUDIO_LOOPING) != 0); // m_flAnimTime = gpGlobals->time; m_flPlaybackRate = 1.0; diff --git a/sp/src/game/client/c_baseentity.cpp b/sp/src/game/client/c_baseentity.cpp index 0b09309a..8f40d7ef 100644 --- a/sp/src/game/client/c_baseentity.cpp +++ b/sp/src/game/client/c_baseentity.cpp @@ -894,7 +894,12 @@ C_BaseEntity::C_BaseEntity() : { AddVar( &m_vecOrigin, &m_iv_vecOrigin, LATCH_SIMULATION_VAR ); AddVar( &m_angRotation, &m_iv_angRotation, LATCH_SIMULATION_VAR ); - AddVar( &m_vecVelocity, &m_iv_vecVelocity, LATCH_SIMULATION_VAR ); + // Removing this until we figure out why velocity introduces view hitching. + // One possible fix is removing the player->ResetLatched() call in CGameMovement::FinishDuck(), + // but that re-introduces a third-person hitching bug. One possible cause is the abrupt change + // in player size/position that occurs when ducking, and how prediction tries to work through that. + // + // AddVar( &m_vecVelocity, &m_iv_vecVelocity, LATCH_SIMULATION_VAR ); m_DataChangeEventRef = -1; m_EntClientFlags = 0; diff --git a/sp/src/game/client/c_baseflex.cpp b/sp/src/game/client/c_baseflex.cpp index 0a5db8e5..6146b2dd 100644 --- a/sp/src/game/client/c_baseflex.cpp +++ b/sp/src/game/client/c_baseflex.cpp @@ -1158,6 +1158,33 @@ void C_BaseFlex::SetupWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightC } +//----------------------------------------------------------------------------- +// Purpose: Use the local bone positions to set flex control weights +// via boneflexdrivers specified in the model +//----------------------------------------------------------------------------- +void C_BaseFlex::BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed ) +{ + const int nBoneFlexDriverCount = pStudioHdr->BoneFlexDriverCount(); + + for ( int i = 0; i < nBoneFlexDriverCount; ++i ) + { + const mstudioboneflexdriver_t *pBoneFlexDriver = pStudioHdr->BoneFlexDriver( i ); + const Vector &position = pos[ pBoneFlexDriver->m_nBoneIndex ]; + + const int nControllerCount = pBoneFlexDriver->m_nControlCount; + for ( int j = 0; j < nControllerCount; ++j ) + { + const mstudioboneflexdrivercontrol_t *pController = pBoneFlexDriver->pBoneFlexDriverControl( j ); + Assert( pController->m_nFlexControllerIndex >= 0 && pController->m_nFlexControllerIndex < pStudioHdr->numflexcontrollers() ); + Assert( pController->m_nBoneComponent >= 0 && pController->m_nBoneComponent <= 2 ); + SetFlexWeight( static_cast< LocalFlexController_t >( pController->m_nFlexControllerIndex ), RemapValClamped( position[pController->m_nBoneComponent], pController->m_flMin, pController->m_flMax, 0.0f, 1.0f ) ); + } + } + + BaseClass::BuildTransformations( pStudioHdr, pos, q, cameraTransform, boneMask, boneComputed ); +} + + //----------------------------------------------------------------------------- // Purpose: process the entities networked state, vcd playback, wav file visemes, and blinks into a global shared flex controller array //----------------------------------------------------------------------------- diff --git a/sp/src/game/client/c_baseflex.h b/sp/src/game/client/c_baseflex.h index f99061d1..71cee3d8 100644 --- a/sp/src/game/client/c_baseflex.h +++ b/sp/src/game/client/c_baseflex.h @@ -147,6 +147,7 @@ public: virtual void OnThreadedDrawSetup(); // model specific + virtual void BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed ); static void LinkToGlobalFlexControllers( CStudioHdr *hdr ); virtual void SetupWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightCount, float *pFlexWeights, float *pFlexDelayedWeights ); virtual bool SetupGlobalWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightCount, float *pFlexWeights, float *pFlexDelayedWeights ); diff --git a/sp/src/game/client/c_baseplayer.cpp b/sp/src/game/client/c_baseplayer.cpp index 3b1ac003..942f7a37 100644 --- a/sp/src/game/client/c_baseplayer.cpp +++ b/sp/src/game/client/c_baseplayer.cpp @@ -47,7 +47,7 @@ #include "replay/ienginereplay.h" #endif #include "steam/steam_api.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #include "client_virtualreality.h" #if defined USES_ECON_ITEMS @@ -115,6 +115,13 @@ static ConVar cl_first_person_uses_world_model ( "cl_first_person_uses_world_mod ConVar demo_fov_override( "demo_fov_override", "0", FCVAR_CLIENTDLL | FCVAR_DONTRECORD, "If nonzero, this value will be used to override FOV during demo playback." ); +// This only needs to be approximate - it just controls the distance to the pivot-point of the head ("the neck") of the in-game character, not the player's real-world neck length. +// Ideally we would find this vector by subtracting the neutral-pose difference between the head bone (the pivot point) and the "eyes" attachment point. +// However, some characters don't have this attachment point, and finding the neutral pose is a pain. +// This value is found by hand, and a good value depends more on the in-game models than on actual human shapes. +ConVar cl_meathook_neck_pivot_ingame_up( "cl_meathook_neck_pivot_ingame_up", "7.0" ); +ConVar cl_meathook_neck_pivot_ingame_fwd( "cl_meathook_neck_pivot_ingame_fwd", "3.0" ); + void RecvProxy_LocalVelocityX( const CRecvProxyData *pData, void *pStruct, void *pOut ); void RecvProxy_LocalVelocityY( const CRecvProxyData *pData, void *pStruct, void *pOut ); void RecvProxy_LocalVelocityZ( const CRecvProxyData *pData, void *pStruct, void *pOut ); @@ -429,6 +436,8 @@ C_BasePlayer::C_BasePlayer() : m_iv_vecViewOffset( "C_BasePlayer::m_iv_vecViewOf m_bFiredWeapon = false; m_nForceVisionFilterFlags = 0; + + ListenForGameEvent( "base_player_teleported" ); } //----------------------------------------------------------------------------- @@ -698,6 +707,20 @@ surfacedata_t* C_BasePlayer::GetGroundSurface() return physprops->GetSurfaceData( trace.surface.surfaceProps ); } +void C_BasePlayer::FireGameEvent( IGameEvent *event ) +{ + if ( FStrEq( event->GetName(), "base_player_teleported" ) ) + { + const int index = event->GetInt( "entindex" ); + if ( index == entindex() && IsLocalPlayer() ) + { + // In VR, we want to make sure our head and body + // are aligned after we teleport. + g_ClientVirtualReality.AlignTorsoAndViewToWeapon(); + } + } + +} //----------------------------------------------------------------------------- // returns the player name @@ -1851,11 +1874,9 @@ void C_BasePlayer::ThirdPersonSwitch( bool bThirdperson ) { return !input->CAM_IsThirdPerson() && ( !ToolsEnabled() || !ToolFramework_IsThirdPersonCamera() ); } - else - { - // Not looking at the local player, e.g. in a replay in third person mode or freelook. - return false; - } + + // Not looking at the local player, e.g. in a replay in third person mode or freelook. + return false; } //----------------------------------------------------------------------------- @@ -1867,11 +1888,9 @@ void C_BasePlayer::ThirdPersonSwitch( bool bThirdperson ) { return !LocalPlayerInFirstPersonView() || cl_first_person_uses_world_model.GetBool(); } - else - { - static ConVarRef vr_first_person_uses_world_model( "vr_first_person_uses_world_model" ); - return !LocalPlayerInFirstPersonView() || vr_first_person_uses_world_model.GetBool(); - } + + static ConVarRef vr_first_person_uses_world_model( "vr_first_person_uses_world_model" ); + return !LocalPlayerInFirstPersonView() || vr_first_person_uses_world_model.GetBool(); } @@ -1995,6 +2014,16 @@ void C_BasePlayer::PostThink( void ) if ( IsAlive()) { + // Need to do this on the client to avoid prediction errors + if ( GetFlags() & FL_DUCKING ) + { + SetCollisionBounds( VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX ); + } + else + { + SetCollisionBounds( VEC_HULL_MIN, VEC_HULL_MAX ); + } + if ( !CommentaryModeShouldSwallowInput( this ) ) { // do weapon stuff @@ -2850,7 +2879,13 @@ void C_BasePlayer::BuildFirstPersonMeathookTransformations( CStudioHdr *hdr, Vec m_BoneAccessor.SetWritableBones( BONE_USED_BY_ANYTHING ); - matrix3x4_t &mHeadTransform = GetBoneForWrite( LookupBone( pchHeadBoneName ) ); + int iHead = LookupBone( pchHeadBoneName ); + if ( iHead == -1 ) + { + return; + } + + matrix3x4_t &mHeadTransform = GetBoneForWrite( iHead ); // "up" on the head bone is along the negative Y axis - not sure why. //Vector vHeadTransformUp ( -mHeadTransform[0][1], -mHeadTransform[1][1], -mHeadTransform[2][1] ); @@ -2862,29 +2897,19 @@ void C_BasePlayer::BuildFirstPersonMeathookTransformations( CStudioHdr *hdr, Vec // We can't move this with animations or effects without causing nausea, so we need to move // the whole body so that the animated head is in the right place to match the player-controlled head. Vector vHeadUp; - bool bMeathookEnable = true; Vector vRealPivotPoint; - bool bEnableDecapitation = true; if( UseVR() ) { - static ConVarRef vr_neck_pivot_ingame_up( "vr_neck_pivot_ingame_up" ); - static ConVarRef vr_neck_pivot_ingame_fwd( "vr_neck_pivot_ingame_fwd" ); - static ConVarRef vr_meathook_enable ( "vr_meathook_enable" ); - static ConVarRef vr_decapitation_enable ( "vr_decapitation_enable" ); - VMatrix mWorldFromMideye = g_ClientVirtualReality.GetWorldFromMidEye(); - bMeathookEnable = vr_meathook_enable.GetBool(); - bEnableDecapitation = vr_decapitation_enable.GetBool(); - // What we do here is: // * Take the required eye pos+orn - the actual pose the player is controlling with the HMD. - // * Go downwards in that space by headtrack_neck_pivot_ingame_* - this is now the neck-pivot in the game world of where the player is actually looking. + // * Go downwards in that space by cl_meathook_neck_pivot_ingame_* - this is now the neck-pivot in the game world of where the player is actually looking. // * Now place the body of the animated character so that the head bone is at that position. // The head bone is the neck pivot point of the in-game character. Vector vRealMidEyePos = mWorldFromMideye.GetTranslation(); - vRealPivotPoint = vRealMidEyePos - ( mWorldFromMideye.GetUp() * vr_neck_pivot_ingame_up.GetFloat() ) - ( mWorldFromMideye.GetForward() * vr_neck_pivot_ingame_fwd.GetFloat() ); + vRealPivotPoint = vRealMidEyePos - ( mWorldFromMideye.GetUp() * cl_meathook_neck_pivot_ingame_up.GetFloat() ) - ( mWorldFromMideye.GetForward() * cl_meathook_neck_pivot_ingame_fwd.GetFloat() ); } else { @@ -2892,55 +2917,48 @@ void C_BasePlayer::BuildFirstPersonMeathookTransformations( CStudioHdr *hdr, Vec Vector vForward, vRight, vUp; AngleVectors( MainViewAngles(), &vForward, &vRight, &vUp ); - vRealPivotPoint = MainViewOrigin() - ( vUp * 7.3f ) - ( vForward * 3.f ); + vRealPivotPoint = MainViewOrigin() - ( vUp * cl_meathook_neck_pivot_ingame_up.GetFloat() ) - ( vForward * cl_meathook_neck_pivot_ingame_fwd.GetFloat() ); } Vector vDeltaToAdd = vRealPivotPoint - vHeadTransformTranslation; - if ( bMeathookEnable ) + // Now add this offset to the entire skeleton. + for (int i = 0; i < hdr->numbones(); i++) { - // Now add this offset to the entire skeleton. - for (int i = 0; i < hdr->numbones(); i++) + // Only update bones reference by the bone mask. + if ( !( hdr->boneFlags( i ) & boneMask ) ) { - // Only update bones reference by the bone mask. - if ( !( hdr->boneFlags( i ) & boneMask ) ) - { - continue; - } - matrix3x4_t& bone = GetBoneForWrite( i ); - Vector vBonePos; - MatrixGetTranslation ( bone, vBonePos ); - vBonePos += vDeltaToAdd; - MatrixSetTranslation ( vBonePos, bone ); + continue; } + matrix3x4_t& bone = GetBoneForWrite( i ); + Vector vBonePos; + MatrixGetTranslation ( bone, vBonePos ); + vBonePos += vDeltaToAdd; + MatrixSetTranslation ( vBonePos, bone ); } - if ( bEnableDecapitation ) + // Then scale the head to zero, but leave its position - forms a "neck stub". + // This prevents us rendering junk all over the screen, e.g. inside of mouth, etc. + MatrixScaleByZero( mHeadTransform ); + + // TODO: right now we nuke the hats by shrinking them to nothing, + // but it feels like we should do something more sensible. + // For example, for one sniper taunt he takes his hat off and waves it - would be nice to see it then. + int iHelm = LookupBone( "prp_helmet" ); + if ( iHelm != -1 ) { - // Then scale the head to zero, but leave its position - forms a "neck stub". - // This prevents us rendering junk all over the screen, e.g. inside of mouth, etc. - MatrixScaleByZero ( mHeadTransform ); - - // TODO: right now we nuke the hats by shrinking them to nothing, - // but it feels like we should do something more sensible. - // For example, for one sniper taunt he takes his hat off and waves it - would be nice to see it then. - int iHelm = LookupBone( "prp_helmet" ); - if ( iHelm != -1 ) - { - // Scale the helmet. - matrix3x4_t &transformhelmet = GetBoneForWrite( iHelm ); - MatrixScaleByZero ( transformhelmet ); - } - - iHelm = LookupBone( "prp_hat" ); - if ( iHelm != -1 ) - { - matrix3x4_t &transformhelmet = GetBoneForWrite( iHelm ); - MatrixScaleByZero ( transformhelmet ); - } + // Scale the helmet. + matrix3x4_t &transformhelmet = GetBoneForWrite( iHelm ); + MatrixScaleByZero( transformhelmet ); } + iHelm = LookupBone( "prp_hat" ); + if ( iHelm != -1 ) + { + matrix3x4_t &transformhelmet = GetBoneForWrite( iHelm ); + MatrixScaleByZero( transformhelmet ); + } } diff --git a/sp/src/game/client/c_baseplayer.h b/sp/src/game/client/c_baseplayer.h index 45c282bf..9d3657bf 100644 --- a/sp/src/game/client/c_baseplayer.h +++ b/sp/src/game/client/c_baseplayer.h @@ -23,6 +23,8 @@ #include "hintsystem.h" #include "SoundEmitterSystem/isoundemittersystembase.h" #include "c_env_fog_controller.h" +#include "igameevents.h" +#include "GameEventListener.h" #if defined USES_ECON_ITEMS #include "econ_item.h" @@ -66,7 +68,7 @@ bool IsInFreezeCam( void ); //----------------------------------------------------------------------------- // Purpose: Base Player class //----------------------------------------------------------------------------- -class C_BasePlayer : public C_BaseCombatCharacter +class C_BasePlayer : public C_BaseCombatCharacter, public CGameEventListener { public: DECLARE_CLASS( C_BasePlayer, C_BaseCombatCharacter ); @@ -467,6 +469,8 @@ protected: // used by client side player footsteps surfacedata_t* GetGroundSurface(); + virtual void FireGameEvent( IGameEvent *event ); + protected: // Did we just enter a vehicle this frame? bool JustEnteredVehicle(); diff --git a/sp/src/game/client/c_pixel_visibility.cpp b/sp/src/game/client/c_pixel_visibility.cpp index e379c856..8ff507b1 100644 --- a/sp/src/game/client/c_pixel_visibility.cpp +++ b/sp/src/game/client/c_pixel_visibility.cpp @@ -16,7 +16,7 @@ #include "utlmultilist.h" #include "vprof.h" #include "icommandline.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" static void PixelvisDrawChanged( IConVar *pPixelvisVar, const char *pOld, float flOldValue ); diff --git a/sp/src/game/client/c_prop_vehicle.cpp b/sp/src/game/client/c_prop_vehicle.cpp index 74dbf7f1..d093656f 100644 --- a/sp/src/game/client/c_prop_vehicle.cpp +++ b/sp/src/game/client/c_prop_vehicle.cpp @@ -18,7 +18,7 @@ #include "vgui/ISurface.h" #include "client_virtualreality.h" #include "../hud_crosshair.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" // NVNT haptic utils #include "haptics/haptic_utils.h" diff --git a/sp/src/game/client/cdll_client_int.cpp b/sp/src/game/client/cdll_client_int.cpp index 0f40f2d3..b5a53e72 100644 --- a/sp/src/game/client/cdll_client_int.cpp +++ b/sp/src/game/client/cdll_client_int.cpp @@ -121,7 +121,7 @@ #include "clientsteamcontext.h" #include "renamed_recvtable_compat.h" #include "mouthinfo.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #include "client_virtualreality.h" #include "mumble.h" @@ -148,7 +148,6 @@ #endif extern vgui::IInputInternal *g_InputInternal; -const char *COM_GetModDirectory(); // return the mod dir (rather than the complete -game param, which can be a path) //============================================================================= // HPE_BEGIN @@ -332,6 +331,11 @@ static ConVar s_CV_ShowParticleCounts("showparticlecounts", "0", 0, "Display num static ConVar s_cl_team("cl_team", "default", FCVAR_USERINFO|FCVAR_ARCHIVE, "Default team when joining a game"); static ConVar s_cl_class("cl_class", "default", FCVAR_USERINFO|FCVAR_ARCHIVE, "Default class when joining a game"); +#ifdef HL1MP_CLIENT_DLL +static ConVar s_cl_load_hl1_content("cl_load_hl1_content", "0", FCVAR_ARCHIVE, "Mount the content from Half-Life: Source if possible"); +#endif + + // Physics system bool g_bLevelInitialized; bool g_bTextMode = false; @@ -943,7 +947,7 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi InitFbx(); #endif - // it's ok if this is NULL. That just means the headtrack.dll wasn't found + // it's ok if this is NULL. That just means the sourcevr.dll wasn't found g_pSourceVR = (ISourceVirtualReality *)appSystemFactory(SOURCE_VIRTUAL_REALITY_INTERFACE_VERSION, NULL); factorylist_t factories; @@ -977,17 +981,6 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi g_pcv_ThreadMode = g_pCVar->FindVar( "host_thread_mode" ); - // If we are in VR mode do some initial setup work - if( UseVR() ) - { - int nViewportWidth, nViewportHeight; - - g_pSourceVR->GetViewportBounds( ISourceVirtualReality::VREye_Left, NULL, NULL, &nViewportWidth, &nViewportHeight ); - vgui::surface()->SetFullscreenViewport( 0, 0, nViewportWidth, nViewportHeight ); - - vgui::ivgui()->SetVRMode( true ); - } - if (!Initializer::InitializeAllObjects()) return false; @@ -1091,6 +1084,7 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi #ifndef _X360 HookHapticMessages(); // Always hook the messages #endif + return true; } @@ -1141,29 +1135,23 @@ void CHLClient::PostInit() g_pSixenseInput->PostInit(); #endif - // If we are in VR mode execute headtrack.cfg in PostInit so all the convars will - // already be set up - if( UseVR() ) + g_ClientVirtualReality.StartupComplete(); + +#ifdef HL1MP_CLIENT_DLL + if ( s_cl_load_hl1_content.GetBool() && steamapicontext && steamapicontext->SteamApps() ) { - // general all-game stuff - engine->ExecuteClientCmd( "exec headtrack\\headtrack.cfg" ); + char szPath[ MAX_PATH*2 ]; + int ccFolder= steamapicontext->SteamApps()->GetAppInstallDir( 280, szPath, sizeof(szPath) ); + if ( ccFolder > 0 ) + { + V_AppendSlash( szPath, sizeof(szPath) ); + V_strncat( szPath, "hl1", sizeof( szPath ) ); - // game specific VR config - CUtlString sCmd; - sCmd.Format( "exec headtrack_%s.cfg", COM_GetModDirectory() ); - engine->ExecuteClientCmd( sCmd.Get() ); - - engine->ExecuteClientCmd( "vr_start_tracking" ); - - vgui::surface()->SetSoftwareCursor( true ); -#if defined(POSIX) - ConVarRef m_rawinput( "m_rawinput" ); - m_rawinput.SetValue( 1 ); - - ConVarRef mat_vsync( "mat_vsync" ); - mat_vsync.SetValue( 0 ); -#endif + g_pFullFileSystem->AddSearchPath( szPath, "HL1" ); + g_pFullFileSystem->AddSearchPath( szPath, "GAME" ); + } } +#endif } //----------------------------------------------------------------------------- diff --git a/sp/src/game/client/client_base.vpc b/sp/src/game/client/client_base.vpc index 79a27d5d..52dceb7e 100644 --- a/sp/src/game/client/client_base.vpc +++ b/sp/src/game/client/client_base.vpc @@ -206,6 +206,8 @@ $Project $File "$SRCDIR\game\shared\basegrenade_shared.cpp" $File "$SRCDIR\game\shared\baseparticleentity.cpp" $File "$SRCDIR\game\shared\baseplayer_shared.cpp" + $File "$SRCDIR\game\shared\baseprojectile.cpp" + $File "$SRCDIR\game\shared\baseprojectile.h" $File "$SRCDIR\game\shared\baseviewmodel_shared.cpp" $File "beamdraw.cpp" $File "$SRCDIR\game\shared\beam_shared.cpp" diff --git a/sp/src/game/client/client_virtualreality.cpp b/sp/src/game/client/client_virtualreality.cpp index 1512d7bf..d729210e 100644 --- a/sp/src/game/client/client_virtualreality.cpp +++ b/sp/src/game/client/client_virtualreality.cpp @@ -9,15 +9,21 @@ #include "client_virtualreality.h" #include "materialsystem/itexture.h" +#include "materialsystem/materialsystem_config.h" #include "view_shared.h" +#include "view_scene.h" #include "VGuiMatSurface/IMatSystemSurface.h" #include "vgui_controls/Controls.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #include "ienginevgui.h" #include "cdll_client_int.h" +#include "vgui/IVGui.h" +#include "vgui_controls/Controls.h" #include "tier0/vprof_telemetry.h" #include +const char *COM_GetModDirectory(); // return the mod dir (rather than the complete -game param, which can be a path) + CClientVirtualReality g_ClientVirtualReality; EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CClientVirtualReality, IClientVirtualReality, CLIENTVIRTUALREALITY_INTERFACE_VERSION, g_ClientVirtualReality ); @@ -26,6 +32,9 @@ EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CClientVirtualReality, IClientVirtualReality, // -------------------------------------------------------------------- // A huge pile of VR convars // -------------------------------------------------------------------- +ConVar vr_activate_default( "vr_activate_default", "0", FCVAR_ARCHIVE, "If this is true the game will switch to VR mode once startup is complete." ); + + ConVar vr_moveaim_mode ( "vr_moveaim_mode", "3", FCVAR_ARCHIVE, "0=move+shoot from face. 1=move with torso. 2,3,4=shoot with face+mouse cursor. 5+ are probably not that useful." ); ConVar vr_moveaim_mode_zoom ( "vr_moveaim_mode_zoom", "3", FCVAR_ARCHIVE, "0=move+shoot from face. 1=move with torso. 2,3,4=shoot with face+mouse cursor. 5+ are probably not that useful." ); @@ -54,21 +63,18 @@ ConVar vr_debug_remote_cam_target_z( "vr_debug_remote_cam_target_z", "-50.0" ); ConVar vr_translation_limit( "vr_translation_limit", "10.0", 0, "How far the in-game head will translate before being clamped." ); -ConVar vr_dont_use_calibration_projection ( "vr_dont_use_calibration_projection", "0", 0, "1=use calibrated rotation, but not projection" ); - // HUD config values ConVar vr_render_hud_in_world( "vr_render_hud_in_world", "1" ); ConVar vr_hud_max_fov( "vr_hud_max_fov", "60", FCVAR_ARCHIVE, "Max FOV of the HUD" ); ConVar vr_hud_forward( "vr_hud_forward", "500", FCVAR_ARCHIVE, "Apparent distance of the HUD in inches" ); ConVar vr_hud_display_ratio( "vr_hud_display_ratio", "0.95", FCVAR_ARCHIVE ); +ConVar vr_hud_never_overlay( "vr_hud_never_overlay", "0" ); ConVar vr_hud_axis_lock_to_world( "vr_hud_axis_lock_to_world", "0", FCVAR_ARCHIVE, "Bitfield - locks HUD axes to the world - 0=pitch, 1=yaw, 2=roll" ); // Default distance clips through rocketlauncher, heavy's body, etc. ConVar vr_projection_znear_multiplier( "vr_projection_znear_multiplier", "0.3", 0, "Allows moving the ZNear plane to deal with body clipping" ); -ConVar vr_stat_sample_period ( "vr_stat_sample_period", "1", 0, "Frequency with which to sample motion stats" ); - // Should the viewmodel (weapon) translate with the HMD, or remain fixed to the in-world body (but still rotate with the head)? Purely a graphics effect - no effect on actual bullet aiming. // Has no effect in aim modes where aiming is not controlled by the head. ConVar vr_viewmodel_translate_with_head ( "vr_viewmodel_translate_with_head", "0", 0, "1=translate the viewmodel with the head motion." ); @@ -80,16 +86,9 @@ ConVar vr_zoom_scope_scale ( "vr_zoom_scope_scale", "6.0", 0, "Something to do w ConVar vr_viewmodel_offset_forward( "vr_viewmodel_offset_forward", "-8", 0 ); ConVar vr_viewmodel_offset_forward_large( "vr_viewmodel_offset_forward_large", "-15", 0 ); -ConVar vr_ipdtest_left_t ( "vr_ipdtest_left_t", "260", FCVAR_ARCHIVE ); -ConVar vr_ipdtest_left_b ( "vr_ipdtest_left_b", "530", FCVAR_ARCHIVE ); -ConVar vr_ipdtest_left_i ( "vr_ipdtest_left_i", "550", FCVAR_ARCHIVE ); -ConVar vr_ipdtest_left_o ( "vr_ipdtest_left_o", "200", FCVAR_ARCHIVE ); -ConVar vr_ipdtest_right_t ( "vr_ipdtest_right_t", "260", FCVAR_ARCHIVE ); -ConVar vr_ipdtest_right_b ( "vr_ipdtest_right_b", "530", FCVAR_ARCHIVE ); -ConVar vr_ipdtest_right_i ( "vr_ipdtest_right_i", "550", FCVAR_ARCHIVE ); -ConVar vr_ipdtest_right_o ( "vr_ipdtest_right_o", "200", FCVAR_ARCHIVE ); - +ConVar vr_force_windowed ( "vr_force_windowed", "0", FCVAR_ARCHIVE ); +ConVar vr_first_person_uses_world_model ( "vr_first_person_uses_world_model", "1", 0, "Causes the third person model to be drawn instead of the view model" ); // -------------------------------------------------------------------- // Purpose: Cycle through the aim & move modes. @@ -122,6 +121,32 @@ void CC_VR_Cycle_Aim_Move_Mode ( const CCommand& args ) static ConCommand vr_cycle_aim_move_mode("vr_cycle_aim_move_mode", CC_VR_Cycle_Aim_Move_Mode, "Cycle through the aim & move modes." ); +// -------------------------------------------------------------------- +// Purpose: Switch to/from VR mode. +// -------------------------------------------------------------------- +CON_COMMAND( vr_activate, "Switch to VR mode" ) +{ + g_ClientVirtualReality.Activate(); +} +CON_COMMAND( vr_deactivate, "Switch from VR mode to normal mode" ) +{ + g_ClientVirtualReality.Deactivate(); +} +CON_COMMAND( vr_toggle, "Toggles VR mode" ) +{ + if( g_pSourceVR ) + { + if( g_pSourceVR->ShouldRunInVR() ) + g_ClientVirtualReality.Deactivate(); + else + g_ClientVirtualReality.Activate(); + } + else + { + Msg( "VR Mode is not enabled.\n" ); + } +} + // -------------------------------------------------------------------- // Purpose: Returns true if the matrix is orthonormal @@ -235,11 +260,9 @@ CClientVirtualReality::CClientVirtualReality() m_rtLastMotionSample = 0; m_bMotionUpdated = false; - m_bIpdTestEnabled = false; - - // Needs to be after the tracker has initted. - m_bIpdTestEnabled = false; - m_IpdTestControl = 0; +#if defined( USE_SDL ) + m_nNonVRSDLDisplayIndex = 0; +#endif } CClientVirtualReality::~CClientVirtualReality() @@ -378,8 +401,8 @@ void CClientVirtualReality::DrawMainMenu() viewEye[STEREO_EYE_RIGHT].y = rightY; viewEye[STEREO_EYE_RIGHT].m_eStereoEye = STEREO_EYE_RIGHT; - // let headtrack.dll tell us where to put the cameras - ProcessCurrentTrackingState( 75.f ); + // let sourcevr.dll tell us where to put the cameras + ProcessCurrentTrackingState( 0 ); Vector vViewModelOrigin; QAngle qViewModelAngles; OverrideView( &viewEye[ STEREO_EYE_MONO ] , &vViewModelOrigin, &qViewModelAngles, HMM_NOOVERRIDE ); @@ -388,23 +411,22 @@ void CClientVirtualReality::DrawMainMenu() // render both eyes for( int nView = STEREO_EYE_LEFT; nView <= STEREO_EYE_RIGHT; nView++ ) { - // clear happens here probably - render->Push3DView( viewEye[nView], VIEW_CLEAR_DEPTH|VIEW_CLEAR_COLOR, NULL, NULL ); - - RenderHUDQuad( true, false ); + CMatRenderContextPtr pRenderContext( materials ); + PIXEvent pixEvent( pRenderContext, nView == STEREO_EYE_LEFT ? "left eye" : "right eye" ); + ITexture *pColor = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(nView-1), ISourceVirtualReality::RT_Color ); + ITexture *pDepth = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(nView-1), ISourceVirtualReality::RT_Depth ); + render->Push3DView( viewEye[nView], VIEW_CLEAR_DEPTH|VIEW_CLEAR_COLOR, pColor, NULL, pDepth ); + RenderHUDQuad( false, false ); render->PopView( NULL ); + + PostProcessFrame( (StereoEye_t)nView ); + + OverlayHUDQuadWithUndistort( viewEye[nView], true, true, false ); } - - vrect_t rect; - rect.x = rect.y = 0; - rect.width = leftW*2; - rect.height = leftH; - PostProcessFrame( &rect ); } - // -------------------------------------------------------------------- // Purpose: // Offset the incoming view appropriately. @@ -449,8 +471,7 @@ bool CClientVirtualReality::OverrideView ( CViewSetup *pViewMiddle, Vector *pVie QAngle torsoAngles = m_PlayerTorsoAngle; VMatrix worldFromTorso; - AngleMatrix ( torsoAngles, worldFromTorso.As3x4() ); - worldFromTorso.SetTranslation ( m_PlayerTorsoOrigin ); + worldFromTorso.SetupMatrixOrgAngles( m_PlayerTorsoOrigin, torsoAngles ); //// Scale translation e.g. to allow big in-game leans with only a small head movement. //// Clamp HMD movement to a reasonable amount to avoid wallhacks, vis problems, etc. @@ -484,16 +505,14 @@ bool CClientVirtualReality::OverrideView ( CViewSetup *pViewMiddle, Vector *pVie // Aim point is independent of view - leave it as it was, just copy it into m_WorldFromWeapon for our use. m_TorsoFromMideye = matMideyeZeroFromMideyeCurrent; m_WorldFromMidEye = worldFromTorso * matMideyeZeroFromMideyeCurrent; - AngleMatrix ( originalMiddleAngles, m_WorldFromWeapon.As3x4() ); - m_WorldFromWeapon.SetTranslation ( originalMiddleOrigin ); + m_WorldFromWeapon.SetupMatrixOrgAngles( originalMiddleOrigin, originalMiddleAngles ); break; case HMM_SHOOTMOVELOOKMOUSE: // HMD is ignored completely, mouse does everything. m_PlayerTorsoAngle = originalMiddleAngles; - AngleMatrix ( originalMiddleAngles, worldFromTorso.As3x4() ); - worldFromTorso.SetTranslation ( m_PlayerTorsoOrigin ); + worldFromTorso.SetupMatrixOrgAngles( m_PlayerTorsoOrigin, originalMiddleAngles ); m_TorsoFromMideye.Identity(); m_WorldFromMidEye = worldFromTorso; @@ -535,9 +554,8 @@ bool CClientVirtualReality::OverrideView ( CViewSetup *pViewMiddle, Vector *pVie Vector vView = vLookat - vOffset; VectorAngles ( vView, m_WorldFromMidEye.GetUp(), pViewMiddle->angles ); - AngleMatrix ( pViewMiddle->angles, m_WorldFromMidEye.As3x4() ); + m_WorldFromMidEye.SetupMatrixOrgAngles( pViewMiddle->origin, pViewMiddle->angles ); - m_WorldFromMidEye.SetTranslation ( pViewMiddle->origin ); m_TorsoFromMideye.Identity(); } @@ -584,47 +602,19 @@ bool CClientVirtualReality::OverrideStereoView( CViewSetup *pViewMiddle, CViewSe return false; } - if ( vr_stereo_swap_eyes.GetBool() ) - { - // Windows likes to randomly rename display numbers which causes eye-swaps, so this tries to cope with that. - CViewSetup *pViewTemp = pViewLeft; - pViewLeft = pViewRight; - pViewRight = pViewTemp; - } + VMatrix matOffsetLeft = g_pSourceVR->GetMidEyeFromEye( ISourceVirtualReality::VREye_Left ); + VMatrix matOffsetRight = g_pSourceVR->GetMidEyeFromEye( ISourceVirtualReality::VREye_Right ); - // Move eyes to calibrated positions. - VMatrix worldFromLeftEye = m_WorldFromMidEye * g_pSourceVR->GetMidEyeFromLeft(); - VMatrix worldFromRightEye = m_WorldFromMidEye * g_pSourceVR->GetMidEyeFromRight(); - - Assert ( IsOrthonormal ( worldFromLeftEye, 0.001f ) ); - Assert ( IsOrthonormal ( worldFromRightEye, 0.001f ) ); - - Vector rightFromLeft = worldFromRightEye.GetTranslation() - worldFromLeftEye.GetTranslation(); - //float calibratedIPD = rightFromLeft.Length(); // THIS IS NOT CORRECT. The positions of the virtual cameras do have any real physical "meaning" with the way we currently calibrate. - float calibratedIPD = g_pSourceVR->GetDisplaySeparationMM() / 25.4f; - - // Scale the eyes closer/further to fit the desired IPD. - // (the calibrated distance is the IPD of whoever calibrated it!) - float desiredIPD = g_pSourceVR->GetUserIPDMM() / 25.4f; - if ( calibratedIPD < 0.000001f ) - { - // No HMD, or a monocular HMD. - } - else - { - float scale = 0.5f * ( desiredIPD - calibratedIPD ) / calibratedIPD; - worldFromLeftEye.SetTranslation ( worldFromLeftEye.GetTranslation() - ( scale * rightFromLeft ) ); - worldFromRightEye.SetTranslation ( worldFromRightEye.GetTranslation() + ( scale * rightFromLeft ) ); - } + // Move eyes to IPD positions. + VMatrix worldFromLeftEye = m_WorldFromMidEye * matOffsetLeft; + VMatrix worldFromRightEye = m_WorldFromMidEye * matOffsetRight; Assert ( IsOrthonormal ( worldFromLeftEye, 0.001f ) ); Assert ( IsOrthonormal ( worldFromRightEye, 0.001f ) ); // Finally convert back to origin+angles. - pViewLeft->origin = worldFromLeftEye.GetTranslation(); - VectorAngles ( worldFromLeftEye.GetForward(), worldFromLeftEye.GetUp(), pViewLeft->angles ); - pViewRight->origin = worldFromRightEye.GetTranslation(); - VectorAngles ( worldFromRightEye.GetForward(), worldFromRightEye.GetUp(), pViewRight->angles ); + MatrixAngles( worldFromLeftEye.As3x4(), pViewLeft->angles, pViewLeft->origin ); + MatrixAngles( worldFromRightEye.As3x4(), pViewRight->angles, pViewRight->origin ); // Find the projection matrices. @@ -645,13 +635,6 @@ bool CClientVirtualReality::OverrideStereoView( CViewSetup *pViewMiddle, CViewSe } } - if ( vr_dont_use_calibration_projection.GetBool() ) - { - pViewLeft ->m_bViewToProjectionOverride = false; - pViewRight ->m_bViewToProjectionOverride = false; - pViewMiddle->m_bViewToProjectionOverride = false; - } - switch ( vr_stereo_mono_set_eye.GetInt() ) { case 0: @@ -683,6 +666,17 @@ bool CClientVirtualReality::OverrideStereoView( CViewSetup *pViewMiddle, CViewSe CalcFovFromProjection ( &(pViewRight ->fov), pViewRight ->m_ViewToProjection ); CalcFovFromProjection ( &(pViewMiddle->fov), pViewMiddle->m_ViewToProjection ); + // if we don't know the HUD FOV, figure that out now + if( m_fHudHorizontalFov == 0.f ) + { + // Figure out the current HUD FOV. + m_fHudHorizontalFov = pViewLeft->fov * vr_hud_display_ratio.GetFloat(); + if( m_fHudHorizontalFov > vr_hud_max_fov.GetFloat() ) + { + m_fHudHorizontalFov = vr_hud_max_fov.GetFloat(); + } + } + // remember the view angles so we can limit the weapon to something near those m_PlayerViewAngle = pViewMiddle->angles; m_PlayerViewOrigin = pViewMiddle->origin; @@ -701,7 +695,6 @@ bool CClientVirtualReality::OverrideStereoView( CViewSetup *pViewMiddle, CViewSe m_fHudHalfHeight = tan( DEG2RAD( fVFOV * 0.5f ) ) * fHudForward * m_WorldZoomScale; QAngle HudAngles; - VMatrix HudUpCorrection; switch ( m_hmmMovementActual ) { case HMM_SHOOTFACE_MOVETORSO: @@ -709,7 +702,6 @@ bool CClientVirtualReality::OverrideStereoView( CViewSetup *pViewMiddle, CViewSe // This helps keep you oriented about where "forwards" is, which is otherwise surprisingly tricky! // TODO: try preserving roll and/or pitch from the view? HudAngles = m_PlayerTorsoAngle; - HudUpCorrection.Identity(); break; case HMM_SHOOTFACE_MOVEFACE: case HMM_SHOOTMOUSE_MOVEFACE: @@ -720,7 +712,6 @@ bool CClientVirtualReality::OverrideStereoView( CViewSetup *pViewMiddle, CViewSe case HMM_SHOOTBOUNDEDMOUSE_LOOKFACE_MOVEMOUSE: // Put the HUD in front of wherever the player is looking. HudAngles = m_PlayerViewAngle; - HudUpCorrection = g_pSourceVR->GetHudUpCorrection(); break; default: Assert ( false ); break; } @@ -742,9 +733,7 @@ bool CClientVirtualReality::OverrideStereoView( CViewSetup *pViewMiddle, CViewSe MatrixAngles( m_WorldFromWeapon.As3x4(), aimAngles ); HudAngles[YAW] = aimAngles[YAW]; } - AngleMatrix ( HudAngles, m_WorldFromHud.As3x4() ); - m_WorldFromHud.SetTranslation ( m_PlayerViewOrigin ); - m_WorldFromHud = m_WorldFromHud * HudUpCorrection; + m_WorldFromHud.SetupMatrixOrgAngles( m_PlayerViewOrigin, HudAngles ); // Remember in source X forwards, Y left, Z up. // We need to transform to a more conventional X right, Y up, Z backwards before doing the projection. @@ -806,8 +795,8 @@ bool CClientVirtualReality::OverridePlayerMotion( float flInputSampleFrametime, { // Figure out what changes were made to the WEAPON by mouse/joystick/etc VMatrix worldFromOldWeapon, worldFromCurWeapon; - AngleMatrix ( oldAngles, worldFromOldWeapon.As3x4() ); - AngleMatrix ( curAngles, worldFromCurWeapon.As3x4() ); + worldFromOldWeapon.SetupMatrixAngles( oldAngles ); + worldFromCurWeapon.SetupMatrixAngles( curAngles ); // We ignore mouse pitch, the mouse can't do rolls, so it's just yaw changes. if( !m_bOverrideTorsoAngle ) @@ -817,7 +806,7 @@ bool CClientVirtualReality::OverridePlayerMotion( float flInputSampleFrametime, m_PlayerTorsoAngle[PITCH] = 0.0f; } - AngleMatrix ( m_PlayerTorsoAngle, worldFromTorso.As3x4() ); + worldFromTorso.SetupMatrixAngles( m_PlayerTorsoAngle ); // Weapon view = mideye view, so apply that to the torso to find the world view direction. m_WorldFromWeapon = worldFromTorso * m_TorsoFromMideye; @@ -846,10 +835,8 @@ bool CClientVirtualReality::OverridePlayerMotion( float flInputSampleFrametime, } // Let every other system know. - AngleMatrix( *pNewAngles, m_WorldFromWeapon.As3x4() ); - AngleMatrix( m_PlayerTorsoAngle, worldFromTorso.As3x4() ); - // Restore the translation. - m_WorldFromWeapon.SetTranslation ( vWeaponOrigin ); + m_WorldFromWeapon.SetupMatrixOrgAngles( vWeaponOrigin, *pNewAngles ); + worldFromTorso.SetupMatrixAngles( m_PlayerTorsoAngle ); } break; case HMM_SHOOTBOUNDEDMOUSE_LOOKFACE_MOVEFACE: @@ -913,10 +900,8 @@ bool CClientVirtualReality::OverridePlayerMotion( float flInputSampleFrametime, } // Let every other system know. - AngleMatrix( *pNewAngles, m_WorldFromWeapon.As3x4() ); - AngleMatrix( m_PlayerTorsoAngle, worldFromTorso.As3x4() ); - // Restore the translation. - m_WorldFromWeapon.SetTranslation ( vWeaponOrigin ); + m_WorldFromWeapon.SetupMatrixOrgAngles( vWeaponOrigin, *pNewAngles ); + worldFromTorso.SetupMatrixAngles( m_PlayerTorsoAngle ); } break; case HMM_SHOOTMOUSE_MOVEFACE: @@ -942,10 +927,8 @@ bool CClientVirtualReality::OverridePlayerMotion( float flInputSampleFrametime, m_PlayerTorsoAngle[ YAW ] += AngleDiff( curAngles[YAW], oldAngles[YAW] ) /2.f; } - AngleMatrix( *pNewAngles, m_WorldFromWeapon.As3x4() ); - AngleMatrix( m_PlayerTorsoAngle, worldFromTorso.As3x4() ); - // Restore the translation. - m_WorldFromWeapon.SetTranslation ( vWeaponOrigin ); + m_WorldFromWeapon.SetupMatrixOrgAngles( vWeaponOrigin, *pNewAngles ); + worldFromTorso.SetupMatrixAngles( m_PlayerTorsoAngle ); } break; default: Assert ( false ); break; @@ -1007,101 +990,6 @@ bool CClientVirtualReality::OverridePlayerMotion( float flInputSampleFrametime, return true; } - -// -------------------------------------------------------------------- -// Purpose: Collects convar and HMD state once a session -// -------------------------------------------------------------------- -bool CClientVirtualReality::CollectSessionStartStats( KeyValues *pkvStats ) -{ - pkvStats->SetName( "TF2VRSessionDetails" ); - - CUtlString sSerialNumber = g_pSourceVR->GetDisplaySerialNumber(); - if( sSerialNumber.IsValid() && !sSerialNumber.IsEmpty() ) - { - pkvStats->SetString( "SerialNumber", sSerialNumber.Get() ); - } - CUtlString sModelNumber = g_pSourceVR->GetDisplayModelNumber(); - if( sModelNumber.IsValid() && !sModelNumber.IsEmpty() ) - { - pkvStats->SetString( "ModelNumberID", sModelNumber.Get() ); - } - - pkvStats->SetFloat( "vr_separation_user_inches", g_pSourceVR->GetUserIPDMM() / 25.4f ); - //pkvStats->SetFloat( "vr_separation_toein_pixels", vr_separation_toein_pixels.GetFloat() ); - //pkvStats->SetInt( "vr_moveaim_mode", vr_moveaim_mode.GetInt() ); - //pkvStats->SetFloat( "vr_moveaim_reticle_yaw_limit", vr_moveaim_reticle_yaw_limit.GetFloat() ); - //pkvStats->SetFloat( "vr_moveaim_reticle_pitch_limit", vr_moveaim_reticle_pitch_limit.GetFloat() ); - //pkvStats->SetInt( "vr_moveaim_mode_zoom", vr_moveaim_mode_zoom.GetInt() ); - //pkvStats->SetFloat( "vr_moveaim_reticle_yaw_limit_zoom", vr_moveaim_reticle_yaw_limit_zoom.GetFloat() ); - //pkvStats->SetFloat( "vr_moveaim_reticle_pitch_limit_zoom", vr_moveaim_reticle_pitch_limit_zoom.GetFloat() ); - //pkvStats->SetFloat( "vr_hud_max_fov", vr_hud_max_fov.GetFloat() ); - //pkvStats->SetFloat( "vr_hud_forward", vr_hud_forward.GetFloat() ); - //pkvStats->SetFloat( "vr_neckmodel_up", vr_neckmodel_up.GetFloat() ); - //pkvStats->SetFloat( "vr_neckmodel_forwards", vr_neckmodel_forwards.GetFloat() ); - //pkvStats->SetInt( "vr_hud_axis_lock_to_world", vr_hud_axis_lock_to_world.GetInt() ); - - //pkvStats->SetInt( "vr_ipdtest_left_t", vr_ipdtest_left_t.GetInt() ); - //pkvStats->SetInt( "vr_ipdtest_left_b", vr_ipdtest_left_b.GetInt() ); - //pkvStats->SetInt( "vr_ipdtest_left_i", vr_ipdtest_left_i.GetInt() ); - //pkvStats->SetInt( "vr_ipdtest_left_o", vr_ipdtest_left_o.GetInt() ); - //pkvStats->SetInt( "vr_ipdtest_right_t", vr_ipdtest_right_t.GetInt() ); - //pkvStats->SetInt( "vr_ipdtest_right_b", vr_ipdtest_right_b.GetInt() ); - //pkvStats->SetInt( "vr_ipdtest_right_i", vr_ipdtest_right_i.GetInt() ); - //pkvStats->SetInt( "vr_ipdtest_right_o", vr_ipdtest_right_o.GetInt() ); - - return true; -} - - -// -------------------------------------------------------------------- -// Purpose: Collects view stats every so often -// -------------------------------------------------------------------- -bool CClientVirtualReality::CollectPeriodicStats( KeyValues *pkvStats ) -{ - // maybe we haven't even been called to get tracking data - if( !m_bMotionUpdated ) - return false; - m_bMotionUpdated = false; - - uint32 unPeriod = (uint32) vr_stat_sample_period.GetInt(); - if( unPeriod == 0 ) - return false; // periodic stats are turned off - - RTime32 rtCurrent = time(NULL); - if( rtCurrent == m_rtLastMotionSample && ( rtCurrent - m_rtLastMotionSample ) < unPeriod ) - return false; // it isn't time to report yet - - pkvStats->SetName( "TF2VRMotionSample" ); - - pkvStats->SetInt( "SampleTime", rtCurrent ); - - Vector vPos; - QAngle viewAngles; - MatrixAngles( m_WorldFromMidEye.As3x4(), viewAngles, vPos ); - - pkvStats->SetFloat( "LookYaw", viewAngles[YAW] ); - pkvStats->SetFloat( "LookPitch", viewAngles[PITCH] ); - pkvStats->SetFloat( "LookRoll", viewAngles[ROLL] ); - pkvStats->SetFloat( "PositionX", vPos.x ); - pkvStats->SetFloat( "PositionY", vPos.y ); - pkvStats->SetFloat( "PositionZ", vPos.z ); - - pkvStats->SetFloat( "VelocityX", m_PlayerLastMovement.x ); - pkvStats->SetFloat( "VelocityY", m_PlayerLastMovement.y ); - pkvStats->SetFloat( "VelocityZ", m_PlayerLastMovement.z ); - - QAngle aimAngles; - MatrixAngles( m_WorldFromWeapon.As3x4(), aimAngles ); - - pkvStats->SetFloat( "AimYaw", aimAngles[YAW] ); - pkvStats->SetFloat( "AimPitch", aimAngles[PITCH] ); - - m_rtLastMotionSample = rtCurrent; - - return true; -} - - // -------------------------------------------------------------------- // Purpose: Returns true if the world is zoomed // -------------------------------------------------------------------- @@ -1154,6 +1042,19 @@ void CClientVirtualReality::CancelTorsoTransformOverride() } +bool CClientVirtualReality::CanOverlayHudQuad() +{ + bool bCanOverlay = true; + + bCanOverlay = bCanOverlay && vr_render_hud_in_world.GetBool(); + bCanOverlay = bCanOverlay && ( ! vr_hud_never_overlay.GetBool() ); + bCanOverlay = bCanOverlay && ( vr_hud_axis_lock_to_world.GetInt() == 0 ); + bCanOverlay = bCanOverlay && ( m_hmmMovementActual != HMM_SHOOTFACE_MOVETORSO ); + + return bCanOverlay; +} + + // -------------------------------------------------------------------- // Purpose: Returns the bounds in world space where the game should // position the HUD. @@ -1177,6 +1078,10 @@ void CClientVirtualReality::GetHUDBounds( Vector *pViewer, Vector *pUL, Vector * // -------------------------------------------------------------------- void CClientVirtualReality::RenderHUDQuad( bool bBlackout, bool bTranslucent ) { + // If we can overlay the HUD directly onto the target later, we'll do that instead (higher image quality). + if ( CanOverlayHudQuad() ) + return; + Vector vHead, vUL, vUR, vLL, vLR; GetHUDBounds ( &vHead, &vUL, &vUR, &vLL, &vLR ); @@ -1304,14 +1209,6 @@ float CClientVirtualReality::GetZoomedModeMagnification() // -------------------------------------------------------------------- bool CClientVirtualReality::ProcessCurrentTrackingState( float fGameFOV ) { - // Figure out the current HUD FOV. - m_fHudHorizontalFov = g_pSourceVR->GetHorizontalFOVDegrees() * vr_hud_display_ratio.GetFloat(); - if( m_fHudHorizontalFov > vr_hud_max_fov.GetFloat() ) - { - m_fHudHorizontalFov = vr_hud_max_fov.GetFloat(); - } - - m_WorldZoomScale = 1.0f; if ( fGameFOV != 0.0f ) { @@ -1397,8 +1294,7 @@ void CClientVirtualReality::AlignTorsoAndViewToWeapon() if( !UseVR() ) return; - VRTrackerState_t state = g_pSourceVR->GetTrackerState(); - if( state.bWillDriftInYaw ) + if( g_pSourceVR->WillDriftInYaw() ) { m_iAlignTorsoAndViewToWeaponCountdown = 2; } @@ -1408,291 +1304,202 @@ void CClientVirtualReality::AlignTorsoAndViewToWeapon() // -------------------------------------------------------------------- // Purpose: Lets VR do stuff at the very end of the rendering process // -------------------------------------------------------------------- -void CClientVirtualReality::PostProcessFrame( const vrect_t *SrcRect ) +void CClientVirtualReality::PostProcessFrame( StereoEye_t eEye ) { if( !UseVR() ) return; - g_pSourceVR->DoDistortionProcessing( SrcRect ); + g_pSourceVR->DoDistortionProcessing( eEye == STEREO_EYE_LEFT ? ISourceVirtualReality::VREye_Left : ISourceVirtualReality::VREye_Right ); +} - if ( m_bIpdTestEnabled ) + +// -------------------------------------------------------------------- +// Pastes the HUD directly onto the backbuffer / render target. +// (higher quality than the RenderHUDQuad() path but can't always be used) +// -------------------------------------------------------------------- +void CClientVirtualReality::OverlayHUDQuadWithUndistort( const CViewSetup &eyeView, bool bDoUndistort, bool bBlackout, bool bTranslucent ) +{ + if ( ! UseVR() ) + return; + + // If we can't overlay the HUD, it will be handled on another path (rendered into the scene with RenderHUDQuad()). + if ( ! CanOverlayHudQuad() ) + return; + + // Get the position of the HUD quad in world space as used by RenderHUDQuad(). Then convert to a rectangle in normalized + // device coordinates. + + Vector vHead, vUL, vUR, vLL, vLR; + GetHUDBounds ( &vHead, &vUL, &vUR, &vLL, &vLR ); + + VMatrix worldToView, viewToProjection, worldToProjection, worldToPixels; + render->GetMatricesForView( eyeView, &worldToView, &viewToProjection, &worldToProjection, &worldToPixels ); + + Vector pUL, pUR, pLL, pLR; + + worldToProjection.V3Mul( vUL, pUL ); + worldToProjection.V3Mul( vUR, pUR ); + worldToProjection.V3Mul( vLL, pLL ); + worldToProjection.V3Mul( vLR, pLR ); + + float ndcHudBounds[4]; + ndcHudBounds[0] = Min ( Min( pUL.x, pUR.x ), Min( pLL.x, pLR.x ) ); + ndcHudBounds[1] = Min ( Min( pUL.y, pUR.y ), Min( pLL.y, pLR.y ) ); + ndcHudBounds[2] = Max ( Max( pUL.x, pUR.x ), Max( pLL.x, pLR.x ) ); + ndcHudBounds[3] = Max ( Max( pUL.y, pUR.y ), Max( pLL.y, pLR.y ) ); + + ISourceVirtualReality::VREye sourceVrEye = ( eyeView.m_eStereoEye == STEREO_EYE_LEFT ) ? ISourceVirtualReality::VREye_Left : ISourceVirtualReality::VREye_Right; + + g_pSourceVR->CompositeHud ( sourceVrEye, ndcHudBounds, bDoUndistort, bBlackout, bTranslucent ); +} + + +// -------------------------------------------------------------------- +// Purpose: Switches to VR mode +// -------------------------------------------------------------------- +void CClientVirtualReality::Activate() +{ + // we can only do this if a headtrack DLL is loaded + if( !g_pSourceVR ) + return; + + // see if VR mode is even enabled + if( materials->GetCurrentConfigForVideoCard().m_nVRModeAdapter == -1 ) { - DrawIpdCalibration ( SrcRect ); + Warning( "Enable VR mode in the video options before trying to use it.\n" ); + return; } -} - -//----------------------------------------------------------------------------- -// Calibration UI -//----------------------------------------------------------------------------- - - -// These control the conversion of IPD from pixels to inches. -ConVar vr_ipdtest_interp_ipd_start_pixels ( "vr_ipdtest_interp_ipd_start_pixels", "491.0", 0 ); -ConVar vr_ipdtest_interp_ipd_start_inches ( "vr_ipdtest_interp_ipd_start_inches", "2.717", 0 ); // 69mm -ConVar vr_ipdtest_interp_ipd_end_pixels ( "vr_ipdtest_interp_ipd_end_pixels", "602.0", 0 ); -ConVar vr_ipdtest_interp_ipd_end_inches ( "vr_ipdtest_interp_ipd_end_inches", "2.205", 0 ); // 56mm - -// These numbers need to be filled in from physical tests. Right now they are placeholder. -ConVar vr_ipdtest_interp_relief_start_pixels ( "vr_ipdtest_interp_relief_start_pixels", "400.0", 0 ); -ConVar vr_ipdtest_interp_relief_start_inches ( "vr_ipdtest_interp_relief_start_inches", "0.0", 0 ); -ConVar vr_ipdtest_interp_relief_end_pixels ( "vr_ipdtest_interp_relief_end_pixels", "600.0", 0 ); -ConVar vr_ipdtest_interp_relief_end_inches ( "vr_ipdtest_interp_relief_end_inches", "1.0", 0 ); - - - - -float Interpolate ( float fIn, float fInStart, float fInEnd, float fOutStart, float fOutEnd ) -{ - float fLamdba = ( fIn - fInStart ) / ( fInEnd - fInStart ); - float fOut = fOutStart + fLamdba * ( fOutEnd - fOutStart ); - return fOut; -} - -void CClientVirtualReality::RecalcEyeCalibration ( TEyeCalibration *p ) -{ - int iDisplayWidth, iDisplayHeight; - bool bSuccess = g_pSourceVR->GetWindowSize ( &iDisplayWidth, &iDisplayHeight ); - Assert ( bSuccess ); - if ( bSuccess ) + // See if we have an actual adapter + int32 nVRModeAdapter = g_pSourceVR->GetVRModeAdapter(); + if( nVRModeAdapter == -1 ) { - // Eye relief. - // Many ways to take the average eye size. But since the top edge is hard to find (strains the eyes, and there's problems with glasses), let's just use the difference between left and right. - p->Left.fSizePixels = (float)( p->Left.iIn - p->Left.iOut ); - p->Right.fSizePixels = (float)( p->Right.iIn - p->Right.iOut ); - // ...not that we have any data yet, nor do we know what to do with it if we had it. - float fLeftInches = Interpolate ( p->Left.fSizePixels, - vr_ipdtest_interp_relief_start_pixels.GetFloat(), - vr_ipdtest_interp_relief_end_pixels.GetFloat(), - vr_ipdtest_interp_relief_start_inches.GetFloat(), - vr_ipdtest_interp_relief_end_inches.GetFloat() ); - p->Left.fReliefInches = fLeftInches; - float fRightInches = Interpolate ( p->Right.fSizePixels, - vr_ipdtest_interp_relief_start_pixels.GetFloat(), - vr_ipdtest_interp_relief_end_pixels.GetFloat(), - vr_ipdtest_interp_relief_start_inches.GetFloat(), - vr_ipdtest_interp_relief_end_inches.GetFloat() ); - p->Right.fReliefInches = fRightInches; - - // Calculate IPD - // In and Out are both measured from the nearest edge of the display, i.e. the left ones from the left edge, the right ones from the right edge. - float fLeftMid = (float)( p->Left.iIn + p->Left.iOut ) * 0.5f; - float fRightMid = (float)( p->Right.iIn + p->Right.iOut ) * 0.5f; - // An outside value of 0 is the first actual pixel on the outer edge of the display. - // So if both values are 0, the two lines are (iDisplayWidth-1) apart. - float fSeparationInPixels = (float)( iDisplayWidth - 1 ) - fLeftMid - fRightMid; - float fIpdInches = Interpolate ( fSeparationInPixels, - vr_ipdtest_interp_ipd_start_pixels.GetFloat(), - vr_ipdtest_interp_ipd_end_pixels.GetFloat(), - vr_ipdtest_interp_ipd_start_inches.GetFloat(), - vr_ipdtest_interp_ipd_end_inches.GetFloat() ); - p->fIpdInches = fIpdInches; - p->fIpdPixels = fSeparationInPixels; + Warning( "Unable to get VRMode adapter from OpenVR. VR mode cannot be enabled. Try restarting and then enabling VR again.\n" ); + return; + } + + // we can only activate if we've got a VR device + if( materials->GetCurrentConfigForVideoCard().m_nVRModeAdapter != nVRModeAdapter ) + { + Warning( "VR Mode expects adapter %d which is different from %d which we are currently using. Try restarting and enabling VR mode again.\n", + nVRModeAdapter, materials->GetCurrentConfigForVideoCard().m_nVRModeAdapter ); + engine->ExecuteClientCmd( "mat_enable_vrmode 0\n" ); + return; } -} -void CClientVirtualReality::GetCurrentEyeCalibration ( TEyeCalibration *p ) -{ - p->Left.iTop = vr_ipdtest_left_t.GetInt(); - p->Left.iBot = vr_ipdtest_left_b.GetInt(); - p->Left.iIn = vr_ipdtest_left_i.GetInt(); - p->Left.iOut = vr_ipdtest_left_o.GetInt(); - p->Right.iTop = vr_ipdtest_right_t.GetInt(); - p->Right.iBot = vr_ipdtest_right_b.GetInt(); - p->Right.iIn = vr_ipdtest_right_i.GetInt(); - p->Right.iOut = vr_ipdtest_right_o.GetInt(); - RecalcEyeCalibration ( p ); - m_IpdTestCurrent = *p; -} + // can't activate twice + if( UseVR() ) + return; -void CClientVirtualReality::SetCurrentEyeCalibration ( TEyeCalibration const &p ) -{ - m_IpdTestCurrent = p; - RecalcEyeCalibration ( &m_IpdTestCurrent ); - g_pSourceVR->SetUserIPDMM( m_IpdTestCurrent.fIpdInches * 25.4f ); - vr_ipdtest_left_t.SetValue ( m_IpdTestCurrent.Left.iTop ); - vr_ipdtest_left_b.SetValue ( m_IpdTestCurrent.Left.iBot ); - vr_ipdtest_left_i.SetValue ( m_IpdTestCurrent.Left.iIn ); - vr_ipdtest_left_o.SetValue ( m_IpdTestCurrent.Left.iOut ); - vr_ipdtest_right_t.SetValue ( m_IpdTestCurrent.Right.iTop ); - vr_ipdtest_right_b.SetValue ( m_IpdTestCurrent.Right.iBot ); - vr_ipdtest_right_i.SetValue ( m_IpdTestCurrent.Right.iIn ); - vr_ipdtest_right_o.SetValue ( m_IpdTestCurrent.Right.iOut ); - -#ifdef _DEBUG - Warning ( " TBIO: left %d %d %d %d: right %d %d %d %d: %f inches\n", // Need the spaces to center it so I can read it! - m_IpdTestCurrent.Left.iTop, - m_IpdTestCurrent.Left.iBot, - m_IpdTestCurrent.Left.iIn, - m_IpdTestCurrent.Left.iOut, - m_IpdTestCurrent.Right.iTop, - m_IpdTestCurrent.Right.iBot, - m_IpdTestCurrent.Right.iIn, - m_IpdTestCurrent.Right.iOut, - m_IpdTestCurrent.fIpdInches ); + // remember where we were + m_bNonVRWindowed = g_pMaterialSystem->GetCurrentConfigForVideoCard().Windowed(); + vgui::surface()->GetScreenSize( m_nNonVRWidth, m_nNonVRHeight ); +#if defined( USE_SDL ) + static ConVarRef sdl_displayindex( "sdl_displayindex" ); + m_nNonVRSDLDisplayIndex = sdl_displayindex.GetInt(); #endif + + if( !g_pSourceVR->Activate() ) + { + // we couldn't activate, so just punt on this whole thing + return; + } + + // general all-game stuff + engine->ExecuteClientCmd( "mat_reset_rendertargets\n" ); + + // game specific VR config + CUtlString sCmd; + sCmd.Format( "exec sourcevr_%s.cfg\n", COM_GetModDirectory() ); + engine->ExecuteClientCmd( sCmd.Get() ); + + vgui::surface()->SetSoftwareCursor( true ); + +#if defined(POSIX) + ConVarRef m_rawinput( "m_rawinput" ); + m_bNonVRRawInput = m_rawinput.GetBool(); + m_rawinput.SetValue( 1 ); + + ConVarRef mat_vsync( "mat_vsync" ); + mat_vsync.SetValue( 0 ); +#endif + + g_pMatSystemSurface->ForceScreenSizeOverride(true, 640, 480 ); + int nViewportWidth, nViewportHeight; + + g_pSourceVR->GetViewportBounds( ISourceVirtualReality::VREye_Left, NULL, NULL, &nViewportWidth, &nViewportHeight ); + vgui::surface()->SetFullscreenViewportAndRenderTarget( 0, 0, nViewportWidth, nViewportHeight, g_pSourceVR->GetRenderTarget( ISourceVirtualReality::VREye_Left, ISourceVirtualReality::RT_Color ) ); + + vgui::ivgui()->SetVRMode( true ); + + VRRect_t rect; + if( g_pSourceVR->GetDisplayBounds( &rect ) ) + { + + // set mode + char szCmd[ 256 ]; + Q_snprintf( szCmd, sizeof( szCmd ), "mat_setvideomode %i %i %i\n", rect.nWidth, rect.nHeight, vr_force_windowed.GetBool()? 1 : 0 ); + engine->ClientCmd_Unrestricted( szCmd ); + } } -void CClientVirtualReality::SetEyeCalibrationDisplayMisc ( int iEditingNum, bool bVisible ) + +void CClientVirtualReality::Deactivate() { - if( bVisible && !m_bIpdTestEnabled ) + // can't deactivate when we aren't active + if( !UseVR() ) + return; + + g_pSourceVR->Deactivate(); + + g_pMatSystemSurface->ForceScreenSizeOverride(false, 0, 0 ); + g_pMaterialSystem->GetRenderContext()->Viewport( 0, 0, m_nNonVRWidth, m_nNonVRHeight ); + vgui::surface()->SetFullscreenViewportAndRenderTarget( 0, 0, m_nNonVRWidth, m_nNonVRHeight, NULL ); + + static ConVarRef cl_software_cursor( "cl_software_cursor" ); + vgui::surface()->SetSoftwareCursor( cl_software_cursor.GetBool() ); + +#if defined( USE_SDL ) + static ConVarRef sdl_displayindex( "sdl_displayindex" ); + sdl_displayindex.SetValue( m_nNonVRSDLDisplayIndex ); +#endif + +#if defined(POSIX) + ConVarRef m_rawinput( "m_rawinput" ); + m_rawinput.SetValue( m_bNonVRRawInput ); +#endif + + // Make sure the client .dll root panel is at the proper point before doing the "SolveTraverse" calls + vgui::VPANEL root = enginevgui->GetPanel( PANEL_CLIENTDLL ); + if ( root != 0 ) { - // if we're being shown, read out the current config from the convars - GetCurrentEyeCalibration ( &m_IpdTestCurrent ); + vgui::ipanel()->SetSize( root, m_nNonVRWidth, m_nNonVRHeight ); + } + // Same for client .dll tools + root = enginevgui->GetPanel( PANEL_CLIENTDLL_TOOLS ); + if ( root != 0 ) + { + vgui::ipanel()->SetSize( root, m_nNonVRWidth, m_nNonVRHeight ); } - m_IpdTestControl = iEditingNum; - m_bIpdTestEnabled = bVisible; + int viewWidth, viewHeight; + vgui::surface()->GetScreenSize( viewWidth, viewHeight ); + + engine->ExecuteClientCmd( "mat_reset_rendertargets\n" ); + + // set mode + char szCmd[ 256 ]; + Q_snprintf( szCmd, sizeof( szCmd ), "mat_setvideomode %i %i %i\n", m_nNonVRWidth, m_nNonVRHeight, m_bNonVRWindowed ? 1 : 0 ); + engine->ClientCmd_Unrestricted( szCmd ); + } -void CClientVirtualReality::DrawIpdCalibration ( const vrect_t *SrcRect ) +// Called when startup is complete +void CClientVirtualReality::StartupComplete() { - int ControlNum = m_IpdTestControl; - int WhichEdges = 0; - bool bShowLeft = false; - bool bShowRight = false; - switch ( ControlNum ) - { - case 0: case 1: case 2: case 3: - bShowLeft = true; - WhichEdges = 1 << ControlNum; - break; - case 4: case 5: case 6: case 7: - bShowRight = true; - WhichEdges = 1 << ControlNum; - break; - case 8: - // Adjust IPD directly. - bShowLeft = true; - bShowRight = true; - WhichEdges = 0x33; - break; - case 9: - // Left relief. - bShowLeft = true; - WhichEdges = 0xff; - break; - case 10: - // Right relief. - bShowRight = true; - WhichEdges = 0xff; - break; - default: - Assert ( false ); - break; - } - - CMatRenderContextPtr pRenderContext( materials ); - - //pRenderContext->ClearColor4ub ( 0, 0, 0, 0 ); - //pRenderContext->ClearBuffers ( true, true ); - - IMaterial *pMaterial = materials->FindMaterial ( "debug/debugtranslucentsinglecolor", TEXTURE_GROUP_OTHER, true ); - pMaterial->ColorModulate( 1.0f, 1.0f, 1.0f ); - pMaterial->AlphaModulate( 1.0f ); - - const int Border = 4; - const int BlueStart = 10; // Well, it used to be blue, now it isn't. - const int BlueSize = 30; - - // You want a pure green for the "current" edge so that it has no chromatic aberration smearing (i.e. white is a terrible choice!) - // The non-current lines can be a different colour because you're not actively tuning them. -#define SET_COLOR1(num) if ( 0 != ( WhichEdges & (1<<(num)) ) ) { pMaterial->ColorModulate( 0.0f, 1.0f, 0.0f ); } else { pMaterial->ColorModulate( 0.25f, 0.25f, 0.25f ); } -#define SET_COLOR2(num) if ( 0 != ( WhichEdges & (1<<(num)) ) ) { pMaterial->ColorModulate( 1.0f, 1.0f, 1.0f ); } else { pMaterial->ColorModulate( 0.0f, 0.0f, 0.0f ); } - - if ( bShowLeft ) - { - int t = m_IpdTestCurrent.Left.iTop; - int b = m_IpdTestCurrent.Left.iBot; - int l = m_IpdTestCurrent.Left.iOut; - int r = m_IpdTestCurrent.Left.iIn; - - // Render a black rect to enhance contrast. - pMaterial->ColorModulate( 0.0f, 0.0f, 0.0f ); - pMaterial->AlphaModulate( 1.0f ); - - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l-Border-1, t-Border-1, r-l+Border*2+3, Border*2+3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l-Border-1, b-Border-1, r-l+Border*2+3, Border*2+3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l-Border-1, t-Border-1, Border*2+3, b-t+Border*2+3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, r-Border-1, t-Border-1, Border*2+3, b-t+Border*2+3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - - int cx = (l+r)/2; - int cy = (t+b)/2; - - // For each side, draw the line along the side, and also a line "pointing to" it from the middle. - // Left - SET_COLOR1(1); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l, t, 1, b-t+1, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - SET_COLOR2(1); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l+BlueStart, cy-1, BlueSize, 3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - - // Right - SET_COLOR1(0); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, r, t, 1, b-t+1, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - SET_COLOR2(0); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, r-BlueStart-BlueSize, cy-1, BlueSize, 3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - - // Top - SET_COLOR1(2); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l, t, r-l+1, 1, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - SET_COLOR2(2); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, cx-1, t+BlueStart, 3, BlueSize, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - - // Bottom - SET_COLOR1(3); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l, b, r-l+1, 1, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - SET_COLOR2(3); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, cx-1, b-BlueStart-BlueSize, 3, BlueSize, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - } - - if ( bShowRight ) - { - int t = m_IpdTestCurrent.Right.iTop; - int b = m_IpdTestCurrent.Right.iBot; - // An outside value of 0 is the first actual pixel on the edge of the display. So if both values are 0, the two lines are (SrcRect->width - 1) apart. - int l = SrcRect->width - 1 - m_IpdTestCurrent.Right.iIn; - int r = SrcRect->width - 1 - m_IpdTestCurrent.Right.iOut; - - // Render a black rect to enhance contrast. - pMaterial->ColorModulate( 0.0f, 0.0f, 0.0f ); - pMaterial->AlphaModulate( 1.0f ); - - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l-Border-1, t-Border-1, r-l+Border*2+3, Border*2+3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l-Border-1, b-Border-1, r-l+Border*2+3, Border*2+3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l-Border-1, t-Border-1, Border*2+3, b-t+Border*2+3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, r-Border-1, t-Border-1, Border*2+3, b-t+Border*2+3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - - int cx = (l+r)/2; - int cy = (t+b)/2; - - // For each side, draw the line along the side, and also a line "pointing to" it from the middle. - // Left - SET_COLOR1(4); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l, t, 1, b-t+1, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - SET_COLOR2(4); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l+BlueStart, cy-1, BlueSize, 3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - - // Right - SET_COLOR1(5); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, r, t, 1, b-t+1, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - SET_COLOR2(5); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, r-BlueStart-BlueSize, cy-1, BlueSize, 3, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - - // Top - SET_COLOR1(6); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l, t, r-l+1, 1, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - SET_COLOR2(6); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, cx-1, t+BlueStart, 3, BlueSize, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - - // Bottom - SET_COLOR1(7); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, l, b, r-l+1, 1, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - SET_COLOR2(7); - pRenderContext->DrawScreenSpaceRectangle ( pMaterial, cx-1, b-BlueStart-BlueSize, 3, BlueSize, 0.0f, 0.0f, 0.0f, 0.0f, 16, 16 ); - } - - return; + if( vr_activate_default.GetBool() ) + Activate(); } diff --git a/sp/src/game/client/client_virtualreality.h b/sp/src/game/client/client_virtualreality.h index c06c6527..9aadfeb3 100644 --- a/sp/src/game/client/client_virtualreality.h +++ b/sp/src/game/client/client_virtualreality.h @@ -14,6 +14,7 @@ #include "tier3/tier3.h" #include "iclientvirtualreality.h" +#include "view_shared.h" enum HeadtrackMovementMode_t { @@ -34,20 +35,6 @@ enum HeadtrackMovementMode_t }; -// used for interacting with the calibration UI -struct TEyeCalibration -{ - struct TEyeEdges - { - int iTop, iBot, iIn, iOut; // These are used to calculate everything else. - float fSizePixels; - float fReliefInches; - } Left, Right; - - float fIpdPixels; - float fIpdInches; -}; - //----------------------------------------------------------------------------- // The implementation //----------------------------------------------------------------------------- @@ -77,6 +64,8 @@ public: virtual InitReturnVal_t Init(); virtual void Shutdown(); + // Called when startup is complete + void StartupComplete(); //--------------------------------------------------------- // IClientVirtualReality implementation @@ -94,6 +83,7 @@ public: bool CurrentlyZoomed(); void OverrideTorsoTransform( const Vector & position, const QAngle & angles ) ; void CancelTorsoTransformOverride( ) ; + bool CanOverlayHudQuad(); void GetHUDBounds( Vector *pViewer, Vector *pUL, Vector *pUR, Vector *pLL, Vector *pLR ); void RenderHUDQuad( bool bBlackout, bool bTranslucent ); float GetZoomedModeMagnification(); @@ -105,23 +95,14 @@ public: const VMatrix & GetWorldFromMidEye() const { return m_WorldFromMidEyeNoDebugCam; } void OverrideViewModelTransform( Vector & vmorigin, QAngle & vmangles, bool bUseLargeOverride ); void AlignTorsoAndViewToWeapon(); - void PostProcessFrame( const vrect_t *SrcRect ); + void PostProcessFrame( StereoEye_t eEye ); + void OverlayHUDQuadWithUndistort( const CViewSetup &view, bool bDoUndistort, bool bBlackout, bool bTranslucent ); //--------------------------------------------------------- - // Stat collection + // Enter/leave VR mode //--------------------------------------------------------- - bool CollectSessionStartStats( KeyValues *pkvStats ); - bool CollectPeriodicStats( KeyValues *pkvStats ); - - //--------------------------------------------------------- - // IPD Calibration - //--------------------------------------------------------- - void DrawIpdCalibration ( const vrect_t *SrcRect ); - - void RecalcEyeCalibration ( TEyeCalibration *p ); - void GetCurrentEyeCalibration ( TEyeCalibration *p ); - void SetCurrentEyeCalibration ( TEyeCalibration const &p ); - void SetEyeCalibrationDisplayMisc ( int iEditingNum, bool bVisible ); + void Activate(); + void Deactivate(); private: HeadtrackMovementMode_t m_hmmMovementActual; @@ -169,11 +150,14 @@ private: RTime32 m_rtLastMotionSample; - // IPD test fields - bool m_bIpdTestEnabled; - int m_IpdTestControl; - TEyeCalibration m_IpdTestCurrent; - + // video mode we had before we entered VR mode + bool m_bNonVRWindowed; + int m_nNonVRWidth; + int m_nNonVRHeight; +#if defined( USE_SDL ) + int m_nNonVRSDLDisplayIndex; +#endif + bool m_bNonVRRawInput; }; extern CClientVirtualReality g_ClientVirtualReality; diff --git a/sp/src/game/client/clientmode_shared.cpp b/sp/src/game/client/clientmode_shared.cpp index a1d1127d..b6dee29c 100644 --- a/sp/src/game/client/clientmode_shared.cpp +++ b/sp/src/game/client/clientmode_shared.cpp @@ -36,7 +36,7 @@ #include #include "hud_vote.h" #include "ienginevgui.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #if defined( _X360 ) #include "xbox/xbox_console.h" #endif @@ -208,6 +208,7 @@ static void __MsgFunc_VGUIMenu( bf_read &msg ) if ( count > 0 ) { KeyValues *keys = new KeyValues("data"); + //Msg( "MsgFunc_VGUIMenu:\n" ); for ( int i=0; iSetString( name, data ); } + // !KLUDGE! Whitelist of URL protocols formats for MOTD + if ( + !V_stricmp( panelname, PANEL_INFO ) // MOTD + && keys->GetInt( "type", 0 ) == 2 // URL message type + ) { + const char *pszURL = keys->GetString( "msg", "" ); + if ( Q_strncmp( pszURL, "http://", 7 ) != 0 && Q_strncmp( pszURL, "https://", 8 ) != 0 ) + { + Warning( "Blocking MOTD URL '%s'; must begin with 'http://' or 'https://'\n", pszURL ); + keys->deleteThis(); + return; + } + } + viewport->SetData( keys ); keys->deleteThis(); @@ -496,7 +512,7 @@ bool ClientModeShared::ShouldBlackoutAroundHUD() //----------------------------------------------------------------------------- -// Purpose: Allows the client mode to override mouse control stuff in headtrack +// Purpose: Allows the client mode to override mouse control stuff in sourcevr //----------------------------------------------------------------------------- HeadtrackMovementMode_t ClientModeShared::ShouldOverrideHeadtrackControl() { diff --git a/sp/src/game/client/clientmode_shared.h b/sp/src/game/client/clientmode_shared.h index ae784c00..27336964 100644 --- a/sp/src/game/client/clientmode_shared.h +++ b/sp/src/game/client/clientmode_shared.h @@ -132,6 +132,7 @@ public: virtual bool IsInfoPanelAllowed() OVERRIDE { return true; } virtual void InfoPanelDisplayed() OVERRIDE { } + virtual bool IsHTMLInfoPanelAllowed() OVERRIDE { return true; } protected: CBaseViewport *m_pViewport; diff --git a/sp/src/game/client/game_controls/vguitextwindow.cpp b/sp/src/game/client/game_controls/vguitextwindow.cpp index 450fa07c..5cdc2532 100644 --- a/sp/src/game/client/game_controls/vguitextwindow.cpp +++ b/sp/src/game/client/game_controls/vguitextwindow.cpp @@ -9,6 +9,7 @@ #include "vguitextwindow.h" #include #include +#include #include #include @@ -165,8 +166,15 @@ void CTextWindow::ShowText( const char *text ) void CTextWindow::ShowURL( const char *URL, bool bAllowUserToDisable ) { #if defined( ENABLE_CHROMEHTMLWINDOW ) - if ( bAllowUserToDisable && cl_disablehtmlmotd.GetBool() ) + #ifdef _DEBUG + Msg( "CTextWindow::ShowURL( %s )\n", URL ); + #endif + + ClientModeShared *mode = ( ClientModeShared * )GetClientModeNormal(); + if ( ( bAllowUserToDisable && cl_disablehtmlmotd.GetBool() ) || !mode->IsHTMLInfoPanelAllowed() ) { + Warning( "Blocking HTML info panel '%s'; Using plaintext instead.\n", URL ); + // User has disabled HTML TextWindows. Show the fallback as text only. if ( g_pStringTableInfoPanel ) { @@ -289,7 +297,15 @@ void CTextWindow::Update( void ) } else if ( m_nContentType == TYPE_URL ) { - ShowURL( m_szMessage ); + if ( !Q_strncmp( m_szMessage, "http://", 7 ) || !Q_strncmp( m_szMessage, "https://", 8 ) || !Q_stricmp( m_szMessage, "about:blank" ) ) + { + ShowURL( m_szMessage ); + } + else + { + // We should have trapped this at a higher level + Assert( !"URL protocol is missing or blocked" ); + } } else if ( m_nContentType == TYPE_FILE ) { diff --git a/sp/src/game/client/hl2/hud_autoaim.cpp b/sp/src/game/client/hl2/hud_autoaim.cpp index 3339a72f..aa808acf 100644 --- a/sp/src/game/client/hl2/hud_autoaim.cpp +++ b/sp/src/game/client/hl2/hud_autoaim.cpp @@ -146,6 +146,7 @@ void CHUDAutoAim::VidInit( void ) //----------------------------------------------------------------------------- bool CHUDAutoAim::ShouldDraw( void ) { +#ifndef HL1_CLIENT_DLL C_BaseHLPlayer *pLocalPlayer = (C_BaseHLPlayer *)C_BasePlayer::GetLocalPlayer(); if ( pLocalPlayer ) { @@ -154,6 +155,7 @@ bool CHUDAutoAim::ShouldDraw( void ) return false; } } +#endif return ( (hud_draw_fixed_reticle.GetBool() || hud_draw_active_reticle.GetBool()) && CHudElement::ShouldDraw() && !engine->IsDrawingLoadingImage() ); } diff --git a/sp/src/game/client/hl2/hud_damageindicator.cpp b/sp/src/game/client/hl2/hud_damageindicator.cpp index 86debdf7..48dd9b62 100644 --- a/sp/src/game/client/hl2/hud_damageindicator.cpp +++ b/sp/src/game/client/hl2/hud_damageindicator.cpp @@ -20,7 +20,7 @@ #include "IEffects.h" #include "hudelement.h" #include "clienteffectprecachesystem.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" using namespace vgui; diff --git a/sp/src/game/client/hl2/hud_weaponselection.cpp b/sp/src/game/client/hl2/hud_weaponselection.cpp index 3d857e99..9d223169 100644 --- a/sp/src/game/client/hl2/hud_weaponselection.cpp +++ b/sp/src/game/client/hl2/hud_weaponselection.cpp @@ -451,6 +451,17 @@ void CHudWeaponSelection::Paint() if ( !pSelectedWeapon ) return; + bool bPushedViewport = false; + if( hud_fastswitch.GetInt() == HUDTYPE_FASTSWITCH || hud_fastswitch.GetInt() == HUDTYPE_PLUS ) + { + CMatRenderContextPtr pRenderContext( materials ); + if( pRenderContext->GetRenderTarget() ) + { + surface()->PushFullscreenViewport(); + bPushedViewport = true; + } + } + // interpolate the selected box size between the small box size and the large box size // interpolation has been removed since there is no weapon pickup animation anymore, so it's all at the largest size float percentageDone = 1.0f; //min(1.0f, (gpGlobals->curtime - m_flPickupStartTime) / m_flWeaponPickupGrowTime); @@ -727,6 +738,11 @@ void CHudWeaponSelection::Paint() } break; } + + if( bPushedViewport ) + { + surface()->PopFullscreenViewport(); + } } @@ -1025,8 +1041,6 @@ void CHudWeaponSelection::ApplySchemeSettings(vgui::IScheme *pScheme) { SetBounds( x, y, screenWide - x, screenTall - y ); } - - SetForceStereoRenderToFrameBuffer( true ); } //----------------------------------------------------------------------------- diff --git a/sp/src/game/client/hud_basedeathnotice.cpp b/sp/src/game/client/hud_basedeathnotice.cpp index b3f494b6..d732bd05 100644 --- a/sp/src/game/client/hud_basedeathnotice.cpp +++ b/sp/src/game/client/hud_basedeathnotice.cpp @@ -114,7 +114,8 @@ void CHudBaseDeathNotice::Paint() DeathNoticeItem &msg = m_DeathNotices[i]; CHudTexture *icon = msg.iconDeath; - + CHudTexture *iconPrekiller = msg.iconPreKiller; + wchar_t victim[256]=L""; wchar_t killer[256]=L""; @@ -125,10 +126,15 @@ void CHudBaseDeathNotice::Paint() int iVictimTextWide = UTIL_ComputeStringWidth( m_hTextFont, victim ) + xSpacing; int iDeathInfoTextWide= msg.wzInfoText[0] ? UTIL_ComputeStringWidth( m_hTextFont, msg.wzInfoText ) + xSpacing : 0; + int iDeathInfoEndTextWide= msg.wzInfoTextEnd[0] ? UTIL_ComputeStringWidth( m_hTextFont, msg.wzInfoTextEnd ) + xSpacing : 0; + int iKillerTextWide = killer[0] ? UTIL_ComputeStringWidth( m_hTextFont, killer ) + xSpacing : 0; int iLineTall = m_flLineHeight; int iTextTall = surface()->GetFontTall( m_hTextFont ); int iconWide = 0, iconTall = 0, iDeathInfoOffset = 0, iVictimTextOffset = 0, iconActualWide = 0; + + int iPreKillerTextWide = msg.wzPreKillerText[0] ? UTIL_ComputeStringWidth( m_hTextFont, msg.wzPreKillerText ) - xSpacing : 0; + int iconPrekillerWide = 0, iconPrekillerActualWide = 0, iconPreKillerTall = 0; // Get the local position for this notice if ( icon ) @@ -145,7 +151,25 @@ void CHudBaseDeathNotice::Paint() iconTall *= flScale; iconWide *= flScale; } - int iTotalWide = iKillerTextWide + iconWide + iVictimTextWide + iDeathInfoTextWide + ( xMargin * 2 ); + + if ( iconPrekiller ) + { + iconPrekillerActualWide = iconPrekiller->EffectiveWidth( 1.0f ); + iconPrekillerWide = iconPrekillerActualWide; + iconPreKillerTall = iconPrekiller->EffectiveHeight( 1.0f ); + + int iconTallDesired = iLineTall-YRES(2); + Assert( 0 != iconTallDesired ); + float flScale = (float) iconTallDesired / (float) iconPreKillerTall; + + iconPrekillerActualWide *= flScale; + iconPreKillerTall *= flScale; + iconPrekillerWide *= flScale; + } + + int iTotalWide = iKillerTextWide + iconWide + iVictimTextWide + iDeathInfoTextWide + iDeathInfoEndTextWide + ( xMargin * 2 ); + iTotalWide += iconPrekillerWide + iPreKillerTextWide; + int y = yStart + ( ( iLineTall + m_flLineSpacing ) * i ); int yText = y + ( ( iLineTall - iTextTall ) / 2 ); int yIcon = y + ( ( iLineTall - iconTall ) / 2 ); @@ -160,11 +184,11 @@ void CHudBaseDeathNotice::Paint() Vertex_t vert[NUM_BACKGROUND_COORD]; GetBackgroundPolygonVerts( x, y+1, x+iTotalWide, y+iLineTall-1, ARRAYSIZE( vert ), vert ); surface()->DrawSetTexture( -1 ); - surface()->DrawSetColor( msg.bLocalPlayerInvolved ? m_clrLocalBGColor : m_clrBaseBGColor ); + surface()->DrawSetColor( GetBackgroundColor ( i ) ); surface()->DrawTexturedPolygon( ARRAYSIZE( vert ), vert ); x += xMargin; - + if ( killer[0] ) { // Draw killer's name @@ -172,6 +196,22 @@ void CHudBaseDeathNotice::Paint() x += iKillerTextWide; } + // prekiller text + if ( msg.wzPreKillerText[0] ) + { + x += xSpacing; + DrawText( x + iDeathInfoOffset, yText, m_hTextFont, GetInfoTextColor( i ), msg.wzPreKillerText ); + x += iPreKillerTextWide; + } + + // Prekiller icon + if ( iconPrekiller ) + { + int yPreIconTall = y + ( ( iLineTall - iconPreKillerTall ) / 2 ); + iconPrekiller->DrawSelf( x, yPreIconTall, iconPrekillerActualWide, iconPreKillerTall, m_clrIcon ); + x += iconPrekillerWide + xSpacing; + } + // Draw glow behind weapon icon to show it was a crit death if ( msg.bCrit && msg.iconCritDeath ) { @@ -194,13 +234,19 @@ void CHudBaseDeathNotice::Paint() iVictimTextOffset -= iDeathInfoTextWide; } - DrawText( x + iDeathInfoOffset, yText, m_hTextFont, GetInfoTextColor( msg.bLocalPlayerInvolved ), msg.wzInfoText ); + DrawText( x + iDeathInfoOffset, yText, m_hTextFont, GetInfoTextColor( i ), msg.wzInfoText ); x += iDeathInfoTextWide; } // Draw victims name DrawText( x + iVictimTextOffset, yText, m_hTextFont, GetTeamColor( msg.Victim.iTeam, msg.bLocalPlayerInvolved ), victim ); x += iVictimTextWide; + + // Draw Additional Text on the end of the victims name + if ( msg.wzInfoTextEnd[0] ) + { + DrawText( x , yText, m_hTextFont, GetInfoTextColor( i ), msg.wzInfoTextEnd ); + } } } @@ -358,7 +404,12 @@ void CHudBaseDeathNotice::FireGameEvent( IGameEvent *event ) bLocalPlayerInvolved = true; } - if ( event->GetInt( "damagebits" ) & DMG_CRITICAL ) + if ( event->GetInt( "death_flags" ) & TF_DEATH_AUSTRALIUM ) + { + m_DeathNotices[iMsg].bCrit= true; + m_DeathNotices[iMsg].iconCritDeath = GetIcon( "d_australium", bLocalPlayerInvolved ? kDeathNoticeIcon_Inverted : kDeathNoticeIcon_Standard ); + } + else if ( event->GetInt( "damagebits" ) & DMG_CRITICAL ) { m_DeathNotices[iMsg].bCrit= true; m_DeathNotices[iMsg].iconCritDeath = GetIcon( "d_crit", bLocalPlayerInvolved ? kDeathNoticeIcon_Inverted : kDeathNoticeIcon_Standard ); diff --git a/sp/src/game/client/hud_basedeathnotice.h b/sp/src/game/client/hud_basedeathnotice.h index 7bd3bb56..2a9da0c5 100644 --- a/sp/src/game/client/hud_basedeathnotice.h +++ b/sp/src/game/client/hud_basedeathnotice.h @@ -30,6 +30,7 @@ struct DeathNoticeItem { szIcon[0]=0; wzInfoText[0]=0; + wzInfoTextEnd[0]=0; iconDeath = NULL; iconCritDeath = NULL; bSelfInflicted = false; @@ -40,6 +41,9 @@ struct DeathNoticeItem iWeaponID = -1; iKillerID = -1; iVictimID = -1; + + iconPreKiller = NULL; + wzPreKillerText[0] = 0; } float GetExpiryTime(); @@ -48,8 +52,13 @@ struct DeathNoticeItem DeathNoticePlayer Victim; char szIcon[32]; // name of icon to display wchar_t wzInfoText[32]; // any additional text to display next to icon + wchar_t wzInfoTextEnd[32]; // any additional text to display next to victim name CHudTexture *iconDeath; CHudTexture *iconCritDeath; // crit background icon + + CHudTexture *iconPreKiller; + wchar_t wzPreKillerText[32]; + bool bSelfInflicted; bool bLocalPlayerInvolved; bool bCrit; @@ -104,7 +113,8 @@ protected: virtual int UseExistingNotice( IGameEvent *event ) { return -1; } void GetLocalizedControlPointName( IGameEvent *event, char *namebuf, int namelen ); - virtual Color GetInfoTextColor( bool bLocalPlayerInvolved ){ return Color( 255, 255, 255, 255 ); } + virtual Color GetInfoTextColor( int iDeathNoticeMsg ){ return Color( 255, 255, 255, 255 ); } + virtual Color GetBackgroundColor ( int iDeathNoticeMsg ) { return m_DeathNotices[iDeathNoticeMsg].bLocalPlayerInvolved ? m_clrLocalBGColor : m_clrBaseBGColor; } CPanelAnimationVarAliasType( float, m_flLineHeight, "LineHeight", "16", "proportional_float" ); CPanelAnimationVarAliasType( float, m_flLineSpacing, "LineSpacing", "4", "proportional_float" ); @@ -115,6 +125,7 @@ protected: CPanelAnimationVar( Color, m_clrIcon, "IconColor", "255 80 0 255" ); CPanelAnimationVar( Color, m_clrBaseBGColor, "BaseBackgroundColor", "46 43 42 220" ); CPanelAnimationVar( Color, m_clrLocalBGColor, "LocalBackgroundColor", "245 229 196 200" ); + CPanelAnimationVar( Color, m_clrKillStreakBg, "KillStreakBackgroundColor", "224 223 219 200" ); CUtlVector m_DeathNotices; diff --git a/sp/src/game/client/hud_crosshair.cpp b/sp/src/game/client/hud_crosshair.cpp index 5327d23b..fc7714fe 100644 --- a/sp/src/game/client/hud_crosshair.cpp +++ b/sp/src/game/client/hud_crosshair.cpp @@ -16,7 +16,7 @@ #include "materialsystem/imaterialsystem.h" #include "VGuiMatSurface/IMatSystemSurface.h" #include "client_virtualreality.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #ifdef SIXENSE #include "sixense/in_sixense.h" diff --git a/sp/src/game/client/hud_vote.cpp b/sp/src/game/client/hud_vote.cpp index 7a88bb22..55b8f389 100644 --- a/sp/src/game/client/hud_vote.cpp +++ b/sp/src/game/client/hud_vote.cpp @@ -1059,6 +1059,10 @@ void CHudVote::MsgFunc_CallVoteFailed( bf_read &msg ) case VOTE_FAILED_CANNOT_KICK_DURING_ROUND: m_pCallVoteFailed->SetControlString( "FailedReason", "#GameUI_vote_failed_round_active" ); break; + + case VOTE_FAILED_MODIFICATION_ALREADY_ACTIVE: + m_pCallVoteFailed->SetControlString( "FailedReason", "#GameUI_vote_failed_event_already_active" ); + break; } } diff --git a/sp/src/game/client/iclientmode.h b/sp/src/game/client/iclientmode.h index 5bf7aedb..2b74f625 100644 --- a/sp/src/game/client/iclientmode.h +++ b/sp/src/game/client/iclientmode.h @@ -147,6 +147,7 @@ public: virtual bool IsInfoPanelAllowed() = 0; virtual void InfoPanelDisplayed() = 0; + virtual bool IsHTMLInfoPanelAllowed() = 0; }; extern IClientMode *g_pClientMode; diff --git a/sp/src/game/client/in_main.cpp b/sp/src/game/client/in_main.cpp index 9cb7cd31..21eb30a0 100644 --- a/sp/src/game/client/in_main.cpp +++ b/sp/src/game/client/in_main.cpp @@ -31,7 +31,7 @@ #endif #include "client_virtualreality.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" // NVNT Include #include "haptics/haptic_utils.h" diff --git a/sp/src/game/client/replay/vgui/replayperformanceeditor.cpp b/sp/src/game/client/replay/vgui/replayperformanceeditor.cpp index 781a5c37..99178f6e 100644 --- a/sp/src/game/client/replay/vgui/replayperformanceeditor.cpp +++ b/sp/src/game/client/replay/vgui/replayperformanceeditor.cpp @@ -1185,6 +1185,7 @@ CReplayPerformanceEditorPanel::CReplayPerformanceEditorPanel( Panel *parent, Rep m_nRedBlueSigns[0] = -1; m_nRedBlueSigns[1] = 1; m_iCurPlayerTarget = -1; + m_bCurrentTargetNeedsVisibilityUpdate = false; m_pImageList = new ImageList( false ); @@ -1737,6 +1738,19 @@ void CReplayPerformanceEditorPanel::OnTick() pCamera->SetPrimaryTarget( m_iCurPlayerTarget ); } + // fixes a case where the replay would be paused and the player would cycle cameras but the + // target's visibility wouldn't be updated until the replay was unpaused (they would be invisible) + if ( m_bCurrentTargetNeedsVisibilityUpdate ) + { + C_BaseEntity *pTarget = ClientEntityList().GetEnt( pCamera->GetPrimaryTargetIndex() ); + if ( pTarget ) + { + pTarget->UpdateVisibility(); + } + + m_bCurrentTargetNeedsVisibilityUpdate = false; + } + // If in free-cam mode, add set view event if we're not paused if ( bInAControllableCameraMode && m_bShownAtLeastOnce && bRecording ) { @@ -2444,12 +2458,14 @@ void CReplayPerformanceEditorPanel::OnCommand( const char *command ) { ReplayCamera()->SetMode( OBS_MODE_IN_EYE ); UpdateCameraSelectionPosition( CAM_FIRST ); + m_bCurrentTargetNeedsVisibilityUpdate = true; g_pReplayPerformanceController->AddEvent_Camera_Change_FirstPerson( flCurTime, nEntIndex ); } else if ( !V_stricmp( pCamType, "third" ) ) { ReplayCamera()->SetMode( OBS_MODE_CHASE ); UpdateCameraSelectionPosition( CAM_THIRD ); + m_bCurrentTargetNeedsVisibilityUpdate = true; g_pReplayPerformanceController->AddEvent_Camera_Change_ThirdPerson( flCurTime, nEntIndex ); AddSetViewEvent(); } @@ -2457,6 +2473,7 @@ void CReplayPerformanceEditorPanel::OnCommand( const char *command ) { ReplayCamera()->SetMode( OBS_MODE_ROAMING ); UpdateCameraSelectionPosition( CAM_FREE ); + m_bCurrentTargetNeedsVisibilityUpdate = true; g_pReplayPerformanceController->AddEvent_Camera_Change_Free( flCurTime ); AddSetViewEvent(); DisplayPerformanceTip( "#Replay_PerfTip_EnterFreeCam", &replay_perftip_count_freecam_enter, MAX_TIP_DISPLAYS ); diff --git a/sp/src/game/client/replay/vgui/replayperformanceeditor.h b/sp/src/game/client/replay/vgui/replayperformanceeditor.h index 50a96d09..034843a3 100644 --- a/sp/src/game/client/replay/vgui/replayperformanceeditor.h +++ b/sp/src/game/client/replay/vgui/replayperformanceeditor.h @@ -224,6 +224,8 @@ private: float m_flActiveTimeInEditor; // Will be zero'd out if user is idle (ie if they don't press space bar often enough) CPanelAnimationVarAliasType( int, m_nRightMarginWidth, "right_margin_width", "0", "proportional_xpos" ); + + bool m_bCurrentTargetNeedsVisibilityUpdate; }; //----------------------------------------------------------------------------- diff --git a/sp/src/game/client/sixense/in_sixense.cpp b/sp/src/game/client/sixense/in_sixense.cpp index 2988201f..e0f4ba39 100644 --- a/sp/src/game/client/sixense/in_sixense.cpp +++ b/sp/src/game/client/sixense/in_sixense.cpp @@ -62,7 +62,7 @@ using sixenseMath::Line; #include "iinput.h" #include "game/client/iviewport.h" #include "filesystem.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #ifdef TF_CLIENT_DLL #include "tf_hud_menu_engy_build.h" diff --git a/sp/src/game/client/view.cpp b/sp/src/game/client/view.cpp index b282b5c3..333a2756 100644 --- a/sp/src/game/client/view.cpp +++ b/sp/src/game/client/view.cpp @@ -36,13 +36,14 @@ #include "materialsystem/itexture.h" #include "materialsystem/imaterialsystem.h" #include "materialsystem/materialsystem_config.h" +#include "VGuiMatSurface/IMatSystemSurface.h" #include "toolframework_client.h" #include "tier0/icommandline.h" #include "ienginevgui.h" #include #include #include "ScreenSpaceEffects.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #include "client_virtualreality.h" #if defined( REPLAY_ENABLED ) @@ -84,10 +85,6 @@ extern ConVar sensitivity; ConVar zoom_sensitivity_ratio( "zoom_sensitivity_ratio", "1.0", 0, "Additional mouse sensitivity scale factor applied when FOV is zoomed in." ); -#ifdef STAGING_ONLY -ConVar vr_stereo_debug_viewport( "vr_stereo_debug_viewport", "0" ); -#endif - CViewRender g_DefaultViewRender; IViewRender *view = NULL; // set in cldll_client_init.cpp if no mod creates their own @@ -301,16 +298,6 @@ void CViewRender::Init( void ) m_pDrawEntities = cvar->FindVar( "r_drawentities" ); m_pDrawBrushModels = cvar->FindVar( "r_drawbrushmodels" ); - if( UseVR() ) - { - m_eStartEye = STEREO_EYE_LEFT; - m_eLastEye = STEREO_EYE_RIGHT; - } - else - { - m_eStartEye = m_eLastEye = STEREO_EYE_MONO; - } - beams->InitBeams(); tempents->Init(); @@ -500,12 +487,18 @@ void CViewRender::DriftPitch (void) StereoEye_t CViewRender::GetFirstEye() const { - return m_eStartEye; + if( UseVR() ) + return STEREO_EYE_LEFT; + else + return STEREO_EYE_MONO; } StereoEye_t CViewRender::GetLastEye() const { - return m_eLastEye; + if( UseVR() ) + return STEREO_EYE_RIGHT; + else + return STEREO_EYE_MONO; } @@ -1177,57 +1170,14 @@ void CViewRender::Render( vrect_t *rect ) } break; + case STEREO_EYE_RIGHT: case STEREO_EYE_LEFT: { -#ifdef STAGING_ONLY - if ( vr_stereo_debug_viewport.GetBool() ) - { - // Stress-test for crazy viewports. - view.width = vr.width * flViewportScale * 0.25f; - view.height = vr.height * flViewportScale * 0.75f; - view.x = vr.x * flViewportScale; - view.y = (vr.y + vr.height * 0.20f) * flViewportScale; - - view.m_nUnscaledWidth = vr.width / 2; - } - else -#endif - { - view.width = vr.width * flViewportScale * 0.5f; - view.height = vr.height * flViewportScale; - view.x = vr.x * flViewportScale ; - view.y = vr.y * flViewportScale; - - view.m_nUnscaledWidth = vr.width / 2; - } - } - break; - - case STEREO_EYE_RIGHT: - { -#ifdef STAGING_ONLY - if ( vr_stereo_debug_viewport.GetBool() ) - { - // Stress-test for crazy viewports. - view.width = vr.width * flViewportScale * 0.75f; - view.height = vr.height * flViewportScale * 0.75f; - view.x = vr.x + vr.width * 0.25f; - view.y = vr.y + vr.height * 0.1f; - - view.m_nUnscaledWidth = vr.width / 2; - view.m_nUnscaledX = vr.x + view.m_nUnscaledWidth; - } - else -#endif - { - view.width = vr.width * flViewportScale * 0.5f; - view.height = vr.height * flViewportScale; - view.x = (vr.x + view.width) * flViewportScale; - view.y = vr.y * flViewportScale; - - view.m_nUnscaledWidth = vr.width / 2; - view.m_nUnscaledX = vr.x + view.m_nUnscaledWidth; - } + g_pSourceVR->GetViewportBounds( (ISourceVirtualReality::VREye)(eEye - 1 ), &view.x, &view.y, &view.width, &view.height ); + view.m_nUnscaledWidth = view.width; + view.m_nUnscaledHeight = view.height; + view.m_nUnscaledX = view.x; + view.m_nUnscaledY = view.y; } break; @@ -1302,9 +1252,32 @@ void CViewRender::Render( vrect_t *rect ) // we should use the monitor view from the left eye for both eyes flags |= RENDERVIEW_SUPPRESSMONITORRENDERING; } - RenderView( view, nClearFlags, flags ); - } + RenderView( view, nClearFlags, flags ); + + if ( UseVR() ) + { + bool bDoUndistort = ! engine->IsTakingScreenshot(); + + if ( bDoUndistort ) + { + g_ClientVirtualReality.PostProcessFrame( eEye ); + } + + // logic here all cloned from code in viewrender.cpp around RenderHUDQuad: + + // figure out if we really want to draw the HUD based on freeze cam + bool bInFreezeCam = ( pPlayer && pPlayer->GetObserverMode() == OBS_MODE_FREEZECAM ); + + // draw the HUD after the view model so its "I'm closer" depth queues work right. + if( !bInFreezeCam && g_ClientVirtualReality.ShouldRenderHUDInWorld() ) + { + // TODO - a bit of a shonky test - basically trying to catch the main menu, the briefing screen, the loadout screen, etc. + bool bTranslucent = !g_pMatSystemSurface->IsCursorVisible(); + g_ClientVirtualReality.OverlayHUDQuadWithUndistort( view, bDoUndistort, g_pClientMode->ShouldBlackoutAroundHUD(), bTranslucent ); + } + } + } // TODO: should these be inside or outside the stereo eye stuff? @@ -1334,15 +1307,6 @@ void CViewRender::Render( vrect_t *rect ) } - if ( UseVR() ) - { - if ( !engine->IsTakingScreenshot() ) - { - // Deal with the distortion on the display. - g_ClientVirtualReality.PostProcessFrame( rect ); - } - } - } diff --git a/sp/src/game/client/view_scene.cpp b/sp/src/game/client/view_scene.cpp index 73c05a2b..098e9ae9 100644 --- a/sp/src/game/client/view_scene.cpp +++ b/sp/src/game/client/view_scene.cpp @@ -11,7 +11,7 @@ #include "rendertexture.h" #include "view_scene.h" #include "viewrender.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #include "client_virtualreality.h" // memdbgon must be the last include file in a .cpp file!!! diff --git a/sp/src/game/client/viewpostprocess.cpp b/sp/src/game/client/viewpostprocess.cpp index 7fe7c40d..3f74acdc 100644 --- a/sp/src/game/client/viewpostprocess.cpp +++ b/sp/src/game/client/viewpostprocess.cpp @@ -834,7 +834,7 @@ void CLuminanceHistogramSystem::UpdateLuminanceRanges( void ) s_bFirstTime = false; // This seems like a bad idea but it's fine for now - const char *sModsForOriginalAlgorithm[] = { "dod", "cstrike", "lostcoast" }; + const char *sModsForOriginalAlgorithm[] = { "dod", "cstrike", "lostcoast", "hl1" }; for ( int i=0; i<3; i++ ) { if ( strlen( engine->GetGameDirectory() ) >= strlen( sModsForOriginalAlgorithm[i] ) ) diff --git a/sp/src/game/client/viewrender.cpp b/sp/src/game/client/viewrender.cpp index 7422479b..a9ef4eb8 100644 --- a/sp/src/game/client/viewrender.cpp +++ b/sp/src/game/client/viewrender.cpp @@ -51,7 +51,7 @@ #include "studio_stats.h" #include "con_nprint.h" #include "clientmode_shared.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #include "client_virtualreality.h" #ifdef PORTAL @@ -394,7 +394,7 @@ protected: bool GetSkyboxFogEnable(); void Enable3dSkyboxFog( void ); - void DrawInternal( view_id_t iSkyBoxViewID = VIEW_3DSKY, bool bInvokePreAndPostRender = true, ITexture *pRenderTarget = NULL ); + void DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostRender, ITexture *pRenderTarget, ITexture *pDepthTarget ); sky3dparams_t * PreRender3dSkyboxWorld( SkyboxVisibility_t nSkyboxVisible ); @@ -1055,7 +1055,15 @@ void CViewRender::DrawViewModels( const CViewSetup &view, bool drawViewmodel ) viewModelSetup.fov = view.fovViewmodel; viewModelSetup.m_flAspectRatio = engine->GetScreenAspectRatio(); - render->Push3DView( viewModelSetup, 0, NULL, GetFrustum() ); + ITexture *pRTColor = NULL; + ITexture *pRTDepth = NULL; + if( view.m_eStereoEye != STEREO_EYE_MONO ) + { + pRTColor = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(view.m_eStereoEye-1), ISourceVirtualReality::RT_Color ); + pRTDepth = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(view.m_eStereoEye-1), ISourceVirtualReality::RT_Depth ); + } + + render->Push3DView( viewModelSetup, 0, pRTColor, GetFrustum(), pRTDepth ); #ifdef PORTAL //the depth range hack doesn't work well enough for the portal mod (and messing with the depth hack values makes some models draw incorrectly) //step up to a full depth clear if we're extremely close to a portal (in a portal environment) @@ -1822,7 +1830,15 @@ void CViewRender::SetupMain3DView( const CViewSetup &view, int &nClearFlags ) } else { - render->Push3DView( view, nClearFlags, NULL, GetFrustum() ); + ITexture *pRTColor = NULL; + ITexture *pRTDepth = NULL; + if( view.m_eStereoEye != STEREO_EYE_MONO ) + { + pRTColor = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(view.m_eStereoEye-1), ISourceVirtualReality::RT_Color ); + pRTDepth = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(view.m_eStereoEye-1), ISourceVirtualReality::RT_Depth ); + } + + render->Push3DView( view, nClearFlags, pRTColor, GetFrustum(), pRTDepth ); } // If we didn't clear the depth here, we'll need to clear it later @@ -2155,6 +2171,12 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT pCopyMaterial->DecrementReferenceCount(); } + // if we're in VR mode we might need to override the render target + if( UseVR() ) + { + saveRenderTarget = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(view.m_eStereoEye - 1), ISourceVirtualReality::RT_Color ); + } + // Draw the 2D graphics render->Push2DView( view, 0, saveRenderTarget, GetFrustum() ); @@ -2192,7 +2214,9 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT vgui::surface()->GetScreenSize( viewWidth, viewHeight ); - viewFramebufferX = view.m_eStereoEye == STEREO_EYE_RIGHT ? viewFramebufferWidth : 0; + viewFramebufferX = 0; + if( view.m_eStereoEye == STEREO_EYE_RIGHT && !saveRenderTarget ) + viewFramebufferX = viewFramebufferWidth; viewFramebufferY = 0; } } @@ -2224,7 +2248,7 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT // let vgui know where to render stuff for the forced-to-framebuffer panels if( UseVR() ) { - vgui::surface()->SetFullscreenViewport( viewFramebufferX, viewFramebufferY, viewFramebufferWidth, viewFramebufferHeight ); + vgui::surface()->SetFullscreenViewportAndRenderTarget( viewFramebufferX, viewFramebufferY, viewFramebufferWidth, viewFramebufferHeight, saveRenderTarget ); } // clear the render target if we need to @@ -4703,7 +4727,7 @@ sky3dparams_t *CSkyboxView::PreRender3dSkyboxWorld( SkyboxVisibility_t nSkyboxVi //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostRender, ITexture *pRenderTarget ) +void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostRender, ITexture *pRenderTarget, ITexture *pDepthTarget ) { unsigned char **areabits = render->GetAreaBits(); unsigned char *savebits; @@ -4736,7 +4760,7 @@ void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostR // cluster with sky. Then we could just connect the areas to do our vis. //m_bOverrideVisOrigin could hose us here, so call direct render->ViewSetupVis( false, 1, &m_pSky3dParams->origin.Get() ); - render->Push3DView( (*this), m_ClearFlags, pRenderTarget, GetFrustum() ); + render->Push3DView( (*this), m_ClearFlags, pRenderTarget, GetFrustum(), pDepthTarget ); // Store off view origin and angles SetupCurrentView( origin, angles, iSkyBoxViewID ); @@ -4832,7 +4856,15 @@ void CSkyboxView::Draw() { VPROF_BUDGET( "CViewRender::Draw3dSkyboxworld", "3D Skybox" ); - DrawInternal(); + ITexture *pRTColor = NULL; + ITexture *pRTDepth = NULL; + if( m_eStereoEye != STEREO_EYE_MONO ) + { + pRTColor = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(m_eStereoEye-1), ISourceVirtualReality::RT_Color ); + pRTDepth = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(m_eStereoEye-1), ISourceVirtualReality::RT_Depth ); + } + + DrawInternal(VIEW_3DSKY, true, pRTColor, pRTDepth ); } @@ -4882,7 +4914,7 @@ void CPortalSkyboxView::Draw() bool bInvokePreAndPostRender = ( g_pPortalRender->ShouldUseStencilsToRenderPortals() == false ); - DrawInternal( iSkyBoxViewID, bInvokePreAndPostRender, m_pRenderTarget ); + DrawInternal( iSkyBoxViewID, bInvokePreAndPostRender, m_pRenderTarget, NULL ); pRenderContext->EnableClipping( bClippingEnabled ); diff --git a/sp/src/game/client/viewrender.h b/sp/src/game/client/viewrender.h index d9901237..723c3222 100644 --- a/sp/src/game/client/viewrender.h +++ b/sp/src/game/client/viewrender.h @@ -474,10 +474,6 @@ private: // This stores the current view CViewSetup m_CurrentView; - // these will both be mono or they will be left/right - StereoEye_t m_eStartEye; - StereoEye_t m_eLastEye; - // VIS Overrides // Set to true to turn off client side vis ( !!!! rendering will be slow since everything will draw ) bool m_bForceNoVis; diff --git a/sp/src/game/protobuf_include.vpc b/sp/src/game/protobuf_include.vpc index c7290fe3..c4fe5022 100644 --- a/sp/src/game/protobuf_include.vpc +++ b/sp/src/game/protobuf_include.vpc @@ -10,6 +10,8 @@ $Project { $Folder "Libraries" { - $Libexternal libprotobuf + $Libexternal libprotobuf [!$VS2012 && !$VS2013] + $Libexternal 2012\libprotobuf [$VS2012] + $Libexternal 2013\libprotobuf [$VS2013] } } diff --git a/sp/src/game/server/ai_activity.cpp b/sp/src/game/server/ai_activity.cpp index 463c8942..a476a9f3 100644 --- a/sp/src/game/server/ai_activity.cpp +++ b/sp/src/game/server/ai_activity.cpp @@ -2153,4 +2153,8 @@ void CAI_BaseNPC::InitDefaultActivitySR(void) ADD_ACTIVITY_TO_SR( ACT_THROWABLE_VM_IDLE ); ADD_ACTIVITY_TO_SR( ACT_THROWABLE_VM_FIRE ); + ADD_ACTIVITY_TO_SR( ACT_SPELL_VM_DRAW ); + ADD_ACTIVITY_TO_SR( ACT_SPELL_VM_IDLE ); + ADD_ACTIVITY_TO_SR( ACT_SPELL_VM_ARM ); + ADD_ACTIVITY_TO_SR( ACT_SPELL_VM_FIRE ); } diff --git a/sp/src/game/server/ai_movesolver.cpp b/sp/src/game/server/ai_movesolver.cpp index 1dc81849..101056a7 100644 --- a/sp/src/game/server/ai_movesolver.cpp +++ b/sp/src/game/server/ai_movesolver.cpp @@ -15,7 +15,7 @@ //----------------------------------------------------------------------------- -inline float round( float f ) +inline float V_round( float f ) { return (float)( (int)( f + 0.5 ) ); } @@ -133,7 +133,7 @@ bool CAI_MoveSolver::Solve( const AI_MoveSuggestion_t *pSuggestions, int nSugges // Convert arc values to solution indices relative to right post. Right is angle down, left is angle up. float halfSpan = current.arc.span * 0.5; - int center = round( ( halfSpan * NUM_SOLUTIONS ) / 360 ); + int center = V_round( ( halfSpan * NUM_SOLUTIONS ) / 360 ); int left = ( current.arc.span * NUM_SOLUTIONS ) / 360; float angRight = current.arc.center - halfSpan; diff --git a/sp/src/game/server/ai_networkmanager.cpp b/sp/src/game/server/ai_networkmanager.cpp index 7f6bea61..21a6f9de 100644 --- a/sp/src/game/server/ai_networkmanager.cpp +++ b/sp/src/game/server/ai_networkmanager.cpp @@ -983,7 +983,7 @@ bool CAI_NetworkManager::IsAIFileCurrent ( const char *szMapName ) Q_strncpy( szLoweredGameDir, pGameDir, sizeof( szLoweredGameDir ) ); Q_strlower( szLoweredGameDir ); - if ( !V_stricmp( szLoweredGameDir, "hl2" ) || !V_stricmp( szLoweredGameDir, "episodic" ) || !V_stricmp( szLoweredGameDir, "ep2" ) || !V_stricmp( szLoweredGameDir, "portal" ) || !V_stricmp( szLoweredGameDir, "lostcoast" ) ) + if ( !V_stricmp( szLoweredGameDir, "hl2" ) || !V_stricmp( szLoweredGameDir, "episodic" ) || !V_stricmp( szLoweredGameDir, "ep2" ) || !V_stricmp( szLoweredGameDir, "portal" ) || !V_stricmp( szLoweredGameDir, "lostcoast" ) || !V_stricmp( szLoweredGameDir, "hl1" ) ) { // we shipped good node graphs for our games return true; diff --git a/sp/src/game/server/baseanimating.cpp b/sp/src/game/server/baseanimating.cpp index 2e1e3a22..34bf6378 100644 --- a/sp/src/game/server/baseanimating.cpp +++ b/sp/src/game/server/baseanimating.cpp @@ -210,6 +210,9 @@ BEGIN_DATADESC( CBaseAnimating ) DEFINE_INPUT( m_fadeMaxDist, FIELD_FLOAT, "fademaxdist" ), DEFINE_KEYFIELD( m_flFadeScale, FIELD_FLOAT, "fadescale" ), + DEFINE_KEYFIELD( m_flModelScale, FIELD_FLOAT, "modelscale" ), + DEFINE_INPUTFUNC( FIELD_VECTOR, "SetModelScale", InputSetModelScale ), + DEFINE_FIELD( m_fBoneCacheFlags, FIELD_SHORT ), END_DATADESC() @@ -441,7 +444,7 @@ void CBaseAnimating::StudioFrameAdvanceInternal( CStudioHdr *pStudioHdr, float f m_flAnimTime.Get(), m_flPrevAnimTime, flInterval, GetCycle() ); */ - m_flGroundSpeed = GetSequenceGroundSpeed( pStudioHdr, GetSequence() ); + m_flGroundSpeed = GetSequenceGroundSpeed( pStudioHdr, GetSequence() ) * GetModelScale(); // Msg("%s : %s : %5.1f\n", GetClassname(), GetSequenceName( GetSequence() ), GetCycle() ); InvalidatePhysicsRecursive( ANIMATION_CHANGED ); @@ -610,6 +613,17 @@ void CBaseAnimating::InputSetLightingOrigin( inputdata_t &inputdata ) SetLightingOrigin( strLightingOrigin ); } +//----------------------------------------------------------------------------- +// Purpose: SetModelScale input handler +//----------------------------------------------------------------------------- +void CBaseAnimating::InputSetModelScale( inputdata_t &inputdata ) +{ + Vector vecScale; + inputdata.value.Vector3D( vecScale ); + + SetModelScale( vecScale.x, vecScale.y ); +} + //========================================================= // SelectWeightedSequence @@ -877,7 +891,7 @@ void CBaseAnimating::ResetSequenceInfo ( ) } CStudioHdr *pStudioHdr = GetModelPtr(); - m_flGroundSpeed = GetSequenceGroundSpeed( pStudioHdr, GetSequence() ); + m_flGroundSpeed = GetSequenceGroundSpeed( pStudioHdr, GetSequence() ) * GetModelScale(); m_bSequenceLoops = ((GetSequenceFlags( pStudioHdr, GetSequence() ) & STUDIO_LOOPING) != 0); // m_flAnimTime = gpGlobals->time; m_flPlaybackRate = 1.0; diff --git a/sp/src/game/server/baseanimating.h b/sp/src/game/server/baseanimating.h index 5f8a019a..75300e8e 100644 --- a/sp/src/game/server/baseanimating.h +++ b/sp/src/game/server/baseanimating.h @@ -338,6 +338,7 @@ private: void StudioFrameAdvanceInternal( CStudioHdr *pStudioHdr, float flInterval ); void InputSetLightingOriginRelative( inputdata_t &inputdata ); void InputSetLightingOrigin( inputdata_t &inputdata ); + void InputSetModelScale( inputdata_t &inputdata ); bool CanSkipAnimation( void ); diff --git a/sp/src/game/server/baseentity.cpp b/sp/src/game/server/baseentity.cpp index edc00977..52316924 100644 --- a/sp/src/game/server/baseentity.cpp +++ b/sp/src/game/server/baseentity.cpp @@ -4524,6 +4524,17 @@ void CBaseEntity::Teleport( const Vector *newPosition, const QAngle *newAngles, teleportList[i].pEntity->CollisionRulesChanged(); } + if ( IsPlayer() ) + { + // Tell the client being teleported + IGameEvent *event = gameeventmanager->CreateEvent( "base_player_teleported" ); + if ( event ) + { + event->SetInt( "entindex", entindex() ); + gameeventmanager->FireEventClientSide( event ); + } + } + Assert( g_TeleportStack[index] == this ); g_TeleportStack.FastRemove( index ); diff --git a/sp/src/game/server/basemultiplayerplayer.cpp b/sp/src/game/server/basemultiplayerplayer.cpp index 031282ac..b6ecd44c 100644 --- a/sp/src/game/server/basemultiplayerplayer.cpp +++ b/sp/src/game/server/basemultiplayerplayer.cpp @@ -132,7 +132,15 @@ bool CBaseMultiplayerPlayer::CanHearAndReadChatFrom( CBasePlayer *pPlayer ) //----------------------------------------------------------------------------- bool CBaseMultiplayerPlayer::ShouldRunRateLimitedCommand( const CCommand &args ) { - const char *pcmd = args[0]; + return ShouldRunRateLimitedCommand( args[0] ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CBaseMultiplayerPlayer::ShouldRunRateLimitedCommand( const char *pszCommand ) +{ + const char *pcmd = pszCommand; int i = m_RateLimitLastCommandTimes.Find( pcmd ); if ( i == m_RateLimitLastCommandTimes.InvalidIndex() ) diff --git a/sp/src/game/server/basemultiplayerplayer.h b/sp/src/game/server/basemultiplayerplayer.h index 5f9b9519..06a0e00d 100644 --- a/sp/src/game/server/basemultiplayerplayer.h +++ b/sp/src/game/server/basemultiplayerplayer.h @@ -89,6 +89,7 @@ public: // Command rate limiting. bool ShouldRunRateLimitedCommand( const CCommand &args ); + bool ShouldRunRateLimitedCommand( const char *pszCommand ); protected: virtual CAI_Expresser *CreateExpresser( void ); diff --git a/sp/src/game/server/baseprojectile.cpp b/sp/src/game/server/baseprojectile.cpp deleted file mode 100644 index 30d92fec..00000000 --- a/sp/src/game/server/baseprojectile.cpp +++ /dev/null @@ -1,136 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//============================================================================= - -#include "cbase.h" -#include "baseprojectile.h" - -BEGIN_DATADESC( CBaseProjectile ) - DEFINE_FIELD( m_flDamage, FIELD_FLOAT ), - DEFINE_FIELD( m_iDamageType, FIELD_INTEGER ), - DEFINE_FIELD( m_flDamageScale, FIELD_FLOAT ), - - DEFINE_FUNCTION( ProjectileTouch ), - DEFINE_THINKFUNC( FlyThink ), -END_DATADESC() - -LINK_ENTITY_TO_CLASS( proj_base, CBaseProjectile ); - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -void CBaseProjectile::Spawn( void ) -{ - Precache(); - - SetModel( STRING( GetModelName() ) ); - - SetSolid( SOLID_BBOX ); - SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_CUSTOM ); - AddFlag( FL_OBJECT ); - - UTIL_SetSize( this, -Vector( 1.0f, 1.0f, 1.0f ), Vector( 1.0f, 1.0f, 1.0f ) ); - - // Setup attributes. - SetGravity( 0.001f ); - m_takedamage = DAMAGE_NO; - - // Setup the touch and think functions. - SetTouch( &CBaseProjectile::ProjectileTouch ); - SetThink( &CBaseProjectile::FlyThink ); - SetNextThink( gpGlobals->curtime ); -} - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -void CBaseProjectile::Precache( void ) -{ - BaseClass::Precache(); - - PrecacheModel( STRING( GetModelName() ) ); -} - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -CBaseProjectile *CBaseProjectile::Create( baseprojectilecreate_t &pCreate ) -{ - CBaseProjectile *pProjectile = static_cast( CBaseEntity::CreateNoSpawn( "proj_base", pCreate.vecOrigin, vec3_angle, pCreate.pOwner ) ); - if ( !pProjectile ) - return NULL; - - pProjectile->SetModelName( pCreate.iszModel ); - pProjectile->SetDamage( pCreate.flDamage ); - pProjectile->SetDamageType( pCreate.iDamageType ); - pProjectile->SetDamageScale( pCreate.flDamageScale ); - pProjectile->SetAbsVelocity( pCreate.vecVelocity ); - - // Setup the initial angles. - QAngle angles; - VectorAngles( -pCreate.vecVelocity, angles ); - pProjectile->SetAbsAngles( angles ); - - // Spawn & Activate - DispatchSpawn( pProjectile ); - pProjectile->Activate(); - - return pProjectile; -} - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -unsigned int CBaseProjectile::PhysicsSolidMaskForEntity( void ) const -{ - return BaseClass::PhysicsSolidMaskForEntity() | CONTENTS_HITBOX; -} - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -void CBaseProjectile::ProjectileTouch( CBaseEntity *pOther ) -{ - // Verify a correct "other." - Assert( pOther ); - if ( !pOther->IsSolid() || pOther->IsSolidFlagSet( FSOLID_VOLUME_CONTENTS ) ) - return; - - // Handle hitting skybox (disappear). - const trace_t *pTrace = &CBaseEntity::GetTouchTrace(); - trace_t *pNewTrace = const_cast( pTrace ); - - if( pTrace->surface.flags & SURF_SKY ) - { - UTIL_Remove( this ); - return; - } - - CTakeDamageInfo info; - info.SetAttacker( GetOwnerEntity() ); - info.SetInflictor( this ); - info.SetDamage( GetDamage() ); - info.SetDamageType( GetDamageType() ); - CalculateMeleeDamageForce( &info, GetAbsVelocity(), GetAbsOrigin(), GetDamageScale() ); - - Vector dir; - AngleVectors( GetAbsAngles(), &dir ); - - pOther->DispatchTraceAttack( info, dir, pNewTrace ); - ApplyMultiDamage(); - - UTIL_Remove( this ); -} - -//----------------------------------------------------------------------------- -// Purpose: Orient the projectile along its velocity -//----------------------------------------------------------------------------- -void CBaseProjectile::FlyThink( void ) -{ - QAngle angles; - VectorAngles( -(GetAbsVelocity()), angles ); - SetAbsAngles( angles ); - SetNextThink( gpGlobals->curtime + 0.1f ); -} diff --git a/sp/src/game/server/baseprojectile.h b/sp/src/game/server/baseprojectile.h deleted file mode 100644 index 51bd04f7..00000000 --- a/sp/src/game/server/baseprojectile.h +++ /dev/null @@ -1,61 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//============================================================================= - -#ifndef BASEPROJECTILE_H -#define BASEPROJECTILE_H -#ifdef _WIN32 -#pragma once -#endif - -// Creation. -struct baseprojectilecreate_t -{ - Vector vecOrigin; - Vector vecVelocity; - CBaseEntity *pOwner; - string_t iszModel; - float flDamage; - int iDamageType; - float flDamageScale; -}; - -//============================================================================= -// -// Generic projectile -// -class CBaseProjectile : public CBaseAnimating -{ - DECLARE_CLASS( CBaseProjectile, CBaseAnimating ); -public: - DECLARE_DATADESC(); - - void Spawn( void ); - void Precache( void ); - - static CBaseProjectile *Create( baseprojectilecreate_t &pCreate ); - - void SetDamage( float flDamage ) { m_flDamage = flDamage; } - void SetDamageScale( float &flScale ) { m_flDamageScale = flScale; } - void SetDamageType( int iType ) { m_iDamageType = iType; } - -private: - // Damage - virtual float GetDamage() { return m_flDamage; } - virtual float GetDamageScale( void ) { return m_flDamageScale; } - virtual int GetDamageType( void ) { return m_iDamageType; } - - unsigned int PhysicsSolidMaskForEntity( void ) const; - - virtual void ProjectileTouch( CBaseEntity *pOther ); - void FlyThink( void ); - -protected: - float m_flDamage; - int m_iDamageType; - float m_flDamageScale; -}; - -#endif // BASEPROJECTILE_H diff --git a/sp/src/game/server/basetempentity.cpp b/sp/src/game/server/basetempentity.cpp index 45bd600a..a238397e 100644 --- a/sp/src/game/server/basetempentity.cpp +++ b/sp/src/game/server/basetempentity.cpp @@ -118,7 +118,7 @@ void CBaseTempEntity::PrecacheTempEnts( void ) void CBaseTempEntity::Create( IRecipientFilter& filter, float delay ) { // temp entities can't be reliable or part of the signon message, use real entities instead - Assert( !filter.IsInitMessage() && !filter.IsInitMessage() ); + Assert( !filter.IsReliable() && !filter.IsInitMessage() ); Assert( delay >= -1 && delay <= 1); // 1 second max delay engine->PlaybackTempEntity( filter, delay, diff --git a/sp/src/game/server/entity_tools_server.cpp b/sp/src/game/server/entity_tools_server.cpp index e1888123..5032ca04 100644 --- a/sp/src/game/server/entity_tools_server.cpp +++ b/sp/src/game/server/entity_tools_server.cpp @@ -409,13 +409,39 @@ void CC_Ent_Keyvalue( const CCommand &args ) return; } - int nID = atoi( args[1] ); - - CBaseEntity *pEnt = g_ServerTools.FindEntityByHammerID( nID ); - if ( !pEnt ) + CBasePlayer *pPlayer = ToBasePlayer( UTIL_GetCommandClient() ); + CBaseEntity *pEnt; + if ( FStrEq( args[1], "" ) || FStrEq( args[1], "!picker" ) ) { - Msg( "Entity ID %d not found.\n", nID ); - return; + if (!pPlayer) + return; + + extern CBaseEntity *FindPickerEntity( CBasePlayer *pPlayer ); + pEnt = FindPickerEntity( pPlayer ); + + if ( !pEnt ) + { + ClientPrint( pPlayer, HUD_PRINTCONSOLE, "No entity in front of player.\n" ); + return; + } + } + else if ( FStrEq( args[1], "!self" ) || FStrEq( args[1], "!caller" ) || FStrEq( args[1], "!activator" ) ) + { + if (!pPlayer) + return; + + pEnt = pPlayer; + } + else + { + int nID = atoi( args[1] ); + + pEnt = g_ServerTools.FindEntityByHammerID( nID ); + if ( !pEnt ) + { + Msg( "Entity ID %d not found.\n", nID ); + return; + } } int nArg = 2; diff --git a/sp/src/game/server/hl1_CBaseHelicopter.h b/sp/src/game/server/hl1_CBaseHelicopter.h index 1e3c1044..01586126 100644 --- a/sp/src/game/server/hl1_CBaseHelicopter.h +++ b/sp/src/game/server/hl1_CBaseHelicopter.h @@ -84,7 +84,7 @@ public: int OnTakeDamage_Alive( const CTakeDamageInfo &info ); - void TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr ); + void TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator ); virtual bool FireGun( void ); diff --git a/sp/src/game/server/hl2/hl2_player.cpp b/sp/src/game/server/hl2/hl2_player.cpp index 1659fe31..e7583f5a 100644 --- a/sp/src/game/server/hl2/hl2_player.cpp +++ b/sp/src/game/server/hl2/hl2_player.cpp @@ -169,7 +169,7 @@ bool Flashlight_UseLegacyVersion( void ) g_bUseLegacyFlashlight = ( !Q_strcmp( modDir, "hl2" ) || !Q_strcmp( modDir, "episodic" ) || - !Q_strcmp( modDir, "lostcoast" )); + !Q_strcmp( modDir, "lostcoast" ) || !Q_strcmp( modDir, "hl1" )); g_bCacheLegacyFlashlightStatus = false; } diff --git a/sp/src/game/server/logicrelay.h b/sp/src/game/server/logicrelay.h index a91a456e..8d082acc 100644 --- a/sp/src/game/server/logicrelay.h +++ b/sp/src/game/server/logicrelay.h @@ -36,6 +36,8 @@ public: // Outputs COutputEvent m_OnTrigger; COutputEvent m_OnSpawn; + + bool IsDisabled( void ){ return m_bDisabled; } private: diff --git a/sp/src/game/server/nav_mesh.cpp b/sp/src/game/server/nav_mesh.cpp index eae35c8d..8a15b39e 100644 --- a/sp/src/game/server/nav_mesh.cpp +++ b/sp/src/game/server/nav_mesh.cpp @@ -630,9 +630,10 @@ void CNavMesh::OnRoundRestart( void ) } // attach prerequisites - CFuncNavPrerequisite *prereq = NULL; - while( ( prereq = (CFuncNavPrerequisite *)gEntList.FindEntityByClassname( prereq, "func_nav_prerequisite" ) ) != NULL ) + for ( int i=0; i( IFuncNavPrerequisiteAutoList::AutoList()[i] ); + Extent prereqExtent; prereqExtent.Init( prereq ); diff --git a/sp/src/game/server/player.cpp b/sp/src/game/server/player.cpp index abda12b4..73aab6d6 100644 --- a/sp/src/game/server/player.cpp +++ b/sp/src/game/server/player.cpp @@ -442,6 +442,7 @@ BEGIN_DATADESC( CBasePlayer ) DEFINE_INPUTFUNC( FIELD_INTEGER, "SetHealth", InputSetHealth ), DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetHUDVisibility", InputSetHUDVisibility ), DEFINE_INPUTFUNC( FIELD_STRING, "SetFogController", InputSetFogController ), + DEFINE_INPUTFUNC( FIELD_STRING, "HandleMapEvent", InputHandleMapEvent ), DEFINE_FIELD( m_nNumCrouches, FIELD_INTEGER ), DEFINE_FIELD( m_bDuckToggled, FIELD_BOOLEAN ), @@ -911,7 +912,7 @@ void CBasePlayer::TraceAttack( const CTakeDamageInfo &inputInfo, const Vector &v // Prevent team damage here so blood doesn't appear if ( info.GetAttacker()->IsPlayer() ) { - if ( !g_pGameRules->FPlayerCanTakeDamage( this, info.GetAttacker() ) ) + if ( !g_pGameRules->FPlayerCanTakeDamage( this, info.GetAttacker(), info ) ) return; } } @@ -1121,7 +1122,7 @@ int CBasePlayer::OnTakeDamage( const CTakeDamageInfo &inputInfo ) // go take the damage first - if ( !g_pGameRules->FPlayerCanTakeDamage( this, info.GetAttacker() ) ) + if ( !g_pGameRules->FPlayerCanTakeDamage( this, info.GetAttacker(), inputInfo ) ) { // Refuse the damage return 0; @@ -8642,6 +8643,14 @@ void CBasePlayer::InputSetHealth( inputdata_t &inputdata ) } } +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CBasePlayer::InputHandleMapEvent( inputdata_t &inputdata ) +{ + Internal_HandleMapEvent( inputdata ); +} + //----------------------------------------------------------------------------- // Purpose: Hides or displays the HUD // Input : &inputdata - diff --git a/sp/src/game/server/player.h b/sp/src/game/server/player.h index 8cd1d0fa..ddbd4416 100644 --- a/sp/src/game/server/player.h +++ b/sp/src/game/server/player.h @@ -765,6 +765,7 @@ public: //--------------------------------- void InputSetHealth( inputdata_t &inputdata ); void InputSetHUDVisibility( inputdata_t &inputdata ); + void InputHandleMapEvent( inputdata_t &inputdata ); surfacedata_t *GetSurfaceData( void ) { return m_pSurfaceData; } void SetLadderNormal( Vector vecLadderNormal ) { m_vecLadderNormal = vecLadderNormal; } @@ -903,6 +904,8 @@ protected: void CalcObserverView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov ); void CalcViewModelView( const Vector& eyeOrigin, const QAngle& eyeAngles); + virtual void Internal_HandleMapEvent( inputdata_t &inputdata ){} + // FIXME: Make these private! (tf_player uses them) // Secondary point to derive PVS from when zoomed in with binoculars/sniper rifle. The PVS is diff --git a/sp/src/game/server/player_lagcompensation.cpp b/sp/src/game/server/player_lagcompensation.cpp index 0fafb2a7..08503652 100644 --- a/sp/src/game/server/player_lagcompensation.cpp +++ b/sp/src/game/server/player_lagcompensation.cpp @@ -770,10 +770,12 @@ void CLagCompensationManager::FinishLagCompensation( CBasePlayer *player ) // Restore it pPlayer->SetSize( restore->m_vecMinsPreScaled, restore->m_vecMaxsPreScaled ); } +#ifdef STAGING_ONLY else { Warning( "Should we really not restore the size?\n" ); } +#endif } if ( restore->m_fFlags & LC_ANGLES_CHANGED ) diff --git a/sp/src/game/server/server_base.vpc b/sp/src/game/server/server_base.vpc index 6445e07d..f1c3c835 100644 --- a/sp/src/game/server/server_base.vpc +++ b/sp/src/game/server/server_base.vpc @@ -245,6 +245,8 @@ $Project $File "$SRCDIR\game\shared\baseparticleentity.h" $File "$SRCDIR\game\shared\baseplayer_shared.cpp" $File "$SRCDIR\game\shared\baseplayer_shared.h" + $File "$SRCDIR\game\shared\baseprojectile.cpp" + $File "$SRCDIR\game\shared\baseprojectile.h" $File "BasePropDoor.h" $File "basetoggle.h" $File "baseviewmodel.cpp" diff --git a/sp/src/game/server/team_control_point_master.cpp b/sp/src/game/server/team_control_point_master.cpp index f60939a7..8ad9796d 100644 --- a/sp/src/game/server/team_control_point_master.cpp +++ b/sp/src/game/server/team_control_point_master.cpp @@ -841,16 +841,6 @@ void CTeamControlPointMaster::InputRoundSpawn( inputdata_t &input ) FindControlPointRounds(); SetBaseControlPoints(); - - // init the ClientAreas - int index = 0; - - for ( int i=0; i( ITriggerAreaCaptureAutoList::AutoList()[i] ); - pArea->SetAreaIndex( index ); - index++; - } ObjectiveResource()->ResetControlPoints(); } diff --git a/sp/src/game/server/team_train_watcher.cpp b/sp/src/game/server/team_train_watcher.cpp index dba231af..b8ef36c3 100644 --- a/sp/src/game/server/team_train_watcher.cpp +++ b/sp/src/game/server/team_train_watcher.cpp @@ -72,6 +72,7 @@ BEGIN_DATADESC( CTeamTrainWatcher ) DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), DEFINE_INPUTFUNC( FIELD_FLOAT, "SetSpeedForwardModifier", InputSetSpeedForwardModifier ), DEFINE_INPUTFUNC( FIELD_INTEGER, "SetTrainRecedeTime", InputSetTrainRecedeTime ), + DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetTrainCanRecede", InputSetTrainCanRecede ), // Outputs DEFINE_OUTPUT( m_OnTrainStartRecede, "OnTrainStartRecede" ), @@ -141,6 +142,9 @@ END_SEND_TABLE() LINK_ENTITY_TO_CLASS( team_train_watcher, CTeamTrainWatcher ); + +IMPLEMENT_AUTO_LIST( ITFTeamTrainWatcher ); + /* LINK_ENTITY_TO_CLASS( team_train_watcher_master, CTeamTrainWatcherMaster ); PRECACHE_REGISTER( team_train_watcher_master ); @@ -710,6 +714,11 @@ void CTeamTrainWatcher::InputSetTrainRecedeTime( inputdata_t &inputdata ) } } +void CTeamTrainWatcher::InputSetTrainCanRecede( inputdata_t &inputdata ) +{ + m_bTrainCanRecede = inputdata.value.Bool(); +} + void CTeamTrainWatcher::InputOnStartOvertime( inputdata_t &inputdata ) { // recalculate the recede time diff --git a/sp/src/game/server/team_train_watcher.h b/sp/src/game/server/team_train_watcher.h index 0bb9b2a6..22b82c6f 100644 --- a/sp/src/game/server/team_train_watcher.h +++ b/sp/src/game/server/team_train_watcher.h @@ -34,7 +34,9 @@ class CTeamControlPoint; // #define TWMASTER_THINK "CTeamTrainWatcherMasterThink" -class CTeamTrainWatcher : public CBaseEntity, public CGameEventListener +DECLARE_AUTO_LIST( ITFTeamTrainWatcher ); + +class CTeamTrainWatcher : public CBaseEntity, public CGameEventListener, public ITFTeamTrainWatcher { DECLARE_CLASS( CTeamTrainWatcher, CBaseEntity ); public: @@ -55,6 +57,7 @@ public: void InputOnStartOvertime( inputdata_t &inputdata ); void InputSetSpeedForwardModifier( inputdata_t &inputdata ); void InputSetTrainRecedeTime( inputdata_t &inputdata ); + void InputSetTrainCanRecede( inputdata_t &inputdata ); // ========================================================== // given a start node and a list of goal nodes diff --git a/sp/src/game/server/trains.cpp b/sp/src/game/server/trains.cpp index 639523b9..bf01ae6f 100644 --- a/sp/src/game/server/trains.cpp +++ b/sp/src/game/server/trains.cpp @@ -1646,7 +1646,7 @@ static CBaseEntity *FindPhysicsBlockerForHierarchy( CBaseEntity *pParentEntity ) { IPhysicsObject *pOther = pSnapshot->GetObject(1); CBaseEntity *pOtherEntity = static_cast(pOther->GetGameData()); - if ( pOtherEntity->GetMoveType() == MOVETYPE_VPHYSICS ) + if ( pOtherEntity && pOtherEntity->GetMoveType() == MOVETYPE_VPHYSICS ) { Vector normal; pSnapshot->GetSurfaceNormal(normal); diff --git a/sp/src/game/server/trigger_area_capture.cpp b/sp/src/game/server/trigger_area_capture.cpp index 177e7701..2839200b 100644 --- a/sp/src/game/server/trigger_area_capture.cpp +++ b/sp/src/game/server/trigger_area_capture.cpp @@ -43,7 +43,6 @@ BEGIN_DATADESC(CTriggerAreaCapture) // DEFINE_FIELD( m_TeamData, CUtlVector < perteamdata_t > ), // DEFINE_FIELD( m_Blockers, CUtlVector < blockers_t > ), // DEFINE_FIELD( m_bActive, FIELD_BOOLEAN ), -// DEFINE_FIELD( m_iAreaIndex, FIELD_INTEGER ), // DEFINE_FIELD( m_hPoint, CHandle < CTeamControlPoint > ), // DEFINE_FIELD( m_bRequiresObject, FIELD_BOOLEAN ), // DEFINE_FIELD( m_iCapAttemptNumber, FIELD_INTEGER ), @@ -96,8 +95,6 @@ void CTriggerAreaCapture::Spawn( void ) Precache(); - m_iAreaIndex = -1; - SetTouch ( &CTriggerAreaCaptureShim::Touch ); SetThink( &CTriggerAreaCapture::CaptureThink ); SetNextThink( gpGlobals->curtime + AREA_THINK_TIME ); @@ -164,14 +161,6 @@ void CTriggerAreaCapture::Precache( void ) { } -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -void CTriggerAreaCapture::SetAreaIndex( int index ) -{ - m_iAreaIndex = index; -} - //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -231,7 +220,7 @@ void CTriggerAreaCapture::StartTouch(CBaseEntity *pOther) //----------------------------------------------------------------------------- void CTriggerAreaCapture::EndTouch(CBaseEntity *pOther) { - if ( PassesTriggerFilters(pOther) && m_hPoint ) + if ( IsTouching( pOther ) && m_hPoint ) { IGameEvent *event = gameeventmanager->CreateEvent( "controlpoint_endtouch" ); if ( event ) @@ -274,8 +263,6 @@ void CTriggerAreaCapture::AreaTouch( CBaseEntity *pOther ) if ( !TeamplayGameRules()->PointsMayBeCaptured() ) return; - Assert( m_iAreaIndex != -1 ); - // dont touch for non-alive or non-players if( !pOther->IsPlayer() || !pOther->IsAlive() ) return; @@ -771,6 +758,8 @@ void CTriggerAreaCapture::StartCapture( int team, int capmode ) m_nCapturingTeam = team; + OnStartCapture( m_nCapturingTeam ); + UpdateNumPlayers(); if ( CaptureModeScalesWithPlayers() ) diff --git a/sp/src/game/server/trigger_area_capture.h b/sp/src/game/server/trigger_area_capture.h index 2d392755..90e0ed0a 100644 --- a/sp/src/game/server/trigger_area_capture.h +++ b/sp/src/game/server/trigger_area_capture.h @@ -55,13 +55,13 @@ public: // A team has finished capturing the zone. virtual void OnEndCapture( int iTeam ) { return; } + virtual void OnStartCapture( int iTeam ) { return; } public: virtual void Spawn( void ); virtual void Precache( void ); virtual bool KeyValue( const char *szKeyName, const char *szValue ); - void SetAreaIndex( int index ); bool IsActive( void ); bool CheckIfDeathCausesBlock( CBaseMultiplayerPlayer *pVictim, CBaseMultiplayerPlayer *pKiller ); @@ -173,8 +173,6 @@ private: COutputInt m_OnNumCappersChanged; COutputInt m_OnNumCappersChanged2; - int m_iAreaIndex; //index of this area among all other areas - CHandle m_hPoint; //the capture point that we are linked to! bool m_bRequiresObject; diff --git a/sp/src/game/server/triggers.cpp b/sp/src/game/server/triggers.cpp index 8835ab26..295e826a 100644 --- a/sp/src/game/server/triggers.cpp +++ b/sp/src/game/server/triggers.cpp @@ -392,30 +392,37 @@ bool CBaseTrigger::PassesTriggerFilters(CBaseEntity *pOther) bool bOtherIsPlayer = pOther->IsPlayer(); - if ( HasSpawnFlags(SF_TRIGGER_ONLY_CLIENTS_IN_VEHICLES) && bOtherIsPlayer ) + if ( bOtherIsPlayer ) { - if ( !((CBasePlayer*)pOther)->IsInAVehicle() ) + CBasePlayer *pPlayer = (CBasePlayer*)pOther; + if ( !pPlayer->IsAlive() ) return false; - // Make sure we're also not exiting the vehicle at the moment - IServerVehicle *pVehicleServer = ((CBasePlayer*)pOther)->GetVehicle(); - if ( pVehicleServer == NULL ) - return false; - - if ( pVehicleServer->IsPassengerExiting() ) - return false; - } + if ( HasSpawnFlags(SF_TRIGGER_ONLY_CLIENTS_IN_VEHICLES) ) + { + if ( !pPlayer->IsInAVehicle() ) + return false; - if ( HasSpawnFlags(SF_TRIGGER_ONLY_CLIENTS_OUT_OF_VEHICLES) && bOtherIsPlayer ) - { - if ( ((CBasePlayer*)pOther)->IsInAVehicle() ) - return false; - } + // Make sure we're also not exiting the vehicle at the moment + IServerVehicle *pVehicleServer = pPlayer->GetVehicle(); + if ( pVehicleServer == NULL ) + return false; - if ( HasSpawnFlags( SF_TRIGGER_DISALLOW_BOTS ) && bOtherIsPlayer ) - { - if ( ((CBasePlayer*)pOther)->IsFakeClient() ) - return false; + if ( pVehicleServer->IsPassengerExiting() ) + return false; + } + + if ( HasSpawnFlags(SF_TRIGGER_ONLY_CLIENTS_OUT_OF_VEHICLES) ) + { + if ( pPlayer->IsInAVehicle() ) + return false; + } + + if ( HasSpawnFlags( SF_TRIGGER_DISALLOW_BOTS ) ) + { + if ( pPlayer->IsFakeClient() ) + return false; + } } CBaseFilter *pFilter = m_hFilter.Get(); @@ -503,6 +510,14 @@ void CBaseTrigger::EndTouch(CBaseEntity *pOther) { m_hTouchingEntities.Remove( i ); } + else if ( hOther->IsPlayer() && !hOther->IsAlive() ) + { +#ifdef STAGING_ONLY + AssertMsg( 0, CFmtStr( "Dead player [%s] is still touching this trigger at [%f %f %f]", hOther->GetEntityName().ToCStr(), XYZ( hOther->GetAbsOrigin() ) ) ); + Warning( "Dead player [%s] is still touching this trigger at [%f %f %f]", hOther->GetEntityName().ToCStr(), XYZ( hOther->GetAbsOrigin() ) ); +#endif + m_hTouchingEntities.Remove( i ); + } else { bFoundOtherTouchee = true; diff --git a/sp/src/game/server/util.cpp b/sp/src/game/server/util.cpp index b273520a..aba6f327 100644 --- a/sp/src/game/server/util.cpp +++ b/sp/src/game/server/util.cpp @@ -902,7 +902,15 @@ void UTIL_ScreenShakeObject( CBaseEntity *pEnt, const Vector ¢er, float ampl continue; } - localAmplitude = ComputeShakeAmplitude( center, pPlayer->WorldSpaceCenter(), amplitude, radius ); + if ( radius > 0 ) + { + localAmplitude = ComputeShakeAmplitude( center, pPlayer->WorldSpaceCenter(), amplitude, radius ); + } + else + { + // If using a 0 radius, apply to everyone with no falloff + localAmplitude = amplitude; + } // This happens if the player is outside the radius, // in which case we should ignore all commands diff --git a/sp/src/game/server/vote_controller.cpp b/sp/src/game/server/vote_controller.cpp index d052e0f9..316974ad 100644 --- a/sp/src/game/server/vote_controller.cpp +++ b/sp/src/game/server/vote_controller.cpp @@ -616,11 +616,7 @@ void CVoteController::VoteControllerThink( void ) } else { - // Don't track failed dedicated server votes - if ( m_iEntityHoldingVote != DEDICATED_SERVER ) - { - m_potentialIssues[m_iActiveIssueIndex]->OnVoteFailed(); - } + m_potentialIssues[m_iActiveIssueIndex]->OnVoteFailed( m_iEntityHoldingVote ); m_resetVoteTimer.Start( 5.0 ); } } @@ -895,34 +891,38 @@ const char *CBaseIssue::GetVotePassedString( void ) //----------------------------------------------------------------------------- // Purpose: Store failures to prevent vote spam //----------------------------------------------------------------------------- -void CBaseIssue::OnVoteFailed( void ) +void CBaseIssue::OnVoteFailed( int iEntityHoldingVote ) { - // Check for an existing match - for ( int index = 0; index < m_FailedVotes.Count(); index++ ) + // Don't track failed dedicated server votes + if ( BRecordVoteFailureEventForEntity( iEntityHoldingVote ) ) { - FailedVote *pFailedVote = m_FailedVotes[index]; - if ( Q_strcmp( pFailedVote->szFailedVoteParameter, GetDetailsString() ) == 0 ) + // Check for an existing match + for ( int index = 0; index < m_FailedVotes.Count(); index++ ) { - int nTime = sv_vote_failure_timer.GetInt(); + FailedVote *pFailedVote = m_FailedVotes[index]; + if ( Q_strcmp( pFailedVote->szFailedVoteParameter, GetDetailsString() ) == 0 ) + { + int nTime = sv_vote_failure_timer.GetInt(); #ifdef TF_DLL - if ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() ) - { - nTime = sv_vote_failure_timer_mvm.GetInt(); - } + if ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() ) + { + nTime = sv_vote_failure_timer_mvm.GetInt(); + } #endif // TF_DLL - pFailedVote->flLockoutTime = gpGlobals->curtime + nTime; + pFailedVote->flLockoutTime = gpGlobals->curtime + nTime; - return; + return; + } } - } - // Need to create a new one - FailedVote *pNewFailedVote = new FailedVote; - int iIndex = m_FailedVotes.AddToTail( pNewFailedVote ); - Q_strcpy( m_FailedVotes[iIndex]->szFailedVoteParameter, GetDetailsString() ); - m_FailedVotes[iIndex]->flLockoutTime = gpGlobals->curtime + sv_vote_failure_timer.GetFloat(); + // Need to create a new one + FailedVote *pNewFailedVote = new FailedVote; + int iIndex = m_FailedVotes.AddToTail( pNewFailedVote ); + Q_strcpy( m_FailedVotes[iIndex]->szFailedVoteParameter, GetDetailsString() ); + m_FailedVotes[iIndex]->flLockoutTime = gpGlobals->curtime + sv_vote_failure_timer.GetFloat(); + } } //----------------------------------------------------------------------------- @@ -939,7 +939,7 @@ bool CBaseIssue::CanTeamCallVote( int iTeam ) const bool CBaseIssue::CanCallVote( int iEntIndex, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime ) { // Automated server vote - don't bother testing against it - if ( iEntIndex == DEDICATED_SERVER ) + if ( !BRecordVoteFailureEventForEntity( iEntIndex ) ) return true; // Bogus player diff --git a/sp/src/game/server/vote_controller.h b/sp/src/game/server/vote_controller.h index 1bdd0281..0376d6a6 100644 --- a/sp/src/game/server/vote_controller.h +++ b/sp/src/game/server/vote_controller.h @@ -25,7 +25,7 @@ public: const char *GetTypeString( void ); // Connection between console command and specific type of issue virtual const char *GetDetailsString(); virtual void SetIssueDetails( const char *pszDetails ); // We need to know the details part of the con command for later - virtual void OnVoteFailed( void ); // The moment the vote fails, also has some time for feedback before the window goes away + virtual void OnVoteFailed( int iEntityHoldingVote ); // The moment the vote fails, also has some time for feedback before the window goes away virtual void OnVoteStarted( void ) {} // Called as soon as the vote starts virtual bool IsEnabled( void ) { return false; } // Query the issue to see if it's enabled virtual bool CanTeamCallVote( int iTeam ) const; // Can someone on the given team call this vote? @@ -40,6 +40,7 @@ public: virtual bool IsYesNoVote( void ); virtual void SetYesNoVoteCount( int iNumYesVotes, int iNumNoVotes, int iNumPotentialVotes ); virtual bool GetVoteOptions( CUtlVector &vecNames ); // We use this to generate options for voting + virtual bool BRecordVoteFailureEventForEntity( int iVoteCallingEntityIndex ) const { return iVoteCallingEntityIndex != DEDICATED_SERVER; } protected: static void ListStandardNoArgCommand( CBasePlayer *forWhom, const char *issueString ); // List a Yes vote command diff --git a/sp/src/game/shared/activitylist.cpp b/sp/src/game/shared/activitylist.cpp index 94bcff15..2b421252 100644 --- a/sp/src/game/shared/activitylist.cpp +++ b/sp/src/game/shared/activitylist.cpp @@ -2270,6 +2270,11 @@ void ActivityList_RegisterSharedActivities( void ) REGISTER_SHARED_ACTIVITY( ACT_THROWABLE_VM_IDLE ); REGISTER_SHARED_ACTIVITY( ACT_THROWABLE_VM_FIRE ); + REGISTER_SHARED_ACTIVITY( ACT_SPELL_VM_DRAW ); + REGISTER_SHARED_ACTIVITY( ACT_SPELL_VM_IDLE ); + REGISTER_SHARED_ACTIVITY( ACT_SPELL_VM_ARM ); + REGISTER_SHARED_ACTIVITY( ACT_SPELL_VM_FIRE ); + AssertMsg( g_HighestActivity == LAST_SHARED_ACTIVITY - 1, "Not all activities from ai_activity.h registered in activitylist.cpp" ); } diff --git a/sp/src/game/shared/ai_activity.h b/sp/src/game/shared/ai_activity.h index 6c5f05c8..fbd10c39 100644 --- a/sp/src/game/shared/ai_activity.h +++ b/sp/src/game/shared/ai_activity.h @@ -2097,11 +2097,16 @@ typedef enum // Throwable Animations ACT_MP_THROW, - ACT_THROWABLE_VM_DRAW, ACT_THROWABLE_VM_IDLE, ACT_THROWABLE_VM_FIRE, + // Spell Animations + ACT_SPELL_VM_DRAW, + ACT_SPELL_VM_IDLE, + ACT_SPELL_VM_ARM, + ACT_SPELL_VM_FIRE, + // this is the end of the global activities, private per-monster activities start here. LAST_SHARED_ACTIVITY, } Activity; diff --git a/sp/src/game/shared/basecombatweapon_shared.h b/sp/src/game/shared/basecombatweapon_shared.h index d773c0c5..701403a0 100644 --- a/sp/src/game/shared/basecombatweapon_shared.h +++ b/sp/src/game/shared/basecombatweapon_shared.h @@ -248,7 +248,7 @@ public: // but they are out of ammo. The default implementation // either reloads, switches weapons, or plays an empty sound. - virtual bool ShouldBlockPrimaryFire() { return !AutoFiresFullClip(); } + virtual bool ShouldBlockPrimaryFire() { return false; } #ifdef CLIENT_DLL virtual void CreateMove( float flInputSampleTime, CUserCmd *pCmd, const QAngle &vecOldViewAngles ) {} diff --git a/sp/src/game/shared/basegrenade_shared.h b/sp/src/game/shared/basegrenade_shared.h index 79e34801..38bb684d 100644 --- a/sp/src/game/shared/basegrenade_shared.h +++ b/sp/src/game/shared/basegrenade_shared.h @@ -11,6 +11,8 @@ #pragma once #endif +#include "baseprojectile.h" + #if defined( CLIENT_DLL ) #define CBaseGrenade C_BaseGrenade @@ -29,12 +31,12 @@ class CTakeDamageInfo; #if !defined( CLIENT_DLL ) -class CBaseGrenade : public CBaseAnimating, public CDefaultPlayerPickupVPhysics +class CBaseGrenade : public CBaseProjectile, public CDefaultPlayerPickupVPhysics #else -class CBaseGrenade : public CBaseAnimating +class CBaseGrenade : public CBaseProjectile #endif { - DECLARE_CLASS( CBaseGrenade, CBaseAnimating ); + DECLARE_CLASS( CBaseGrenade, CBaseProjectile ); public: CBaseGrenade(void); diff --git a/sp/src/game/shared/baseplayer_shared.cpp b/sp/src/game/shared/baseplayer_shared.cpp index f56e72e4..cba09eb7 100644 --- a/sp/src/game/shared/baseplayer_shared.cpp +++ b/sp/src/game/shared/baseplayer_shared.cpp @@ -22,7 +22,7 @@ #include "view.h" #include "client_virtualreality.h" #define CRecipientFilter C_RecipientFilter - #include "headtrack/isourcevirtualreality.h" + #include "sourcevr/isourcevirtualreality.h" #else diff --git a/sp/src/game/shared/baseprojectile.cpp b/sp/src/game/shared/baseprojectile.cpp new file mode 100644 index 00000000..c695db93 --- /dev/null +++ b/sp/src/game/shared/baseprojectile.cpp @@ -0,0 +1,26 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" +#include "baseprojectile.h" + + +IMPLEMENT_NETWORKCLASS_ALIASED( BaseProjectile, DT_BaseProjectile ) + +BEGIN_NETWORK_TABLE( CBaseProjectile, DT_BaseProjectile ) +END_NETWORK_TABLE() + + +//----------------------------------------------------------------------------- +// Purpose: Constructor. +//----------------------------------------------------------------------------- +CBaseProjectile::CBaseProjectile() +{ +#ifdef GAME_DLL + m_iDestroyableHitCount = 0; +#endif +} diff --git a/sp/src/game/shared/baseprojectile.h b/sp/src/game/shared/baseprojectile.h new file mode 100644 index 00000000..2ff00fc5 --- /dev/null +++ b/sp/src/game/shared/baseprojectile.h @@ -0,0 +1,53 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef BASEPROJECTILE_H +#define BASEPROJECTILE_H +#ifdef _WIN32 +#pragma once +#endif + +#include "cbase.h" + +#ifdef GAME_DLL +#include "baseanimating.h" +#else +#include "c_baseanimating.h" +#endif + +#ifdef CLIENT_DLL +#define CBaseProjectile C_BaseProjectile +#endif // CLIENT_DLL + +//============================================================================= +// +// Base Projectile. +// +//============================================================================= +class CBaseProjectile : public CBaseAnimating +{ +public: + DECLARE_CLASS( CBaseProjectile, CBaseAnimating ); + DECLARE_NETWORKCLASS(); + + CBaseProjectile(); + +#ifdef GAME_DLL + virtual int GetDestroyableHitCount( void ) const { return m_iDestroyableHitCount; } + void IncrementDestroyableHitCount( void ) { ++m_iDestroyableHitCount; } +#endif // GAME_DLL + + virtual bool IsDestroyable( void ) { return false; } + virtual void Destroy( bool bBlinkOut = true, bool bBreakRocket = false ) {} + +protected: +#ifdef GAME_DLL + int m_iDestroyableHitCount; +#endif // GAME_DLL +}; + +#endif // BASEPROJECTILE_H diff --git a/sp/src/game/shared/baseviewmodel_shared.cpp b/sp/src/game/shared/baseviewmodel_shared.cpp index 99c4bfce..20538e8c 100644 --- a/sp/src/game/shared/baseviewmodel_shared.cpp +++ b/sp/src/game/shared/baseviewmodel_shared.cpp @@ -12,7 +12,7 @@ #include "iprediction.h" #include "prediction.h" #include "client_virtualreality.h" -#include "headtrack/isourcevirtualreality.h" +#include "sourcevr/isourcevirtualreality.h" #else #include "vguiscreen.h" #endif diff --git a/sp/src/game/shared/effect_color_tables.h b/sp/src/game/shared/effect_color_tables.h index 54f6384f..322d0e08 100644 --- a/sp/src/game/shared/effect_color_tables.h +++ b/sp/src/game/shared/effect_color_tables.h @@ -44,6 +44,7 @@ static colorentry_t bloodcolors[] = { BLOOD_COLOR_RED, 72, 0, 0 }, { BLOOD_COLOR_YELLOW, 195, 195, 0 }, { BLOOD_COLOR_MECH, 20, 20, 20 }, + { BLOOD_COLOR_GREEN, 195, 195, 0 }, }; #endif // EFFECT_COLOR_TABLES_H diff --git a/sp/src/game/shared/gamemovement.cpp b/sp/src/game/shared/gamemovement.cpp index 4f1132b1..8de6fc32 100644 --- a/sp/src/game/shared/gamemovement.cpp +++ b/sp/src/game/shared/gamemovement.cpp @@ -55,6 +55,12 @@ ConVar player_limit_jump_speed( "player_limit_jump_speed", "1", FCVAR_REPLICATED // duck controls. Its value is meaningless anytime we don't have the options window open. ConVar option_duck_method("option_duck_method", "1", FCVAR_REPLICATED|FCVAR_ARCHIVE );// 0 = HOLD to duck, 1 = Duck is a toggle +#ifdef STAGING_ONLY +#ifdef CLIENT_DLL +ConVar debug_latch_reset_onduck( "debug_latch_reset_onduck", "1", FCVAR_CHEAT ); +#endif +#endif + // [MD] I'll remove this eventually. For now, I want the ability to A/B the optimizations. bool g_bMovementOptimizations = true; @@ -4108,8 +4114,15 @@ void CGameMovement::FinishUnDuck( void ) mv->SetAbsOrigin( newOrigin ); #ifdef CLIENT_DLL +#ifdef STAGING_ONLY + if ( debug_latch_reset_onduck.GetBool() ) + { + player->ResetLatched(); + } +#else player->ResetLatched(); #endif +#endif // CLIENT_DLL // Recategorize position since ducking can change origin CategorizePosition(); @@ -4207,8 +4220,15 @@ void CGameMovement::FinishDuck( void ) mv->SetAbsOrigin( out ); #ifdef CLIENT_DLL +#ifdef STAGING_ONLY + if ( debug_latch_reset_onduck.GetBool() ) + { + player->ResetLatched(); + } +#else player->ResetLatched(); #endif +#endif // CLIENT_DLL } // See if we are stuck? diff --git a/sp/src/game/shared/gamerules.h b/sp/src/game/shared/gamerules.h index 6d99f64f..4b2f5124 100644 --- a/sp/src/game/shared/gamerules.h +++ b/sp/src/game/shared/gamerules.h @@ -271,7 +271,7 @@ public: // Client damage rules virtual float FlPlayerFallDamage( CBasePlayer *pPlayer ) = 0;// this client just hit the ground after a fall. How much damage? - virtual bool FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ) {return TRUE;};// can this player take damage from this attacker? + virtual bool FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker, const CTakeDamageInfo &info ) {return TRUE;};// can this player take damage from this attacker? virtual bool ShouldAutoAim( CBasePlayer *pPlayer, edict_t *target ) { return TRUE; } virtual float GetAutoAimScale( CBasePlayer *pPlayer ) { return 1.0f; } virtual int GetAutoAimMode() { return AUTOAIM_ON; } diff --git a/sp/src/game/shared/movevars_shared.cpp b/sp/src/game/shared/movevars_shared.cpp index 3ef79945..b5b94c72 100644 --- a/sp/src/game/shared/movevars_shared.cpp +++ b/sp/src/game/shared/movevars_shared.cpp @@ -36,7 +36,7 @@ float GetCurrentGravity( void ) ConVar sv_gravity ( "sv_gravity", DEFAULT_GRAVITY_STRING, FCVAR_NOTIFY | FCVAR_REPLICATED, "World gravity." ); -#if defined( DOD_DLL ) || defined( CSTRIKE_DLL ) +#if defined( DOD_DLL ) || defined( CSTRIKE_DLL ) || defined( HL1MP_DLL ) ConVar sv_stopspeed ( "sv_stopspeed","100", FCVAR_NOTIFY | FCVAR_REPLICATED, "Minimum stopping speed when on ground." ); #else ConVar sv_stopspeed ( "sv_stopspeed","100", FCVAR_NOTIFY | FCVAR_REPLICATED | FCVAR_DEVELOPMENTONLY, "Minimum stopping speed when on ground." ); @@ -48,7 +48,7 @@ ConVar sv_specaccelerate( "sv_specaccelerate", "5", FCVAR_NOTIFY | FCVAR_ARCHIVE ConVar sv_specspeed ( "sv_specspeed", "3", FCVAR_ARCHIVE | FCVAR_NOTIFY | FCVAR_REPLICATED); ConVar sv_specnoclip ( "sv_specnoclip", "1", FCVAR_ARCHIVE | FCVAR_NOTIFY | FCVAR_REPLICATED); -#if defined( CSTRIKE_DLL ) +#if defined( CSTRIKE_DLL ) || defined( HL1MP_DLL ) ConVar sv_maxspeed ( "sv_maxspeed", "320", FCVAR_NOTIFY | FCVAR_REPLICATED); #else ConVar sv_maxspeed ( "sv_maxspeed", "320", FCVAR_NOTIFY | FCVAR_REPLICATED | FCVAR_DEVELOPMENTONLY); @@ -58,7 +58,7 @@ ConVar sv_maxspeed ( "sv_maxspeed", "320", FCVAR_NOTIFY | FCVAR_REPLICATED | FC ConVar sv_accelerate ( "sv_accelerate", "7", FCVAR_NOTIFY | FCVAR_REPLICATED); #else -#if defined( CSTRIKE_DLL ) +#if defined( CSTRIKE_DLL ) || defined( HL1MP_DLL ) ConVar sv_accelerate ( "sv_accelerate", "10", FCVAR_NOTIFY | FCVAR_REPLICATED); #else ConVar sv_accelerate ( "sv_accelerate", "10", FCVAR_NOTIFY | FCVAR_REPLICATED | FCVAR_DEVELOPMENTONLY); @@ -66,7 +66,7 @@ ConVar sv_maxspeed ( "sv_maxspeed", "320", FCVAR_NOTIFY | FCVAR_REPLICATED | FC #endif//_XBOX -#if defined( CSTRIKE_DLL ) +#if defined( CSTRIKE_DLL ) || defined( HL1MP_DLL ) ConVar sv_airaccelerate( "sv_airaccelerate", "10", FCVAR_NOTIFY | FCVAR_REPLICATED); ConVar sv_wateraccelerate( "sv_wateraccelerate", "10", FCVAR_NOTIFY | FCVAR_REPLICATED); ConVar sv_waterfriction( "sv_waterfriction", "1", FCVAR_NOTIFY | FCVAR_REPLICATED); @@ -82,13 +82,13 @@ ConVar sv_rollspeed ( "sv_rollspeed", "200", FCVAR_NOTIFY | FCVAR_REPLICATED | F ConVar sv_rollangle ( "sv_rollangle", "0", FCVAR_NOTIFY | FCVAR_REPLICATED | FCVAR_DEVELOPMENTONLY, "Max view roll angle"); #endif // CSTRIKE_DLL -#if defined( DOD_DLL ) || defined( CSTRIKE_DLL ) +#if defined( DOD_DLL ) || defined( CSTRIKE_DLL ) || defined( HL1MP_DLL ) ConVar sv_friction ( "sv_friction","4", FCVAR_NOTIFY | FCVAR_REPLICATED, "World friction." ); #else ConVar sv_friction ( "sv_friction","4", FCVAR_NOTIFY | FCVAR_REPLICATED | FCVAR_DEVELOPMENTONLY, "World friction." ); #endif // DOD_DLL || CSTRIKE_DLL -#if defined( CSTRIKE_DLL ) +#if defined( CSTRIKE_DLL ) || defined( HL1MP_DLL ) ConVar sv_bounce ( "sv_bounce","0", FCVAR_NOTIFY | FCVAR_REPLICATED, "Bounce multiplier for when physically simulated objects collide with other objects." ); ConVar sv_maxvelocity ( "sv_maxvelocity","3500", FCVAR_REPLICATED, "Maximum speed any ballistically moving object is allowed to attain per axis." ); ConVar sv_stepsize ( "sv_stepsize","18", FCVAR_NOTIFY | FCVAR_REPLICATED ); diff --git a/sp/src/game/shared/mp_shareddefs.cpp b/sp/src/game/shared/mp_shareddefs.cpp index 561ba6fb..b555a88f 100644 --- a/sp/src/game/shared/mp_shareddefs.cpp +++ b/sp/src/game/shared/mp_shareddefs.cpp @@ -103,7 +103,7 @@ const char *g_pszMPConcepts[] = "TLK_TAUNT_REPLAY", // MP_CONCEPT_TAUNT_REPLAY "TLK_TAUNT_LAUGH", // MP_CONCEPT_TAUNT_LAUGH "TLK_TAUNT_HEROIC_POSE", // MP_CONCEPT_TAUNT_HEROIC_POSE - "TLK_HIGHFIVE_READY", // MP_CONCEPT_HIGHFIVE_READY + "TLK_PARTNER_TAUNT_READY", // MP_CONCEPT_PARTNER_TAUNT_READY "TLK_PLAYER_HOLDTAUNT", // MP_CONCEPT_HOLDTAUNT "TLK_TAUNT_PYRO_ARMAGEDDON", // MP_CONCEPT_TAUNT_PYRO_ARMAGEDDON "TLK_ROCKET_DESTOYED", // MP_CONCEPT_ROCKET_DESTOYED @@ -144,16 +144,55 @@ const char *g_pszMPConcepts[] = "TLK_MAGIC_DANCE", // MP_CONCEPT_MAGIC_DANCE "HalloweenLongFall", // MP_CONCEPT_HALLOWEEN_LONGFALL "TLK_TAUNT_GUITAR_RIFF", // MP_CONCEPT_TAUNT_GUITAR_RIFF + + // TF Halloween 2013 shenanigans. + "TLK_PLAYER_CAST_FIREBALL", // MP_CONCEPT_PLAYER_CAST_FIREBALL + "TLK_PLAYER_CAST_MERASMUS_ZAP", // MP_CONCEPT_PLAYER_CAST_MERASMUS_ZAP + "TLK_PLAYER_CAST_SELF_HEAL", // MP_CONCEPT_PLAYER_CAST_SELF_HEAL + "TLK_PLAYER_CAST_MIRV", // MP_CONCEPT_PLAYER_CAST_MIRV + "TLK_PLAYER_CAST_BLAST_JUMP", // MP_CONCEPT_PLAYER_CAST_BLAST_JUMP + "TLK_PLAYER_CAST_STEALTH", // MP_CONCEPT_PLAYER_CAST_STEALTH + "TLK_PLAYER_CAST_TELEPORT", // MP_CONCEPT_PLAYER_CAST_TELEPORT + "TLK_PLAYER_CAST_LIGHTNING_BALL", // MP_CONCEPT_PLAYER_CAST_LIGHTNING_BALL + "TLK_PLAYER_CAST_MOVEMENT_BUFF", // MP_CONCEPT_PLAYER_CAST_MOVEMENT_BUFF + "TLK_PLAYER_CAST_MONOCULOUS", // MP_CONCEPT_PLAYER_CAST_MONOCULOUS + "TLK_PLAYER_CAST_METEOR_SWARM", // MP_CONCEPT_PLAYER_CAST_METEOR_SWARM + "TLK_PLAYER_CAST_SKELETON_HORDE", // MP_CONCEPT_PLAYER_CAST_SKELETON_HORDE + + "TLK_PLAYER_SPELL_FIREBALL", // MP_CONCEPT_PLAYER_SPELL_FIREBALL + "TLK_PLAYER_SPELL_MERASMUS_ZAP", // MP_CONCEPT_PLAYER_SPELL_MERASMUS_ZAP + "TLK_PLAYER_SPELL_SELF_HEAL", // MP_CONCEPT_PLAYER_SPELL_SELF_HEAL + "TLK_PLAYER_SPELL_MIRV", // MP_CONCEPT_PLAYER_SPELL_MIRV + "TLK_PLAYER_SPELL_BLAST_JUMP", // MP_CONCEPT_PLAYER_SPELL_BLAST_JUMP + "TLK_PLAYER_SPELL_STEALTH", // MP_CONCEPT_PLAYER_SPELL_STEALTH + "TLK_PLAYER_SPELL_TELEPORT", // MP_CONCEPT_PLAYER_SPELL_TELEPORT + "TLK_PLAYER_SPELL_LIGHTNING_BALL", // MP_CONCEPT_PLAYER_SPELL_LIGHTNING_BALL + "TLK_PLAYER_SPELL_MOVEMENT_BUFF", // MP_CONCEPT_PLAYER_SPELL_MOVEMENT_BUFF + "TLK_PLAYER_SPELL_MONOCULOUS", // MP_CONCEPT_PLAYER_SPELL_MONOCULOUS + "TLK_PLAYER_SPELL_METEOR_SWARM", // MP_CONCEPT_PLAYER_SPELL_METEOR_SWARM + "TLK_PLAYER_SPELL_SKELETON_HORDE", // MP_CONCEPT_PLAYER_SPELL_SKELETON_HORDE + + // Events. + "TLK_PLAYER_SPELL_PICKUP_COMMON", // MP_CONCEPT_PLAYER_SPELL_PICKUP_COMMON + "TLK_PLAYER_SPELL_PICKUP_RARE", // MP_CONCEPT_PLAYER_SPELL_PICKUP_RARE + "TLK_PLAYER_HELLTOWER_MIDNIGHT", // MP_CONCEPT_PLAYER_HELLTOWER_MIDNIGHT + "TLK_PLAYER_SKELETON_KING_APPEAR", // MP_CONCEPT_PLAYER_SKELETON_KING_APPEAR + + "TLK_MANNHATTAN_GATE_ATK", // MP_CONCEPT_MANNHATTAN_GATE_ATK + "TLK_MANNHATTAN_GATE_TAKE", // MP_CONCEPT_MANNHATTAN_GATE_TAKE + "TLK_RESURRECTED", // MP_CONCEPT_RESURRECTED + "TLK_MVM_LOOT_COMMON", // MP_CONCEPT_MVM_LOOT_COMMON + "TLK_MVM_LOOT_RARE", // MP_CONCEPT_MVM_LOOT_RARE + "TLK_MVM_LOOT_ULTRARARE", // MP_CONCEPT_MVM_LOOT_ULTRARARE + "TLK_MEDIC_HEAL_SHIELD", // MP_CONCEPT_MEDIC_HEAL_SHIELD }; +COMPILE_TIME_ASSERT( ARRAYSIZE( g_pszMPConcepts ) == MP_TF_CONCEPT_COUNT ); //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- int GetMPConceptIndexFromString( const char *pszConcept ) { - // Make sure our concept string and enum arrays are the same length - Assert( ARRAYSIZE( g_pszMPConcepts ) == MP_TF_CONCEPT_COUNT ); - for ( int iConcept = 0; iConcept < ARRAYSIZE( g_pszMPConcepts ); ++iConcept ) { if ( !Q_stricmp( pszConcept, g_pszMPConcepts[iConcept] ) ) diff --git a/sp/src/game/shared/mp_shareddefs.h b/sp/src/game/shared/mp_shareddefs.h index bb173c52..8ad6011b 100644 --- a/sp/src/game/shared/mp_shareddefs.h +++ b/sp/src/game/shared/mp_shareddefs.h @@ -112,7 +112,7 @@ enum MP_CONCEPT_TAUNT_REPLAY, // "TLK_TAUNT_REPLAY" MP_CONCEPT_TAUNT_LAUGH, // "TLK_TAUNT_LAUGH" MP_CONCEPT_TAUNT_HEROIC_POSE, // "TLK_TAUNT_HEROIC_POSE" - MP_CONCEPT_HIGHFIVE_READY, // "TLK_HIGHFIVE_READY" + MP_CONCEPT_PARTNER_TAUNT_READY, // "TLK_PARTNER_TAUNT_READY" MP_CONCEPT_HOLDTAUNT, // "TLK_PLAYER_HOLDTAUNT" MP_CONCEPT_TAUNT_PYRO_ARMAGEDDON, // "TLK_TAUNT_PYRO_ARMAGEDDON" MP_CONCEPT_ROCKET_DESTOYED, // "TLK_ROCKET_DESTOYED" @@ -153,6 +153,48 @@ enum MP_CONCEPT_MAGIC_DANCE, // "TLK_MAGIC_DANCE" MP_CONCEPT_HALLOWEEN_LONGFALL, MP_CONCEPT_TAUNT_GUITAR_RIFF, // "TLK_TAUNT_GUITAR_RIFF" + + // TF Halloween 2013 shenanigans. + MP_CONCEPT_PLAYER_CAST_FIREBALL, // "TLK_PLAYER_CAST_FIREBALL" + MP_CONCEPT_PLAYER_CAST_MERASMUS_ZAP, // "TLK_PLAYER_CAST_MERASMUS_ZAP" + MP_CONCEPT_PLAYER_CAST_SELF_HEAL, // "TLK_PLAYER_CAST_SELF_HEAL" + MP_CONCEPT_PLAYER_CAST_MIRV, // "TLK_PLAYER_CAST_MIRV" + MP_CONCEPT_PLAYER_CAST_BLAST_JUMP, // "TLK_PLAYER_CAST_BLAST_JUMP" + MP_CONCEPT_PLAYER_CAST_STEALTH, // "TLK_PLAYER_CAST_STEALTH" + MP_CONCEPT_PLAYER_CAST_TELEPORT, // "TLK_PLAYER_CAST_TELEPORT" + MP_CONCEPT_PLAYER_CAST_LIGHTNING_BALL, // "TLK_PLAYER_CAST_LIGHTNING_BALL" + MP_CONCEPT_PLAYER_CAST_MOVEMENT_BUFF, // "TLK_PLAYER_CAST_MOVEMENT_BUFF" + MP_CONCEPT_PLAYER_CAST_MONOCULOUS, // "TLK_PLAYER_CAST_MONOCULOUS" + MP_CONCEPT_PLAYER_CAST_METEOR_SWARM, // "TLK_PLAYER_CAST_METEOR_SWARM" + MP_CONCEPT_PLAYER_CAST_SKELETON_HORDE, // "TLK_PLAYER_CAST_SKELETON_HORDE" + + MP_CONCEPT_PLAYER_SPELL_FIREBALL, // "TLK_PLAYER_SPELL_FIREBALL" + MP_CONCEPT_PLAYER_SPELL_MERASMUS_ZAP, // "TLK_PLAYER_SPELL_MERASMUS_ZAP" + MP_CONCEPT_PLAYER_SPELL_SELF_HEAL, // "TLK_PLAYER_SPELL_SELF_HEAL" + MP_CONCEPT_PLAYER_SPELL_MIRV, // "TLK_PLAYER_SPELL_MIRV" + MP_CONCEPT_PLAYER_SPELL_BLAST_JUMP, // "TLK_PLAYER_SPELL_BLAST_JUMP" + MP_CONCEPT_PLAYER_SPELL_STEALTH, // "TLK_PLAYER_SPELL_STEALTH" + MP_CONCEPT_PLAYER_SPELL_TELEPORT, // "TLK_PLAYER_SPELL_TELEPORT" + MP_CONCEPT_PLAYER_SPELL_LIGHTNING_BALL, // "TLK_PLAYER_SPELL_LIGHTNING_BALL" + MP_CONCEPT_PLAYER_SPELL_MOVEMENT_BUFF, // "TLK_PLAYER_SPELL_MOVEMENT_BUFF" + MP_CONCEPT_PLAYER_SPELL_MONOCULOUS, // "TLK_PLAYER_SPELL_MONOCULOUS" + MP_CONCEPT_PLAYER_SPELL_METEOR_SWARM, // "TLK_PLAYER_SPELL_METEOR_SWARM" + MP_CONCEPT_PLAYER_SPELL_SKELETON_HORDE, // "TLK_PLAYER_SPELL_SKELETON_HORDE" + + // Events. + MP_CONCEPT_PLAYER_SPELL_PICKUP_COMMON, // "TLK_PLAYER_SPELL_PICKUP_COMMON" + MP_CONCEPT_PLAYER_SPELL_PICKUP_RARE, // "TLK_PLAYER_SPELL_PICKUP_RARE" + MP_CONCEPT_PLAYER_HELLTOWER_MIDNIGHT, // "TLK_PLAYER_HELLTOWER_MIDNIGHT" + MP_CONCEPT_PLAYER_SKELETON_KING_APPEAR, // "TLK_PLAYER_SKELETON_KING_APPEAR" + + MP_CONCEPT_MANNHATTAN_GATE_ATK, // "TLK_MANNHATTAN_GATE_ATK" + MP_CONCEPT_MANNHATTAN_GATE_TAKE, // "TLK_MANNHATTAN_GATE_TAKE" + MP_CONCEPT_RESURRECTED, // "TLK_RESURRECTED" + MP_CONCEPT_MVM_LOOT_COMMON, // "TLK_MVM_LOOT_COMMON" + MP_CONCEPT_MVM_LOOT_RARE, // "TLK_MVM_LOOT_RARE" + MP_CONCEPT_MVM_LOOT_ULTRARARE, // "TLK_MVM_LOOT_ULTRARARE" + MP_CONCEPT_MEDIC_HEAL_SHIELD, // "TLK_MEDIC_HEAL_SHIELD" + MP_TF_CONCEPT_COUNT // Other MP_CONCEPT_* start he using MP_TF_CONCEPT_COUNT + 1 as start. diff --git a/sp/src/game/shared/multiplay_gamerules.cpp b/sp/src/game/shared/multiplay_gamerules.cpp index 409f2362..07932e92 100644 --- a/sp/src/game/shared/multiplay_gamerules.cpp +++ b/sp/src/game/shared/multiplay_gamerules.cpp @@ -641,7 +641,7 @@ ConVarRef suitcharger( "sk_suitcharger" ); //========================================================= //========================================================= - bool CMultiplayRules::FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ) + bool CMultiplayRules::FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker, const CTakeDamageInfo &info ) { return true; } @@ -834,7 +834,11 @@ ConVarRef suitcharger( "sk_suitcharger" ); // If the inflictor is the killer, then it must be their current weapon doing the damage if ( pScorer->GetActiveWeapon() ) { +#ifdef HL1MP_DLL + killer_weapon_name = pScorer->GetActiveWeapon()->GetClassname(); +#else killer_weapon_name = pScorer->GetActiveWeapon()->GetDeathNoticeName(); +#endif } } else @@ -870,7 +874,9 @@ ConVarRef suitcharger( "sk_suitcharger" ); event->SetInt("attacker", killer_ID ); event->SetInt("customkill", info.GetDamageCustom() ); event->SetInt("priority", 7 ); // HLTV event priority, not transmitted - +#ifdef HL1MP_DLL + event->SetString("weapon", killer_weapon_name ); +#endif gameeventmanager->FireEvent( event ); } @@ -1748,6 +1754,37 @@ ConVarRef suitcharger( "sk_suitcharger" ); } } + void CMultiplayRules::RandomPlayersSpeakConceptIfAllowed( int iConcept, int iNumRandomPlayer /*= 1*/, int iTeam /*= TEAM_UNASSIGNED*/, const char *modifiers /*= NULL*/ ) + { + CUtlVector< CBaseMultiplayerPlayer* > speakCandidates; + + CBaseMultiplayerPlayer *pPlayer; + for ( int i = 1; i <= gpGlobals->maxClients; i++ ) + { + pPlayer = ToBaseMultiplayerPlayer( UTIL_PlayerByIndex( i ) ); + + if ( !pPlayer ) + continue; + + if ( iTeam != TEAM_UNASSIGNED ) + { + if ( pPlayer->GetTeamNumber() != iTeam ) + continue; + } + + speakCandidates.AddToTail( pPlayer ); + } + + int iSpeaker = iNumRandomPlayer; + while ( iSpeaker > 0 && speakCandidates.Count() > 0 ) + { + int iRandomSpeaker = RandomInt( 0, speakCandidates.Count() - 1 ); + speakCandidates[ iRandomSpeaker ]->SpeakConceptIfAllowed( iConcept, modifiers ); + speakCandidates.FastRemove( iRandomSpeaker ); + iSpeaker--; + } + } + void CMultiplayRules::ClientSettingsChanged( CBasePlayer *pPlayer ) { // NVNT see if this user is still or has began using a haptic device diff --git a/sp/src/game/shared/multiplay_gamerules.h b/sp/src/game/shared/multiplay_gamerules.h index 4512c9c9..08e06e4a 100644 --- a/sp/src/game/shared/multiplay_gamerules.h +++ b/sp/src/game/shared/multiplay_gamerules.h @@ -136,7 +136,7 @@ public: // Client damage rules virtual float FlPlayerFallDamage( CBasePlayer *pPlayer ); - virtual bool FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ); + virtual bool FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker, const CTakeDamageInfo &info ); virtual bool AllowDamage( CBaseEntity *pVictim, const CTakeDamageInfo &info ); // Client spawn/respawn control @@ -215,6 +215,7 @@ public: void IncrementMapCycleIndex(); void HaveAllPlayersSpeakConceptIfAllowed( int iConcept, int iTeam = TEAM_UNASSIGNED, const char *modifiers = NULL ); + void RandomPlayersSpeakConceptIfAllowed( int iConcept, int iNumRandomPlayer = 1, int iTeam = TEAM_UNASSIGNED, const char *modifiers = NULL ); virtual void GetTaggedConVarList( KeyValues *pCvarTagList ); diff --git a/sp/src/game/shared/particle_property.cpp b/sp/src/game/shared/particle_property.cpp index e5a5487d..8ddc9784 100644 --- a/sp/src/game/shared/particle_property.cpp +++ b/sp/src/game/shared/particle_property.cpp @@ -557,6 +557,14 @@ void CParticleProperty::UpdateControlPoint( ParticleEffectList_t *pEffect, int i if ( bUseHeadOrigin > 0 ) { int iBone = Studio_BoneIndexByName( pAnimating->GetModelPtr(), "bip_head" ); + if ( iBone < 0 ) + { + iBone = Studio_BoneIndexByName( pAnimating->GetModelPtr(), "prp_helmet" ); + if ( iBone < 0 ) + { + iBone = Studio_BoneIndexByName( pAnimating->GetModelPtr(), "prp_hat" ); + } + } if ( iBone >= 0 ) { bUsingHeadOrigin = true; @@ -587,18 +595,23 @@ void CParticleProperty::UpdateControlPoint( ParticleEffectList_t *pEffect, int i if ( !pAnimating->GetAttachment( pPoint->iAttachmentPoint, attachmentToWorld ) ) { - Warning( "Cannot update control point %d for effect '%s'.\n", pPoint->iAttachmentPoint, pEffect->pParticleEffect->GetEffectName() ); - attachmentToWorld = pAnimating->RenderableToWorldTransform(); + // try C_BaseAnimating if attach point is not on the weapon + if ( !pAnimating->C_BaseAnimating::GetAttachment( pPoint->iAttachmentPoint, attachmentToWorld ) ) + { + Warning( "Cannot update control point %d for effect '%s'.\n", pPoint->iAttachmentPoint, pEffect->pParticleEffect->GetEffectName() ); + attachmentToWorld = pAnimating->RenderableToWorldTransform(); + } } - MatrixVectors( attachmentToWorld, &vecForward, &vecRight, &vecUp ); - MatrixPosition( attachmentToWorld, vecOrigin ); + VMatrix vMat(attachmentToWorld); + MatrixTranslate( vMat, pPoint->vecOriginOffset ); + MatrixVectors( vMat.As3x4(), &vecForward, &vecRight, &vecUp ); + MatrixPosition( vMat.As3x4(), vecOrigin ); if ( pEffect->pParticleEffect->m_pDef->IsViewModelEffect() ) { FormatViewModelAttachment( vecOrigin, true ); } - } } break; diff --git a/sp/src/game/shared/props_shared.cpp b/sp/src/game/shared/props_shared.cpp index 7cf4489b..6d0f9209 100644 --- a/sp/src/game/shared/props_shared.cpp +++ b/sp/src/game/shared/props_shared.cpp @@ -1323,7 +1323,7 @@ CBaseEntity *CreateGibsFromList( CUtlVector &list, int modelindex, if ( !pCollide ) return NULL; - int nSkin = 0; + int nSkin = params.nDefaultSkin; CBaseEntity *pOwnerEntity = pEntity; CBaseAnimating *pOwnerAnim = NULL; if ( pPhysics ) diff --git a/sp/src/game/shared/props_shared.h b/sp/src/game/shared/props_shared.h index ee849ed2..c63cb212 100644 --- a/sp/src/game/shared/props_shared.h +++ b/sp/src/game/shared/props_shared.h @@ -227,6 +227,7 @@ struct breakablepropparams_t impactEnergyScale = 0; defBurstScale = 0; defCollisionGroup = COLLISION_GROUP_NONE; + nDefaultSkin = 0; } const Vector &origin; @@ -236,6 +237,7 @@ struct breakablepropparams_t float impactEnergyScale; float defBurstScale; int defCollisionGroup; + int nDefaultSkin; }; const char *GetMassEquivalent(float flMass); diff --git a/sp/src/game/shared/shareddefs.h b/sp/src/game/shared/shareddefs.h index b7103be3..842d2f06 100644 --- a/sp/src/game/shared/shareddefs.h +++ b/sp/src/game/shared/shareddefs.h @@ -151,8 +151,20 @@ typedef enum VOTE_FAILED_MAP_NOT_VALID, VOTE_FAILED_CANNOT_KICK_FOR_TIME, VOTE_FAILED_CANNOT_KICK_DURING_ROUND, + + // TF-specific? + VOTE_FAILED_MODIFICATION_ALREADY_ACTIVE, } vote_create_failed_t; +enum +{ +#ifdef STAGING_ONLY + SERVER_MODIFICATION_ITEM_DURATION_IN_MINUTES = 2 +#else + SERVER_MODIFICATION_ITEM_DURATION_IN_MINUTES = 120 +#endif +}; + #define MAX_VOTE_DETAILS_LENGTH 64 #define INVALID_ISSUE -1 #define MAX_VOTE_OPTIONS 5 diff --git a/sp/src/game/shared/takedamageinfo.cpp b/sp/src/game/shared/takedamageinfo.cpp index e83878cf..e9062d80 100644 --- a/sp/src/game/shared/takedamageinfo.cpp +++ b/sp/src/game/shared/takedamageinfo.cpp @@ -58,9 +58,9 @@ void CTakeDamageInfo::Init( CBaseEntity *pInflictor, CBaseEntity *pAttacker, CBa m_vecReportedPosition = reportedPosition; m_iAmmoType = -1; m_iDamagedOtherPlayers = 0; - m_iPlayerPenetrationCount = 0; m_flDamageBonus = 0.f; + m_bForceFriendlyFire = false; } CTakeDamageInfo::CTakeDamageInfo() diff --git a/sp/src/game/shared/takedamageinfo.h b/sp/src/game/shared/takedamageinfo.h index a4c01826..702e9322 100644 --- a/sp/src/game/shared/takedamageinfo.h +++ b/sp/src/game/shared/takedamageinfo.h @@ -77,6 +77,8 @@ public: void SetDamageCustom( int iDamageCustom ); int GetDamageStats( void ) const; void SetDamageStats( int iDamageStats ); + void SetForceFriendlyFire( bool bValue ) { m_bForceFriendlyFire = bValue; } + bool IsForceFriendlyFire( void ) const { return m_bForceFriendlyFire; } int GetAmmoType() const; void SetAmmoType( int iAmmoType ); @@ -123,6 +125,7 @@ protected: int m_iDamagedOtherPlayers; int m_iPlayerPenetrationCount; float m_flDamageBonus; // Anything that increases damage (crit) - store the delta + bool m_bForceFriendlyFire; // Ideally this would be a dmg type, but we can't add more DECLARE_SIMPLE_DATADESC(); }; diff --git a/sp/src/game/shared/teamplay_gamerules.cpp b/sp/src/game/shared/teamplay_gamerules.cpp index 1cbe368a..171313b3 100644 --- a/sp/src/game/shared/teamplay_gamerules.cpp +++ b/sp/src/game/shared/teamplay_gamerules.cpp @@ -352,9 +352,9 @@ bool CTeamplayRules::IsTeamplay( void ) return true; } -bool CTeamplayRules::FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ) +bool CTeamplayRules::FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker, const CTakeDamageInfo &info ) { - if ( pAttacker && PlayerRelationship( pPlayer, pAttacker ) == GR_TEAMMATE ) + if ( pAttacker && PlayerRelationship( pPlayer, pAttacker ) == GR_TEAMMATE && !info.IsForceFriendlyFire() ) { // my teammate hit me. if ( (friendlyfire.GetInt() == 0) && (pAttacker != pPlayer) ) @@ -364,7 +364,7 @@ bool CTeamplayRules::FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pA } } - return BaseClass::FPlayerCanTakeDamage( pPlayer, pAttacker ); + return BaseClass::FPlayerCanTakeDamage( pPlayer, pAttacker, info ); } //========================================================= diff --git a/sp/src/game/shared/teamplay_gamerules.h b/sp/src/game/shared/teamplay_gamerules.h index 10f953e1..952895eb 100644 --- a/sp/src/game/shared/teamplay_gamerules.h +++ b/sp/src/game/shared/teamplay_gamerules.h @@ -67,7 +67,7 @@ public: virtual bool ClientCommand( CBaseEntity *pEdict, const CCommand &args ); virtual void ClientSettingsChanged( CBasePlayer *pPlayer ); virtual bool IsTeamplay( void ); - virtual bool FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ); + virtual bool FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker, const CTakeDamageInfo &info ); virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget ); virtual bool PlayerCanHearChat( CBasePlayer *pListener, CBasePlayer *pSpeaker ); virtual const char *GetTeamID( CBaseEntity *pEntity ); diff --git a/sp/src/game/shared/teamplay_round_timer.cpp b/sp/src/game/shared/teamplay_round_timer.cpp index 63098cd6..f993749a 100644 --- a/sp/src/game/shared/teamplay_round_timer.cpp +++ b/sp/src/game/shared/teamplay_round_timer.cpp @@ -636,6 +636,12 @@ const char *CTeamRoundTimer::GetTimeWarningSound( int nWarning ) //----------------------------------------------------------------------------- void CTeamRoundTimer::SendTimeWarning( int nWarning ) { +#if defined( TF_CLIENT_DLL ) + // don't play any time warnings for Helltower + if ( TFGameRules() && TFGameRules()->IsHalloweenScenario( CTFGameRules::HALLOWEEN_SCENARIO_HIGHTOWER ) ) + return; +#endif + // don't play sounds if the level designer has turned them off or if it's during the WaitingForPlayers time if ( !m_bTimerPaused && m_bAutoCountdown && !TeamplayRoundBasedRules()->IsInWaitingForPlayers() ) { diff --git a/sp/src/game/shared/teamplayroundbased_gamerules.cpp b/sp/src/game/shared/teamplayroundbased_gamerules.cpp index 38f1294d..26a75b18 100644 --- a/sp/src/game/shared/teamplayroundbased_gamerules.cpp +++ b/sp/src/game/shared/teamplayroundbased_gamerules.cpp @@ -1267,7 +1267,7 @@ CGameRulesRoundStateInfo* CTeamplayRoundBasedRules::State_LookupInfo( gamerules_ { GR_STATE_INIT, "GR_STATE_INIT", &CTeamplayRoundBasedRules::State_Enter_INIT, NULL, &CTeamplayRoundBasedRules::State_Think_INIT }, { GR_STATE_PREGAME, "GR_STATE_PREGAME", &CTeamplayRoundBasedRules::State_Enter_PREGAME, NULL, &CTeamplayRoundBasedRules::State_Think_PREGAME }, { GR_STATE_STARTGAME, "GR_STATE_STARTGAME", &CTeamplayRoundBasedRules::State_Enter_STARTGAME, NULL, &CTeamplayRoundBasedRules::State_Think_STARTGAME }, - { GR_STATE_PREROUND, "GR_STATE_PREROUND", &CTeamplayRoundBasedRules::State_Enter_PREROUND, NULL, &CTeamplayRoundBasedRules::State_Think_PREROUND }, + { GR_STATE_PREROUND, "GR_STATE_PREROUND", &CTeamplayRoundBasedRules::State_Enter_PREROUND, &CTeamplayRoundBasedRules::State_Leave_PREROUND, &CTeamplayRoundBasedRules::State_Think_PREROUND }, { GR_STATE_RND_RUNNING, "GR_STATE_RND_RUNNING", &CTeamplayRoundBasedRules::State_Enter_RND_RUNNING, NULL, &CTeamplayRoundBasedRules::State_Think_RND_RUNNING }, { GR_STATE_TEAM_WIN, "GR_STATE_TEAM_WIN", &CTeamplayRoundBasedRules::State_Enter_TEAM_WIN, NULL, &CTeamplayRoundBasedRules::State_Think_TEAM_WIN }, { GR_STATE_RESTART, "GR_STATE_RESTART", &CTeamplayRoundBasedRules::State_Enter_RESTART, NULL, &CTeamplayRoundBasedRules::State_Think_RESTART }, @@ -1424,6 +1424,14 @@ void CTeamplayRoundBasedRules::State_Enter_PREROUND( void ) StopWatchModeThink(); } +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CTeamplayRoundBasedRules::State_Leave_PREROUND( void ) +{ + PreRound_End(); +} + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -2159,6 +2167,7 @@ void CTeamplayRoundBasedRules::SetWinningTeam( int team, int iWinReason, bool bF if ( event ) { event->SetInt( "team", team ); + event->SetInt( "winreason", iWinReason ); event->SetBool( "full_round", bForceMapReset ); event->SetFloat( "round_time", gpGlobals->curtime - m_flRoundStartTime ); event->SetBool( "was_sudden_death", bWasSuddenDeath ); @@ -3062,11 +3071,11 @@ void CTeamplayRoundBasedRules::PlayWinSong( int team ) { if ( i == team ) { - BroadcastSound( i, "Game.YourTeamWon" ); + BroadcastSound( i, WinSongName( i ) ); } else { - const char *pchLoseSong = LoseSongName(); + const char *pchLoseSong = LoseSongName( i ); if ( pchLoseSong ) { BroadcastSound( i, pchLoseSong ); @@ -3094,11 +3103,11 @@ void CTeamplayRoundBasedRules::PlaySuddenDeathSong( void ) //----------------------------------------------------------------------------- void CTeamplayRoundBasedRules::PlayStalemateSong( void ) { - BroadcastSound( TEAM_UNASSIGNED, "Game.Stalemate" ); + BroadcastSound( TEAM_UNASSIGNED, GetStalemateSong( TEAM_UNASSIGNED ) ); for ( int i = FIRST_GAME_TEAM; i < GetNumberOfTeams(); i++ ) { - BroadcastSound( i, "Game.Stalemate" ); + BroadcastSound( i, GetStalemateSong( i ) ); } } diff --git a/sp/src/game/shared/teamplayroundbased_gamerules.h b/sp/src/game/shared/teamplayroundbased_gamerules.h index 61567d49..cf584092 100644 --- a/sp/src/game/shared/teamplayroundbased_gamerules.h +++ b/sp/src/game/shared/teamplayroundbased_gamerules.h @@ -297,6 +297,8 @@ public: virtual void BetweenRounds_End( void ) { return; } virtual void BetweenRounds_Think( void ) { return; } + virtual void PreRound_End( void ) { return; } + bool PrevRoundWasWaitingForPlayers() { return m_bPrevRoundWasWaitingForPlayers; } virtual bool ShouldScorePerRound( void ){ return true; } @@ -415,6 +417,7 @@ protected: void State_Think_STARTGAME( void ); void State_Enter_PREROUND( void ); + void State_Leave_PREROUND( void ); void State_Think_PREROUND( void ); void State_Enter_RND_RUNNING( void ); @@ -456,7 +459,9 @@ protected: void PlayStalemateSong( void ); void PlaySuddenDeathSong( void ); - virtual const char* LoseSongName( void ) { return "Game.YourTeamLost"; } + virtual const char* GetStalemateSong( int nTeam ) { return "Game.Stalemate"; } + virtual const char* WinSongName( int nTeam ) { return "Game.YourTeamWon"; } + virtual const char* LoseSongName( int nTeam ) { return "Game.YourTeamLost"; } virtual void RespawnTeam( int iTeam ) { RespawnPlayers( false, true, iTeam ); } diff --git a/sp/src/game/shared/voice_banmgr.cpp b/sp/src/game/shared/voice_banmgr.cpp index 7f4864d7..d362d58f 100644 --- a/sp/src/game/shared/voice_banmgr.cpp +++ b/sp/src/game/shared/voice_banmgr.cpp @@ -54,11 +54,9 @@ bool CVoiceBanMgr::Init(const char *pGameDir) { int version; filesystem->Read(&version, sizeof(version), fh); - if(version == BANMGR_FILEVERSION) + if(version == BANMGR_FILEVERSION && filesystem->Size(fh) > 4 ) { - filesystem->Seek(fh, 0, FILESYSTEM_SEEK_TAIL); - int nIDs = (filesystem->Tell(fh) - sizeof(version)) / SIGNED_GUID_LEN; - filesystem->Seek(fh, sizeof(version), FILESYSTEM_SEEK_CURRENT); + int nIDs = ( filesystem->Size( fh ) - sizeof(version)) / SIGNED_GUID_LEN; for(int i=0; i < nIDs; i++) { diff --git a/sp/src/lib/public/appframework.lib b/sp/src/lib/public/appframework.lib index 1896be3f..2884a22e 100644 Binary files a/sp/src/lib/public/appframework.lib and b/sp/src/lib/public/appframework.lib differ diff --git a/sp/src/lib/public/bitmap.lib b/sp/src/lib/public/bitmap.lib index 3f631b59..3f842c0b 100644 Binary files a/sp/src/lib/public/bitmap.lib and b/sp/src/lib/public/bitmap.lib differ diff --git a/sp/src/lib/public/choreoobjects.lib b/sp/src/lib/public/choreoobjects.lib index d9346c6b..b295be49 100644 Binary files a/sp/src/lib/public/choreoobjects.lib and b/sp/src/lib/public/choreoobjects.lib differ diff --git a/sp/src/lib/public/dmxloader.lib b/sp/src/lib/public/dmxloader.lib index 1bf632e0..ffe58400 100644 Binary files a/sp/src/lib/public/dmxloader.lib and b/sp/src/lib/public/dmxloader.lib differ diff --git a/sp/src/lib/public/fgdlib.lib b/sp/src/lib/public/fgdlib.lib index b2098d16..c8f92974 100644 Binary files a/sp/src/lib/public/fgdlib.lib and b/sp/src/lib/public/fgdlib.lib differ diff --git a/sp/src/lib/public/libz.lib b/sp/src/lib/public/libz.lib index 692f43dd..4920f823 100644 Binary files a/sp/src/lib/public/libz.lib and b/sp/src/lib/public/libz.lib differ diff --git a/sp/src/lib/public/linux32/bitmap.a b/sp/src/lib/public/linux32/bitmap.a index 53c85947..a03e746b 100644 Binary files a/sp/src/lib/public/linux32/bitmap.a and b/sp/src/lib/public/linux32/bitmap.a differ diff --git a/sp/src/lib/public/linux32/choreoobjects.a b/sp/src/lib/public/linux32/choreoobjects.a index 1bf42e68..d60beca8 100644 Binary files a/sp/src/lib/public/linux32/choreoobjects.a and b/sp/src/lib/public/linux32/choreoobjects.a differ diff --git a/sp/src/lib/public/linux32/dmxloader.a b/sp/src/lib/public/linux32/dmxloader.a index 63ac2548..80f085c0 100644 Binary files a/sp/src/lib/public/linux32/dmxloader.a and b/sp/src/lib/public/linux32/dmxloader.a differ diff --git a/sp/src/lib/public/linux32/libSDL2-2.0.so.0 b/sp/src/lib/public/linux32/libSDL2-2.0.so.0 index 5908adb7..4cb32b6a 100644 Binary files a/sp/src/lib/public/linux32/libSDL2-2.0.so.0 and b/sp/src/lib/public/linux32/libSDL2-2.0.so.0 differ diff --git a/sp/src/lib/public/linux32/libtier0.so b/sp/src/lib/public/linux32/libtier0.so index 0b856218..bece6f75 100644 Binary files a/sp/src/lib/public/linux32/libtier0.so and b/sp/src/lib/public/linux32/libtier0.so differ diff --git a/sp/src/lib/public/linux32/libvstdlib.so b/sp/src/lib/public/linux32/libvstdlib.so index ff877923..2640250d 100644 Binary files a/sp/src/lib/public/linux32/libvstdlib.so and b/sp/src/lib/public/linux32/libvstdlib.so differ diff --git a/sp/src/lib/public/linux32/matsys_controls.a b/sp/src/lib/public/linux32/matsys_controls.a index e17d6912..c999a735 100644 Binary files a/sp/src/lib/public/linux32/matsys_controls.a and b/sp/src/lib/public/linux32/matsys_controls.a differ diff --git a/sp/src/lib/public/linux32/particles.a b/sp/src/lib/public/linux32/particles.a index 3eff3ec8..f8bdb0f6 100644 Binary files a/sp/src/lib/public/linux32/particles.a and b/sp/src/lib/public/linux32/particles.a differ diff --git a/sp/src/lib/public/linux32/shaderlib.a b/sp/src/lib/public/linux32/shaderlib.a index 152dd01f..41b693c7 100644 Binary files a/sp/src/lib/public/linux32/shaderlib.a and b/sp/src/lib/public/linux32/shaderlib.a differ diff --git a/sp/src/lib/public/linux32/tier2.a b/sp/src/lib/public/linux32/tier2.a index c35eefda..869c3c84 100644 Binary files a/sp/src/lib/public/linux32/tier2.a and b/sp/src/lib/public/linux32/tier2.a differ diff --git a/sp/src/lib/public/linux32/tier3.a b/sp/src/lib/public/linux32/tier3.a index 85bc5036..b99b4f81 100644 Binary files a/sp/src/lib/public/linux32/tier3.a and b/sp/src/lib/public/linux32/tier3.a differ diff --git a/sp/src/lib/public/linux32/vtf.a b/sp/src/lib/public/linux32/vtf.a index 668f2554..c5accec5 100644 Binary files a/sp/src/lib/public/linux32/vtf.a and b/sp/src/lib/public/linux32/vtf.a differ diff --git a/sp/src/lib/public/mathlib.lib b/sp/src/lib/public/mathlib.lib index 5452e806..d1d71fd7 100644 Binary files a/sp/src/lib/public/mathlib.lib and b/sp/src/lib/public/mathlib.lib differ diff --git a/sp/src/lib/public/matsys_controls.lib b/sp/src/lib/public/matsys_controls.lib index 3f508149..167517c6 100644 Binary files a/sp/src/lib/public/matsys_controls.lib and b/sp/src/lib/public/matsys_controls.lib differ diff --git a/sp/src/lib/public/nvtristrip.lib b/sp/src/lib/public/nvtristrip.lib index 1ac1a83a..92ac3d4e 100644 Binary files a/sp/src/lib/public/nvtristrip.lib and b/sp/src/lib/public/nvtristrip.lib differ diff --git a/sp/src/lib/public/osx32/bitmap.a b/sp/src/lib/public/osx32/bitmap.a index 0e0c885f..a1b496a8 100644 Binary files a/sp/src/lib/public/osx32/bitmap.a and b/sp/src/lib/public/osx32/bitmap.a differ diff --git a/sp/src/lib/public/osx32/choreoobjects.a b/sp/src/lib/public/osx32/choreoobjects.a index 38241d5e..b3fa1ff4 100644 Binary files a/sp/src/lib/public/osx32/choreoobjects.a and b/sp/src/lib/public/osx32/choreoobjects.a differ diff --git a/sp/src/lib/public/osx32/dmxloader.a b/sp/src/lib/public/osx32/dmxloader.a index 8bee889a..cb1729fb 100644 Binary files a/sp/src/lib/public/osx32/dmxloader.a and b/sp/src/lib/public/osx32/dmxloader.a differ diff --git a/sp/src/lib/public/osx32/libSDL2-2.0.0.dylib b/sp/src/lib/public/osx32/libSDL2-2.0.0.dylib index 3fd8c749..c8dcd704 100644 Binary files a/sp/src/lib/public/osx32/libSDL2-2.0.0.dylib and b/sp/src/lib/public/osx32/libSDL2-2.0.0.dylib differ diff --git a/sp/src/lib/public/osx32/libtier0.dylib b/sp/src/lib/public/osx32/libtier0.dylib index 4adf7eb0..cdd1e710 100644 Binary files a/sp/src/lib/public/osx32/libtier0.dylib and b/sp/src/lib/public/osx32/libtier0.dylib differ diff --git a/sp/src/lib/public/osx32/libvstdlib.dylib b/sp/src/lib/public/osx32/libvstdlib.dylib index b4bb975a..5d461998 100644 Binary files a/sp/src/lib/public/osx32/libvstdlib.dylib and b/sp/src/lib/public/osx32/libvstdlib.dylib differ diff --git a/sp/src/lib/public/osx32/matsys_controls.a b/sp/src/lib/public/osx32/matsys_controls.a index 4a9271d1..e83b37a0 100644 Binary files a/sp/src/lib/public/osx32/matsys_controls.a and b/sp/src/lib/public/osx32/matsys_controls.a differ diff --git a/sp/src/lib/public/osx32/particles.a b/sp/src/lib/public/osx32/particles.a index a0d3a387..c5dda2d6 100644 Binary files a/sp/src/lib/public/osx32/particles.a and b/sp/src/lib/public/osx32/particles.a differ diff --git a/sp/src/lib/public/osx32/shaderlib.a b/sp/src/lib/public/osx32/shaderlib.a index acb84e34..52c298ae 100644 Binary files a/sp/src/lib/public/osx32/shaderlib.a and b/sp/src/lib/public/osx32/shaderlib.a differ diff --git a/sp/src/lib/public/osx32/tier2.a b/sp/src/lib/public/osx32/tier2.a index 8421a097..cc1f50d8 100644 Binary files a/sp/src/lib/public/osx32/tier2.a and b/sp/src/lib/public/osx32/tier2.a differ diff --git a/sp/src/lib/public/osx32/tier3.a b/sp/src/lib/public/osx32/tier3.a index f16de338..2795e730 100644 Binary files a/sp/src/lib/public/osx32/tier3.a and b/sp/src/lib/public/osx32/tier3.a differ diff --git a/sp/src/lib/public/osx32/vtf.a b/sp/src/lib/public/osx32/vtf.a index 18bd45c8..c36609ae 100644 Binary files a/sp/src/lib/public/osx32/vtf.a and b/sp/src/lib/public/osx32/vtf.a differ diff --git a/sp/src/lib/public/particles.lib b/sp/src/lib/public/particles.lib index b368fd75..5e61c7a0 100644 Binary files a/sp/src/lib/public/particles.lib and b/sp/src/lib/public/particles.lib differ diff --git a/sp/src/lib/public/raytrace.lib b/sp/src/lib/public/raytrace.lib index 89968d7a..32b25be2 100644 Binary files a/sp/src/lib/public/raytrace.lib and b/sp/src/lib/public/raytrace.lib differ diff --git a/sp/src/lib/public/shaderlib.lib b/sp/src/lib/public/shaderlib.lib index ffaeaac4..da6df422 100644 Binary files a/sp/src/lib/public/shaderlib.lib and b/sp/src/lib/public/shaderlib.lib differ diff --git a/sp/src/lib/public/tier0.lib b/sp/src/lib/public/tier0.lib index 51f69f33..1a09ee27 100644 Binary files a/sp/src/lib/public/tier0.lib and b/sp/src/lib/public/tier0.lib differ diff --git a/sp/src/lib/public/tier1.lib b/sp/src/lib/public/tier1.lib index 11161f7d..2e2cba26 100644 Binary files a/sp/src/lib/public/tier1.lib and b/sp/src/lib/public/tier1.lib differ diff --git a/sp/src/lib/public/tier2.lib b/sp/src/lib/public/tier2.lib index 21e77fef..3d22c36e 100644 Binary files a/sp/src/lib/public/tier2.lib and b/sp/src/lib/public/tier2.lib differ diff --git a/sp/src/lib/public/tier3.lib b/sp/src/lib/public/tier3.lib index d68a576f..5aecf6e0 100644 Binary files a/sp/src/lib/public/tier3.lib and b/sp/src/lib/public/tier3.lib differ diff --git a/sp/src/lib/public/vgui_controls.lib b/sp/src/lib/public/vgui_controls.lib index d59d07be..ac7ffcd8 100644 Binary files a/sp/src/lib/public/vgui_controls.lib and b/sp/src/lib/public/vgui_controls.lib differ diff --git a/sp/src/lib/public/vmpi.lib b/sp/src/lib/public/vmpi.lib index e67325c2..df1e7483 100644 Binary files a/sp/src/lib/public/vmpi.lib and b/sp/src/lib/public/vmpi.lib differ diff --git a/sp/src/lib/public/vstdlib.lib b/sp/src/lib/public/vstdlib.lib index 9c676dce..94b81f56 100644 Binary files a/sp/src/lib/public/vstdlib.lib and b/sp/src/lib/public/vstdlib.lib differ diff --git a/sp/src/lib/public/vtf.lib b/sp/src/lib/public/vtf.lib index e4b4985e..47ba0e4a 100644 Binary files a/sp/src/lib/public/vtf.lib and b/sp/src/lib/public/vtf.lib differ diff --git a/sp/src/mathlib/mathlib_base.cpp b/sp/src/mathlib/mathlib_base.cpp index a403ccfa..15c51963 100644 --- a/sp/src/mathlib/mathlib_base.cpp +++ b/sp/src/mathlib/mathlib_base.cpp @@ -4244,7 +4244,7 @@ FPExceptionDisabler::FPExceptionDisabler() // Retrieve the current state of the exception flags. This // must be done before changing them. _MCW_EM is a bit // mask representing all available exception masks. - _controlfp_s(&mOldValues, _MCW_EM, _MCW_EM); + _controlfp_s(&mOldValues, 0, 0); // Set all of the exception flags, which suppresses FP // exceptions on the x87 and SSE units. _controlfp_s(0, _MCW_EM, _MCW_EM); @@ -4269,7 +4269,7 @@ FPExceptionEnabler::FPExceptionEnabler(unsigned int enableBits /*= _EM_OVERFLOW // Retrieve the current state of the exception flags. This // must be done before changing them. _MCW_EM is a bit // mask representing all available exception masks. - _controlfp_s(&mOldValues, _MCW_EM, _MCW_EM); + _controlfp_s(&mOldValues, 0, 0); // Make sure no non-exception flags have been specified, // to avoid accidental changing of rounding modes, etc. diff --git a/sp/src/mathlib/vmatrix.cpp b/sp/src/mathlib/vmatrix.cpp index 1cd316f3..e99fae2a 100644 --- a/sp/src/mathlib/vmatrix.cpp +++ b/sp/src/mathlib/vmatrix.cpp @@ -507,7 +507,7 @@ bool VMatrix::IsRotationMatrix() const FloatMakePositive( v2.Dot(v3) ) < 0.01f; } -void VMatrix::SetupMatrixOrgAngles( const Vector &origin, const QAngle &vAngles ) +static void SetupMatrixAnglesInternal( vec_t m[4][4], const QAngle & vAngles ) { float sr, sp, sy, cr, cp, cy; @@ -528,6 +528,11 @@ void VMatrix::SetupMatrixOrgAngles( const Vector &origin, const QAngle &vAngles m[0][3] = 0.f; m[1][3] = 0.f; m[2][3] = 0.f; +} + +void VMatrix::SetupMatrixOrgAngles( const Vector &origin, const QAngle &vAngles ) +{ + SetupMatrixAnglesInternal( m, vAngles ); // Add translation m[0][3] = origin.x; @@ -540,6 +545,21 @@ void VMatrix::SetupMatrixOrgAngles( const Vector &origin, const QAngle &vAngles } +void VMatrix::SetupMatrixAngles( const QAngle &vAngles ) +{ + SetupMatrixAnglesInternal( m, vAngles ); + + // Zero everything else + m[0][3] = 0.0f; + m[1][3] = 0.0f; + m[2][3] = 0.0f; + m[3][0] = 0.0f; + m[3][1] = 0.0f; + m[3][2] = 0.0f; + m[3][3] = 1.0f; +} + + //----------------------------------------------------------------------------- // Sets matrix to identity //----------------------------------------------------------------------------- diff --git a/sp/src/public/VGuiMatSurface/IMatSystemSurface.h b/sp/src/public/VGuiMatSurface/IMatSystemSurface.h index ddc73e69..03ff33b0 100644 --- a/sp/src/public/VGuiMatSurface/IMatSystemSurface.h +++ b/sp/src/public/VGuiMatSurface/IMatSystemSurface.h @@ -105,6 +105,10 @@ public: // Gets a material bound to a surface texture ID virtual IMaterial *DrawGetTextureMaterial( int id ) = 0; + + // The matching method is in ISurface, but we can't add anything there and remain mod-compatible. + // So this goes here instead. + virtual void GetFullscreenViewportAndRenderTarget( int & x, int & y, int & w, int & h, ITexture **ppRenderTarget ) = 0; }; diff --git a/sp/src/public/XUnzip.cpp b/sp/src/public/XUnzip.cpp index bd7dc20e..cea57582 100644 --- a/sp/src/public/XUnzip.cpp +++ b/sp/src/public/XUnzip.cpp @@ -4474,15 +4474,7 @@ bool SafeUnzipMemory( const void *pvZipped, int cubZipped, void *pvDest, int cub int iRes = ZR_CORRUPT; if ( hZip ) { - try - { - iRes = UnzipItem( hZip, 0, pvDest, cubDest, ZIP_MEMORY ); - } - catch ( ... ) - { - // failed to unzip, try to continue - iRes = ZR_CORRUPT; - } + iRes = UnzipItem( hZip, 0, pvDest, cubDest, ZIP_MEMORY ); CloseZip( hZip ); } diff --git a/sp/src/public/bone_setup.cpp b/sp/src/public/bone_setup.cpp index 0cc81c67..250133d5 100644 --- a/sp/src/public/bone_setup.cpp +++ b/sp/src/public/bone_setup.cpp @@ -678,6 +678,12 @@ static void CalcLocalHierarchyAnimation( int boneMask ) { +#ifdef STAGING_ONLY + Assert( iNewParent == -1 || (iNewParent >= 0 && iNewParent < MAXSTUDIOBONES) ); + Assert( iBone > 0 ); + Assert( iBone < MAXSTUDIOBONES ); +#endif // STAGING_ONLY + Vector localPos; Quaternion localQ; @@ -715,12 +721,19 @@ static void CalcLocalHierarchyAnimation( CalcDecompressedAnimation( pHierarchy->pLocalAnim(), iFrame - pHierarchy->iStart, flFraq, localPos, localQ ); BuildBoneChain( pStudioHdr, rootXform, pos, q, iBone, boneToWorld, boneComputed ); - BuildBoneChain( pStudioHdr, rootXform, pos, q, iNewParent, boneToWorld, boneComputed ); matrix3x4_t localXform; AngleMatrix( localQ, localPos, localXform ); - ConcatTransforms( boneToWorld[iNewParent], localXform, boneToWorld[iBone] ); + if ( iNewParent != -1 ) + { + BuildBoneChain( pStudioHdr, rootXform, pos, q, iNewParent, boneToWorld, boneComputed ); + ConcatTransforms( boneToWorld[iNewParent], localXform, boneToWorld[iBone] ); + } + else + { + boneToWorld[iBone] = localXform; + } // back solve Vector p1; @@ -995,10 +1008,17 @@ static void CalcVirtualAnimation( virtualmodel_t *pVModel, const CStudioHdr *pSt int iBone = pAnimGroup->masterBone[pHierarchy->iBone]; if (iBone >= 0 && (pStudioHdr->boneFlags(iBone) & boneMask)) { - int iNewParent = pAnimGroup->masterBone[pHierarchy->iNewParent]; - if (iNewParent >= 0 && (pStudioHdr->boneFlags(iNewParent) & boneMask)) + if ( pHierarchy->iNewParent != -1 ) { - CalcLocalHierarchyAnimation( pStudioHdr, boneToWorld, boneComputed, pos, q, pbone, pHierarchy, iBone, iNewParent, cycle, iFrame, s, boneMask ); + int iNewParent = pAnimGroup->masterBone[pHierarchy->iNewParent]; + if (iNewParent >= 0 && (pStudioHdr->boneFlags(iNewParent) & boneMask)) + { + CalcLocalHierarchyAnimation( pStudioHdr, boneToWorld, boneComputed, pos, q, pbone, pHierarchy, iBone, iNewParent, cycle, iFrame, s, boneMask ); + } + } + else + { + CalcLocalHierarchyAnimation( pStudioHdr, boneToWorld, boneComputed, pos, q, pbone, pHierarchy, iBone, -1, cycle, iFrame, s, boneMask ); } } } @@ -5948,3 +5968,81 @@ bool Studio_PrefetchSequence( const CStudioHdr *pStudioHdr, int iSequence ) // Everything for this sequence is resident? return !pendingload; } + + +//----------------------------------------------------------------------------- +// Purpose: Drive a flex controller from a component of a bone +//----------------------------------------------------------------------------- +void Studio_RunBoneFlexDrivers( float *pflFlexControllerWeights, const CStudioHdr *pStudioHdr, const Vector *pvPositions, const matrix3x4_t *pBoneToWorld, const matrix3x4_t &mRootToWorld ) +{ + bool bRootToWorldInvComputed = false; + matrix3x4_t mRootToWorldInv; + matrix3x4_t mParentInv; + matrix3x4_t mBoneLocal; + + const int nBoneFlexDriverCount = pStudioHdr->BoneFlexDriverCount(); + + for ( int i = 0; i < nBoneFlexDriverCount; ++i ) + { + const mstudioboneflexdriver_t *pBoneFlexDriver = pStudioHdr->BoneFlexDriver( i ); + const mstudiobone_t *pStudioBone = pStudioHdr->pBone( pBoneFlexDriver->m_nBoneIndex ); + + const int nControllerCount = pBoneFlexDriver->m_nControlCount; + + if ( pStudioBone->flags & BONE_USED_BY_BONE_MERGE ) + { + // The local space version of the bone is not available if this is a bonemerged bone + // so do the slow computation of the local version of the bone from boneToWorld + + if ( pStudioBone->parent < 0 ) + { + if ( !bRootToWorldInvComputed ) + { + MatrixInvert( mRootToWorld, mRootToWorldInv ); + bRootToWorldInvComputed = true; + } + + MatrixMultiply( mRootToWorldInv, pBoneToWorld[ pBoneFlexDriver->m_nBoneIndex ], mBoneLocal ); + } + else + { + MatrixInvert( pBoneToWorld[ pStudioBone->parent ], mParentInv ); + MatrixMultiply( mParentInv, pBoneToWorld[ pBoneFlexDriver->m_nBoneIndex ], mBoneLocal ); + } + + for ( int j = 0; j < nControllerCount; ++j ) + { + const mstudioboneflexdrivercontrol_t *pController = pBoneFlexDriver->pBoneFlexDriverControl( j ); + const mstudioflexcontroller_t *pFlexController = pStudioHdr->pFlexcontroller( static_cast< LocalFlexController_t >( pController->m_nFlexControllerIndex ) ); + + if ( pFlexController->localToGlobal < 0 ) + continue; + + Assert( pController->m_nFlexControllerIndex >= 0 && pController->m_nFlexControllerIndex < pStudioHdr->numflexcontrollers() ); + Assert( pController->m_nBoneComponent >= 0 && pController->m_nBoneComponent <= 2 ); + pflFlexControllerWeights[pFlexController->localToGlobal] = + RemapValClamped( mBoneLocal[pController->m_nBoneComponent][3], pController->m_flMin, pController->m_flMax, 0.0f, 1.0f ); + } + } + else + { + // Use the local space version of the bone directly for non-bonemerged bones + + const Vector &position = pvPositions[ pBoneFlexDriver->m_nBoneIndex ]; + + for ( int j = 0; j < nControllerCount; ++j ) + { + const mstudioboneflexdrivercontrol_t *pController = pBoneFlexDriver->pBoneFlexDriverControl( j ); + const mstudioflexcontroller_t *pFlexController = pStudioHdr->pFlexcontroller( static_cast< LocalFlexController_t >( pController->m_nFlexControllerIndex ) ); + + if ( pFlexController->localToGlobal < 0 ) + continue; + + Assert( pController->m_nFlexControllerIndex >= 0 && pController->m_nFlexControllerIndex < pStudioHdr->numflexcontrollers() ); + Assert( pController->m_nBoneComponent >= 0 && pController->m_nBoneComponent <= 2 ); + pflFlexControllerWeights[pFlexController->localToGlobal] = + RemapValClamped( position[pController->m_nBoneComponent], pController->m_flMin, pController->m_flMax, 0.0f, 1.0f ); + } + } + } +} diff --git a/sp/src/public/bone_setup.h b/sp/src/public/bone_setup.h index ebbdfd57..76f00a66 100644 --- a/sp/src/public/bone_setup.h +++ b/sp/src/public/bone_setup.h @@ -444,4 +444,6 @@ void QuaternionMA( const Quaternion &p, float s, const Quaternion &q, Quaternion bool Studio_PrefetchSequence( const CStudioHdr *pStudioHdr, int iSequence ); +void Studio_RunBoneFlexDrivers( float *pFlexController, const CStudioHdr *pStudioHdr, const Vector *pPositions, const matrix3x4_t *pBoneToWorld, const matrix3x4_t &mRootToWorld ); + #endif // BONE_SETUP_H diff --git a/sp/src/public/filesystem_init.cpp b/sp/src/public/filesystem_init.cpp index 08e8da17..36b484f5 100644 --- a/sp/src/public/filesystem_init.cpp +++ b/sp/src/public/filesystem_init.cpp @@ -224,6 +224,7 @@ CFSSearchPathsInit::CFSSearchPathsInit() m_pDirectoryName = NULL; m_pLanguage = NULL; m_ModPath[0] = 0; + m_bMountHDContent = m_bLowViolence = false; } @@ -460,52 +461,6 @@ FSReturnCode_t LoadGameInfoFile( return FS_OK; } -// checks the registry for the low violence setting -// Check "HKEY_CURRENT_USER\Software\Valve\Source\Settings" and "User Token 2" or "User Token 3" -bool IsLowViolenceBuild( void ) -{ -#if defined(_WIN32) - HKEY hKey; - char szValue[64]; - unsigned long len = sizeof(szValue) - 1; - bool retVal = false; - - if ( IsPC() && RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Valve\\Source\\Settings", NULL, KEY_READ, &hKey) == ERROR_SUCCESS ) - { - // User Token 2 - if ( RegQueryValueEx( hKey, "User Token 2", NULL, NULL, (unsigned char*)szValue, &len ) == ERROR_SUCCESS ) - { - if ( Q_strlen( szValue ) > 0 ) - { - retVal = true; - } - } - - if ( !retVal ) - { - // reset "len" for the next check - len = sizeof(szValue) - 1; - - // User Token 3 - if ( RegQueryValueEx( hKey, "User Token 3", NULL, NULL, (unsigned char*)szValue, &len ) == ERROR_SUCCESS ) - { - if ( Q_strlen( szValue ) > 0 ) - { - retVal = true; - } - } - } - - RegCloseKey(hKey); - } - - return retVal; -#elif POSIX - return false; -#else - #error "Fix me" -#endif -} static void FileSystem_AddLoadedSearchPath( CFSSearchPathsInit &initInfo, @@ -519,13 +474,26 @@ static void FileSystem_AddLoadedSearchPath( { // Not in LV build, don't mount - if ( !bLowViolence ) + if ( !initInfo.m_bLowViolence ) return; // Mount, as a game path pPathID = "game"; } + // Check for mounting HD game content if enabled + if ( V_stricmp( pPathID, "game_hd" ) == 0 ) + { + + // Not in LV build, don't mount + if ( !initInfo.m_bMountHDContent ) + return; + + // Mount, as a game path + pPathID = "game"; + } + + // Special processing for ordinary game folders if ( V_stristr( fullLocationPath, ".vpk" ) == NULL && Q_stricmp( pPathID, "game" ) == 0 ) { @@ -600,7 +568,7 @@ FSReturnCode_t FileSystem_LoadSearchPaths( CFSSearchPathsInit &initInfo ) } } - bool bLowViolence = IsLowViolenceBuild(); + bool bLowViolence = initInfo.m_bLowViolence; for ( KeyValues *pCur=pSearchPaths->GetFirstValue(); pCur; pCur=pCur->GetNextValue() ) { const char *pLocation = pCur->GetString(); diff --git a/sp/src/public/filesystem_init.h b/sp/src/public/filesystem_init.h index 182ea411..d95e7c3a 100644 --- a/sp/src/public/filesystem_init.h +++ b/sp/src/public/filesystem_init.h @@ -156,6 +156,9 @@ public: // This is the filesystem FileSystem_LoadSearchPaths is talking to. IFileSystem *m_pFileSystem; + bool m_bMountHDContent; + bool m_bLowViolence; + // Outputs. public: // This is the location of the first search path called "game", which also becomes your "mod" search path. diff --git a/sp/src/public/materialsystem/imaterialsystem.h b/sp/src/public/materialsystem/imaterialsystem.h index 9a16b9db..812eb262 100644 --- a/sp/src/public/materialsystem/imaterialsystem.h +++ b/sp/src/public/materialsystem/imaterialsystem.h @@ -524,7 +524,8 @@ enum RenderTargetSizeMode_t RT_SIZE_FULL_FRAME_BUFFER=4, // Same size as frame buffer, or next lower power of 2 if we can't do that. RT_SIZE_OFFSCREEN=5, // Target of specified size, don't mess with dimensions RT_SIZE_FULL_FRAME_BUFFER_ROUNDED_UP=6, // Same size as the frame buffer, rounded up if necessary for systems that can't do non-power of two textures. - RT_SIZE_REPLAY_SCREENSHOT = 7 // Rounded down to power of 2, essentially... + RT_SIZE_REPLAY_SCREENSHOT = 7, // Rounded down to power of 2, essentially... + RT_SIZE_LITERAL = 8 // Use the size passed in. Don't clamp it to the frame buffer size. Really. }; typedef void (*MaterialBufferReleaseFunc_t)( ); @@ -1028,6 +1029,16 @@ public: #ifdef DX_TO_GL_ABSTRACTION virtual void DoStartupShaderPreloading( void ) = 0; #endif + + // Sets the override sizes for all render target size tests. These replace the frame buffer size. + // Set them when you are rendering primarily to something larger than the frame buffer (as in VR mode). + virtual void SetRenderTargetFrameBufferSizeOverrides( int nWidth, int nHeight ) = 0; + + // Returns the (possibly overridden) framebuffer size for render target sizing. + virtual void GetRenderTargetFrameBufferDimensions( int & nWidth, int & nHeight ) = 0; + + // returns the display device name that matches the adapter index we were started with + virtual char *GetDisplayDeviceName() const = 0; }; @@ -1482,7 +1493,7 @@ public: // Returns whether a pointer is render data. NOTE: passing NULL returns true virtual bool IsRenderData( const void *pData ) const = 0; virtual void PrintfVA( char *fmt, va_list vargs ) = 0; - virtual void Printf( PRINTF_FORMAT_STRING char *fmt, ... ) = 0; + virtual void Printf( PRINTF_FORMAT_STRING const char *fmt, ... ) = 0; virtual float Knob( char *knobname, float *setvalue = NULL ) = 0; // Allows us to override the alpha write setting of a material virtual void OverrideAlphaWriteEnable( bool bEnable, bool bAlphaWriteEnable ) = 0; diff --git a/sp/src/public/materialsystem/materialsystem_config.h b/sp/src/public/materialsystem/materialsystem_config.h index b0fe3a27..2908d2ce 100644 --- a/sp/src/public/materialsystem/materialsystem_config.h +++ b/sp/src/public/materialsystem/materialsystem_config.h @@ -33,6 +33,7 @@ enum MaterialSystem_Config_Flags_t MATSYS_VIDCFG_FLAGS_SCALE_TO_OUTPUT_RESOLUTION = ( 1 << 14 ), MATSYS_VIDCFG_FLAGS_USING_MULTIPLE_WINDOWS = ( 1 << 15 ), MATSYS_VIDCFG_FLAGS_DISABLE_PHONG = ( 1 << 16 ), + MATSYS_VIDCFG_FLAGS_VR_MODE = ( 1 << 17 ), }; struct MaterialSystemHardwareIdentifier_t @@ -64,6 +65,7 @@ struct MaterialSystem_Config_t bool ScaleToOutputResolution() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_SCALE_TO_OUTPUT_RESOLUTION ) != 0; } bool UsingMultipleWindows() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_USING_MULTIPLE_WINDOWS ) != 0; } bool UsePhong() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_DISABLE_PHONG ) == 0; } + bool VRMode() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_VR_MODE) != 0; } bool ShadowDepthTexture() const { return m_bShadowDepthTexture; } bool MotionBlur() const { return m_bMotionBlur; } bool SupportFlashlight() const { return m_bSupportFlashlight; } @@ -140,6 +142,8 @@ struct MaterialSystem_Config_t bool m_bMotionBlur; bool m_bSupportFlashlight; + int m_nVRModeAdapter; + MaterialSystem_Config_t() { memset( this, 0, sizeof( *this ) ); @@ -160,6 +164,7 @@ struct MaterialSystem_Config_t SetFlag( MATSYS_VIDCFG_FLAGS_SCALE_TO_OUTPUT_RESOLUTION, false ); SetFlag( MATSYS_VIDCFG_FLAGS_USING_MULTIPLE_WINDOWS, false ); SetFlag( MATSYS_VIDCFG_FLAGS_DISABLE_PHONG, false ); + SetFlag( MATSYS_VIDCFG_FLAGS_VR_MODE, false ); m_VideoMode.m_Width = 640; m_VideoMode.m_Height = 480; @@ -182,6 +187,8 @@ struct MaterialSystem_Config_t m_bMotionBlur = false; m_bSupportFlashlight = true; + m_nVRModeAdapter = -1; + // misc defaults bAllowCheats = false; bCompressedTextures = true; diff --git a/sp/src/public/mathlib/vector.h b/sp/src/public/mathlib/vector.h index c19261d7..a797da25 100644 --- a/sp/src/public/mathlib/vector.h +++ b/sp/src/public/mathlib/vector.h @@ -1187,7 +1187,7 @@ inline Vector &AllocTempVector() } ThreadPause(); } - return s_vecTemp[nIndex & 0xffff]; + return s_vecTemp[nIndex]; } diff --git a/sp/src/public/mathlib/vmatrix.h b/sp/src/public/mathlib/vmatrix.h index 2c536672..c18e4822 100644 --- a/sp/src/public/mathlib/vmatrix.h +++ b/sp/src/public/mathlib/vmatrix.h @@ -200,6 +200,9 @@ public: // Setup a matrix for origin and angles. void SetupMatrixOrgAngles( const Vector &origin, const QAngle &vAngles ); + // Setup a matrix for angles and no translation. + void SetupMatrixAngles( const QAngle &vAngles ); + // General inverse. This may fail so check the return! bool InverseGeneral(VMatrix &vInverse) const; diff --git a/sp/src/public/matsys_controls/mdlpanel.h b/sp/src/public/matsys_controls/mdlpanel.h index 8f0ccb30..91f936e7 100644 --- a/sp/src/public/matsys_controls/mdlpanel.h +++ b/sp/src/public/matsys_controls/mdlpanel.h @@ -51,6 +51,8 @@ public: virtual void OnTick(); + virtual void Paint(); + // Sets the current mdl virtual void SetMDL( MDLHandle_t handle, void *pProxyData = NULL ); virtual void SetMDL( const char *pMDLName, void *pProxyData = NULL ); @@ -78,6 +80,7 @@ public: void SetSkin( int nSkin ); void SetLookAtCamera( bool bLookAtCamera ); void SetIgnoreDoubleClick( bool bState ); + void SetThumbnailSafeZone( bool bVisible ); // Bounds. bool GetBoundingBox( Vector &vecBoundsMin, Vector &vecBoundsMax ); @@ -103,6 +106,8 @@ public: protected: + virtual void SetupRenderState( int nDisplayWidth, int nDisplayHeight ) OVERRIDE; + struct MDLData_t { CMDL m_MDL; @@ -122,7 +127,7 @@ protected: private: // paint it! - void OnPaint3D(); + virtual void OnPaint3D(); virtual void PrePaint3D( IMatRenderContext *pRenderContext ) { }; virtual void PostPaint3D( IMatRenderContext *pRenderContext ) { }; virtual void RenderingMergedModel( IMatRenderContext *pRenderContext, CStudioHdr *pStudioHdr, MDLHandle_t mdlHandle, matrix3x4_t *pWorldMatrix ) { }; @@ -141,6 +146,7 @@ private: bool m_bWireFrame : 1; bool m_bLookAtCamera : 1; bool m_bIgnoreDoubleClick : 1; + bool m_bThumbnailSafeZone : 1; float m_PoseParameters[ MAXSTUDIOPOSEPARAM ]; }; diff --git a/sp/src/public/matsys_controls/mdlpicker.h b/sp/src/public/matsys_controls/mdlpicker.h index 202167c5..fcacfc9c 100644 --- a/sp/src/public/matsys_controls/mdlpicker.h +++ b/sp/src/public/matsys_controls/mdlpicker.h @@ -101,6 +101,7 @@ private: void WriteBackbackVMTFiles( const char *assetName ); void GenerateBackpackIcons( void ); + CUtlString GetOutputFileSuffix(); MESSAGE_FUNC_PARAMS( OnCheckButtonChecked, "CheckButtonChecked", kv ); MESSAGE_FUNC_PARAMS( OnItemSelected, "ItemSelected", kv ); diff --git a/sp/src/public/matsys_controls/potterywheelpanel.h b/sp/src/public/matsys_controls/potterywheelpanel.h index 8cb41497..47125a3f 100644 --- a/sp/src/public/matsys_controls/potterywheelpanel.h +++ b/sp/src/public/matsys_controls/potterywheelpanel.h @@ -131,8 +131,9 @@ protected: bool m_bRenderToTexture; + virtual void SetupRenderState( int nDisplayWidth, int nDisplayHeight ); + private: - void SetupRenderState( int nDisplayWidth, int nDisplayHeight ); void CreateDefaultLights(); void DestroyLights(); diff --git a/sp/src/public/shaderapi/IShaderDevice.h b/sp/src/public/shaderapi/IShaderDevice.h index 34749de0..832e6ac7 100644 --- a/sp/src/public/shaderapi/IShaderDevice.h +++ b/sp/src/public/shaderapi/IShaderDevice.h @@ -271,6 +271,7 @@ public: #ifdef DX_TO_GL_ABSTRACTION virtual void DoStartupShaderPreloading( void ) = 0; #endif + virtual char *GetDisplayDeviceName() = 0; }; diff --git a/sp/src/public/shaderapi/ishaderapi.h b/sp/src/public/shaderapi/ishaderapi.h index 69782a60..367cd0e9 100644 --- a/sp/src/public/shaderapi/ishaderapi.h +++ b/sp/src/public/shaderapi/ishaderapi.h @@ -603,7 +603,7 @@ public: // debug logging // only implemented in some subclasses virtual void PrintfVA( char *fmt, va_list vargs ) = 0; - virtual void Printf( PRINTF_FORMAT_STRING char *fmt, ... ) = 0; + virtual void Printf( PRINTF_FORMAT_STRING const char *fmt, ... ) = 0; virtual float Knob( char *knobname, float *setvalue = NULL ) = 0; // Allows us to override the alpha write setting of a material virtual void OverrideAlphaWriteEnable( bool bEnable, bool bAlphaWriteEnable ) = 0; diff --git a/mp/src/public/headtrack/isourcevirtualreality.h b/sp/src/public/sourcevr/isourcevirtualreality.h similarity index 64% rename from mp/src/public/headtrack/isourcevirtualreality.h rename to sp/src/public/sourcevr/isourcevirtualreality.h index 291d28a6..3e438455 100644 --- a/mp/src/public/headtrack/isourcevirtualreality.h +++ b/sp/src/public/sourcevr/isourcevirtualreality.h @@ -21,21 +21,19 @@ //----------------------------------------------------------------------------- // forward declarations //----------------------------------------------------------------------------- +class ITexture; +class IMaterialSystem; //----------------------------------------------------------------------------- // important enumeration //----------------------------------------------------------------------------- -struct VRTrackerState_t + +struct VRRect_t { - // Tracker has finished starting up and has produced at least one valid pose. - bool bInitialized; - - // Tracker currently has a valid pose. - bool bHasValidPose; - - // Tracker is in a state where it is likely to suffer from yaw drift. This - // would apply to any gyro-only tracking system. - bool bWillDriftInYaw; + int32 nX; + int32 nY; + int32 nWidth; + int32 nHeight; }; @@ -69,6 +67,14 @@ public: VREye_Right }; + // Which texture is being requested in GetRenderTarget? + enum EWhichRenderTarget + { + RT_Color = 0, + RT_Depth, + }; + + // ---------------------------------------------------------------------- // General utilities // ---------------------------------------------------------------------- @@ -76,24 +82,17 @@ public: // Returns true if the game should run in VR mode virtual bool ShouldRunInVR() = 0; - // The name of the display at which the game should put its window. - // TODO: This is pretty horrible from a "what the game has to do" point - // of view. Make it better. - virtual const char *GetDisplayName() = 0; - - // The size of the window that the game should create - virtual bool GetWindowSize( int *pnWidth, int *pnHeight ) = 0; - - // Lets engine tell headtrack that it's going to use a different size window based - // what the display is actually using. This happens when somebody clones - // their desktop onto the HMD - virtual void OverrideWindowSize( int nWidth, int nHeight ) = 0; + // Returns true if there is a compatible HMD connected + virtual bool IsHmdConnected() = 0; // The size and position of the viewport for the specified eye virtual void GetViewportBounds( VREye eEye, int *pnX, int *pnY, int *pnWidth, int *pnHeight ) = 0; // Performs the distortion post-processing. - virtual bool DoDistortionProcessing ( const vrect_t *SrcRect ) = 0; + virtual bool DoDistortionProcessing ( VREye eEye ) = 0; + + // Composites the HUD directly onto the backbuffer / render target, including undistort. + virtual bool CompositeHud ( VREye eEye, float ndcHudBounds[4], bool bDoUndistort, bool bBlackout, bool bTranslucent ) = 0; // ---------------------------------------------------------------------- // Getting the current pose @@ -102,13 +101,6 @@ public: // returns the pose relative to the zero point virtual VMatrix GetMideyePose() = 0; - // returns the gravity-relative HUD correction matrix (I think) - virtual VMatrix GetHudUpCorrection() = 0; - - // transforms to mid eye form left/right - virtual VMatrix GetMidEyeFromLeft() = 0; - virtual VMatrix GetMidEyeFromRight() = 0; - // All-in-one interfaces (they call GetCameraPoseZeroFromCurrent) // Grabs the current tracking data and sets up state for the Override* calls. virtual bool SampleTrackingState ( float PlayerGameFov, float fPredictionSeconds ) = 0; @@ -117,41 +109,49 @@ public: // Information about the display // ---------------------------------------------------------------------- - // returns the serial number for the display or NULL if no serial number - // could be retrieved - virtual const char *GetDisplaySerialNumber() = 0; - - // returns the model number for the display or NULL if no model number - // could be retrieved - virtual const char *GetDisplayModelNumber() = 0; - - // returns the "ipd" of the display. This is the separation of the centers - // of the two lenses in mm - virtual float GetDisplaySeparationMM() = 0; + // Passes back the bounds of the window that the game should create. This might + // span two displays if we're dealing with a two-input display. Returns true + // if the bounds were set. + virtual bool GetDisplayBounds( VRRect_t *pRect ) = 0; // Computes and returns the projection matrix for the eye virtual bool GetEyeProjectionMatrix ( VMatrix *pResult, VREye, float zNear, float zFar, float fovScale ) = 0; - // Returns the horizontal FOV of the display in degrees - virtual float GetHorizontalFOVDegrees() = 0; - - // ---------------------------------------------------------------------- - // Information about the user - // ---------------------------------------------------------------------- - - // returns the intrapupilar distance of the user in mm - virtual float GetUserIPDMM() = 0; - - // sets the intrapupilar distance of the user in mm - virtual void SetUserIPDMM( float fIPDMM ) = 0; + // Returns the transform from the mid-eye to the specified eye. Multiply this by + // the tweaked (for mouse rotation and WASD translation) mideye position to get the + // view matrix. This matrix takes the user's IPD into account. + virtual VMatrix GetMidEyeFromEye( VREye eEye ) = 0; + // returns the adapter index to use for VR mode + virtual int GetVRModeAdapter() = 0; // ---------------------------------------------------------------------- // Information about the tracker // ---------------------------------------------------------------------- - // returns the state of the tracking system - virtual VRTrackerState_t GetTrackerState() = 0; + virtual bool WillDriftInYaw() = 0; + + // ---------------------------------------------------------------------- + // Methods about oversized offscreen rendering + // ---------------------------------------------------------------------- + + // Sets up the pre-distortion render targets. + virtual void CreateRenderTargets( IMaterialSystem *pMaterialSystem ) = 0; + virtual void ShutdownRenderTargets() = 0; + + // fetches the render target for the specified eye + virtual ITexture *GetRenderTarget( VREye eEye, EWhichRenderTarget eWhich ) = 0; + + // Returns the (possibly overridden) framebuffer size for render target sizing. + virtual void GetRenderTargetFrameBufferDimensions( int & nWidth, int & nHeight ) = 0; + + // ---------------------------------------------------------------------- + // Enter/leave VR mode + // ---------------------------------------------------------------------- + virtual bool Activate() = 0; + virtual void Deactivate() = 0; + + }; diff --git a/sp/src/public/studio.h b/sp/src/public/studio.h index 95f22a36..bcc38d5d 100644 --- a/sp/src/public/studio.h +++ b/sp/src/public/studio.h @@ -313,6 +313,63 @@ private: }; +//----------------------------------------------------------------------------- +// The component of the bone used by mstudioboneflexdriver_t +//----------------------------------------------------------------------------- +enum StudioBoneFlexComponent_t +{ + STUDIO_BONE_FLEX_INVALID = -1, // Invalid + STUDIO_BONE_FLEX_TX = 0, // Translate X + STUDIO_BONE_FLEX_TY = 1, // Translate Y + STUDIO_BONE_FLEX_TZ = 2 // Translate Z +}; + + +//----------------------------------------------------------------------------- +// Component is one of Translate X, Y or Z [0,2] (StudioBoneFlexComponent_t) +//----------------------------------------------------------------------------- +struct mstudioboneflexdrivercontrol_t +{ + DECLARE_BYTESWAP_DATADESC(); + + int m_nBoneComponent; // Bone component that drives flex, StudioBoneFlexComponent_t + int m_nFlexControllerIndex; // Flex controller to drive + float m_flMin; // Min value of bone component mapped to 0 on flex controller + float m_flMax; // Max value of bone component mapped to 1 on flex controller + + mstudioboneflexdrivercontrol_t(){} +private: + // No copy constructors allowed + mstudioboneflexdrivercontrol_t( const mstudioboneflexdrivercontrol_t &vOther ); +}; + + +//----------------------------------------------------------------------------- +// Drive flex controllers from bone components +//----------------------------------------------------------------------------- +struct mstudioboneflexdriver_t +{ + DECLARE_BYTESWAP_DATADESC(); + + int m_nBoneIndex; // Bone to drive flex controller + int m_nControlCount; // Number of flex controllers being driven + int m_nControlIndex; // Index into data where controllers are (relative to this) + + inline mstudioboneflexdrivercontrol_t *pBoneFlexDriverControl( int i ) const + { + Assert( i >= 0 && i < m_nControlCount ); + return (mstudioboneflexdrivercontrol_t *)(((byte *)this) + m_nControlIndex) + i; + } + + int unused[3]; + + mstudioboneflexdriver_t(){} +private: + // No copy constructors allowed + mstudioboneflexdriver_t( const mstudioboneflexdriver_t &vOther ); +}; + + #define BONE_CALCULATE_MASK 0x1F #define BONE_PHYSICALLY_SIMULATED 0x01 // bone is physically simulated when physics are active #define BONE_PHYSICS_PROCEDURAL 0x02 // procedural when physics is active @@ -902,33 +959,6 @@ struct mstudioflexcontrollerui_t }; -// these are the on-disk format vertex anims -struct dstudiovertanim_t -{ - unsigned short index; - byte speed; // 255/max_length_in_flex - byte side; // 255/left_right - Vector48 delta; - Vector48 ndelta; - -private: - // No copy constructors allowed - dstudiovertanim_t(const dstudiovertanim_t& vOther); -}; - - -struct dstudiovertanim_wrinkle_t : public dstudiovertanim_t -{ - short wrinkledelta; // Encodes a range from -1 to 1. NOTE: -32768 == -32767 == -1.0f, 32767 = 1.0f - -private: - // No copy constructors allowed - dstudiovertanim_wrinkle_t( const dstudiovertanim_t& vOther ); -}; - -const float g_VertAnimFixedPointScale = 1.0f / 4096.0f; -const float g_VertAnimFixedPointScaleInv = 1.0f / g_VertAnimFixedPointScale; - // this is the memory image of vertex anims (16-bit fixed point) struct mstudiovertanim_t { @@ -952,21 +982,31 @@ protected: }; public: - inline Vector GetDeltaFixed() + inline void ConvertToFixed( float flVertAnimFixedPointScale ) { - return Vector( delta[0]*g_VertAnimFixedPointScale, delta[1]*g_VertAnimFixedPointScale, delta[2]*g_VertAnimFixedPointScale ); + delta[0] = flDelta[0].GetFloat() / flVertAnimFixedPointScale; + delta[1] = flDelta[1].GetFloat() / flVertAnimFixedPointScale; + delta[2] = flDelta[2].GetFloat() / flVertAnimFixedPointScale; + ndelta[0] = flNDelta[0].GetFloat() / flVertAnimFixedPointScale; + ndelta[1] = flNDelta[1].GetFloat() / flVertAnimFixedPointScale; + ndelta[2] = flNDelta[2].GetFloat() / flVertAnimFixedPointScale; } - inline Vector GetNDeltaFixed() + + inline Vector GetDeltaFixed( float flVertAnimFixedPointScale ) { - return Vector( ndelta[0]*g_VertAnimFixedPointScale, ndelta[1]*g_VertAnimFixedPointScale, ndelta[2]*g_VertAnimFixedPointScale ); + return Vector( delta[0] * flVertAnimFixedPointScale, delta[1] * flVertAnimFixedPointScale, delta[2] * flVertAnimFixedPointScale ); } - inline void GetDeltaFixed4DAligned( Vector4DAligned *vFillIn ) + inline Vector GetNDeltaFixed( float flVertAnimFixedPointScale ) { - vFillIn->Set( delta[0]*g_VertAnimFixedPointScale, delta[1]*g_VertAnimFixedPointScale, delta[2]*g_VertAnimFixedPointScale, 0.0f ); + return Vector( ndelta[0] * flVertAnimFixedPointScale, ndelta[1] * flVertAnimFixedPointScale, ndelta[2] * flVertAnimFixedPointScale ); } - inline void GetNDeltaFixed4DAligned( Vector4DAligned *vFillIn ) + inline void GetDeltaFixed4DAligned( Vector4DAligned *vFillIn, float flVertAnimFixedPointScale ) { - vFillIn->Set( ndelta[0]*g_VertAnimFixedPointScale, ndelta[1]*g_VertAnimFixedPointScale, ndelta[2]*g_VertAnimFixedPointScale, 0.0f ); + vFillIn->Set( delta[0] * flVertAnimFixedPointScale, delta[1] * flVertAnimFixedPointScale, delta[2] * flVertAnimFixedPointScale, 0.0f ); + } + inline void GetNDeltaFixed4DAligned( Vector4DAligned *vFillIn, float flVertAnimFixedPointScale ) + { + vFillIn->Set( ndelta[0] * flVertAnimFixedPointScale, ndelta[1] * flVertAnimFixedPointScale, ndelta[2] * flVertAnimFixedPointScale, 0.0f ); } inline Vector GetDeltaFloat() { @@ -976,17 +1016,17 @@ public: { return Vector (flNDelta[0].GetFloat(), flNDelta[1].GetFloat(), flNDelta[2].GetFloat()); } - inline void SetDeltaFixed( const Vector& vInput ) + inline void SetDeltaFixed( const Vector& vInput, float flVertAnimFixedPointScale ) { - delta[0] = vInput.x * g_VertAnimFixedPointScaleInv; - delta[1] = vInput.y * g_VertAnimFixedPointScaleInv; - delta[2] = vInput.z * g_VertAnimFixedPointScaleInv; + delta[0] = vInput.x / flVertAnimFixedPointScale; + delta[1] = vInput.y / flVertAnimFixedPointScale; + delta[2] = vInput.z / flVertAnimFixedPointScale; } - inline void SetNDeltaFixed( const Vector& vInputNormal ) + inline void SetNDeltaFixed( const Vector& vInputNormal, float flVertAnimFixedPointScale ) { - ndelta[0] = vInputNormal.x * g_VertAnimFixedPointScaleInv; - ndelta[1] = vInputNormal.y * g_VertAnimFixedPointScaleInv; - ndelta[2] = vInputNormal.z * g_VertAnimFixedPointScaleInv; + ndelta[0] = vInputNormal.x / flVertAnimFixedPointScale; + ndelta[1] = vInputNormal.y / flVertAnimFixedPointScale; + ndelta[2] = vInputNormal.z / flVertAnimFixedPointScale; } // Ick...can also force fp16 data into this structure for writing to file in legacy format... @@ -1003,10 +1043,20 @@ public: flNDelta[2].SetFloat( vInputNormal.z ); } + class CSortByIndex + { + public: + bool operator()(const mstudiovertanim_t &left, const mstudiovertanim_t & right)const + { + return left.index < right.index; + } + }; + friend class CSortByIndex; + mstudiovertanim_t(){} -private: - // No copy constructors allowed - mstudiovertanim_t(const mstudiovertanim_t& vOther); +//private: +// No copy constructors allowed, but it's needed for std::sort() +// mstudiovertanim_t(const mstudiovertanim_t& vOther); }; @@ -1017,20 +1067,25 @@ struct mstudiovertanim_wrinkle_t : public mstudiovertanim_t short wrinkledelta; - inline void SetWrinkleFixed( float flWrinkle ) + inline void SetWrinkleFixed( float flWrinkle, float flVertAnimFixedPointScale ) { - int nWrinkleDeltaInt = flWrinkle * g_VertAnimFixedPointScaleInv; + int nWrinkleDeltaInt = flWrinkle / flVertAnimFixedPointScale; wrinkledelta = clamp( nWrinkleDeltaInt, -32767, 32767 ); } - inline Vector4D GetDeltaFixed() + inline Vector4D GetDeltaFixed( float flVertAnimFixedPointScale ) { - return Vector4D( delta[0]*g_VertAnimFixedPointScale, delta[1]*g_VertAnimFixedPointScale, delta[2]*g_VertAnimFixedPointScale, wrinkledelta*g_VertAnimFixedPointScale ); + return Vector4D( delta[0] * flVertAnimFixedPointScale, delta[1] * flVertAnimFixedPointScale, delta[2] * flVertAnimFixedPointScale, wrinkledelta * flVertAnimFixedPointScale ); } - inline void GetDeltaFixed4DAligned( Vector4DAligned *vFillIn ) + inline void GetDeltaFixed4DAligned( Vector4DAligned *vFillIn, float flVertAnimFixedPointScale ) { - vFillIn->Set( delta[0]*g_VertAnimFixedPointScale, delta[1]*g_VertAnimFixedPointScale, delta[2]*g_VertAnimFixedPointScale, wrinkledelta*g_VertAnimFixedPointScale ); + vFillIn->Set( delta[0] * flVertAnimFixedPointScale, delta[1] * flVertAnimFixedPointScale, delta[2] * flVertAnimFixedPointScale, wrinkledelta * flVertAnimFixedPointScale ); + } + + inline float GetWrinkleDeltaFixed( float flVertAnimFixedPointScale ) + { + return wrinkledelta * flVertAnimFixedPointScale; } }; @@ -1959,6 +2014,9 @@ struct vertexFileFixup_t #define STUDIOHDR_FLAGS_CAST_TEXTURE_SHADOWS ( 1 << 18 ) +// flagged on load to indicate no animation events on this model +#define STUDIOHDR_FLAGS_VERT_ANIM_FIXED_POINT_SCALE ( 1 << 21 ) + // NOTE! Next time we up the .mdl file format, remove studiohdr2_t // and insert all fields in this structure into studiohdr_t. struct studiohdr2_t @@ -1982,7 +2040,11 @@ struct studiohdr2_t int sznameindex; inline char *pszName() { return (sznameindex) ? (char *)(((byte *)this) + sznameindex ) : NULL; } - int reserved[58]; + int m_nBoneFlexDriverCount; + int m_nBoneFlexDriverIndex; + inline mstudioboneflexdriver_t *pBoneFlexDriver( int i ) const { Assert( i >= 0 && i < m_nBoneFlexDriverCount ); return (mstudioboneflexdriver_t *)(((byte *)this) + m_nBoneFlexDriverIndex) + i; } + + int reserved[56]; }; struct studiohdr_t @@ -2229,7 +2291,10 @@ struct studiohdr_t int flexcontrolleruiindex; mstudioflexcontrollerui_t *pFlexControllerUI( int i ) const { Assert( i >= 0 && i < numflexcontrollerui); return (mstudioflexcontrollerui_t *)(((byte *)this) + flexcontrolleruiindex) + i; } - int unused3[2]; + float flVertAnimFixedPointScale; + inline float VertAnimFixedPointScale() const { return ( flags & STUDIOHDR_FLAGS_VERT_ANIM_FIXED_POINT_SCALE ) ? flVertAnimFixedPointScale : 1.0f / 4096.0f; } + + int unused3[1]; // FIXME: Remove when we up the model version. Move all fields of studiohdr2_t into studiohdr_t. int studiohdr2index; @@ -2245,6 +2310,9 @@ struct studiohdr_t inline mstudiolinearbone_t *pLinearBones() const { return studiohdr2index ? pStudioHdr2()->pLinearBones() : NULL; } + inline int BoneFlexDriverCount() const { return studiohdr2index ? pStudioHdr2()->m_nBoneFlexDriverCount : 0; } + inline const mstudioboneflexdriver_t* BoneFlexDriver( int i ) const { Assert( i >= 0 && i < BoneFlexDriverCount() ); return studiohdr2index ? pStudioHdr2()->pBoneFlexDriver( i ) : NULL; } + // NOTE: No room to add stuff? Up the .mdl file format version // [and move all fields in studiohdr2_t into studiohdr_t and kill studiohdr2_t], // or add your stuff to studiohdr2_t. See NumSrcBoneTransforms/SrcBoneTransform for the pattern to use. @@ -2404,6 +2472,11 @@ public: inline mstudiolinearbone_t *pLinearBones() const { return m_pStudioHdr->pLinearBones(); } + inline int BoneFlexDriverCount() const { return m_pStudioHdr->BoneFlexDriverCount(); } + inline const mstudioboneflexdriver_t *BoneFlexDriver( int i ) const { return m_pStudioHdr->BoneFlexDriver( i ); } + + inline float VertAnimFixedPointScale() const { return m_pStudioHdr->VertAnimFixedPointScale(); } + public: int IsSequenceLooping( int iSequence ); float GetSequenceCycleRate( int iSequence ); @@ -2971,6 +3044,9 @@ inline void Studio_SetRootLOD( studiohdr_t *pStudioHdr, int rootLOD ) rootLOD = pStudioHdr->numAllowedRootLODs - 1; } + Assert( rootLOD >= 0 && rootLOD < MAX_NUM_LODS ); + Clamp( rootLOD, 0, MAX_NUM_LODS - 1 ); + // run the lod fixups that culls higher detail lods // vertexes are external, fixups ensure relative offsets and counts are cognizant of shrinking data // indexes are built in lodN..lod0 order so higher detail lod data can be truncated at load diff --git a/sp/src/public/tier0/afxmem_override.cpp b/sp/src/public/tier0/afxmem_override.cpp index 425cabd8..f5794b27 100644 --- a/sp/src/public/tier0/afxmem_override.cpp +++ b/sp/src/public/tier0/afxmem_override.cpp @@ -429,8 +429,7 @@ void* __cdecl operator new(size_t nSize, int nType, LPCSTR lpszFileName, int nLi #endif } -#if 0 -#if _MSC_VER >= 1200 +#if _MSC_VER >= 1700 void __cdecl operator delete(void* p, int nType, LPCSTR /* lpszFileName */, int /* nLine */) { #if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG) @@ -440,19 +439,16 @@ void __cdecl operator delete(void* p, int nType, LPCSTR /* lpszFileName */, int #endif } #endif // _MSC_VER >= 1200 -#endif -#if _MSC_VER >= 1210 +#if _MSC_VER >= 1700 void* __cdecl operator new[](size_t nSize, int nType, LPCSTR lpszFileName, int nLine) { return ::operator new(nSize, nType, lpszFileName, nLine); } -#if 0 void __cdecl operator delete[](void* p, int nType, LPCSTR lpszFileName, int nLine) { ::operator delete(p, nType, lpszFileName, nLine); } -#endif #endif // _MSC_VER >= 1210 #endif //_DEBUG diff --git a/sp/src/public/tier0/dbg.h b/sp/src/public/tier0/dbg.h index ac7930a4..5fe45a1c 100644 --- a/sp/src/public/tier0/dbg.h +++ b/sp/src/public/tier0/dbg.h @@ -247,8 +247,8 @@ DBG_INTERFACE struct SDL_Window * GetAssertDialogParent(); if (!(_exp)) \ { \ _SpewInfo( SPEW_ASSERT, __TFILE__, __LINE__ ); \ - SpewRetval_t ret = _SpewMessage("%s", _msg); \ - CallAssertFailedNotifyFunc( __TFILE__, __LINE__, _msg ); \ + SpewRetval_t ret = _SpewMessage("%s", static_cast( _msg )); \ + CallAssertFailedNotifyFunc( __TFILE__, __LINE__, _msg ); \ _executeExp; \ if ( ret == SPEW_DEBUGGER) \ { \ @@ -343,6 +343,9 @@ DBG_INTERFACE struct SDL_Window * GetAssertDialogParent(); #define AssertEquals( _exp, _expectedValue ) AssertMsg2( (_exp) == (_expectedValue), _T("Expected %d but got %d!"), (_expectedValue), (_exp) ) #define AssertFloatEquals( _exp, _expectedValue, _tol ) AssertMsg2( fabs((_exp) - (_expectedValue)) <= (_tol), _T("Expected %f but got %f!"), (_expectedValue), (_exp) ) #define Verify( _exp ) Assert( _exp ) +#define VerifyMsg1( _exp, _msg, a1 ) AssertMsg1( _exp, _msg, a1 ) +#define VerifyMsg2( _exp, _msg, a1, a2 ) AssertMsg2( _exp, _msg, a1, a2 ) +#define VerifyMsg3( _exp, _msg, a1, a2, a3 ) AssertMsg3( _exp, _msg, a1, a2, a3 ) #define VerifyEquals( _exp, _expectedValue ) AssertEquals( _exp, _expectedValue ) #define DbgVerify( _exp ) Assert( _exp ) @@ -366,6 +369,9 @@ DBG_INTERFACE struct SDL_Window * GetAssertDialogParent(); #define AssertEquals( _exp, _expectedValue ) ((void)0) #define AssertFloatEquals( _exp, _expectedValue, _tol ) ((void)0) #define Verify( _exp ) (_exp) +#define VerifyMsg1( _exp, _msg, a1 ) (_exp) +#define VerifyMsg2( _exp, _msg, a1, a2 ) (_exp) +#define VerifyMsg3( _exp, _msg, a1, a2, a3 ) (_exp) #define VerifyEquals( _exp, _expectedValue ) (_exp) #define DbgVerify( _exp ) (_exp) diff --git a/sp/src/public/tier1/fmtstr.h b/sp/src/public/tier1/fmtstr.h index 8c9ccf47..31ee23c7 100644 --- a/sp/src/public/tier1/fmtstr.h +++ b/sp/src/public/tier1/fmtstr.h @@ -125,7 +125,42 @@ public: } void AppendFormatV( const char *pchFormat, va_list args ); - void Append( const char *pchValue ) { AppendFormat( "%s", pchValue ); } + + void Append( const char *pchValue ) + { + // This function is close to the metal to cut down on the CPU cost + // of the previous incantation of Append which was implemented as + // AppendFormat( "%s", pchValue ). This implementation, though not + // as easy to read, instead does a strcpy from the existing end + // point of the CFmtStrN. This brings something like a 10-20x speedup + // in my rudimentary tests. It isn't using V_strncpy because that + // function doesn't return the number of characters copied, which + // we need to adjust m_nLength. Doing the V_strncpy with a V_strlen + // afterwards took twice as long as this implementations in tests, + // so V_strncpy's implementation was used to write this method. + char *pDest = m_szBuf + m_nLength; + const int maxLen = SIZE_BUF - m_nLength; + char *pLast = pDest + maxLen - 1; + while ( (pDest < pLast) && (*pchValue != 0) ) + { + *pDest = *pchValue; + ++pDest; ++pchValue; + } + *pDest = 0; + m_nLength = pDest - m_szBuf; + } + + //optimized version of append for just adding a single character + void Append( char ch ) + { + if( m_nLength < SIZE_BUF - 1 ) + { + m_szBuf[ m_nLength ] = ch; + m_nLength++; + m_szBuf[ m_nLength ] = '\0'; + } + } + void AppendIndent( uint32 unCount, char chIndent = '\t' ); protected: @@ -193,6 +228,84 @@ typedef CFmtStrQuietTruncationN CFmtStrQuietTruncation; typedef CFmtStrN<1024> CFmtStr1024; typedef CFmtStrN<8192> CFmtStrMax; + +//----------------------------------------------------------------------------- +// Purpose: Fast-path number-to-string helper (with optional quoting) +// Derived off of the Steam CNumStr but with a few tweaks, such as +// trimming off the in-our-cases-unnecessary strlen calls (by not +// storing the length in the class). +//----------------------------------------------------------------------------- + +class CNumStr +{ +public: + CNumStr() { m_szBuf[0] = 0; } + + explicit CNumStr( bool b ) { SetBool( b ); } + + explicit CNumStr( int8 n8 ) { SetInt8( n8 ); } + explicit CNumStr( uint8 un8 ) { SetUint8( un8 ); } + explicit CNumStr( int16 n16 ) { SetInt16( n16 ); } + explicit CNumStr( uint16 un16 ) { SetUint16( un16 ); } + explicit CNumStr( int32 n32 ) { SetInt32( n32 ); } + explicit CNumStr( uint32 un32 ) { SetUint32( un32 ); } + explicit CNumStr( int64 n64 ) { SetInt64( n64 ); } + explicit CNumStr( uint64 un64 ) { SetUint64( un64 ); } + +#if defined(COMPILER_GCC) && defined(PLATFORM_64BITS) + explicit CNumStr( lint64 n64 ) { SetInt64( (int64)n64 ); } + explicit CNumStr( ulint64 un64 ) { SetUint64( (uint64)un64 ); } +#endif + + explicit CNumStr( double f ) { SetDouble( f ); } + explicit CNumStr( float f ) { SetFloat( f ); } + + inline void SetBool( bool b ) { Q_memcpy( m_szBuf, b ? "1" : "0", 2 ); } + +#ifdef _WIN32 + inline void SetInt8( int8 n8 ) { _itoa( (int32)n8, m_szBuf, 10 ); } + inline void SetUint8( uint8 un8 ) { _itoa( (int32)un8, m_szBuf, 10 ); } + inline void SetInt16( int16 n16 ) { _itoa( (int32)n16, m_szBuf, 10 ); } + inline void SetUint16( uint16 un16 ) { _itoa( (int32)un16, m_szBuf, 10 ); } + inline void SetInt32( int32 n32 ) { _itoa( n32, m_szBuf, 10 ); } + inline void SetUint32( uint32 un32 ) { _i64toa( (int64)un32, m_szBuf, 10 ); } + inline void SetInt64( int64 n64 ) { _i64toa( n64, m_szBuf, 10 ); } + inline void SetUint64( uint64 un64 ) { _ui64toa( un64, m_szBuf, 10 ); } +#else + inline void SetInt8( int8 n8 ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%d", (int32)n8 ); } + inline void SetUint8( uint8 un8 ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%d", (int32)un8 ); } + inline void SetInt16( int16 n16 ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%d", (int32)n16 ); } + inline void SetUint16( uint16 un16 ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%d", (int32)un16 ); } + inline void SetInt32( int32 n32 ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%d", n32 ); } + inline void SetUint32( uint32 un32 ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%u", un32 ); } + inline void SetInt64( int64 n64 ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%lld", n64 ); } + inline void SetUint64( uint64 un64 ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%llu", un64 ); } +#endif + + inline void SetDouble( double f ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%.18g", f ); } + inline void SetFloat( float f ) { Q_snprintf( m_szBuf, sizeof(m_szBuf), "%.18g", f ); } + + inline void SetHexUint64( uint64 un64 ) { Q_binarytohex( (byte *)&un64, sizeof( un64 ), m_szBuf, sizeof( m_szBuf ) ); } + + operator const char *() const { return m_szBuf; } + const char* String() const { return m_szBuf; } + + void AddQuotes() + { + Assert( m_szBuf[0] != '"' ); + const int nLength = Q_strlen( m_szBuf ); + Q_memmove( m_szBuf + 1, m_szBuf, nLength ); + m_szBuf[0] = '"'; + m_szBuf[nLength + 1] = '"'; + m_szBuf[nLength + 2] = 0; + } + +protected: + char m_szBuf[28]; // long enough to hold 18 digits of precision, a decimal, a - sign, e+### suffix, and quotes + +}; + + //============================================================================= bool BGetLocalFormattedDateAndTime( time_t timeVal, char *pchDate, int cubDate, char *pchTime, int cubTime ); diff --git a/sp/src/public/togl/osx/cglmbuffer.h b/sp/src/public/togl/osx/cglmbuffer.h index 0b161000..24a0b0fa 100644 --- a/sp/src/public/togl/osx/cglmbuffer.h +++ b/sp/src/public/togl/osx/cglmbuffer.h @@ -1,99 +1,99 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// -// cglmprogram.h -// GLMgr buffers (index / vertex) -// ... maybe add PBO later as well -//=============================================================================== - -#ifndef CGLMBUFFER_H -#define CGLMBUFFER_H - -#pragma once - -// ext links - -// http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt - -//=============================================================================== - -// tokens not in the SDK headers - -//#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT -// #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9 -//#endif - -//=============================================================================== - -// forward declarations - -class GLMContext; - -enum EGLMBufferType -{ - kGLMVertexBuffer, - kGLMIndexBuffer, - kGLMUniformBuffer, // for bindable uniform - kGLMPixelBuffer, // for PBO - - kGLMNumBufferTypes -}; - - // pass this in "options" to constructor to make a dynamic buffer -#define GLMBufferOptionDynamic 0x00000001 - -struct GLMBuffLockParams -{ - uint m_offset; - uint m_size; - bool m_nonblocking; - bool m_discard; -}; - -class CGLMBuffer -{ - -public: - void Lock( GLMBuffLockParams *params, char **addressOut ); - void Unlock( void ); - -//protected: - friend class GLMContext; // only GLMContext can make CGLMBuffer objects - friend class GLMTester; - friend class IDirect3D9; - friend class IDirect3DDevice9; - - CGLMBuffer ( GLMContext *ctx, EGLMBufferType type, uint size, uint options ); - ~CGLMBuffer ( ); - - void SetModes ( bool asyncMap, bool explicitFlush, bool force = false ); - void FlushRange ( uint offset, uint size ); - - GLMContext *m_ctx; // link back to parent context - EGLMBufferType m_type; - uint m_size; - GLenum m_buffGLTarget; // GL_ARRAY_BUFFER_ARB / GL_ELEMENT_BUFFER_ARB - GLuint m_name; // name of this program in the context - uint m_revision; // bump anytime the size changes or buffer is orphaned - bool m_enableAsyncMap; // mirror of the buffer state - bool m_enableExplicitFlush; // mirror of the buffer state - - bool m_bound; // true if bound to context - bool m_mapped; // is it currently mapped - uint m_dirtyMinOffset; // when equal, range is empty - uint m_dirtyMaxOffset; - - float *m_lastMappedAddress; - - // --------------------- pseudo-VBO support below here (explicitly for dynamic index buffers) - bool m_pseudo; // true if the m_name is 0, and the backing is plain RAM - - // in pseudo mode, there is just one RAM buffer that acts as the backing. - // expectation is that this mode would only be used for dynamic indices. - // since indices have to be consumed (copied to command stream) prior to return from a drawing call, - // there's no need to do any fencing or multibuffering. orphaning in particular becomes a no-op. - - char *m_pseudoBuf; // storage for pseudo buffer -}; - - +// +// cglmprogram.h +// GLMgr buffers (index / vertex) +// ... maybe add PBO later as well +//=============================================================================== + +#ifndef CGLMBUFFER_H +#define CGLMBUFFER_H + +#pragma once + +// ext links + +// http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt + +//=============================================================================== + +// tokens not in the SDK headers + +//#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT +// #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9 +//#endif + +//=============================================================================== + +// forward declarations + +class GLMContext; + +enum EGLMBufferType +{ + kGLMVertexBuffer, + kGLMIndexBuffer, + kGLMUniformBuffer, // for bindable uniform + kGLMPixelBuffer, // for PBO + + kGLMNumBufferTypes +}; + + // pass this in "options" to constructor to make a dynamic buffer +#define GLMBufferOptionDynamic 0x00000001 + +struct GLMBuffLockParams +{ + uint m_offset; + uint m_size; + bool m_nonblocking; + bool m_discard; +}; + +class CGLMBuffer +{ + +public: + void Lock( GLMBuffLockParams *params, char **addressOut ); + void Unlock( void ); + +//protected: + friend class GLMContext; // only GLMContext can make CGLMBuffer objects + friend class GLMTester; + friend class IDirect3D9; + friend class IDirect3DDevice9; + + CGLMBuffer ( GLMContext *ctx, EGLMBufferType type, uint size, uint options ); + ~CGLMBuffer ( ); + + void SetModes ( bool asyncMap, bool explicitFlush, bool force = false ); + void FlushRange ( uint offset, uint size ); + + GLMContext *m_ctx; // link back to parent context + EGLMBufferType m_type; + uint m_size; + GLenum m_buffGLTarget; // GL_ARRAY_BUFFER_ARB / GL_ELEMENT_BUFFER_ARB + GLuint m_name; // name of this program in the context + uint m_revision; // bump anytime the size changes or buffer is orphaned + bool m_enableAsyncMap; // mirror of the buffer state + bool m_enableExplicitFlush; // mirror of the buffer state + + bool m_bound; // true if bound to context + bool m_mapped; // is it currently mapped + uint m_dirtyMinOffset; // when equal, range is empty + uint m_dirtyMaxOffset; + + float *m_lastMappedAddress; + + // --------------------- pseudo-VBO support below here (explicitly for dynamic index buffers) + bool m_pseudo; // true if the m_name is 0, and the backing is plain RAM + + // in pseudo mode, there is just one RAM buffer that acts as the backing. + // expectation is that this mode would only be used for dynamic indices. + // since indices have to be consumed (copied to command stream) prior to return from a drawing call, + // there's no need to do any fencing or multibuffering. orphaning in particular becomes a no-op. + + char *m_pseudoBuf; // storage for pseudo buffer +}; + + #endif \ No newline at end of file diff --git a/sp/src/public/togl/osx/cglmfbo.h b/sp/src/public/togl/osx/cglmfbo.h index ccf3e970..c94bac70 100644 --- a/sp/src/public/togl/osx/cglmfbo.h +++ b/sp/src/public/togl/osx/cglmfbo.h @@ -1,91 +1,91 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// -// cglmfbo.h -// GLMgr FBO's (render targets) -// -//=============================================================================== - -#ifndef CGLMFBO_H -#define CGLMFBO_H - -#pragma once - -#include "togl/rendermechanism.h" - -// good FBO references / recaps -// http://www.songho.ca/opengl/gl_fbo.html -// http://www.gamedev.net/reference/articles/article2331.asp - -// ext links - -// http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt -// http://www.opengl.org/registry/specs/EXT/framebuffer_multisample.txt - -//=============================================================================== - -// tokens not in the SDK headers - -#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT - #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9 -#endif - -//=============================================================================== - -// forward declarations - -class GLMContext; - -// implicitly 16 maximum color attachments possible -enum EGLMFBOAttachment { - kAttColor0, kAttColor1, kAttColor2, kAttColor3, - kAttColor4, kAttColor5, kAttColor6, kAttColor7, - kAttColor8, kAttColor9, kAttColor10, kAttColor11, - kAttColor12, kAttColor13, kAttColor14, kAttColor15, - kAttDepth, kAttStencil, kAttDepthStencil, - kAttCount -}; - -struct GLMFBOTexAttachParams -{ - CGLMTex *m_tex; - int m_face; // keep zero if not cube map - int m_mip; // keep zero if notmip mapped - int m_zslice; // keep zero if not a 3D tex -}; - -class CGLMFBO -{ - -public: - -protected: - friend class GLMContext; // only GLMContext can make CGLMFBO objects - friend class GLMTester; - friend class CGLMTex; - - friend class IDirect3D9; - friend class IDirect3DDevice9; - - CGLMFBO( GLMContext *ctx ); - ~CGLMFBO( ); - - void TexAttach( GLMFBOTexAttachParams *params, EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT ); - void TexDetach( EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT ); - // you can also pass GL_READ_FRAMEBUFFER_EXT or GL_DRAW_FRAMEBUFFER_EXT to selectively bind the receiving FBO to one or the other. - - void TexScrub( CGLMTex *tex ); - // search and destroy any attachment for the named texture - - bool IsReady( void ); // aka FBO completeness check - ready to draw - - GLMContext *m_ctx; // link back to parent context - - GLuint m_name; // name of this FBO in the context - - GLMFBOTexAttachParams m_attach[ kAttCount ]; // indexed by EGLMFBOAttachment - - int m_sizeX,m_sizeY; -}; - - -#endif +// +// cglmfbo.h +// GLMgr FBO's (render targets) +// +//=============================================================================== + +#ifndef CGLMFBO_H +#define CGLMFBO_H + +#pragma once + +#include "togl/rendermechanism.h" + +// good FBO references / recaps +// http://www.songho.ca/opengl/gl_fbo.html +// http://www.gamedev.net/reference/articles/article2331.asp + +// ext links + +// http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt +// http://www.opengl.org/registry/specs/EXT/framebuffer_multisample.txt + +//=============================================================================== + +// tokens not in the SDK headers + +#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT + #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9 +#endif + +//=============================================================================== + +// forward declarations + +class GLMContext; + +// implicitly 16 maximum color attachments possible +enum EGLMFBOAttachment { + kAttColor0, kAttColor1, kAttColor2, kAttColor3, + kAttColor4, kAttColor5, kAttColor6, kAttColor7, + kAttColor8, kAttColor9, kAttColor10, kAttColor11, + kAttColor12, kAttColor13, kAttColor14, kAttColor15, + kAttDepth, kAttStencil, kAttDepthStencil, + kAttCount +}; + +struct GLMFBOTexAttachParams +{ + CGLMTex *m_tex; + int m_face; // keep zero if not cube map + int m_mip; // keep zero if notmip mapped + int m_zslice; // keep zero if not a 3D tex +}; + +class CGLMFBO +{ + +public: + +protected: + friend class GLMContext; // only GLMContext can make CGLMFBO objects + friend class GLMTester; + friend class CGLMTex; + + friend class IDirect3D9; + friend class IDirect3DDevice9; + + CGLMFBO( GLMContext *ctx ); + ~CGLMFBO( ); + + void TexAttach( GLMFBOTexAttachParams *params, EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT ); + void TexDetach( EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT ); + // you can also pass GL_READ_FRAMEBUFFER_EXT or GL_DRAW_FRAMEBUFFER_EXT to selectively bind the receiving FBO to one or the other. + + void TexScrub( CGLMTex *tex ); + // search and destroy any attachment for the named texture + + bool IsReady( void ); // aka FBO completeness check - ready to draw + + GLMContext *m_ctx; // link back to parent context + + GLuint m_name; // name of this FBO in the context + + GLMFBOTexAttachParams m_attach[ kAttCount ]; // indexed by EGLMFBOAttachment + + int m_sizeX,m_sizeY; +}; + + +#endif diff --git a/sp/src/public/togl/osx/cglmprogram.h b/sp/src/public/togl/osx/cglmprogram.h index ee7f4de2..3b1b4d86 100644 --- a/sp/src/public/togl/osx/cglmprogram.h +++ b/sp/src/public/togl/osx/cglmprogram.h @@ -1,291 +1,291 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// -// cglmprogram.h -// GLMgr programs (ARBVP/ARBfp) -// -//=============================================================================== - -#ifndef CGLMPROGRAM_H -#define CGLMPROGRAM_H - -#include - -#pragma once - -// good ARB program references -// http://petewarden.com/notes/archives/2005/05/fragment_progra_2.html -// http://petewarden.com/notes/archives/2005/06/fragment_progra_3.html - -// ext links - -// http://www.opengl.org/registry/specs/ARB/vertex_program.txt -// http://www.opengl.org/registry/specs/ARB/fragment_program.txt -// http://www.opengl.org/registry/specs/EXT/gpu_program_parameters.txt - - -//=============================================================================== - -// tokens not in the SDK headers - -//#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT -// #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9 -//#endif - -//=============================================================================== - -// forward declarations - -class GLMContext; -class CGLMShaderPair; -class CGLMShaderPairCache; - -// CGLMProgram can contain two flavors of the same program, one in assembler, one in GLSL. -// these flavors are pretty different in terms of the API's that are used to activate them - -// for example, assembler programs can just get bound to the context, whereas GLSL programs -// have to be linked. To some extent we try to hide that detail inside GLM. - -// for now, make CGLMProgram a container, it does not set policy or hold a preference as to which -// flavor you want to use. GLMContext has to handle that. - -enum EGLMProgramType -{ - kGLMVertexProgram, - kGLMFragmentProgram, - - kGLMNumProgramTypes -}; - -enum EGLMProgramLang -{ - kGLMARB, - kGLMGLSL, - - kGLMNumProgramLangs -}; - -struct GLMShaderDesc -{ - union - { - GLuint arb; // ARB program object name - GLhandleARB glsl; // GLSL shader object handle (void*) - } m_object; - - // these can change if shader text is edited - bool m_textPresent; // is this flavor(lang) of text present in the buffer? - int m_textOffset; // where is it - int m_textLength; // how big - - bool m_compiled; // has this text been through a compile attempt - bool m_valid; // and if so, was the compile successful - - int m_slowMark; // has it been flagged during a non native draw batch before. increment every time it's slow. - - int m_highWater; // vount of vec4's in the major uniform array ("vc" on vs, "pc" on ps) - // written by dxabstract.... gross! -}; - -GLenum GLMProgTypeToARBEnum( EGLMProgramType type ); // map vert/frag to ARB asm bind target -GLenum GLMProgTypeToGLSLEnum( EGLMProgramType type ); // map vert/frag to ARB asm bind target - -class CGLMProgram -{ -public: - friend class CGLMShaderPairCache; - friend class CGLMShaderPair; - friend class GLMContext; // only GLMContext can make CGLMProgram objects - friend class GLMTester; - friend class IDirect3D9; - friend class IDirect3DDevice9; - - //=============================== - - // constructor is very light, it just makes one empty program object per flavor. - CGLMProgram( GLMContext *ctx, EGLMProgramType type ); - ~CGLMProgram( ); - - void SetProgramText ( char *text ); // import text to GLM object - invalidate any prev compiled program - - bool CompileActiveSources ( void ); // compile only the flavors that were provided. - bool Compile ( EGLMProgramLang lang ); - bool CheckValidity ( EGLMProgramLang lang ); - - void LogSlow ( EGLMProgramLang lang ); // detailed spew when called for first time; one liner or perhaps silence after that - - void GetLabelIndexCombo ( char *labelOut, int labelOutMaxChars, int *indexOut, int *comboOut ); - void GetComboIndexNameString ( char *stringOut, int stringOutMaxChars ); // mmmmmmmm-nnnnnnnn-filename - -#if GLMDEBUG - bool PollForChanges( void ); // check mirror for changes. - void ReloadStringFromEditable( void ); // populate m_string from editable item (react to change) - bool SyncWithEditable( void ); -#endif - - //=============================== - - // common stuff - - GLMContext *m_ctx; // link back to parent context - - EGLMProgramType m_type; // vertex or pixel - - uint m_serial; // serial number for hashing - - char *m_text; // copy of text passed into constructor. Can change if editable shaders is enabled. - // note - it can contain multiple flavors, so use CGLMTextSectioner to scan it and locate them -#if GLMDEBUG - CGLMEditableTextItem *m_editable; // editable text item for debugging -#endif - - GLMShaderDesc m_descs[ kGLMNumProgramLangs ]; - - uint m_samplerMask; // (1< + +#pragma once + +// good ARB program references +// http://petewarden.com/notes/archives/2005/05/fragment_progra_2.html +// http://petewarden.com/notes/archives/2005/06/fragment_progra_3.html + +// ext links + +// http://www.opengl.org/registry/specs/ARB/vertex_program.txt +// http://www.opengl.org/registry/specs/ARB/fragment_program.txt +// http://www.opengl.org/registry/specs/EXT/gpu_program_parameters.txt + + +//=============================================================================== + +// tokens not in the SDK headers + +//#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT +// #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9 +//#endif + +//=============================================================================== + +// forward declarations + +class GLMContext; +class CGLMShaderPair; +class CGLMShaderPairCache; + +// CGLMProgram can contain two flavors of the same program, one in assembler, one in GLSL. +// these flavors are pretty different in terms of the API's that are used to activate them - +// for example, assembler programs can just get bound to the context, whereas GLSL programs +// have to be linked. To some extent we try to hide that detail inside GLM. + +// for now, make CGLMProgram a container, it does not set policy or hold a preference as to which +// flavor you want to use. GLMContext has to handle that. + +enum EGLMProgramType +{ + kGLMVertexProgram, + kGLMFragmentProgram, + + kGLMNumProgramTypes +}; + +enum EGLMProgramLang +{ + kGLMARB, + kGLMGLSL, + + kGLMNumProgramLangs +}; + +struct GLMShaderDesc +{ + union + { + GLuint arb; // ARB program object name + GLhandleARB glsl; // GLSL shader object handle (void*) + } m_object; + + // these can change if shader text is edited + bool m_textPresent; // is this flavor(lang) of text present in the buffer? + int m_textOffset; // where is it + int m_textLength; // how big + + bool m_compiled; // has this text been through a compile attempt + bool m_valid; // and if so, was the compile successful + + int m_slowMark; // has it been flagged during a non native draw batch before. increment every time it's slow. + + int m_highWater; // vount of vec4's in the major uniform array ("vc" on vs, "pc" on ps) + // written by dxabstract.... gross! +}; + +GLenum GLMProgTypeToARBEnum( EGLMProgramType type ); // map vert/frag to ARB asm bind target +GLenum GLMProgTypeToGLSLEnum( EGLMProgramType type ); // map vert/frag to ARB asm bind target + +class CGLMProgram +{ +public: + friend class CGLMShaderPairCache; + friend class CGLMShaderPair; + friend class GLMContext; // only GLMContext can make CGLMProgram objects + friend class GLMTester; + friend class IDirect3D9; + friend class IDirect3DDevice9; + + //=============================== + + // constructor is very light, it just makes one empty program object per flavor. + CGLMProgram( GLMContext *ctx, EGLMProgramType type ); + ~CGLMProgram( ); + + void SetProgramText ( char *text ); // import text to GLM object - invalidate any prev compiled program + + bool CompileActiveSources ( void ); // compile only the flavors that were provided. + bool Compile ( EGLMProgramLang lang ); + bool CheckValidity ( EGLMProgramLang lang ); + + void LogSlow ( EGLMProgramLang lang ); // detailed spew when called for first time; one liner or perhaps silence after that + + void GetLabelIndexCombo ( char *labelOut, int labelOutMaxChars, int *indexOut, int *comboOut ); + void GetComboIndexNameString ( char *stringOut, int stringOutMaxChars ); // mmmmmmmm-nnnnnnnn-filename + +#if GLMDEBUG + bool PollForChanges( void ); // check mirror for changes. + void ReloadStringFromEditable( void ); // populate m_string from editable item (react to change) + bool SyncWithEditable( void ); +#endif + + //=============================== + + // common stuff + + GLMContext *m_ctx; // link back to parent context + + EGLMProgramType m_type; // vertex or pixel + + uint m_serial; // serial number for hashing + + char *m_text; // copy of text passed into constructor. Can change if editable shaders is enabled. + // note - it can contain multiple flavors, so use CGLMTextSectioner to scan it and locate them +#if GLMDEBUG + CGLMEditableTextItem *m_editable; // editable text item for debugging +#endif + + GLMShaderDesc m_descs[ kGLMNumProgramLangs ]; + + uint m_samplerMask; // (1< m_layoutMap; -}; - -//=============================================================================== - -// a sampler specifies desired state for drawing on a given sampler index -// this is the combination of a texture choice and a set of sampler parameters -// see http://msdn.microsoft.com/en-us/library/bb172602(VS.85).aspx - - -struct GLMTexSamplingParams -{ - GLenum m_addressModes[3]; // S, T, R - GLfloat m_borderColor[4]; // R,G,B,A - - GLenum m_magFilter; - GLenum m_minFilter; - - GLfloat m_mipmapBias; - GLint m_minMipLevel; - GLint m_maxMipLevel; - GLint m_maxAniso; - GLenum m_compareMode; // only used for depth and stencil type textures - bool m_srgb; // srgb texture read... -}; - -struct GLMTexLockParams -{ - // input params which identify the slice of interest - CGLMTex *m_tex; - int m_face; - int m_mip; - - // identifies the region of the slice - GLMRegion m_region; - - // tells GLM to force re-read of the texels back from GL - // i.e. "I know I stepped on those texels with a draw or blit - the GLM copy is stale" - bool m_readback; -}; - -struct GLMTexLockDesc -{ - GLMTexLockParams m_req; // form of the lock request - - bool m_active; // set true at lock time. cleared at unlock time. - - int m_sliceIndex; // which slice in the layout - int m_sliceBaseOffset; // where is that in the texture data - int m_sliceRegionOffset; // offset to the start (lowest address corner) of the region requested -}; - -//=============================================================================== - -#define GLM_SAMPLER_COUNT 16 - -typedef CBitVec CTexBindMask; - -enum EGLMTexSliceFlag -{ - kSliceValid = 0x01, // slice has been teximage'd in whole at least once - set to 0 initially - kSliceStorageValid = 0x02, // if backing store is available, this slice's data is a valid copy - set to 0 initially - kSliceLocked = 0x04, // are one or more locks outstanding on this slice - kSliceFullyDirty = 0x08, // does the slice need to be fully downloaded at unlock time (disregard dirty rects) -}; - -class CGLMTex -{ - -public: - - void Lock( GLMTexLockParams *params, char** addressOut, int* yStrideOut, int *zStrideOut ); - void Unlock( GLMTexLockParams *params ); - -protected: - friend class GLMContext; // only GLMContext can make CGLMTex objects - friend class GLMTester; - friend class CGLMFBO; - - friend class IDirect3DDevice9; - friend class IDirect3DBaseTexture9; - friend class IDirect3DTexture9; - friend class IDirect3DSurface9; - friend class IDirect3DCubeTexture9; - friend class IDirect3DVolumeTexture9; - - CGLMTex( GLMContext *ctx, GLMTexLayout *layout, GLMTexSamplingParams *sampling, char *debugLabel = NULL ); - ~CGLMTex( ); - - int CalcSliceIndex( int face, int mip ); - void CalcTexelDataOffsetAndStrides( int sliceIndex, int x, int y, int z, int *offsetOut, int *yStrideOut, int *zStrideOut ); - - void ApplySamplingParams( GLMTexSamplingParams *params, bool noCheck=FALSE ); - - void ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice=true ); - void WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice=true, bool noDataWrite=false ); - // last param lets us send NULL data ptr (only legal with uncompressed formats, beware) - // this helps out ResetSRGB. - - void ResetSRGB( bool srgb, bool noDataWrite ); - // re-specify texture format to match desired sRGB form - // noWrite means send NULL for texel source addresses instead of actual data - ideal for RT's - - GLMTexLayout *m_layout; // layout of texture (shared across all tex with same layout) - int m_minActiveMip;//index of lowest mip that has been written. used to drive setting of GL_TEXTURE_MAX_LEVEL. - int m_maxActiveMip;//index of highest mip that has been written. used to drive setting of GL_TEXTURE_MAX_LEVEL. - - GLMTexSamplingParams m_sampling; // mirror of sampling params currently embodied in the texture - // (consult this at draw time, in order to know if changes need to be made) - - GLMContext *m_ctx; // link back to parent context - - GLuint m_texName; // name of this texture in the context - bool m_texClientStorage; // was CS selecetd for texture - bool m_texPreloaded; // has it been kicked into VRAM with GLMContext::PreloadTex yet - - GLuint m_rboName; // name of MSAA RBO backing the tex if MSAA enabled (or zero) - bool m_rboDirty; // has RBO been drawn on - i.e. needs to be blitted back to texture if texture is going to be sampled from - - CTexBindMask m_bindPoints; // true for each place in the parent ctx where currently - // bound (indexed via EGLMTexCtxBindingIndex) - - int m_rtAttachCount; // how many RT's have this texture attached somewhere - - char *m_backing; // backing storage if available - - int m_lockCount; // lock reqs are stored in the GLMContext for tracking - - CUtlVector m_sliceFlags; - - char *m_debugLabel; // strdup() of debugLabel passed in, or NULL -}; - - -#endif +// +// cglmtex.h +// GLMgr textures +// +//=============================================================================== + +#ifndef CGLMTEX_H +#define CGLMTEX_H + +#pragma once + +#include "tier1/utlhash.h" +#include "tier1/utlmap.h" + +//=============================================================================== + +// forward declarations + +class GLMContext; +class GLMTester; +class CGLMTexLayoutTable; +class CGLMTex; +class CGLMFBO; + +class IDirect3DSurface9; + +//=============================================================================== + +struct GLMTexFormatDesc +{ + char *m_formatSummary; // for debug visibility + + D3DFORMAT m_d3dFormat; // what D3D knows it as; see public/bitmap/imageformat.h + + GLenum m_glIntFormat; // GL internal format + GLenum m_glIntFormatSRGB; // internal format if SRGB flavor + GLenum m_glDataFormat; // GL data format + GLenum m_glDataType; // GL data type + + int m_chunkSize; // 1 or 4 - 4 is used for compressed textures + int m_bytesPerSquareChunk; // how many bytes for the smallest quantum (m_chunkSize x m_chunkSize) + // this description lets us calculate size cleanly without conditional logic for compression +}; +const GLMTexFormatDesc *GetFormatDesc( D3DFORMAT format ); + +//=============================================================================== + +// utility function for generating slabs of texels. mostly for test. +typedef struct +{ + // in + D3DFORMAT m_format; + void *m_dest; // dest address + int m_chunkCount; // square chunk count (single texels or compressed blocks) + int m_byteCountLimit; // caller expectation of max number of bytes to write out + float r,g,b,a; // color desired + + // out + int m_bytesWritten; +} GLMGenTexelParams; + +// return true if successful +bool GLMGenTexels( GLMGenTexelParams *params ); + + +//=============================================================================== + +struct GLMTexLayoutSlice +{ + int m_xSize,m_ySize,m_zSize; //texel dimensions of this slice + int m_storageOffset; //where in the storage slab does this slice live + int m_storageSize; //how much storage does this slice occupy +}; + +enum EGLMTexFlags +{ + kGLMTexMipped = 0x01, + kGLMTexMippedAuto = 0x02, + kGLMTexRenderable = 0x04, + kGLMTexIsStencil = 0x08, + kGLMTexIsDepth = 0x10, + kGLMTexSRGB = 0x20, + kGLMTexMultisampled = 0x40, // has an RBO backing it. Cannot combine with Mipped, MippedAuto. One slice maximum, only targeting GL_TEXTURE_2D. + // actually not 100% positive on the mipmapping, the RBO itself can't be mipped, but the resulting texture could + // have mipmaps generated. +}; + +//=============================================================================== + +struct GLMTexLayoutKey +{ + // input values: held const, these are the hash key for the form map + GLenum m_texGLTarget; // flavor of texture: GL_TEXTURE_2D, GL_TEXTURE_3D, GLTEXTURE_CUBE_MAP + D3DFORMAT m_texFormat; // D3D texel format + unsigned long m_texFlags; // mipped, autogen mips, render target, ... ? + unsigned long m_texSamples; // zero for a plain tex, 2/4/6/8 for "MSAA tex" (RBO backed) + int m_xSize,m_ySize,m_zSize; // size of base mip +}; + +bool LessFunc_GLMTexLayoutKey( const GLMTexLayoutKey &a, const GLMTexLayoutKey &b ); + +#define GLM_TEX_MAX_MIPS 14 +#define GLM_TEX_MAX_FACES 6 +#define GLM_TEX_MAX_SLICES (GLM_TEX_MAX_MIPS * GLM_TEX_MAX_FACES) + +struct GLMTexLayout +{ + char *m_layoutSummary; // for debug visibility + + // const inputs used for hashing + GLMTexLayoutKey m_key; + + // refcount + int m_refCount; + + // derived values: + GLMTexFormatDesc *m_format; // format specific info + int m_mipCount; // derived by starying at base size and working down towards 1x1 + int m_faceCount; // 1 for 2d/3d, 6 for cubemap + int m_sliceCount; // product of faces and mips + int m_storageTotalSize; // size of storage slab required + + // slice array + GLMTexLayoutSlice m_slices[0]; // dynamically allocated 2-d array [faces][mips] +}; + + +class CGLMTexLayoutTable +{ +public: + CGLMTexLayoutTable(); + + GLMTexLayout *NewLayoutRef( GLMTexLayoutKey *key ); // pass in a pointer to layout key - receive ptr to completed layout + void DelLayoutRef( GLMTexLayout *layout ); // pass in pointer to completed layout. refcount is dropped. + + void DumpStats( void ); +protected: + CUtlMap< GLMTexLayoutKey, GLMTexLayout* > m_layoutMap; +}; + +//=============================================================================== + +// a sampler specifies desired state for drawing on a given sampler index +// this is the combination of a texture choice and a set of sampler parameters +// see http://msdn.microsoft.com/en-us/library/bb172602(VS.85).aspx + + +struct GLMTexSamplingParams +{ + GLenum m_addressModes[3]; // S, T, R + GLfloat m_borderColor[4]; // R,G,B,A + + GLenum m_magFilter; + GLenum m_minFilter; + + GLfloat m_mipmapBias; + GLint m_minMipLevel; + GLint m_maxMipLevel; + GLint m_maxAniso; + GLenum m_compareMode; // only used for depth and stencil type textures + bool m_srgb; // srgb texture read... +}; + +struct GLMTexLockParams +{ + // input params which identify the slice of interest + CGLMTex *m_tex; + int m_face; + int m_mip; + + // identifies the region of the slice + GLMRegion m_region; + + // tells GLM to force re-read of the texels back from GL + // i.e. "I know I stepped on those texels with a draw or blit - the GLM copy is stale" + bool m_readback; +}; + +struct GLMTexLockDesc +{ + GLMTexLockParams m_req; // form of the lock request + + bool m_active; // set true at lock time. cleared at unlock time. + + int m_sliceIndex; // which slice in the layout + int m_sliceBaseOffset; // where is that in the texture data + int m_sliceRegionOffset; // offset to the start (lowest address corner) of the region requested +}; + +//=============================================================================== + +#define GLM_SAMPLER_COUNT 16 + +typedef CBitVec CTexBindMask; + +enum EGLMTexSliceFlag +{ + kSliceValid = 0x01, // slice has been teximage'd in whole at least once - set to 0 initially + kSliceStorageValid = 0x02, // if backing store is available, this slice's data is a valid copy - set to 0 initially + kSliceLocked = 0x04, // are one or more locks outstanding on this slice + kSliceFullyDirty = 0x08, // does the slice need to be fully downloaded at unlock time (disregard dirty rects) +}; + +class CGLMTex +{ + +public: + + void Lock( GLMTexLockParams *params, char** addressOut, int* yStrideOut, int *zStrideOut ); + void Unlock( GLMTexLockParams *params ); + +protected: + friend class GLMContext; // only GLMContext can make CGLMTex objects + friend class GLMTester; + friend class CGLMFBO; + + friend class IDirect3DDevice9; + friend class IDirect3DBaseTexture9; + friend class IDirect3DTexture9; + friend class IDirect3DSurface9; + friend class IDirect3DCubeTexture9; + friend class IDirect3DVolumeTexture9; + + CGLMTex( GLMContext *ctx, GLMTexLayout *layout, GLMTexSamplingParams *sampling, char *debugLabel = NULL ); + ~CGLMTex( ); + + int CalcSliceIndex( int face, int mip ); + void CalcTexelDataOffsetAndStrides( int sliceIndex, int x, int y, int z, int *offsetOut, int *yStrideOut, int *zStrideOut ); + + void ApplySamplingParams( GLMTexSamplingParams *params, bool noCheck=FALSE ); + + void ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice=true ); + void WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice=true, bool noDataWrite=false ); + // last param lets us send NULL data ptr (only legal with uncompressed formats, beware) + // this helps out ResetSRGB. + + void ResetSRGB( bool srgb, bool noDataWrite ); + // re-specify texture format to match desired sRGB form + // noWrite means send NULL for texel source addresses instead of actual data - ideal for RT's + + GLMTexLayout *m_layout; // layout of texture (shared across all tex with same layout) + int m_minActiveMip;//index of lowest mip that has been written. used to drive setting of GL_TEXTURE_MAX_LEVEL. + int m_maxActiveMip;//index of highest mip that has been written. used to drive setting of GL_TEXTURE_MAX_LEVEL. + + GLMTexSamplingParams m_sampling; // mirror of sampling params currently embodied in the texture + // (consult this at draw time, in order to know if changes need to be made) + + GLMContext *m_ctx; // link back to parent context + + GLuint m_texName; // name of this texture in the context + bool m_texClientStorage; // was CS selecetd for texture + bool m_texPreloaded; // has it been kicked into VRAM with GLMContext::PreloadTex yet + + GLuint m_rboName; // name of MSAA RBO backing the tex if MSAA enabled (or zero) + bool m_rboDirty; // has RBO been drawn on - i.e. needs to be blitted back to texture if texture is going to be sampled from + + CTexBindMask m_bindPoints; // true for each place in the parent ctx where currently + // bound (indexed via EGLMTexCtxBindingIndex) + + int m_rtAttachCount; // how many RT's have this texture attached somewhere + + char *m_backing; // backing storage if available + + int m_lockCount; // lock reqs are stored in the GLMContext for tracking + + CUtlVector m_sliceFlags; + + char *m_debugLabel; // strdup() of debugLabel passed in, or NULL +}; + + +#endif diff --git a/sp/src/public/togl/osx/dxabstract.h b/sp/src/public/togl/osx/dxabstract.h index 92f6bc32..50676e04 100644 --- a/sp/src/public/togl/osx/dxabstract.h +++ b/sp/src/public/togl/osx/dxabstract.h @@ -1,804 +1,804 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// -// -// -//================================================================================================== - -#ifndef DXABSTRACT_H -#define DXABSTRACT_H -#ifdef _WIN32 -#pragma once -#endif - -#include "togl/rendermechanism.h" - -#include "materialsystem/ishader.h" - -// Uncomment this on Windows if you want to compile the Windows GL version. -// #undef USE_ACTUAL_DX - -#ifdef USE_ACTUAL_DX - -#ifndef WIN32 -#error sorry man -#endif -#ifdef _X360 -#include "d3d9.h" -#include "d3dx9.h" -#else -#include -#include "../../dx9sdk/include/d3d9.h" -#include "../../dx9sdk/include/d3dx9.h" -#endif -typedef HWND VD3DHWND; - -#else - -#ifdef WIN32 -#error Gl on win32? -#endif - -#include "tier0/platform.h" - -#ifndef DX_TO_GL_ABSTRACTION -#define DX_TO_GL_ABSTRACTION -#endif - -#include "bitmap/imageformat.h" -#include "togl/rendermechanism.h" - -#ifdef OSX -extern "C" void Debugger(void); -#endif - -// turn this on to get refcount logging from IUnknown -#define IUNKNOWN_ALLOC_SPEW 0 -#define IUNKNOWN_ALLOC_SPEW_MARK_ALL 0 - - -// ------------------------------------------------------------------------------------------------------------------------------ // -// DEFINES -// ------------------------------------------------------------------------------------------------------------------------------ // - -typedef void* VD3DHWND; -typedef void* VD3DHANDLE; - - -TOGL_INTERFACE void toglGetClientRect( VD3DHWND hWnd, RECT *destRect ); - -struct TOGL_CLASS IUnknown -{ - int m_refcount[2]; - bool m_mark; - - IUnknown( void ) - { - m_refcount[0] = 1; - m_refcount[1] = 0; - m_mark = (IUNKNOWN_ALLOC_SPEW_MARK_ALL != 0); // either all are marked, or only the ones that have SetMark(true) called on them - - #if IUNKNOWN_ALLOC_SPEW - if (m_mark) - { - GLMPRINTF(("-A- IUnew (%08x) refc -> (%d,%d) ",this,m_refcount[0],m_refcount[1])); - } - #endif - }; - - virtual ~IUnknown( void ) - { - #if IUNKNOWN_ALLOC_SPEW - if (m_mark) - { - GLMPRINTF(("-A- IUdel (%08x) ",this )); - } - #endif - }; - - void AddRef( int which=0, char *comment = NULL ) - { - Assert( which >= 0 ); - Assert( which < 2 ); - m_refcount[which]++; - - #if IUNKNOWN_ALLOC_SPEW - if (m_mark) - { - GLMPRINTF(("-A- IUAddRef (%08x,%d) refc -> (%d,%d) [%s]",this,which,m_refcount[0],m_refcount[1],comment?comment:"...")) ; - if (!comment) - { - GLMPRINTF(("")) ; // place to hang a breakpoint - } - } - #endif - }; - - ULONG __stdcall Release( int which=0, char *comment = NULL ) - { - Assert( which >= 0 ); - Assert( which < 2 ); - - //int oldrefcs[2] = { m_refcount[0], m_refcount[1] }; - bool deleting = false; - - m_refcount[which]--; - if ( (!m_refcount[0]) && (!m_refcount[1]) ) - { - deleting = true; - } - - #if IUNKNOWN_ALLOC_SPEW - if (m_mark) - { - GLMPRINTF(("-A- IURelease (%08x,%d) refc -> (%d,%d) [%s] %s",this,which,m_refcount[0],m_refcount[1],comment?comment:"...",deleting?"->DELETING":"")); - if (!comment) - { - GLMPRINTF(("")) ; // place to hang a breakpoint - } - } - #endif - - if (deleting) - { - if (m_mark) - { - GLMPRINTF(("")) ; // place to hang a breakpoint - } - delete this; - return 0; - } - else - { - return m_refcount[0]; - } - }; - - void SetMark( bool markValue, char *comment=NULL ) - { - #if IUNKNOWN_ALLOC_SPEW - if (!m_mark && markValue) // leading edge detect - { - // print the same thing that the constructor would have printed if it had been marked from the beginning - // i.e. it's anticipated that callers asking for marking will do so right at create time - GLMPRINTF(("-A- IUSetMark (%08x) refc -> (%d,%d) (%s) ",this,m_refcount[0],m_refcount[1],comment?comment:"...")); - } - #endif - - m_mark = markValue; - } -}; - - -// ------------------------------------------------------------------------------------------------------------------------------ // -// INTERFACES -// ------------------------------------------------------------------------------------------------------------------------------ // - -struct TOGL_CLASS IDirect3DResource9 : public IUnknown -{ - IDirect3DDevice9 *m_device; // parent device - D3DRESOURCETYPE m_restype; - - DWORD SetPriority(DWORD PriorityNew); -}; - -struct TOGL_CLASS IDirect3DBaseTexture9 : public IDirect3DResource9 // "A Texture.." -{ - D3DSURFACE_DESC m_descZero; // desc of top level. - CGLMTex *m_tex; // a CGLMTex can represent all forms of tex - int m_srgbFlipCount; - - virtual ~IDirect3DBaseTexture9(); - D3DRESOURCETYPE GetType(); - DWORD GetLevelCount(); - HRESULT GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc); -}; - -struct TOGL_CLASS IDirect3DTexture9 : public IDirect3DBaseTexture9 // "Texture 2D" -{ - IDirect3DSurface9 *m_surfZero; // surf of top level. - - virtual ~IDirect3DTexture9(); - - HRESULT LockRect(UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags); - HRESULT UnlockRect(UINT Level); - HRESULT GetSurfaceLevel(UINT Level,IDirect3DSurface9** ppSurfaceLevel); -}; - -struct TOGL_CLASS IDirect3DCubeTexture9 : public IDirect3DBaseTexture9 // "Texture Cube Map" -{ - IDirect3DSurface9 *m_surfZero[6]; // surfs of top level. - - virtual ~IDirect3DCubeTexture9(); - - HRESULT GetCubeMapSurface(D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface9** ppCubeMapSurface); - HRESULT GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc); -}; - -struct TOGL_CLASS IDirect3DVolumeTexture9 : public IDirect3DBaseTexture9 // "Texture 3D" -{ - IDirect3DSurface9 *m_surfZero; // surf of top level. - D3DVOLUME_DESC m_volDescZero; // volume desc top level - - virtual ~IDirect3DVolumeTexture9(); - - HRESULT LockBox(UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags); - HRESULT UnlockBox(UINT Level); - HRESULT GetLevelDesc( UINT level, D3DVOLUME_DESC *pDesc ); -}; - - -// for the moment, a "D3D surface" is modeled as a GLM tex, a face, and a mip. -// no Create method, these are filled in by the various create surface methods. - -struct TOGL_CLASS IDirect3DSurface9 : public IDirect3DResource9 -{ - virtual ~IDirect3DSurface9(); - - HRESULT LockRect(D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags); - HRESULT UnlockRect(); - HRESULT GetDesc(D3DSURFACE_DESC *pDesc); - - D3DSURFACE_DESC m_desc; - CGLMTex *m_tex; - int m_face; - int m_mip; -}; - - - -struct TOGL_CLASS IDirect3D9 : public IUnknown -{ -public: - virtual ~IDirect3D9(); - - UINT GetAdapterCount(); //cheese: returns 1 - - HRESULT GetDeviceCaps (UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps); - HRESULT GetAdapterIdentifier (UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier); - HRESULT CheckDeviceFormat (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat); - UINT GetAdapterModeCount (UINT Adapter,D3DFORMAT Format); - HRESULT EnumAdapterModes (UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode); - HRESULT CheckDeviceType (UINT Adapter,D3DDEVTYPE DevType,D3DFORMAT AdapterFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed); - HRESULT GetAdapterDisplayMode (UINT Adapter,D3DDISPLAYMODE* pMode); - HRESULT CheckDepthStencilMatch (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat); - HRESULT CheckDeviceMultiSampleType (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels); - - HRESULT CreateDevice (UINT Adapter,D3DDEVTYPE DeviceType,VD3DHWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface); -}; - -struct TOGL_CLASS IDirect3DSwapChain9 : public IUnknown -{ -}; - - - - // typedef enum D3DDECLUSAGE - // { - // D3DDECLUSAGE_POSITION = 0, - // D3DDECLUSAGE_BLENDWEIGHT = 1, - // D3DDECLUSAGE_BLENDINDICES = 2, - // D3DDECLUSAGE_NORMAL = 3, - // D3DDECLUSAGE_PSIZE = 4, - // D3DDECLUSAGE_TEXCOORD = 5, - // D3DDECLUSAGE_TANGENT = 6, - // D3DDECLUSAGE_BINORMAL = 7, - // D3DDECLUSAGE_TESSFACTOR = 8, - // D3DDECLUSAGE_POSITIONT = 9, - // D3DDECLUSAGE_COLOR = 10, - // D3DDECLUSAGE_FOG = 11, - // D3DDECLUSAGE_DEPTH = 12, - // D3DDECLUSAGE_SAMPLE = 13, - // } D3DDECLUSAGE, *LPD3DDECLUSAGE; - // Constants - // - // D3DDECLUSAGE_POSITION - // Position data ranging from (-1,-1) to (1,1). Use D3DDECLUSAGE_POSITION with - // a usage index of 0 to specify untransformed position for fixed function - // vertex processing and the n-patch tessellator. Use D3DDECLUSAGE_POSITION - // with a usage index of 1 to specify untransformed position in the fixed - // function vertex shader for vertex tweening. - // - // D3DDECLUSAGE_BLENDWEIGHT - // Blending weight data. Use D3DDECLUSAGE_BLENDWEIGHT with a usage index of 0 - // to specify the blend weights used in indexed and nonindexed vertex - // blending. - // - // D3DDECLUSAGE_BLENDINDICES - // Blending indices data. Use D3DDECLUSAGE_BLENDINDICES with a usage index of - // 0 to specify matrix indices for indexed paletted skinning. - // - // D3DDECLUSAGE_NORMAL - // Vertex normal data. Use D3DDECLUSAGE_NORMAL with a usage index of 0 to - // specify vertex normals for fixed function vertex processing and the n-patch - // tessellator. Use D3DDECLUSAGE_NORMAL with a usage index of 1 to specify - // vertex normals for fixed function vertex processing for vertex tweening. - // - // D3DDECLUSAGE_PSIZE - // Point size data. Use D3DDECLUSAGE_PSIZE with a usage index of 0 to specify - // the point-size attribute used by the setup engine of the rasterizer to - // expand a point into a quad for the point-sprite functionality. - // - // D3DDECLUSAGE_TEXCOORD - // Texture coordinate data. Use D3DDECLUSAGE_TEXCOORD, n to specify texture - // coordinates in fixed function vertex processing and in pixel shaders prior - // to ps_3_0. These can be used to pass user defined data. - // - // D3DDECLUSAGE_TANGENT - // Vertex tangent data. - // - // D3DDECLUSAGE_BINORMAL - // Vertex binormal data. - // - // D3DDECLUSAGE_TESSFACTOR - // Single positive floating point value. Use D3DDECLUSAGE_TESSFACTOR with a - // usage index of 0 to specify a tessellation factor used in the tessellation - // unit to control the rate of tessellation. For more information about the - // data type, see D3DDECLTYPE_FLOAT1. - // - // D3DDECLUSAGE_POSITIONT - // Vertex data contains transformed position data ranging from (0,0) to - // (viewport width, viewport height). Use D3DDECLUSAGE_POSITIONT with a usage - // index of 0 to specify transformed position. When a declaration containing - // this is set, the pipeline does not perform vertex processing. - // - // D3DDECLUSAGE_COLOR - // Vertex data contains diffuse or specular color. Use D3DDECLUSAGE_COLOR with - // a usage index of 0 to specify the diffuse color in the fixed function - // vertex shader and pixel shaders prior to ps_3_0. Use D3DDECLUSAGE_COLOR - // with a usage index of 1 to specify the specular color in the fixed function - // vertex shader and pixel shaders prior to ps_3_0. - // - // D3DDECLUSAGE_FOG - // Vertex data contains fog data. Use D3DDECLUSAGE_FOG with a usage index of 0 - // to specify a fog blend value used after pixel shading finishes. This - // applies to pixel shaders prior to version ps_3_0. - // - // D3DDECLUSAGE_DEPTH - // Vertex data contains depth data. - // - // D3DDECLUSAGE_SAMPLE - // Vertex data contains sampler data. Use D3DDECLUSAGE_SAMPLE with a usage - // index of 0 to specify the displacement value to look up. It can be used - // only with D3DDECLUSAGE_LOOKUPPRESAMPLED or D3DDECLUSAGE_LOOKUP. - - //note the form of the list terminator.. - - // #define D3DDECL_END() {0xFF,0,D3DDECLTYPE_UNUSED,0,0,0} - // typedef struct _D3DVERTEXELEMENT9 - // { - // WORD Stream; // Stream index - // WORD Offset; // Offset in the stream in bytes - // BYTE Type; // Data type - // BYTE Method; // Processing method - // BYTE Usage; // Semantics - // BYTE UsageIndex; // Semantic index - // } D3DVERTEXELEMENT9, *LPD3DVERTEXELEMENT9; - -#define MAX_D3DVERTEXELEMENTS 16 - -struct TOGL_CLASS IDirect3DVertexDeclaration9 : public IUnknown -{ -//public: - uint m_elemCount; - D3DVERTEXELEMENT9_GL m_elements[ MAX_D3DVERTEXELEMENTS ]; - - virtual ~IDirect3DVertexDeclaration9(); -}; - -struct TOGL_CLASS IDirect3DQuery9 : public IDirect3DResource9 //was IUnknown -{ -//public: - D3DQUERYTYPE m_type; // D3DQUERYTYPE_OCCLUSION or D3DQUERYTYPE_EVENT - GLMContext *m_ctx; - CGLMQuery *m_query; - - virtual ~IDirect3DQuery9(); - - HRESULT Issue(DWORD dwIssueFlags); - HRESULT GetData(void* pData,DWORD dwSize,DWORD dwGetDataFlags); -}; - -struct TOGL_CLASS IDirect3DVertexBuffer9 : public IDirect3DResource9 //was IUnknown -{ -//public: - GLMContext *m_ctx; - CGLMBuffer *m_vtxBuffer; - D3DVERTEXBUFFER_DESC m_vtxDesc; // to satisfy GetDesc - - virtual ~IDirect3DVertexBuffer9(); - HRESULT Lock(UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags); - HRESULT Unlock(); - HRESULT UnlockActualSize( uint nActualSize, const void *pActualData = NULL ); - -}; - -struct TOGL_CLASS IDirect3DIndexBuffer9 : public IDirect3DResource9 //was IUnknown -{ -//public: - GLMContext *m_ctx; - CGLMBuffer *m_idxBuffer; - D3DINDEXBUFFER_DESC m_idxDesc; // to satisfy GetDesc - - virtual ~IDirect3DIndexBuffer9(); - - HRESULT Lock(UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags); - HRESULT Unlock(); - HRESULT UnlockActualSize( uint nActualSize, const void *pActualData = NULL ); - HRESULT GetDesc(D3DINDEXBUFFER_DESC *pDesc); -}; - -struct TOGL_CLASS IDirect3DPixelShader9 : public IDirect3DResource9 //was IUnknown -{ -//public: - CGLMProgram *m_pixProgram; - uint m_pixHighWater; // count of active constant slots referenced by shader. - uint m_pixSamplerMask; // (1< m_stack; - int m_stackTop; // top of stack is at the highest index, this is that index. push increases, pop decreases. - - HRESULT Create( void ); - - D3DXMATRIX* GetTop(); - void Push(); - void Pop(); - void LoadIdentity(); - void LoadMatrix( const D3DXMATRIX *pMat ); - void MultMatrix( const D3DXMATRIX *pMat ); - void MultMatrixLocal( const D3DXMATRIX *pMat ); - HRESULT ScaleLocal(FLOAT x, FLOAT y, FLOAT z); - - // Left multiply the current matrix with the computed rotation - // matrix, counterclockwise about the given axis with the given angle. - // (rotation is about the local origin of the object) - HRESULT RotateAxisLocal(CONST D3DXVECTOR3* pV, FLOAT Angle); - - // Left multiply the current matrix with the computed translation - // matrix. (transformation is about the local origin of the object) - HRESULT TranslateLocal(FLOAT x, FLOAT y, FLOAT z); -}; -typedef ID3DXMatrixStack* LPD3DXMATRIXSTACK; - -struct TOGL_CLASS IDirect3DDevice9 : public IUnknown -{ -public: - // members - - IDirect3DDevice9Params m_params; // mirror of the creation inputs - - // D3D flavor stuff - IDirect3DSurface9 *m_rtSurfaces[16]; // current color RT surfaces. [0] is initially == m_defaultColorSurface - IDirect3DSurface9 *m_dsSurface; // current DS RT surface. can be changed! - - IDirect3DSurface9 *m_defaultColorSurface; // default color surface. - IDirect3DSurface9 *m_defaultDepthStencilSurface; // queried by GetDepthStencilSurface. - - IDirect3DVertexDeclaration9 *m_vertDecl; // Set by SetVertexDeclaration... - D3DStreamDesc m_streams[ D3D_MAX_STREAMS ]; // Set by SetStreamSource.. - D3DIndexDesc m_indices; // Set by SetIndices.. - - IDirect3DVertexShader9 *m_vertexShader; // Set by SetVertexShader... - IDirect3DPixelShader9 *m_pixelShader; // Set by SetPixelShader... - - IDirect3DBaseTexture9 *m_textures[16]; // set by SetTexture... NULL if stage inactive - D3DSamplerDesc m_samplers[16]; // set by SetSamplerState.. - // GLM flavor stuff - GLMContext *m_ctx; - CGLMFBO *m_drawableFBO; // this FBO should have all the attachments set to match m_rtSurfaces and m_dsSurface. - - // GL state - struct - { - // render state buckets - GLAlphaTestEnable_t m_AlphaTestEnable; - GLAlphaTestFunc_t m_AlphaTestFunc; - - GLAlphaToCoverageEnable_t m_AlphaToCoverageEnable; - - GLDepthTestEnable_t m_DepthTestEnable; - GLDepthMask_t m_DepthMask; - GLDepthFunc_t m_DepthFunc; - - GLClipPlaneEnable_t m_ClipPlaneEnable[kGLMUserClipPlanes]; - GLClipPlaneEquation_t m_ClipPlaneEquation[kGLMUserClipPlanes]; - - GLColorMaskSingle_t m_ColorMaskSingle; - GLColorMaskMultiple_t m_ColorMaskMultiple; - - GLCullFaceEnable_t m_CullFaceEnable; - GLCullFrontFace_t m_CullFrontFace; - GLPolygonMode_t m_PolygonMode; - GLDepthBias_t m_DepthBias; - GLScissorEnable_t m_ScissorEnable; - GLScissorBox_t m_ScissorBox; - GLViewportBox_t m_ViewportBox; - GLViewportDepthRange_t m_ViewportDepthRange; - - GLBlendEnable_t m_BlendEnable; - GLBlendFactor_t m_BlendFactor; - GLBlendEquation_t m_BlendEquation; - GLBlendColor_t m_BlendColor; - GLBlendEnableSRGB_t m_BlendEnableSRGB; - - GLStencilTestEnable_t m_StencilTestEnable; - GLStencilFunc_t m_StencilFunc; - GLStencilOp_t m_StencilOp; - GLStencilWriteMask_t m_StencilWriteMask; - - GLClearColor_t m_ClearColor; - GLClearDepth_t m_ClearDepth; - GLClearStencil_t m_ClearStencil; - - bool m_FogEnable; // not really pushed to GL, just latched here - - // samplers - GLMTexSamplingParams m_samplers[ 16 ]; - - // bindings...hmmm... - - // dirty-bits - uint m_stateDirtyMask; // covers the state blocks, indexed by 1<m_nCurOwnerThreadId; } - -}; - -struct ID3DXInclude -{ - virtual HRESULT Open(D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes) = 0; - virtual HRESULT Close(LPCVOID pData) = 0; -}; -typedef ID3DXInclude* LPD3DXINCLUDE; - - -struct TOGL_CLASS ID3DXBuffer : public IUnknown -{ - void* GetBufferPointer(); - DWORD GetBufferSize(); -}; - -typedef ID3DXBuffer* LPD3DXBUFFER; - -class TOGL_CLASS ID3DXConstantTable : public IUnknown -{ -}; -typedef ID3DXConstantTable* LPD3DXCONSTANTTABLE; - - - -// ------------------------------------------------------------------------------------------------------------------------------ // -// D3DX stuff. -// ------------------------------------------------------------------------------------------------------------------------------ // - -TOGL_INTERFACE const char* D3DXGetPixelShaderProfile( IDirect3DDevice9 *pDevice ); - - -TOGL_INTERFACE D3DXMATRIX* D3DXMatrixMultiply( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); -TOGL_INTERFACE D3DXVECTOR3* D3DXVec3TransformCoord( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - -TOGL_INTERFACE HRESULT D3DXCreateMatrixStack( DWORD Flags, LPD3DXMATRIXSTACK* ppStack); -TOGL_INTERFACE void D3DXMatrixIdentity( D3DXMATRIX * ); - -TOGL_INTERFACE D3DXINLINE D3DXVECTOR3* D3DXVec3Subtract( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ - pOut->x = pV1->x - pV2->x; - pOut->y = pV1->y - pV2->y; - pOut->z = pV1->z - pV2->z; - return pOut; -} - -TOGL_INTERFACE D3DXINLINE D3DXVECTOR3* D3DXVec3Cross( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ - D3DXVECTOR3 v; - - v.x = pV1->y * pV2->z - pV1->z * pV2->y; - v.y = pV1->z * pV2->x - pV1->x * pV2->z; - v.z = pV1->x * pV2->y - pV1->y * pV2->x; - - *pOut = v; - return pOut; -} - -TOGL_INTERFACE D3DXINLINE FLOAT D3DXVec3Dot( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) -{ - return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z; -} - -TOGL_INTERFACE D3DXMATRIX* D3DXMatrixInverse( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); - -TOGL_INTERFACE D3DXMATRIX* D3DXMatrixTranspose( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); - -TOGL_INTERFACE D3DXPLANE* D3DXPlaneNormalize( D3DXPLANE *pOut, CONST D3DXPLANE *pP); - -TOGL_INTERFACE D3DXVECTOR4* D3DXVec4Transform( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); - - -TOGL_INTERFACE D3DXVECTOR4* D3DXVec4Normalize( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); - -TOGL_INTERFACE D3DXMATRIX* D3DXMatrixTranslation( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); - -// Build an ortho projection matrix. (right-handed) -TOGL_INTERFACE D3DXMATRIX* D3DXMatrixOrthoOffCenterRH( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,FLOAT zf ); - -TOGL_INTERFACE D3DXMATRIX* D3DXMatrixPerspectiveRH( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -TOGL_INTERFACE D3DXMATRIX* D3DXMatrixPerspectiveOffCenterRH( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); - -// Transform a plane by a matrix. The vector (a,b,c) must be normal. -// M should be the inverse transpose of the transformation desired. -TOGL_INTERFACE D3DXPLANE* D3DXPlaneTransform( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); - -TOGL_INTERFACE IDirect3D9 *Direct3DCreate9(UINT SDKVersion); - -TOGL_INTERFACE void D3DPERF_SetOptions( DWORD dwOptions ); - -TOGL_INTERFACE HRESULT D3DXCompileShader( - LPCSTR pSrcData, - UINT SrcDataLen, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPCSTR pFunctionName, - LPCSTR pProfile, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs, - LPD3DXCONSTANTTABLE* ppConstantTable); - - -#endif // USE_ACTUAL_DX - -// fake D3D usage constant for SRGB tex creation -#define D3DUSAGE_TEXTURE_SRGB (0x80000000L) - -#endif // DXABSTRACT_H +// +// +// +//================================================================================================== + +#ifndef DXABSTRACT_H +#define DXABSTRACT_H +#ifdef _WIN32 +#pragma once +#endif + +#include "togl/rendermechanism.h" + +#include "materialsystem/ishader.h" + +// Uncomment this on Windows if you want to compile the Windows GL version. +// #undef USE_ACTUAL_DX + +#ifdef USE_ACTUAL_DX + +#ifndef WIN32 +#error sorry man +#endif +#ifdef _X360 +#include "d3d9.h" +#include "d3dx9.h" +#else +#include +#include "../../dx9sdk/include/d3d9.h" +#include "../../dx9sdk/include/d3dx9.h" +#endif +typedef HWND VD3DHWND; + +#else + +#ifdef WIN32 +#error Gl on win32? +#endif + +#include "tier0/platform.h" + +#ifndef DX_TO_GL_ABSTRACTION +#define DX_TO_GL_ABSTRACTION +#endif + +#include "bitmap/imageformat.h" +#include "togl/rendermechanism.h" + +#ifdef OSX +extern "C" void Debugger(void); +#endif + +// turn this on to get refcount logging from IUnknown +#define IUNKNOWN_ALLOC_SPEW 0 +#define IUNKNOWN_ALLOC_SPEW_MARK_ALL 0 + + +// ------------------------------------------------------------------------------------------------------------------------------ // +// DEFINES +// ------------------------------------------------------------------------------------------------------------------------------ // + +typedef void* VD3DHWND; +typedef void* VD3DHANDLE; + + +TOGL_INTERFACE void toglGetClientRect( VD3DHWND hWnd, RECT *destRect ); + +struct TOGL_CLASS IUnknown +{ + int m_refcount[2]; + bool m_mark; + + IUnknown( void ) + { + m_refcount[0] = 1; + m_refcount[1] = 0; + m_mark = (IUNKNOWN_ALLOC_SPEW_MARK_ALL != 0); // either all are marked, or only the ones that have SetMark(true) called on them + + #if IUNKNOWN_ALLOC_SPEW + if (m_mark) + { + GLMPRINTF(("-A- IUnew (%08x) refc -> (%d,%d) ",this,m_refcount[0],m_refcount[1])); + } + #endif + }; + + virtual ~IUnknown( void ) + { + #if IUNKNOWN_ALLOC_SPEW + if (m_mark) + { + GLMPRINTF(("-A- IUdel (%08x) ",this )); + } + #endif + }; + + void AddRef( int which=0, char *comment = NULL ) + { + Assert( which >= 0 ); + Assert( which < 2 ); + m_refcount[which]++; + + #if IUNKNOWN_ALLOC_SPEW + if (m_mark) + { + GLMPRINTF(("-A- IUAddRef (%08x,%d) refc -> (%d,%d) [%s]",this,which,m_refcount[0],m_refcount[1],comment?comment:"...")) ; + if (!comment) + { + GLMPRINTF(("")) ; // place to hang a breakpoint + } + } + #endif + }; + + ULONG __stdcall Release( int which=0, char *comment = NULL ) + { + Assert( which >= 0 ); + Assert( which < 2 ); + + //int oldrefcs[2] = { m_refcount[0], m_refcount[1] }; + bool deleting = false; + + m_refcount[which]--; + if ( (!m_refcount[0]) && (!m_refcount[1]) ) + { + deleting = true; + } + + #if IUNKNOWN_ALLOC_SPEW + if (m_mark) + { + GLMPRINTF(("-A- IURelease (%08x,%d) refc -> (%d,%d) [%s] %s",this,which,m_refcount[0],m_refcount[1],comment?comment:"...",deleting?"->DELETING":"")); + if (!comment) + { + GLMPRINTF(("")) ; // place to hang a breakpoint + } + } + #endif + + if (deleting) + { + if (m_mark) + { + GLMPRINTF(("")) ; // place to hang a breakpoint + } + delete this; + return 0; + } + else + { + return m_refcount[0]; + } + }; + + void SetMark( bool markValue, char *comment=NULL ) + { + #if IUNKNOWN_ALLOC_SPEW + if (!m_mark && markValue) // leading edge detect + { + // print the same thing that the constructor would have printed if it had been marked from the beginning + // i.e. it's anticipated that callers asking for marking will do so right at create time + GLMPRINTF(("-A- IUSetMark (%08x) refc -> (%d,%d) (%s) ",this,m_refcount[0],m_refcount[1],comment?comment:"...")); + } + #endif + + m_mark = markValue; + } +}; + + +// ------------------------------------------------------------------------------------------------------------------------------ // +// INTERFACES +// ------------------------------------------------------------------------------------------------------------------------------ // + +struct TOGL_CLASS IDirect3DResource9 : public IUnknown +{ + IDirect3DDevice9 *m_device; // parent device + D3DRESOURCETYPE m_restype; + + DWORD SetPriority(DWORD PriorityNew); +}; + +struct TOGL_CLASS IDirect3DBaseTexture9 : public IDirect3DResource9 // "A Texture.." +{ + D3DSURFACE_DESC m_descZero; // desc of top level. + CGLMTex *m_tex; // a CGLMTex can represent all forms of tex + int m_srgbFlipCount; + + virtual ~IDirect3DBaseTexture9(); + D3DRESOURCETYPE GetType(); + DWORD GetLevelCount(); + HRESULT GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc); +}; + +struct TOGL_CLASS IDirect3DTexture9 : public IDirect3DBaseTexture9 // "Texture 2D" +{ + IDirect3DSurface9 *m_surfZero; // surf of top level. + + virtual ~IDirect3DTexture9(); + + HRESULT LockRect(UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags); + HRESULT UnlockRect(UINT Level); + HRESULT GetSurfaceLevel(UINT Level,IDirect3DSurface9** ppSurfaceLevel); +}; + +struct TOGL_CLASS IDirect3DCubeTexture9 : public IDirect3DBaseTexture9 // "Texture Cube Map" +{ + IDirect3DSurface9 *m_surfZero[6]; // surfs of top level. + + virtual ~IDirect3DCubeTexture9(); + + HRESULT GetCubeMapSurface(D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface9** ppCubeMapSurface); + HRESULT GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc); +}; + +struct TOGL_CLASS IDirect3DVolumeTexture9 : public IDirect3DBaseTexture9 // "Texture 3D" +{ + IDirect3DSurface9 *m_surfZero; // surf of top level. + D3DVOLUME_DESC m_volDescZero; // volume desc top level + + virtual ~IDirect3DVolumeTexture9(); + + HRESULT LockBox(UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags); + HRESULT UnlockBox(UINT Level); + HRESULT GetLevelDesc( UINT level, D3DVOLUME_DESC *pDesc ); +}; + + +// for the moment, a "D3D surface" is modeled as a GLM tex, a face, and a mip. +// no Create method, these are filled in by the various create surface methods. + +struct TOGL_CLASS IDirect3DSurface9 : public IDirect3DResource9 +{ + virtual ~IDirect3DSurface9(); + + HRESULT LockRect(D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags); + HRESULT UnlockRect(); + HRESULT GetDesc(D3DSURFACE_DESC *pDesc); + + D3DSURFACE_DESC m_desc; + CGLMTex *m_tex; + int m_face; + int m_mip; +}; + + + +struct TOGL_CLASS IDirect3D9 : public IUnknown +{ +public: + virtual ~IDirect3D9(); + + UINT GetAdapterCount(); //cheese: returns 1 + + HRESULT GetDeviceCaps (UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps); + HRESULT GetAdapterIdentifier (UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier); + HRESULT CheckDeviceFormat (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat); + UINT GetAdapterModeCount (UINT Adapter,D3DFORMAT Format); + HRESULT EnumAdapterModes (UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode); + HRESULT CheckDeviceType (UINT Adapter,D3DDEVTYPE DevType,D3DFORMAT AdapterFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed); + HRESULT GetAdapterDisplayMode (UINT Adapter,D3DDISPLAYMODE* pMode); + HRESULT CheckDepthStencilMatch (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat); + HRESULT CheckDeviceMultiSampleType (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels); + + HRESULT CreateDevice (UINT Adapter,D3DDEVTYPE DeviceType,VD3DHWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface); +}; + +struct TOGL_CLASS IDirect3DSwapChain9 : public IUnknown +{ +}; + + + + // typedef enum D3DDECLUSAGE + // { + // D3DDECLUSAGE_POSITION = 0, + // D3DDECLUSAGE_BLENDWEIGHT = 1, + // D3DDECLUSAGE_BLENDINDICES = 2, + // D3DDECLUSAGE_NORMAL = 3, + // D3DDECLUSAGE_PSIZE = 4, + // D3DDECLUSAGE_TEXCOORD = 5, + // D3DDECLUSAGE_TANGENT = 6, + // D3DDECLUSAGE_BINORMAL = 7, + // D3DDECLUSAGE_TESSFACTOR = 8, + // D3DDECLUSAGE_POSITIONT = 9, + // D3DDECLUSAGE_COLOR = 10, + // D3DDECLUSAGE_FOG = 11, + // D3DDECLUSAGE_DEPTH = 12, + // D3DDECLUSAGE_SAMPLE = 13, + // } D3DDECLUSAGE, *LPD3DDECLUSAGE; + // Constants + // + // D3DDECLUSAGE_POSITION + // Position data ranging from (-1,-1) to (1,1). Use D3DDECLUSAGE_POSITION with + // a usage index of 0 to specify untransformed position for fixed function + // vertex processing and the n-patch tessellator. Use D3DDECLUSAGE_POSITION + // with a usage index of 1 to specify untransformed position in the fixed + // function vertex shader for vertex tweening. + // + // D3DDECLUSAGE_BLENDWEIGHT + // Blending weight data. Use D3DDECLUSAGE_BLENDWEIGHT with a usage index of 0 + // to specify the blend weights used in indexed and nonindexed vertex + // blending. + // + // D3DDECLUSAGE_BLENDINDICES + // Blending indices data. Use D3DDECLUSAGE_BLENDINDICES with a usage index of + // 0 to specify matrix indices for indexed paletted skinning. + // + // D3DDECLUSAGE_NORMAL + // Vertex normal data. Use D3DDECLUSAGE_NORMAL with a usage index of 0 to + // specify vertex normals for fixed function vertex processing and the n-patch + // tessellator. Use D3DDECLUSAGE_NORMAL with a usage index of 1 to specify + // vertex normals for fixed function vertex processing for vertex tweening. + // + // D3DDECLUSAGE_PSIZE + // Point size data. Use D3DDECLUSAGE_PSIZE with a usage index of 0 to specify + // the point-size attribute used by the setup engine of the rasterizer to + // expand a point into a quad for the point-sprite functionality. + // + // D3DDECLUSAGE_TEXCOORD + // Texture coordinate data. Use D3DDECLUSAGE_TEXCOORD, n to specify texture + // coordinates in fixed function vertex processing and in pixel shaders prior + // to ps_3_0. These can be used to pass user defined data. + // + // D3DDECLUSAGE_TANGENT + // Vertex tangent data. + // + // D3DDECLUSAGE_BINORMAL + // Vertex binormal data. + // + // D3DDECLUSAGE_TESSFACTOR + // Single positive floating point value. Use D3DDECLUSAGE_TESSFACTOR with a + // usage index of 0 to specify a tessellation factor used in the tessellation + // unit to control the rate of tessellation. For more information about the + // data type, see D3DDECLTYPE_FLOAT1. + // + // D3DDECLUSAGE_POSITIONT + // Vertex data contains transformed position data ranging from (0,0) to + // (viewport width, viewport height). Use D3DDECLUSAGE_POSITIONT with a usage + // index of 0 to specify transformed position. When a declaration containing + // this is set, the pipeline does not perform vertex processing. + // + // D3DDECLUSAGE_COLOR + // Vertex data contains diffuse or specular color. Use D3DDECLUSAGE_COLOR with + // a usage index of 0 to specify the diffuse color in the fixed function + // vertex shader and pixel shaders prior to ps_3_0. Use D3DDECLUSAGE_COLOR + // with a usage index of 1 to specify the specular color in the fixed function + // vertex shader and pixel shaders prior to ps_3_0. + // + // D3DDECLUSAGE_FOG + // Vertex data contains fog data. Use D3DDECLUSAGE_FOG with a usage index of 0 + // to specify a fog blend value used after pixel shading finishes. This + // applies to pixel shaders prior to version ps_3_0. + // + // D3DDECLUSAGE_DEPTH + // Vertex data contains depth data. + // + // D3DDECLUSAGE_SAMPLE + // Vertex data contains sampler data. Use D3DDECLUSAGE_SAMPLE with a usage + // index of 0 to specify the displacement value to look up. It can be used + // only with D3DDECLUSAGE_LOOKUPPRESAMPLED or D3DDECLUSAGE_LOOKUP. + + //note the form of the list terminator.. + + // #define D3DDECL_END() {0xFF,0,D3DDECLTYPE_UNUSED,0,0,0} + // typedef struct _D3DVERTEXELEMENT9 + // { + // WORD Stream; // Stream index + // WORD Offset; // Offset in the stream in bytes + // BYTE Type; // Data type + // BYTE Method; // Processing method + // BYTE Usage; // Semantics + // BYTE UsageIndex; // Semantic index + // } D3DVERTEXELEMENT9, *LPD3DVERTEXELEMENT9; + +#define MAX_D3DVERTEXELEMENTS 16 + +struct TOGL_CLASS IDirect3DVertexDeclaration9 : public IUnknown +{ +//public: + uint m_elemCount; + D3DVERTEXELEMENT9_GL m_elements[ MAX_D3DVERTEXELEMENTS ]; + + virtual ~IDirect3DVertexDeclaration9(); +}; + +struct TOGL_CLASS IDirect3DQuery9 : public IDirect3DResource9 //was IUnknown +{ +//public: + D3DQUERYTYPE m_type; // D3DQUERYTYPE_OCCLUSION or D3DQUERYTYPE_EVENT + GLMContext *m_ctx; + CGLMQuery *m_query; + + virtual ~IDirect3DQuery9(); + + HRESULT Issue(DWORD dwIssueFlags); + HRESULT GetData(void* pData,DWORD dwSize,DWORD dwGetDataFlags); +}; + +struct TOGL_CLASS IDirect3DVertexBuffer9 : public IDirect3DResource9 //was IUnknown +{ +//public: + GLMContext *m_ctx; + CGLMBuffer *m_vtxBuffer; + D3DVERTEXBUFFER_DESC m_vtxDesc; // to satisfy GetDesc + + virtual ~IDirect3DVertexBuffer9(); + HRESULT Lock(UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags); + HRESULT Unlock(); + HRESULT UnlockActualSize( uint nActualSize, const void *pActualData = NULL ); + +}; + +struct TOGL_CLASS IDirect3DIndexBuffer9 : public IDirect3DResource9 //was IUnknown +{ +//public: + GLMContext *m_ctx; + CGLMBuffer *m_idxBuffer; + D3DINDEXBUFFER_DESC m_idxDesc; // to satisfy GetDesc + + virtual ~IDirect3DIndexBuffer9(); + + HRESULT Lock(UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags); + HRESULT Unlock(); + HRESULT UnlockActualSize( uint nActualSize, const void *pActualData = NULL ); + HRESULT GetDesc(D3DINDEXBUFFER_DESC *pDesc); +}; + +struct TOGL_CLASS IDirect3DPixelShader9 : public IDirect3DResource9 //was IUnknown +{ +//public: + CGLMProgram *m_pixProgram; + uint m_pixHighWater; // count of active constant slots referenced by shader. + uint m_pixSamplerMask; // (1< m_stack; + int m_stackTop; // top of stack is at the highest index, this is that index. push increases, pop decreases. + + HRESULT Create( void ); + + D3DXMATRIX* GetTop(); + void Push(); + void Pop(); + void LoadIdentity(); + void LoadMatrix( const D3DXMATRIX *pMat ); + void MultMatrix( const D3DXMATRIX *pMat ); + void MultMatrixLocal( const D3DXMATRIX *pMat ); + HRESULT ScaleLocal(FLOAT x, FLOAT y, FLOAT z); + + // Left multiply the current matrix with the computed rotation + // matrix, counterclockwise about the given axis with the given angle. + // (rotation is about the local origin of the object) + HRESULT RotateAxisLocal(CONST D3DXVECTOR3* pV, FLOAT Angle); + + // Left multiply the current matrix with the computed translation + // matrix. (transformation is about the local origin of the object) + HRESULT TranslateLocal(FLOAT x, FLOAT y, FLOAT z); +}; +typedef ID3DXMatrixStack* LPD3DXMATRIXSTACK; + +struct TOGL_CLASS IDirect3DDevice9 : public IUnknown +{ +public: + // members + + IDirect3DDevice9Params m_params; // mirror of the creation inputs + + // D3D flavor stuff + IDirect3DSurface9 *m_rtSurfaces[16]; // current color RT surfaces. [0] is initially == m_defaultColorSurface + IDirect3DSurface9 *m_dsSurface; // current DS RT surface. can be changed! + + IDirect3DSurface9 *m_defaultColorSurface; // default color surface. + IDirect3DSurface9 *m_defaultDepthStencilSurface; // queried by GetDepthStencilSurface. + + IDirect3DVertexDeclaration9 *m_vertDecl; // Set by SetVertexDeclaration... + D3DStreamDesc m_streams[ D3D_MAX_STREAMS ]; // Set by SetStreamSource.. + D3DIndexDesc m_indices; // Set by SetIndices.. + + IDirect3DVertexShader9 *m_vertexShader; // Set by SetVertexShader... + IDirect3DPixelShader9 *m_pixelShader; // Set by SetPixelShader... + + IDirect3DBaseTexture9 *m_textures[16]; // set by SetTexture... NULL if stage inactive + D3DSamplerDesc m_samplers[16]; // set by SetSamplerState.. + // GLM flavor stuff + GLMContext *m_ctx; + CGLMFBO *m_drawableFBO; // this FBO should have all the attachments set to match m_rtSurfaces and m_dsSurface. + + // GL state + struct + { + // render state buckets + GLAlphaTestEnable_t m_AlphaTestEnable; + GLAlphaTestFunc_t m_AlphaTestFunc; + + GLAlphaToCoverageEnable_t m_AlphaToCoverageEnable; + + GLDepthTestEnable_t m_DepthTestEnable; + GLDepthMask_t m_DepthMask; + GLDepthFunc_t m_DepthFunc; + + GLClipPlaneEnable_t m_ClipPlaneEnable[kGLMUserClipPlanes]; + GLClipPlaneEquation_t m_ClipPlaneEquation[kGLMUserClipPlanes]; + + GLColorMaskSingle_t m_ColorMaskSingle; + GLColorMaskMultiple_t m_ColorMaskMultiple; + + GLCullFaceEnable_t m_CullFaceEnable; + GLCullFrontFace_t m_CullFrontFace; + GLPolygonMode_t m_PolygonMode; + GLDepthBias_t m_DepthBias; + GLScissorEnable_t m_ScissorEnable; + GLScissorBox_t m_ScissorBox; + GLViewportBox_t m_ViewportBox; + GLViewportDepthRange_t m_ViewportDepthRange; + + GLBlendEnable_t m_BlendEnable; + GLBlendFactor_t m_BlendFactor; + GLBlendEquation_t m_BlendEquation; + GLBlendColor_t m_BlendColor; + GLBlendEnableSRGB_t m_BlendEnableSRGB; + + GLStencilTestEnable_t m_StencilTestEnable; + GLStencilFunc_t m_StencilFunc; + GLStencilOp_t m_StencilOp; + GLStencilWriteMask_t m_StencilWriteMask; + + GLClearColor_t m_ClearColor; + GLClearDepth_t m_ClearDepth; + GLClearStencil_t m_ClearStencil; + + bool m_FogEnable; // not really pushed to GL, just latched here + + // samplers + GLMTexSamplingParams m_samplers[ 16 ]; + + // bindings...hmmm... + + // dirty-bits + uint m_stateDirtyMask; // covers the state blocks, indexed by 1<m_nCurOwnerThreadId; } + +}; + +struct ID3DXInclude +{ + virtual HRESULT Open(D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes) = 0; + virtual HRESULT Close(LPCVOID pData) = 0; +}; +typedef ID3DXInclude* LPD3DXINCLUDE; + + +struct TOGL_CLASS ID3DXBuffer : public IUnknown +{ + void* GetBufferPointer(); + DWORD GetBufferSize(); +}; + +typedef ID3DXBuffer* LPD3DXBUFFER; + +class TOGL_CLASS ID3DXConstantTable : public IUnknown +{ +}; +typedef ID3DXConstantTable* LPD3DXCONSTANTTABLE; + + + +// ------------------------------------------------------------------------------------------------------------------------------ // +// D3DX stuff. +// ------------------------------------------------------------------------------------------------------------------------------ // + +TOGL_INTERFACE const char* D3DXGetPixelShaderProfile( IDirect3DDevice9 *pDevice ); + + +TOGL_INTERFACE D3DXMATRIX* D3DXMatrixMultiply( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); +TOGL_INTERFACE D3DXVECTOR3* D3DXVec3TransformCoord( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +TOGL_INTERFACE HRESULT D3DXCreateMatrixStack( DWORD Flags, LPD3DXMATRIXSTACK* ppStack); +TOGL_INTERFACE void D3DXMatrixIdentity( D3DXMATRIX * ); + +TOGL_INTERFACE D3DXINLINE D3DXVECTOR3* D3DXVec3Subtract( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + pOut->z = pV1->z - pV2->z; + return pOut; +} + +TOGL_INTERFACE D3DXINLINE D3DXVECTOR3* D3DXVec3Cross( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ + D3DXVECTOR3 v; + + v.x = pV1->y * pV2->z - pV1->z * pV2->y; + v.y = pV1->z * pV2->x - pV1->x * pV2->z; + v.z = pV1->x * pV2->y - pV1->y * pV2->x; + + *pOut = v; + return pOut; +} + +TOGL_INTERFACE D3DXINLINE FLOAT D3DXVec3Dot( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ + return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z; +} + +TOGL_INTERFACE D3DXMATRIX* D3DXMatrixInverse( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); + +TOGL_INTERFACE D3DXMATRIX* D3DXMatrixTranspose( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); + +TOGL_INTERFACE D3DXPLANE* D3DXPlaneNormalize( D3DXPLANE *pOut, CONST D3DXPLANE *pP); + +TOGL_INTERFACE D3DXVECTOR4* D3DXVec4Transform( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); + + +TOGL_INTERFACE D3DXVECTOR4* D3DXVec4Normalize( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); + +TOGL_INTERFACE D3DXMATRIX* D3DXMatrixTranslation( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); + +// Build an ortho projection matrix. (right-handed) +TOGL_INTERFACE D3DXMATRIX* D3DXMatrixOrthoOffCenterRH( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,FLOAT zf ); + +TOGL_INTERFACE D3DXMATRIX* D3DXMatrixPerspectiveRH( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +TOGL_INTERFACE D3DXMATRIX* D3DXMatrixPerspectiveOffCenterRH( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); + +// Transform a plane by a matrix. The vector (a,b,c) must be normal. +// M should be the inverse transpose of the transformation desired. +TOGL_INTERFACE D3DXPLANE* D3DXPlaneTransform( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); + +TOGL_INTERFACE IDirect3D9 *Direct3DCreate9(UINT SDKVersion); + +TOGL_INTERFACE void D3DPERF_SetOptions( DWORD dwOptions ); + +TOGL_INTERFACE HRESULT D3DXCompileShader( + LPCSTR pSrcData, + UINT SrcDataLen, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pFunctionName, + LPCSTR pProfile, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs, + LPD3DXCONSTANTTABLE* ppConstantTable); + + +#endif // USE_ACTUAL_DX + +// fake D3D usage constant for SRGB tex creation +#define D3DUSAGE_TEXTURE_SRGB (0x80000000L) + +#endif // DXABSTRACT_H diff --git a/sp/src/public/togl/osx/glfuncs.h b/sp/src/public/togl/osx/glfuncs.h index 78184bef..b0be737c 100644 --- a/sp/src/public/togl/osx/glfuncs.h +++ b/sp/src/public/togl/osx/glfuncs.h @@ -1,184 +1,184 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// !!! FIXME: Some of these aren't base OpenGL...pick out the extensions. -// !!! FIXME: Also, look up these -1, -1 versions numbers. -GL_FUNC(OpenGL,true,GLenum,glGetError,(void),()) -GL_FUNC_VOID(OpenGL,true,glActiveTexture,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glAlphaFunc,(GLenum a,GLclampf b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glAttachObjectARB,(GLhandleARB a,GLhandleARB b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glBegin,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glBindAttribLocationARB,(GLhandleARB a,GLuint b,const GLcharARB *c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glBindBufferARB,(GLenum a,GLuint b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glBindProgramARB,(GLenum a,GLuint b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glBindTexture,(GLenum a,GLuint b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glBlendColor,(GLclampf a,GLclampf b,GLclampf c,GLclampf d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glBlendEquation,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glBlendFunc,(GLenum a,GLenum b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glBufferDataARB,(GLenum a,GLsizeiptrARB b,const GLvoid *c,GLenum d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glClear,(GLbitfield a),(a)) -GL_FUNC_VOID(OpenGL,true,glClearColor,(GLclampf a,GLclampf b,GLclampf c,GLclampf d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glClearDepth,(GLclampd a),(a)) -GL_FUNC_VOID(OpenGL,true,glClearStencil,(GLint a),(a)) -GL_FUNC_VOID(OpenGL,true,glClipPlane,(GLenum a,const GLdouble *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glColorMask,(GLboolean a,GLboolean b,GLboolean c,GLboolean d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glCompileShaderARB,(GLhandleARB a),(a)) -GL_FUNC_VOID(OpenGL,true,glCompressedTexImage2D,(GLenum a,GLint b,GLenum c,GLsizei d,GLsizei e,GLint f,GLsizei g,const GLvoid *h),(a,b,c,d,e,f,g,h)) -GL_FUNC_VOID(OpenGL,true,glCompressedTexImage3D,(GLenum a,GLint b,GLenum c,GLsizei d,GLsizei e,GLsizei f,GLint g,GLsizei h,const GLvoid *i),(a,b,c,d,e,f,g,h,i)) -GL_FUNC(OpenGL,true,GLhandleARB,glCreateProgramObjectARB,(void),()) -GL_FUNC(OpenGL,true,GLhandleARB,glCreateShaderObjectARB,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glDeleteBuffersARB,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glDeleteObjectARB,(GLhandleARB a),(a)) -GL_FUNC_VOID(OpenGL,true,glDeleteProgramsARB,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glDeleteQueriesARB,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glDeleteShader,(GLuint a),(a)) -GL_FUNC_VOID(OpenGL,true,glDeleteTextures,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glDepthFunc,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glDepthMask,(GLboolean a),(a)) -GL_FUNC_VOID(OpenGL,true,glDepthRange,(GLclampd a,GLclampd b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glDetachObjectARB,(GLhandleARB a,GLhandleARB b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glDisable,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glDisableVertexAttribArray,(GLuint a),(a)) -GL_FUNC_VOID(OpenGL,true,glDrawArrays,(GLenum a,GLint b,GLsizei c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glDrawBuffer,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glDrawRangeElements,(GLenum a,GLuint b,GLuint c,GLsizei d,GLenum e,const GLvoid *f),(a,b,c,d,e,f)) -GL_FUNC_VOID(OpenGL,true,glEnable,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glEnableVertexAttribArray,(GLuint a),(a)) -GL_FUNC_VOID(OpenGL,true,glEnd,(void),()) -GL_FUNC_VOID(OpenGL,true,glFinish,(void),()) -GL_FUNC_VOID(OpenGL,true,glFlush,(void),()) -GL_FUNC_VOID(OpenGL,true,glFrontFace,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glGenBuffersARB,(GLsizei a,GLuint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glGenProgramsARB,(GLsizei a,GLuint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glGenQueriesARB,(GLsizei a,GLuint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glGenTextures,(GLsizei a,GLuint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glGetBooleanv,(GLenum a,GLboolean *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glGetCompressedTexImage,(GLenum a,GLint b,GLvoid *c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glGetDoublev,(GLenum a,GLdouble *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glGetFloatv,(GLenum a,GLfloat *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glGetInfoLogARB,(GLhandleARB a,GLsizei b,GLsizei *c,GLcharARB *d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glGetIntegerv,(GLenum a,GLint *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glGetObjectParameterivARB,(GLhandleARB a,GLenum b,GLint *c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glGetProgramivARB,(GLenum a,GLenum b,GLint *c),(a,b,c)) -GL_FUNC(OpenGL,true,const GLubyte *,glGetString,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glGetTexImage,(GLenum a,GLint b,GLenum c,GLenum d,GLvoid *e),(a,b,c,d,e)) -GL_FUNC(OpenGL,true,GLint,glGetUniformLocationARB,(GLhandleARB a,const GLcharARB *b),(a,b)) -GL_FUNC(OpenGL,true,GLboolean,glIsEnabled,(GLenum a),(a)) -GL_FUNC(OpenGL,true,GLboolean,glIsTexture,(GLuint a),(a)) -GL_FUNC_VOID(OpenGL,true,glLinkProgramARB,(GLhandleARB a),(a)) -GL_FUNC(OpenGL,true,GLvoid*,glMapBufferARB,(GLenum a,GLenum b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glOrtho,(GLdouble a,GLdouble b,GLdouble c,GLdouble d,GLdouble e,GLdouble f),(a,b,c,d,e,f)) -GL_FUNC_VOID(OpenGL,true,glPixelStorei,(GLenum a,GLint b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glPolygonMode,(GLenum a,GLenum b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glPolygonOffset,(GLfloat a,GLfloat b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glPopAttrib,(void),()) -GL_FUNC_VOID(OpenGL,true,glProgramStringARB,(GLenum a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glPushAttrib,(GLbitfield a),(a)) -GL_FUNC_VOID(OpenGL,true,glReadBuffer,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glScissor,(GLint a,GLint b,GLsizei c,GLsizei d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glShaderSourceARB,(GLhandleARB a,GLsizei b,const GLcharARB **c,const GLint *d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glStencilFunc,(GLenum a,GLint b,GLuint c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glStencilMask,(GLuint a),(a)) -GL_FUNC_VOID(OpenGL,true,glStencilOp,(GLenum a,GLenum b,GLenum c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glTexCoord2f,(GLfloat a,GLfloat b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glTexImage2D,(GLenum a,GLint b,GLint c,GLsizei d,GLsizei e,GLint f,GLenum g,GLenum h,const GLvoid *i),(a,b,c,d,e,f,g,h,i)) -GL_FUNC_VOID(OpenGL,true,glTexImage3D,(GLenum a,GLint b,GLint c,GLsizei d,GLsizei e,GLsizei f,GLint g,GLenum h,GLenum i,const GLvoid *j),(a,b,c,d,e,f,g,h,i,j)) -GL_FUNC_VOID(OpenGL,true,glTexParameterfv,(GLenum a,GLenum b,const GLfloat *c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glTexParameteri,(GLenum a,GLenum b,GLint c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glTexSubImage2D,(GLenum a,GLint b,GLint c,GLint d,GLsizei e,GLsizei f,GLenum g,GLenum h,const GLvoid *i),(a,b,c,d,e,f,g,h,i)) -GL_FUNC_VOID(OpenGL,true,glUniform1f,(GLint a,GLfloat b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glUniform1i,(GLint a,GLint b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glUniform1iARB,(GLint a,GLint b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glUniform4fv,(GLint a,GLsizei b,const GLfloat *c),(a,b,c)) -GL_FUNC(OpenGL,true,GLboolean,glUnmapBuffer,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glUseProgram,(GLuint a),(a)) -GL_FUNC_VOID(OpenGL,true,glVertex3f,(GLfloat a,GLfloat b,GLfloat c),(a,b,c)) -GL_FUNC_VOID(OpenGL,true,glVertexAttribPointer,(GLuint a,GLint b,GLenum c,GLboolean d,GLsizei e,const GLvoid *f),(a,b,c,d,e,f)) -GL_FUNC_VOID(OpenGL,true,glViewport,(GLint a,GLint b,GLsizei c,GLsizei d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glEnableClientState,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glDisableClientState,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glClientActiveTexture,(GLenum a),(a)) -GL_FUNC_VOID(OpenGL,true,glVertexPointer,(GLint a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glTexCoordPointer,(GLint a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glProgramEnvParameters4fvEXT,(GLenum a,GLuint b,GLsizei c,const GLfloat *d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glColor4sv,(const GLshort *a),(a)) -GL_FUNC_VOID(OpenGL,true,glStencilOpSeparate,(GLenum a,GLenum b,GLenum c,GLenum d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glStencilFuncSeparate,(GLenum a,GLenum b,GLint c,GLuint d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glGetTexLevelParameteriv,(GLenum a,GLint b,GLenum c,GLint *d),(a,b,c,d)) -GL_FUNC_VOID(OpenGL,true,glColor4f,(GLfloat a,GLfloat b,GLfloat c,GLfloat d),(a,b,c,d)) -GL_EXT(GL_EXT_framebuffer_object,-1,-1) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glBindFramebufferEXT,(GLenum a,GLuint b),(a,b)) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glBindRenderbufferEXT,(GLenum a,GLuint b),(a,b)) -GL_FUNC(GL_EXT_framebuffer_object,false,GLenum,glCheckFramebufferStatusEXT,(GLenum a),(a)) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glDeleteRenderbuffersEXT,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glFramebufferRenderbufferEXT,(GLenum a,GLenum b,GLenum c,GLuint d),(a,b,c,d)) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glFramebufferTexture2DEXT,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e),(a,b,c,d,e)) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glFramebufferTexture3DEXT,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e,GLint f),(a,b,c,d,e,f)) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glGenFramebuffersEXT,(GLsizei a,GLuint *b),(a,b)) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glGenRenderbuffersEXT,(GLsizei a,GLuint *b),(a,b)) -GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glDeleteFramebuffersEXT,(GLsizei a,const GLuint *b),(a,b)) -GL_EXT(GL_EXT_framebuffer_blit,-1,-1) -GL_FUNC_VOID(GL_EXT_framebuffer_blit,false,glBlitFramebufferEXT,(GLint a,GLint b,GLint c,GLint d,GLint e,GLint f,GLint g,GLint h,GLbitfield i,GLenum j),(a,b,c,d,e,f,g,h,i,j)) -GL_EXT(GL_EXT_framebuffer_multisample,-1,-1) -GL_FUNC_VOID(GL_EXT_framebuffer_multisample,false,glRenderbufferStorageMultisampleEXT,(GLenum a,GLsizei b,GLenum c,GLsizei d,GLsizei e),(a,b,c,d,e)) -GL_EXT(GL_APPLE_fence,-1,-1) -GL_FUNC(GL_APPLE_fence,false,GLboolean,glTestFenceAPPLE,(GLuint a),(a)) -GL_FUNC_VOID(GL_APPLE_fence,false,glSetFenceAPPLE,(GLuint a),(a)) -GL_FUNC_VOID(GL_APPLE_fence,false,glFinishFenceAPPLE,(GLuint a),(a)) -GL_FUNC_VOID(GL_APPLE_fence,false,glDeleteFencesAPPLE,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(GL_APPLE_fence,false,glGenFencesAPPLE,(GLsizei a,GLuint *b),(a,b)) -GL_EXT(GL_NV_fence,-1,-1) -GL_FUNC(GL_NV_fence,false,GLboolean,glTestFenceNV,(GLuint a),(a)) -GL_FUNC_VOID(GL_NV_fence,false,glSetFenceNV,(GLuint a,GLenum b),(a,b)) -GL_FUNC_VOID(GL_NV_fence,false,glFinishFenceNV,(GLuint a),(a)) -GL_FUNC_VOID(GL_NV_fence,false,glDeleteFencesNV,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(GL_NV_fence,false,glGenFencesNV,(GLsizei a,GLuint *b),(a,b)) -GL_EXT(GL_ARB_sync,3,2) -#ifdef HAVE_GL_ARB_SYNC -GL_FUNC_VOID(GL_ARB_sync,false,glGetSynciv,(GLsync a, GLenum b, GLsizei c, GLsizei *d, GLint *e),(a,b,c,d,e)) -GL_FUNC(GL_ARB_sync,false,GLenum,glClientWaitSync,(GLsync a, GLbitfield b, GLuint64 c),(a,b,c)) -GL_FUNC_VOID(GL_ARB_sync,false,glWaitSync,(GLsync a, GLbitfield b, GLuint64 c),(a,b,c)) -GL_FUNC_VOID(GL_ARB_sync,false,glDeleteSync,(GLsync a),(a)) -GL_FUNC(GL_ARB_sync,false,GLsync,glFenceSync,(GLenum a, GLbitfield b),(a,b)) -#endif -GL_EXT(GL_EXT_draw_buffers2,-1,-1) -GL_FUNC_VOID(GL_EXT_draw_buffers2,false,glColorMaskIndexedEXT,(GLuint a,GLboolean b,GLboolean c,GLboolean d,GLboolean e),(a,b,c,d,e)) -GL_FUNC_VOID(GL_EXT_draw_buffers2,false,glEnableIndexedEXT,(GLenum a,GLuint b),(a,b)) -GL_FUNC_VOID(GL_EXT_draw_buffers2,false,glDisableIndexedEXT,(GLenum a,GLuint b),(a,b)) -GL_FUNC_VOID(GL_EXT_draw_buffers2,false,glGetBooleanIndexedvEXT,(GLenum a,GLuint b,GLboolean *c),(a,b,c)) -GL_EXT(GL_EXT_bindable_uniform,-1,-1) -GL_FUNC_VOID(GL_EXT_bindable_uniform,false,glUniformBufferEXT,(GLuint a,GLint b,GLuint c),(a,b,c)) -GL_EXT(GL_APPLE_flush_buffer_range,-1,-1) -GL_FUNC_VOID(GL_APPLE_flush_buffer_range,false,glBufferParameteriAPPLE,(GLenum a,GLenum b,GLint c),(a,b,c)) -GL_FUNC_VOID(GL_APPLE_flush_buffer_range,false,glFlushMappedBufferRangeAPPLE,(GLenum a,GLintptr b,GLsizeiptr c),(a,b,c)) -GL_EXT(GL_ARB_map_buffer_range,-1,-1) -GL_FUNC(GL_ARB_map_buffer_range,false,void*,glMapBufferRange,(GLenum a,GLintptr b,GLsizeiptr c,GLbitfield d),(a,b,c,d)) -GL_FUNC_VOID(GL_ARB_map_buffer_range,false,glFlushMappedBufferRange,(GLenum a,GLintptr b,GLsizeiptr c),(a,b,c)) -GL_EXT(GL_ARB_occlusion_query,-1,-1) -GL_FUNC_VOID(GL_ARB_occlusion_query,false,glBeginQueryARB,(GLenum a,GLuint b),(a,b)) -GL_FUNC_VOID(GL_ARB_occlusion_query,false,glEndQueryARB,(GLenum a),(a)) -GL_FUNC_VOID(GL_ARB_occlusion_query,false,glGetQueryObjectivARB,(GLuint a,GLenum b,GLint *c),(a,b,c)) -GL_FUNC_VOID(GL_ARB_occlusion_query,false,glGetQueryObjectuivARB,(GLuint a,GLenum b,GLuint *c),(a,b,c)) -GL_EXT(GL_APPLE_texture_range,-1,-1) -GL_FUNC_VOID(GL_APPLE_texture_range,false,glTextureRangeAPPLE,(GLenum a,GLsizei b,void *c),(a,b,c)) -GL_FUNC_VOID(GL_APPLE_texture_range,false,glGetTexParameterPointervAPPLE,(GLenum a,GLenum b,void* *c),(a,b,c)) -GL_EXT(GL_APPLE_client_storage,-1,-1) -GL_EXT(GL_ARB_uniform_buffer,-1,-1) -GL_EXT(GL_ARB_vertex_array_bgra,-1,-1) -GL_EXT(GL_EXT_vertex_array_bgra,-1,-1) -GL_EXT(GL_ARB_framebuffer_object,3,0) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glBindFramebuffer,(GLenum a,GLuint b),(a,b)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glBindRenderbuffer,(GLenum a,GLuint b),(a,b)) -GL_FUNC(GL_ARB_framebuffer_object,false,GLenum,glCheckFramebufferStatus,(GLenum a),(a)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glDeleteRenderbuffers,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glFramebufferRenderbuffer,(GLenum a,GLenum b,GLenum c,GLuint d),(a,b,c,d)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glFramebufferTexture2D,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e),(a,b,c,d,e)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glFramebufferTexture3D,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e,GLint f),(a,b,c,d,e,f)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glGenFramebuffers,(GLsizei a,GLuint *b),(a,b)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glGenRenderbuffers,(GLsizei a,GLuint *b),(a,b)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glDeleteFramebuffers,(GLsizei a,const GLuint *b),(a,b)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glBlitFramebuffer,(GLint a,GLint b,GLint c,GLint d,GLint e,GLint f,GLint g,GLint h,GLbitfield i,GLenum j),(a,b,c,d,e,f,g,h,i,j)) -GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glRenderbufferStorageMultisample,(GLenum a,GLsizei b,GLenum c,GLsizei d,GLsizei e),(a,b,c,d,e)) -GL_EXT(GL_GREMEDY_string_marker,-1,-1) -GL_FUNC_VOID(GL_GREMEDY_string_marker,false,glStringMarkerGREMEDY,(GLsizei a,const void *b),(a,b)) -GL_FUNC_VOID(OpenGL,true,glPushClientAttrib,(GLbitfield a),(a)) -GL_FUNC_VOID(OpenGL,true,glPopClientAttrib,(void),()) - +// !!! FIXME: Some of these aren't base OpenGL...pick out the extensions. +// !!! FIXME: Also, look up these -1, -1 versions numbers. +GL_FUNC(OpenGL,true,GLenum,glGetError,(void),()) +GL_FUNC_VOID(OpenGL,true,glActiveTexture,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glAlphaFunc,(GLenum a,GLclampf b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glAttachObjectARB,(GLhandleARB a,GLhandleARB b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glBegin,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glBindAttribLocationARB,(GLhandleARB a,GLuint b,const GLcharARB *c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glBindBufferARB,(GLenum a,GLuint b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glBindProgramARB,(GLenum a,GLuint b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glBindTexture,(GLenum a,GLuint b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glBlendColor,(GLclampf a,GLclampf b,GLclampf c,GLclampf d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glBlendEquation,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glBlendFunc,(GLenum a,GLenum b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glBufferDataARB,(GLenum a,GLsizeiptrARB b,const GLvoid *c,GLenum d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glClear,(GLbitfield a),(a)) +GL_FUNC_VOID(OpenGL,true,glClearColor,(GLclampf a,GLclampf b,GLclampf c,GLclampf d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glClearDepth,(GLclampd a),(a)) +GL_FUNC_VOID(OpenGL,true,glClearStencil,(GLint a),(a)) +GL_FUNC_VOID(OpenGL,true,glClipPlane,(GLenum a,const GLdouble *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glColorMask,(GLboolean a,GLboolean b,GLboolean c,GLboolean d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glCompileShaderARB,(GLhandleARB a),(a)) +GL_FUNC_VOID(OpenGL,true,glCompressedTexImage2D,(GLenum a,GLint b,GLenum c,GLsizei d,GLsizei e,GLint f,GLsizei g,const GLvoid *h),(a,b,c,d,e,f,g,h)) +GL_FUNC_VOID(OpenGL,true,glCompressedTexImage3D,(GLenum a,GLint b,GLenum c,GLsizei d,GLsizei e,GLsizei f,GLint g,GLsizei h,const GLvoid *i),(a,b,c,d,e,f,g,h,i)) +GL_FUNC(OpenGL,true,GLhandleARB,glCreateProgramObjectARB,(void),()) +GL_FUNC(OpenGL,true,GLhandleARB,glCreateShaderObjectARB,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glDeleteBuffersARB,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glDeleteObjectARB,(GLhandleARB a),(a)) +GL_FUNC_VOID(OpenGL,true,glDeleteProgramsARB,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glDeleteQueriesARB,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glDeleteShader,(GLuint a),(a)) +GL_FUNC_VOID(OpenGL,true,glDeleteTextures,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glDepthFunc,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glDepthMask,(GLboolean a),(a)) +GL_FUNC_VOID(OpenGL,true,glDepthRange,(GLclampd a,GLclampd b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glDetachObjectARB,(GLhandleARB a,GLhandleARB b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glDisable,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glDisableVertexAttribArray,(GLuint a),(a)) +GL_FUNC_VOID(OpenGL,true,glDrawArrays,(GLenum a,GLint b,GLsizei c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glDrawBuffer,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glDrawRangeElements,(GLenum a,GLuint b,GLuint c,GLsizei d,GLenum e,const GLvoid *f),(a,b,c,d,e,f)) +GL_FUNC_VOID(OpenGL,true,glEnable,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glEnableVertexAttribArray,(GLuint a),(a)) +GL_FUNC_VOID(OpenGL,true,glEnd,(void),()) +GL_FUNC_VOID(OpenGL,true,glFinish,(void),()) +GL_FUNC_VOID(OpenGL,true,glFlush,(void),()) +GL_FUNC_VOID(OpenGL,true,glFrontFace,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glGenBuffersARB,(GLsizei a,GLuint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glGenProgramsARB,(GLsizei a,GLuint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glGenQueriesARB,(GLsizei a,GLuint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glGenTextures,(GLsizei a,GLuint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glGetBooleanv,(GLenum a,GLboolean *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glGetCompressedTexImage,(GLenum a,GLint b,GLvoid *c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glGetDoublev,(GLenum a,GLdouble *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glGetFloatv,(GLenum a,GLfloat *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glGetInfoLogARB,(GLhandleARB a,GLsizei b,GLsizei *c,GLcharARB *d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glGetIntegerv,(GLenum a,GLint *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glGetObjectParameterivARB,(GLhandleARB a,GLenum b,GLint *c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glGetProgramivARB,(GLenum a,GLenum b,GLint *c),(a,b,c)) +GL_FUNC(OpenGL,true,const GLubyte *,glGetString,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glGetTexImage,(GLenum a,GLint b,GLenum c,GLenum d,GLvoid *e),(a,b,c,d,e)) +GL_FUNC(OpenGL,true,GLint,glGetUniformLocationARB,(GLhandleARB a,const GLcharARB *b),(a,b)) +GL_FUNC(OpenGL,true,GLboolean,glIsEnabled,(GLenum a),(a)) +GL_FUNC(OpenGL,true,GLboolean,glIsTexture,(GLuint a),(a)) +GL_FUNC_VOID(OpenGL,true,glLinkProgramARB,(GLhandleARB a),(a)) +GL_FUNC(OpenGL,true,GLvoid*,glMapBufferARB,(GLenum a,GLenum b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glOrtho,(GLdouble a,GLdouble b,GLdouble c,GLdouble d,GLdouble e,GLdouble f),(a,b,c,d,e,f)) +GL_FUNC_VOID(OpenGL,true,glPixelStorei,(GLenum a,GLint b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glPolygonMode,(GLenum a,GLenum b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glPolygonOffset,(GLfloat a,GLfloat b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glPopAttrib,(void),()) +GL_FUNC_VOID(OpenGL,true,glProgramStringARB,(GLenum a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glPushAttrib,(GLbitfield a),(a)) +GL_FUNC_VOID(OpenGL,true,glReadBuffer,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glScissor,(GLint a,GLint b,GLsizei c,GLsizei d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glShaderSourceARB,(GLhandleARB a,GLsizei b,const GLcharARB **c,const GLint *d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glStencilFunc,(GLenum a,GLint b,GLuint c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glStencilMask,(GLuint a),(a)) +GL_FUNC_VOID(OpenGL,true,glStencilOp,(GLenum a,GLenum b,GLenum c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glTexCoord2f,(GLfloat a,GLfloat b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glTexImage2D,(GLenum a,GLint b,GLint c,GLsizei d,GLsizei e,GLint f,GLenum g,GLenum h,const GLvoid *i),(a,b,c,d,e,f,g,h,i)) +GL_FUNC_VOID(OpenGL,true,glTexImage3D,(GLenum a,GLint b,GLint c,GLsizei d,GLsizei e,GLsizei f,GLint g,GLenum h,GLenum i,const GLvoid *j),(a,b,c,d,e,f,g,h,i,j)) +GL_FUNC_VOID(OpenGL,true,glTexParameterfv,(GLenum a,GLenum b,const GLfloat *c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glTexParameteri,(GLenum a,GLenum b,GLint c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glTexSubImage2D,(GLenum a,GLint b,GLint c,GLint d,GLsizei e,GLsizei f,GLenum g,GLenum h,const GLvoid *i),(a,b,c,d,e,f,g,h,i)) +GL_FUNC_VOID(OpenGL,true,glUniform1f,(GLint a,GLfloat b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glUniform1i,(GLint a,GLint b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glUniform1iARB,(GLint a,GLint b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glUniform4fv,(GLint a,GLsizei b,const GLfloat *c),(a,b,c)) +GL_FUNC(OpenGL,true,GLboolean,glUnmapBuffer,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glUseProgram,(GLuint a),(a)) +GL_FUNC_VOID(OpenGL,true,glVertex3f,(GLfloat a,GLfloat b,GLfloat c),(a,b,c)) +GL_FUNC_VOID(OpenGL,true,glVertexAttribPointer,(GLuint a,GLint b,GLenum c,GLboolean d,GLsizei e,const GLvoid *f),(a,b,c,d,e,f)) +GL_FUNC_VOID(OpenGL,true,glViewport,(GLint a,GLint b,GLsizei c,GLsizei d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glEnableClientState,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glDisableClientState,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glClientActiveTexture,(GLenum a),(a)) +GL_FUNC_VOID(OpenGL,true,glVertexPointer,(GLint a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glTexCoordPointer,(GLint a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glProgramEnvParameters4fvEXT,(GLenum a,GLuint b,GLsizei c,const GLfloat *d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glColor4sv,(const GLshort *a),(a)) +GL_FUNC_VOID(OpenGL,true,glStencilOpSeparate,(GLenum a,GLenum b,GLenum c,GLenum d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glStencilFuncSeparate,(GLenum a,GLenum b,GLint c,GLuint d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glGetTexLevelParameteriv,(GLenum a,GLint b,GLenum c,GLint *d),(a,b,c,d)) +GL_FUNC_VOID(OpenGL,true,glColor4f,(GLfloat a,GLfloat b,GLfloat c,GLfloat d),(a,b,c,d)) +GL_EXT(GL_EXT_framebuffer_object,-1,-1) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glBindFramebufferEXT,(GLenum a,GLuint b),(a,b)) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glBindRenderbufferEXT,(GLenum a,GLuint b),(a,b)) +GL_FUNC(GL_EXT_framebuffer_object,false,GLenum,glCheckFramebufferStatusEXT,(GLenum a),(a)) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glDeleteRenderbuffersEXT,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glFramebufferRenderbufferEXT,(GLenum a,GLenum b,GLenum c,GLuint d),(a,b,c,d)) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glFramebufferTexture2DEXT,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e),(a,b,c,d,e)) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glFramebufferTexture3DEXT,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e,GLint f),(a,b,c,d,e,f)) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glGenFramebuffersEXT,(GLsizei a,GLuint *b),(a,b)) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glGenRenderbuffersEXT,(GLsizei a,GLuint *b),(a,b)) +GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glDeleteFramebuffersEXT,(GLsizei a,const GLuint *b),(a,b)) +GL_EXT(GL_EXT_framebuffer_blit,-1,-1) +GL_FUNC_VOID(GL_EXT_framebuffer_blit,false,glBlitFramebufferEXT,(GLint a,GLint b,GLint c,GLint d,GLint e,GLint f,GLint g,GLint h,GLbitfield i,GLenum j),(a,b,c,d,e,f,g,h,i,j)) +GL_EXT(GL_EXT_framebuffer_multisample,-1,-1) +GL_FUNC_VOID(GL_EXT_framebuffer_multisample,false,glRenderbufferStorageMultisampleEXT,(GLenum a,GLsizei b,GLenum c,GLsizei d,GLsizei e),(a,b,c,d,e)) +GL_EXT(GL_APPLE_fence,-1,-1) +GL_FUNC(GL_APPLE_fence,false,GLboolean,glTestFenceAPPLE,(GLuint a),(a)) +GL_FUNC_VOID(GL_APPLE_fence,false,glSetFenceAPPLE,(GLuint a),(a)) +GL_FUNC_VOID(GL_APPLE_fence,false,glFinishFenceAPPLE,(GLuint a),(a)) +GL_FUNC_VOID(GL_APPLE_fence,false,glDeleteFencesAPPLE,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(GL_APPLE_fence,false,glGenFencesAPPLE,(GLsizei a,GLuint *b),(a,b)) +GL_EXT(GL_NV_fence,-1,-1) +GL_FUNC(GL_NV_fence,false,GLboolean,glTestFenceNV,(GLuint a),(a)) +GL_FUNC_VOID(GL_NV_fence,false,glSetFenceNV,(GLuint a,GLenum b),(a,b)) +GL_FUNC_VOID(GL_NV_fence,false,glFinishFenceNV,(GLuint a),(a)) +GL_FUNC_VOID(GL_NV_fence,false,glDeleteFencesNV,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(GL_NV_fence,false,glGenFencesNV,(GLsizei a,GLuint *b),(a,b)) +GL_EXT(GL_ARB_sync,3,2) +#ifdef HAVE_GL_ARB_SYNC +GL_FUNC_VOID(GL_ARB_sync,false,glGetSynciv,(GLsync a, GLenum b, GLsizei c, GLsizei *d, GLint *e),(a,b,c,d,e)) +GL_FUNC(GL_ARB_sync,false,GLenum,glClientWaitSync,(GLsync a, GLbitfield b, GLuint64 c),(a,b,c)) +GL_FUNC_VOID(GL_ARB_sync,false,glWaitSync,(GLsync a, GLbitfield b, GLuint64 c),(a,b,c)) +GL_FUNC_VOID(GL_ARB_sync,false,glDeleteSync,(GLsync a),(a)) +GL_FUNC(GL_ARB_sync,false,GLsync,glFenceSync,(GLenum a, GLbitfield b),(a,b)) +#endif +GL_EXT(GL_EXT_draw_buffers2,-1,-1) +GL_FUNC_VOID(GL_EXT_draw_buffers2,false,glColorMaskIndexedEXT,(GLuint a,GLboolean b,GLboolean c,GLboolean d,GLboolean e),(a,b,c,d,e)) +GL_FUNC_VOID(GL_EXT_draw_buffers2,false,glEnableIndexedEXT,(GLenum a,GLuint b),(a,b)) +GL_FUNC_VOID(GL_EXT_draw_buffers2,false,glDisableIndexedEXT,(GLenum a,GLuint b),(a,b)) +GL_FUNC_VOID(GL_EXT_draw_buffers2,false,glGetBooleanIndexedvEXT,(GLenum a,GLuint b,GLboolean *c),(a,b,c)) +GL_EXT(GL_EXT_bindable_uniform,-1,-1) +GL_FUNC_VOID(GL_EXT_bindable_uniform,false,glUniformBufferEXT,(GLuint a,GLint b,GLuint c),(a,b,c)) +GL_EXT(GL_APPLE_flush_buffer_range,-1,-1) +GL_FUNC_VOID(GL_APPLE_flush_buffer_range,false,glBufferParameteriAPPLE,(GLenum a,GLenum b,GLint c),(a,b,c)) +GL_FUNC_VOID(GL_APPLE_flush_buffer_range,false,glFlushMappedBufferRangeAPPLE,(GLenum a,GLintptr b,GLsizeiptr c),(a,b,c)) +GL_EXT(GL_ARB_map_buffer_range,-1,-1) +GL_FUNC(GL_ARB_map_buffer_range,false,void*,glMapBufferRange,(GLenum a,GLintptr b,GLsizeiptr c,GLbitfield d),(a,b,c,d)) +GL_FUNC_VOID(GL_ARB_map_buffer_range,false,glFlushMappedBufferRange,(GLenum a,GLintptr b,GLsizeiptr c),(a,b,c)) +GL_EXT(GL_ARB_occlusion_query,-1,-1) +GL_FUNC_VOID(GL_ARB_occlusion_query,false,glBeginQueryARB,(GLenum a,GLuint b),(a,b)) +GL_FUNC_VOID(GL_ARB_occlusion_query,false,glEndQueryARB,(GLenum a),(a)) +GL_FUNC_VOID(GL_ARB_occlusion_query,false,glGetQueryObjectivARB,(GLuint a,GLenum b,GLint *c),(a,b,c)) +GL_FUNC_VOID(GL_ARB_occlusion_query,false,glGetQueryObjectuivARB,(GLuint a,GLenum b,GLuint *c),(a,b,c)) +GL_EXT(GL_APPLE_texture_range,-1,-1) +GL_FUNC_VOID(GL_APPLE_texture_range,false,glTextureRangeAPPLE,(GLenum a,GLsizei b,void *c),(a,b,c)) +GL_FUNC_VOID(GL_APPLE_texture_range,false,glGetTexParameterPointervAPPLE,(GLenum a,GLenum b,void* *c),(a,b,c)) +GL_EXT(GL_APPLE_client_storage,-1,-1) +GL_EXT(GL_ARB_uniform_buffer,-1,-1) +GL_EXT(GL_ARB_vertex_array_bgra,-1,-1) +GL_EXT(GL_EXT_vertex_array_bgra,-1,-1) +GL_EXT(GL_ARB_framebuffer_object,3,0) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glBindFramebuffer,(GLenum a,GLuint b),(a,b)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glBindRenderbuffer,(GLenum a,GLuint b),(a,b)) +GL_FUNC(GL_ARB_framebuffer_object,false,GLenum,glCheckFramebufferStatus,(GLenum a),(a)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glDeleteRenderbuffers,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glFramebufferRenderbuffer,(GLenum a,GLenum b,GLenum c,GLuint d),(a,b,c,d)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glFramebufferTexture2D,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e),(a,b,c,d,e)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glFramebufferTexture3D,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e,GLint f),(a,b,c,d,e,f)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glGenFramebuffers,(GLsizei a,GLuint *b),(a,b)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glGenRenderbuffers,(GLsizei a,GLuint *b),(a,b)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glDeleteFramebuffers,(GLsizei a,const GLuint *b),(a,b)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glBlitFramebuffer,(GLint a,GLint b,GLint c,GLint d,GLint e,GLint f,GLint g,GLint h,GLbitfield i,GLenum j),(a,b,c,d,e,f,g,h,i,j)) +GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glRenderbufferStorageMultisample,(GLenum a,GLsizei b,GLenum c,GLsizei d,GLsizei e),(a,b,c,d,e)) +GL_EXT(GL_GREMEDY_string_marker,-1,-1) +GL_FUNC_VOID(GL_GREMEDY_string_marker,false,glStringMarkerGREMEDY,(GLsizei a,const void *b),(a,b)) +GL_FUNC_VOID(OpenGL,true,glPushClientAttrib,(GLbitfield a),(a)) +GL_FUNC_VOID(OpenGL,true,glPopClientAttrib,(void),()) + diff --git a/sp/src/public/togl/osx/glmdisplay.h b/sp/src/public/togl/osx/glmdisplay.h index cf3a3b90..c0d9e10b 100644 --- a/sp/src/public/togl/osx/glmdisplay.h +++ b/sp/src/public/togl/osx/glmdisplay.h @@ -1,177 +1,177 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// -// glmdisplay.h -// display related stuff - used by both GLMgr and the CocoaMgr -// -//=============================================================================== - -#ifndef GLMDISPLAY_H -#define GLMDISPLAY_H - -#pragma once - -#ifdef OSX -#include -#include -#include -#include -#include -#include - -typedef uint32_t CGDirectDisplayID; -typedef uint32_t CGOpenGLDisplayMask; -typedef double CGRefreshRate; - -//#include -#elif defined(LINUX) -#include "tier0/platform.h" -#include -#include -#else -#error -#endif - -typedef void _PseudoNSGLContext; // aka NSOpenGLContext -typedef _PseudoNSGLContext *PseudoNSGLContextPtr; - -struct GLMDisplayModeInfoFields -{ - uint m_modePixelWidth; - uint m_modePixelHeight; - uint m_modeRefreshHz; - // are we even going to talk about bit depth... not yet -}; - -struct GLMDisplayInfoFields -{ -#ifdef OSX - CGDirectDisplayID m_cgDisplayID; - CGOpenGLDisplayMask m_glDisplayMask; // result of CGDisplayIDToOpenGLDisplayMask on the cg_displayID. -#endif - uint m_displayPixelWidth; - uint m_displayPixelHeight; -}; - -struct GLMRendererInfoFields -{ - /*properties of interest and their desired values. - - kCGLRPFullScreen = 54, true - kCGLRPAccelerated = 73, true - kCGLRPWindow = 80, true - - kCGLRPRendererID = 70, informational - kCGLRPDisplayMask = 84, informational - kCGLRPBufferModes = 100, informational - kCGLRPColorModes = 103, informational - kCGLRPAccumModes = 104, informational - kCGLRPDepthModes = 105, informational - kCGLRPStencilModes = 106, informational - kCGLRPMaxAuxBuffers = 107, informational - kCGLRPMaxSampleBuffers = 108, informational - kCGLRPMaxSamples = 109, informational - kCGLRPSampleModes = 110, informational - kCGLRPSampleAlpha = 111, informational - kCGLRPVideoMemory = 120, informational - kCGLRPTextureMemory = 121, informational - kCGLRPRendererCount = 128 number of renderers in the CGLRendererInfoObj under examination - - kCGLRPOffScreen = 53, D/C - kCGLRPRobust = 75, FALSE or D/C - aka we're asking for no-fallback - kCGLRPBackingStore = 76, D/C - kCGLRPMPSafe = 78, D/C - kCGLRPMultiScreen = 81, D/C - kCGLRPCompliant = 83, D/C - */ - - - //--------------------------- info we have from CGL renderer queries, IOKit, Gestalt - //--------------------------- these are set up in the displayDB by CocoaMgr - GLint m_fullscreen; - GLint m_accelerated; - GLint m_windowed; - - GLint m_rendererID; - GLint m_displayMask; - GLint m_bufferModes; - GLint m_colorModes; - GLint m_accumModes; - GLint m_depthModes; - GLint m_stencilModes; - - GLint m_maxAuxBuffers; - GLint m_maxSampleBuffers; - GLint m_maxSamples; - GLint m_sampleModes; - GLint m_sampleAlpha; - - GLint m_vidMemory; - GLint m_texMemory; - - uint m_pciVendorID; - uint m_pciDeviceID; - char m_pciModelString[64]; - char m_driverInfoString[64]; - - //--------------------------- OS version related - set up by CocoaMgr - - // OS version found - uint m_osComboVersion; // 0x00XXYYZZ : XX major, YY minor, ZZ minor minor : 10.6.3 --> 0x000A0603. 10.5.8 --> 0x000A0508. - - //--------------------------- shorthands - also set up by CocoaMgr - driven by vendorid / deviceid - - bool m_ati; - bool m_atiR5xx; - bool m_atiR6xx; - bool m_atiR7xx; - bool m_atiR8xx; - bool m_atiNewer; - - bool m_intel; - bool m_intel95x; - bool m_intel3100; - bool m_intelNewer; - - bool m_nv; - bool m_nvG7x; - bool m_nvG8x; - bool m_nvNewer; - - //--------------------------- context query results - left blank in the display DB - but valid in a GLMContext (call ctx->Caps() to get a const ref) - - // booleans - bool m_hasGammaWrites; // aka glGetBooleanv(GL_FRAMEBUFFER_SRGB_CAPABLE_EXT) / glEnable(GL_FRAMEBUFFER_SRGB_EXT) - bool m_hasMixedAttachmentSizes; // aka ARB_fbo in 10.6.3 - test for min OS vers, then exported ext string - bool m_hasBGRA; // aka GL_BGRA vertex attribs in 10.6.3 - - test for min OS vers, then exported ext string - bool m_hasNewFullscreenMode; // aka 10.6.x "big window" fullscreen mode - bool m_hasNativeClipVertexMode; // aka GLSL gl_ClipVertex does not fall back to SW- OS version and folklore-based - bool m_hasOcclusionQuery; // occlusion query: do you speak it ?! - bool m_hasFramebufferBlit; // framebuffer blit: know what I'm sayin?! - bool m_hasPerfPackage1; // means new MTGL, fast OQ, fast uniform upload, NV can resolve flipped (late summer 2010 post 10.6.4 update) - - // counts - int m_maxAniso; // aniso limit - context query - - // other exts - bool m_hasBindableUniforms; - bool m_hasUniformBuffers; - - // runtime options that aren't negotiable once set - bool m_hasDualShaders; // must supply CLI arg "-glmdualshaders" or we go GLSL only - - //--------------------------- " can'ts " - specific problems that need to be worked around - - bool m_cantBlitReliably; // Intel chipsets have problems blitting sRGB sometimes - bool m_cantAttachSRGB; // NV G8x on 10.5.8 can't have srgb tex on FBO color - separate issue from hasGammaWrites - bool m_cantResolveFlipped; // happens on NV in 10.6.4 and prior - console variable "gl_can_resolve_flipped" can overrule - bool m_cantResolveScaled; // happens everywhere per GL spec but may be relaxed some day - console variable "gl_can_resolve_scaled" can overrule - bool m_costlyGammaFlips; // this means that sRGB sampling state affects shader code gen, resulting in state-dependent code regen - - - //--------------------------- " bads " - known bad drivers - bool m_badDriver1064NV; // this is the bad NVIDIA driver on 10.6.4 - stutter, tex corruption, black screen issues -}; - - - -#endif +// +// glmdisplay.h +// display related stuff - used by both GLMgr and the CocoaMgr +// +//=============================================================================== + +#ifndef GLMDISPLAY_H +#define GLMDISPLAY_H + +#pragma once + +#ifdef OSX +#include +#include +#include +#include +#include +#include + +typedef uint32_t CGDirectDisplayID; +typedef uint32_t CGOpenGLDisplayMask; +typedef double CGRefreshRate; + +//#include +#elif defined(LINUX) +#include "tier0/platform.h" +#include +#include +#else +#error +#endif + +typedef void _PseudoNSGLContext; // aka NSOpenGLContext +typedef _PseudoNSGLContext *PseudoNSGLContextPtr; + +struct GLMDisplayModeInfoFields +{ + uint m_modePixelWidth; + uint m_modePixelHeight; + uint m_modeRefreshHz; + // are we even going to talk about bit depth... not yet +}; + +struct GLMDisplayInfoFields +{ +#ifdef OSX + CGDirectDisplayID m_cgDisplayID; + CGOpenGLDisplayMask m_glDisplayMask; // result of CGDisplayIDToOpenGLDisplayMask on the cg_displayID. +#endif + uint m_displayPixelWidth; + uint m_displayPixelHeight; +}; + +struct GLMRendererInfoFields +{ + /*properties of interest and their desired values. + + kCGLRPFullScreen = 54, true + kCGLRPAccelerated = 73, true + kCGLRPWindow = 80, true + + kCGLRPRendererID = 70, informational + kCGLRPDisplayMask = 84, informational + kCGLRPBufferModes = 100, informational + kCGLRPColorModes = 103, informational + kCGLRPAccumModes = 104, informational + kCGLRPDepthModes = 105, informational + kCGLRPStencilModes = 106, informational + kCGLRPMaxAuxBuffers = 107, informational + kCGLRPMaxSampleBuffers = 108, informational + kCGLRPMaxSamples = 109, informational + kCGLRPSampleModes = 110, informational + kCGLRPSampleAlpha = 111, informational + kCGLRPVideoMemory = 120, informational + kCGLRPTextureMemory = 121, informational + kCGLRPRendererCount = 128 number of renderers in the CGLRendererInfoObj under examination + + kCGLRPOffScreen = 53, D/C + kCGLRPRobust = 75, FALSE or D/C - aka we're asking for no-fallback + kCGLRPBackingStore = 76, D/C + kCGLRPMPSafe = 78, D/C + kCGLRPMultiScreen = 81, D/C + kCGLRPCompliant = 83, D/C + */ + + + //--------------------------- info we have from CGL renderer queries, IOKit, Gestalt + //--------------------------- these are set up in the displayDB by CocoaMgr + GLint m_fullscreen; + GLint m_accelerated; + GLint m_windowed; + + GLint m_rendererID; + GLint m_displayMask; + GLint m_bufferModes; + GLint m_colorModes; + GLint m_accumModes; + GLint m_depthModes; + GLint m_stencilModes; + + GLint m_maxAuxBuffers; + GLint m_maxSampleBuffers; + GLint m_maxSamples; + GLint m_sampleModes; + GLint m_sampleAlpha; + + GLint m_vidMemory; + GLint m_texMemory; + + uint m_pciVendorID; + uint m_pciDeviceID; + char m_pciModelString[64]; + char m_driverInfoString[64]; + + //--------------------------- OS version related - set up by CocoaMgr + + // OS version found + uint m_osComboVersion; // 0x00XXYYZZ : XX major, YY minor, ZZ minor minor : 10.6.3 --> 0x000A0603. 10.5.8 --> 0x000A0508. + + //--------------------------- shorthands - also set up by CocoaMgr - driven by vendorid / deviceid + + bool m_ati; + bool m_atiR5xx; + bool m_atiR6xx; + bool m_atiR7xx; + bool m_atiR8xx; + bool m_atiNewer; + + bool m_intel; + bool m_intel95x; + bool m_intel3100; + bool m_intelNewer; + + bool m_nv; + bool m_nvG7x; + bool m_nvG8x; + bool m_nvNewer; + + //--------------------------- context query results - left blank in the display DB - but valid in a GLMContext (call ctx->Caps() to get a const ref) + + // booleans + bool m_hasGammaWrites; // aka glGetBooleanv(GL_FRAMEBUFFER_SRGB_CAPABLE_EXT) / glEnable(GL_FRAMEBUFFER_SRGB_EXT) + bool m_hasMixedAttachmentSizes; // aka ARB_fbo in 10.6.3 - test for min OS vers, then exported ext string + bool m_hasBGRA; // aka GL_BGRA vertex attribs in 10.6.3 - - test for min OS vers, then exported ext string + bool m_hasNewFullscreenMode; // aka 10.6.x "big window" fullscreen mode + bool m_hasNativeClipVertexMode; // aka GLSL gl_ClipVertex does not fall back to SW- OS version and folklore-based + bool m_hasOcclusionQuery; // occlusion query: do you speak it ?! + bool m_hasFramebufferBlit; // framebuffer blit: know what I'm sayin?! + bool m_hasPerfPackage1; // means new MTGL, fast OQ, fast uniform upload, NV can resolve flipped (late summer 2010 post 10.6.4 update) + + // counts + int m_maxAniso; // aniso limit - context query + + // other exts + bool m_hasBindableUniforms; + bool m_hasUniformBuffers; + + // runtime options that aren't negotiable once set + bool m_hasDualShaders; // must supply CLI arg "-glmdualshaders" or we go GLSL only + + //--------------------------- " can'ts " - specific problems that need to be worked around + + bool m_cantBlitReliably; // Intel chipsets have problems blitting sRGB sometimes + bool m_cantAttachSRGB; // NV G8x on 10.5.8 can't have srgb tex on FBO color - separate issue from hasGammaWrites + bool m_cantResolveFlipped; // happens on NV in 10.6.4 and prior - console variable "gl_can_resolve_flipped" can overrule + bool m_cantResolveScaled; // happens everywhere per GL spec but may be relaxed some day - console variable "gl_can_resolve_scaled" can overrule + bool m_costlyGammaFlips; // this means that sRGB sampling state affects shader code gen, resulting in state-dependent code regen + + + //--------------------------- " bads " - known bad drivers + bool m_badDriver1064NV; // this is the bad NVIDIA driver on 10.6.4 - stutter, tex corruption, black screen issues +}; + + + +#endif diff --git a/sp/src/public/togl/osx/glmgr.h b/sp/src/public/togl/osx/glmgr.h index cdf64206..24f9a00d 100644 --- a/sp/src/public/togl/osx/glmgr.h +++ b/sp/src/public/togl/osx/glmgr.h @@ -1,1088 +1,1088 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// -// glmgr.h -// singleton class, common basis for managing GL contexts -// responsible for tracking adapters and contexts -// -//=============================================================================== - -#ifndef GLMGR_H -#define GLMGR_H - -#pragma once - -#undef HAVE_GL_ARB_SYNC -#ifdef LINUX -#define HAVE_GL_ARB_SYNC 1 -#endif - -#include "glentrypoints.h" -#include "glmdebug.h" -#include "glmdisplay.h" -#include "glmgrext.h" -#include "glmgrbasics.h" -#include "cglmtex.h" -#include "cglmfbo.h" -#include "cglmprogram.h" -#include "cglmbuffer.h" -#include "cglmquery.h" - -#include "tier0/vprof_telemetry.h" -#include "materialsystem/ishader.h" -#include "dxabstract_types.h" - - -#ifdef LINUX -#define Debugger DebuggerBreak -#undef CurrentTime - -// prevent some conflicts in SDL headers... -#undef M_PI -#include -#ifndef _STDINT_H_ -#define _STDINT_H_ 1 -#endif - -#include "SDL/SDL.h" -#endif - -//=============================================================================== -// glue to call out to Obj-C land (these are in glmgrcocoa.mm) -#ifdef OSX -PseudoNSGLContextPtr GetCurrentNSGLContext( ); -CGLContextObj GetCGLContextFromNSGL( PseudoNSGLContextPtr nsglCtx ); -#endif - -#include "tier0/dynfunction.h" - -//=============================================================================== - -// parrot the D3D present parameters, more or less... "adapter" translates into "active display index" per the m_activeDisplayCount below. -class GLMDisplayParams -{ - public: - - // presumption, these indices are in sync with the current display DB that GLMgr has handy - //int m_rendererIndex; // index of renderer (-1 if root context) - //int m_displayIndex; // index of display in renderer - for FS - //int m_modeIndex; // index of mode in display - for FS - - void *m_focusWindow; // (VD3DHWND aka WindowRef) - what window does this context display into - - bool m_fsEnable; // fullscreen on or not - bool m_vsyncEnable; // vsync on or not - - // height and width have to match the display mode info if full screen. - - uint m_backBufferWidth; // pixel width (aka screen h-resolution if full screen) - uint m_backBufferHeight; // pixel height (aka screen v-resolution if full screen) - D3DFORMAT m_backBufferFormat; // pixel format - uint m_multiSampleCount; // 0 means no MSAA, 2 means 2x MSAA, etc - // uint m_multiSampleQuality; // no MSAA quality control yet - - bool m_enableAutoDepthStencil; // generally set to 'TRUE' per CShaderDeviceDx8::SetPresentParameters - D3DFORMAT m_autoDepthStencilFormat; - - uint m_fsRefreshHz; // if full screen, this refresh rate (likely 0 for LCD's) - - //uint m_rootRendererID; // only used if m_rendererIndex is -1. - //uint m_rootDisplayMask; // only used if m_rendererIndex is -1. - - bool m_mtgl; // enable multi threaded GL driver -}; - -//=============================================================================== - -class GLMgr -{ -public: - - //=========================================================================== - // class methods - singleton - static void NewGLMgr( void ); // instantiate singleton.. - static GLMgr *aGLMgr( void ); // return singleton.. - static void DelGLMgr( void ); // tear down singleton.. - - //=========================================================================== - // plain methods - - #if 0 // turned all these off while new approach is coded - void RefreshDisplayDB( void ); // blow away old display DB, make a new one - GLMDisplayDB *GetDisplayDB( void ); // get a ptr to the one GLMgr keeps. only valid til next refresh. - - // eligible renderers will be ranked by desirability starting at index 0 within the db - // within each renderer, eligible displays will be ranked some kind of desirability (area? dist from menu bar?) - // within each display, eligible modes will be ranked by descending areas - - // calls supplying indices are implicitly making reference to the current DB - bool CaptureDisplay( int rendIndex, int displayIndex, bool captureAll ); // capture one display or all displays - void ReleaseDisplays( void ); // release all captures - - int GetDisplayMode( int rendIndex, int displayIndex ); // retrieve current display res (returns modeIndex) - void SetDisplayMode( GLMDisplayParams *params ); // set the display res (only useful for FS) - #endif - - GLMContext *NewContext( GLMDisplayParams *params ); // this will have to change - void DelContext( GLMContext *context ); - - // with usage of CGLMacro.h we could dispense with the "current context" thing - // and just declare a member variable of GLMContext, allowing each glXXX call to be routed directly - // to the correct context - void SetCurrentContext( GLMContext *context ); // make current in calling thread only - GLMContext *GetCurrentContext( void ); - -protected: - friend class GLMContext; - - GLMgr(); - ~GLMgr(); -}; - - -//===========================================================================// - -// helper function to do enable or disable in one step -inline void glSetEnable( GLenum which, bool enable ) -{ - if (enable) - gGL->glEnable(which); - else - gGL->glDisable(which); -} - -// helper function for int vs enum clarity -inline void glGetEnumv( GLenum which, GLenum *dst ) -{ - gGL->glGetIntegerv( which, (int*)dst ); -} - -//===========================================================================// -// -// types to support the GLMContext -// -//===========================================================================// - -// Each state set/get path we are providing caching for, needs its own struct and a comparison operator. -// we also provide an enum of how many such types there are, handy for building dirty masks etc. - -// shorthand macros -#define EQ(fff) ( (src.fff) == (fff) ) - -//rasterizer -struct GLAlphaTestEnable_t { GLint enable; bool operator==(const GLAlphaTestEnable_t& src) const { return EQ(enable); } }; -struct GLAlphaTestFunc_t { GLenum func; GLclampf ref; bool operator==(const GLAlphaTestFunc_t& src) const { return EQ(func) && EQ(ref); } }; -struct GLCullFaceEnable_t { GLint enable; bool operator==(const GLCullFaceEnable_t& src) const { return EQ(enable); } }; -struct GLCullFrontFace_t { GLenum value; bool operator==(const GLCullFrontFace_t& src) const { return EQ(value); } }; -struct GLPolygonMode_t { GLenum values[2]; bool operator==(const GLPolygonMode_t& src) const { return EQ(values[0]) && EQ(values[1]); } }; -struct GLDepthBias_t { GLfloat factor; GLfloat units; bool operator==(const GLDepthBias_t& src) const { return EQ(factor) && EQ(units); } }; -struct GLScissorEnable_t { GLint enable; bool operator==(const GLScissorEnable_t& src) const { return EQ(enable); } }; -struct GLScissorBox_t { GLint x,y; GLsizei width, height; bool operator==(const GLScissorBox_t& src) const { return EQ(x) && EQ(y) && EQ(width) && EQ(height); } }; -struct GLAlphaToCoverageEnable_t{ GLint enable; bool operator==(const GLAlphaToCoverageEnable_t& src) const { return EQ(enable); } }; -struct GLViewportBox_t { GLint x,y; GLsizei width, height; bool operator==(const GLViewportBox_t& src) const { return EQ(x) && EQ(y) && EQ(width) && EQ(height); } }; -struct GLViewportDepthRange_t { GLdouble near,far; bool operator==(const GLViewportDepthRange_t& src) const { return EQ(near) && EQ(far); } }; -struct GLClipPlaneEnable_t { GLint enable; bool operator==(const GLClipPlaneEnable_t& src) const { return EQ(enable); } }; -struct GLClipPlaneEquation_t { GLfloat x,y,z,w; bool operator==(const GLClipPlaneEquation_t& src) const { return EQ(x) && EQ(y) && EQ(z) && EQ(w); } }; - -//blend -struct GLColorMaskSingle_t { char r,g,b,a; bool operator==(const GLColorMaskSingle_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; -struct GLColorMaskMultiple_t { char r,g,b,a; bool operator==(const GLColorMaskMultiple_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; -struct GLBlendEnable_t { GLint enable; bool operator==(const GLBlendEnable_t& src) const { return EQ(enable); } }; -struct GLBlendFactor_t { GLenum srcfactor,dstfactor; bool operator==(const GLBlendFactor_t& src) const { return EQ(srcfactor) && EQ(dstfactor); } }; -struct GLBlendEquation_t { GLenum equation; bool operator==(const GLBlendEquation_t& src) const { return EQ(equation); } }; -struct GLBlendColor_t { GLfloat r,g,b,a; bool operator==(const GLBlendColor_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; -struct GLBlendEnableSRGB_t { GLint enable; bool operator==(const GLBlendEnableSRGB_t& src) const { return EQ(enable); } }; - -//depth -struct GLDepthTestEnable_t { GLint enable; bool operator==(const GLDepthTestEnable_t& src) const { return EQ(enable); } }; -struct GLDepthFunc_t { GLenum func; bool operator==(const GLDepthFunc_t& src) const { return EQ(func); } }; -struct GLDepthMask_t { char mask; bool operator==(const GLDepthMask_t& src) const { return EQ(mask); } }; - -//stencil -struct GLStencilTestEnable_t { GLint enable; bool operator==(const GLStencilTestEnable_t& src) const { return EQ(enable); } }; -struct GLStencilFunc_t { GLenum frontfunc, backfunc; GLint ref; GLuint mask; bool operator==(const GLStencilFunc_t& src) const { return EQ(frontfunc) && EQ(backfunc) && EQ(ref) && EQ(mask); } }; -struct GLStencilOp_t { GLenum sfail; GLenum dpfail; GLenum dppass; bool operator==(const GLStencilOp_t& src) const { return EQ(sfail) && EQ(dpfail) && EQ(dppass); } }; -struct GLStencilWriteMask_t { GLint mask; bool operator==(const GLStencilWriteMask_t& src) const { return EQ(mask); } }; - -//clearing -struct GLClearColor_t { GLfloat r,g,b,a; bool operator==(const GLClearColor_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; -struct GLClearDepth_t { GLdouble d; bool operator==(const GLClearDepth_t& src) const { return EQ(d); } }; -struct GLClearStencil_t { GLint s; bool operator==(const GLClearStencil_t& src) const { return EQ(s); } }; - -#undef EQ - -enum EGLMStateBlockType -{ - kGLAlphaTestEnable, - kGLAlphaTestFunc, - - kGLCullFaceEnable, - kGLCullFrontFace, - - kGLPolygonMode, - - kGLDepthBias, - - kGLScissorEnable, - kGLScissorBox, - - kGLViewportBox, - kGLViewportDepthRange, - - kGLClipPlaneEnable, - kGLClipPlaneEquation, - - kGLColorMaskSingle, - kGLColorMaskMultiple, - - kGLBlendEnable, - kGLBlendFactor, - kGLBlendEquation, - kGLBlendColor, - kGLBlendEnableSRGB, - - kGLDepthTestEnable, - kGLDepthFunc, - kGLDepthMask, - - kGLStencilTestEnable, - kGLStencilFunc, - kGLStencilOp, - kGLStencilWriteMask, - - kGLClearColor, - kGLClearDepth, - kGLClearStencil, - - kGLAlphaToCoverageEnable, - - kGLMStateBlockLimit -}; - -//===========================================================================// - -// templated functions representing GL R/W bottlenecks -// one set of set/get/getdefault is instantiated for each of the GL*** types above. - -// use these from the non array state objects -template void GLContextSet( T *src ); -template void GLContextGet( T *dst ); -template void GLContextGetDefault( T *dst ); - -// use these from the array state objects -template void GLContextSetIndexed( T *src, int index ); -template void GLContextGetIndexed( T *dst, int index ); -template void GLContextGetDefaultIndexed( T *dst, int index ); - -//===========================================================================// - -// caching state object template. One of these is instantiated in the context per unique struct type above -template class GLState -{ - public: - - GLState() - { - dirty = false; - memset( &data, 0, sizeof(data) ); - }; - - // write: client src into cache - // common case is both false. dirty is calculated, context write is deferred. - void Write( T *src, bool noCompare=false, bool noDefer=false ) - { - if (noCompare) - { - dirty = true; - } - else - { - // only == is implemented, so test for equal and negate - // note, you only set dirty if mismatch, you never clear it until flush - if ( !(data == *src) ) - { - dirty = true; - } - } - - data = *src; - - if (noDefer) - { - Flush( true ); // dirty becomes false - } - }; - - // write cache->context if dirty or forced. - void Flush( bool noDefer=false ) - { - if (dirty || noDefer) - { - GLContextSet( &data ); - GLMCheckError(); - // good place for some error checking here - dirty = false; - } - }; - - // default: write default value to cache, optionally write through - void Default( bool noDefer=false ) - { - GLContextGetDefault( &data ); // read default values directly to our cache copy - dirty = true; - Flush(noDefer); - }; - - // read: sel = 0 for cache, 1 for context - void Read( T *dst, int sel ) - { - if (sel==0) - { - *dst = data; - } - else - { - GLContextGet( dst ); - GLMCheckError(); - } - }; - - // check: verify that context equals cache, return true if mismatched or if illegal values seen - bool Check ( void ) - { - T temp; - bool result; - - GLContextGet( &temp ); - GLMCheckError(); - result = !(temp == data); - return result; - }; - - protected: - T data; - bool dirty; -}; - -// caching state object template - with multiple values behind it that are indexed -template class GLStateArray -{ - public: - - GLStateArray() - { - memset( &dirty, 0, sizeof(dirty) ); - memset( &data, 0, sizeof(data) ); - }; - - // write: client src into cache - // common case is both false. dirty is calculated, context write is deferred. - void WriteIndex( T *src, int index, bool noCompare=false, bool noDefer=false ) - { - if (noCompare) - { - dirty[index] = true; - } - else - { - // only == is implemented, so test for equal and negate - // note, you only set dirty if mismatch, you never clear it until flush - if (! (data[index] == *src) ) - { - dirty[index] = true; - } - } - - data[index] = *src; - - if (noDefer) - { - FlushIndex( index, true ); // dirty becomes false - } - }; - - // write cache->context if dirty or forced. - void FlushIndex( int index, bool noDefer=false ) - { - if (dirty[index] || noDefer) - { - GLContextSetIndexed( &data[index], index ); - GLMCheckError(); - dirty[index] = false; - } - }; - - // write all slots in the array - void Flush( bool noDefer=false ) - { - for( int i=0; i m_AlphaTestEnable; - - GLState m_AlphaTestFunc; - - GLState m_CullFaceEnable; - GLState m_CullFrontFace; - GLState m_PolygonMode; - - GLState m_DepthBias; - - GLStateArray m_ClipPlaneEnable; - GLStateArray m_ClipPlaneEquation; // dxabstract puts them directly into param slot 253(0) and 254(1) - - GLState m_ScissorEnable; - GLState m_ScissorBox; - - GLState m_AlphaToCoverageEnable; - - GLState m_ViewportBox; - GLState m_ViewportDepthRange; - - GLState m_ColorMaskSingle; - GLStateArray m_ColorMaskMultiple; // need an official constant for the color buffers limit - - GLState m_BlendEnable; - GLState m_BlendFactor; - GLState m_BlendEquation; - GLState m_BlendColor; - GLState m_BlendEnableSRGB; // write to this one to transmit intent to write SRGB encoded pixels to drawing FB - bool m_FakeBlendEnableSRGB; // writes to above will be shunted here if fake SRGB is in effect. - - GLState m_DepthTestEnable; - GLState m_DepthFunc; - GLState m_DepthMask; - - GLState m_StencilTestEnable; // global stencil test enable - GLState m_StencilFunc; // holds front and back stencil funcs - GLStateArray m_StencilOp; // indexed: 0=front 1=back - GLState m_StencilWriteMask; - - GLState m_ClearColor; - GLState m_ClearDepth; - GLState m_ClearStencil; - - // texture bindings and sampler setup - int m_activeTexture; // mirror for glActiveTexture - GLMTexSampler m_samplers[GLM_SAMPLER_COUNT]; - - // texture lock tracking - CGLMTex objects share usage of this - CUtlVector< GLMTexLockDesc > m_texLocks; - - // render target binding - check before draw - // similar to tex sampler mechanism, we track "bound" from "chosen for drawing" separately, - // so binding for creation/setup need not disrupt any notion of what will be used at draw time - - CGLMFBO *m_boundDrawFBO; // FBO on GL_DRAW_FRAMEBUFFER bind point - CGLMFBO *m_boundReadFBO; // FBO on GL_READ_FRAMEBUFFER bind point - // ^ both are set if you bind to GL_FRAMEBUFFER_EXT - - CGLMFBO *m_drawingFBO; // what FBO should be bound at draw time (to both read/draw bp's). - - CGLMFBO *m_blitReadFBO; - CGLMFBO *m_blitDrawFBO; // scratch FBO's for framebuffer blit - - CGLMFBO *m_scratchFBO[ kGLMScratchFBOCount ]; // general purpose FBO's for internal use - - CUtlVector< CGLMFBO* > m_fboTable; // each live FBO goes in the table - - // program bindings - EGLMProgramLang m_drawingLangAtFrameStart; // selector for start of frame (spills into m_drawingLang) - EGLMProgramLang m_drawingLang; // selector for which language we desire to draw with on the next batch - CGLMProgram *m_drawingProgram[ kGLMNumProgramTypes ]; - - GLMProgramParamsF m_programParamsF[ kGLMNumProgramTypes ]; - GLMProgramParamsB m_programParamsB[ kGLMNumProgramTypes ]; // two banks, but only the vertex one is used - GLMProgramParamsI m_programParamsI[ kGLMNumProgramTypes ]; // two banks, but only the vertex one is used - EGLMParamWriteMode m_paramWriteMode; - - CGLMProgram *m_nullFragmentProgram; // write opaque black. Activate when caller asks for null FP - - CGLMProgram *m_preloadTexVertexProgram; // programs to help preload textures (dummies) - CGLMProgram *m_preload2DTexFragmentProgram; - CGLMProgram *m_preload3DTexFragmentProgram; - CGLMProgram *m_preloadCubeTexFragmentProgram; - - CGLMProgram *m_boundProgram[ kGLMNumProgramTypes ]; - - CGLMShaderPairCache *m_pairCache; // GLSL only - CGLMShaderPair *m_boundPair; // GLSL only - uint m_boundPairRevision; // GLSL only - GLhandleARB m_boundPairProgram; // GLSL only - - // buffer bindings - CGLMBuffer *m_lastKnownBufferBinds[ kGLMNumBufferTypes ]; // tracked per bind point for dupe-bind-absorb - GLMVertexAttributeDesc m_lastKnownVertexAttribs[ kGLMVertexAttributeIndexMax ]; // tracked per attrib for dupe-set-absorb - uint m_lastKnownVertexAttribMask; // tracked for dupe-enable-absorb - - CGLMBuffer *m_drawIndexBuffer; // ... ? do we need dupe tracking for index buffer setup? ? - - GLMVertexSetup m_drawVertexSetup; - - EGLMAttribWriteMode m_attribWriteMode; - - bool m_slowCheckEnable; // turn this on or no native checking is done ("-glmassertslow" or "-glmsspewslow") - bool m_slowAssertEnable; // turn this on to assert on a non-native batch "-glmassertslow" - bool m_slowSpewEnable; // turn this on to log non-native batches to stdout "-glmspewslow" - - // debug font texture - CGLMTex *m_debugFontTex; // might be NULL unless you call GenDebugFontTex - CGLMBuffer *m_debugFontIndices; // up to 1024 indices (256 chars times 4) - CGLMBuffer *m_debugFontVertices; // up to 1024 verts - - // batch/frame debugging support - int m_debugFrameIndex; // init to -1. Increment at BeginFrame - int m_debugBatchIndex; // init to -1. Increment at any draw call - -#if GLMDEBUG - // interactive (DebugHook) debug support - - // using these you can implement frame advance, batch single step, and batch rewind (let it run til next frame and hold on prev batch #) - int m_holdFrameBegin; // -1 if no hold req'd, otherwise # of frame to hold at (at beginframe time) - int m_holdFrameEnd; // -1 if no hold req'd, otherwise # of frame to hold at (at endframe time) - - int m_holdBatch,m_holdBatchFrame; // -1 if no hold, else # of batch&frame to hold at (both must be set) - // these can be expired/cleared to -1 if the frame passes without a hit - // may be desirable to re-pause in that event, as user was expecting a hold to occur - - bool m_debugDelayEnable; // allow sleep delay - uint m_debugDelay; // sleep time per hook call in microseconds (for usleep()) - - // pre-draw global toggles / options - bool m_autoClearColor,m_autoClearDepth,m_autoClearStencil; - float m_autoClearColorValues[4]; - - // debug knobs - int m_selKnobIndex; - float m_selKnobMinValue,m_selKnobMaxValue,m_selKnobIncrement; -#endif - -}; - -struct GLMTestParams -{ - GLMContext *m_ctx; - int *m_testList; // -1 termed - - bool m_glErrToDebugger; - bool m_glErrToConsole; - - bool m_intlErrToDebugger; - bool m_intlErrToConsole; - - int m_frameCount; // how many frames to test. -}; - -class GLMTester -{ - public: - - GLMTester(GLMTestParams *params); - ~GLMTester(); - - - // optionally callable by test routines to get basic drawables wired up - void StdSetup( void ); - void StdCleanup( void ); - - // callable by test routines to clear the frame or present it - void Clear( void ); - void Present( int seed ); - - // error reporting - void CheckGLError( char *comment ); // obey m_params setting for console / debugger response - void InternalError( int errcode, char *comment ); // if errcode!=0, obey m_params setting for console / debugger response - - void RunTests(); - - void RunOneTest( int testindex ); - - // test routines themselves - void Test0(); - void Test1(); - void Test2(); - void Test3(); - - GLMTestParams m_params; // copy of caller's params, do not mutate... - - // std-setup stuff - int m_drawWidth, m_drawHeight; - CGLMFBO *m_drawFBO; - CGLMTex *m_drawColorTex; - CGLMTex *m_drawDepthTex; -}; - -class CShowPixelsParams -{ -public: - GLuint m_srcTexName; - int m_width,m_height; - bool m_vsyncEnable; - bool m_fsEnable; // want receiving view to be full screen. for now, just target the main screen. extend later. - bool m_useBlit; // use FBO blit - sending context says it is available. - bool m_noBlit; // the back buffer has already been populated by the caller (perhaps via direct MSAA resolve from multisampled RT tex) - bool m_onlySyncView; // react to full/windowed state change only, do not present bits -}; - - -#define kMaxCrawlFrames 100 -#define kMaxCrawlText (kMaxCrawlFrames * 256) -class CStackCrawlParams -{ - public: - uint m_frameLimit; // input: max frames to retrieve - uint m_frameCount; // output: frames found - void *m_crawl[kMaxCrawlFrames]; // call site addresses - char *m_crawlNames[kMaxCrawlFrames]; // pointers into text following, one per decoded name - char m_crawlText[kMaxCrawlText]; -}; - -#endif +// +// glmgr.h +// singleton class, common basis for managing GL contexts +// responsible for tracking adapters and contexts +// +//=============================================================================== + +#ifndef GLMGR_H +#define GLMGR_H + +#pragma once + +#undef HAVE_GL_ARB_SYNC +#ifdef LINUX +#define HAVE_GL_ARB_SYNC 1 +#endif + +#include "glentrypoints.h" +#include "glmdebug.h" +#include "glmdisplay.h" +#include "glmgrext.h" +#include "glmgrbasics.h" +#include "cglmtex.h" +#include "cglmfbo.h" +#include "cglmprogram.h" +#include "cglmbuffer.h" +#include "cglmquery.h" + +#include "tier0/vprof_telemetry.h" +#include "materialsystem/ishader.h" +#include "dxabstract_types.h" + + +#ifdef LINUX +#define Debugger DebuggerBreak +#undef CurrentTime + +// prevent some conflicts in SDL headers... +#undef M_PI +#include +#ifndef _STDINT_H_ +#define _STDINT_H_ 1 +#endif + +#include "SDL/SDL.h" +#endif + +//=============================================================================== +// glue to call out to Obj-C land (these are in glmgrcocoa.mm) +#ifdef OSX +PseudoNSGLContextPtr GetCurrentNSGLContext( ); +CGLContextObj GetCGLContextFromNSGL( PseudoNSGLContextPtr nsglCtx ); +#endif + +#include "tier0/dynfunction.h" + +//=============================================================================== + +// parrot the D3D present parameters, more or less... "adapter" translates into "active display index" per the m_activeDisplayCount below. +class GLMDisplayParams +{ + public: + + // presumption, these indices are in sync with the current display DB that GLMgr has handy + //int m_rendererIndex; // index of renderer (-1 if root context) + //int m_displayIndex; // index of display in renderer - for FS + //int m_modeIndex; // index of mode in display - for FS + + void *m_focusWindow; // (VD3DHWND aka WindowRef) - what window does this context display into + + bool m_fsEnable; // fullscreen on or not + bool m_vsyncEnable; // vsync on or not + + // height and width have to match the display mode info if full screen. + + uint m_backBufferWidth; // pixel width (aka screen h-resolution if full screen) + uint m_backBufferHeight; // pixel height (aka screen v-resolution if full screen) + D3DFORMAT m_backBufferFormat; // pixel format + uint m_multiSampleCount; // 0 means no MSAA, 2 means 2x MSAA, etc + // uint m_multiSampleQuality; // no MSAA quality control yet + + bool m_enableAutoDepthStencil; // generally set to 'TRUE' per CShaderDeviceDx8::SetPresentParameters + D3DFORMAT m_autoDepthStencilFormat; + + uint m_fsRefreshHz; // if full screen, this refresh rate (likely 0 for LCD's) + + //uint m_rootRendererID; // only used if m_rendererIndex is -1. + //uint m_rootDisplayMask; // only used if m_rendererIndex is -1. + + bool m_mtgl; // enable multi threaded GL driver +}; + +//=============================================================================== + +class GLMgr +{ +public: + + //=========================================================================== + // class methods - singleton + static void NewGLMgr( void ); // instantiate singleton.. + static GLMgr *aGLMgr( void ); // return singleton.. + static void DelGLMgr( void ); // tear down singleton.. + + //=========================================================================== + // plain methods + + #if 0 // turned all these off while new approach is coded + void RefreshDisplayDB( void ); // blow away old display DB, make a new one + GLMDisplayDB *GetDisplayDB( void ); // get a ptr to the one GLMgr keeps. only valid til next refresh. + + // eligible renderers will be ranked by desirability starting at index 0 within the db + // within each renderer, eligible displays will be ranked some kind of desirability (area? dist from menu bar?) + // within each display, eligible modes will be ranked by descending areas + + // calls supplying indices are implicitly making reference to the current DB + bool CaptureDisplay( int rendIndex, int displayIndex, bool captureAll ); // capture one display or all displays + void ReleaseDisplays( void ); // release all captures + + int GetDisplayMode( int rendIndex, int displayIndex ); // retrieve current display res (returns modeIndex) + void SetDisplayMode( GLMDisplayParams *params ); // set the display res (only useful for FS) + #endif + + GLMContext *NewContext( GLMDisplayParams *params ); // this will have to change + void DelContext( GLMContext *context ); + + // with usage of CGLMacro.h we could dispense with the "current context" thing + // and just declare a member variable of GLMContext, allowing each glXXX call to be routed directly + // to the correct context + void SetCurrentContext( GLMContext *context ); // make current in calling thread only + GLMContext *GetCurrentContext( void ); + +protected: + friend class GLMContext; + + GLMgr(); + ~GLMgr(); +}; + + +//===========================================================================// + +// helper function to do enable or disable in one step +inline void glSetEnable( GLenum which, bool enable ) +{ + if (enable) + gGL->glEnable(which); + else + gGL->glDisable(which); +} + +// helper function for int vs enum clarity +inline void glGetEnumv( GLenum which, GLenum *dst ) +{ + gGL->glGetIntegerv( which, (int*)dst ); +} + +//===========================================================================// +// +// types to support the GLMContext +// +//===========================================================================// + +// Each state set/get path we are providing caching for, needs its own struct and a comparison operator. +// we also provide an enum of how many such types there are, handy for building dirty masks etc. + +// shorthand macros +#define EQ(fff) ( (src.fff) == (fff) ) + +//rasterizer +struct GLAlphaTestEnable_t { GLint enable; bool operator==(const GLAlphaTestEnable_t& src) const { return EQ(enable); } }; +struct GLAlphaTestFunc_t { GLenum func; GLclampf ref; bool operator==(const GLAlphaTestFunc_t& src) const { return EQ(func) && EQ(ref); } }; +struct GLCullFaceEnable_t { GLint enable; bool operator==(const GLCullFaceEnable_t& src) const { return EQ(enable); } }; +struct GLCullFrontFace_t { GLenum value; bool operator==(const GLCullFrontFace_t& src) const { return EQ(value); } }; +struct GLPolygonMode_t { GLenum values[2]; bool operator==(const GLPolygonMode_t& src) const { return EQ(values[0]) && EQ(values[1]); } }; +struct GLDepthBias_t { GLfloat factor; GLfloat units; bool operator==(const GLDepthBias_t& src) const { return EQ(factor) && EQ(units); } }; +struct GLScissorEnable_t { GLint enable; bool operator==(const GLScissorEnable_t& src) const { return EQ(enable); } }; +struct GLScissorBox_t { GLint x,y; GLsizei width, height; bool operator==(const GLScissorBox_t& src) const { return EQ(x) && EQ(y) && EQ(width) && EQ(height); } }; +struct GLAlphaToCoverageEnable_t{ GLint enable; bool operator==(const GLAlphaToCoverageEnable_t& src) const { return EQ(enable); } }; +struct GLViewportBox_t { GLint x,y; GLsizei width, height; bool operator==(const GLViewportBox_t& src) const { return EQ(x) && EQ(y) && EQ(width) && EQ(height); } }; +struct GLViewportDepthRange_t { GLdouble near,far; bool operator==(const GLViewportDepthRange_t& src) const { return EQ(near) && EQ(far); } }; +struct GLClipPlaneEnable_t { GLint enable; bool operator==(const GLClipPlaneEnable_t& src) const { return EQ(enable); } }; +struct GLClipPlaneEquation_t { GLfloat x,y,z,w; bool operator==(const GLClipPlaneEquation_t& src) const { return EQ(x) && EQ(y) && EQ(z) && EQ(w); } }; + +//blend +struct GLColorMaskSingle_t { char r,g,b,a; bool operator==(const GLColorMaskSingle_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; +struct GLColorMaskMultiple_t { char r,g,b,a; bool operator==(const GLColorMaskMultiple_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; +struct GLBlendEnable_t { GLint enable; bool operator==(const GLBlendEnable_t& src) const { return EQ(enable); } }; +struct GLBlendFactor_t { GLenum srcfactor,dstfactor; bool operator==(const GLBlendFactor_t& src) const { return EQ(srcfactor) && EQ(dstfactor); } }; +struct GLBlendEquation_t { GLenum equation; bool operator==(const GLBlendEquation_t& src) const { return EQ(equation); } }; +struct GLBlendColor_t { GLfloat r,g,b,a; bool operator==(const GLBlendColor_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; +struct GLBlendEnableSRGB_t { GLint enable; bool operator==(const GLBlendEnableSRGB_t& src) const { return EQ(enable); } }; + +//depth +struct GLDepthTestEnable_t { GLint enable; bool operator==(const GLDepthTestEnable_t& src) const { return EQ(enable); } }; +struct GLDepthFunc_t { GLenum func; bool operator==(const GLDepthFunc_t& src) const { return EQ(func); } }; +struct GLDepthMask_t { char mask; bool operator==(const GLDepthMask_t& src) const { return EQ(mask); } }; + +//stencil +struct GLStencilTestEnable_t { GLint enable; bool operator==(const GLStencilTestEnable_t& src) const { return EQ(enable); } }; +struct GLStencilFunc_t { GLenum frontfunc, backfunc; GLint ref; GLuint mask; bool operator==(const GLStencilFunc_t& src) const { return EQ(frontfunc) && EQ(backfunc) && EQ(ref) && EQ(mask); } }; +struct GLStencilOp_t { GLenum sfail; GLenum dpfail; GLenum dppass; bool operator==(const GLStencilOp_t& src) const { return EQ(sfail) && EQ(dpfail) && EQ(dppass); } }; +struct GLStencilWriteMask_t { GLint mask; bool operator==(const GLStencilWriteMask_t& src) const { return EQ(mask); } }; + +//clearing +struct GLClearColor_t { GLfloat r,g,b,a; bool operator==(const GLClearColor_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; +struct GLClearDepth_t { GLdouble d; bool operator==(const GLClearDepth_t& src) const { return EQ(d); } }; +struct GLClearStencil_t { GLint s; bool operator==(const GLClearStencil_t& src) const { return EQ(s); } }; + +#undef EQ + +enum EGLMStateBlockType +{ + kGLAlphaTestEnable, + kGLAlphaTestFunc, + + kGLCullFaceEnable, + kGLCullFrontFace, + + kGLPolygonMode, + + kGLDepthBias, + + kGLScissorEnable, + kGLScissorBox, + + kGLViewportBox, + kGLViewportDepthRange, + + kGLClipPlaneEnable, + kGLClipPlaneEquation, + + kGLColorMaskSingle, + kGLColorMaskMultiple, + + kGLBlendEnable, + kGLBlendFactor, + kGLBlendEquation, + kGLBlendColor, + kGLBlendEnableSRGB, + + kGLDepthTestEnable, + kGLDepthFunc, + kGLDepthMask, + + kGLStencilTestEnable, + kGLStencilFunc, + kGLStencilOp, + kGLStencilWriteMask, + + kGLClearColor, + kGLClearDepth, + kGLClearStencil, + + kGLAlphaToCoverageEnable, + + kGLMStateBlockLimit +}; + +//===========================================================================// + +// templated functions representing GL R/W bottlenecks +// one set of set/get/getdefault is instantiated for each of the GL*** types above. + +// use these from the non array state objects +template void GLContextSet( T *src ); +template void GLContextGet( T *dst ); +template void GLContextGetDefault( T *dst ); + +// use these from the array state objects +template void GLContextSetIndexed( T *src, int index ); +template void GLContextGetIndexed( T *dst, int index ); +template void GLContextGetDefaultIndexed( T *dst, int index ); + +//===========================================================================// + +// caching state object template. One of these is instantiated in the context per unique struct type above +template class GLState +{ + public: + + GLState() + { + dirty = false; + memset( &data, 0, sizeof(data) ); + }; + + // write: client src into cache + // common case is both false. dirty is calculated, context write is deferred. + void Write( T *src, bool noCompare=false, bool noDefer=false ) + { + if (noCompare) + { + dirty = true; + } + else + { + // only == is implemented, so test for equal and negate + // note, you only set dirty if mismatch, you never clear it until flush + if ( !(data == *src) ) + { + dirty = true; + } + } + + data = *src; + + if (noDefer) + { + Flush( true ); // dirty becomes false + } + }; + + // write cache->context if dirty or forced. + void Flush( bool noDefer=false ) + { + if (dirty || noDefer) + { + GLContextSet( &data ); + GLMCheckError(); + // good place for some error checking here + dirty = false; + } + }; + + // default: write default value to cache, optionally write through + void Default( bool noDefer=false ) + { + GLContextGetDefault( &data ); // read default values directly to our cache copy + dirty = true; + Flush(noDefer); + }; + + // read: sel = 0 for cache, 1 for context + void Read( T *dst, int sel ) + { + if (sel==0) + { + *dst = data; + } + else + { + GLContextGet( dst ); + GLMCheckError(); + } + }; + + // check: verify that context equals cache, return true if mismatched or if illegal values seen + bool Check ( void ) + { + T temp; + bool result; + + GLContextGet( &temp ); + GLMCheckError(); + result = !(temp == data); + return result; + }; + + protected: + T data; + bool dirty; +}; + +// caching state object template - with multiple values behind it that are indexed +template class GLStateArray +{ + public: + + GLStateArray() + { + memset( &dirty, 0, sizeof(dirty) ); + memset( &data, 0, sizeof(data) ); + }; + + // write: client src into cache + // common case is both false. dirty is calculated, context write is deferred. + void WriteIndex( T *src, int index, bool noCompare=false, bool noDefer=false ) + { + if (noCompare) + { + dirty[index] = true; + } + else + { + // only == is implemented, so test for equal and negate + // note, you only set dirty if mismatch, you never clear it until flush + if (! (data[index] == *src) ) + { + dirty[index] = true; + } + } + + data[index] = *src; + + if (noDefer) + { + FlushIndex( index, true ); // dirty becomes false + } + }; + + // write cache->context if dirty or forced. + void FlushIndex( int index, bool noDefer=false ) + { + if (dirty[index] || noDefer) + { + GLContextSetIndexed( &data[index], index ); + GLMCheckError(); + dirty[index] = false; + } + }; + + // write all slots in the array + void Flush( bool noDefer=false ) + { + for( int i=0; i m_AlphaTestEnable; + + GLState m_AlphaTestFunc; + + GLState m_CullFaceEnable; + GLState m_CullFrontFace; + GLState m_PolygonMode; + + GLState m_DepthBias; + + GLStateArray m_ClipPlaneEnable; + GLStateArray m_ClipPlaneEquation; // dxabstract puts them directly into param slot 253(0) and 254(1) + + GLState m_ScissorEnable; + GLState m_ScissorBox; + + GLState m_AlphaToCoverageEnable; + + GLState m_ViewportBox; + GLState m_ViewportDepthRange; + + GLState m_ColorMaskSingle; + GLStateArray m_ColorMaskMultiple; // need an official constant for the color buffers limit + + GLState m_BlendEnable; + GLState m_BlendFactor; + GLState m_BlendEquation; + GLState m_BlendColor; + GLState m_BlendEnableSRGB; // write to this one to transmit intent to write SRGB encoded pixels to drawing FB + bool m_FakeBlendEnableSRGB; // writes to above will be shunted here if fake SRGB is in effect. + + GLState m_DepthTestEnable; + GLState m_DepthFunc; + GLState m_DepthMask; + + GLState m_StencilTestEnable; // global stencil test enable + GLState m_StencilFunc; // holds front and back stencil funcs + GLStateArray m_StencilOp; // indexed: 0=front 1=back + GLState m_StencilWriteMask; + + GLState m_ClearColor; + GLState m_ClearDepth; + GLState m_ClearStencil; + + // texture bindings and sampler setup + int m_activeTexture; // mirror for glActiveTexture + GLMTexSampler m_samplers[GLM_SAMPLER_COUNT]; + + // texture lock tracking - CGLMTex objects share usage of this + CUtlVector< GLMTexLockDesc > m_texLocks; + + // render target binding - check before draw + // similar to tex sampler mechanism, we track "bound" from "chosen for drawing" separately, + // so binding for creation/setup need not disrupt any notion of what will be used at draw time + + CGLMFBO *m_boundDrawFBO; // FBO on GL_DRAW_FRAMEBUFFER bind point + CGLMFBO *m_boundReadFBO; // FBO on GL_READ_FRAMEBUFFER bind point + // ^ both are set if you bind to GL_FRAMEBUFFER_EXT + + CGLMFBO *m_drawingFBO; // what FBO should be bound at draw time (to both read/draw bp's). + + CGLMFBO *m_blitReadFBO; + CGLMFBO *m_blitDrawFBO; // scratch FBO's for framebuffer blit + + CGLMFBO *m_scratchFBO[ kGLMScratchFBOCount ]; // general purpose FBO's for internal use + + CUtlVector< CGLMFBO* > m_fboTable; // each live FBO goes in the table + + // program bindings + EGLMProgramLang m_drawingLangAtFrameStart; // selector for start of frame (spills into m_drawingLang) + EGLMProgramLang m_drawingLang; // selector for which language we desire to draw with on the next batch + CGLMProgram *m_drawingProgram[ kGLMNumProgramTypes ]; + + GLMProgramParamsF m_programParamsF[ kGLMNumProgramTypes ]; + GLMProgramParamsB m_programParamsB[ kGLMNumProgramTypes ]; // two banks, but only the vertex one is used + GLMProgramParamsI m_programParamsI[ kGLMNumProgramTypes ]; // two banks, but only the vertex one is used + EGLMParamWriteMode m_paramWriteMode; + + CGLMProgram *m_nullFragmentProgram; // write opaque black. Activate when caller asks for null FP + + CGLMProgram *m_preloadTexVertexProgram; // programs to help preload textures (dummies) + CGLMProgram *m_preload2DTexFragmentProgram; + CGLMProgram *m_preload3DTexFragmentProgram; + CGLMProgram *m_preloadCubeTexFragmentProgram; + + CGLMProgram *m_boundProgram[ kGLMNumProgramTypes ]; + + CGLMShaderPairCache *m_pairCache; // GLSL only + CGLMShaderPair *m_boundPair; // GLSL only + uint m_boundPairRevision; // GLSL only + GLhandleARB m_boundPairProgram; // GLSL only + + // buffer bindings + CGLMBuffer *m_lastKnownBufferBinds[ kGLMNumBufferTypes ]; // tracked per bind point for dupe-bind-absorb + GLMVertexAttributeDesc m_lastKnownVertexAttribs[ kGLMVertexAttributeIndexMax ]; // tracked per attrib for dupe-set-absorb + uint m_lastKnownVertexAttribMask; // tracked for dupe-enable-absorb + + CGLMBuffer *m_drawIndexBuffer; // ... ? do we need dupe tracking for index buffer setup? ? + + GLMVertexSetup m_drawVertexSetup; + + EGLMAttribWriteMode m_attribWriteMode; + + bool m_slowCheckEnable; // turn this on or no native checking is done ("-glmassertslow" or "-glmsspewslow") + bool m_slowAssertEnable; // turn this on to assert on a non-native batch "-glmassertslow" + bool m_slowSpewEnable; // turn this on to log non-native batches to stdout "-glmspewslow" + + // debug font texture + CGLMTex *m_debugFontTex; // might be NULL unless you call GenDebugFontTex + CGLMBuffer *m_debugFontIndices; // up to 1024 indices (256 chars times 4) + CGLMBuffer *m_debugFontVertices; // up to 1024 verts + + // batch/frame debugging support + int m_debugFrameIndex; // init to -1. Increment at BeginFrame + int m_debugBatchIndex; // init to -1. Increment at any draw call + +#if GLMDEBUG + // interactive (DebugHook) debug support + + // using these you can implement frame advance, batch single step, and batch rewind (let it run til next frame and hold on prev batch #) + int m_holdFrameBegin; // -1 if no hold req'd, otherwise # of frame to hold at (at beginframe time) + int m_holdFrameEnd; // -1 if no hold req'd, otherwise # of frame to hold at (at endframe time) + + int m_holdBatch,m_holdBatchFrame; // -1 if no hold, else # of batch&frame to hold at (both must be set) + // these can be expired/cleared to -1 if the frame passes without a hit + // may be desirable to re-pause in that event, as user was expecting a hold to occur + + bool m_debugDelayEnable; // allow sleep delay + uint m_debugDelay; // sleep time per hook call in microseconds (for usleep()) + + // pre-draw global toggles / options + bool m_autoClearColor,m_autoClearDepth,m_autoClearStencil; + float m_autoClearColorValues[4]; + + // debug knobs + int m_selKnobIndex; + float m_selKnobMinValue,m_selKnobMaxValue,m_selKnobIncrement; +#endif + +}; + +struct GLMTestParams +{ + GLMContext *m_ctx; + int *m_testList; // -1 termed + + bool m_glErrToDebugger; + bool m_glErrToConsole; + + bool m_intlErrToDebugger; + bool m_intlErrToConsole; + + int m_frameCount; // how many frames to test. +}; + +class GLMTester +{ + public: + + GLMTester(GLMTestParams *params); + ~GLMTester(); + + + // optionally callable by test routines to get basic drawables wired up + void StdSetup( void ); + void StdCleanup( void ); + + // callable by test routines to clear the frame or present it + void Clear( void ); + void Present( int seed ); + + // error reporting + void CheckGLError( char *comment ); // obey m_params setting for console / debugger response + void InternalError( int errcode, char *comment ); // if errcode!=0, obey m_params setting for console / debugger response + + void RunTests(); + + void RunOneTest( int testindex ); + + // test routines themselves + void Test0(); + void Test1(); + void Test2(); + void Test3(); + + GLMTestParams m_params; // copy of caller's params, do not mutate... + + // std-setup stuff + int m_drawWidth, m_drawHeight; + CGLMFBO *m_drawFBO; + CGLMTex *m_drawColorTex; + CGLMTex *m_drawDepthTex; +}; + +class CShowPixelsParams +{ +public: + GLuint m_srcTexName; + int m_width,m_height; + bool m_vsyncEnable; + bool m_fsEnable; // want receiving view to be full screen. for now, just target the main screen. extend later. + bool m_useBlit; // use FBO blit - sending context says it is available. + bool m_noBlit; // the back buffer has already been populated by the caller (perhaps via direct MSAA resolve from multisampled RT tex) + bool m_onlySyncView; // react to full/windowed state change only, do not present bits +}; + + +#define kMaxCrawlFrames 100 +#define kMaxCrawlText (kMaxCrawlFrames * 256) +class CStackCrawlParams +{ + public: + uint m_frameLimit; // input: max frames to retrieve + uint m_frameCount; // output: frames found + void *m_crawl[kMaxCrawlFrames]; // call site addresses + char *m_crawlNames[kMaxCrawlFrames]; // pointers into text following, one per decoded name + char m_crawlText[kMaxCrawlText]; +}; + +#endif diff --git a/sp/src/public/togl/osx/glmgrbasics.h b/sp/src/public/togl/osx/glmgrbasics.h index 78e41464..d446b512 100644 --- a/sp/src/public/togl/osx/glmgrbasics.h +++ b/sp/src/public/togl/osx/glmgrbasics.h @@ -1,299 +1,299 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// -// glmgrbasics.h -// types, common headers, forward declarations, utilities -// -//=============================================================================== - -#ifndef GLMBASICS_H -#define GLMBASICS_H - -#pragma once - -#ifdef OSX -#include -#include -#include -#include -#include -#include -#include -//#include -#elif defined(LINUX) -#include -#include -#else -#error -#endif - -#include "tier0/platform.h" - -#include "bitmap/imageformat.h" -#include "bitvec.h" -#include "tier1/checksum_md5.h" -#include "tier1/utlvector.h" -#include "tier1/convar.h" - -#include - -#include "dxabstract_types.h" - -// types -struct GLMRect; -typedef void *PseudoGLContextPtr; - - - // 3-d integer box (used for texture lock/unlock etc) -struct GLMRegion -{ - int xmin,xmax; - int ymin,ymax; - int zmin,zmax; -}; - -struct GLMRect // follows GL convention - if coming from the D3D rect you will need to fiddle the Y's -{ - int xmin; // left - int ymin; // bottom - int xmax; // right - int ymax; // top -}; - -// macros - -//#define GLMassert(x) assert(x) - -// forward decls -class GLMgr; // singleton -class GLMContext; // GL context -class CGLMContextTester; // testing class -class CGLMTex; -class CGLMFBO; -class CGLMProgram; -class CGLMBuffer; - - -// utilities - -typedef enum -{ - // D3D codes - eD3D_DEVTYPE, - eD3D_FORMAT, - eD3D_RTYPE, - eD3D_USAGE, - eD3D_RSTATE, // render state - eD3D_SIO, // D3D shader bytecode - eD3D_VTXDECLUSAGE, - - // CGL codes - eCGL_RENDID, - - // OpenGL error codes - eGL_ERROR, - - // OpenGL enums - eGL_ENUM, - eGL_RENDERER - -} GLMThing_t; - -const char* GLMDecode( GLMThing_t type, unsigned long value ); // decode a numeric const -const char* GLMDecodeMask( GLMThing_t type, unsigned long value ); // decode a bitmask - -void GLMStop( void ); // aka Debugger() -void GLMCheckError( bool noStop = false, bool noLog= false ); -void GLMEnableTrace( bool on ); - -// expose these in release now -// Mimic PIX events so we can decorate debug spew -void GLMBeginPIXEvent( const char *str ); -void GLMEndPIXEvent( void ); - -//=============================================================================== -// knob twiddling -float GLMKnob( char *knobname, float *setvalue ); // Pass NULL to not-set the knob value -float GLMKnobToggle( char *knobname ); - -//=============================================================================== -// other stuff - -// helpers for CGLSetOption - no op if no profiler -void GLMProfilerClearTrace( void ); -void GLMProfilerEnableTrace( bool enable ); - -// helpers for CGLSetParameter - no op if no profiler -void GLMProfilerDumpState( void ); - - -//=============================================================================== -// classes - -// helper class making function tracking easier to wire up -#if GLMDEBUG -class GLMFuncLogger -{ - public: - - // simple function log - GLMFuncLogger( const char *funcName ) - { - m_funcName = funcName; - m_earlyOut = false; - - GLMPrintf( ">%s", m_funcName ); - }; - - // more advanced version lets you pass args (i.e. called parameters or anything else of interest) - // no macro for this one, since no easy way to pass through the args as well as the funcname - GLMFuncLogger( const char *funcName, char *fmt, ... ) - { - m_funcName = funcName; - m_earlyOut = false; - - // this acts like GLMPrintf here - // all the indent policy is down in GLMPrintfVA - // which means we need to inject a ">" at the front of the format string to make this work... sigh. - - char modifiedFmt[2000]; - modifiedFmt[0] = '>'; - strcpy( modifiedFmt+1, fmt ); - - va_list vargs; - va_start(vargs, fmt); - GLMPrintfVA( modifiedFmt, vargs ); - va_end( vargs ); - } - - ~GLMFuncLogger( ) - { - if (m_earlyOut) - { - GLMPrintf( "<%s (early out)", m_funcName ); - } - else - { - GLMPrintf( "<%s", m_funcName ); - } - }; - - void EarlyOut( void ) - { - m_earlyOut = true; - }; - - const char *m_funcName; // set at construction time - bool m_earlyOut; -}; - -// handy macro to go with the function tracking class -#define GLM_FUNC GLMFuncLogger _logger_ ( __FUNCTION__ ) -#else -#define GLM_FUNC -#endif - - -// class to keep an in-memory mirror of a file which may be getting edited during run -class CGLMFileMirror -{ -public: - CGLMFileMirror( char *fullpath ); // just associates mirror with file. if file exists it will be read. - //if non existent it will be created with size zero - ~CGLMFileMirror( ); - - bool HasData( void ); // see if data avail - void GetData( char **dataPtr, uint *dataSizePtr ); // read it out - void SetData( char *data, uint dataSize ); // put data in (and write it to disk) - bool PollForChanges( void ); // check disk copy. If different, read it back in and return true. - - void UpdateStatInfo( void ); // make sure stat info is current for our file - void ReadFile( void ); - void WriteFile( void ); - - void OpenInEditor( bool foreground=false ); // pass TRUE if you would like the editor to pop to foreground - - /// how about a "wait for change" method.. - - char *m_path; // fullpath to file - bool m_exists; - struct stat m_stat; // stat results for the file (last time checked) - - char *m_data; // content of file - uint m_size; // length of content - -}; - -// class based on the file mirror, that makes it easy to edit them outside the app. - -// it receives an initial block of text from the engine, and hashes it. ("orig") -// it munges it by duplicating all the text after the "!!" line, and appending it in commented form. ("munged") -// a mirror file is activated, using a filename based on the hash from the orig text. -// if there is already content on disk matching that filename, use that content *unless* the 'blitz' parameter is set. -// (i.e. engine is instructing this subsystem to wipe out any old/modified variants of the text) - - -class CGLMEditableTextItem -{ -public: - CGLMEditableTextItem( char *text, uint size, bool forceOverwrite, char *prefix, char *suffix = NULL ); // create a text blob from text source, optional filename suffix - ~CGLMEditableTextItem( ); - - bool HasData( void ); - bool PollForChanges( void ); // return true if stale i.e. you need to get a new edition - void GetCurrentText( char **textOut, uint *sizeOut ); // query for read access to the active blob (could be the original, could be external edited copy) - void OpenInEditor( bool foreground=false ); // call user attention to this text - - // internal methods - void GenHashOfOrigText( void ); - void GenBaseNameAndFullPath( char *prefix, char *suffix ); - void GenMungedText( bool fromMirror ); - - // members - // orig - uint m_origSize; - char *m_origText; // what was submitted - unsigned char m_origDigest[MD5_DIGEST_LENGTH]; // digest of what was submitted - - // munged - uint m_mungedSize; - char *m_mungedText; // re-processed edition, initial content submission to the file mirror - - // mirror - char *m_mirrorBaseName; // generated from the hash of the orig text, plus the label / prefix - char *m_mirrorFullPath; // base name - CGLMFileMirror *m_mirror; // file mirror itself. holds "official" copy for GetCurrentText to return. -}; - - -// debug font -extern unsigned char g_glmDebugFontMap[16384]; - -// class for cracking multi-part text blobs -// sections are demarcated by beginning-of-line markers submitted in a table by the caller - -struct GLMTextSection -{ - int m_markerIndex; // based on table of markers passed in to constructor - uint m_textOffset; // where is the text - offset - int m_textLength; // how big is the section -}; - -class CGLMTextSectioner -{ -public: - CGLMTextSectioner( char *text, int textSize, char **markers ); // constructor finds all the sections - ~CGLMTextSectioner( ); - - int Count( void ); // how many sections found - void GetSection( int index, uint *offsetOut, uint *lengthOut, int *markerIndexOut ); - // find section, size, what marker - // note that more than one section can be marked similarly. - // so policy isn't made here, you walk the sections and decide what to do if there are dupes. - - //members - - //section table - CUtlVector< GLMTextSection > m_sectionTable; -}; - -#endif +// +// glmgrbasics.h +// types, common headers, forward declarations, utilities +// +//=============================================================================== + +#ifndef GLMBASICS_H +#define GLMBASICS_H + +#pragma once + +#ifdef OSX +#include +#include +#include +#include +#include +#include +#include +//#include +#elif defined(LINUX) +#include +#include +#else +#error +#endif + +#include "tier0/platform.h" + +#include "bitmap/imageformat.h" +#include "bitvec.h" +#include "tier1/checksum_md5.h" +#include "tier1/utlvector.h" +#include "tier1/convar.h" + +#include + +#include "dxabstract_types.h" + +// types +struct GLMRect; +typedef void *PseudoGLContextPtr; + + + // 3-d integer box (used for texture lock/unlock etc) +struct GLMRegion +{ + int xmin,xmax; + int ymin,ymax; + int zmin,zmax; +}; + +struct GLMRect // follows GL convention - if coming from the D3D rect you will need to fiddle the Y's +{ + int xmin; // left + int ymin; // bottom + int xmax; // right + int ymax; // top +}; + +// macros + +//#define GLMassert(x) assert(x) + +// forward decls +class GLMgr; // singleton +class GLMContext; // GL context +class CGLMContextTester; // testing class +class CGLMTex; +class CGLMFBO; +class CGLMProgram; +class CGLMBuffer; + + +// utilities + +typedef enum +{ + // D3D codes + eD3D_DEVTYPE, + eD3D_FORMAT, + eD3D_RTYPE, + eD3D_USAGE, + eD3D_RSTATE, // render state + eD3D_SIO, // D3D shader bytecode + eD3D_VTXDECLUSAGE, + + // CGL codes + eCGL_RENDID, + + // OpenGL error codes + eGL_ERROR, + + // OpenGL enums + eGL_ENUM, + eGL_RENDERER + +} GLMThing_t; + +const char* GLMDecode( GLMThing_t type, unsigned long value ); // decode a numeric const +const char* GLMDecodeMask( GLMThing_t type, unsigned long value ); // decode a bitmask + +void GLMStop( void ); // aka Debugger() +void GLMCheckError( bool noStop = false, bool noLog= false ); +void GLMEnableTrace( bool on ); + +// expose these in release now +// Mimic PIX events so we can decorate debug spew +void GLMBeginPIXEvent( const char *str ); +void GLMEndPIXEvent( void ); + +//=============================================================================== +// knob twiddling +float GLMKnob( char *knobname, float *setvalue ); // Pass NULL to not-set the knob value +float GLMKnobToggle( char *knobname ); + +//=============================================================================== +// other stuff + +// helpers for CGLSetOption - no op if no profiler +void GLMProfilerClearTrace( void ); +void GLMProfilerEnableTrace( bool enable ); + +// helpers for CGLSetParameter - no op if no profiler +void GLMProfilerDumpState( void ); + + +//=============================================================================== +// classes + +// helper class making function tracking easier to wire up +#if GLMDEBUG +class GLMFuncLogger +{ + public: + + // simple function log + GLMFuncLogger( const char *funcName ) + { + m_funcName = funcName; + m_earlyOut = false; + + GLMPrintf( ">%s", m_funcName ); + }; + + // more advanced version lets you pass args (i.e. called parameters or anything else of interest) + // no macro for this one, since no easy way to pass through the args as well as the funcname + GLMFuncLogger( const char *funcName, char *fmt, ... ) + { + m_funcName = funcName; + m_earlyOut = false; + + // this acts like GLMPrintf here + // all the indent policy is down in GLMPrintfVA + // which means we need to inject a ">" at the front of the format string to make this work... sigh. + + char modifiedFmt[2000]; + modifiedFmt[0] = '>'; + strcpy( modifiedFmt+1, fmt ); + + va_list vargs; + va_start(vargs, fmt); + GLMPrintfVA( modifiedFmt, vargs ); + va_end( vargs ); + } + + ~GLMFuncLogger( ) + { + if (m_earlyOut) + { + GLMPrintf( "<%s (early out)", m_funcName ); + } + else + { + GLMPrintf( "<%s", m_funcName ); + } + }; + + void EarlyOut( void ) + { + m_earlyOut = true; + }; + + const char *m_funcName; // set at construction time + bool m_earlyOut; +}; + +// handy macro to go with the function tracking class +#define GLM_FUNC GLMFuncLogger _logger_ ( __FUNCTION__ ) +#else +#define GLM_FUNC +#endif + + +// class to keep an in-memory mirror of a file which may be getting edited during run +class CGLMFileMirror +{ +public: + CGLMFileMirror( char *fullpath ); // just associates mirror with file. if file exists it will be read. + //if non existent it will be created with size zero + ~CGLMFileMirror( ); + + bool HasData( void ); // see if data avail + void GetData( char **dataPtr, uint *dataSizePtr ); // read it out + void SetData( char *data, uint dataSize ); // put data in (and write it to disk) + bool PollForChanges( void ); // check disk copy. If different, read it back in and return true. + + void UpdateStatInfo( void ); // make sure stat info is current for our file + void ReadFile( void ); + void WriteFile( void ); + + void OpenInEditor( bool foreground=false ); // pass TRUE if you would like the editor to pop to foreground + + /// how about a "wait for change" method.. + + char *m_path; // fullpath to file + bool m_exists; + struct stat m_stat; // stat results for the file (last time checked) + + char *m_data; // content of file + uint m_size; // length of content + +}; + +// class based on the file mirror, that makes it easy to edit them outside the app. + +// it receives an initial block of text from the engine, and hashes it. ("orig") +// it munges it by duplicating all the text after the "!!" line, and appending it in commented form. ("munged") +// a mirror file is activated, using a filename based on the hash from the orig text. +// if there is already content on disk matching that filename, use that content *unless* the 'blitz' parameter is set. +// (i.e. engine is instructing this subsystem to wipe out any old/modified variants of the text) + + +class CGLMEditableTextItem +{ +public: + CGLMEditableTextItem( char *text, uint size, bool forceOverwrite, char *prefix, char *suffix = NULL ); // create a text blob from text source, optional filename suffix + ~CGLMEditableTextItem( ); + + bool HasData( void ); + bool PollForChanges( void ); // return true if stale i.e. you need to get a new edition + void GetCurrentText( char **textOut, uint *sizeOut ); // query for read access to the active blob (could be the original, could be external edited copy) + void OpenInEditor( bool foreground=false ); // call user attention to this text + + // internal methods + void GenHashOfOrigText( void ); + void GenBaseNameAndFullPath( char *prefix, char *suffix ); + void GenMungedText( bool fromMirror ); + + // members + // orig + uint m_origSize; + char *m_origText; // what was submitted + unsigned char m_origDigest[MD5_DIGEST_LENGTH]; // digest of what was submitted + + // munged + uint m_mungedSize; + char *m_mungedText; // re-processed edition, initial content submission to the file mirror + + // mirror + char *m_mirrorBaseName; // generated from the hash of the orig text, plus the label / prefix + char *m_mirrorFullPath; // base name + CGLMFileMirror *m_mirror; // file mirror itself. holds "official" copy for GetCurrentText to return. +}; + + +// debug font +extern unsigned char g_glmDebugFontMap[16384]; + +// class for cracking multi-part text blobs +// sections are demarcated by beginning-of-line markers submitted in a table by the caller + +struct GLMTextSection +{ + int m_markerIndex; // based on table of markers passed in to constructor + uint m_textOffset; // where is the text - offset + int m_textLength; // how big is the section +}; + +class CGLMTextSectioner +{ +public: + CGLMTextSectioner( char *text, int textSize, char **markers ); // constructor finds all the sections + ~CGLMTextSectioner( ); + + int Count( void ); // how many sections found + void GetSection( int index, uint *offsetOut, uint *lengthOut, int *markerIndexOut ); + // find section, size, what marker + // note that more than one section can be marked similarly. + // so policy isn't made here, you walk the sections and decide what to do if there are dupes. + + //members + + //section table + CUtlVector< GLMTextSection > m_sectionTable; +}; + +#endif diff --git a/sp/src/public/togl/osx/glmgrext.h b/sp/src/public/togl/osx/glmgrext.h index 02939bb6..ace2c666 100644 --- a/sp/src/public/togl/osx/glmgrext.h +++ b/sp/src/public/togl/osx/glmgrext.h @@ -1,93 +1,93 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -// -// glmgrext.h -// helper file for extension testing and runtime importing of entry points -// -//=============================================================================== - -#pragma once - -#ifdef OSX -#include -#include -#elif defined(LINUX) -#include -#include -#else -#error -#endif - -#ifndef GL_EXT_framebuffer_sRGB - #define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 - #define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA -#endif - -#ifndef ARB_texture_rg - #define GL_COMPRESSED_RED 0x8225 - #define GL_COMPRESSED_RG 0x8226 - #define GL_RG 0x8227 - #define GL_RG_INTEGER 0x8228 - #define GL_R8 0x8229 - #define GL_R16 0x822A - #define GL_RG8 0x822B - #define GL_RG16 0x822C - #define GL_R16F 0x822D - #define GL_R32F 0x822E - #define GL_RG16F 0x822F - #define GL_RG32F 0x8230 - #define GL_R8I 0x8231 - #define GL_R8UI 0x8232 - #define GL_R16I 0x8233 - #define GL_R16UI 0x8234 - #define GL_R32I 0x8235 - #define GL_R32UI 0x8236 - #define GL_RG8I 0x8237 - #define GL_RG8UI 0x8238 - #define GL_RG16I 0x8239 - #define GL_RG16UI 0x823A - #define GL_RG32I 0x823B - #define GL_RG32UI 0x823C -#endif - -#ifndef GL_EXT_bindable_uniform - #define GL_UNIFORM_BUFFER_EXT 0x8DEE -#endif - -// unpublished extension enums (thus the "X") - -// from EXT_framebuffer_multisample_blit_scaled.. -#define XGL_SCALED_RESOLVE_FASTEST_EXT 0x90BA -#define XGL_SCALED_RESOLVE_NICEST_EXT 0x90BB - -#ifndef GL_TEXTURE_MINIMIZE_STORAGE_APPLE -#define GL_TEXTURE_MINIMIZE_STORAGE_APPLE 0x85B6 -#endif - -#ifndef GL_ALL_COMPLETED_NV -#define GL_ALL_COMPLETED_NV 0x84F2 -#endif - -#ifndef GL_MAP_READ_BIT -#define GL_MAP_READ_BIT 0x0001 -#endif - -#ifndef GL_MAP_WRITE_BIT -#define GL_MAP_WRITE_BIT 0x0002 -#endif - -#ifndef GL_MAP_INVALIDATE_RANGE_BIT -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#endif - -#ifndef GL_MAP_INVALIDATE_BUFFER_BIT -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#endif - -#ifndef GL_MAP_FLUSH_EXPLICIT_BIT -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#endif - -#ifndef GL_MAP_UNSYNCHRONIZED_BIT -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 -#endif - +// +// glmgrext.h +// helper file for extension testing and runtime importing of entry points +// +//=============================================================================== + +#pragma once + +#ifdef OSX +#include +#include +#elif defined(LINUX) +#include +#include +#else +#error +#endif + +#ifndef GL_EXT_framebuffer_sRGB + #define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 + #define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif + +#ifndef ARB_texture_rg + #define GL_COMPRESSED_RED 0x8225 + #define GL_COMPRESSED_RG 0x8226 + #define GL_RG 0x8227 + #define GL_RG_INTEGER 0x8228 + #define GL_R8 0x8229 + #define GL_R16 0x822A + #define GL_RG8 0x822B + #define GL_RG16 0x822C + #define GL_R16F 0x822D + #define GL_R32F 0x822E + #define GL_RG16F 0x822F + #define GL_RG32F 0x8230 + #define GL_R8I 0x8231 + #define GL_R8UI 0x8232 + #define GL_R16I 0x8233 + #define GL_R16UI 0x8234 + #define GL_R32I 0x8235 + #define GL_R32UI 0x8236 + #define GL_RG8I 0x8237 + #define GL_RG8UI 0x8238 + #define GL_RG16I 0x8239 + #define GL_RG16UI 0x823A + #define GL_RG32I 0x823B + #define GL_RG32UI 0x823C +#endif + +#ifndef GL_EXT_bindable_uniform + #define GL_UNIFORM_BUFFER_EXT 0x8DEE +#endif + +// unpublished extension enums (thus the "X") + +// from EXT_framebuffer_multisample_blit_scaled.. +#define XGL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define XGL_SCALED_RESOLVE_NICEST_EXT 0x90BB + +#ifndef GL_TEXTURE_MINIMIZE_STORAGE_APPLE +#define GL_TEXTURE_MINIMIZE_STORAGE_APPLE 0x85B6 +#endif + +#ifndef GL_ALL_COMPLETED_NV +#define GL_ALL_COMPLETED_NV 0x84F2 +#endif + +#ifndef GL_MAP_READ_BIT +#define GL_MAP_READ_BIT 0x0001 +#endif + +#ifndef GL_MAP_WRITE_BIT +#define GL_MAP_WRITE_BIT 0x0002 +#endif + +#ifndef GL_MAP_INVALIDATE_RANGE_BIT +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#endif + +#ifndef GL_MAP_INVALIDATE_BUFFER_BIT +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#endif + +#ifndef GL_MAP_FLUSH_EXPLICIT_BIT +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#endif + +#ifndef GL_MAP_UNSYNCHRONIZED_BIT +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#endif + diff --git a/sp/src/public/vgui/ISurface.h b/sp/src/public/vgui/ISurface.h index b1e39bd4..0ccc8157 100644 --- a/sp/src/public/vgui/ISurface.h +++ b/sp/src/public/vgui/ISurface.h @@ -32,6 +32,7 @@ #endif class Color; +class ITexture; namespace vgui { @@ -386,7 +387,7 @@ public: virtual IHTMLChromeController *AccessChromeHTMLController() = 0; // the origin of the viewport on the framebuffer (Which might not be 0,0 for stereo) - virtual void SetFullscreenViewport( int x, int y, int w, int h ) = 0; + virtual void SetFullscreenViewportAndRenderTarget( int x, int y, int w, int h, ITexture *pRenderTarget ) = 0; virtual void GetFullscreenViewport( int & x, int & y, int & w, int & h ) = 0; virtual void PushFullscreenViewport() = 0; virtual void PopFullscreenViewport() = 0; @@ -394,6 +395,12 @@ public: // handles support for software cursors virtual void SetSoftwareCursor( bool bUseSoftwareCursor ) = 0; virtual void PaintSoftwareCursor() = 0; + + + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // !! WARNING! YOU MUST NOT ADD YOUR NEW METHOD HERE OR YOU WILL BREAK MODS !! + // !! Add your new stuff to the bottom of IMatSystemSurface instead. !! + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! }; } diff --git a/sp/src/public/windows_default.manifest b/sp/src/public/windows_default.manifest index 19973c57..31ec6d82 100644 --- a/sp/src/public/windows_default.manifest +++ b/sp/src/public/windows_default.manifest @@ -8,6 +8,8 @@ + + diff --git a/sp/src/thirdparty/protobuf-2.3.0/gtest/msvc/gtest.vcxproj b/sp/src/thirdparty/protobuf-2.3.0/gtest/msvc/gtest.vcxproj index 6e8f970e..a2bbc119 100644 --- a/sp/src/thirdparty/protobuf-2.3.0/gtest/msvc/gtest.vcxproj +++ b/sp/src/thirdparty/protobuf-2.3.0/gtest/msvc/gtest.vcxproj @@ -18,10 +18,12 @@ StaticLibrary MultiByte + v110_xp StaticLibrary MultiByte + v110_xp diff --git a/sp/src/thirdparty/protobuf-2.3.0/gtest/msvc/gtest_main.vcxproj b/sp/src/thirdparty/protobuf-2.3.0/gtest/msvc/gtest_main.vcxproj index af13fd33..938e84a2 100644 --- a/sp/src/thirdparty/protobuf-2.3.0/gtest/msvc/gtest_main.vcxproj +++ b/sp/src/thirdparty/protobuf-2.3.0/gtest/msvc/gtest_main.vcxproj @@ -18,10 +18,12 @@ StaticLibrary MultiByte + v110_xp StaticLibrary MultiByte + v110_xp diff --git a/sp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/io/zero_copy_stream_impl_lite.cc b/sp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/io/zero_copy_stream_impl_lite.cc index 79d57452..c2e04600 100644 --- a/sp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/io/zero_copy_stream_impl_lite.cc +++ b/sp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/io/zero_copy_stream_impl_lite.cc @@ -35,6 +35,7 @@ #include #include #include +#include namespace google { namespace protobuf { diff --git a/sp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/repeated_field.cc b/sp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/repeated_field.cc index 68544f34..38ce984e 100644 --- a/sp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/repeated_field.cc +++ b/sp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/repeated_field.cc @@ -34,6 +34,7 @@ #include #include +#include namespace google { namespace protobuf { diff --git a/sp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/wire_format_lite_inl.h b/sp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/wire_format_lite_inl.h index d7b2c302..07b207d0 100644 --- a/sp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/wire_format_lite_inl.h +++ b/sp/src/thirdparty/protobuf-2.3.0/src/google/protobuf/wire_format_lite_inl.h @@ -37,6 +37,7 @@ #define GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_INL_H__ #include +#include #include #include #include diff --git a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotobuf-lite.vcxproj b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotobuf-lite.vcxproj index e2995b8a..b24b8bbe 100644 --- a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotobuf-lite.vcxproj +++ b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotobuf-lite.vcxproj @@ -26,15 +26,19 @@ StaticLibrary + v110_xp StaticLibrary + v110_xp StaticLibrary + v110_xp StaticLibrary + v110_xp @@ -57,15 +61,15 @@ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\$(ProjectName)\ - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) Disabled ../src;.;%(AdditionalIncludeDirectories) _HAS_ITERATOR_DEBUGGING=0;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) @@ -84,11 +88,11 @@ X64 - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) Disabled ../src;.;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug @@ -99,9 +103,9 @@ - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) ../src;.;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;;%(PreprocessorDefinitions) MultiThreaded @@ -115,9 +119,9 @@ X64 - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) ../src;.;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions) MultiThreaded diff --git a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotobuf.vcxproj b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotobuf.vcxproj index ad279452..6afa7a6d 100644 --- a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotobuf.vcxproj +++ b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotobuf.vcxproj @@ -26,15 +26,19 @@ StaticLibrary + v110_xp StaticLibrary + v110_xp StaticLibrary + v110_xp StaticLibrary + v110_xp @@ -57,15 +61,15 @@ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\$(ProjectName)\ - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) Disabled ../src;.;%(AdditionalIncludeDirectories) _HAS_ITERATOR_DEBUGGING=0;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) @@ -84,11 +88,11 @@ X64 - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) Disabled ../src;.;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug @@ -100,9 +104,9 @@ - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) ../src;.;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions) MultiThreaded @@ -116,9 +120,9 @@ X64 - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) ../src;.;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOBUF_EXPORTS;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions) MultiThreaded diff --git a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotoc.vcxproj b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotoc.vcxproj index 98b46fce..bc517c70 100644 --- a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotoc.vcxproj +++ b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/libprotoc.vcxproj @@ -25,15 +25,19 @@ StaticLibrary + v110_xp StaticLibrary + v110_xp StaticLibrary + v110_xp StaticLibrary + v110_xp @@ -56,15 +60,15 @@ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\$(ProjectName)\ - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) Disabled ../src;.;%(AdditionalIncludeDirectories) _HAS_ITERATOR_DEBUGGING=0;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBPROTOC_EXPORTS;%(PreprocessorDefinitions) @@ -82,11 +86,11 @@ X64 - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) Disabled ../src;.;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBPROTOC_EXPORTS;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug @@ -97,9 +101,9 @@ - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) ../src;.;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOC_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOC_EXPORTS;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions) MultiThreaded @@ -112,9 +116,9 @@ X64 - /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 %(AdditionalOptions) + /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /d2Zi+ %(AdditionalOptions) ../src;.;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOC_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBPROTOC_EXPORTS;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions) MultiThreaded diff --git a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/lite-test.vcxproj b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/lite-test.vcxproj index d046a361..ffcb54ce 100644 --- a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/lite-test.vcxproj +++ b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/lite-test.vcxproj @@ -26,15 +26,19 @@ Application + v110_xp Application + v110_xp Application + v110_xp Application + v110_xp @@ -81,7 +85,7 @@ Disabled ../src;.;../gtest/include;%(AdditionalIncludeDirectories) _HAS_ITERATOR_DEBUGGING=0;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug @@ -112,7 +116,7 @@ Disabled ../src;.;../gtest/include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug diff --git a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/make.bat b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/make.bat index 89b257a8..70cc0261 100644 --- a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/make.bat +++ b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/make.bat @@ -4,24 +4,23 @@ setlocal @rem Move to the batch file directory so we can run it from anywhere cd %~dp0 -call "%VS100COMNTOOLS%vsvars32.bat" +call "%VS110COMNTOOLS%vsvars32.bat" +set dirsuffix=\2012 -for /d %%d in (debug release "debug|x64" "release|x64") do ( +@rem Note that we no longer build separate debug libraries +for /d %%d in ( "release|Win32" "release|x64") do ( + @rem Note that this message seems to display out of order for some reason... echo Building %%d devenv protobuf_2010.sln /clean %%d - devenv protobuf_2010.sln /build %%d /project libprotobuf devenv protobuf_2010.sln /build %%d /project libprotobuf-lite + @rem Note that building libprotoc also ensures that libprotobuf builds devenv protobuf_2010.sln /build %%d /project libprotoc ) -p4 edit ..\..\..\lib\win32\debug\VS2010\libproto*.lib -p4 edit ..\..\..\lib\win32\release\VS2010\libproto*.lib -p4 edit ..\..\..\lib\win64\debug\VS2010\libproto*.lib -p4 edit ..\..\..\lib\win64\release\VS2010\libproto*.lib +p4 edit ..\..\..\lib\public%dirsuffix%\libproto*.lib +p4 edit ..\..\..\lib\public\x64%dirsuffix%\libproto*.lib -copy /y Debug\libproto*.lib ..\..\..\lib\win32\debug\VS2010 -copy /y Release\libproto*.lib ..\..\..\lib\win32\Release\VS2010 -copy /y x64\Debug\libproto*.lib ..\..\..\lib\win64\debug\VS2010 -copy /y x64\Release\libproto*.lib ..\..\..\lib\win64\Release\VS2010 +copy /y Release\libproto*.lib ..\..\..\lib\public%dirsuffix% +copy /y x64\Release\libproto*.lib ..\..\..\lib\public\x64%dirsuffix% @echo Check in the changed libraries in src\lib if you are done. diff --git a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/make2013.bat b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/make2013.bat new file mode 100644 index 00000000..f2329b9e --- /dev/null +++ b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/make2013.bat @@ -0,0 +1,54 @@ +@echo off +setlocal + +@rem Move to the batch file directory so we can run it from anywhere +cd %~dp0 + +call "%VS120COMNTOOLS%vsvars32.bat" +set dirsuffix=\2013 + +p4 edit ..\gtest\msvc\*.vcxproj +p4 edit *.vcxproj +p4 edit *.sln + +@rem This will upgrade from v110_xp to v120_xp +devenv protobuf_2010.sln /upgrade +@rem Remove upgrade files +rmdir Backup /s/q +rmdir _UpgradeReport_Files /s/q +del UpgradeLog*.* + +@rem Note that we no longer build separate debug libraries +for /d %%d in ( "release|Win32" "release|x64") do ( + @rem Note that this message seems to display out of order for some reason... + echo Building %%d + devenv protobuf_2010.sln /clean %%d + devenv protobuf_2010.sln /build %%d /project libprotobuf-lite + @rem Note that building libprotoc also ensures that libprotobuf builds + devenv protobuf_2010.sln /build %%d /project libprotoc +) + +@rem Make the destination directories in case they don't already exist. +mkdir ..\..\..\lib\public%dirsuffix% +mkdir ..\..\..\lib\public\x64%dirsuffix% + +@rem Edit the destination files if they do exist +p4 edit ..\..\..\lib\public%dirsuffix%\libproto*.lib +p4 edit ..\..\..\lib\public\x64%dirsuffix%\libproto*.lib + +copy /y Release\libproto*.lib ..\..\..\lib\public%dirsuffix% +copy /y x64\Release\libproto*.lib ..\..\..\lib\public\x64%dirsuffix% + +@rem Auto-add the files if they aren't added yet. Too bad we can't use wildcards here. +p4 add ..\..\..\lib\public%dirsuffix%\libprotobuf-lite.lib +p4 add ..\..\..\lib\public%dirsuffix%\libprotobuf.lib +p4 add ..\..\..\lib\public%dirsuffix%\libprotoc.lib +p4 add ..\..\..\lib\public\x64%dirsuffix%\libprotobuf-lite.lib +p4 add ..\..\..\lib\public\x64%dirsuffix%\libprotobuf.lib +p4 add ..\..\..\lib\public\x64%dirsuffix%\libprotoc.lib + +p4 revert ..\gtest\msvc\*.vcxproj +p4 revert *.vcxproj +p4 revert *.sln + +@echo Check in the changed libraries in src\lib if you are done. diff --git a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/protobuf_2010.sln b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/protobuf_2010.sln index 413793a1..d67098c8 100644 --- a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/protobuf_2010.sln +++ b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/protobuf_2010.sln @@ -1,6 +1,6 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libprotobuf", "libprotobuf.vcxproj", "{3E283F37-A4ED-41B7-A3E6-A2D89D131A30}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libprotoc", "libprotoc.vcxproj", "{B84FF31A-5F9A-46F8-AB22-DBFC9BECE3BE}" @@ -61,20 +61,16 @@ Global {4DF72760-C055-40A5-A77E-30A17E2AC2DB}.Release|x64.Build.0 = Release|x64 {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug|Win32.ActiveCfg = Debug|Win32 {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug|Win32.Build.0 = Debug|Win32 - {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug|x64.ActiveCfg = Debug|x64 - {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug|x64.Build.0 = Debug|x64 + {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug|x64.ActiveCfg = Debug|Win32 {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release|Win32.ActiveCfg = Release|Win32 {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release|Win32.Build.0 = Release|Win32 - {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release|x64.ActiveCfg = Release|x64 - {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release|x64.Build.0 = Release|x64 + {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release|x64.ActiveCfg = Release|Win32 {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug|Win32.ActiveCfg = Debug|Win32 {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug|Win32.Build.0 = Debug|Win32 - {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug|x64.ActiveCfg = Debug|x64 - {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug|x64.Build.0 = Debug|x64 + {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug|x64.ActiveCfg = Debug|Win32 {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release|Win32.ActiveCfg = Release|Win32 {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release|Win32.Build.0 = Release|Win32 - {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release|x64.ActiveCfg = Release|x64 - {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release|x64.Build.0 = Release|x64 + {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release|x64.ActiveCfg = Release|Win32 {49EA010D-706F-4BE2-A397-77854B72A040}.Debug|Win32.ActiveCfg = Debug|Win32 {49EA010D-706F-4BE2-A397-77854B72A040}.Debug|Win32.Build.0 = Debug|Win32 {49EA010D-706F-4BE2-A397-77854B72A040}.Debug|x64.ActiveCfg = Debug|x64 diff --git a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/protoc.vcxproj b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/protoc.vcxproj index f27d9dca..ceb37b42 100644 --- a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/protoc.vcxproj +++ b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/protoc.vcxproj @@ -25,15 +25,19 @@ Application + v110_xp Application + v110_xp Application + v110_xp Application + v110_xp @@ -72,7 +76,7 @@ Disabled ../src;.;%(AdditionalIncludeDirectories) _HAS_ITERATOR_DEBUGGING=0;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug @@ -95,7 +99,7 @@ Disabled ../src;.;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug diff --git a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/test_plugin.vcxproj b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/test_plugin.vcxproj index 894c5fa3..628d197c 100644 --- a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/test_plugin.vcxproj +++ b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/test_plugin.vcxproj @@ -26,15 +26,19 @@ Application + v110_xp Application + v110_xp Application + v110_xp Application + v110_xp @@ -81,7 +85,7 @@ Disabled ../src;.;../gtest/include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug @@ -112,7 +116,7 @@ Disabled ../src;.;../gtest/include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug diff --git a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/tests.vcxproj b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/tests.vcxproj index 0f72ce12..6077d16f 100644 --- a/sp/src/thirdparty/protobuf-2.3.0/vsprojects/tests.vcxproj +++ b/sp/src/thirdparty/protobuf-2.3.0/vsprojects/tests.vcxproj @@ -26,15 +26,19 @@ Application + v110_xp Application + v110_xp Application + v110_xp Application + v110_xp @@ -81,7 +85,7 @@ Disabled ../src;.;../gtest/include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug @@ -112,7 +116,7 @@ Disabled ../src;.;../gtest/include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true + false EnableFastChecks MultiThreadedDebug diff --git a/sp/src/tier1/qsort_s.cpp b/sp/src/tier1/qsort_s.cpp index 8222b32b..820d151d 100644 --- a/sp/src/tier1/qsort_s.cpp +++ b/sp/src/tier1/qsort_s.cpp @@ -1,112 +1,112 @@ //========= Copyright Valve Corporation, All rights reserved. ============// -/******************************************************************/ -/* qsort.c -- Non-Recursive ANSI Quicksort function */ -/* */ -/* Public domain by Raymond Gardner, Englewood CO February 1991 */ -/* */ -/* Usage: */ -/* qsort(base, nbr_elements, width_bytes, compare_function); */ -/* void *base; */ -/* size_t nbr_elements, width_bytes; */ -/* int (*compare_function)(const void *, const void *); */ -/* */ -/* Sorts an array starting at base, of length nbr_elements, each */ -/* element of size width_bytes, ordered via compare_function, */ -/* which is called as (*compare_function)(ptr_to_element1, */ -/* ptr_to_element2) and returns < 0 if element1 < element2, */ -/* 0 if element1 = element2, > 0 if element1 > element2. */ -/* Most refinements are due to R. Sedgewick. See "Implementing */ -/* Quicksort Programs", Comm. ACM, Oct. 1978, and Corrigendum, */ -/* Comm. ACM, June 1979. */ -/******************************************************************/ - -// modified to take (and use) a context object, ala Microsoft's qsort_s -// "extension" to the stdlib - -#include /* for size_t definition */ - -/* -** swap nbytes between a and b -*/ - -static void swap_bytes(char *a, char *b, size_t nbytes) -{ - char tmp; - do { - tmp = *a; *a++ = *b; *b++ = tmp; - } while ( --nbytes ); -} - -#define SWAP(a, b) (swap_bytes((char *)(a), (char *)(b), size)) - -#define COMP(ctx, a, b) ((*comp)((void *)ctx, (void *)(a), (void *)(b))) - -#define T 7 /* subfiles of T or fewer elements will */ - /* be sorted by a simple insertion sort */ - /* Note! T must be at least 3 */ - -extern "C" void qsort_s(void *basep, size_t nelems, size_t size, - int (*comp)(void *, const void *, const void *), - void *ctx) -{ - char *stack[40], **sp; /* stack and stack pointer */ - char *i, *j, *limit; /* scan and limit pointers */ - size_t thresh; /* size of T elements in bytes */ - char *base; /* base pointer as char * */ - - base = (char *)basep; /* set up char * base pointer */ - thresh = T * size; /* init threshold */ - sp = stack; /* init stack pointer */ - limit = base + nelems * size;/* pointer past end of array */ - for ( ;; ) { /* repeat until break... */ - if ( limit - base > thresh ) { /* if more than T elements */ - /* swap base with middle */ - SWAP((((limit-base)/size)/2)*size+base, base); - i = base + size; /* i scans left to right */ - j = limit - size; /* j scans right to left */ - if ( COMP(ctx, i, j) > 0 ) /* Sedgewick's */ - SWAP(i, j); /* three-element sort */ - if ( COMP(ctx, base, j) > 0 )/* sets things up */ - SWAP(base, j); /* so that */ - if ( COMP(ctx, i, base) > 0 )/* *i <= *base <= *j */ - SWAP(i, base); /* *base is pivot element */ - for ( ;; ) { /* loop until break */ - do /* move i right */ - i += size; /* until *i >= pivot */ - while ( COMP(ctx, i, base) < 0 ); - do /* move j left */ - j -= size; /* until *j <= pivot */ - while ( COMP(ctx, j, base) > 0 ); - if ( i > j ) /* if pointers crossed */ - break; /* break loop */ - SWAP(i, j); /* else swap elements, keep scanning*/ - } - SWAP(base, j); /* move pivot into correct place */ - if ( j - base > limit - i ) { /* if left subfile larger */ - sp[0] = base; /* stack left subfile base */ - sp[1] = j; /* and limit */ - base = i; /* sort the right subfile */ - } else { /* else right subfile larger*/ - sp[0] = i; /* stack right subfile base */ - sp[1] = limit; /* and limit */ - limit = j; /* sort the left subfile */ - } - sp += 2; /* increment stack pointer */ - } else { /* else subfile is small, use insertion sort */ - for ( j = base, i = j+size; i < limit; j = i, i += size ) - for ( ; COMP(ctx, j, j+size) > 0; j -= size ) { - SWAP(j, j+size); - if ( j == base ) - break; - } - if ( sp != stack ) { /* if any entries on stack */ - sp -= 2; /* pop the base and limit */ - base = sp[0]; - limit = sp[1]; - } else /* else stack empty, done */ - break; - } - } -} - - +/******************************************************************/ +/* qsort.c -- Non-Recursive ANSI Quicksort function */ +/* */ +/* Public domain by Raymond Gardner, Englewood CO February 1991 */ +/* */ +/* Usage: */ +/* qsort(base, nbr_elements, width_bytes, compare_function); */ +/* void *base; */ +/* size_t nbr_elements, width_bytes; */ +/* int (*compare_function)(const void *, const void *); */ +/* */ +/* Sorts an array starting at base, of length nbr_elements, each */ +/* element of size width_bytes, ordered via compare_function, */ +/* which is called as (*compare_function)(ptr_to_element1, */ +/* ptr_to_element2) and returns < 0 if element1 < element2, */ +/* 0 if element1 = element2, > 0 if element1 > element2. */ +/* Most refinements are due to R. Sedgewick. See "Implementing */ +/* Quicksort Programs", Comm. ACM, Oct. 1978, and Corrigendum, */ +/* Comm. ACM, June 1979. */ +/******************************************************************/ + +// modified to take (and use) a context object, ala Microsoft's qsort_s +// "extension" to the stdlib + +#include /* for size_t definition */ + +/* +** swap nbytes between a and b +*/ + +static void swap_bytes(char *a, char *b, size_t nbytes) +{ + char tmp; + do { + tmp = *a; *a++ = *b; *b++ = tmp; + } while ( --nbytes ); +} + +#define SWAP(a, b) (swap_bytes((char *)(a), (char *)(b), size)) + +#define COMP(ctx, a, b) ((*comp)((void *)ctx, (void *)(a), (void *)(b))) + +#define T 7 /* subfiles of T or fewer elements will */ + /* be sorted by a simple insertion sort */ + /* Note! T must be at least 3 */ + +extern "C" void qsort_s(void *basep, size_t nelems, size_t size, + int (*comp)(void *, const void *, const void *), + void *ctx) +{ + char *stack[40], **sp; /* stack and stack pointer */ + char *i, *j, *limit; /* scan and limit pointers */ + size_t thresh; /* size of T elements in bytes */ + char *base; /* base pointer as char * */ + + base = (char *)basep; /* set up char * base pointer */ + thresh = T * size; /* init threshold */ + sp = stack; /* init stack pointer */ + limit = base + nelems * size;/* pointer past end of array */ + for ( ;; ) { /* repeat until break... */ + if ( limit - base > thresh ) { /* if more than T elements */ + /* swap base with middle */ + SWAP((((limit-base)/size)/2)*size+base, base); + i = base + size; /* i scans left to right */ + j = limit - size; /* j scans right to left */ + if ( COMP(ctx, i, j) > 0 ) /* Sedgewick's */ + SWAP(i, j); /* three-element sort */ + if ( COMP(ctx, base, j) > 0 )/* sets things up */ + SWAP(base, j); /* so that */ + if ( COMP(ctx, i, base) > 0 )/* *i <= *base <= *j */ + SWAP(i, base); /* *base is pivot element */ + for ( ;; ) { /* loop until break */ + do /* move i right */ + i += size; /* until *i >= pivot */ + while ( COMP(ctx, i, base) < 0 ); + do /* move j left */ + j -= size; /* until *j <= pivot */ + while ( COMP(ctx, j, base) > 0 ); + if ( i > j ) /* if pointers crossed */ + break; /* break loop */ + SWAP(i, j); /* else swap elements, keep scanning*/ + } + SWAP(base, j); /* move pivot into correct place */ + if ( j - base > limit - i ) { /* if left subfile larger */ + sp[0] = base; /* stack left subfile base */ + sp[1] = j; /* and limit */ + base = i; /* sort the right subfile */ + } else { /* else right subfile larger*/ + sp[0] = i; /* stack right subfile base */ + sp[1] = limit; /* and limit */ + limit = j; /* sort the left subfile */ + } + sp += 2; /* increment stack pointer */ + } else { /* else subfile is small, use insertion sort */ + for ( j = base, i = j+size; i < limit; j = i, i += size ) + for ( ; COMP(ctx, j, j+size) > 0; j -= size ) { + SWAP(j, j+size); + if ( j == base ) + break; + } + if ( sp != stack ) { /* if any entries on stack */ + sp -= 2; /* pop the base and limit */ + base = sp[0]; + limit = sp[1]; + } else /* else stack empty, done */ + break; + } + } +} + + diff --git a/sp/src/tier1/snappy-stubs-internal.h b/sp/src/tier1/snappy-stubs-internal.h index 94468ba8..ec5d1018 100644 --- a/sp/src/tier1/snappy-stubs-internal.h +++ b/sp/src/tier1/snappy-stubs-internal.h @@ -138,8 +138,8 @@ class LogMessage { class LogMessageCrash : public LogMessage { public: LogMessageCrash() { } -#if _MSC_VER == 1700 -// Bogus warning from VS 2012: +#if _MSC_VER == 1700 || _MSC_VER == 1800 +// Bogus warning from VS 2012 and VS 2013: // warning C4722: 'snappy::LogMessageCrash::~LogMessageCrash' : destructor never returns, potential memory leak #pragma warning(push) #pragma warning(disable : 4722) @@ -150,7 +150,7 @@ class LogMessageCrash : public LogMessage { abort(); } }; -#if _MSC_VER == 1700 +#if _MSC_VER == 1700 || _MSC_VER == 1800 #pragma warning(pop) #endif diff --git a/sp/src/utils/glview/glview.cpp b/sp/src/utils/glview/glview.cpp index d7da07b3..6d50de7f 100644 --- a/sp/src/utils/glview/glview.cpp +++ b/sp/src/utils/glview/glview.cpp @@ -64,7 +64,7 @@ BOOL g_Update = TRUE; BOOL g_bDisp = FALSE; IPhysicsCollision *physcollision = NULL; // ----------- -static int g_Keys[255]; +static int g_Keys[256]; void AppKeyDown( int key ); void AppKeyUp( int key ); diff --git a/sp/src/utils/height2normal/height2normal.vpc b/sp/src/utils/height2normal/height2normal.vpc index be330ee4..febd9d34 100644 --- a/sp/src/utils/height2normal/height2normal.vpc +++ b/sp/src/utils/height2normal/height2normal.vpc @@ -14,7 +14,7 @@ $Configuration $Compiler { $AdditionalIncludeDirectories "$BASE,..\common" - $PreprocessorDefinitions "_HAS_ITERATOR_DEBUGGING=0;_DEBUG;_WIN32;_CONSOLE" + $PreprocessorDefinitions "_HAS_ITERATOR_DEBUGGING=0;_WIN32;_CONSOLE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions)" } } diff --git a/sp/src/utils/qc_eyes/qc_eyes.vpc b/sp/src/utils/qc_eyes/qc_eyes.vpc index ee3b4e39..a417fd7b 100644 --- a/sp/src/utils/qc_eyes/qc_eyes.vpc +++ b/sp/src/utils/qc_eyes/qc_eyes.vpc @@ -13,10 +13,17 @@ $Configuration { $Compiler { + // Deprecated MBCS MFC libraries for VS 2013 (nafxcw.lib and nafxcwd.lib) can be downloaded from http://go.microsoft.com/?linkid=9832071 + $PreprocessorDefinitions "$BASE;NO_WARN_MBCS_MFC_DEPRECATION" $Create/UsePrecompiledHeader "Use Precompiled Header (/Yu)" $PrecompiledHeaderFile "Debug/QC_Eyes.pch" $EnableC++Exceptions "Yes (/EHsc)" } + + $Linker + { + $AdditionalDependencies "$BASE;windowscodecs.lib" + } } $Project "QC_Eyes" diff --git a/sp/src/utils/vbsp/boundbox.cpp b/sp/src/utils/vbsp/boundbox.cpp index ecb8dfa0..a62e9e2f 100644 --- a/sp/src/utils/vbsp/boundbox.cpp +++ b/sp/src/utils/vbsp/boundbox.cpp @@ -14,7 +14,7 @@ #include "tier0/memdbgon.h" -float rint(float f) +float V_rint(float f) { if (f > 0.0f) { return (float) floor(f + 0.5f); @@ -223,7 +223,7 @@ void BoundBox::GetBoundsSize(Vector& size) //----------------------------------------------------------------------------- static int Snap(/*int*/ float iValue, int iGridSize) { - return (int)(rint(iValue/iGridSize) * iGridSize); + return (int)(V_rint(iValue/iGridSize) * iGridSize); } diff --git a/sp/src/vgui2/chromehtml/html_chrome.cpp b/sp/src/vgui2/chromehtml/html_chrome.cpp index 89874400..37ba4f74 100644 --- a/sp/src/vgui2/chromehtml/html_chrome.cpp +++ b/sp/src/vgui2/chromehtml/html_chrome.cpp @@ -111,18 +111,18 @@ void CCEFThread::WakeThread() //----------------------------------------------------------------------------- #define HTML_MSG_FUNC( eHTMLCommand, bodyType, commandFunc ) \ case eHTMLCommand: \ - { \ - CHTMLProtoBufMsg< bodyType > cmd( pCmd->m_eCmd ); \ - if ( !cmd.BDeserializeCrossProc( &pCmd->m_Buffer ) ) \ - { \ - bError = true; \ - } \ +{ \ + CHTMLProtoBufMsg< bodyType > cmd( pCmd->m_eCmd ); \ + if ( !cmd.BDeserializeCrossProc( &pCmd->m_Buffer ) ) \ +{ \ + bError = true; \ +} \ else \ - { \ +{ \ cmd.Body().set_browser_handle( pCmd->m_iBrowser ); \ - g_CEFThread.commandFunc( cmd ); \ - } \ - } \ + g_CEFThread.commandFunc( cmd ); \ +} \ +} \ break; @@ -204,7 +204,7 @@ void CCEFThread::RunCurrentCommands() HTML_MSG_FUNC( eHTMLCommands_ExitFullScreen, CMsgExitFullScreen, ThreadExitFullScreen ); HTML_MSG_FUNC( eHTMLCommands_CloseFullScreenFlashIfOpen, CMsgCloseFullScreenFlashIfOpen, ThreadCloseFullScreenFlashIfOpen ); HTML_MSG_FUNC( eHTMLCommands_PauseFullScreenFlashMovieIfOpen, CMsgPauseFullScreenFlashMovieIfOpen, ThreadPauseFullScreenFlashMovieIfOpen ); - + default: bError = true; AssertMsg1( false, "Invalid message in browser stream (%d)", pCmd->m_eCmd ); @@ -351,7 +351,7 @@ bool CCEFThread::GetMainThreadCommand( HTMLCommandBuffer_t **pBuf ) return true; } else - return m_tslResponseBuffers.PopItem( pBuf ); + return m_tslResponseBuffers.PopItem( pBuf ); } @@ -376,7 +376,7 @@ bool CCEFThread::GetCEFThreadCommand( HTMLCommandBuffer_t **pBuf ) //----------------------------------------------------------------------------- const char *CCEFThread::PchWebkitUserAgent() { - return "Mozilla/5.0 (%s; U; %s; en-US; %s/%llu; %s) AppleWebKit/535.15 (KHTML, like Gecko) Chrome/18.0.989.0 Safari/535.11"; + return "Mozilla/5.0 (%s; U; %s; en-US; %s/%llu; %s) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19"; } @@ -405,7 +405,6 @@ void CCEFThread::ThreadCreateBrowser( const CHTMLProtoBufMsg CefWindowInfo info; info.SetAsOffScreen( NULL ); info.m_bPopupWindow = htmlCommand.BodyConst().popup(); - CefBrowserSettings settings; settings.fullscreen_enabled = true; settings.threaded_compositing_enabled = true; @@ -416,6 +415,28 @@ void CCEFThread::ThreadCreateBrowser( const CHTMLProtoBufMsg // ports for Mac and Linux have bugs where it is not really disabled, causing havoc settings.drag_drop_disabled = true; +#ifdef LINUX + // Turn off web features here that don't work on Linux + settings.webgl_disabled = true; +#endif + + // CEF HTML local storage, databases, and offline application cache are all busted; + // they live in a temp dir which gets cleaned up on shutdown. There's no point in + // enabling them just to generate extra files to cleanup on shutdown when there's + // no actual disk persistence. we need to upgrade CEF again before they will work. + settings.local_storage_disabled = true; + settings.databases_disabled = true; + settings.application_cache_disabled = true; + settings.java_disabled = true; + + // We don't provide a UI to connect to the WebKit developer tools API + // so there is no point having it suck up CPU and listening on a port. + settings.developer_tools_disabled = true; + + // Drag and drop is supposed to be disabled automatically for offscreen views, but + // ports for Mac and Linux have bugs where it is not really disabled, causing havoc + settings.drag_drop_disabled = true; + #ifdef LINUX // Turn off web features here that don't work on Linux settings.webgl_disabled = true; @@ -479,7 +500,7 @@ void CCEFThread::ThreadBrowserSize( const CHTMLProtoBufMsg &htm GET_BROSWER_FUNC( htmlCommand, SetSize( PET_VIEW, htmlCommand.BodyConst().width(), htmlCommand.BodyConst().height() ) ); if ( BIsValidBrowserHandle( htmlCommand.BodyConst().browser_handle(), iClient ) ) m_listClientHandlers[iClient]->SetSize( htmlCommand.BodyConst().width(), htmlCommand.BodyConst().height() ); -} + } //----------------------------------------------------------------------------- @@ -646,8 +667,8 @@ void CCEFThread::ThreadBrowserHorizontalScrollBarSizeHelper( int iBrowser, bool if ( bForceSendUpdate || 0 != memcmp( &pHandler->m_CachedHScroll, &scroll, sizeof( scroll ) ) ) { pHandler->m_CachedHScroll = scroll; - - CHTMLProtoBufMsg cmd( eHTMLCommands_HorizontalScrollBarSizeResponse ); + + CHTMLProtoBufMsg cmd( eHTMLCommands_HorizontalScrollBarSizeResponse ); cmd.Body().set_x( scroll.m_nX ); cmd.Body().set_y( scroll.m_nY ); cmd.Body().set_wide( scroll.m_nWide ); @@ -655,10 +676,10 @@ void CCEFThread::ThreadBrowserHorizontalScrollBarSizeHelper( int iBrowser, bool cmd.Body().set_scroll_max( scroll.m_nMax ); cmd.Body().set_scroll( scroll.m_nScroll ); cmd.Body().set_visible( scroll.m_bVisible != 0 ); - cmd.Body().set_zoom( flZoom ); - int m_iBrowser = iBrowser; - DISPATCH_MESSAGE( eHTMLCommands_HorizontalScrollBarSizeResponse ); - } + cmd.Body().set_zoom( flZoom ); + int m_iBrowser = iBrowser; + DISPATCH_MESSAGE( eHTMLCommands_HorizontalScrollBarSizeResponse ); +} } } @@ -701,7 +722,7 @@ void CCEFThread::ThreadBrowserVerticalScrollBarSizeHelper( int iBrowser, bool bF { pHandler->m_CachedVScroll = scroll; - CHTMLProtoBufMsg cmd( eHTMLCommands_VerticalScrollBarSizeResponse ); + CHTMLProtoBufMsg cmd( eHTMLCommands_VerticalScrollBarSizeResponse ); cmd.Body().set_x( scroll.m_nX ); cmd.Body().set_y( scroll.m_nY ); cmd.Body().set_wide( scroll.m_nWide ); @@ -709,10 +730,10 @@ void CCEFThread::ThreadBrowserVerticalScrollBarSizeHelper( int iBrowser, bool bF cmd.Body().set_scroll_max( scroll.m_nMax ); cmd.Body().set_scroll( scroll.m_nScroll ); cmd.Body().set_visible( scroll.m_bVisible != 0 ); - cmd.Body().set_zoom( flZoom ); - int m_iBrowser = iBrowser; - DISPATCH_MESSAGE( eHTMLCommands_VerticalScrollBarSizeResponse ); - } + cmd.Body().set_zoom( flZoom ); + int m_iBrowser = iBrowser; + DISPATCH_MESSAGE( eHTMLCommands_VerticalScrollBarSizeResponse ); +} } } @@ -743,7 +764,7 @@ void CCEFThread::ThreadBrowserSetHorizontalScroll( const CHTMLProtoBufMsg &htmlCmd ) //----------------------------------------------------------------------------- void IOT_SetCookie(const CefString& url, CefCookie* cookie, CThreadEvent *pEvent ) { - CefSetCookie(url, *cookie); + CefCookieManager::GetGlobalManager()->SetCookie(url, *cookie); pEvent->Set(); } @@ -936,7 +957,7 @@ private: //----------------------------------------------------------------------------- void IOT_CookiesForURL(const CefString& url, CThreadEvent *pEvent, CUtlVector *pVecCookies ) { - CefVisitUrlCookies( url, false, new CookieVisitor( pVecCookies, pEvent ) ); + CefCookieManager::GetGlobalManager()->VisitUrlCookies( url, false, new CookieVisitor( pVecCookies, pEvent ) ); } @@ -1029,7 +1050,6 @@ void CCEFThread::AppGetSettings(CefSettings& settings, CefRefPtr& app) //#endif } - //----------------------------------------------------------------------------- // Purpose: clean up the temp folders cef can leave around on crash //----------------------------------------------------------------------------- @@ -1092,12 +1112,13 @@ int CCEFThread::Run() // Populate the settings based on command line arguments. AppGetSettings(settings, app); + settings.pack_loading_disabled = true; // Initialize CEF. CefInitialize(settings, app, ""); #if defined( VPROF_ENABLED ) - //CVProfile *pProfile = GetVProfProfileForCurrentThread(); +// CVProfile *pProfile = GetVProfProfileForCurrentThread(); #endif CLimitTimer timer; @@ -1125,8 +1146,8 @@ int CCEFThread::Run() m_bSawUserInputThisFrame = false; #if defined( VPROF_ENABLED ) - //if ( pProfile ) - // pProfile->MarkFrame( "UI CEF HTML Thread" ); +// if ( pProfile ) +// pProfile->MarkFrame( "UI CEF HTML Thread" ); #endif // Limit animation frame rate timer.SetLimit( k_nMillion/m_nTargetFrameRate ); @@ -1138,7 +1159,7 @@ int CCEFThread::Run() } // now let cef think - if ( m_listClientHandlers.Count() || timerLastCefThink.BLimitReached() ) + if ( !m_bExit && ( m_listClientHandlers.Count() || timerLastCefThink.BLimitReached() ) && m_nTargetFrameRate > 0 ) { VPROF_BUDGET( "CCEFThread - CefDoMessageLoopWork()", VPROF_BUDGETGROUP_TENFOOT ); CefDoMessageLoopWork(); @@ -1314,7 +1335,7 @@ void CCEFThread::CheckForFullScreenFlashControl() } SetForegroundWindow( m_flashfullscreenHWND ); - } + } } else { @@ -1360,40 +1381,40 @@ void CCEFThread::Validate( CValidator &validator, const tchar *pchName ) // hacky but reliable way to avoid both vgui and panorama validating all this stuff twice if ( !validator.IsClaimed( m_sHTMLCacheDir.Access() ) ) { - VALIDATE_SCOPE(); - ValidateObj( m_sHTMLCacheDir ); - ValidateObj( m_sCookiePath ); - ValidateObj( m_listClientHandlers ); - FOR_EACH_LL( m_listClientHandlers, i ) - { - ValidatePtr( m_listClientHandlers[i] ); - } - ValidateObj( m_vecQueueCommands ); - FOR_EACH_VEC( m_vecQueueCommands, i ) - { - ValidatePtr( m_vecQueueCommands[i] ); - } + VALIDATE_SCOPE(); + ValidateObj( m_sHTMLCacheDir ); + ValidateObj( m_sCookiePath ); + ValidateObj( m_listClientHandlers ); + FOR_EACH_LL( m_listClientHandlers, i ) + { + ValidatePtr( m_listClientHandlers[i] ); + } + ValidateObj( m_vecQueueCommands ); + FOR_EACH_VEC( m_vecQueueCommands, i ) + { + ValidatePtr( m_vecQueueCommands[i] ); + } ValidateObj( m_vecQueueResponses ); FOR_EACH_VEC( m_vecQueueResponses, i ) { ValidatePtr( m_vecQueueResponses[i] ); } - ValidateObj( m_tslUnsedBuffers ); + ValidateObj( m_tslUnsedBuffers ); + { + CTSList::Node_t *pNode = m_tslUnsedBuffers.Detach(); + while ( pNode ) { - CTSList::Node_t *pNode = m_tslUnsedBuffers.Detach(); - while ( pNode ) - { - CTSList::Node_t *pNext = (CTSList::Node_t *)pNode->Next; - ValidatePtr( pNode->elem ); - m_tslUnsedBuffers.Push( pNode ); - pNode = pNext; - } + CTSList::Node_t *pNext = (CTSList::Node_t *)pNode->Next; + ValidatePtr( pNode->elem ); + m_tslUnsedBuffers.Push( pNode ); + pNode = pNext; } - - ValidateObj( m_tslCommandBuffers ); - ValidateObj( m_tslResponseBuffers ); } + + ValidateObj( m_tslCommandBuffers ); + ValidateObj( m_tslResponseBuffers ); +} } #endif @@ -1567,23 +1588,23 @@ void CChromePainter::OnPaint(CefRefPtr browser, PaintElementType typ { // main browser painting - if ( !m_pParent->IsVisuallyNonEmpty() ) - { - return; - } + if ( !m_pParent->IsVisuallyNonEmpty() ) + { + return; + } // If there were no dirty regions (unlikely), perhaps due to a bug, be conservative and paint all if ( dirtyRects.empty() ) - { + { m_MainTexture.MarkAllDirty(); - } - else - { + } + else + { for ( RectList::const_iterator iter = dirtyRects.begin(); iter != dirtyRects.end(); ++iter ) - { + { m_MainTexture.MarkDirtyRect( iter->x, iter->y, iter->x + iter->width, iter->y + iter->height ); - } - } + } + } // Refresh all dirty main texture pixels from the chromium rendering buffer if ( m_MainTexture.BUpdatePixels( (byte*)buffer, wide, tall ) ) @@ -1629,7 +1650,7 @@ void CChromePainter::SetUpdated( bool state ) // Purpose: move to the next html texture to render into //----------------------------------------------------------------------------- uint32 CChromePainter::FlipTexture() -{ +{ int iTex = m_iNextTexture; m_iTexturesInFlightBits |= ( 1< browser, if ( !frame->IsMain() ) return; - std::wstring sURL = frame->GetURL(); - if ( sURL.empty() ) - return; + std::wstring sURL = frame->GetURL(); + if ( sURL.empty() ) + return; - CStrAutoEncode url( sURL.c_str() ); - m_strCurrentUrl = url.ToString(); + CStrAutoEncode url( sURL.c_str() ); + m_strCurrentUrl = url.ToString(); - if ( m_strCurrentUrl.IsEmpty() ) - return; + if ( m_strCurrentUrl.IsEmpty() ) + return; - bool bIsRedirect = false; - if ( m_strCurrentUrl == m_strLastRedirectURL ) - bIsRedirect = true; + bool bIsRedirect = false; + if ( m_strCurrentUrl == m_strLastRedirectURL ) + bIsRedirect = true; - CHTMLProtoBufMsg cmd( eHTMLCommands_URLChanged ); - cmd.Body().set_url( url.ToString() ); + CHTMLProtoBufMsg cmd( eHTMLCommands_URLChanged ); + cmd.Body().set_url( url.ToString() ); cmd.Body().set_bnewnavigation( bIsNewNavigation ); - - if ( !m_strPostData.IsEmpty() ) + + if ( !m_strPostData.IsEmpty() ) cmd.Body().set_postdata( m_strPostData.String() ); - cmd.Body().set_bisredirect( bIsRedirect ); - CefString frameName = frame->GetName(); - if ( !frameName.empty() ) - cmd.Body().set_pagetitle( frameName.c_str() ); + cmd.Body().set_bisredirect( bIsRedirect ); + CefString frameName = frame->GetName(); + if ( !frameName.empty() ) + cmd.Body().set_pagetitle( frameName.c_str() ); - DISPATCH_MESSAGE( eHTMLCommands_URLChanged ); - } + DISPATCH_MESSAGE( eHTMLCommands_URLChanged ); +} { CHTMLProtoBufMsg cmd( eHTMLCommands_CanGoBackandForward ); @@ -2420,10 +2441,10 @@ bool CClientHandler::OnTooltip(CefRefPtr browser, CefString& text) { m_strToolTip = text.c_str(); - CHTMLProtoBufMsg cmd( eHTMLCommands_UpdateToolTip ); + CHTMLProtoBufMsg cmd( eHTMLCommands_UpdateToolTip ); cmd.Body().set_text( m_strToolTip ); - DISPATCH_MESSAGE( eHTMLCommands_UpdateToolTip ); - } + DISPATCH_MESSAGE( eHTMLCommands_UpdateToolTip ); + } } else if ( m_bShowingToolTip ) { @@ -2612,9 +2633,9 @@ bool CChromePainter::OnFileOpenDialog( CefRefPtr browser, bool bMult { if ( !cmd.BodyConst().files(i).empty() ) { - CPathString path( cmd.BodyConst().files(i).c_str() ); - files.push_back( path.GetWCharPathPrePended() ); - } + CPathString path( cmd.BodyConst().files(i).c_str() ); + files.push_back( path.GetWCharPathPrePended() ); + } } // if you have a DEBUG build and are crashing here it is because @@ -2853,7 +2874,7 @@ void CClientHandler::SetMouseLocation( int nMouseX, int nMouseY ) m_nMouseScrolledY = nMouseY + m_Browser->HorizontalScroll(); m_bMouseFocus = true; m_Browser->SendMouseMoveEvent( m_nMouseX, m_nMouseY, false ); - } +} } //----------------------------------------------------------------------------- @@ -2952,7 +2973,7 @@ const byte *CClientHandler::PComposedTextureData( uint32 iTexture ) VPROF_BUDGET( "CClientHandler::PTextureData", VPROF_BUDGETGROUP_VGUI ); return m_Painter.PComposedTextureData( iTexture ); -} + } //----------------------------------------------------------------------------- @@ -3048,12 +3069,13 @@ void CCEFThread::ThreadLinkAtPosition( const CHTMLProtoBufMsgGetBrowser() ) - pchURL = m_listClientHandlers[iClient]->GetBrowser()->GetLinkAtPosition( htmlCommand.BodyConst().x(), htmlCommand.BodyConst().y(), bLiveLink, bInput ); + m_listClientHandlers[iClient]->GetBrowser()->GetLinkAtPosition( htmlCommand.BodyConst().x(), htmlCommand.BodyConst().y(), + pchURL, bLiveLink, bInput); } CHTMLProtoBufMsg cmd( eHTMLCommands_LinkAtPositionResponse ); @@ -3079,9 +3101,9 @@ void CCEFThread::ThreadZoomToElementAtPosition( const CHTMLProtoBufMsgGetBrowser() ) { CefRect initialRect, finalRect; - float zoomLevel = m_listClientHandlers[iClient]->GetBrowser()->scalePageToFitElementAt( - htmlCommand.BodyConst().x(), htmlCommand.BodyConst().y(), - initialRect, finalRect ); + float zoomLevel = m_listClientHandlers[iClient]->GetBrowser()->scalePageToFitElementAt( + htmlCommand.BodyConst().x(), htmlCommand.BodyConst().y(), + initialRect, finalRect ); int m_iBrowser = htmlCommand.BodyConst().browser_handle(); ThreadBrowserVerticalScrollBarSizeHelper( m_iBrowser, true ); ThreadBrowserHorizontalScrollBarSizeHelper( m_iBrowser, true ); @@ -3100,7 +3122,7 @@ void CCEFThread::ThreadZoomToElementAtPosition( const CHTMLProtoBufMsg &htmlC int nMouseX, nMouseY; m_listClientHandlers[ iClient ]->GetMouseLocation( nMouseX, nMouseY ); - browser->SendMouseWheelEvent( nMouseX, nMouseY, htmlCommand.BodyConst().delta() ); + browser->SendMouseWheelEvent( nMouseX, nMouseY, 0, htmlCommand.BodyConst().delta() ); } } @@ -3374,7 +3396,13 @@ void CCEFThread::ThreadKeyTyped( const CHTMLProtoBufMsg &htmlComman if ( !browser.get() ) return; - browser->SendKeyEvent( KT_CHAR, htmlCommand.BodyConst().unichar(), 0, false, false ); + CefKeyInfo keyInfo; +#ifdef OSX + keyInfo.character = htmlCommand.BodyConst().unichar(); +#else + keyInfo.key = htmlCommand.BodyConst().unichar(); +#endif + browser->SendKeyEvent( KT_CHAR, keyInfo, 0 ); } } @@ -3391,7 +3419,13 @@ void CCEFThread::ThreadKeyDown( const CHTMLProtoBufMsg &htmlCommand if ( !browser.get() ) return; - browser->SendKeyEvent( KT_KEYDOWN, htmlCommand.BodyConst().keycode(), htmlCommand.BodyConst().modifiers(), false, false ); + CefKeyInfo keyInfo; +#ifdef OSX + keyInfo.keyCode = htmlCommand.BodyConst().keycode(); +#else + keyInfo.key = htmlCommand.BodyConst().keycode(); +#endif + browser->SendKeyEvent( KT_KEYDOWN, keyInfo, htmlCommand.BodyConst().modifiers() ); } } @@ -3408,7 +3442,13 @@ void CCEFThread::ThreadKeyUp( const CHTMLProtoBufMsg &htmlCommand ) if ( !browser.get() ) return; - browser->SendKeyEvent( KT_KEYUP, htmlCommand.BodyConst().keycode(), htmlCommand.BodyConst().modifiers(), false, false ); + CefKeyInfo keyInfo; +#ifdef OSX + keyInfo.keyCode = htmlCommand.BodyConst().keycode(); +#else + keyInfo.key = htmlCommand.BodyConst().keycode(); +#endif + browser->SendKeyEvent( KT_KEYUP, keyInfo, htmlCommand.BodyConst().modifiers() ); } } diff --git a/sp/src/vpc_scripts/platform_dirs.vpc b/sp/src/vpc_scripts/platform_dirs.vpc index 60c795c2..65d0b979 100644 --- a/sp/src/vpc_scripts/platform_dirs.vpc +++ b/sp/src/vpc_scripts/platform_dirs.vpc @@ -1,4 +1,4 @@ -$Macro PLATSUBDIR "\." [$WIN32] +$Macro PLATSUBDIR "\." [$WIN32] $Macro PLATSUBDIR "\x64" [$WIN64] $Macro PLATSUBDIR "\." [$X360] $Macro PLATSUBDIR "\linux32" [$LINUX32] diff --git a/sp/src/vpc_scripts/source_dll_win32_base.vpc b/sp/src/vpc_scripts/source_dll_win32_base.vpc index fea67c51..1507687e 100644 --- a/sp/src/vpc_scripts/source_dll_win32_base.vpc +++ b/sp/src/vpc_scripts/source_dll_win32_base.vpc @@ -39,7 +39,7 @@ $Configuration $Compiler [$WIN32] { - $EnableEnhancedInstructionSet "Streaming SIMD Extensions 2 (/arch:SSE2)" + $EnableEnhancedInstructionSet "Streaming SIMD Extensions (/arch:SSE)" } $Linker @@ -103,6 +103,23 @@ $Project } } } + + // Implement __imp__EncodePointer and __imp__DecodePointer so that we can run on XP SP1 + // when building with VS 2010. + $File "$SRCDIR\public\tier0\pointeroverride.asm" [$WIN32 && $VS2010] + { + $Configuration + { + $CustomBuildStep + { + // General + $CommandLine "$QUOTE$(VCInstallDir)bin\ml.exe$QUOTE /safeseh /c /Cp /Zi /Fo$QUOTE$(IntDir)\$(InputName).obj$QUOTE $QUOTE$(InputPath)$QUOTE" + $Description "Compiling pointeroverride.asm" + $Outputs "$(IntDir)\$(InputName).obj" + } + } + } + $File "$SRCDIR\common\debug_dll_check.cpp" [!$SOURCESDK] { $Configuration diff --git a/sp/src/vpc_scripts/source_dll_win32_debug.vpc b/sp/src/vpc_scripts/source_dll_win32_debug.vpc index f6e18696..aa8ebf13 100644 --- a/sp/src/vpc_scripts/source_dll_win32_debug.vpc +++ b/sp/src/vpc_scripts/source_dll_win32_debug.vpc @@ -74,7 +74,7 @@ $Configuration "Debug" $WholeProgramOptimization // Preprocessor - $PreprocessorDefinitions "$BASE;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "$BASE;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions)" $IgnoreStandardIncludePath $GeneratePreprocessedFile $KeepComments @@ -132,8 +132,7 @@ $Configuration "Debug" $OmitDefaultLibraryNames $ErrorReporting "Prompt Immediately (/errorReport:prompt)" - // Command Line (L4D adding /MP) - $AdditionalOptions "/MP /Zm200" + $AdditionalOptions "/Zm200" } $Linker @@ -225,6 +224,8 @@ $Configuration "Debug" $DelaySign $ErrorReporting "Prompt Immediately (/ERRORREPORT:PROMPT)" $CLRUnmanagedCodeCheck + // SAFE_SEH should always be disabled on debug builds. + $ImageHasSafeExceptionHandlers "false" // Command Line $AdditionalOptions @@ -283,7 +284,7 @@ $Configuration "Debug" $Resources { // General - $PreprocessorDefinitions "$BASE;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "$BASE;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)" $Culture "English (United States) (0x409)" $AdditionalIncludeDirectories $IgnoreStandardIncludePath diff --git a/sp/src/vpc_scripts/source_dll_win32_release.vpc b/sp/src/vpc_scripts/source_dll_win32_release.vpc index fb17d0fb..916045f5 100644 --- a/sp/src/vpc_scripts/source_dll_win32_release.vpc +++ b/sp/src/vpc_scripts/source_dll_win32_release.vpc @@ -81,7 +81,7 @@ $Configuration "Release" $WholeProgramOptimization // Preprocessor - $PreprocessorDefinitions "$BASE;WIN32;_WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "$BASE;WIN32;_WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions)" $PreprocessorDefinitions "$BASE;RELEASE_ASSERTS" [$RELEASEASSERTS] $IgnoreStandardIncludePath $GeneratePreprocessedFile @@ -141,8 +141,7 @@ $Configuration "Release" $OmitDefaultLibraryNames $ErrorReporting "Prompt Immediately (/errorReport:prompt)" - // Command Line (L4D adding /MP) - $AdditionalOptions "/MP /Zm200" + $AdditionalOptions "/Zm200" // Enable extra debugging information. $AdditionalOptions "$BASE /d2Zi+" [$VS2010] $AdditionalOptions "$BASE /Oy-" [$NOFPO] @@ -248,6 +247,8 @@ $Configuration "Release" $DelaySign $ErrorReporting "Prompt Immediately (/ERRORREPORT:PROMPT)" $CLRUnmanagedCodeCheck + // Most DLLs cannot yet handle SafeSEH + $ImageHasSafeExceptionHandlers "false" // Command Line $AdditionalOptions @@ -306,7 +307,7 @@ $Configuration "Release" $Resources { // General - $PreprocessorDefinitions "$BASE;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "$BASE;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)" $Culture "English (United States) (0x409)" $AdditionalIncludeDirectories $IgnoreStandardIncludePath diff --git a/sp/src/vpc_scripts/source_exe_win_win32_base.vpc b/sp/src/vpc_scripts/source_exe_win_win32_base.vpc index 9a79a68d..22b3896f 100644 --- a/sp/src/vpc_scripts/source_exe_win_win32_base.vpc +++ b/sp/src/vpc_scripts/source_exe_win_win32_base.vpc @@ -39,7 +39,7 @@ $Configuration $Compiler [$WIN32] { - $EnableEnhancedInstructionSet "Streaming SIMD Extensions 2 (/arch:SSE2)" + $EnableEnhancedInstructionSet "Streaming SIMD Extensions (/arch:SSE)" } $Linker @@ -98,6 +98,22 @@ $Project } } } + + // Implement __imp__EncodePointer and __imp__DecodePointer so that we can run on XP SP1 + // when building with VS 2010. + $File "$SRCDIR\public\tier0\pointeroverride.asm" [$WIN32 && $VS2010] + { + $Configuration + { + $CustomBuildStep + { + // General + $CommandLine "$QUOTE$(VCInstallDir)bin\ml.exe$QUOTE /c /Cp /Zi /Fo$QUOTE$(IntDir)\$(InputName).obj$QUOTE $QUOTE$(InputPath)$QUOTE" + $Description "Compiling pointeroverride.asm" + $Outputs "$(IntDir)\$(InputName).obj" + } + } + } } $Folder "Link Libraries" diff --git a/sp/src/vpc_scripts/source_exe_win_win32_debug.vpc b/sp/src/vpc_scripts/source_exe_win_win32_debug.vpc index 725883ed..302d80e9 100644 --- a/sp/src/vpc_scripts/source_exe_win_win32_debug.vpc +++ b/sp/src/vpc_scripts/source_exe_win_win32_debug.vpc @@ -74,7 +74,7 @@ $Configuration "Debug" $WholeProgramOptimization // Preprocessor - $PreprocessorDefinitions "$BASE;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "$BASE;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions)" $IgnoreStandardIncludePath $GeneratePreprocessedFile $KeepComments @@ -229,6 +229,8 @@ $Configuration "Debug" $DelaySign $ErrorReporting "Prompt Immediately (/ERRORREPORT:PROMPT)" $CLRUnmanagedCodeCheck + // SAFE_SEH should always be disabled on debug builds. + $ImageHasSafeExceptionHandlers "false" // Command Line $AdditionalOptions @@ -287,7 +289,7 @@ $Configuration "Debug" $Resources { // General - $PreprocessorDefinitions "_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)" $Culture "English (United States) (0x409)" $AdditionalIncludeDirectories $IgnoreStandardIncludePath @@ -327,4 +329,4 @@ $Configuration "Debug" $Outputs $AdditionalDependencies } -} \ No newline at end of file +} diff --git a/sp/src/vpc_scripts/source_exe_win_win32_release.vpc b/sp/src/vpc_scripts/source_exe_win_win32_release.vpc index 6f74c508..d3370146 100644 --- a/sp/src/vpc_scripts/source_exe_win_win32_release.vpc +++ b/sp/src/vpc_scripts/source_exe_win_win32_release.vpc @@ -81,7 +81,7 @@ $Configuration "Release" $WholeProgramOptimization // Preprocessor - $PreprocessorDefinitions "$BASE;WIN32;_WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "$BASE;WIN32;_WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions)" $PreprocessorDefinitions "$BASE;RELEASE_ASSERTS" [$RELEASEASSERTS] $IgnoreStandardIncludePath $GeneratePreprocessedFile @@ -247,6 +247,8 @@ $Configuration "Release" $DelaySign $ErrorReporting "Prompt Immediately (/ERRORREPORT:PROMPT)" $CLRUnmanagedCodeCheck + // Most DLLs cannot yet handle SafeSEH + $ImageHasSafeExceptionHandlers "false" // Command Line $AdditionalOptions @@ -305,7 +307,7 @@ $Configuration "Release" $Resources { // General - $PreprocessorDefinitions "NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)" $Culture "English (United States) (0x409)" $AdditionalIncludeDirectories $IgnoreStandardIncludePath diff --git a/sp/src/vpc_scripts/source_lib_win32_base.vpc b/sp/src/vpc_scripts/source_lib_win32_base.vpc index 0eb822ab..c5f8e0b5 100644 --- a/sp/src/vpc_scripts/source_lib_win32_base.vpc +++ b/sp/src/vpc_scripts/source_lib_win32_base.vpc @@ -38,7 +38,7 @@ $Configuration $Compiler [$WIN32] { - $EnableEnhancedInstructionSet "Streaming SIMD Extensions 2 (/arch:SSE2)" + $EnableEnhancedInstructionSet "Streaming SIMD Extensions (/arch:SSE)" } $PreBuildEvent diff --git a/sp/src/vpc_scripts/source_lib_win32_debug.vpc b/sp/src/vpc_scripts/source_lib_win32_debug.vpc index cf82df16..cefc44f4 100644 --- a/sp/src/vpc_scripts/source_lib_win32_debug.vpc +++ b/sp/src/vpc_scripts/source_lib_win32_debug.vpc @@ -75,7 +75,7 @@ $Configuration "Debug" $WholeProgramOptimization // Preprocessor - $PreprocessorDefinitions "$BASE;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "$BASE;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions)" $IgnoreStandardIncludePath $GeneratePreprocessedFile $KeepComments @@ -136,9 +136,6 @@ $Configuration "Debug" $UseFullPaths "Yes (/FC)" $OmitDefaultLibraryNames $ErrorReporting "Prompt Immediately (/errorReport:prompt)" - - // Command Line (L4D adding /MP) - $AdditionalOptions "/MP" [$VS2005] } $Librarian diff --git a/sp/src/vpc_scripts/source_lib_win32_release.vpc b/sp/src/vpc_scripts/source_lib_win32_release.vpc index c87a13b7..b6f54059 100644 --- a/sp/src/vpc_scripts/source_lib_win32_release.vpc +++ b/sp/src/vpc_scripts/source_lib_win32_release.vpc @@ -82,7 +82,7 @@ $Configuration "Release" $WholeProgramOptimization // Preprocessor - $PreprocessorDefinitions "$BASE;WIN32;_WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + $PreprocessorDefinitions "$BASE;WIN32;_WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_ALLOW_RUNTIME_LIBRARY_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_MSC_VER_MISMATCH;%(PreprocessorDefinitions)" $PreprocessorDefinitions "$BASE;RELEASE_ASSERTS" [$RELEASEASSERTS] $IgnoreStandardIncludePath $GeneratePreprocessedFile @@ -142,10 +142,8 @@ $Configuration "Release" $OmitDefaultLibraryNames $ErrorReporting "Prompt Immediately (/errorReport:prompt)" - // Command Line (L4D adding /MP) - $AdditionalOptions "/MP" // Enable extra debugging information. - $AdditionalOptions "$BASE /d2Zi+" [$VS2010] + $AdditionalOptions "/d2Zi+" [$VS2010] $AdditionalOptions "$BASE /Oy-" [$NOFPO] } diff --git a/sp/src/vpc_scripts/source_win32_base.vpc b/sp/src/vpc_scripts/source_win32_base.vpc index 60968484..3749a07a 100644 --- a/sp/src/vpc_scripts/source_win32_base.vpc +++ b/sp/src/vpc_scripts/source_win32_base.vpc @@ -3,8 +3,10 @@ $Configuration $General { // Request a specific compiler toolset. - $PlatformToolset "v110" [$VS2012] // VS 11 - $PlatformToolset "v120" [$VS2013] // VS 12 + $PlatformToolset "v110_xp" [$VS2012 && !$ANALYZE] // VS 2012 targeting Windows XP - http://msdn.microsoft.com/en-us/library/vstudio/jj851139.aspx + $PlatformToolset "v110" [$VS2012 && $ANALYZE] // VS 2012 for /analyze + $PlatformToolset "v120_xp" [$VS2013 && !$ANALYZE] // VS 2013 targeting Windows XP - http://msdn.microsoft.com/en-us/library/vstudio/jj851139.aspx + $PlatformToolset "v120" [$VS2013 && $ANALYZE] // VS 2013 for /analyze } $General @@ -15,16 +17,17 @@ $Configuration // VS 2012 compiles fine but does not link. We want to redirect to stub versions of // the tools (like link.exe and mt.exe) so that the link stage will be NOPed when // doing /analyze builds. - $ExecutableDirectories "$SRCDIR\devtools\vs_nop_tools;$BASE" [$ANALYZE && ($VS2012 || $VS2013)] + $ExecutableDirectories "$SRCDIR\devtools\vs_nop_tools;$BASE" [$ANALYZE] } $Compiler { + $MultiProcessorCompilation "True" + // warning C4316: object allocated on the heap may not be aligned 16 $DisableSpecificWarnings "$BASE;4316" [$VS2013] - // When using /analyze (triggered with /define:ANALYZE on the vpc command line) we want - // to use /MP but not at its most aggressive setting, and we want to forcibly disable lots + // When using /analyze (triggered with /define:ANALYZE on the vpc command line) we want to forcibly disable lots // of warnings (also disabled in platform.h but not everybody includes that). // See platform.h for the list of warnings with explanations. // warning C6318: Ill-defined __try/__except: use of the constant EXCEPTION_CONTINUE_SEARCH -- bogus @@ -33,7 +36,9 @@ $Configuration // Note that /analyze for VS 2010 only works with the 32-bit compiler, but for VS 2012 it works on 64-bit // as well. $DisableSpecificWarnings "$BASE;6308;6255;6387;6309;6011;6211;6031;6326;6239;6285;6237;6235;6240;6323;6326;6335;6320;6250;6384;6318;6322" [$ANALYZE] - $AdditionalOptions "$BASE /MP3 /analyze /analyze:stacksize100000" [$ANALYZE] + // See http://randomascii.wordpress.com/2011/10/04/analyzecommand-line-options/ for details on these options. + // /analyze:only may result in fewer warnings being reported, but the warnings it misses should show up in the regular build. + $AdditionalOptions "$BASE /analyze /analyze:only /analyze:stacksize100000" [$ANALYZE] // Specify /define:ALLOWSHADOWING to suppress variable shadowing warnings $DisableSpecificWarnings "$BASE;6244;6246" [$ANALYZE && $ALLOWSHADOWING]