-
-
Notifications
You must be signed in to change notification settings - Fork 404
DirectX9 Grabber #1039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Paulchen-Panther
merged 8 commits into
hyperion-project:master
from
Paulchen-Panther:directx
Oct 26, 2020
Merged
DirectX9 Grabber #1039
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fd2bc13
DirectX Windows grabber added
Paulchen-Panther 26f1cee
Resize destination image with DirectX
Paulchen-Panther 4c464eb
DirectX-SDK added to CI/CD Workflows
Paulchen-Panther 7d7aa1d
Removed double QT default set
Paulchen-Panther 7569097
corrected color byte order
Paulchen-Panther 42f0bae
Merge branch 'directx' of https://github.com/Paulchen-Panther/hyperio…
Paulchen-Panther 8896b75
Merge branch 'master' into directx
Paulchen-Panther 56689aa
Merge branch 'master' into directx
Paulchen-Panther File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Find the DirectX 9 includes and library | ||
# This module defines: | ||
# DIRECTX9_INCLUDE_DIRS, where to find d3d9.h, etc. | ||
# DIRECTX9_LIBRARIES, libraries to link against to use DirectX. | ||
# DIRECTX9_FOUND, If false, do not try to use DirectX. | ||
# DIRECTX9_ROOT_DIR, directory where DirectX was installed. | ||
|
||
set(DIRECTX9_INCLUDE_PATHS | ||
"$ENV{DXSDK_DIR}/Include" | ||
"$ENV{DIRECTX_ROOT}/Include" | ||
"C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Include" | ||
"C:/Program Files/Microsoft DirectX SDK (June 2010)/Include" | ||
) | ||
find_path(DIRECTX9_INCLUDE_DIRS d3dx9.h ${DIRECTX9_INCLUDE_PATHS} NO_DEFAULT_PATH) | ||
|
||
get_filename_component(DIRECTX9_ROOT_DIR "${DIRECTX9_INCLUDE_DIRS}/.." ABSOLUTE) | ||
|
||
if (CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
set(DIRECTX9_LIBRARY_PATHS "${DIRECTX9_ROOT_DIR}/Lib/x64") | ||
else () | ||
set(DIRECTX9_LIBRARY_PATHS "${DIRECTX9_ROOT_DIR}/Lib/x86" "${DIRECTX9_ROOT_DIR}/Lib") | ||
endif () | ||
|
||
find_library(DIRECTX9_D3D9_LIBRARY d3d9 ${DIRECTX9_LIBRARY_PATHS} NO_DEFAULT_PATH) | ||
find_library(DIRECTX9_D3DX9_LIBRARY d3dx9 ${DIRECTX9_LIBRARY_PATHS} NO_DEFAULT_PATH) | ||
find_library(DIRECTX9_DXERR_LIBRARY DxErr ${DIRECTX9_LIBRARY_PATHS} NO_DEFAULT_PATH) | ||
set(DIRECTX9_LIBRARIES ${DIRECTX9_D3D9_LIBRARY} ${DIRECTX9_D3DX9_LIBRARY} ${DIRECTX9_DXERR_LIBRARY}) | ||
|
||
# handle the QUIETLY and REQUIRED arguments and set DIRECTX9_FOUND to TRUE if all listed variables are TRUE | ||
include(FindPackageHandleStandardArgs) | ||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DirectX9 DEFAULT_MSG DIRECTX9_ROOT_DIR DIRECTX9_LIBRARIES DIRECTX9_INCLUDE_DIRS) | ||
mark_as_advanced(DIRECTX9_INCLUDE_DIRS DIRECTX9_D3D9_LIBRARY DIRECTX9_D3DX9_LIBRARY DIRECTX9_DXERR_LIBRARY) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#pragma once | ||
|
||
#include <QObject> | ||
|
||
// DirectX 9 header | ||
#include <d3d9.h> | ||
#include <d3dx9.h> | ||
|
||
// Hyperion-utils includes | ||
#include <utils/ColorRgb.h> | ||
#include <hyperion/Grabber.h> | ||
|
||
/// | ||
/// @brief The DirectX9 capture implementation | ||
/// | ||
class DirectXGrabber : public Grabber | ||
{ | ||
public: | ||
|
||
DirectXGrabber(int cropLeft, int cropRight, int cropTop, int cropBottom, int pixelDecimation, int display); | ||
|
||
virtual ~DirectXGrabber(); | ||
|
||
/// | ||
/// Captures a single snapshot of the display and writes the data to the given image. The | ||
/// provided image should have the same dimensions as the configured values (_width and | ||
/// _height) | ||
/// | ||
/// @param[out] image The snapped screenshot | ||
/// | ||
virtual int grabFrame(Image<ColorRgb> & image); | ||
|
||
/// | ||
/// @brief Set a new video mode | ||
/// | ||
virtual void setVideoMode(VideoMode mode); | ||
|
||
/// | ||
/// @brief Apply new width/height values, overwrite Grabber.h implementation | ||
/// | ||
virtual bool setWidthHeight(int width, int height) { return true; }; | ||
|
||
/// | ||
/// @brief Apply new pixelDecimation | ||
/// | ||
virtual void setPixelDecimation(int pixelDecimation); | ||
|
||
/// | ||
/// Set the crop values | ||
/// @param cropLeft Left pixel crop | ||
/// @param cropRight Right pixel crop | ||
/// @param cropTop Top pixel crop | ||
/// @param cropBottom Bottom pixel crop | ||
/// | ||
virtual void setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom); | ||
|
||
private: | ||
/// | ||
/// @brief Setup a new capture display, will free the previous one | ||
/// @return True on success, false if no display is found | ||
/// | ||
bool setupDisplay(); | ||
|
||
/// | ||
/// @brief free the _screen pointer | ||
/// | ||
void freeResources(); | ||
|
||
private: | ||
int _pixelDecimation; | ||
unsigned _displayWidth; | ||
unsigned _displayHeight; | ||
RECT* _srcRect; | ||
|
||
IDirect3D9* _d3d9; | ||
IDirect3DDevice9* _device; | ||
IDirect3DSurface9* _surface; | ||
IDirect3DSurface9* _surfaceDest; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
|
||
#include <hyperion/GrabberWrapper.h> | ||
#include <grabber/DirectXGrabber.h> | ||
|
||
class DirectXWrapper: public GrabberWrapper | ||
{ | ||
public: | ||
/// | ||
/// Constructs the DirectX grabber with a specified grab size and update rate. | ||
/// | ||
/// @param[in] cropLeft Remove from left [pixels] | ||
/// @param[in] cropRight Remove from right [pixels] | ||
/// @param[in] cropTop Remove from top [pixels] | ||
/// @param[in] cropBottom Remove from bottom [pixels] | ||
/// @param[in] pixelDecimation Decimation factor for image [pixels] | ||
/// @param[in] display The display used[index] | ||
/// @param[in] updateRate_Hz The image grab rate [Hz] | ||
/// | ||
DirectXWrapper(int cropLeft, int cropRight, int cropTop, int cropBottom, int pixelDecimation, int display, const unsigned updateRate_Hz); | ||
|
||
/// | ||
/// Destructor of this DirectX grabber. Releases any claimed resources. | ||
/// | ||
virtual ~DirectXWrapper() {}; | ||
|
||
public slots: | ||
/// | ||
/// Performs a single frame grab and computes the led-colors | ||
/// | ||
virtual void action(); | ||
|
||
private: | ||
/// The actual grabber | ||
DirectXGrabber _grabber; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,7 @@ endif() | |
if (ENABLE_QT) | ||
add_subdirectory(qt) | ||
endif() | ||
|
||
if (ENABLE_DX) | ||
add_subdirectory(directx) | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Define the current source locations | ||
SET( CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber ) | ||
SET( CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/directx ) | ||
|
||
include_directories(${DIRECTX9_INCLUDE_DIRS}) | ||
|
||
FILE ( GLOB DIRECTX_GRAB_SOURCES "${CURRENT_HEADER_DIR}/DirectX*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) | ||
|
||
add_library( directx-grabber ${DIRECTX_GRAB_SOURCES} ) | ||
|
||
target_link_libraries(directx-grabber | ||
hyperion | ||
${DIRECTX9_LIBRARIES} | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.