Browse Source

Export NvOptimusEnablement global variable to signal Nvidia drivers to use high-performance graphics

master
C. J. Howard 4 years ago
parent
commit
2c951cf418
2 changed files with 39 additions and 0 deletions
  1. +12
    -0
      CMakeLists.txt
  2. +27
    -0
      src/platform/windows/nvidia.cpp

+ 12
- 0
CMakeLists.txt View File

@ -35,7 +35,19 @@ configure_file(${PROJECT_SOURCE_DIR}/src/configuration.hpp.in
file(GLOB_RECURSE SOURCE_FILES
${PROJECT_SOURCE_DIR}/src/*.cpp)
# Remove platform-specific source files
set(EXCLUDE_DIR "${PROJECT_SOURCE_DIR}/src/platform/")
foreach(TMP_PATH ${SOURCE_FILES})
string(FIND ${TMP_PATH} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND)
if (NOT ${EXCLUDE_DIR_FOUND} EQUAL -1)
list(REMOVE_ITEM SOURCE_FILES ${TMP_PATH})
endif ()
endforeach(TMP_PATH)
if(MSVC)
# Add platform-specific source files
list(APPEND SOURCE_FILES "${PROJECT_SOURCE_DIR}/src/platform/windows/nvidia.cpp")
# Generate Windows icon resource file
set(ICON_FILE "${PROJECT_SOURCE_DIR}/../antkeeper-data/src/icons/antkeeper.ico")
configure_file(${PROJECT_SOURCE_DIR}/src/platform/windows/icon.rc.in

+ 27
- 0
src/platform/windows/nvidia.cpp View File

@ -0,0 +1,27 @@
/*
* Copyright (C) 2020 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
// Direct Nvidia Optimus to use high-performance graphics
extern "C"
{
_declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
}

Loading…
Cancel
Save