WIP: Restoring of the command line only builds (no GUI support).

This commit is contained in:
bubnikv 2019-04-12 12:16:44 +02:00
parent 8094cd22da
commit 349e30a39c
3 changed files with 42 additions and 13 deletions

View file

@ -6,14 +6,20 @@
#include <Windows.h>
#include <shellapi.h>
#include <wchar.h>
// Let the NVIDIA and AMD know we want to use their graphics card
// on a dual graphics card system.
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
#ifdef SLIC3R_GUI
// Let the NVIDIA and AMD know we want to use their graphics card
// on a dual graphics card system.
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
#endif /* SLIC3R_GUI */
#include <stdlib.h>
#include <stdio.h>
#include <GL/GL.h>
#ifdef SLIC3R_GUI
#include <GL/GL.h>
#endif /* SLIC3R_GUI */
#include <string>
#include <vector>
@ -23,6 +29,7 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
#include <stdio.h>
#ifdef SLIC3R_GUI
class OpenGLVersionCheck
{
public:
@ -188,6 +195,7 @@ protected:
};
bool OpenGLVersionCheck::message_pump_exit = false;
#endif /* SLIC3R_GUI */
extern "C" {
typedef int (__stdcall *Slic3rMainFunc)(int argc, wchar_t **argv);
@ -206,17 +214,23 @@ int wmain(int argc, wchar_t **argv)
std::vector<wchar_t*> argv_extended;
argv_extended.emplace_back(argv[0]);
#ifdef SLIC3R_GUI
// Here one may push some additional parameters based on the wrapper type.
bool force_mesa = false;
#endif /* SLIC3R_GUI */
for (int i = 1; i < argc; ++ i) {
#ifdef SLIC3R_GUI
if (wcscmp(argv[i], L"--sw-renderer") == 0)
force_mesa = true;
else if (wcscmp(argv[i], L"--no-sw-renderer") == 0)
force_mesa = false;
#endif /* SLIC3R_GUI */
argv_extended.emplace_back(argv[i]);
}
argv_extended.emplace_back(nullptr);
#ifdef SLIC3R_GUI
OpenGLVersionCheck opengl_version_check;
bool load_mesa =
// Forced from the command line.
@ -226,6 +240,7 @@ int wmain(int argc, wchar_t **argv)
::GetSystemMetrics(SM_REMOTESESSION) ||
// Try to load the default OpenGL driver and test its context version.
! opengl_version_check.load_opengl_dll() || ! opengl_version_check.is_version_greater_or_equal_to(2, 0);
#endif /* SLIC3R_GUI */
wchar_t path_to_exe[MAX_PATH + 1] = { 0 };
::GetModuleFileNameW(nullptr, path_to_exe, MAX_PATH);
@ -236,6 +251,7 @@ int wmain(int argc, wchar_t **argv)
_wsplitpath(path_to_exe, drive, dir, fname, ext);
_wmakepath(path_to_exe, drive, dir, nullptr, nullptr);
#ifdef SLIC3R_GUI
// https://wiki.qt.io/Cross_compiling_Mesa_for_Windows
// http://download.qt.io/development_releases/prebuilt/llvmpipe/windows/
if (load_mesa) {
@ -260,6 +276,7 @@ int wmain(int argc, wchar_t **argv)
printf("slic3r.dll was not loaded\n");
return -1;
}
#endif /* SLIC3R_GUI */
// resolve function address here
slic3r_main = (Slic3rMainFunc)GetProcAddress(hInstance_Slic3r,