mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
(Windows) Fixed some build issues and got the OpenGL shaders to work.
Also some additional code cleanup.
This commit is contained in:
parent
aa07a1094f
commit
2a852170a8
|
@ -241,16 +241,17 @@ if(NOT WIN32)
|
||||||
nanosvg)
|
nanosvg)
|
||||||
elseif(WIN32)
|
elseif(WIN32)
|
||||||
set(COMMON_LIBRARIES
|
set(COMMON_LIBRARIES
|
||||||
"${PROJECT_SOURCE_DIR}/libpugixml.dll"
|
|
||||||
"${PROJECT_SOURCE_DIR}/FreeImage.dll"
|
"${PROJECT_SOURCE_DIR}/FreeImage.dll"
|
||||||
|
"${PROJECT_SOURCE_DIR}/glew32.dll"
|
||||||
"${PROJECT_SOURCE_DIR}/libcurl-x64.dll"
|
"${PROJECT_SOURCE_DIR}/libcurl-x64.dll"
|
||||||
"${PROJECT_SOURCE_DIR}/libvlc.dll"
|
|
||||||
"${PROJECT_SOURCE_DIR}/libfreetype.dll"
|
"${PROJECT_SOURCE_DIR}/libfreetype.dll"
|
||||||
"Winmm.dll"
|
"${PROJECT_SOURCE_DIR}/libpugixml.dll"
|
||||||
"mingw32"
|
|
||||||
"${PROJECT_SOURCE_DIR}/libSDL2main.a"
|
"${PROJECT_SOURCE_DIR}/libSDL2main.a"
|
||||||
|
"${PROJECT_SOURCE_DIR}/libvlc.dll"
|
||||||
"${PROJECT_SOURCE_DIR}/SDL2.dll"
|
"${PROJECT_SOURCE_DIR}/SDL2.dll"
|
||||||
"nanosvg")
|
"mingw32"
|
||||||
|
"nanosvg"
|
||||||
|
"Winmm.dll")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
|
|
83
INSTALL.md
83
INSTALL.md
|
@ -10,9 +10,9 @@ Table of contents:
|
||||||
|
|
||||||
EmulationStation-DE is developed and compiled using both Clang/LLVM and GCC on Unix, Clang/LLVM on macOS and GCC (MinGW) on Windows. I'm intending to get Clang/LLVM working on Windows as well.
|
EmulationStation-DE is developed and compiled using both Clang/LLVM and GCC on Unix, Clang/LLVM on macOS and GCC (MinGW) on Windows. I'm intending to get Clang/LLVM working on Windows as well.
|
||||||
|
|
||||||
There are much more details regarding compilers later in this document, so read on!
|
There are more details regarding compilers later in this document.
|
||||||
|
|
||||||
Any code editor can be used of course, but I recommend [VSCodium](https://vscodium.com) or [VSCode](https://code.visualstudio.com).
|
Any code editor can be used of course, but I recommend [VSCode](https://code.visualstudio.com).
|
||||||
|
|
||||||
|
|
||||||
## Building on Unix
|
## Building on Unix
|
||||||
|
@ -20,13 +20,13 @@ Any code editor can be used of course, but I recommend [VSCodium](https://vscodi
|
||||||
The code has a few dependencies. For building, you'll need CMake and development packages for cURL, FreeImage, FreeType, libVLC, pugixml, SDL2 and RapidJSON.
|
The code has a few dependencies. For building, you'll need CMake and development packages for cURL, FreeImage, FreeType, libVLC, pugixml, SDL2 and RapidJSON.
|
||||||
|
|
||||||
**On Debian/Ubuntu:**
|
**On Debian/Ubuntu:**
|
||||||
All of the required packages can be easily installed with `apt-get`:
|
All of the required packages can be easily installed with apt-get:
|
||||||
```
|
```
|
||||||
sudo apt-get install build-essential cmake libsdl2-dev libfreeimage-dev libfreetype6-dev libcurl4-openssl-dev libpugixml-dev rapidjson-dev libasound2-dev libvlc-dev libgl1-mesa-dev
|
sudo apt-get install build-essential cmake libsdl2-dev libfreeimage-dev libfreetype6-dev libcurl4-openssl-dev libpugixml-dev rapidjson-dev libasound2-dev libvlc-dev libgl1-mesa-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
**On Fedora:**
|
**On Fedora:**
|
||||||
For this operating system, use `dnf` (with rpmfusion activated) :
|
For this operating system, use dnf (with rpmfusion activated) :
|
||||||
```
|
```
|
||||||
sudo dnf install cmake SDL2-devel freeimage-devel freetype-devel curl-devel rapidjson-devel alsa-lib-devel vlc-devel mesa-libGL-devel
|
sudo dnf install cmake SDL2-devel freeimage-devel freetype-devel curl-devel rapidjson-devel alsa-lib-devel vlc-devel mesa-libGL-devel
|
||||||
```
|
```
|
||||||
|
@ -109,7 +109,7 @@ Advantage with GCC (vs Clang):
|
||||||
*Release build: Optimizations enabled, debug info disabled, binary stripped.* \
|
*Release build: Optimizations enabled, debug info disabled, binary stripped.* \
|
||||||
*Debug build: Optimizations disabled, debug info enabled, binary not stripped.*
|
*Debug build: Optimizations disabled, debug info enabled, binary not stripped.*
|
||||||
|
|
||||||
This Clang debug build is LLVM "native", i.e. intended to be debugged using the LLVM project debugger LLDB. The problem is that this is still not well integrated with VSCodium that I use for development so I need to keep using GDB. But this is problematic as the libstd++ data required by GDB is missing in the binary, making it impossible to see the values of for instance `std::string` variables.
|
This Clang debug build is LLVM "native", i.e. intended to be debugged using the LLVM project debugger LLDB. The problem is that this is still not well integrated with VSCode that I use for development so I need to keep using GDB. But this is problematic as the libstd++ data required by GDB is missing in the binary, making it impossible to see the values of for instance `std::string` variables.
|
||||||
|
|
||||||
It's possible to activate the additional debug info needed by GDB by using the flag `-D_GLIBCXX_DEBUG`. I've added this to CMakeLists.txt when using Clang, but this bloats the binary and makes the code much slower. Actually, instead of a 4% faster application startup, it's now 36% slower! The same goes for the binary size, instead of 17% smaller it's now 17% larger.
|
It's possible to activate the additional debug info needed by GDB by using the flag `-D_GLIBCXX_DEBUG`. I've added this to CMakeLists.txt when using Clang, but this bloats the binary and makes the code much slower. Actually, instead of a 4% faster application startup, it's now 36% slower! The same goes for the binary size, instead of 17% smaller it's now 17% larger.
|
||||||
|
|
||||||
|
@ -211,7 +211,9 @@ sudo apt-get install rpm
|
||||||
|
|
||||||
## Building on macOS
|
## Building on macOS
|
||||||
|
|
||||||
EmulationStation for macOS is built using Clang/LLVM which is the default compiler for this operating system. It's pretty straightforward to build software on this OS. Although it's a bizarre Unix variant, it is still a proper system with good tools. The main deficiency (apart from a very strange window manager) is that there is no package manager and you need to register an account to install software from the App Store. There are several third party package managers though, and the use of one of them, `Homebrew`, is detailed below.
|
EmulationStation for macOS is built using Clang/LLVM which is the default compiler for this operating system. It's pretty straightforward to build software on this OS. Although it's a bizarre Unix variant with a very strange window manager, it is still a proper system with good tools. The main deficiency is that there is no native package manager, but as there are several third party package managers available, this can be partly compensated for. The use of one of them, `Homebrew`, is detailed below.
|
||||||
|
|
||||||
|
As for code editing, I use [VSCode](https://code.visualstudio.com). I suppose Xcode could be used instead but I have no experience with this tool and no interest in it as I want to use the same tools for all the operating systems that I develop on.
|
||||||
|
|
||||||
**Setting up the build tools:**
|
**Setting up the build tools:**
|
||||||
|
|
||||||
|
@ -428,25 +430,27 @@ This is a strange legacy operating system. However it's still popular, so we nee
|
||||||
|
|
||||||
I did a brief evaluation of the Microsoft Visual C++ compiler (MSVC) but as far as I'm concerned it's an abomination so I won't cover it here and it won't be supported.
|
I did a brief evaluation of the Microsoft Visual C++ compiler (MSVC) but as far as I'm concerned it's an abomination so I won't cover it here and it won't be supported.
|
||||||
|
|
||||||
|
The OpenGL library shipped with Windows is unfortunately garbage, so the OpenGL Extension Wrangler (GLEW) library needs to be used as well to provide shader support. Its installation is explained below.
|
||||||
|
|
||||||
At the moment I have only built the software using GCC on Windows, but I aim to get Clang/LLVM working at a later date.
|
At the moment I have only built the software using GCC on Windows, but I aim to get Clang/LLVM working at a later date.
|
||||||
|
|
||||||
Anyway, here's a (not so) brief summary of how to get a build environment up and running on Windows.
|
Anyway, here's a (not so) brief summary of how to get a build environment up and running on Windows.
|
||||||
|
|
||||||
**Install Git, CMake, MinGW and your code editor:**
|
**Install Git, CMake, MinGW and your code editor:**
|
||||||
|
|
||||||
[Git](https://gitforwindows.org)
|
[https://gitforwindows.org](https://gitforwindows.org)
|
||||||
|
|
||||||
[CMake](https://cmake.org/download)
|
[https://cmake.org/download](https://cmake.org/download)
|
||||||
|
|
||||||
[MinGW](https://gnutoolchains.com/mingw64)
|
[https://gnutoolchains.com/mingw64](https://gnutoolchains.com/mingw64)
|
||||||
|
|
||||||
Make a copy of `mingw64/bin/mingw32-make` to `make` just for convenience and make sure that the necessary paths are defined for the PATH environmental variable.
|
Make a copy of `mingw64/bin/mingw32-make` to `make` just for convenience and make sure that the necessary paths are defined for the PATH environmental variable.
|
||||||
|
|
||||||
I won't get into the details on how to configure Git, but there are many resources available online to support with this. The `Git Bash` shell is very useful though as it's somewhat reproducing a Unix environment using MinGW/MSYS.
|
I won't get into the details on how to configure Git, but there are many resources available online to support with this. The `Git Bash` shell is very useful though as it's somewhat reproducing a Unix environment using MinGW/MSYS.
|
||||||
|
|
||||||
Install your editor of choice. As for VSCodium it's unfortunately broken or crippled under Windows, making some important extensions impossible to install. VSCode can however be used instead.
|
Install your editor of choice, I use [VSCode](https://code.visualstudio.com).
|
||||||
|
|
||||||
It's strongly recommended to set line breaks to Unix-style (linefeed only) directly in the editor, although it can also be configured in Git for conversion during commit. The source code for EmulationStation-DE only uses Unix-style line breaks.
|
It's strongly recommended to set line breaks to Unix-style (line feed only) directly in the editor, although it can also be configured in Git for conversion during commit. The source code for EmulationStation-DE only uses Unix-style line breaks.
|
||||||
|
|
||||||
**Enable pretty printing for GDB:**
|
**Enable pretty printing for GDB:**
|
||||||
|
|
||||||
|
@ -455,7 +459,7 @@ This is useful for displaying `std::string` values for example.
|
||||||
Adjust your paths accordingly, the below are just examples of course.
|
Adjust your paths accordingly, the below are just examples of course.
|
||||||
|
|
||||||
Save a file to
|
Save a file to
|
||||||
C:/Programming/mingw64/bin/pp.gdb with the following contents:
|
C:\Programming\mingw64\bin\pp.gdb with the following contents:
|
||||||
|
|
||||||
```
|
```
|
||||||
python
|
python
|
||||||
|
@ -472,21 +476,39 @@ If using VSCode, add the following line to launch.json:
|
||||||
|
|
||||||
An equivalent setup should be possible on other code editors as well.
|
An equivalent setup should be possible on other code editors as well.
|
||||||
|
|
||||||
Note that most GDB builds for Windows have broken Python support so that pretty printing won't work. The MinGW installation recommended in the previous step works fine though.
|
Note that most GDB builds for Windows have broken Python support so that pretty printing won't work. The MinGW installation recommended in the previous step should work fine though.
|
||||||
|
|
||||||
**Download the dependency packages:**
|
**Download the dependency packages:**
|
||||||
|
|
||||||
[FreeImage](https://sourceforge.net/projects/freeimage)
|
FreeImage\
|
||||||
|
[https://sourceforge.net/projects/freeimage](https://sourceforge.net/projects/freeimage)
|
||||||
|
|
||||||
[cURL](https://curl.haxx.se/download.html)
|
cURL\
|
||||||
|
[https://curl.haxx.se/download.html](https://curl.haxx.se/download.html)
|
||||||
|
|
||||||
[SDL2](https://www.libsdl.org/download-2.0.php)
|
SDL2\
|
||||||
|
[https://www.libsdl.org/download-2.0.php](https://www.libsdl.org/download-2.0.php)
|
||||||
|
|
||||||
[libVLC](https://ftp.lysator.liu.se/pub/videolan/vlc)
|
libVLC\
|
||||||
|
[https://ftp.lysator.liu.se/pub/videolan/vlc](https://ftp.lysator.liu.se/pub/videolan/vlc)
|
||||||
|
|
||||||
Uncompress the files to a suitable directory, for example C:/Programming/Dependencies/
|
Uncompress the files for the above packages to a suitable directory, for example C:\Programming\Dependencies\
|
||||||
|
|
||||||
The following packages are not readily available for Windows, so clone the repos and build them yourself:
|
GLEW\
|
||||||
|
[http://glew.sourceforge.net](http://glew.sourceforge.net)
|
||||||
|
|
||||||
|
This library needs to be compiled from source as the pre-built libraries don't seem to work with GCC. The GitHub repo seems to be somewhat broken as well, therefore the manual download is required. It's recommended to get the source in zip format and uncompress it to the same directory as the other libraries listed above.
|
||||||
|
|
||||||
|
Now simply build the required glew32.dll library:
|
||||||
|
|
||||||
|
```
|
||||||
|
unzip glew-2.1.0.zip
|
||||||
|
cd glew-2.1.0
|
||||||
|
make
|
||||||
|
```
|
||||||
|
You will probably see a huge amount of compile warnings, and the glewinfo.exe tool may fail to build, but we don't need it so it's not an issue.
|
||||||
|
|
||||||
|
The following packages are not readily available for Windows either, so clone the repos and build them yourself:
|
||||||
|
|
||||||
[FreeType](https://www.freetype.org)
|
[FreeType](https://www.freetype.org)
|
||||||
```
|
```
|
||||||
|
@ -518,7 +540,7 @@ git checkout v1.1.0
|
||||||
|
|
||||||
**Clone the EmulationStation-DE repository:**
|
**Clone the EmulationStation-DE repository:**
|
||||||
|
|
||||||
This works the same as in Unix, just run the following:
|
This works the same as in Unix or macOS, just run the following:
|
||||||
|
|
||||||
```
|
```
|
||||||
git clone https://gitlab.com/leonstyhre/emulationstation-de
|
git clone https://gitlab.com/leonstyhre/emulationstation-de
|
||||||
|
@ -526,11 +548,11 @@ git clone https://gitlab.com/leonstyhre/emulationstation-de
|
||||||
|
|
||||||
**Setup the include directories:**
|
**Setup the include directories:**
|
||||||
|
|
||||||
As there is no standardized include directory structure in Windows and no package manager, you need to provide the include files manually.
|
As there is no standardized include directory structure in Windows, you need to provide the include files manually.
|
||||||
|
|
||||||
Make a directory in your build environment tree, for instance under `C:/Programming/include`.
|
Make a directory in your build environment tree, for instance under C:\Programming\include\
|
||||||
|
|
||||||
Copy the include files from cURL, FreeImage, FreeType, pugixml, RapidJSON, SDL2 and VLC to this directory.
|
Copy the include files from cURL, FreeImage, FreeType, GLEW, pugixml, RapidJSON, SDL2 and VLC to this directory.
|
||||||
It should then look something like this:
|
It should then look something like this:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -539,6 +561,7 @@ curl/
|
||||||
FreeImage.h
|
FreeImage.h
|
||||||
freetype/
|
freetype/
|
||||||
ft2build.h
|
ft2build.h
|
||||||
|
GL/
|
||||||
pugiconfig.hpp
|
pugiconfig.hpp
|
||||||
pugixml.hpp
|
pugixml.hpp
|
||||||
rapidjson/
|
rapidjson/
|
||||||
|
@ -554,18 +577,19 @@ Copy the following files to the `emulationstation-de` build directory. Most of t
|
||||||
|
|
||||||
```
|
```
|
||||||
FreeImage.dll
|
FreeImage.dll
|
||||||
|
glew32.dll
|
||||||
libcrypto-1_1-x64.dll (from the OpenSSL package, located in Git MinGW/MSYS under /mingw/bin/)
|
libcrypto-1_1-x64.dll (from the OpenSSL package, located in Git MinGW/MSYS under /mingw/bin/)
|
||||||
libcurl-x64.dll
|
libcurl-x64.dll
|
||||||
libfreetype.dll
|
libfreetype.dll
|
||||||
libgcc_s_seh-1.dll (located in Git MinGW/MSYS under /mingw/bin/)
|
libgcc_s_seh-1.dll (located in Git MinGW/MSYS under /mingw/bin/)
|
||||||
libpugixml.dll
|
libpugixml.dll
|
||||||
|
libSDL2main.a
|
||||||
libssl-1_1-x64.dll (from the OpenSSL package, located in Git MinGW under /mingw/bin/)
|
libssl-1_1-x64.dll (from the OpenSSL package, located in Git MinGW under /mingw/bin/)
|
||||||
libstdc++-6.dll
|
libstdc++-6.dll
|
||||||
libvlc.dll
|
libvlc.dll
|
||||||
libvlccore.dll
|
libvlccore.dll
|
||||||
libwinpthread-1.dll (located in Git MinGW under /mingw/bin/)
|
libwinpthread-1.dll (located in Git MinGW under /mingw/bin/)
|
||||||
SDL2.dll
|
SDL2.dll
|
||||||
libSDL2main.a
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The files from the MinGW installation must correspond to the version used to compile the binary.
|
The files from the MinGW installation must correspond to the version used to compile the binary.
|
||||||
|
@ -608,21 +632,22 @@ Or for a debug build:
|
||||||
cmake -G "MinGW Makefiles" -DWIN32_INCLUDE_DIR=../include -DCMAKE_BUILD_TYPE=Debug .
|
cmake -G "MinGW Makefiles" -DWIN32_INCLUDE_DIR=../include -DCMAKE_BUILD_TYPE=Debug .
|
||||||
```
|
```
|
||||||
|
|
||||||
For some reason defining the '../include' path doesn't work when running CMake from PowerShell (and no, changing to backslash doesn't help). Instead use Bash, by running from a `Git Bash` shell.
|
For some reason defining the '../include' path doesn't work when running CMake from PowerShell (and no, changing to backslash doesn't help). Instead use Bash, by running from a Git Bash shell.
|
||||||
|
|
||||||
The make command works fine directly in PowerShell though so it can be run from the VSCode terminal. Unfortunately I haven't been able to find a way to use a civilized shell from inside VSCode so we're stuck with PowerShell.
|
The make command works fine directly in PowerShell though so it can be run from the VSCode terminal.
|
||||||
|
|
||||||
Running `make -j6` (or whatever number of parallel jobs you prefer) should now build the binary.
|
Running `make -j6` (or whatever number of parallel jobs you prefer) should now build the binary.
|
||||||
|
|
||||||
Note that compilation time is much longer than on Unix, and linking time is excessive for a debug build (around 10 times longer on my computer). The debug binary is also much larger than on Unix.
|
Note that compilation time is much longer than on Unix or macOS, and linking time is excessive for a debug build (around 10 times longer on my computer). The debug binary is also much larger than on Unix.
|
||||||
|
|
||||||
**Creating an NSIS installer:**
|
**Creating an NSIS installer:**
|
||||||
|
|
||||||
To create an NSIS installer (Nullsoft Scriptable Install System) you need to first install the NSIS creation tool:
|
To create an NSIS installer (Nullsoft Scriptable Install System) you need to first install the NSIS creation tool:
|
||||||
|
|
||||||
[NSIS](https://nsis.sourceforge.io/Download)
|
NSIS\
|
||||||
|
[https://nsis.sourceforge.io/Download](https://nsis.sourceforge.io/Download)
|
||||||
|
|
||||||
Simply install the application using it's installer.
|
Simply install the application using its installer.
|
||||||
|
|
||||||
After the installation has been completed, go to the emulationstation-de directory and run cpack to generate the NSIS installer:
|
After the installation has been completed, go to the emulationstation-de directory and run cpack to generate the NSIS installer:
|
||||||
|
|
||||||
|
|
|
@ -119,9 +119,10 @@ endif()
|
||||||
# Setup for installation and package generation.
|
# Setup for installation and package generation.
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
install(TARGETS EmulationStation RUNTIME DESTINATION .)
|
install(TARGETS EmulationStation RUNTIME DESTINATION .)
|
||||||
install(FILES ../FreeImage.dll ../libcrypto-1_1-x64.dll ../libcurl-x64.dll ../libfreetype.dll
|
install(FILES ../FreeImage.dll ../glew32.dll ../libcrypto-1_1-x64.dll ../libcurl-x64.dll
|
||||||
../libgcc_s_seh-1.dll ../libpugixml.dll ../libssl-1_1-x64.dll ../libstdc++-6.dll
|
../libfreetype.dll ../libgcc_s_seh-1.dll ../libpugixml.dll ../libssl-1_1-x64.dll
|
||||||
../libvlc.dll ../libvlccore.dll ../libwinpthread-1.dll ../SDL2.dll DESTINATION .)
|
../libstdc++-6.dll ../libvlc.dll ../libvlccore.dll ../libwinpthread-1.dll
|
||||||
|
../SDL2.dll DESTINATION .)
|
||||||
install(DIRECTORY ${CMAKE_SOURCE_DIR}/plugins DESTINATION .)
|
install(DIRECTORY ${CMAKE_SOURCE_DIR}/plugins DESTINATION .)
|
||||||
install(FILES ../LICENSE DESTINATION .)
|
install(FILES ../LICENSE DESTINATION .)
|
||||||
install(DIRECTORY ${CMAKE_SOURCE_DIR}/licenses DESTINATION .)
|
install(DIRECTORY ${CMAKE_SOURCE_DIR}/licenses DESTINATION .)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
|
// EmulationStation Desktop Edition
|
||||||
// VolumeControl.cpp
|
// VolumeControl.cpp
|
||||||
//
|
//
|
||||||
// Controls system audio volume.
|
// Controls system audio volume.
|
||||||
|
@ -13,10 +15,6 @@
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN64)
|
|
||||||
#include <mmdeviceapi.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// The ALSA Audio Card and Audio Device selection code is disabled at the moment.
|
// The ALSA Audio Card and Audio Device selection code is disabled at the moment.
|
||||||
// As PulseAudio controls the sound devices for the desktop environment, it doesn't
|
// As PulseAudio controls the sound devices for the desktop environment, it doesn't
|
||||||
// make much sense to be able to select ALSA devices directly. Normally (always?)
|
// make much sense to be able to select ALSA devices directly. Normally (always?)
|
||||||
|
@ -173,14 +171,15 @@ void VolumeControl::init()
|
||||||
}
|
}
|
||||||
#elif defined(_WIN64)
|
#elif defined(_WIN64)
|
||||||
// Get windows version information.
|
// Get windows version information.
|
||||||
OSVERSIONINFOEXA osVer = {sizeof(OSVERSIONINFO)};
|
OSVERSIONINFOEXA osVer = { sizeof(OSVERSIONINFO) };
|
||||||
::GetVersionExA(reinterpret_cast<LPOSVERSIONINFOA>(&osVer));
|
::GetVersionExA(reinterpret_cast<LPOSVERSIONINFOA>(&osVer));
|
||||||
// Check windows version.
|
// Check windows version.
|
||||||
if (osVer.dwMajorVersion < 6) {
|
if (osVer.dwMajorVersion < 6) {
|
||||||
// Windows older than Vista. use mixer API. open default mixer.
|
// Windows older than Vista. use mixer API. open default mixer.
|
||||||
if (mixerHandle == nullptr) {
|
if (mixerHandle == nullptr) {
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
if (mixerOpen(&mixerHandle, 0, (DWORD_PTR)nullptr, 0, 0) == MMSYSERR_NOERROR) {
|
if (mixerOpen(&mixerHandle, 0, reinterpret_cast<DWORD_PTR>(nullptr), 0, 0) ==
|
||||||
|
MMSYSERR_NOERROR) {
|
||||||
#else
|
#else
|
||||||
if (mixerOpen(&mixerHandle, 0, nullptr, 0, 0) == MMSYSERR_NOERROR) {
|
if (mixerOpen(&mixerHandle, 0, nullptr, 0, 0) == MMSYSERR_NOERROR) {
|
||||||
#endif
|
#endif
|
||||||
|
@ -191,12 +190,13 @@ void VolumeControl::init()
|
||||||
mixerLineControls.cControls = 1;
|
mixerLineControls.cControls = 1;
|
||||||
// Id of "Speaker Out" line's volume slider.
|
// Id of "Speaker Out" line's volume slider.
|
||||||
//mixerLineControls.dwControlID = 0x00000000;
|
//mixerLineControls.dwControlID = 0x00000000;
|
||||||
//Get volume control.
|
// Get volume control.
|
||||||
mixerLineControls.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
|
mixerLineControls.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
|
||||||
mixerLineControls.pamxctrl = &mixerControl;
|
mixerLineControls.pamxctrl = &mixerControl;
|
||||||
mixerLineControls.cbmxctrl = sizeof(MIXERCONTROL);
|
mixerLineControls.cbmxctrl = sizeof(MIXERCONTROL);
|
||||||
if (mixerGetLineControls((HMIXEROBJ)mixerHandle, &mixerLineControls,
|
if (mixerGetLineControls(reinterpret_cast<HMIXEROBJ>(mixerHandle),
|
||||||
MIXER_GETLINECONTROLSF_ONEBYTYPE) != MMSYSERR_NOERROR) {
|
&mixerLineControls, MIXER_GETLINECONTROLSF_ONEBYTYPE) !=
|
||||||
|
MMSYSERR_NOERROR) {
|
||||||
LOG(LogError) <<
|
LOG(LogError) <<
|
||||||
"VolumeControl::getVolume() - Failed to get mixer volume control!";
|
"VolumeControl::getVolume() - Failed to get mixer volume control!";
|
||||||
mixerClose(mixerHandle);
|
mixerClose(mixerHandle);
|
||||||
|
@ -214,7 +214,7 @@ void VolumeControl::init()
|
||||||
CoInitialize(nullptr);
|
CoInitialize(nullptr);
|
||||||
IMMDeviceEnumerator * deviceEnumerator = nullptr;
|
IMMDeviceEnumerator * deviceEnumerator = nullptr;
|
||||||
CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_INPROC_SERVER,
|
CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_INPROC_SERVER,
|
||||||
__uuidof(IMMDeviceEnumerator), (LPVOID *)&deviceEnumerator);
|
__uuidof(IMMDeviceEnumerator), reinterpret_cast<LPVOID *>(&deviceEnumerator));
|
||||||
if (deviceEnumerator != nullptr) {
|
if (deviceEnumerator != nullptr) {
|
||||||
// Get default endpoint.
|
// Get default endpoint.
|
||||||
IMMDevice * defaultDevice = nullptr;
|
IMMDevice * defaultDevice = nullptr;
|
||||||
|
@ -222,7 +222,8 @@ void VolumeControl::init()
|
||||||
if (defaultDevice != nullptr) {
|
if (defaultDevice != nullptr) {
|
||||||
// Retrieve endpoint volume.
|
// Retrieve endpoint volume.
|
||||||
defaultDevice->Activate(__uuidof(IAudioEndpointVolume),
|
defaultDevice->Activate(__uuidof(IAudioEndpointVolume),
|
||||||
CLSCTX_INPROC_SERVER, nullptr, (LPVOID *)&endpointVolume);
|
CLSCTX_INPROC_SERVER, nullptr,
|
||||||
|
reinterpret_cast<LPVOID *>(&endpointVolume));
|
||||||
if (endpointVolume == nullptr)
|
if (endpointVolume == nullptr)
|
||||||
LOG(LogError) << "VolumeControl::init() - "
|
LOG(LogError) << "VolumeControl::init() - "
|
||||||
"Failed to get default audio endpoint volume!";
|
"Failed to get default audio endpoint volume!";
|
||||||
|
@ -315,9 +316,9 @@ int VolumeControl::getVolume() const
|
||||||
mixerControlDetails.cMultipleItems = 0;
|
mixerControlDetails.cMultipleItems = 0;
|
||||||
mixerControlDetails.paDetails = &value;
|
mixerControlDetails.paDetails = &value;
|
||||||
mixerControlDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
|
mixerControlDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
|
||||||
if (mixerGetControlDetails((HMIXEROBJ)mixerHandle, &mixerControlDetails,
|
if (mixerGetControlDetails(reinterpret_cast<HMIXEROBJ>(mixerHandle), &mixerControlDetails,
|
||||||
MIXER_GETCONTROLDETAILSF_VALUE) == MMSYSERR_NOERROR)
|
MIXER_GETCONTROLDETAILSF_VALUE) == MMSYSERR_NOERROR)
|
||||||
volume = (int)Math::round((value.dwValue * 100) / 65535.0f);
|
volume = static_cast<int>(Math::round((value.dwValue * 100) / 65535.0f));
|
||||||
else
|
else
|
||||||
LOG(LogError) << "VolumeControl::getVolume() - Failed to get mixer volume!";
|
LOG(LogError) << "VolumeControl::getVolume() - Failed to get mixer volume!";
|
||||||
}
|
}
|
||||||
|
@ -325,7 +326,7 @@ int VolumeControl::getVolume() const
|
||||||
// Windows Vista or above. use EndpointVolume API.
|
// Windows Vista or above. use EndpointVolume API.
|
||||||
float floatVolume = 0.0f; // 0-1
|
float floatVolume = 0.0f; // 0-1
|
||||||
if (endpointVolume->GetMasterVolumeLevelScalar(&floatVolume) == S_OK) {
|
if (endpointVolume->GetMasterVolumeLevelScalar(&floatVolume) == S_OK) {
|
||||||
volume = (int)Math::round(floatVolume * 100.0f);
|
volume = static_cast<int>(Math::round(floatVolume * 100.0f));
|
||||||
LOG(LogInfo) << "System audio volume is " << volume;
|
LOG(LogInfo) << "System audio volume is " << volume;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -387,7 +388,7 @@ void VolumeControl::setVolume(int volume)
|
||||||
mixerControlDetails.cMultipleItems = 0;
|
mixerControlDetails.cMultipleItems = 0;
|
||||||
mixerControlDetails.paDetails = &value;
|
mixerControlDetails.paDetails = &value;
|
||||||
mixerControlDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
|
mixerControlDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
|
||||||
if (mixerSetControlDetails((HMIXEROBJ)mixerHandle, &mixerControlDetails,
|
if (mixerSetControlDetails(reinterpret_cast<HMIXEROBJ>(mixerHandle), &mixerControlDetails,
|
||||||
MIXER_SETCONTROLDETAILSF_VALUE) != MMSYSERR_NOERROR)
|
MIXER_SETCONTROLDETAILSF_VALUE) != MMSYSERR_NOERROR)
|
||||||
LOG(LogError) << "VolumeControl::setVolume() - Failed to set mixer volume!";
|
LOG(LogError) << "VolumeControl::setVolume() - Failed to set mixer volume!";
|
||||||
}
|
}
|
||||||
|
@ -395,7 +396,7 @@ void VolumeControl::setVolume(int volume)
|
||||||
// Windows Vista or above. use EndpointVolume API.
|
// Windows Vista or above. use EndpointVolume API.
|
||||||
float floatVolume = 0.0f; // 0-1
|
float floatVolume = 0.0f; // 0-1
|
||||||
if (volume > 0)
|
if (volume > 0)
|
||||||
floatVolume = (float)volume / 100.0f;
|
floatVolume = static_cast<float>(volume) / 100.0f;
|
||||||
if (endpointVolume->SetMasterVolumeLevelScalar(floatVolume, nullptr) != S_OK)
|
if (endpointVolume->SetMasterVolumeLevelScalar(floatVolume, nullptr) != S_OK)
|
||||||
LOG(LogError) << "VolumeControl::setVolume() - Failed to set master volume!";
|
LOG(LogError) << "VolumeControl::setVolume() - Failed to set master volume!";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
|
// EmulationStation Desktop Edition
|
||||||
// VolumeControl.h
|
// VolumeControl.h
|
||||||
//
|
//
|
||||||
// Controls system audio volume.
|
// Controls system audio volume.
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#ifndef ES_APP_VOLUME_CONTROL_H
|
#ifndef ES_APP_VOLUME_CONTROL_H
|
||||||
#define ES_APP_VOLUME_CONTROL_H
|
#define ES_APP_VOLUME_CONTROL_H
|
||||||
|
|
||||||
|
@ -19,7 +20,8 @@
|
||||||
#elif defined(_WIN64)
|
#elif defined(_WIN64)
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <endpointvolume.h>
|
#include <endpointvolume.h>
|
||||||
//#include <mmeapi.h>
|
#include <mmdeviceapi.h>
|
||||||
|
#include <mmsystem.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Singleton pattern. Call getInstance() to get an object.
|
// Singleton pattern. Call getInstance() to get an object.
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
// Desktop Edition fork by Leon Styhre.
|
// Desktop Edition fork by Leon Styhre.
|
||||||
//
|
//
|
||||||
// The line length limit is 100 characters and the indentations are 4 spaces.
|
// The line length limit is 100 characters and the indentations are 4 spaces.
|
||||||
|
// Line breaks are Unix-style (line feed only).
|
||||||
//
|
//
|
||||||
// main.cpp
|
// main.cpp
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
|
// EmulationStation Desktop Edition
|
||||||
// Platform.cpp
|
// Platform.cpp
|
||||||
//
|
//
|
||||||
// Platform-specific functions.
|
// Platform-specific functions.
|
||||||
|
@ -19,13 +21,7 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN64)
|
|
||||||
#include <windows.h>
|
|
||||||
#include <codecvt>
|
|
||||||
#include <locale>
|
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
int runRebootCommand()
|
int runRebootCommand()
|
||||||
|
@ -133,16 +129,16 @@ int launchEmulatorWindows(const std::wstring& cmd_utf16)
|
||||||
DWORD errorCode = 0;
|
DWORD errorCode = 0;
|
||||||
|
|
||||||
processReturnValue = CreateProcessW(
|
processReturnValue = CreateProcessW(
|
||||||
nullptr, // No application name (use command line).
|
nullptr, // No application name (use command line).
|
||||||
(wchar_t*) cmd_utf16.c_str(), // Command line.
|
const_cast<wchar_t*>(cmd_utf16.c_str()), // Command line.
|
||||||
nullptr, // Process attributes.
|
nullptr, // Process attributes.
|
||||||
nullptr, // Thread attributes.
|
nullptr, // Thread attributes.
|
||||||
FALSE, // Handles inheritance.
|
FALSE, // Handles inheritance.
|
||||||
0, // Creation flags.
|
0, // Creation flags.
|
||||||
nullptr, // Use parent's environment block.
|
nullptr, // Use parent's environment block.
|
||||||
nullptr, // Use parent's starting directory.
|
nullptr, // Use parent's starting directory.
|
||||||
&si, // Pointer to the STARTUPINFOW structure.
|
&si, // Pointer to the STARTUPINFOW structure.
|
||||||
&pi); // Pointer to the PROCESS_INFORMATION structure.
|
&pi); // Pointer to the PROCESS_INFORMATION structure.
|
||||||
|
|
||||||
// Unfortunately suspending ES and resuming when the emulator process has exited
|
// Unfortunately suspending ES and resuming when the emulator process has exited
|
||||||
// doesn't work reliably on Windows, so we may need to keep ES running in the
|
// doesn't work reliably on Windows, so we may need to keep ES running in the
|
||||||
|
@ -161,7 +157,7 @@ int launchEmulatorWindows(const std::wstring& cmd_utf16)
|
||||||
|
|
||||||
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||||
nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
(LPWSTR)&pBuffer, 0, nullptr);
|
reinterpret_cast<LPWSTR>(&pBuffer), 0, nullptr);
|
||||||
|
|
||||||
errorCode = GetLastError();
|
errorCode = GetLastError();
|
||||||
|
|
||||||
|
@ -196,7 +192,7 @@ unsigned int getTaskbarState()
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
APPBARDATA barData;
|
APPBARDATA barData;
|
||||||
barData.cbSize = sizeof(APPBARDATA);
|
barData.cbSize = sizeof(APPBARDATA);
|
||||||
return (UINT) SHAppBarMessage(ABM_GETSTATE, &barData);
|
return static_cast<UINT>(SHAppBarMessage(ABM_GETSTATE, &barData));
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
|
// EmulationStation Desktop Edition
|
||||||
// Platform.h
|
// Platform.h
|
||||||
//
|
//
|
||||||
// Platform-specific functions.
|
// Platform-specific functions.
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#ifndef ES_CORE_PLATFORM_H
|
#ifndef ES_CORE_PLATFORM_H
|
||||||
#define ES_CORE_PLATFORM_H
|
#define ES_CORE_PLATFORM_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// Why the hell this naming inconsistency exists is well beyond me.
|
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
#define sleep Sleep
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum QuitMode {
|
enum QuitMode {
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
|
// EmulationStation Desktop Edition
|
||||||
// ImageComponent.cpp
|
// ImageComponent.cpp
|
||||||
//
|
//
|
||||||
// Handles images: loading, resizing, cropping, color shifting etc.
|
// Handles images: loading, resizing, cropping, color shifting etc.
|
||||||
|
@ -337,9 +339,9 @@ void ImageComponent::updateColors()
|
||||||
{
|
{
|
||||||
const float opacity = (mOpacity * (mFading ? mFadeOpacity / 255.0 : 1.0)) / 255.0;
|
const float opacity = (mOpacity * (mFading ? mFadeOpacity / 255.0 : 1.0)) / 255.0;
|
||||||
const unsigned int color = Renderer::convertColor((mColorShift & 0xFFFFFF00) |
|
const unsigned int color = Renderer::convertColor((mColorShift & 0xFFFFFF00) |
|
||||||
(unsigned char)((mColorShift & 0xFF) * opacity));
|
static_cast<unsigned char>((mColorShift & 0xFF) * opacity));
|
||||||
const unsigned int colorEnd = Renderer::convertColor((mColorShiftEnd & 0xFFFFFF00) |
|
const unsigned int colorEnd = Renderer::convertColor((mColorShiftEnd & 0xFFFFFF00) |
|
||||||
(unsigned char)((mColorShiftEnd & 0xFF) * opacity));
|
static_cast<unsigned char>((mColorShiftEnd & 0xFF) * opacity));
|
||||||
|
|
||||||
mVertices[0].col = color;
|
mVertices[0].col = color;
|
||||||
mVertices[1].col = mColorGradientHorizontal ? colorEnd : color;
|
mVertices[1].col = mColorGradientHorizontal ? colorEnd : color;
|
||||||
|
@ -408,7 +410,7 @@ void ImageComponent::fadeIn(bool textureLoaded)
|
||||||
mFading = false;
|
mFading = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mFadeOpacity = (unsigned char)opacity;
|
mFadeOpacity = static_cast<unsigned char>(opacity);
|
||||||
}
|
}
|
||||||
updateColors();
|
updateColors();
|
||||||
}
|
}
|
||||||
|
@ -425,15 +427,16 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const s
|
||||||
{
|
{
|
||||||
using namespace ThemeFlags;
|
using namespace ThemeFlags;
|
||||||
|
|
||||||
GuiComponent::applyTheme(theme, view, element, (properties ^ SIZE) |
|
GuiComponent::applyTheme(theme, view, element, (properties ^ ThemeFlags::SIZE) |
|
||||||
((properties & (SIZE | POSITION)) ? ORIGIN : 0));
|
((properties & (ThemeFlags::SIZE | POSITION)) ? ORIGIN : 0));
|
||||||
|
|
||||||
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "image");
|
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "image");
|
||||||
if (!elem)
|
if (!elem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Vector2f scale = getParent() ? getParent()->getSize() :
|
Vector2f scale = getParent() ? getParent()->getSize() :
|
||||||
Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
Vector2f(static_cast<float>(Renderer::getScreenWidth()),
|
||||||
|
static_cast<float>(Renderer::getScreenHeight()));
|
||||||
|
|
||||||
if (properties & ThemeFlags::SIZE) {
|
if (properties & ThemeFlags::SIZE) {
|
||||||
if (elem->has("size"))
|
if (elem->has("size"))
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
|
// EmulationStation Desktop Edition
|
||||||
// ImageComponent.h
|
// ImageComponent.h
|
||||||
//
|
//
|
||||||
// Handles images: loading, resizing, cropping, color shifting etc.
|
// Handles images: loading, resizing, cropping, color shifting etc.
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#ifndef ES_CORE_COMPONENTS_IMAGE_COMPONENT_H
|
#ifndef ES_CORE_COMPONENTS_IMAGE_COMPONENT_H
|
||||||
#define ES_CORE_COMPONENTS_IMAGE_COMPONENT_H
|
#define ES_CORE_COMPONENTS_IMAGE_COMPONENT_H
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ std::string getTitleFolder() {
|
||||||
void writeSubtitle(const char* gameName, const char* systemName, bool always)
|
void writeSubtitle(const char* gameName, const char* systemName, bool always)
|
||||||
{
|
{
|
||||||
FILE* file = fopen(getTitlePath().c_str(), "w");
|
FILE* file = fopen(getTitlePath().c_str(), "w");
|
||||||
int end = (int)(Settings::getInstance()->getInt("ScreenSaverSwapVideoTimeout") / (1000));
|
int end = static_cast<int>((Settings::getInstance()->
|
||||||
|
getInt("ScreenSaverSwapVideoTimeout") / (1000)));
|
||||||
|
|
||||||
if (always)
|
if (always)
|
||||||
fprintf(file, "1\n00:00:01,000 --> 00:00:%d,000\n", end);
|
fprintf(file, "1\n00:00:01,000 --> 00:00:%d,000\n", end);
|
||||||
|
@ -198,8 +199,8 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const s
|
||||||
{
|
{
|
||||||
using namespace ThemeFlags;
|
using namespace ThemeFlags;
|
||||||
|
|
||||||
GuiComponent::applyTheme(theme, view, element, (properties ^ SIZE) |
|
GuiComponent::applyTheme(theme, view, element, (properties ^ ThemeFlags::SIZE) |
|
||||||
((properties & (SIZE | POSITION)) ? ORIGIN : 0));
|
((properties & (ThemeFlags::SIZE | POSITION)) ? ORIGIN : 0));
|
||||||
|
|
||||||
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "video");
|
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "video");
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
|
// EmulationStation Desktop Edition
|
||||||
// Renderer.cpp
|
// Renderer.cpp
|
||||||
//
|
//
|
||||||
// General rendering functions.
|
// General rendering functions.
|
||||||
|
@ -8,11 +10,11 @@
|
||||||
|
|
||||||
#include "math/Transform4x4f.h"
|
#include "math/Transform4x4f.h"
|
||||||
#include "math/Vector2i.h"
|
#include "math/Vector2i.h"
|
||||||
#include "Shader_GL21.h"
|
|
||||||
#include "resources/ResourceManager.h"
|
#include "resources/ResourceManager.h"
|
||||||
#include "ImageIO.h"
|
#include "ImageIO.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
#include "Shader_GL21.h"
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
@ -55,8 +57,10 @@ namespace Renderer
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Try creating SDL surface from logo data.
|
// Try creating SDL surface from logo data.
|
||||||
SDL_Surface* logoSurface = SDL_CreateRGBSurfaceFrom((void*)rawData.data(),
|
SDL_Surface* logoSurface = SDL_CreateRGBSurfaceFrom(
|
||||||
(int)width, (int)height, 32, (int)(width * 4), rmask, gmask, bmask, amask);
|
static_cast<void*>(rawData.data()),
|
||||||
|
static_cast<int>(width), static_cast<int>(height), 32,
|
||||||
|
static_cast<int>((width * 4)), rmask, gmask, bmask, amask);
|
||||||
|
|
||||||
if (logoSurface != nullptr) {
|
if (logoSurface != nullptr) {
|
||||||
SDL_SetWindowIcon(sdlWindow, logoSurface);
|
SDL_SetWindowIcon(sdlWindow, logoSurface);
|
||||||
|
@ -76,22 +80,22 @@ namespace Renderer
|
||||||
|
|
||||||
initialCursorState = (SDL_ShowCursor(0) != 0);
|
initialCursorState = (SDL_ShowCursor(0) != 0);
|
||||||
|
|
||||||
SDL_DisplayMode dispMode;
|
SDL_DisplayMode displayMode;
|
||||||
SDL_GetDesktopDisplayMode(0, &dispMode);
|
SDL_GetDesktopDisplayMode(0, &displayMode);
|
||||||
windowWidth = Settings::getInstance()->getInt("WindowWidth") ?
|
windowWidth = Settings::getInstance()->getInt("WindowWidth") ?
|
||||||
Settings::getInstance()->getInt("WindowWidth") : dispMode.w;
|
Settings::getInstance()->getInt("WindowWidth") : displayMode.w;
|
||||||
windowHeight = Settings::getInstance()->getInt("WindowHeight") ?
|
windowHeight = Settings::getInstance()->getInt("WindowHeight") ?
|
||||||
Settings::getInstance()->getInt("WindowHeight") : dispMode.h;
|
Settings::getInstance()->getInt("WindowHeight") : displayMode.h;
|
||||||
screenWidth = Settings::getInstance()->getInt("ScreenWidth") ?
|
screenWidth = Settings::getInstance()->getInt("ScreenWidth") ?
|
||||||
Settings::getInstance()->getInt("ScreenWidth") : windowWidth;
|
Settings::getInstance()->getInt("ScreenWidth") : windowWidth;
|
||||||
screenHeight = Settings::getInstance()->getInt("ScreenHeight") ?
|
screenHeight = Settings::getInstance()->getInt("ScreenHeight") ?
|
||||||
Settings::getInstance()->getInt("ScreenHeight") : windowHeight;
|
Settings::getInstance()->getInt("ScreenHeight") : windowHeight;
|
||||||
screenOffsetX = Settings::getInstance()->getInt("ScreenOffsetX") ?
|
screenOffsetX = Settings::getInstance()->getInt("ScreenOffsetX") ?
|
||||||
Settings::getInstance()->getInt("ScreenOffsetX") : 0;
|
Settings::getInstance()->getInt("ScreenOffsetX") : 0;
|
||||||
screenOffsetY = Settings::getInstance()->getInt("ScreenOffsetY") ?
|
screenOffsetY = Settings::getInstance()->getInt("ScreenOffsetY") ?
|
||||||
Settings::getInstance()->getInt("ScreenOffsetY") : 0;
|
Settings::getInstance()->getInt("ScreenOffsetY") : 0;
|
||||||
screenRotate = Settings::getInstance()->getInt("ScreenRotate") ?
|
screenRotate = Settings::getInstance()->getInt("ScreenRotate") ?
|
||||||
Settings::getInstance()->getInt("ScreenRotate") : 0;
|
Settings::getInstance()->getInt("ScreenRotate") : 0;
|
||||||
|
|
||||||
// Prevent ES window from minimizing when switching windows (when launching
|
// Prevent ES window from minimizing when switching windows (when launching
|
||||||
// games or when manually switching windows using task switcher).
|
// games or when manually switching windows using task switcher).
|
||||||
|
@ -100,7 +104,7 @@ namespace Renderer
|
||||||
#if defined(__APPLE__) || defined(__unix__)
|
#if defined(__APPLE__) || defined(__unix__)
|
||||||
bool userResolution = false;
|
bool userResolution = false;
|
||||||
// Check if the user has changed the resolution from the command line.
|
// Check if the user has changed the resolution from the command line.
|
||||||
if (windowWidth != dispMode.w || windowHeight != dispMode.h)
|
if (windowWidth != displayMode.w || windowHeight != displayMode.h)
|
||||||
userResolution = true;
|
userResolution = true;
|
||||||
// Not sure if this could be a useful setting for some users.
|
// Not sure if this could be a useful setting for some users.
|
||||||
// SDL_SetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, "0");
|
// SDL_SetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, "0");
|
||||||
|
@ -234,7 +238,7 @@ namespace Renderer
|
||||||
viewport.w = screenHeight;
|
viewport.w = screenHeight;
|
||||||
viewport.h = screenWidth;
|
viewport.h = screenWidth;
|
||||||
projection.orthoProjection(0, screenHeight, screenWidth, 0, -1.0, 1.0);
|
projection.orthoProjection(0, screenHeight, screenWidth, 0, -1.0, 1.0);
|
||||||
projection.rotate((float)ES_DEG_TO_RAD(90), {0, 0, 1});
|
projection.rotate(static_cast<float>(ES_DEG_TO_RAD(90)), {0, 0, 1});
|
||||||
projection.translate({0, screenHeight * -1.0f, 0});
|
projection.translate({0, screenHeight * -1.0f, 0});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -244,7 +248,7 @@ namespace Renderer
|
||||||
viewport.w = screenWidth;
|
viewport.w = screenWidth;
|
||||||
viewport.h = screenHeight;
|
viewport.h = screenHeight;
|
||||||
projection.orthoProjection(0, screenWidth, screenHeight, 0, -1.0, 1.0);
|
projection.orthoProjection(0, screenWidth, screenHeight, 0, -1.0, 1.0);
|
||||||
projection.rotate((float)ES_DEG_TO_RAD(180), {0, 0, 1});
|
projection.rotate(static_cast<float>(ES_DEG_TO_RAD(180)), {0, 0, 1});
|
||||||
projection.translate({screenWidth * -1.0f, screenHeight * -1.0f, 0});
|
projection.translate({screenWidth * -1.0f, screenHeight * -1.0f, 0});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -254,7 +258,7 @@ namespace Renderer
|
||||||
viewport.w = screenHeight;
|
viewport.w = screenHeight;
|
||||||
viewport.h = screenWidth;
|
viewport.h = screenWidth;
|
||||||
projection.orthoProjection(0, screenHeight, screenWidth, 0, -1.0, 1.0);
|
projection.orthoProjection(0, screenHeight, screenWidth, 0, -1.0, 1.0);
|
||||||
projection.rotate((float)ES_DEG_TO_RAD(270), {0, 0, 1});
|
projection.rotate(static_cast<float>(ES_DEG_TO_RAD(270)), {0, 0, 1});
|
||||||
projection.translate({screenWidth * -1.0f, 0, 0});
|
projection.translate({screenWidth * -1.0f, 0, 0});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -284,24 +288,20 @@ namespace Renderer
|
||||||
box.h = screenHeight - box.y;
|
box.h = screenHeight - box.y;
|
||||||
|
|
||||||
switch (screenRotate) {
|
switch (screenRotate) {
|
||||||
case 0: {
|
case 0:
|
||||||
box = Rect(screenOffsetX + box.x, screenOffsetY + box.y, box.w, box.h);
|
box = Rect(screenOffsetX + box.x, screenOffsetY + box.y, box.w, box.h);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 1: {
|
case 1:
|
||||||
box = Rect(windowWidth - screenOffsetY - box.y - box.h, screenOffsetX +
|
box = Rect(windowWidth - screenOffsetY - box.y - box.h,
|
||||||
box.x, box.h, box.w);
|
screenOffsetX + box.x, box.h, box.w);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 2: {
|
case 2:
|
||||||
box = Rect(windowWidth - screenOffsetX - box.x - box.w, windowHeight -
|
box = Rect(windowWidth - screenOffsetX - box.x - box.w, windowHeight -
|
||||||
screenOffsetY - box.y - box.h, box.w, box.h);
|
screenOffsetY - box.y - box.h, box.w, box.h);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 3: {
|
case 3:
|
||||||
box = Rect(screenOffsetY + box.y, windowHeight - screenOffsetX - box.x -
|
box = Rect(screenOffsetY + box.y, windowHeight -
|
||||||
box.w, box.h, box.w);
|
screenOffsetX - box.x - box.w, box.h, box.w);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
|
// EmulationStation Desktop Edition
|
||||||
// Renderer.h
|
// Renderer.h
|
||||||
//
|
//
|
||||||
// General rendering functions.
|
// General rendering functions.
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#ifndef ES_CORE_RENDERER_RENDERER_H
|
#ifndef ES_CORE_RENDERER_RENDERER_H
|
||||||
#define ES_CORE_RENDERER_RENDERER_H
|
#define ES_CORE_RENDERER_RENDERER_H
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
|
// EmulationStation Desktop Edition
|
||||||
// Renderer_GL21.cpp
|
// Renderer_GL21.cpp
|
||||||
//
|
//
|
||||||
// OpenGL 2.1 rendering functions.
|
// OpenGL 2.1 rendering functions.
|
||||||
|
@ -88,24 +90,32 @@ namespace Renderer
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(_WIN64)
|
||||||
|
glewInit();
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_GL_MakeCurrent(getSDLWindow(), sdlContext);
|
SDL_GL_MakeCurrent(getSDLWindow(), sdlContext);
|
||||||
|
|
||||||
std::string vendor = glGetString(GL_VENDOR) ?
|
std::string vendor = glGetString(GL_VENDOR) ?
|
||||||
(const char*)glGetString(GL_VENDOR) : "";
|
reinterpret_cast<const char*>(glGetString(GL_VENDOR)) : "";
|
||||||
std::string renderer = glGetString(GL_RENDERER) ?
|
std::string renderer = glGetString(GL_RENDERER) ?
|
||||||
(const char*)glGetString(GL_RENDERER) : "";
|
reinterpret_cast<const char*>(glGetString(GL_RENDERER)) : "";
|
||||||
std::string version = glGetString(GL_VERSION) ?
|
std::string version = glGetString(GL_VERSION) ?
|
||||||
(const char*)glGetString(GL_VERSION) : "";
|
reinterpret_cast<const char*>(glGetString(GL_VERSION)) : "";
|
||||||
std::string extensions = glGetString(GL_EXTENSIONS) ?
|
std::string extensions = glGetString(GL_EXTENSIONS) ?
|
||||||
(const char*)glGetString(GL_EXTENSIONS) : "";
|
reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)) : "";
|
||||||
|
|
||||||
LOG(LogInfo) << "GL vendor: " << vendor;
|
LOG(LogInfo) << "GL vendor: " << vendor;
|
||||||
LOG(LogInfo) << "GL renderer: " << renderer;
|
LOG(LogInfo) << "GL renderer: " << renderer;
|
||||||
LOG(LogInfo) << "GL version: " << version;
|
LOG(LogInfo) << "GL version: " << version;
|
||||||
|
#if defined(_WIN64)
|
||||||
|
LOG(LogInfo) << "EmulationStation renderer: OpenGL 2.1 with GLEW";
|
||||||
|
#else
|
||||||
LOG(LogInfo) << "EmulationStation renderer: OpenGL 2.1";
|
LOG(LogInfo) << "EmulationStation renderer: OpenGL 2.1";
|
||||||
|
#endif
|
||||||
LOG(LogInfo) << "Checking available OpenGL extensions...";
|
LOG(LogInfo) << "Checking available OpenGL extensions...";
|
||||||
std::string glExts = glGetString(GL_EXTENSIONS) ?
|
std::string glExts = glGetString(GL_EXTENSIONS) ?
|
||||||
(const char*)glGetString(GL_EXTENSIONS) : "";
|
reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)) : "";
|
||||||
if (extensions.find("GL_ARB_texture_non_power_of_two") == std::string::npos) {
|
if (extensions.find("GL_ARB_texture_non_power_of_two") == std::string::npos) {
|
||||||
LOG(LogError) << "GL_ARB_texture_non_power_of_two: MISSING";
|
LOG(LogError) << "GL_ARB_texture_non_power_of_two: MISSING";
|
||||||
missingExtension = true;
|
missingExtension = true;
|
||||||
|
@ -327,7 +337,7 @@ namespace Renderer
|
||||||
float shaderWidth = width * 1.2;
|
float shaderWidth = width * 1.2;
|
||||||
// Workaround to get the scanlines to render somehow proportional to the
|
// Workaround to get the scanlines to render somehow proportional to the
|
||||||
// resolution. A better solution is for sure needed.
|
// resolution. A better solution is for sure needed.
|
||||||
float shaderHeight = height + height / ((int)height >> 7) * 2.0;
|
float shaderHeight = height + height / (static_cast<int>(height) >> 7) * 2.0;
|
||||||
if (runShader) {
|
if (runShader) {
|
||||||
runShader->activateShaders();
|
runShader->activateShaders();
|
||||||
runShader->setModelViewProjectionMatrix(getProjectionMatrix() * _trans);
|
runShader->setModelViewProjectionMatrix(getProjectionMatrix() * _trans);
|
||||||
|
@ -343,7 +353,7 @@ namespace Renderer
|
||||||
void setProjection(const Transform4x4f& _projection)
|
void setProjection(const Transform4x4f& _projection)
|
||||||
{
|
{
|
||||||
GL_CHECK_ERROR(glMatrixMode(GL_PROJECTION));
|
GL_CHECK_ERROR(glMatrixMode(GL_PROJECTION));
|
||||||
GL_CHECK_ERROR(glLoadMatrixf((GLfloat*)&_projection));
|
GL_CHECK_ERROR(glLoadMatrixf(reinterpret_cast<const GLfloat*>(&_projection)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMatrix(const Transform4x4f& _matrix)
|
void setMatrix(const Transform4x4f& _matrix)
|
||||||
|
@ -352,7 +362,7 @@ namespace Renderer
|
||||||
matrix.round();
|
matrix.round();
|
||||||
|
|
||||||
GL_CHECK_ERROR(glMatrixMode(GL_MODELVIEW));
|
GL_CHECK_ERROR(glMatrixMode(GL_MODELVIEW));
|
||||||
GL_CHECK_ERROR(glLoadMatrixf((GLfloat*)&matrix));
|
GL_CHECK_ERROR(glLoadMatrixf(reinterpret_cast<const GLfloat*>(&matrix)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setViewport(const Rect& _viewport)
|
void setViewport(const Rect& _viewport)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
|
// EmulationStation Desktop Edition
|
||||||
// Shader_GL21.cpp
|
// Shader_GL21.cpp
|
||||||
//
|
//
|
||||||
// OpenGL 2.1 GLSL shader functions.
|
// OpenGL 2.1 GLSL shader functions.
|
||||||
|
@ -38,7 +40,7 @@ namespace Renderer
|
||||||
|
|
||||||
// This will load the entire GLSL source code into the string variable.
|
// This will load the entire GLSL source code into the string variable.
|
||||||
const ResourceData& shaderData = ResourceManager::getInstance()->getFileData(path);
|
const ResourceData& shaderData = ResourceManager::getInstance()->getFileData(path);
|
||||||
shaderCode.assign((const char*)shaderData.ptr.get(), shaderData.length);
|
shaderCode.assign(reinterpret_cast<const char*>(shaderData.ptr.get()), shaderData.length);
|
||||||
|
|
||||||
// Define the GLSL version (version 120 = OpenGL 2.1).
|
// Define the GLSL version (version 120 = OpenGL 2.1).
|
||||||
preprocessorDefines = "#version 120\n";
|
preprocessorDefines = "#version 120\n";
|
||||||
|
@ -65,7 +67,8 @@ namespace Renderer
|
||||||
GLuint currentShader = glCreateShader(std::get<2>(*it));
|
GLuint currentShader = glCreateShader(std::get<2>(*it));
|
||||||
GLchar const* shaderCodePtr = std::get<1>(*it).c_str();
|
GLchar const* shaderCodePtr = std::get<1>(*it).c_str();
|
||||||
|
|
||||||
glShaderSource(currentShader, 1, (const GLchar**)&shaderCodePtr, nullptr);
|
glShaderSource(currentShader, 1,
|
||||||
|
reinterpret_cast<const GLchar**>(&shaderCodePtr), nullptr);
|
||||||
glCompileShader(currentShader);
|
glCompileShader(currentShader);
|
||||||
|
|
||||||
GLint shaderCompiled;
|
GLint shaderCompiled;
|
||||||
|
@ -114,7 +117,8 @@ namespace Renderer
|
||||||
void Renderer::Shader::setModelViewProjectionMatrix(Transform4x4f mvpMatrix)
|
void Renderer::Shader::setModelViewProjectionMatrix(Transform4x4f mvpMatrix)
|
||||||
{
|
{
|
||||||
if (shaderMVPMatrix != -1)
|
if (shaderMVPMatrix != -1)
|
||||||
GL_CHECK_ERROR(glUniformMatrix4fv(shaderMVPMatrix, 1, GL_FALSE, (GLfloat*)&mvpMatrix));
|
GL_CHECK_ERROR(glUniformMatrix4fv(shaderMVPMatrix, 1, GL_FALSE,
|
||||||
|
reinterpret_cast<GLfloat*>(&mvpMatrix)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Shader::setTextureSize(std::array<GLfloat, 2> shaderVec2)
|
void Renderer::Shader::setTextureSize(std::array<GLfloat, 2> shaderVec2)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
|
// EmulationStation Desktop Edition
|
||||||
// Shader_GL21.h
|
// Shader_GL21.h
|
||||||
//
|
//
|
||||||
// OpenGL 2.1 GLSL shader functions.
|
// OpenGL 2.1 GLSL shader functions.
|
||||||
|
@ -11,6 +13,10 @@
|
||||||
|
|
||||||
#include "math/Transform4x4f.h"
|
#include "math/Transform4x4f.h"
|
||||||
|
|
||||||
|
#if defined(_WIN64)
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <SDL2/SDL_opengl.h>
|
#include <SDL2/SDL_opengl.h>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
Loading…
Reference in a new issue