mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-13 21:02:34 +08:00
parent
5f58178cdc
commit
7278f2f817
6
.github/workflows/cmake.yml
vendored
6
.github/workflows/cmake.yml
vendored
@ -24,7 +24,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: sudo apt-get update && sudo apt-get -y install libxrandr-dev libfreeimage-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv1 libpulse-dev libpulse0
|
run: sudo apt-get update && sudo apt-get -y install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv1 libpulse-dev libpulse0
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||||
@ -48,7 +48,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: sudo apt-get update && sudo apt-get -y install libxrandr-dev libfreeimage-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv1 libpulse-dev libpulse0 wayland-scanner++ wayland-protocols libwayland-dev
|
run: sudo apt-get update && sudo apt-get -y install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv1 libpulse-dev libpulse0 wayland-scanner++ wayland-protocols libwayland-dev
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||||
@ -72,7 +72,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: sudo apt-get update && sudo apt-get -y install wayland-scanner++ wayland-protocols libwayland-dev libwayland-egl-backend-dev libfreeimage-dev libglfw3-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libglm-dev libmpv-dev mpv libmpv1 libpulse-dev libpulse0
|
run: sudo apt-get update && sudo apt-get -y install wayland-scanner++ wayland-protocols libwayland-dev libwayland-egl-backend-dev libglfw3-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libglm-dev libmpv-dev mpv libmpv1 libpulse-dev libpulse0
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||||
|
@ -33,7 +33,6 @@ find_package(SDL2 REQUIRED)
|
|||||||
find_package(MPV REQUIRED)
|
find_package(MPV REQUIRED)
|
||||||
find_package(LZ4 REQUIRED)
|
find_package(LZ4 REQUIRED)
|
||||||
find_package(FFMPEG REQUIRED)
|
find_package(FFMPEG REQUIRED)
|
||||||
find_package(FreeImage REQUIRED)
|
|
||||||
find_package(PulseAudio REQUIRED)
|
find_package(PulseAudio REQUIRED)
|
||||||
|
|
||||||
# Download CEF of specified version for current platform
|
# Download CEF of specified version for current platform
|
||||||
@ -100,7 +99,6 @@ include_directories(
|
|||||||
${LZ4_INCLUDE_DIR}
|
${LZ4_INCLUDE_DIR}
|
||||||
${SDL2_INCLUDE_DIRS}
|
${SDL2_INCLUDE_DIRS}
|
||||||
${FFMPEG_INCLUDE_DIR}
|
${FFMPEG_INCLUDE_DIR}
|
||||||
${FREEIMAGE_INCLUDE_DIR}
|
|
||||||
${PULSEAUDIO_INCLUDE_DIR}
|
${PULSEAUDIO_INCLUDE_DIR}
|
||||||
src
|
src
|
||||||
${CEF_INCLUDE_PATH}
|
${CEF_INCLUDE_PATH}
|
||||||
@ -441,7 +439,6 @@ target_link_libraries (linux-wallpaperengine PUBLIC
|
|||||||
${LZ4_LIBRARY}
|
${LZ4_LIBRARY}
|
||||||
${SDL2_LIBRARIES}
|
${SDL2_LIBRARIES}
|
||||||
${FFMPEG_LIBRARIES}
|
${FFMPEG_LIBRARIES}
|
||||||
${FREEIMAGE_LIBRARIES}
|
|
||||||
${MPV_LIBRARY}
|
${MPV_LIBRARY}
|
||||||
${PULSEAUDIO_LIBRARY}
|
${PULSEAUDIO_LIBRARY}
|
||||||
glfw
|
glfw
|
||||||
|
@ -1,83 +0,0 @@
|
|||||||
# Find the FreeImage library.
|
|
||||||
#
|
|
||||||
# This module defines
|
|
||||||
# FREEIMAGE_FOUND - True if FREEIMAGE was found.
|
|
||||||
# FREEIMAGE_INCLUDE_DIRS - Include directories for FREEIMAGE headers.
|
|
||||||
# FREEIMAGE_LIBRARIES - Libraries for FREEIMAGE.
|
|
||||||
#
|
|
||||||
# To specify an additional directory to search, set FREEIMAGE_ROOT.
|
|
||||||
#
|
|
||||||
# Copyright (c) 2010, Ewen Cheslack-Postava
|
|
||||||
# Based on FindSQLite3.cmake by:
|
|
||||||
# Copyright (c) 2006, Jaroslaw Staniek, <js@iidea.pl>
|
|
||||||
# Extended by Siddhartha Chaudhuri, 2008.
|
|
||||||
#
|
|
||||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
|
||||||
#
|
|
||||||
|
|
||||||
SET(FREEIMAGE_FOUND FALSE)
|
|
||||||
SET(FREEIMAGE_INCLUDE_DIRS)
|
|
||||||
SET(FREEIMAGE_LIBRARIES)
|
|
||||||
|
|
||||||
SET(SEARCH_PATHS
|
|
||||||
$ENV{ProgramFiles}/freeimage/include
|
|
||||||
$ENV{SystemDrive}/freeimage/include
|
|
||||||
$ENV{ProgramFiles}/freeimage
|
|
||||||
$ENV{SystemDrive}/freeimage
|
|
||||||
)
|
|
||||||
IF(FREEIMAGE_ROOT)
|
|
||||||
SET(SEARCH_PATHS
|
|
||||||
${FREEIMAGE_ROOT}
|
|
||||||
${FREEIMAGE_ROOT}/include
|
|
||||||
${SEARCH_PATHS}
|
|
||||||
)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
FIND_PATH(FREEIMAGE_INCLUDE_DIRS
|
|
||||||
NAMES FreeImage.h
|
|
||||||
PATHS ${SEARCH_PATHS}
|
|
||||||
NO_DEFAULT_PATH)
|
|
||||||
IF(NOT FREEIMAGE_INCLUDE_DIRS) # now look in system locations
|
|
||||||
FIND_PATH(FREEIMAGE_INCLUDE_DIRS NAMES FreeImage.h)
|
|
||||||
ENDIF(NOT FREEIMAGE_INCLUDE_DIRS)
|
|
||||||
|
|
||||||
SET(FREEIMAGE_LIBRARY_DIRS)
|
|
||||||
IF(FREEIMAGE_ROOT)
|
|
||||||
SET(FREEIMAGE_LIBRARY_DIRS ${FREEIMAGE_ROOT})
|
|
||||||
IF(EXISTS "${FREEIMAGE_ROOT}/lib")
|
|
||||||
SET(FREEIMAGE_LIBRARY_DIRS ${FREEIMAGE_LIBRARY_DIRS} ${FREEIMAGE_ROOT}/lib)
|
|
||||||
ENDIF()
|
|
||||||
IF(EXISTS "${FREEIMAGE_ROOT}/lib/static")
|
|
||||||
SET(FREEIMAGE_LIBRARY_DIRS ${FREEIMAGE_LIBRARY_DIRS} ${FREEIMAGE_ROOT}/lib/static)
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
# FREEIMAGE
|
|
||||||
# Without system dirs
|
|
||||||
FIND_LIBRARY(FREEIMAGE_LIBRARY
|
|
||||||
NAMES freeimage
|
|
||||||
PATHS ${FREEIMAGE_LIBRARY_DIRS}
|
|
||||||
NO_DEFAULT_PATH
|
|
||||||
)
|
|
||||||
IF(NOT FREEIMAGE_LIBRARY) # now look in system locations
|
|
||||||
FIND_LIBRARY(FREEIMAGE_LIBRARY NAMES freeimage)
|
|
||||||
ENDIF(NOT FREEIMAGE_LIBRARY)
|
|
||||||
|
|
||||||
SET(FREEIMAGE_LIBRARIES)
|
|
||||||
IF(FREEIMAGE_LIBRARY)
|
|
||||||
SET(FREEIMAGE_LIBRARIES ${FREEIMAGE_LIBRARY})
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(FREEIMAGE_INCLUDE_DIRS AND FREEIMAGE_LIBRARIES)
|
|
||||||
SET(FREEIMAGE_FOUND TRUE)
|
|
||||||
IF(NOT FREEIMAGE_FIND_QUIETLY)
|
|
||||||
MESSAGE(STATUS "Found FreeImage: headers at ${FREEIMAGE_INCLUDE_DIRS}, libraries at ${FREEIMAGE_LIBRARY_DIRS} :: ${FREEIMAGE_LIBRARIES}")
|
|
||||||
ENDIF(NOT FREEIMAGE_FIND_QUIETLY)
|
|
||||||
ELSE(FREEIMAGE_INCLUDE_DIRS AND FREEIMAGE_LIBRARIES)
|
|
||||||
SET(FREEIMAGE_FOUND FALSE)
|
|
||||||
IF(FREEIMAGE_FIND_REQUIRED)
|
|
||||||
MESSAGE(STATUS "FreeImage not found")
|
|
||||||
ENDIF(FREEIMAGE_FIND_REQUIRED)
|
|
||||||
ENDIF(FREEIMAGE_INCLUDE_DIRS AND FREEIMAGE_LIBRARIES)
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(FREEIMAGE_INCLUDE_DIRS FREEIMAGE_LIBRARIES)
|
|
@ -32,14 +32,13 @@ Wallpaper Engine is a software designed by [Kristjan Skutta](https://store.steam
|
|||||||
- GLM
|
- GLM
|
||||||
- GLEW
|
- GLEW
|
||||||
- GLUT
|
- GLUT
|
||||||
- FreeImage
|
|
||||||
- MPV
|
- MPV
|
||||||
- PulseAudio
|
- PulseAudio
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
```
|
```
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install build-essential cmake libxrandr-dev libfreeimage-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv1 libpulse-dev libpulse0
|
sudo apt-get install build-essential cmake libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv1 libpulse-dev libpulse0
|
||||||
```
|
```
|
||||||
|
|
||||||
# 5. How to use
|
# 5. How to use
|
||||||
|
7988
include/stb_image.h
Normal file
7988
include/stb_image.h
Normal file
File diff suppressed because it is too large
Load Diff
1724
include/stb_image_write.h
Normal file
1724
include/stb_image_write.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,7 @@ pkgdesc="use steam's wallpaperengine on linux"
|
|||||||
arch=('x86_64')
|
arch=('x86_64')
|
||||||
url="https://github.com/Almamu/linux-wallpaperengine"
|
url="https://github.com/Almamu/linux-wallpaperengine"
|
||||||
license=('GPL3')
|
license=('GPL3')
|
||||||
depends=('lz4' 'ffmpeg' 'mpv' 'freeimage' 'glfw' 'glew' 'freeglut' 'libpulse')
|
depends=('lz4' 'ffmpeg' 'mpv' 'glfw' 'glew' 'freeglut' 'libpulse')
|
||||||
makedepends=('git' 'cmake' 'sdl2' 'glm')
|
makedepends=('git' 'cmake' 'sdl2' 'glm')
|
||||||
provides=("linux-wallpaperengine")
|
provides=("linux-wallpaperengine")
|
||||||
source=("${pkgname}::git+https://github.com/Almamu/linux-wallpaperengine.git#branch=main")
|
source=("${pkgname}::git+https://github.com/Almamu/linux-wallpaperengine.git#branch=main")
|
||||||
|
@ -87,7 +87,6 @@ CApplicationContext::CApplicationContext (int argc, char* argv []) {
|
|||||||
{
|
{
|
||||||
.take = false,
|
.take = false,
|
||||||
.path = "",
|
.path = "",
|
||||||
.format = FIF_UNKNOWN,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -280,13 +279,7 @@ void CApplicationContext::validateScreenshot () {
|
|||||||
|
|
||||||
const std::string extension = this->settings.screenshot.path.extension ();
|
const std::string extension = this->settings.screenshot.path.extension ();
|
||||||
|
|
||||||
if (extension == ".bmp")
|
if (extension != ".bmp" && extension != ".png" && extension != ".jpeg" && extension != ".jpg")
|
||||||
this->settings.screenshot.format = FIF_BMP;
|
|
||||||
else if (extension == ".png")
|
|
||||||
this->settings.screenshot.format = FIF_PNG;
|
|
||||||
else if (extension == ".jpg" || extension == ".jpeg")
|
|
||||||
this->settings.screenshot.format = FIF_JPEG;
|
|
||||||
else
|
|
||||||
sLog.exception ("Cannot determine screenshot format, unknown extension ", extension);
|
sLog.exception ("Cannot determine screenshot format, unknown extension ", extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
#include <glm/vec4.hpp>
|
#include <glm/vec4.hpp>
|
||||||
|
|
||||||
#include <FreeImage.h>
|
|
||||||
|
|
||||||
#include "CApplicationState.h"
|
#include "CApplicationState.h"
|
||||||
|
|
||||||
#include "WallpaperEngine/Assets/ITexture.h"
|
#include "WallpaperEngine/Assets/ITexture.h"
|
||||||
@ -101,8 +99,6 @@ class CApplicationContext {
|
|||||||
bool take;
|
bool take;
|
||||||
/** The path to where the screenshot must be saved */
|
/** The path to where the screenshot must be saved */
|
||||||
std::filesystem::path path;
|
std::filesystem::path path;
|
||||||
/** The image format */
|
|
||||||
FREE_IMAGE_FORMAT format;
|
|
||||||
} screenshot;
|
} screenshot;
|
||||||
} settings;
|
} settings;
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
#include "WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h"
|
#include "WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||||
|
#include <stb_image_write.h>
|
||||||
|
|
||||||
#define FULLSCREEN_CHECK_WAIT_TIME 250
|
#define FULLSCREEN_CHECK_WAIT_TIME 250
|
||||||
|
|
||||||
@ -212,14 +214,13 @@ void CWallpaperApplication::setupProperties () {
|
|||||||
this->setupPropertiesForProject (info);
|
this->setupPropertiesForProject (info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallpaperApplication::takeScreenshot (const std::filesystem::path& filename, FREE_IMAGE_FORMAT format) {
|
void CWallpaperApplication::takeScreenshot (const std::filesystem::path& filename) {
|
||||||
// this should be getting called at the end of the frame, so the right thing should be bound already
|
// this should be getting called at the end of the frame, so the right thing should be bound already
|
||||||
const int width = this->m_renderContext->getOutput ().getFullWidth ();
|
const int width = this->m_renderContext->getOutput ().getFullWidth ();
|
||||||
const int height = this->m_renderContext->getOutput ().getFullHeight ();
|
const int height = this->m_renderContext->getOutput ().getFullHeight ();
|
||||||
|
|
||||||
// build the output file with FreeImage
|
// build the output file with stbi_image_write
|
||||||
static FIBITMAP* bitmap = FreeImage_Allocate (width, height, 24);
|
auto* bitmap = new uint8_t [width * height * sizeof (uint8_t) * 3] {0};
|
||||||
RGBQUAD color;
|
|
||||||
int xoffset = 0;
|
int xoffset = 0;
|
||||||
|
|
||||||
for (const auto& [screen, viewport] : this->m_renderContext->getOutput ().getViewports ()) {
|
for (const auto& [screen, viewport] : this->m_renderContext->getOutput ().getViewports ()) {
|
||||||
@ -236,13 +237,12 @@ void CWallpaperApplication::takeScreenshot (const std::filesystem::path& filenam
|
|||||||
// now get access to the pixels
|
// now get access to the pixels
|
||||||
for (int y = viewport->viewport.w; y > 0; y--) {
|
for (int y = viewport->viewport.w; y > 0; y--) {
|
||||||
for (int x = 0; x < viewport->viewport.z; x++) {
|
for (int x = 0; x < viewport->viewport.z; x++) {
|
||||||
color.rgbRed = *pixel++;
|
int finalx = x + xoffset;
|
||||||
color.rgbGreen = *pixel++;
|
int finaly = this->m_renderContext->getOutput ().renderVFlip () ? (viewport->viewport.w - y) : y;
|
||||||
color.rgbBlue = *pixel++;
|
|
||||||
|
|
||||||
// set the pixel in the destination
|
bitmap[finaly * 3 + finalx] = *pixel++;
|
||||||
FreeImage_SetPixelColor (bitmap, x + xoffset,
|
bitmap[finaly * 3 + finalx + 1] = *pixel++;
|
||||||
this->m_renderContext->getOutput ().renderVFlip () ? (viewport->viewport.w - y) : y, &color);
|
bitmap[finaly * 3 + finalx + 2] = *pixel++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,10 +253,15 @@ void CWallpaperApplication::takeScreenshot (const std::filesystem::path& filenam
|
|||||||
delete [] buffer;
|
delete [] buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally save the file
|
auto extension = filename.extension();
|
||||||
FreeImage_Save (format, bitmap, filename.c_str (), 0);
|
|
||||||
|
|
||||||
FreeImage_Unload (bitmap);
|
if (extension == ".bmp") {
|
||||||
|
stbi_write_bmp (filename.c_str(), width, height, 3, bitmap);
|
||||||
|
} else if (extension == ".png") {
|
||||||
|
stbi_write_png (filename.c_str(), width, height, 3, bitmap, width * 3);
|
||||||
|
} else if (extension == ".jpg" || extension == ".jpeg") {
|
||||||
|
stbi_write_jpg (filename.c_str(), width, height, 3, bitmap, 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallpaperApplication::show () {
|
void CWallpaperApplication::show () {
|
||||||
@ -398,8 +403,7 @@ void CWallpaperApplication::show () {
|
|||||||
if (!this->m_context.settings.screenshot.take || m_videoDriver->getFrameCounter () < 5)
|
if (!this->m_context.settings.screenshot.take || m_videoDriver->getFrameCounter () < 5)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
this->takeScreenshot (this->m_context.settings.screenshot.path,
|
this->takeScreenshot (this->m_context.settings.screenshot.path);
|
||||||
this->m_context.settings.screenshot.format);
|
|
||||||
this->m_context.settings.screenshot.take = false;
|
this->m_context.settings.screenshot.take = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,11 +104,9 @@ class CWallpaperApplication {
|
|||||||
/**
|
/**
|
||||||
* Takes an screenshot of the background and saves it to the specified path
|
* Takes an screenshot of the background and saves it to the specified path
|
||||||
*
|
*
|
||||||
* @param context
|
|
||||||
* @param filename
|
* @param filename
|
||||||
* @param format
|
|
||||||
*/
|
*/
|
||||||
void takeScreenshot (const std::filesystem::path& filename, FREE_IMAGE_FORMAT format);
|
void takeScreenshot (const std::filesystem::path& filename);
|
||||||
|
|
||||||
/** The application context that contains the current app settings */
|
/** The application context that contains the current app settings */
|
||||||
CApplicationContext& m_context;
|
CApplicationContext& m_context;
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
#include <lz4.h>
|
#include <lz4.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
|
#include <stb_image.h>
|
||||||
|
|
||||||
using namespace WallpaperEngine::Assets;
|
using namespace WallpaperEngine::Assets;
|
||||||
|
|
||||||
CTexture::CTexture (const void* fileData) : m_resolution () {
|
CTexture::CTexture (const void* fileData) : m_resolution () {
|
||||||
@ -17,7 +20,7 @@ CTexture::CTexture (const void* fileData) : m_resolution () {
|
|||||||
this->m_resolution = {this->m_header->textureWidth, this->m_header->textureHeight, this->m_header->gifWidth,
|
this->m_resolution = {this->m_header->textureWidth, this->m_header->textureHeight, this->m_header->gifWidth,
|
||||||
this->m_header->gifHeight};
|
this->m_header->gifHeight};
|
||||||
} else {
|
} else {
|
||||||
if (this->m_header->freeImageFormat != FREE_IMAGE_FORMAT::FIF_UNKNOWN) {
|
if (this->m_header->freeImageFormat != FreeImageFormat::FIF_UNKNOWN) {
|
||||||
// wpengine-texture format always has one mipmap
|
// wpengine-texture format always has one mipmap
|
||||||
// get first image size
|
// get first image size
|
||||||
auto element = this->m_header->images.find (0)->second.begin ();
|
auto element = this->m_header->images.find (0)->second.begin ();
|
||||||
@ -31,7 +34,7 @@ CTexture::CTexture (const void* fileData) : m_resolution () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->m_header->freeImageFormat != FREE_IMAGE_FORMAT::FIF_UNKNOWN) {
|
if (this->m_header->freeImageFormat != FreeImageFormat::FIF_UNKNOWN) {
|
||||||
internalFormat = GL_RGBA8;
|
internalFormat = GL_RGBA8;
|
||||||
// set some extra information too as it's used for image sizing
|
// set some extra information too as it's used for image sizing
|
||||||
// this ensures that a_TexCoord uses the full image instead of just part of it
|
// this ensures that a_TexCoord uses the full image instead of just part of it
|
||||||
@ -92,39 +95,32 @@ CTexture::CTexture (const void* fileData) : m_resolution () {
|
|||||||
auto end = imgCur->second.end ();
|
auto end = imgCur->second.end ();
|
||||||
|
|
||||||
for (int32_t level = 0; cur != end; ++cur, level++) {
|
for (int32_t level = 0; cur != end; ++cur, level++) {
|
||||||
FIBITMAP* bitmap = nullptr;
|
stbi_uc* handle = nullptr;
|
||||||
FIBITMAP* converted = nullptr;
|
|
||||||
FIMEMORY* memory = nullptr;
|
|
||||||
void* dataptr = (*cur)->uncompressedData;
|
void* dataptr = (*cur)->uncompressedData;
|
||||||
uint32_t width = (*cur)->width;
|
int width = (*cur)->width;
|
||||||
uint32_t height = (*cur)->height;
|
int height = (*cur)->height;
|
||||||
uint32_t bufferSize = (*cur)->uncompressedSize;
|
uint32_t bufferSize = (*cur)->uncompressedSize;
|
||||||
GLenum textureFormat = GL_RGBA;
|
GLenum textureFormat = GL_RGBA;
|
||||||
|
|
||||||
if (this->m_header->freeImageFormat != FREE_IMAGE_FORMAT::FIF_UNKNOWN) {
|
if (this->m_header->freeImageFormat != FreeImageFormat::FIF_UNKNOWN) {
|
||||||
memory =
|
int fileChannels;
|
||||||
FreeImage_OpenMemory (reinterpret_cast<BYTE*> ((*cur)->uncompressedData), (*cur)->uncompressedSize);
|
|
||||||
|
|
||||||
// load the image and setup pointers so they can be used
|
dataptr = handle = stbi_load_from_memory (
|
||||||
bitmap = FreeImage_LoadFromMemory (this->m_header->freeImageFormat, memory);
|
reinterpret_cast <unsigned char*> ((*cur)->uncompressedData),
|
||||||
// flip the image vertically
|
(*cur)->uncompressedSize,
|
||||||
FreeImage_FlipVertical (bitmap);
|
&width,
|
||||||
// convert to a 32bits bytearray
|
&height,
|
||||||
converted = FreeImage_ConvertTo32Bits (bitmap);
|
&fileChannels,
|
||||||
|
4);
|
||||||
dataptr = FreeImage_GetBits (converted);
|
|
||||||
width = FreeImage_GetWidth (converted);
|
|
||||||
height = FreeImage_GetHeight (converted);
|
|
||||||
bufferSize = FreeImage_GetMemorySize (converted);
|
|
||||||
textureFormat = GL_BGRA;
|
|
||||||
} else {
|
} else {
|
||||||
if (this->m_header->format == TextureFormat::R8) {
|
if (this->m_header->format == TextureFormat::R8) {
|
||||||
// red textures are 1-byte-per-pixel, so it's alignment has to be set manually
|
// red textures are 1-byte-per-pixel, so it's alignment has to be set manually
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||||
textureFormat = GL_RED;
|
textureFormat = GL_RED;
|
||||||
} else if (this->m_header->format == TextureFormat::RG88)
|
} else if (this->m_header->format == TextureFormat::RG88) {
|
||||||
textureFormat = GL_RG;
|
textureFormat = GL_RG;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (internalFormat) {
|
switch (internalFormat) {
|
||||||
case GL_RGBA8:
|
case GL_RGBA8:
|
||||||
@ -142,11 +138,9 @@ CTexture::CTexture (const void* fileData) : m_resolution () {
|
|||||||
default: sLog.exception ("Cannot load texture, unknown format", this->m_header->format);
|
default: sLog.exception ("Cannot load texture, unknown format", this->m_header->format);
|
||||||
}
|
}
|
||||||
|
|
||||||
// freeimage buffer won't be used anymore, so free memory
|
// stbi_image buffer won't be used anymore, so free memory
|
||||||
if (this->m_header->freeImageFormat != FREE_IMAGE_FORMAT::FIF_UNKNOWN) {
|
if (this->m_header->freeImageFormat != FreeImageFormat::FIF_UNKNOWN) {
|
||||||
FreeImage_Unload (bitmap);
|
stbi_image_free (handle);
|
||||||
FreeImage_Unload (converted);
|
|
||||||
FreeImage_CloseMemory (memory);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,7 +292,7 @@ CTexture::TextureHeader* CTexture::parseHeader (const char* fileData) {
|
|||||||
if (strncmp (fileData, "TEXB0003", 9) == 0) {
|
if (strncmp (fileData, "TEXB0003", 9) == 0) {
|
||||||
header->containerVersion = ContainerVersion::TEXB0003;
|
header->containerVersion = ContainerVersion::TEXB0003;
|
||||||
header->imageCount = *pointer++;
|
header->imageCount = *pointer++;
|
||||||
header->freeImageFormat = static_cast<FREE_IMAGE_FORMAT> (*pointer++);
|
header->freeImageFormat = static_cast<FreeImageFormat> (*pointer++);
|
||||||
} else if (strncmp (fileData, "TEXB0002", 9) == 0) {
|
} else if (strncmp (fileData, "TEXB0002", 9) == 0) {
|
||||||
header->containerVersion = ContainerVersion::TEXB0002;
|
header->containerVersion = ContainerVersion::TEXB0002;
|
||||||
header->imageCount = *pointer++;
|
header->imageCount = *pointer++;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "ITexture.h"
|
#include "ITexture.h"
|
||||||
|
|
||||||
#include <FreeImage.h>
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <glm/vec4.hpp>
|
#include <glm/vec4.hpp>
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -34,6 +33,48 @@ class CTexture final : public ITexture {
|
|||||||
TEXS0003 = 1,
|
TEXS0003 = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum FreeImageFormat : int {
|
||||||
|
FIF_UNKNOWN = -1,
|
||||||
|
FIF_BMP = 0,
|
||||||
|
FIF_ICO = 1,
|
||||||
|
FIF_JPEG = 2,
|
||||||
|
FIF_JNG = 3,
|
||||||
|
FIF_KOALA = 4,
|
||||||
|
FIF_LBM = 5,
|
||||||
|
FIF_IFF = FIF_LBM,
|
||||||
|
FIF_MNG = 6,
|
||||||
|
FIF_PBM = 7,
|
||||||
|
FIF_PBMRAW = 8,
|
||||||
|
FIF_PCD = 9,
|
||||||
|
FIF_PCX = 10,
|
||||||
|
FIF_PGM = 11,
|
||||||
|
FIF_PGMRAW = 12,
|
||||||
|
FIF_PNG = 13,
|
||||||
|
FIF_PPM = 14,
|
||||||
|
FIF_PPMRAW = 15,
|
||||||
|
FIF_RAS = 16,
|
||||||
|
FIF_TARGA = 17,
|
||||||
|
FIF_TIFF = 18,
|
||||||
|
FIF_WBMP = 19,
|
||||||
|
FIF_PSD = 20,
|
||||||
|
FIF_CUT = 21,
|
||||||
|
FIF_XBM = 22,
|
||||||
|
FIF_XPM = 23,
|
||||||
|
FIF_DDS = 24,
|
||||||
|
FIF_GIF = 25,
|
||||||
|
FIF_HDR = 26,
|
||||||
|
FIF_FAXG3 = 27,
|
||||||
|
FIF_SGI = 28,
|
||||||
|
FIF_EXR = 29,
|
||||||
|
FIF_J2K = 30,
|
||||||
|
FIF_JP2 = 31,
|
||||||
|
FIF_PFM = 32,
|
||||||
|
FIF_PICT = 33,
|
||||||
|
FIF_RAW = 34,
|
||||||
|
FIF_WEBP = 35,
|
||||||
|
FIF_JXR = 36
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Texture mipmap data
|
* Texture mipmap data
|
||||||
*/
|
*/
|
||||||
@ -93,7 +134,7 @@ class CTexture final : public ITexture {
|
|||||||
/** Texture data format */
|
/** Texture data format */
|
||||||
TextureFormat format;
|
TextureFormat format;
|
||||||
/** Free Image format */
|
/** Free Image format */
|
||||||
FREE_IMAGE_FORMAT freeImageFormat = FREE_IMAGE_FORMAT::FIF_UNKNOWN;
|
FreeImageFormat freeImageFormat = FreeImageFormat::FIF_UNKNOWN;
|
||||||
/** The amount of images in the texture file */
|
/** The amount of images in the texture file */
|
||||||
uint32_t imageCount;
|
uint32_t imageCount;
|
||||||
/** Number of mipmap levels on the texture */
|
/** Number of mipmap levels on the texture */
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "CGLFWOpenGLDriver.h"
|
#include "CGLFWOpenGLDriver.h"
|
||||||
#include "WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h"
|
#include "WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <FreeImage.h>
|
|
||||||
|
|
||||||
#define GLFW_EXPOSE_NATIVE_X11
|
#define GLFW_EXPOSE_NATIVE_X11
|
||||||
#include <GLFW/glfw3native.h>
|
#include <GLFW/glfw3native.h>
|
||||||
@ -61,9 +60,6 @@ CGLFWOpenGLDriver::CGLFWOpenGLDriver (const char* windowTitle, CApplicationConte
|
|||||||
if (result != GLEW_OK)
|
if (result != GLEW_OK)
|
||||||
sLog.error ("Failed to initialize GLEW: ", glewGetErrorString (result));
|
sLog.error ("Failed to initialize GLEW: ", glewGetErrorString (result));
|
||||||
|
|
||||||
// initialize free image
|
|
||||||
FreeImage_Initialise (TRUE);
|
|
||||||
|
|
||||||
// setup output
|
// setup output
|
||||||
if (context.settings.render.mode == CApplicationContext::EXPLICIT_WINDOW ||
|
if (context.settings.render.mode == CApplicationContext::EXPLICIT_WINDOW ||
|
||||||
context.settings.render.mode == CApplicationContext::NORMAL_WINDOW) {
|
context.settings.render.mode == CApplicationContext::NORMAL_WINDOW) {
|
||||||
@ -82,7 +78,6 @@ CGLFWOpenGLDriver::CGLFWOpenGLDriver (const char* windowTitle, CApplicationConte
|
|||||||
|
|
||||||
CGLFWOpenGLDriver::~CGLFWOpenGLDriver () {
|
CGLFWOpenGLDriver::~CGLFWOpenGLDriver () {
|
||||||
glfwTerminate ();
|
glfwTerminate ();
|
||||||
FreeImage_DeInitialise ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Output::COutput& CGLFWOpenGLDriver::getOutput () {
|
Output::COutput& CGLFWOpenGLDriver::getOutput () {
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#include "CWaylandOpenGLDriver.h"
|
#include "CWaylandOpenGLDriver.h"
|
||||||
#include "WallpaperEngine/Application/CWallpaperApplication.h"
|
#include "WallpaperEngine/Application/CWallpaperApplication.h"
|
||||||
|
|
||||||
#include <FreeImage.h>
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#define class _class
|
#define class _class
|
||||||
@ -255,8 +253,6 @@ CWaylandOpenGLDriver::CWaylandOpenGLDriver (CApplicationContext& context, CWallp
|
|||||||
|
|
||||||
if (result != GLEW_OK)
|
if (result != GLEW_OK)
|
||||||
sLog.error ("Failed to initialize GLEW: ", glewGetErrorString (result));
|
sLog.error ("Failed to initialize GLEW: ", glewGetErrorString (result));
|
||||||
|
|
||||||
FreeImage_Initialise (TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CWaylandOpenGLDriver::~CWaylandOpenGLDriver () {
|
CWaylandOpenGLDriver::~CWaylandOpenGLDriver () {
|
||||||
|
Loading…
Reference in New Issue
Block a user