mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-01-11 08:39:12 +01:00
convert to SDL 1.2
Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
parent
14efe60ec0
commit
d23cf74c1d
87
RetroFE/CMake/FindSDL.cmake
Normal file
87
RetroFE/CMake/FindSDL.cmake
Normal file
@ -0,0 +1,87 @@
|
||||
# - Find SDL library and headers
|
||||
#
|
||||
# Find module for SDL 2.0 (http://www.libsdl.org/).
|
||||
# It defines the following variables:
|
||||
# SDL_INCLUDE_DIRS - The location of the headers, e.g., SDL.h.
|
||||
# SDL_LIBRARIES - The libraries to link against to use SDL.
|
||||
# SDL_FOUND - If false, do not try to use SDL.
|
||||
# SDL_VERSION_STRING - Human-readable string containing the version of SDL.
|
||||
#
|
||||
# This module responds to the the flag:
|
||||
# SDL_BUILDING_LIBRARY
|
||||
# If this is defined, then no SDL_main will be linked in because
|
||||
# only applications need main().
|
||||
# Otherwise, it is assumed you are building an application and this
|
||||
# module will attempt to locate and set the the proper link flags
|
||||
# as part of the returned SDL_LIBRARIES variable.
|
||||
#
|
||||
# Also defined, but not for general use are:
|
||||
# SDL_INCLUDE_DIR - The directory that contains SDL.h.
|
||||
# SDL_LIBRARY - The location of the SDL library.
|
||||
# SDLMAIN_LIBRARY - The location of the SDLmain library.
|
||||
#
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2013 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_SDL QUIET sdl)
|
||||
|
||||
find_path(SDL_INCLUDE_DIR
|
||||
NAMES SDL/SDL.h
|
||||
HINTS
|
||||
${SDL_ROOT}/include
|
||||
)
|
||||
|
||||
find_library(SDL_LIBRARY
|
||||
NAMES SDL
|
||||
HINTS
|
||||
${SDL_ROOT}/lib
|
||||
PATH_SUFFIXES x86
|
||||
)
|
||||
|
||||
if(NOT SDL_BUILDING_LIBRARY)
|
||||
find_library(SDLMAIN_LIBRARY
|
||||
NAMES SDLmain
|
||||
HINTS
|
||||
${SDL_ROOT}/lib
|
||||
PATH_SUFFIXES x86
|
||||
)
|
||||
endif()
|
||||
|
||||
if(SDL_INCLUDE_DIR AND EXISTS "${SDL_INCLUDE_DIR}/SDL/SDL_version.h")
|
||||
file(STRINGS "${SDL_INCLUDE_DIR}/SDL/SDL_version.h" SDL_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL_INCLUDE_DIR}/SDL/SDL_version.h" SDL_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL_INCLUDE_DIR}/SDL/SDL_version.h" SDL_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_VERSION_MAJOR "${SDL_VERSION_MAJOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_VERSION_MINOR "${SDL_VERSION_MINOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_VERSION_PATCH "${SDL_VERSION_PATCH_LINE}")
|
||||
set(SDL_VERSION_STRING ${SDL_VERSION_MAJOR}.${SDL_VERSION_MINOR}.${SDL_VERSION_PATCH})
|
||||
unset(SDL_VERSION_MAJOR_LINE)
|
||||
unset(SDL_VERSION_MINOR_LINE)
|
||||
unset(SDL_VERSION_PATCH_LINE)
|
||||
unset(SDL_VERSION_MAJOR)
|
||||
unset(SDL_VERSION_MINOR)
|
||||
unset(SDL_VERSION_PATCH)
|
||||
endif()
|
||||
|
||||
set(SDL_INCLUDE_DIRS ${SDL_INCLUDE_DIR} ${SDL_INCLUDE_DIR}/SDL)
|
||||
set(SDL_LIBRARIES ${SDLMAIN_LIBRARY} ${SDL_LIBRARY})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(SDL
|
||||
REQUIRED_VARS SDL_INCLUDE_DIR SDL_LIBRARY
|
||||
VERSION_VAR SDL_VERSION_STRING)
|
||||
|
||||
mark_as_advanced(SDL_INCLUDE_DIR SDL_LIBRARY)
|
||||
73
RetroFE/CMake/FindSDL_gfx.cmake
Normal file
73
RetroFE/CMake/FindSDL_gfx.cmake
Normal file
@ -0,0 +1,73 @@
|
||||
# Downloaded from http://cmake.3232098.n2.nabble.com/Find-modules-for-SDL-td7585211.html and adapted to SDL_gfx
|
||||
#
|
||||
# - Find SDL_gfx library and headers
|
||||
#
|
||||
# Find module for SDL_gfx 2.0 (http://www.libsdl.org/projects/SDL_gfx/).
|
||||
# It defines the following variables:
|
||||
# SDL_GFX_INCLUDE_DIRS - The location of the headers, e.g., SDL_gfx.h.
|
||||
# SDL_GFX_LIBRARIES - The libraries to link against to use SDL_gfx.
|
||||
# SDL_GFX_FOUND - If false, do not try to use SDL_gfx.
|
||||
# SDL_GFX_VERSION_STRING
|
||||
# Human-readable string containing the version of SDL_gfx.
|
||||
#
|
||||
# Also defined, but not for general use are:
|
||||
# SDL_GFX_INCLUDE_DIR - The directory that contains SDL_gfx.h.
|
||||
# SDL_GFX_LIBRARY - The location of the SDL_gfx library.
|
||||
#
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2013 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_SDL_GFX QUIET SDL_gfx)
|
||||
|
||||
find_path(SDL_GFX_INCLUDE_DIR
|
||||
NAMES SDL/SDL_rotozoom.h
|
||||
HINTS
|
||||
${SDL_GFX_ROOT}
|
||||
PATH_SUFFIXES include
|
||||
)
|
||||
|
||||
find_library(SDL_GFX_LIBRARY
|
||||
NAMES SDL_gfx
|
||||
HINTS
|
||||
${SDL_GFX_ROOT}/lib
|
||||
PATH_SUFFIXES x86
|
||||
)
|
||||
|
||||
if(SDL_GFX_INCLUDE_DIR AND EXISTS "${SDL_GFX_INCLUDE_DIR}/SDL/SDL_gfx.h")
|
||||
file(STRINGS "${SDL_GFX_INCLUDE_DIR}/SDL/SDL_gfx.h" SDL_GFX_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_GFX_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL_GFX_INCLUDE_DIR}/SDL/SDL_gfx.h" SDL_GFX_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_GFX_MINOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL_GFX_INCLUDE_DIR}/SDL/SDL_gfx.h" SDL_GFX_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_GFX_PATCHLEVEL[ \t]+[0-9]+$")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_GFX_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_GFX_VERSION_MAJOR "${SDL_GFX_VERSION_MAJOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_GFX_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_GFX_VERSION_MINOR "${SDL_GFX_VERSION_MINOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_GFX_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_GFX_VERSION_PATCH "${SDL_GFX_VERSION_PATCH_LINE}")
|
||||
set(SDL_GFX_VERSION_STRING ${SDL_GFX_VERSION_MAJOR}.${SDL_GFX_VERSION_MINOR}.${SDL_GFX_VERSION_PATCH})
|
||||
unset(SDL_GFX_VERSION_MAJOR_LINE)
|
||||
unset(SDL_GFX_VERSION_MINOR_LINE)
|
||||
unset(SDL_GFX_VERSION_PATCH_LINE)
|
||||
unset(SDL_GFX_VERSION_MAJOR)
|
||||
unset(SDL_GFX_VERSION_MINOR)
|
||||
unset(SDL_GFX_VERSION_PATCH)
|
||||
endif()
|
||||
|
||||
set(SDL_GFX_INCLUDE_DIRS ${SDL_GFX_INCLUDE_DIR} ${SDL_GFX_INCLUDE_DIR}/SDL)
|
||||
set(SDL_GFX_LIBRARIES ${SDL_GFX_LIBRARY})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(SDL_gfx
|
||||
REQUIRED_VARS SDL_GFX_INCLUDE_DIRS SDL_GFX_LIBRARIES
|
||||
VERSION_VAR SDL_GFX_VERSION_STRING)
|
||||
|
||||
mark_as_advanced(SDL_GFX_INCLUDE_DIR SDL_GFX_LIBRARY)
|
||||
70
RetroFE/CMake/FindSDL_image.cmake
Normal file
70
RetroFE/CMake/FindSDL_image.cmake
Normal file
@ -0,0 +1,70 @@
|
||||
# - Find SDL_image library and headers
|
||||
#
|
||||
# Find module for SDL_image 2.0 (http://www.libsdl.org/projects/SDL_image/).
|
||||
# It defines the following variables:
|
||||
# SDL_IMAGE_INCLUDE_DIRS - The location of the headers, e.g., SDL_image.h.
|
||||
# SDL_IMAGE_LIBRARIES - The libraries to link against to use SDL_image.
|
||||
# SDL_IMAGE_FOUND - If false, do not try to use SDL_image.
|
||||
# SDL_IMAGE_VERSION_STRING
|
||||
# Human-readable string containing the version of SDL_image.
|
||||
#
|
||||
# Also defined, but not for general use are:
|
||||
# SDL_IMAGE_INCLUDE_DIR - The directory that contains SDL_image.h.
|
||||
# SDL_IMAGE_LIBRARY - The location of the SDL_image library.
|
||||
#
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2013 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_SDL_IMAGE QUIET SDL_image)
|
||||
|
||||
find_path(SDL_IMAGE_INCLUDE_DIR
|
||||
NAMES SDL/SDL_image.h
|
||||
HINTS
|
||||
${SDL_IMAGE_ROOT}/include
|
||||
)
|
||||
|
||||
find_library(SDL_IMAGE_LIBRARY
|
||||
NAMES SDL_image
|
||||
HINTS
|
||||
${SDL_IMAGE_ROOT}/lib
|
||||
PATH_SUFFIXES x86
|
||||
)
|
||||
|
||||
if(SDL_IMAGE_INCLUDE_DIR AND EXISTS "${SDL_IMAGE_INCLUDE_DIR}/SDL/SDL_image.h")
|
||||
file(STRINGS "${SDL_IMAGE_INCLUDE_DIR}/SDL/SDL_image.h" SDL_IMAGE_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL_IMAGE_INCLUDE_DIR}/SDL/SDL_image.h" SDL_IMAGE_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL_IMAGE_INCLUDE_DIR}/SDL/SDL_image.h" SDL_IMAGE_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+[0-9]+$")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_IMAGE_VERSION_MAJOR "${SDL_IMAGE_VERSION_MAJOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_IMAGE_VERSION_MINOR "${SDL_IMAGE_VERSION_MINOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_IMAGE_VERSION_PATCH "${SDL_IMAGE_VERSION_PATCH_LINE}")
|
||||
set(SDL_IMAGE_VERSION_STRING ${SDL_IMAGE_VERSION_MAJOR}.${SDL_IMAGE_VERSION_MINOR}.${SDL_IMAGE_VERSION_PATCH})
|
||||
unset(SDL_IMAGE_VERSION_MAJOR_LINE)
|
||||
unset(SDL_IMAGE_VERSION_MINOR_LINE)
|
||||
unset(SDL_IMAGE_VERSION_PATCH_LINE)
|
||||
unset(SDL_IMAGE_VERSION_MAJOR)
|
||||
unset(SDL_IMAGE_VERSION_MINOR)
|
||||
unset(SDL_IMAGE_VERSION_PATCH)
|
||||
endif()
|
||||
|
||||
set(SDL_IMAGE_INCLUDE_DIRS ${SDL_IMAGE_INCLUDE_DIR} ${SDL_IMAGE_INCLUDE_DIR}/SDL)
|
||||
set(SDL_IMAGE_LIBRARIES ${SDL_IMAGE_LIBRARY})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(SDL_image
|
||||
REQUIRED_VARS SDL_IMAGE_INCLUDE_DIRS SDL_IMAGE_LIBRARIES
|
||||
VERSION_VAR SDL_IMAGE_VERSION_STRING)
|
||||
|
||||
mark_as_advanced(SDL_IMAGE_INCLUDE_DIR SDL_IMAGE_LIBRARY)
|
||||
72
RetroFE/CMake/FindSDL_mixer.cmake
Normal file
72
RetroFE/CMake/FindSDL_mixer.cmake
Normal file
@ -0,0 +1,72 @@
|
||||
# Downloaded from http://cmake.3232098.n2.nabble.com/Find-modules-for-SDL-td7585211.html and adapted to SDL_mixer
|
||||
#
|
||||
# - Find SDL_mixer library and headers
|
||||
#
|
||||
# Find module for SDL_mixer 2.0 (http://www.libsdl.org/projects/SDL_mixer/).
|
||||
# It defines the following variables:
|
||||
# SDL_MIXER_INCLUDE_DIRS - The location of the headers, e.g., SDL_mixer.h.
|
||||
# SDL_MIXER_LIBRARIES - The libraries to link against to use SDL_mixer.
|
||||
# SDL_MIXER_FOUND - If false, do not try to use SDL_mixer.
|
||||
# SDL_MIXER_VERSION_STRING
|
||||
# Human-readable string containing the version of SDL_mixer.
|
||||
#
|
||||
# Also defined, but not for general use are:
|
||||
# SDL_MIXER_INCLUDE_DIR - The directory that contains SDL_mixer.h.
|
||||
# SDL_MIXER_LIBRARY - The location of the SDL_mixer library.
|
||||
#
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2013 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_SDL_MIXER QUIET SDL_mixer)
|
||||
|
||||
find_path(SDL_MIXER_INCLUDE_DIR
|
||||
NAMES SDL/SDL_mixer.h
|
||||
HINTS
|
||||
${SDL_MIXER_ROOT}/include
|
||||
)
|
||||
|
||||
find_library(SDL_MIXER_LIBRARY
|
||||
NAMES SDL_mixer
|
||||
HINTS
|
||||
${SDL_MIXER_ROOT}/lib
|
||||
PATH_SUFFIXES x86
|
||||
)
|
||||
|
||||
if(SDL_MIXER_INCLUDE_DIR AND EXISTS "${SDL_MIXER_INCLUDE_DIR}/SDL/SDL_mixer.h")
|
||||
file(STRINGS "${SDL_MIXER_INCLUDE_DIR}/SDL/SDL_mixer.h" SDL_MIXER_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL_MIXER_INCLUDE_DIR}/SDL/SDL_mixer.h" SDL_MIXER_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL_MIXER_INCLUDE_DIR}/SDL/SDL_mixer.h" SDL_MIXER_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+[0-9]+$")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_MAJOR "${SDL_MIXER_VERSION_MAJOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_MINOR "${SDL_MIXER_VERSION_MINOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_PATCH "${SDL_MIXER_VERSION_PATCH_LINE}")
|
||||
set(SDL_MIXER_VERSION_STRING ${SDL_MIXER_VERSION_MAJOR}.${SDL_MIXER_VERSION_MINOR}.${SDL_MIXER_VERSION_PATCH})
|
||||
unset(SDL_MIXER_VERSION_MAJOR_LINE)
|
||||
unset(SDL_MIXER_VERSION_MINOR_LINE)
|
||||
unset(SDL_MIXER_VERSION_PATCH_LINE)
|
||||
unset(SDL_MIXER_VERSION_MAJOR)
|
||||
unset(SDL_MIXER_VERSION_MINOR)
|
||||
unset(SDL_MIXER_VERSION_PATCH)
|
||||
endif()
|
||||
|
||||
set(SDL_MIXER_INCLUDE_DIRS ${SDL_MIXER_INCLUDE_DIR} ${SDL_MIXER_INCLUDE_DIR}/SDL)
|
||||
set(SDL_MIXER_LIBRARIES ${SDL_MIXER_LIBRARY})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(SDL_mixer
|
||||
REQUIRED_VARS SDL_MIXER_INCLUDE_DIRS SDL_MIXER_LIBRARIES
|
||||
VERSION_VAR SDL_MIXER_VERSION_STRING)
|
||||
|
||||
mark_as_advanced(SDL_MIXER_INCLUDE_DIR SDL_MIXER_LIBRARY)
|
||||
73
RetroFE/CMake/FindSDL_ttf.cmake
Normal file
73
RetroFE/CMake/FindSDL_ttf.cmake
Normal file
@ -0,0 +1,73 @@
|
||||
# Downloaded from http://cmake.3232098.n2.nabble.com/Find-modules-for-SDL-td7585211.html and adapted to SDL_ttf
|
||||
#
|
||||
# - Find SDL_ttf library and headers
|
||||
#
|
||||
# Find module for SDL_ttf 2.0 (http://www.libsdl.org/projects/SDL_ttf/).
|
||||
# It defines the following variables:
|
||||
# SDL_TTF_INCLUDE_DIRS - The location of the headers, e.g., SDL_ttf.h.
|
||||
# SDL_TTF_LIBRARIES - The libraries to link against to use SDL_ttf.
|
||||
# SDL_TTF_FOUND - If false, do not try to use SDL_ttf.
|
||||
# SDL_TTF_VERSION_STRING
|
||||
# Human-readable string containing the version of SDL_ttf.
|
||||
#
|
||||
# Also defined, but not for general use are:
|
||||
# SDL_TTF_INCLUDE_DIR - The directory that contains SDL_ttf.h.
|
||||
# SDL_TTF_LIBRARY - The location of the SDL_ttf library.
|
||||
#
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2013 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_SDL_TTF QUIET SDL_ttf)
|
||||
|
||||
find_path(SDL_TTF_INCLUDE_DIR
|
||||
NAMES SDL/SDL_ttf.h
|
||||
HINTS
|
||||
${SDL_TTF_ROOT}
|
||||
PATH_SUFFIXES include
|
||||
)
|
||||
|
||||
find_library(SDL_TTF_LIBRARY
|
||||
NAMES SDL_ttf
|
||||
HINTS
|
||||
${SDL_TTF_ROOT}/lib
|
||||
PATH_SUFFIXES x86
|
||||
)
|
||||
|
||||
if(SDL_TTF_INCLUDE_DIR AND EXISTS "${SDL_TTF_INCLUDE_DIR}/SDL/SDL_ttf.h")
|
||||
file(STRINGS "${SDL_TTF_INCLUDE_DIR}/SDL/SDL_ttf.h" SDL_TTF_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL_TTF_INCLUDE_DIR}/SDL/SDL_ttf.h" SDL_TTF_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL_TTF_INCLUDE_DIR}/SDL/SDL_ttf.h" SDL_TTF_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+[0-9]+$")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_MAJOR "${SDL_TTF_VERSION_MAJOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_MINOR "${SDL_TTF_VERSION_MINOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_PATCH "${SDL_TTF_VERSION_PATCH_LINE}")
|
||||
set(SDL_TTF_VERSION_STRING ${SDL_TTF_VERSION_MAJOR}.${SDL_TTF_VERSION_MINOR}.${SDL_TTF_VERSION_PATCH})
|
||||
unset(SDL_TTF_VERSION_MAJOR_LINE)
|
||||
unset(SDL_TTF_VERSION_MINOR_LINE)
|
||||
unset(SDL_TTF_VERSION_PATCH_LINE)
|
||||
unset(SDL_TTF_VERSION_MAJOR)
|
||||
unset(SDL_TTF_VERSION_MINOR)
|
||||
unset(SDL_TTF_VERSION_PATCH)
|
||||
endif()
|
||||
|
||||
set(SDL_TTF_INCLUDE_DIRS ${SDL_TTF_INCLUDE_DIR} ${SDL_TTF_INCLUDE_DIR}/SDL)
|
||||
set(SDL_TTF_LIBRARIES ${SDL_TTF_LIBRARY})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(SDL_ttf
|
||||
REQUIRED_VARS SDL_TTF_INCLUDE_DIRS SDL_TTF_LIBRARIES
|
||||
VERSION_VAR SDL_TTF_VERSION_STRING)
|
||||
|
||||
mark_as_advanced(SDL_TTF_INCLUDE_DIR SDL_TTF_LIBRARY)
|
||||
@ -40,24 +40,35 @@ endif()
|
||||
if(WIN32)
|
||||
find_package(Glib2 REQUIRED)
|
||||
find_package(GStreamer REQUIRED)
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(SDL2_image REQUIRED)
|
||||
find_package(SDL2_mixer REQUIRED)
|
||||
find_package(SDL2_ttf REQUIRED)
|
||||
#find_package(SDL2 REQUIRED)
|
||||
#find_package(SDL2_image REQUIRED)
|
||||
#find_package(SDL2_mixer REQUIRED)
|
||||
#find_package(SDL2_ttf REQUIRED)
|
||||
find_package(SDL REQUIRED )
|
||||
find_package(SDL_image REQUIRED )
|
||||
find_package(SDL_mixer REQUIRED SDL_mixer)
|
||||
find_package(SDL_ttf REQUIRED )
|
||||
find_package(SDL_gfx REQUIRED )
|
||||
find_package(ZLIB REQUIRED)
|
||||
else()
|
||||
include(FindPkgConfig)
|
||||
pkg_search_module(SDL2 REQUIRED sdl2)
|
||||
pkg_search_module(SDL2_IMAGE REQUIRED SDL2_image)
|
||||
pkg_search_module(SDL2_MIXER REQUIRED SDL2_mixer)
|
||||
pkg_search_module(SDL2_TTF REQUIRED SDL2_ttf)
|
||||
#pkg_search_module(SDL2 REQUIRED sdl2)
|
||||
#pkg_search_module(SDL2_IMAGE REQUIRED SDL2_image)
|
||||
#pkg_search_module(SDL2_MIXER REQUIRED SDL2_mixer)
|
||||
#pkg_search_module(SDL2_TTF REQUIRED SDL2_ttf)
|
||||
find_package(SDL REQUIRED )
|
||||
find_package(SDL_image REQUIRED )
|
||||
find_package(SDL_mixer REQUIRED SDL_mixer)
|
||||
find_package(SDL_ttf REQUIRED )
|
||||
find_package(SDL_gfx REQUIRED )
|
||||
pkg_search_module(ZLIB REQUIRED zlib)
|
||||
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0 gstreamer-video-1.0)
|
||||
pkg_check_modules(Glib2 REQUIRED glib-2.0 gobject-2.0 gthread-2.0 gmodule-2.0)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
if(APPLE)
|
||||
find_package(SDL2 REQUIRED)
|
||||
#find_package(SDL2 REQUIRED)
|
||||
find_package(SDL REQUIRED )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -65,10 +76,15 @@ set(RETROFE_INCLUDE_DIRS
|
||||
"/usr/local/opt/gst-plugins-base/include/gstreamer-1.0"
|
||||
"${GLIB2_INCLUDE_DIRS}"
|
||||
"${GSTREAMER_INCLUDE_DIRS}"
|
||||
"${SDL2_INCLUDE_DIRS}"
|
||||
"${SDL2_IMAGE_INCLUDE_DIRS}"
|
||||
"${SDL2_MIXER_INCLUDE_DIRS}"
|
||||
"${SDL2_TTF_INCLUDE_DIRS}"
|
||||
#"${SDL2_INCLUDE_DIRS}"
|
||||
#"${SDL2_IMAGE_INCLUDE_DIRS}"
|
||||
#"${SDL2_MIXER_INCLUDE_DIRS}"
|
||||
#"${SDL2_TTF_INCLUDE_DIRS}"
|
||||
"${SDL_INCLUDE_DIRS}"
|
||||
"${SDL_IMAGE_INCLUDE_DIRS}"
|
||||
"${SDL_MIXER_INCLUDE_DIRS}"
|
||||
"${SDL_TTF_INCLUDE_DIRS}"
|
||||
"${SDL_GFX_INCLUDE_DIRS}"
|
||||
"${ZLIB_INCLUDE_DIRS}"
|
||||
"${SQLITE3_ROOT}"
|
||||
"${RAPIDXML_ROOT}"
|
||||
@ -81,10 +97,15 @@ endif()
|
||||
set(RETROFE_LIBRARIES
|
||||
${GLIB2_LIBRARIES}
|
||||
${GSTREAMER_LIBRARIES}
|
||||
${SDL2_LIBRARIES}
|
||||
${SDL2_IMAGE_LIBRARIES}
|
||||
${SDL2_MIXER_LIBRARIES}
|
||||
${SDL2_TTF_LIBRARIES}
|
||||
#${SDL2_LIBRARIES}
|
||||
#${SDL2_IMAGE_LIBRARIES}
|
||||
#${SDL2_MIXER_LIBRARIES}
|
||||
#${SDL2_TTF_LIBRARIES}
|
||||
${SDL_LIBRARIES}
|
||||
${SDL_IMAGE_LIBRARIES}
|
||||
${SDL_MIXER_LIBRARIES}
|
||||
${SDL_TTF_LIBRARIES}
|
||||
${SDL_GFX_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
)
|
||||
|
||||
@ -206,6 +227,7 @@ include_directories(${RETROFE_INCLUDE_DIRS})
|
||||
add_executable(retrofe ${RETROFE_SOURCES} ${RETROFE_HEADERS})
|
||||
target_link_libraries(retrofe ${RETROFE_LIBRARIES})
|
||||
set_target_properties(retrofe PROPERTIES LINKER_LANGUAGE CXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wall")
|
||||
if(MINGW)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -lmingw32 -mwindows")
|
||||
endif()
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
class InputHandler
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#include "KeyboardHandler.h"
|
||||
|
||||
KeyboardHandler::KeyboardHandler(SDL_Scancode s)
|
||||
KeyboardHandler::KeyboardHandler(SDLKey s)
|
||||
: scancode_(s)
|
||||
, pressed_(false)
|
||||
{
|
||||
@ -15,7 +15,7 @@ bool KeyboardHandler::update(SDL_Event &e)
|
||||
{
|
||||
if(e.type != SDL_KEYUP && e.type != SDL_KEYDOWN) return false;
|
||||
|
||||
if(e.key.keysym.scancode == scancode_)
|
||||
if(e.key.keysym.sym == scancode_)
|
||||
{
|
||||
pressed_ = (e.type == SDL_KEYDOWN);
|
||||
return true;
|
||||
|
||||
@ -5,13 +5,13 @@
|
||||
class KeyboardHandler : public InputHandler
|
||||
{
|
||||
public:
|
||||
KeyboardHandler(SDL_Scancode scancode);
|
||||
KeyboardHandler(SDLKey scancode);
|
||||
bool update(SDL_Event &e);
|
||||
bool pressed();
|
||||
void reset();
|
||||
|
||||
private:
|
||||
SDL_Scancode scancode_;
|
||||
SDLKey scancode_;
|
||||
bool pressed_;
|
||||
};
|
||||
|
||||
|
||||
@ -18,12 +18,104 @@
|
||||
#include "../Database/Configuration.h"
|
||||
#include "../Utility/Log.h"
|
||||
#include "../Utility/Utils.h"
|
||||
#include "JoyAxisHandler.h"
|
||||
#include "JoyButtonHandler.h"
|
||||
#include "JoyHatHandler.h"
|
||||
#include <string>
|
||||
//#include "JoyAxisHandler.h"
|
||||
//#include "JoyButtonHandler.h"
|
||||
//#include "JoyHatHandler.h"
|
||||
#include "KeyboardHandler.h"
|
||||
#include "MouseButtonHandler.h"
|
||||
|
||||
const key_names_s key_names[] = {
|
||||
/*
|
||||
a subset of
|
||||
sed 's/^#define \([^ \t]\+\)[ \t]*\([^\ \t]\+\)/ { \"\1\",\t\2 },/' /usr/include/linux/input.h
|
||||
*/
|
||||
{ "KEY_RESERVED", SDLK_UNKNOWN },
|
||||
{ "Escape", SDLK_ESCAPE },
|
||||
{ "1", SDLK_1 },
|
||||
{ "2", SDLK_2 },
|
||||
{ "3", SDLK_3 },
|
||||
{ "4", SDLK_4 },
|
||||
{ "5", SDLK_5 },
|
||||
{ "6", SDLK_6 },
|
||||
{ "7", SDLK_7 },
|
||||
{ "8", SDLK_8 },
|
||||
{ "9", SDLK_9 },
|
||||
{ "0", SDLK_0 },
|
||||
{ "-", SDLK_MINUS },
|
||||
{ "=", SDLK_EQUALS },
|
||||
{ "Backspace", SDLK_BACKSPACE },
|
||||
{ "Tab", SDLK_TAB },
|
||||
{ "Q", SDLK_q },
|
||||
{ "W", SDLK_w },
|
||||
{ "E", SDLK_e },
|
||||
{ "R", SDLK_r },
|
||||
{ "T", SDLK_t },
|
||||
{ "Y", SDLK_y },
|
||||
{ "U", SDLK_u },
|
||||
{ "I", SDLK_i },
|
||||
{ "O", SDLK_o },
|
||||
{ "P", SDLK_p },
|
||||
{ "[", SDLK_LEFTBRACKET },
|
||||
{ "]", SDLK_RIGHTBRACKET },
|
||||
{ "Return", SDLK_RETURN },
|
||||
{ "Left Ctrl", SDLK_LCTRL },
|
||||
{ "A", SDLK_a },
|
||||
{ "S", SDLK_s },
|
||||
{ "D", SDLK_d },
|
||||
{ "F", SDLK_f },
|
||||
{ "G", SDLK_g },
|
||||
{ "H", SDLK_h },
|
||||
{ "J", SDLK_j },
|
||||
{ "K", SDLK_k },
|
||||
{ "L", SDLK_l },
|
||||
{ ";", SDLK_SEMICOLON },
|
||||
{ "'", SDLK_QUOTE },
|
||||
{ "Left Shift", SDLK_LSHIFT },
|
||||
{ "\\", SDLK_BACKSLASH },
|
||||
{ "Z", SDLK_z },
|
||||
{ "X", SDLK_x },
|
||||
{ "C", SDLK_c },
|
||||
{ "V", SDLK_v },
|
||||
{ "B", SDLK_b },
|
||||
{ "N", SDLK_n },
|
||||
{ "M", SDLK_m },
|
||||
{ ",", SDLK_PERIOD },
|
||||
{ ".", SDLK_COMMA },
|
||||
{ "/", SDLK_SLASH },
|
||||
{ "Right Shift", SDLK_RSHIFT },
|
||||
{ "Left Alt", SDLK_LALT },
|
||||
{ "Space", SDLK_SPACE },
|
||||
{ "CapsLock", SDLK_CAPSLOCK },
|
||||
{ "F1", SDLK_F1 },
|
||||
{ "F2", SDLK_F2 },
|
||||
{ "F3", SDLK_F3 },
|
||||
{ "F4", SDLK_F4 },
|
||||
{ "F5", SDLK_F5 },
|
||||
{ "F6", SDLK_F6 },
|
||||
{ "F7", SDLK_F7 },
|
||||
{ "F8", SDLK_F8 },
|
||||
{ "F9", SDLK_F9 },
|
||||
{ "F10", SDLK_F10 },
|
||||
{ "F11", SDLK_F11 },
|
||||
{ "F12", SDLK_F12 },
|
||||
{ "Right Ctrl", SDLK_RCTRL },
|
||||
{ "Right Alt", SDLK_RALT },
|
||||
{ "Up", SDLK_UP },
|
||||
{ "PageUp", SDLK_PAGEUP },
|
||||
{ "Left", SDLK_LEFT },
|
||||
{ "Right", SDLK_RIGHT },
|
||||
{ "End", SDLK_END },
|
||||
{ "Down", SDLK_DOWN },
|
||||
{ "PageDown", SDLK_PAGEDOWN },
|
||||
{ "Insert", SDLK_INSERT },
|
||||
{ "Delete", SDLK_DELETE },
|
||||
|
||||
|
||||
{ "LAST", -1 },
|
||||
};
|
||||
|
||||
|
||||
UserInput::UserInput(Configuration &c)
|
||||
: config_(c)
|
||||
{
|
||||
@ -93,6 +185,24 @@ bool UserInput::initialize()
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/* Return linux Key code from corresponding str*/
|
||||
SDLKey UserInput::SDL_GetScancodeFromName(const char *name)
|
||||
{
|
||||
int i=0;
|
||||
SDLKey returnValue = SDLK_UNKNOWN;
|
||||
while(key_names[i].code >= 0){
|
||||
if(!strncmp(key_names[i].name, name, 32)){
|
||||
returnValue = (SDLKey) key_names[i].code;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if(key_names[i].code < 0){
|
||||
returnValue = SDLK_UNKNOWN;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
bool UserInput::MapKey(std::string keyDescription, KeyCode_E key)
|
||||
{
|
||||
return MapKey(keyDescription, key, true);
|
||||
@ -100,7 +210,7 @@ bool UserInput::MapKey(std::string keyDescription, KeyCode_E key)
|
||||
|
||||
bool UserInput::MapKey(std::string keyDescription, KeyCode_E key, bool required)
|
||||
{
|
||||
SDL_Scancode scanCode;
|
||||
SDLKey scanCode;
|
||||
std::string description;
|
||||
|
||||
std::string configKey = "controls." + keyDescription;
|
||||
@ -126,9 +236,9 @@ bool UserInput::MapKey(std::string keyDescription, KeyCode_E key, bool required)
|
||||
|
||||
bool found = false;
|
||||
|
||||
if (scanCode != SDL_SCANCODE_UNKNOWN)
|
||||
if (scanCode != SDLK_UNKNOWN)
|
||||
{
|
||||
Logger::write(Logger::ZONE_INFO, "Input", "Binding key " + configKey);
|
||||
Logger::write(Logger::ZONE_INFO, "Input", "Binding key " + configKey + ", Key Value: " + std::to_string(scanCode));
|
||||
keyHandlers_.push_back(std::pair<InputHandler *, KeyCode_E>(new KeyboardHandler(scanCode), key));
|
||||
found = true;
|
||||
}
|
||||
|
||||
@ -14,11 +14,17 @@
|
||||
* along with RetroFE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL2/SDL_joystick.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
//#include "SDL_scancode.h"
|
||||
|
||||
typedef struct{
|
||||
char name[32];
|
||||
int code;
|
||||
}key_names_s;
|
||||
|
||||
const int cMaxJoy = 4;
|
||||
|
||||
@ -64,6 +70,8 @@ public:
|
||||
void clearJoysticks( );
|
||||
|
||||
private:
|
||||
SDLKey SDL_GetScancodeFromName(const char *name);
|
||||
//SDL_Scancode SDL_GetScancodeFromName(const char *name);
|
||||
bool MapKey(std::string keyDescription, KeyCode_E key);
|
||||
bool MapKey(std::string keyDescription, KeyCode_E key, bool required);
|
||||
Configuration &config_;
|
||||
|
||||
@ -68,7 +68,8 @@ void Component::freeGraphicsMemory()
|
||||
if ( backgroundTexture_ )
|
||||
{
|
||||
SDL_LockMutex(SDL::getMutex());
|
||||
SDL_DestroyTexture(backgroundTexture_);
|
||||
//SDL_DestroyTexture(backgroundTexture_);
|
||||
SDL_FreeSurface(backgroundTexture_);
|
||||
SDL_UnlockMutex(SDL::getMutex());
|
||||
|
||||
backgroundTexture_ = NULL;
|
||||
@ -80,7 +81,7 @@ void Component::allocateGraphicsMemory()
|
||||
{
|
||||
// make a 4x4 pixel wide surface to be stretched during rendering, make it a white background so we can use
|
||||
// color later
|
||||
SDL_Surface *surface = SDL_CreateRGBSurface(0, 4, 4, 32, 0, 0, 0, 0);
|
||||
/*SDL_Surface *surface = SDL_CreateRGBSurface(0, 4, 4, 32, 0, 0, 0, 0);
|
||||
SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, 255, 255, 255));
|
||||
|
||||
SDL_LockMutex(SDL::getMutex());
|
||||
@ -88,7 +89,12 @@ void Component::allocateGraphicsMemory()
|
||||
SDL_UnlockMutex(SDL::getMutex());
|
||||
|
||||
SDL_FreeSurface(surface);
|
||||
SDL_SetTextureBlendMode(backgroundTexture_, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetTextureBlendMode(backgroundTexture_, SDL_BLENDMODE_BLEND);*/
|
||||
|
||||
SDL_LockMutex(SDL::getMutex());
|
||||
backgroundTexture_ = SDL_CreateRGBSurface(0, 4, 4, 32, 0, 0, 0, 0);
|
||||
SDL_FillRect(backgroundTexture_, NULL, SDL_MapRGB(backgroundTexture_->format, 255, 255, 255));
|
||||
SDL_UnlockMutex(SDL::getMutex());
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,11 +223,11 @@ void Component::draw()
|
||||
rect.x = static_cast<int>(baseViewInfo.XRelativeToOrigin());
|
||||
rect.y = static_cast<int>(baseViewInfo.YRelativeToOrigin());
|
||||
|
||||
|
||||
SDL_SetTextureColorMod(backgroundTexture_,
|
||||
// TODO : adapt to sdl1.2
|
||||
/*SDL_SetTextureColorMod(backgroundTexture_,
|
||||
static_cast<char>(baseViewInfo.BackgroundRed*255),
|
||||
static_cast<char>(baseViewInfo.BackgroundGreen*255),
|
||||
static_cast<char>(baseViewInfo.BackgroundBlue*255));
|
||||
static_cast<char>(baseViewInfo.BackgroundBlue*255));*/
|
||||
|
||||
SDL::renderCopy(backgroundTexture_, baseViewInfo.BackgroundAlpha, NULL, &rect, baseViewInfo);
|
||||
}
|
||||
|
||||
@ -67,7 +67,8 @@ private:
|
||||
|
||||
AnimationEvents *tweens_;
|
||||
Animation *currentTweens_;
|
||||
SDL_Texture *backgroundTexture_;
|
||||
//SDL_Texture *backgroundTexture_;
|
||||
SDL_Surface *backgroundTexture_;
|
||||
|
||||
ViewInfo storeViewInfo_;
|
||||
unsigned int currentTweenIndex_;
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Component.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <string>
|
||||
|
||||
class Container : public Component
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
#include "../ViewInfo.h"
|
||||
#include "../../SDL.h"
|
||||
#include "../../Utility/Log.h"
|
||||
#include <SDL2/SDL_image.h>
|
||||
#include <SDL/SDL_image.h>
|
||||
|
||||
Image::Image(std::string file, std::string altFile, Page &p, float scaleX, float scaleY)
|
||||
: Component(p)
|
||||
@ -42,7 +42,8 @@ void Image::freeGraphicsMemory()
|
||||
SDL_LockMutex(SDL::getMutex());
|
||||
if (texture_ != NULL)
|
||||
{
|
||||
SDL_DestroyTexture(texture_);
|
||||
//SDL_DestroyTexture(texture_);
|
||||
SDL_FreeSurface(texture_);
|
||||
texture_ = NULL;
|
||||
}
|
||||
SDL_UnlockMutex(SDL::getMutex());
|
||||
@ -56,18 +57,22 @@ void Image::allocateGraphicsMemory()
|
||||
if(!texture_)
|
||||
{
|
||||
SDL_LockMutex(SDL::getMutex());
|
||||
texture_ = IMG_LoadTexture(SDL::getRenderer(), file_.c_str());
|
||||
//texture_ = IMG_LoadTexture(SDL::getRenderer(), file_.c_str());
|
||||
texture_ = IMG_Load(file_.c_str());
|
||||
if (!texture_ && altFile_ != "")
|
||||
{
|
||||
texture_ = IMG_LoadTexture(SDL::getRenderer(), altFile_.c_str());
|
||||
//texture_ = IMG_LoadTexture(SDL::getRenderer(), altFile_.c_str());
|
||||
texture_ = IMG_Load(altFile_.c_str());
|
||||
}
|
||||
|
||||
if (texture_ != NULL)
|
||||
{
|
||||
SDL_SetTextureBlendMode(texture_, SDL_BLENDMODE_BLEND);
|
||||
SDL_QueryTexture(texture_, NULL, NULL, &width, &height);
|
||||
//SDL_SetTextureBlendMode(texture_, SDL_BLENDMODE_BLEND);
|
||||
/*SDL_QueryTexture(texture_, NULL, NULL, &width, &height);
|
||||
baseViewInfo.ImageWidth = width * scaleX_;
|
||||
baseViewInfo.ImageHeight = height * scaleY_;
|
||||
baseViewInfo.ImageHeight = height * scaleY_;*/
|
||||
baseViewInfo.ImageWidth = texture_->w * scaleX_;
|
||||
baseViewInfo.ImageHeight = texture_->h * scaleY_;
|
||||
}
|
||||
SDL_UnlockMutex(SDL::getMutex());
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Component.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <string>
|
||||
|
||||
class Image : public Component
|
||||
@ -29,7 +29,8 @@ public:
|
||||
void draw();
|
||||
|
||||
protected:
|
||||
SDL_Texture *texture_;
|
||||
//SDL_Texture *texture_;
|
||||
SDL_Surface *texture_;
|
||||
std::string file_;
|
||||
std::string altFile_;
|
||||
float scaleX_;
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#include "ReloadableText.h"
|
||||
#include "../../Video/IVideo.h"
|
||||
#include "../../Collection/Item.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <string>
|
||||
|
||||
class Image;
|
||||
|
||||
@ -42,8 +42,10 @@ ReloadableScrollingText::ReloadableScrollingText(Configuration &config, bool sys
|
||||
, pluralPrefix_(pluralPrefix)
|
||||
, pluralPostfix_(pluralPostfix)
|
||||
, alignment_(alignment)
|
||||
, scaleX_(scaleX)
|
||||
, scaleY_(scaleY)
|
||||
//, scaleX_(scaleX)
|
||||
//, scaleY_(scaleY)
|
||||
, scaleX_(1.0f) //TODO
|
||||
, scaleY_(1.0f) //TODO
|
||||
, direction_(direction)
|
||||
, scrollingSpeed_(scrollingSpeed)
|
||||
, startPosition_(startPosition)
|
||||
@ -459,7 +461,8 @@ void ReloadableScrollingText::draw( )
|
||||
else // If not, use the general font settings
|
||||
font = fontInst_;
|
||||
|
||||
SDL_Texture *t = font->getTexture( );
|
||||
//SDL_Texture *t = font->getTexture( );
|
||||
SDL_Surface *t = font->getTexture( );
|
||||
|
||||
float imageWidth = 0;
|
||||
float imageMaxWidth = 0;
|
||||
@ -481,7 +484,9 @@ void ReloadableScrollingText::draw( )
|
||||
imageMaxHeight = baseViewInfo.MaxHeight;
|
||||
}
|
||||
|
||||
float scale = (float)baseViewInfo.FontSize / (float)font->getHeight( ) / scaleY_;
|
||||
//float scale = (float)baseViewInfo.FontSize / (float)font->getHeight( ) / scaleY_;
|
||||
//TODO, modify for scaling - for now, no scaling in effect
|
||||
float scale = 1.0f;
|
||||
|
||||
float xOrigin = baseViewInfo.XRelativeToOrigin( );
|
||||
float yOrigin = baseViewInfo.YRelativeToOrigin( );
|
||||
@ -513,17 +518,19 @@ void ReloadableScrollingText::draw( )
|
||||
|
||||
Font::GlyphInfo glyph;
|
||||
|
||||
if (font->getRect( text_[l][i], glyph) && glyph.rect.h > 0)
|
||||
//if (font->getRect( text_[l][i], glyph) && glyph.rect.h > 0)
|
||||
if (font->getRect( text_[l][i], glyph))
|
||||
{
|
||||
SDL_Rect charRect = glyph.rect;
|
||||
rect.h = static_cast<int>( charRect.h * scale * scaleY_ );
|
||||
rect.w = static_cast<int>( charRect.w * scale * scaleX_ );
|
||||
rect.y = static_cast<int>( yOrigin );
|
||||
|
||||
if (font->getAscent( ) < glyph.maxY)
|
||||
/*if (font->getAscent( ) < glyph.maxY)
|
||||
{
|
||||
rect.y += static_cast<int>( (font->getAscent( ) - glyph.maxY) * scale * scaleY_ );
|
||||
}
|
||||
}*/
|
||||
rect.y += static_cast<int>( (font->getAscent( ) - glyph.maxY) * scale * scaleY_ );
|
||||
|
||||
// Check if glyph falls partially outside the box at the back end
|
||||
if ((rect.x + static_cast<int>( glyph.advance * scale * scaleX_ )) >= (static_cast<int>( xOrigin ) + imageMaxWidth))
|
||||
@ -707,7 +714,8 @@ void ReloadableScrollingText::draw( )
|
||||
{
|
||||
Font::GlyphInfo glyph;
|
||||
|
||||
if (font->getRect( word[i], glyph) && glyph.rect.h > 0)
|
||||
//if (font->getRect( word[i], glyph) && glyph.rect.h > 0)
|
||||
if (font->getRect( word[i], glyph))
|
||||
{
|
||||
SDL_Rect charRect = glyph.rect;
|
||||
rect.h = static_cast<int>( charRect.h * scale * scaleY_ );
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#pragma once
|
||||
#include "Component.h"
|
||||
#include "../../Collection/Item.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "../Font.h"
|
||||
#include "../Page.h"
|
||||
#include "../../Collection/Item.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <string>
|
||||
|
||||
class ReloadableText : public Component
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
#include "../../SDL.h"
|
||||
#include "../ViewInfo.h"
|
||||
#include <math.h>
|
||||
#include <SDL2/SDL_image.h>
|
||||
#include <SDL/SDL_image.h>
|
||||
#include <sstream>
|
||||
#include <cctype>
|
||||
#include <iomanip>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include "../Page.h"
|
||||
#include "../ViewInfo.h"
|
||||
#include "../../Database/Configuration.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
|
||||
class Configuration;
|
||||
|
||||
@ -73,7 +73,8 @@ void Text::draw( )
|
||||
else // If not, use the general font settings
|
||||
font = fontInst_;
|
||||
|
||||
SDL_Texture *t = font->getTexture( );
|
||||
//SDL_Texture *t = font->getTexture( );
|
||||
SDL_Surface *t = font->getTexture( );
|
||||
|
||||
float imageHeight = 0;
|
||||
float imageWidth = 0;
|
||||
@ -88,8 +89,14 @@ void Text::draw( )
|
||||
}
|
||||
|
||||
imageHeight = (float)font->getHeight( );
|
||||
float scale = (float)baseViewInfo.FontSize / (float)imageHeight;
|
||||
//float scale = (float)baseViewInfo.FontSize / (float)imageHeight;
|
||||
|
||||
//TODO, modify for scaling - for now, no scaling in effect
|
||||
float scale = 1.0f;
|
||||
|
||||
/*printf("\n");
|
||||
printf("imageMaxWidth=%f, imageHeight=%f, baseViewInfo.FontSize=%f,scale=%f\n", imageMaxWidth, imageHeight, baseViewInfo.FontSize, scale);
|
||||
*/
|
||||
unsigned int textIndexMax = 0;
|
||||
|
||||
// determine image width
|
||||
@ -110,6 +117,14 @@ void Text::draw( )
|
||||
|
||||
textIndexMax = i;
|
||||
imageWidth += glyph.advance;
|
||||
|
||||
/*printf("textData_[%d]=%c, glyph.advance= %f - %d\n", i, textData_[i], glyph.advance, glyph.advance);
|
||||
printf("imageWidth=%f \n", imageWidth);*/
|
||||
}
|
||||
else{
|
||||
/*std::stringstream ss;
|
||||
ss << "Could not find Glyph info for char: " << textData_[i];
|
||||
Logger::write(Logger::ZONE_WARNING, "Text", ss.str());*/
|
||||
}
|
||||
|
||||
}
|
||||
@ -140,7 +155,8 @@ void Text::draw( )
|
||||
{
|
||||
Font::GlyphInfo glyph;
|
||||
|
||||
if ( font->getRect(textData_[i], glyph) && glyph.rect.h > 0 )
|
||||
//if ( font->getRect(textData_[i], glyph) && glyph.rect.h > 0 ) // Not working in SDL1.2 because glyph.rect.h = 0 for spaces
|
||||
if ( font->getRect(textData_[i], glyph))
|
||||
{
|
||||
SDL_Rect charRect = glyph.rect;
|
||||
float h = static_cast<float>( charRect.h * scale );
|
||||
@ -153,11 +169,13 @@ void Text::draw( )
|
||||
{
|
||||
rect.x += static_cast<int>( (float)(glyph.minX) * scale );
|
||||
}
|
||||
if ( font->getAscent( ) < glyph.maxY )
|
||||
/*if ( font->getAscent( ) < glyph.maxY )
|
||||
{
|
||||
rect.y += static_cast<int>( (font->getAscent( ) - glyph.maxY)*scale );
|
||||
}
|
||||
}*/
|
||||
|
||||
/*printf("font->getAscent( ) = %d, glyph.maxY : %d\n", font->getAscent( ), glyph.maxY );*/
|
||||
rect.y += static_cast<int>( (font->getAscent( ) - glyph.maxY)*scale );
|
||||
|
||||
SDL::renderCopy( t, baseViewInfo.Alpha, &charRect, &rect, baseViewInfo );
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
#include "Component.h"
|
||||
#include "../Page.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#pragma once
|
||||
#include "Component.h"
|
||||
#include "../../Video/IVideo.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <string>
|
||||
|
||||
class Video : public Component
|
||||
|
||||
@ -93,12 +93,12 @@ void VideoComponent::draw()
|
||||
rect.w = static_cast<int>(baseViewInfo.ScaledWidth());
|
||||
|
||||
videoInst_->draw();
|
||||
SDL_Texture *texture = videoInst_->getTexture();
|
||||
/*SDL_Texture *texture = videoInst_->getTexture();
|
||||
|
||||
if(texture)
|
||||
{
|
||||
SDL::renderCopy(texture, baseViewInfo.Alpha, NULL, &rect, baseViewInfo);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
bool VideoComponent::isPlaying()
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "../Page.h"
|
||||
#include "../../Collection/Item.h"
|
||||
#include "../../Video/IVideo.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <string>
|
||||
|
||||
class VideoComponent : public Component
|
||||
|
||||
@ -16,8 +16,9 @@
|
||||
#include "Font.h"
|
||||
#include "../SDL.h"
|
||||
#include "../Utility/Log.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_ttf.h>
|
||||
#include <SDL/SDL_gfxBlitFunc.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
@ -34,7 +35,7 @@ Font::~Font()
|
||||
deInitialize();
|
||||
}
|
||||
|
||||
SDL_Texture *Font::getTexture()
|
||||
SDL_Surface *Font::getTexture()
|
||||
{
|
||||
return texture;
|
||||
}
|
||||
@ -87,7 +88,7 @@ bool Font::initialize()
|
||||
GlyphInfoBuild *info = new GlyphInfoBuild;
|
||||
memset(info, 0, sizeof(GlyphInfoBuild));
|
||||
|
||||
color_.a = 255;
|
||||
//color_.a = 255;
|
||||
info->surface = TTF_RenderGlyph_Blended(font, i, color_);
|
||||
TTF_GlyphMetrics(font, i,
|
||||
&info->glyph.minX, &info->glyph.maxX,
|
||||
@ -110,11 +111,11 @@ bool Font::initialize()
|
||||
|
||||
x += info->glyph.rect.w;
|
||||
y = (y > info->glyph.rect.h) ? y : info->glyph.rect.h;
|
||||
/*
|
||||
std::stringstream ss;
|
||||
ss << " tw:" << atlasWidth << " th:" << atlasHeight << " x:" << x << " y:" << y << " w:" << info->Glyph.Rect.w << " h:" << info->Glyph.Rect.h;
|
||||
Logger::Write(Logger::ZONE_ERROR, "FontCache", ss.str());
|
||||
*/
|
||||
|
||||
/*std::stringstream ss;
|
||||
ss << " tw:" << atlasWidth << " th:" << atlasHeight << " x:" << x << " y:" << y << " w:" << info->glyph.rect.w << " h:" << info->glyph.rect.h;
|
||||
Logger::write(Logger::ZONE_INFO, "FontCache", ss.str());*/
|
||||
|
||||
}
|
||||
|
||||
atlasWidth = (atlasWidth >= x) ? atlasWidth : x;
|
||||
@ -136,21 +137,32 @@ bool Font::initialize()
|
||||
amask = 0xff000000;
|
||||
#endif
|
||||
|
||||
SDL_Surface *atlasSurface = SDL_CreateRGBSurface(0, atlasWidth, atlasHeight, 32, rmask, gmask, bmask, amask);
|
||||
//SDL_Surface *atlasSurface = SDL_CreateRGBSurface(0, atlasWidth, atlasHeight, 32, rmask, gmask, bmask, amask);
|
||||
texture = SDL_CreateRGBSurface(0, atlasWidth, atlasHeight, 32, rmask, gmask, bmask, amask);
|
||||
SDL_FillRect(texture, NULL, SDL_MapRGBA(texture->format, 0, 0, 0, 0));
|
||||
|
||||
/*texture = SDL_CreateRGBSurface(0, atlasWidth, atlasHeight, 32, 0, 0, 0, 0);
|
||||
int transparentColorKey = SDL_MapRGB(texture->format, color_.r-1, color_.g-1, color_.b-1);
|
||||
SDL_FillRect(texture, NULL, transparentColorKey);
|
||||
SDL_SetColorKey(texture, SDL_SRCCOLORKEY, transparentColorKey);*/
|
||||
|
||||
std::map<unsigned int, GlyphInfoBuild *>::iterator it;
|
||||
for(it = atlas.begin(); it != atlas.end(); it++)
|
||||
{
|
||||
GlyphInfoBuild *info = it->second;
|
||||
SDL_BlitSurface(info->surface, NULL, atlasSurface, &info->glyph.rect);
|
||||
//SDL_BlitSurface(info->surface, NULL, atlasSurface, &info->glyph.rect);
|
||||
SDL_SetAlpha( info->surface, 0, SDL_ALPHA_OPAQUE );
|
||||
SDL_BlitSurface(info->surface, NULL, texture, &info->glyph.rect);
|
||||
//SDL_gfxBlitRGBA (info->surface, NULL, texture, &info->glyph.rect);
|
||||
SDL_FreeSurface(info->surface);
|
||||
info->surface = NULL;
|
||||
}
|
||||
SDL_LockMutex(SDL::getMutex());
|
||||
|
||||
texture = SDL_CreateTextureFromSurface(SDL::getRenderer(), atlasSurface);
|
||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
||||
/*SDL_LockMutex(SDL::getMutex());
|
||||
//texture = SDL_CreateTextureFromSurface(SDL::getRenderer(), atlasSurface);
|
||||
//SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
||||
SDL_FreeSurface(atlasSurface);
|
||||
SDL_UnlockMutex(SDL::getMutex());
|
||||
SDL_UnlockMutex(SDL::getMutex());*/
|
||||
|
||||
TTF_CloseFont(font);
|
||||
|
||||
@ -164,7 +176,8 @@ void Font::deInitialize()
|
||||
if(texture)
|
||||
{
|
||||
SDL_LockMutex(SDL::getMutex());
|
||||
SDL_DestroyTexture(texture);
|
||||
//SDL_DestroyTexture(texture);
|
||||
SDL_FreeSurface(texture);
|
||||
texture = NULL;
|
||||
SDL_UnlockMutex(SDL::getMutex());
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
@ -36,7 +36,8 @@ public:
|
||||
virtual ~Font();
|
||||
bool initialize();
|
||||
void deInitialize();
|
||||
SDL_Texture *getTexture();
|
||||
//SDL_Texture *getTexture();
|
||||
SDL_Surface *getTexture();
|
||||
bool getRect(unsigned int charCode, GlyphInfo &glyph);
|
||||
int getHeight();
|
||||
int getAscent();
|
||||
@ -48,7 +49,8 @@ private:
|
||||
SDL_Surface *surface;
|
||||
};
|
||||
|
||||
SDL_Texture *texture;
|
||||
//SDL_Texture *texture;
|
||||
SDL_Surface *texture;
|
||||
int height;
|
||||
int ascent;
|
||||
std::map<unsigned int, GlyphInfoBuild *> atlas;
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#include "Font.h"
|
||||
#include "../Utility/Log.h"
|
||||
#include "../SDL.h"
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
#include <SDL/SDL_ttf.h>
|
||||
#include <sstream>
|
||||
|
||||
//todo: memory leak when launching games
|
||||
|
||||
@ -63,7 +63,7 @@ PageBuilder::PageBuilder(std::string layoutKey, std::string layoutPage, Configur
|
||||
{
|
||||
screenWidth_ = SDL::getWindowWidth();
|
||||
screenHeight_ = SDL::getWindowHeight();
|
||||
fontColor_.a = 255;
|
||||
//fontColor_.a = 255;
|
||||
fontColor_.r = 0;
|
||||
fontColor_.g = 0;
|
||||
fontColor_.b = 0;
|
||||
|
||||
@ -17,8 +17,8 @@
|
||||
|
||||
#include "Component/Image.h"
|
||||
#include "FontCache.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_mixer.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_mixer.h>
|
||||
#include <rapidxml.hpp>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
#include <SDL/SDL_ttf.h>
|
||||
|
||||
#if defined(__linux) || defined(__APPLE__)
|
||||
#include <sys/stat.h>
|
||||
@ -50,10 +50,15 @@
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#include <SDL2/SDL_syswm.h>
|
||||
#include <SDL2/SDL_thread.h>
|
||||
#include <SDL/SDL_syswm.h>
|
||||
#include <SDL/SDL_thread.h>
|
||||
#endif
|
||||
|
||||
#define REMOVE_TEST_FUNKEY
|
||||
#define FUNKEY_ALL_POLLEVENT_DELAY 30 //ms
|
||||
|
||||
#define FPS 30 // TODO: set in conf file
|
||||
|
||||
|
||||
RetroFE::RetroFE( Configuration &c )
|
||||
: initialized(false)
|
||||
@ -85,15 +90,19 @@ void RetroFE::render( )
|
||||
{
|
||||
|
||||
SDL_LockMutex( SDL::getMutex( ) );
|
||||
SDL_SetRenderDrawColor( SDL::getRenderer( ), 0x0, 0x0, 0x00, 0xFF );
|
||||
SDL_RenderClear( SDL::getRenderer( ) );
|
||||
//SDL_SetRenderDrawColor( SDL::getRenderer( ), 0x0, 0x0, 0x00, 0xFF );
|
||||
//SDL_RenderClear( SDL::getRenderer( ) );
|
||||
SDL_FillRect(SDL::getWindow( ), NULL, SDL_MapRGB(SDL::getWindow( )->format, 0, 0, 0));
|
||||
|
||||
if ( currentPage_ )
|
||||
{
|
||||
currentPage_->draw( );
|
||||
}
|
||||
|
||||
SDL_RenderPresent( SDL::getRenderer( ) );
|
||||
//SDL_RenderPresent( SDL::getRenderer( ) );
|
||||
//SDL_Flip(SDL::getWindow( ));
|
||||
SDL::renderAndFlipWindow();
|
||||
|
||||
SDL_UnlockMutex( SDL::getMutex( ) );
|
||||
|
||||
}
|
||||
@ -143,7 +152,7 @@ void RetroFE::launchEnter( )
|
||||
{
|
||||
|
||||
// Disable window focus
|
||||
SDL_SetWindowGrab(SDL::getWindow( ), SDL_FALSE);
|
||||
//SDL_SetWindowGrab(SDL::getWindow( ), SDL_FALSE);
|
||||
|
||||
// Free the textures, and optionally take down SDL
|
||||
freeGraphicsMemory( );
|
||||
@ -159,9 +168,9 @@ void RetroFE::launchExit( )
|
||||
allocateGraphicsMemory( );
|
||||
|
||||
// Restore the SDL settings
|
||||
SDL_RestoreWindow( SDL::getWindow( ) );
|
||||
SDL_RaiseWindow( SDL::getWindow( ) );
|
||||
SDL_SetWindowGrab( SDL::getWindow( ), SDL_TRUE );
|
||||
//SDL_RestoreWindow( SDL::getWindow( ) );
|
||||
//SDL_RaiseWindow( SDL::getWindow( ) );
|
||||
//SDL_SetWindowGrab( SDL::getWindow( ), SDL_TRUE );
|
||||
|
||||
// Empty event queue, but handle joystick add/remove events
|
||||
SDL_Event e;
|
||||
@ -182,7 +191,7 @@ void RetroFE::launchExit( )
|
||||
}
|
||||
|
||||
|
||||
// Free the textures, and optionall take down SDL
|
||||
// Free the textures, and optionally take down SDL
|
||||
void RetroFE::freeGraphicsMemory( )
|
||||
{
|
||||
|
||||
@ -224,6 +233,7 @@ void RetroFE::allocateGraphicsMemory( )
|
||||
currentPage_->allocateGraphicsMemory( );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -264,6 +274,118 @@ bool RetroFE::deInitialize( )
|
||||
return retVal;
|
||||
}
|
||||
|
||||
// Print State
|
||||
void RetroFE::printState(RETROFE_STATE state){
|
||||
switch(state){
|
||||
case RETROFE_IDLE:
|
||||
printf("RETROFE_IDLE");
|
||||
break;
|
||||
case RETROFE_LOAD_ART:
|
||||
printf("RETROFE_LOAD_ART");
|
||||
break;
|
||||
case RETROFE_ENTER:
|
||||
printf("RETROFE_ENTER");
|
||||
break;
|
||||
case RETROFE_SPLASH_EXIT:
|
||||
printf("RETROFE_SPLASH_EXIT");
|
||||
break;
|
||||
case RETROFE_PLAYLIST_REQUEST:
|
||||
printf("RETROFE_PLAYLIST_REQUEST");
|
||||
break;
|
||||
case RETROFE_PLAYLIST_EXIT:
|
||||
printf("RETROFE_PLAYLIST_EXIT");
|
||||
break;
|
||||
case RETROFE_PLAYLIST_LOAD_ART:
|
||||
printf("RETROFE_PLAYLIST_LOAD_ART");
|
||||
break;
|
||||
case RETROFE_PLAYLIST_ENTER:
|
||||
printf("RETROFE_PLAYLIST_ENTER");
|
||||
break;
|
||||
case RETROFE_MENUJUMP_REQUEST:
|
||||
printf("RETROFE_MENUJUMP_REQUEST");
|
||||
break;
|
||||
case RETROFE_MENUJUMP_EXIT:
|
||||
printf("RETROFE_MENUJUMP_EXIT");
|
||||
break;
|
||||
case RETROFE_MENUJUMP_LOAD_ART:
|
||||
printf("RETROFE_MENUJUMP_LOAD_ART");
|
||||
break;
|
||||
case RETROFE_MENUJUMP_ENTER:
|
||||
printf("RETROFE_MENUJUMP_ENTER");
|
||||
break;
|
||||
case RETROFE_HIGHLIGHT_REQUEST:
|
||||
printf("RETROFE_HIGHLIGHT_REQUEST");
|
||||
break;
|
||||
case RETROFE_HIGHLIGHT_EXIT:
|
||||
printf("RETROFE_HIGHLIGHT_EXIT");
|
||||
break;
|
||||
case RETROFE_HIGHLIGHT_LOAD_ART:
|
||||
printf("RETROFE_HIGHLIGHT_LOAD_ART");
|
||||
break;
|
||||
case RETROFE_HIGHLIGHT_ENTER:
|
||||
printf("RETROFE_HIGHLIGHT_ENTER");
|
||||
break;
|
||||
case RETROFE_NEXT_PAGE_REQUEST:
|
||||
printf("RETROFE_NEXT_PAGE_REQUEST");
|
||||
break;
|
||||
case RETROFE_NEXT_PAGE_MENU_EXIT:
|
||||
printf("RETROFE_NEXT_PAGE_MENU_EXIT");
|
||||
break;
|
||||
case RETROFE_NEXT_PAGE_MENU_LOAD_ART:
|
||||
printf("RETROFE_NEXT_PAGE_MENU_LOAD_ART");
|
||||
break;
|
||||
case RETROFE_NEXT_PAGE_MENU_ENTER:
|
||||
printf("RETROFE_NEXT_PAGE_MENU_ENTER");
|
||||
break;
|
||||
case RETROFE_HANDLE_MENUENTRY:
|
||||
printf("RETROFE_HANDLE_MENUENTRY");
|
||||
break;
|
||||
case RETROFE_LAUNCH_ENTER:
|
||||
printf("RETROFE_LAUNCH_ENTER");
|
||||
break;
|
||||
case RETROFE_LAUNCH_REQUEST:
|
||||
printf("RETROFE_LAUNCH_REQUEST");
|
||||
break;
|
||||
case RETROFE_LAUNCH_EXIT:
|
||||
printf("RETROFE_LAUNCH_EXIT");
|
||||
break;
|
||||
case RETROFE_BACK_REQUEST:
|
||||
printf("RETROFE_BACK_REQUEST");
|
||||
break;
|
||||
case RETROFE_BACK_MENU_EXIT:
|
||||
printf("RETROFE_BACK_MENU_EXIT");
|
||||
break;
|
||||
case RETROFE_BACK_MENU_LOAD_ART:
|
||||
printf("RETROFE_BACK_MENU_LOAD_ART");
|
||||
break;
|
||||
case RETROFE_BACK_MENU_ENTER:
|
||||
printf("RETROFE_BACK_MENU_ENTER");
|
||||
break;
|
||||
case RETROFE_MENUMODE_START_REQUEST:
|
||||
printf("RETROFE_MENUMODE_START_REQUEST");
|
||||
break;
|
||||
case RETROFE_MENUMODE_START_LOAD_ART:
|
||||
printf("RETROFE_MENUMODE_START_LOAD_ART");
|
||||
break;
|
||||
case RETROFE_MENUMODE_START_ENTER:
|
||||
printf("RETROFE_MENUMODE_START_ENTER");
|
||||
break;
|
||||
case RETROFE_NEW:
|
||||
printf("RETROFE_NEW");
|
||||
break;
|
||||
case RETROFE_QUIT_REQUEST:
|
||||
printf("RETROFE_QUIT_REQUEST");
|
||||
break;
|
||||
case RETROFE_QUIT:
|
||||
printf("RETROFE_QUIT");
|
||||
break;
|
||||
default:
|
||||
printf("STATE UNDEFINED:%d", state);
|
||||
break;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
// Run RetroFE
|
||||
void RetroFE::run( )
|
||||
@ -293,7 +415,8 @@ void RetroFE::run( )
|
||||
VideoFactory::createVideo( ); // pre-initialize the gstreamer engine
|
||||
Video::setEnabled( videoEnable );
|
||||
|
||||
initializeThread = SDL_CreateThread( initialize, "RetroFEInit", (void *)this );
|
||||
//initializeThread = SDL_CreateThread( initialize, "RetroFEInit", (void *)this );
|
||||
initializeThread = SDL_CreateThread( initialize, (void *)this );
|
||||
|
||||
if ( !initializeThread )
|
||||
{
|
||||
@ -338,10 +461,12 @@ void RetroFE::run( )
|
||||
exitSplashMode = true;
|
||||
while ( SDL_PollEvent( &e ) )
|
||||
{
|
||||
#ifndef REMOVE_TEST_FUNKEY
|
||||
if ( e.type == SDL_JOYDEVICEADDED || e.type == SDL_JOYDEVICEREMOVED )
|
||||
{
|
||||
input_.update( e );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
input_.resetStates( );
|
||||
attract_.reset( );
|
||||
@ -355,6 +480,9 @@ void RetroFE::run( )
|
||||
break;
|
||||
}
|
||||
|
||||
// Uncomment to print State for debug purposes
|
||||
//printState(state);
|
||||
|
||||
switch(state)
|
||||
{
|
||||
|
||||
@ -800,7 +928,7 @@ void RetroFE::run( )
|
||||
|
||||
// Start menu mode
|
||||
case RETROFE_MENUMODE_START_REQUEST:
|
||||
if ( currentPage_->isIdle( ) )
|
||||
/*if ( currentPage_->isIdle( ) )
|
||||
{
|
||||
lastMenuOffsets_[currentPage_->getCollectionName( )] = currentPage_->getScrollOffsetIndex( );
|
||||
lastMenuPlaylists_[currentPage_->getCollectionName( )] = currentPage_->getPlaylistName( );
|
||||
@ -822,11 +950,17 @@ void RetroFE::run( )
|
||||
currentPage_->onNewItemSelected( );
|
||||
currentPage_->reallocateMenuSpritePoints( );
|
||||
state = RETROFE_MENUMODE_START_LOAD_ART;
|
||||
}
|
||||
}*/
|
||||
|
||||
/// Clear events
|
||||
SDL_Event ev;
|
||||
while ( SDL_PollEvent( &ev ) );
|
||||
input_.resetStates( );
|
||||
state = RETROFE_IDLE;
|
||||
break;
|
||||
|
||||
case RETROFE_MENUMODE_START_LOAD_ART:
|
||||
currentPage_->start();
|
||||
//currentPage_->start();
|
||||
state = RETROFE_MENUMODE_START_ENTER;
|
||||
break;
|
||||
|
||||
@ -881,8 +1015,11 @@ void RetroFE::run( )
|
||||
SDL_Delay( static_cast<unsigned int>( sleepTime ) );
|
||||
}
|
||||
|
||||
|
||||
// Handle current pages updates
|
||||
if ( currentPage_ )
|
||||
{
|
||||
#ifndef REMOVE_TEST_FUNKEY
|
||||
if (!splashMode)
|
||||
{
|
||||
attract_.update( deltaTime, *currentPage_ );
|
||||
@ -891,6 +1028,7 @@ void RetroFE::run( )
|
||||
{
|
||||
attract_.reset( );
|
||||
}
|
||||
#endif
|
||||
currentPage_->update( deltaTime );
|
||||
}
|
||||
|
||||
@ -932,9 +1070,14 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput( Page *page )
|
||||
while ( SDL_PollEvent( &e ) )
|
||||
{
|
||||
input_.update(e);
|
||||
if ( e.type == SDL_KEYDOWN && !e.key.repeat )
|
||||
/*if ( e.type == SDL_KEYDOWN && !e.key.repeat )
|
||||
{
|
||||
break;
|
||||
}*/
|
||||
if ( e.type == SDL_KEYDOWN )
|
||||
{
|
||||
//printf("e.key.keysym.sym = %d\n", e.key.keysym.sym);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1244,9 +1387,9 @@ CollectionInfo *RetroFE::getCollection(std::string collectionName)
|
||||
(void)config_.getProperty( "showParenthesis", showParenthesis );
|
||||
(void)config_.getProperty( "showSquareBrackets", showSquareBrackets );
|
||||
|
||||
typedef std::map<std::string, std::vector <Item *> *> Playlists_T;
|
||||
for ( Playlists_T::iterator itP = collection->playlists.begin( ); itP != collection->playlists.end( ); itP++ )
|
||||
{
|
||||
typedef std::map<std::string, std::vector <Item *> *> Playlists_T;
|
||||
for ( Playlists_T::iterator itP = collection->playlists.begin( ); itP != collection->playlists.end( ); itP++ )
|
||||
{
|
||||
for ( std::vector <Item *>::iterator itI = itP->second->begin( ); itI != itP->second->end( ); itI++ )
|
||||
{
|
||||
if ( !showParenthesis )
|
||||
|
||||
@ -24,8 +24,8 @@
|
||||
#include "Graphics/FontCache.h"
|
||||
#include "Video/IVideo.h"
|
||||
#include "Video/VideoFactory.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_ttf.h>
|
||||
#include <list>
|
||||
#include <stack>
|
||||
#include <map>
|
||||
@ -103,6 +103,7 @@ private:
|
||||
void update( float dt, bool scrollActive );
|
||||
CollectionInfo *getCollection( std::string collectionName );
|
||||
CollectionInfo *getMenuCollection( std::string collectionName );
|
||||
void printState(RETROFE_STATE state);
|
||||
|
||||
Configuration &config_;
|
||||
DB *db_;
|
||||
|
||||
@ -18,17 +18,23 @@
|
||||
#include "SDL.h"
|
||||
#include "Database/Configuration.h"
|
||||
#include "Utility/Log.h"
|
||||
#include <SDL2/SDL_mixer.h>
|
||||
#include <SDL/SDL_mixer.h>
|
||||
//#include <SDL/SDL_rotozoom.h>
|
||||
#include <SDL/SDL_gfxBlitFunc.h>
|
||||
|
||||
|
||||
SDL_Window *SDL::window_ = NULL;
|
||||
SDL_Renderer *SDL::renderer_ = NULL;
|
||||
//SDL_Window *SDL::window_ = NULL;
|
||||
//SDL_Renderer *SDL::renderer_ = NULL;
|
||||
SDL_Surface *SDL::window_ = NULL;
|
||||
SDL_Surface *SDL::window_virtual_ = NULL;
|
||||
SDL_Surface *SDL::texture_copy_alpha_ = NULL;
|
||||
SDL_mutex *SDL::mutex_ = NULL;
|
||||
int SDL::displayWidth_ = 0;
|
||||
int SDL::displayHeight_ = 0;
|
||||
int SDL::windowWidth_ = 0;
|
||||
int SDL::windowHeight_ = 0;
|
||||
bool SDL::fullscreen_ = false;
|
||||
bool SDL::showFrame_ = true;
|
||||
|
||||
|
||||
// Initialize SDL
|
||||
@ -38,12 +44,13 @@ bool SDL::initialize( Configuration &config )
|
||||
bool retVal = true;
|
||||
std::string hString;
|
||||
std::string vString;
|
||||
Uint32 windowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS;
|
||||
Uint32 windowFlags = SDL_HWSURFACE | SDL_DOUBLEBUF;
|
||||
int audioRate = MIX_DEFAULT_FREQUENCY;
|
||||
Uint16 audioFormat = MIX_DEFAULT_FORMAT; /* 16-bit stereo */
|
||||
int audioChannels = 1;
|
||||
int audioBuffers = 4096;
|
||||
bool hideMouse;
|
||||
const SDL_VideoInfo* videoInfo;
|
||||
|
||||
Logger::write( Logger::ZONE_INFO, "SDL", "Initializing" );
|
||||
if (retVal && SDL_Init( SDL_INIT_EVERYTHING ) != 0)
|
||||
@ -68,16 +75,16 @@ bool SDL::initialize( Configuration &config )
|
||||
// check for a few other necessary Configurations
|
||||
if ( retVal )
|
||||
{
|
||||
// Get current display mode of all displays.
|
||||
for(int i = 0; i < SDL_GetNumVideoDisplays( ); ++i)
|
||||
// Get current screen resolution
|
||||
videoInfo = SDL_GetVideoInfo();
|
||||
if (videoInfo == NULL)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
if ( SDL_GetCurrentDisplayMode( i, &mode ) == 0 )
|
||||
{
|
||||
displayWidth_ = mode.w;
|
||||
displayHeight_ = mode.h;
|
||||
break;
|
||||
}
|
||||
Logger::write( Logger::ZONE_ERROR, "SDL", "SDL_GetVideoInfo failed");
|
||||
retVal = false;
|
||||
}
|
||||
else{
|
||||
displayWidth_ = videoInfo->current_w;
|
||||
displayHeight_ = videoInfo->current_h;
|
||||
}
|
||||
|
||||
if ( !config.getProperty( "horizontal", hString ) )
|
||||
@ -87,16 +94,7 @@ bool SDL::initialize( Configuration &config )
|
||||
}
|
||||
else if ( hString == "stretch" )
|
||||
{
|
||||
// Get current display mode of all displays.
|
||||
for(int i = 0; i < SDL_GetNumVideoDisplays( ); ++i)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
if ( SDL_GetCurrentDisplayMode( i, &mode ) == 0 )
|
||||
{
|
||||
windowWidth_ = mode.w;
|
||||
break;
|
||||
}
|
||||
}
|
||||
windowWidth_ = displayWidth_;
|
||||
}
|
||||
else if ( !config.getProperty( "horizontal", windowWidth_ ) )
|
||||
{
|
||||
@ -113,16 +111,7 @@ bool SDL::initialize( Configuration &config )
|
||||
}
|
||||
else if ( vString == "stretch" )
|
||||
{
|
||||
// Get current display mode of all displays.
|
||||
for(int i = 0; i < SDL_GetNumVideoDisplays( ); ++i)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
if ( SDL_GetDesktopDisplayMode( i, &mode ) == 0 )
|
||||
{
|
||||
windowHeight_ = mode.h;
|
||||
break;
|
||||
}
|
||||
}
|
||||
windowHeight_ = displayHeight_;
|
||||
}
|
||||
else if ( !config.getProperty( "vertical", windowHeight_ ) )
|
||||
{
|
||||
@ -138,11 +127,18 @@ bool SDL::initialize( Configuration &config )
|
||||
|
||||
if (retVal && fullscreen_)
|
||||
{
|
||||
#ifdef WIN32
|
||||
windowFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
#else
|
||||
windowFlags |= SDL_WINDOW_FULLSCREEN;
|
||||
#endif
|
||||
windowFlags |= SDL_FULLSCREEN;
|
||||
}
|
||||
|
||||
if ( retVal && !config.getProperty( "showFrame", showFrame_ ) )
|
||||
{
|
||||
Logger::write( Logger::ZONE_ERROR, "Configuration", "Missing property: \"showFrame\"" );
|
||||
retVal = false;
|
||||
}
|
||||
|
||||
if (retVal && !showFrame_)
|
||||
{
|
||||
windowFlags |= SDL_NOFRAME;
|
||||
}
|
||||
|
||||
if ( retVal )
|
||||
@ -153,17 +149,49 @@ bool SDL::initialize( Configuration &config )
|
||||
|
||||
Logger::write( Logger::ZONE_INFO, "SDL", ss.str( ));
|
||||
|
||||
window_ = SDL_CreateWindow( "RetroFE", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth_, windowHeight_, windowFlags );
|
||||
|
||||
window_ = SDL_SetVideoMode(windowWidth_, windowHeight_, 32, windowFlags);
|
||||
if ( window_ == NULL )
|
||||
{
|
||||
std::string error = SDL_GetError( );
|
||||
Logger::write( Logger::ZONE_ERROR, "SDL", "Create window failed: " + error );
|
||||
Logger::write( Logger::ZONE_ERROR, "SDL", "SDL_SetVideoMode failed: " + error );
|
||||
retVal = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( retVal )
|
||||
unsigned int rmask;
|
||||
unsigned int gmask;
|
||||
unsigned int bmask;
|
||||
unsigned int amask;
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
rmask = 0xff000000;
|
||||
gmask = 0x00ff0000;
|
||||
bmask = 0x0000ff00;
|
||||
amask = 0x000000ff;
|
||||
#else
|
||||
rmask = 0x000000ff;
|
||||
gmask = 0x0000ff00;
|
||||
bmask = 0x00ff0000;
|
||||
amask = 0xff000000;
|
||||
#endif
|
||||
window_virtual_ = SDL_CreateRGBSurface(0, windowWidth_, windowHeight_, 32, 0,0,0,0);
|
||||
//window_virtual_ = SDL_CreateRGBSurface(0, windowWidth_, windowHeight_, 32, rmask, gmask, bmask, amask); // colors are reversed with this !
|
||||
if ( window_virtual_ == NULL )
|
||||
{
|
||||
std::string error = SDL_GetError( );
|
||||
Logger::write( Logger::ZONE_ERROR, "SDL", "SDL_CreateRGBSurface window_virtual_ failed: " + error );
|
||||
retVal = false;
|
||||
}
|
||||
SDL_FillRect(window_virtual_, NULL, SDL_MapRGBA(window_virtual_->format, 0, 0, 0, 0));
|
||||
|
||||
texture_copy_alpha_ = SDL_CreateRGBSurface(0, windowWidth_, windowHeight_, 32, rmask, gmask, bmask, amask);
|
||||
if ( texture_copy_alpha_ == NULL )
|
||||
{
|
||||
std::string error = SDL_GetError( );
|
||||
Logger::write( Logger::ZONE_ERROR, "SDL", "SDL_CreateRGBSurface texture_copy_alpha_ failed: " + error );
|
||||
retVal = false;
|
||||
}
|
||||
SDL_FillRect(texture_copy_alpha_, NULL, SDL_MapRGBA(texture_copy_alpha_->format, 0, 0, 0, 0));
|
||||
}
|
||||
/*if ( retVal )
|
||||
{
|
||||
renderer_ = SDL_CreateRenderer( window_, -1, SDL_RENDERER_ACCELERATED );
|
||||
|
||||
@ -173,14 +201,14 @@ bool SDL::initialize( Configuration &config )
|
||||
Logger::write( Logger::ZONE_ERROR, "SDL", "Create renderer failed: " + error );
|
||||
retVal = false;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if ( SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1") != SDL_TRUE )
|
||||
/*if ( SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1") != SDL_TRUE )
|
||||
{
|
||||
Logger::write( Logger::ZONE_ERROR, "SDL", "Improve scale quality. Continuing with low-quality settings." );
|
||||
}
|
||||
}*/
|
||||
|
||||
bool minimize_on_focus_loss_;
|
||||
/*bool minimize_on_focus_loss_;
|
||||
if ( config.getProperty( "minimize_on_focus_loss", minimize_on_focus_loss_ ) )
|
||||
{
|
||||
if ( minimize_on_focus_loss_ )
|
||||
@ -191,7 +219,7 @@ bool SDL::initialize( Configuration &config )
|
||||
{
|
||||
SDL_SetHintWithPriority( SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0", SDL_HINT_OVERRIDE );
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if ( retVal )
|
||||
{
|
||||
@ -231,16 +259,22 @@ bool SDL::deInitialize( )
|
||||
mutex_ = NULL;
|
||||
}
|
||||
|
||||
if ( renderer_ )
|
||||
/*if ( renderer_ )
|
||||
{
|
||||
SDL_DestroyRenderer(renderer_);
|
||||
renderer_ = NULL;
|
||||
}*/
|
||||
|
||||
if ( window_virtual_ )
|
||||
{
|
||||
SDL_FreeSurface(window_virtual_);
|
||||
window_virtual_ = NULL;
|
||||
}
|
||||
|
||||
if ( window_ )
|
||||
if ( texture_copy_alpha_ )
|
||||
{
|
||||
SDL_DestroyWindow(window_);
|
||||
window_ = NULL;
|
||||
SDL_FreeSurface(texture_copy_alpha_);
|
||||
texture_copy_alpha_ = NULL;
|
||||
}
|
||||
|
||||
SDL_ShowCursor( SDL_TRUE );
|
||||
@ -252,10 +286,10 @@ bool SDL::deInitialize( )
|
||||
|
||||
|
||||
// Get the renderer
|
||||
SDL_Renderer* SDL::getRenderer( )
|
||||
/*SDL_Renderer* SDL::getRenderer( )
|
||||
{
|
||||
return renderer_;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// Get the mutex
|
||||
@ -266,14 +300,158 @@ SDL_mutex* SDL::getMutex( )
|
||||
|
||||
|
||||
// Get the window
|
||||
SDL_Window* SDL::getWindow( )
|
||||
SDL_Surface* SDL::getWindow( )
|
||||
{
|
||||
//return window_;
|
||||
return window_virtual_;
|
||||
}
|
||||
/*SDL_Window* SDL::getWindow( )
|
||||
{
|
||||
return window_;
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void SDL::SDL_Rotate_270(SDL_Surface * dst, SDL_Surface * src){
|
||||
int i, j;
|
||||
uint32_t *source_pixels = (uint32_t*) src->pixels;
|
||||
uint32_t *dest_pixels = (uint32_t*) dst->pixels;
|
||||
|
||||
/// --- Checking for right pixel format ---
|
||||
//MENU_DEBUG_PRINTF("Source bpb = %d, Dest bpb = %d\n", src->format->BitsPerPixel, dst->format->BitsPerPixel);
|
||||
if(src->format->BitsPerPixel != 32){
|
||||
printf("Error in SDL_Rotate_270, Wrong virtual_hw_surface pixel format: %d bpb, expected: uint32_t bpb\n", src->format->BitsPerPixel);
|
||||
return;
|
||||
}
|
||||
if(dst->format->BitsPerPixel != 32){
|
||||
printf("Error in SDL_Rotate_270, Wrong hw_surface pixel format: %d bpb, expected: uint32_t bpb\n", dst->format->BitsPerPixel);
|
||||
return;
|
||||
}
|
||||
|
||||
/// --- Checking if same dimensions ---
|
||||
if(dst->w != src->w || dst->h != src->h){
|
||||
printf("Error in SDL_Rotate_270, hw_surface (%dx%d) and virtual_hw_surface (%dx%d) have different dimensions\n",
|
||||
dst->w, dst->h, src->w, src->h);
|
||||
return;
|
||||
}
|
||||
|
||||
/// --- Pixel copy and rotation (270) ---
|
||||
uint32_t *cur_p_src, *cur_p_dst;
|
||||
for(i=0; i<src->h; i++){
|
||||
for(j=0; j<src->w; j++){
|
||||
cur_p_src = source_pixels + i*src->w + j;
|
||||
cur_p_dst = dest_pixels + (dst->h-1-j)*dst->w + i;
|
||||
*cur_p_dst = *cur_p_src;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Copy virtual window to HW window and Flip display
|
||||
void SDL::renderAndFlipWindow( )
|
||||
{
|
||||
//SDL_BlitSurface(window_virtual_, NULL, window_, NULL);
|
||||
SDL_Rotate_270(window_, window_virtual_);
|
||||
|
||||
SDL_Flip(window_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Uint32 SDL::get_pixel32( SDL_Surface *surface, int x, int y )
|
||||
{
|
||||
//Convert the pixels to 32 bit
|
||||
Uint32 *pixels = (Uint32 *)surface->pixels;
|
||||
|
||||
//Get the requested pixel
|
||||
return pixels[ ( y * surface->w ) + x ];
|
||||
}
|
||||
|
||||
void SDL::put_pixel32( SDL_Surface *surface, int x, int y, Uint32 pixel )
|
||||
{
|
||||
//Convert the pixels to 32 bit
|
||||
Uint32 *pixels = (Uint32 *)surface->pixels;
|
||||
|
||||
//Set the pixel
|
||||
pixels[ ( y * surface->w ) + x ] = pixel;
|
||||
}
|
||||
|
||||
|
||||
// Flip a surface
|
||||
SDL_Surface * SDL::flip_surface( SDL_Surface *surface, int flags )
|
||||
{
|
||||
//Pointer to the soon to be flipped surface
|
||||
SDL_Surface *flipped = NULL;
|
||||
|
||||
//If the image is color keyed
|
||||
if( surface->flags & SDL_SRCCOLORKEY )
|
||||
{
|
||||
flipped = SDL_CreateRGBSurface( SDL_SWSURFACE, surface->w, surface->h, surface->format->BitsPerPixel, surface->format->Rmask, surface->format->Gmask, surface->format->Bmask, 0 );
|
||||
}
|
||||
//Otherwise
|
||||
else
|
||||
{
|
||||
flipped = SDL_CreateRGBSurface( SDL_SWSURFACE, surface->w, surface->h, surface->format->BitsPerPixel, surface->format->Rmask, surface->format->Gmask, surface->format->Bmask, surface->format->Amask );
|
||||
}
|
||||
|
||||
//If the surface must be locked
|
||||
if( SDL_MUSTLOCK( surface ) )
|
||||
{
|
||||
//Lock the surface
|
||||
SDL_LockSurface( surface );
|
||||
}
|
||||
|
||||
//Go through columns
|
||||
for( int x = 0, rx = flipped->w - 1; x < flipped->w; x++, rx-- )
|
||||
{
|
||||
//Go through rows
|
||||
for( int y = 0, ry = flipped->h - 1; y < flipped->h; y++, ry-- )
|
||||
{
|
||||
//Get pixel
|
||||
Uint32 pixel = get_pixel32( surface, x, y );
|
||||
|
||||
//Copy pixel
|
||||
if( ( flags & FLIP_VERTICAL ) && ( flags & FLIP_HORIZONTAL ) )
|
||||
{
|
||||
put_pixel32( flipped, rx, ry, pixel );
|
||||
}
|
||||
else if( flags & FLIP_HORIZONTAL )
|
||||
{
|
||||
put_pixel32( flipped, rx, y, pixel );
|
||||
}
|
||||
else if( flags & FLIP_VERTICAL )
|
||||
{
|
||||
put_pixel32( flipped, x, ry, pixel );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Unlock surface
|
||||
if( SDL_MUSTLOCK( surface ) )
|
||||
{
|
||||
SDL_UnlockSurface( surface );
|
||||
}
|
||||
|
||||
//Copy color key
|
||||
if( surface->flags & SDL_SRCCOLORKEY )
|
||||
{
|
||||
SDL_SetColorKey( flipped, SDL_RLEACCEL | SDL_SRCCOLORKEY, surface->format->colorkey );
|
||||
}
|
||||
|
||||
//Return flipped surface
|
||||
return flipped;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Render a copy of a texture
|
||||
bool SDL::renderCopy( SDL_Texture *texture, float alpha, SDL_Rect *src, SDL_Rect *dest, ViewInfo &viewInfo )
|
||||
/*bool SDL::renderCopy( SDL_Texture *texture, float alpha, SDL_Rect *src, SDL_Rect *dest, ViewInfo &viewInfo )*/
|
||||
bool SDL::renderCopy( SDL_Surface *texture, float alpha, SDL_Rect *src, SDL_Rect *dest, ViewInfo &viewInfo )
|
||||
{
|
||||
|
||||
SDL_Rect srcRect;
|
||||
@ -309,11 +487,13 @@ bool SDL::renderCopy( SDL_Texture *texture, float alpha, SDL_Rect *src, SDL_Rect
|
||||
{
|
||||
srcRect.x = 0;
|
||||
srcRect.y = 0;
|
||||
int w = 0;
|
||||
/*int w = 0;
|
||||
int h = 0;
|
||||
SDL_QueryTexture(texture, NULL, NULL, &w, &h);
|
||||
srcRect.w = w;
|
||||
srcRect.h = h;
|
||||
srcRect.h = h;*/
|
||||
srcRect.w = texture->w;
|
||||
srcRect.h = texture->h;
|
||||
}
|
||||
|
||||
// Define the scale
|
||||
@ -369,40 +549,111 @@ bool SDL::renderCopy( SDL_Texture *texture, float alpha, SDL_Rect *src, SDL_Rect
|
||||
|
||||
}
|
||||
|
||||
SDL_SetTextureAlphaMod( texture, static_cast<char>( alpha * 255 ) );
|
||||
SDL_RenderCopyEx( getRenderer( ), texture, &srcRect, &dstRect, viewInfo.Angle, NULL, SDL_FLIP_NONE );
|
||||
//printf("scaleX : %d, scale Y:%d\n", scaleX, scaleY);
|
||||
//SDL_SetTextureAlphaMod( texture, static_cast<char>( alpha * 255 ) );
|
||||
//SDL_RenderCopyEx( getRenderer( ), texture, &srcRect, &dstRect, viewInfo.Angle, NULL, SDL_FLIP_NONE );
|
||||
|
||||
if ( viewInfo.Reflection == "top" )
|
||||
|
||||
/*if(texture->format->Amask){
|
||||
SDL_SetAlpha( texture, 0, SDL_ALPHA_OPAQUE );
|
||||
SDL_BlitSurface (texture, &srcRect, texture_copy_alpha_, &dstRect);
|
||||
SDL_gfxMultiplyAlpha (texture_copy_alpha_, static_cast<char>( alpha * 255 ));
|
||||
SDL_BlitSurface (texture_copy_alpha_, &dstRect, getWindow(), &dstRect);
|
||||
}
|
||||
else{
|
||||
//SDL_SetAlpha(texture, SDL_SRCALPHA, static_cast<char>( alpha * 255 ));
|
||||
SDL_gfxSetAlpha(texture, static_cast<char>( alpha * 255 ));
|
||||
SDL_BlitSurface (texture, &srcRect, getWindow(), &dstRect);
|
||||
}*/
|
||||
|
||||
/*SDL_SetAlpha(texture, SDL_SRCALPHA, static_cast<char>( alpha * 255 ));
|
||||
SDL_BlitSurface (texture, &srcRect, getWindow(), &dstRect);*/
|
||||
|
||||
|
||||
unsigned int rmask;
|
||||
unsigned int gmask;
|
||||
unsigned int bmask;
|
||||
unsigned int amask;
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
rmask = 0xff000000;
|
||||
gmask = 0x00ff0000;
|
||||
bmask = 0x0000ff00;
|
||||
amask = 0x000000ff;
|
||||
#else
|
||||
rmask = 0x000000ff;
|
||||
gmask = 0x0000ff00;
|
||||
bmask = 0x00ff0000;
|
||||
amask = 0xff000000;
|
||||
#endif
|
||||
SDL_Surface * texture_tmp = SDL_CreateRGBSurface(0, texture->w, texture->h, 32, rmask, gmask, bmask, amask);
|
||||
//SDL_FillRect(texture_tmp, NULL, SDL_MapRGBA(texture_tmp->format, 0, 0, 0, 0));
|
||||
SDL_SetAlpha( texture, 0, SDL_ALPHA_OPAQUE );
|
||||
SDL_BlitSurface (texture, NULL, texture_tmp, NULL);
|
||||
SDL_gfxMultiplyAlpha (texture_tmp, static_cast<char>( alpha * 255 ));
|
||||
//SDL_gfxBlitRGBA(texture_tmp, &srcRect, getWindow(), &dstRect);
|
||||
SDL_BlitSurface(texture_tmp, &srcRect, getWindow(), &dstRect);
|
||||
SDL_FreeSurface(texture_tmp);
|
||||
|
||||
|
||||
//texture = rotozoomSurfaceXY(texture, viewInfo.Angle, scaleX, scaleY, SMOOTHING_OFF);
|
||||
//texture = rotozoomSurfaceXY(texture, viewInfo.Angle, 0.5, 0.5, SMOOTHING_OFF);
|
||||
//double scale_x = 240/1920;
|
||||
//double scale_y = 240/1080;
|
||||
//texture = rotozoomSurfaceXY(texture, 0, 0.5, 0.6, SMOOTHING_ON);
|
||||
|
||||
/*if ( viewInfo.Reflection == "top" )
|
||||
{
|
||||
dstRect.h = static_cast<unsigned int>( static_cast<float>(dstRect.h ) * viewInfo.ReflectionScale);
|
||||
dstRect.y = dstRect.y - dstRect.h - viewInfo.ReflectionDistance;
|
||||
SDL_SetTextureAlphaMod( texture, static_cast<char>( viewInfo.ReflectionAlpha * alpha * 255 ) );
|
||||
SDL_RenderCopyEx( getRenderer( ), texture, src, &dstRect, viewInfo.Angle, NULL, SDL_FLIP_VERTICAL );
|
||||
}
|
||||
//SDL_SetTextureAlphaMod( texture, static_cast<char>( viewInfo.ReflectionAlpha * alpha * 255 ) );
|
||||
//SDL_RenderCopyEx( getRenderer( ), texture, src, &dstRect, viewInfo.Angle, NULL, SDL_FLIP_VERTICAL );
|
||||
|
||||
if ( viewInfo.Reflection == "bottom" )
|
||||
//texture = rotozoomSurfaceXY(texture, viewInfo.Angle, scaleX, scaleY, SMOOTHING_ON);
|
||||
|
||||
|
||||
SDL_SetAlpha( texture, 0, SDL_ALPHA_OPAQUE );
|
||||
SDL_BlitSurface (texture, &srcRect, texture_copy_alpha_, &dstRect);
|
||||
texture_copy_alpha_ = flip_surface(texture_copy_alpha_, FLIP_VERTICAL);
|
||||
SDL_gfxMultiplyAlpha (texture_copy_alpha_, static_cast<char>( alpha * 255 ));
|
||||
SDL_BlitSurface (texture_copy_alpha_, &dstRect, getWindow(), &dstRect);
|
||||
}*/
|
||||
|
||||
/*if ( viewInfo.Reflection == "bottom" )
|
||||
{
|
||||
dstRect.y = dstRect.y + dstRect.h + viewInfo.ReflectionDistance;
|
||||
dstRect.h = static_cast<unsigned int>( static_cast<float>(dstRect.h ) * viewInfo.ReflectionScale);
|
||||
SDL_SetTextureAlphaMod( texture, static_cast<char>( viewInfo.ReflectionAlpha * alpha * 255 ) );
|
||||
SDL_RenderCopyEx( getRenderer( ), texture, src, &dstRect, viewInfo.Angle, NULL, SDL_FLIP_VERTICAL );
|
||||
//SDL_SetTextureAlphaMod( texture, static_cast<char>( viewInfo.ReflectionAlpha * alpha * 255 ) );
|
||||
//SDL_RenderCopyEx( getRenderer( ), texture, src, &dstRect, viewInfo.Angle, NULL, SDL_FLIP_VERTICAL );
|
||||
SDL_SetAlpha(texture, SDL_SRCALPHA, static_cast<char>( alpha * 255 ));
|
||||
//texture = flip_surface(texture, FLIP_VERTICAL);
|
||||
//texture = rotozoomSurfaceXY(texture, viewInfo.Angle, scaleX, scaleY, SMOOTHING_ON);
|
||||
SDL_BlitSurface(texture, src, getWindow(), &dstRect);
|
||||
}
|
||||
|
||||
if ( viewInfo.Reflection == "left" )
|
||||
{
|
||||
dstRect.w = static_cast<unsigned int>( static_cast<float>(dstRect.w ) * viewInfo.ReflectionScale);
|
||||
dstRect.x = dstRect.x - dstRect.w - viewInfo.ReflectionDistance;
|
||||
SDL_SetTextureAlphaMod( texture, static_cast<char>( viewInfo.ReflectionAlpha * alpha * 255 ) );
|
||||
SDL_RenderCopyEx( getRenderer( ), texture, src, &dstRect, viewInfo.Angle, NULL, SDL_FLIP_HORIZONTAL );
|
||||
//SDL_SetTextureAlphaMod( texture, static_cast<char>( viewInfo.ReflectionAlpha * alpha * 255 ) );
|
||||
//SDL_RenderCopyEx( getRenderer( ), texture, src, &dstRect, viewInfo.Angle, NULL, SDL_FLIP_HORIZONTAL );
|
||||
SDL_SetAlpha(texture, SDL_SRCALPHA, static_cast<char>( alpha * 255 ));
|
||||
//texture = flip_surface(texture, FLIP_HORIZONTAL);
|
||||
//texture = rotozoomSurfaceXY(texture, viewInfo.Angle, scaleX, scaleY, SMOOTHING_ON);
|
||||
SDL_BlitSurface(texture, src, getWindow(), &dstRect);
|
||||
}
|
||||
|
||||
if ( viewInfo.Reflection == "right" )
|
||||
{
|
||||
dstRect.x = dstRect.x + dstRect.w + viewInfo.ReflectionDistance;
|
||||
dstRect.w = static_cast<unsigned int>( static_cast<float>(dstRect.w ) * viewInfo.ReflectionScale);
|
||||
SDL_SetTextureAlphaMod( texture, static_cast<char>( viewInfo.ReflectionAlpha * alpha * 255 ) );
|
||||
SDL_RenderCopyEx( getRenderer( ), texture, src, &dstRect, viewInfo.Angle, NULL, SDL_FLIP_HORIZONTAL );
|
||||
}
|
||||
//SDL_SetTextureAlphaMod( texture, static_cast<char>( viewInfo.ReflectionAlpha * alpha * 255 ) );
|
||||
//SDL_RenderCopyEx( getRenderer( ), texture, src, &dstRect, viewInfo.Angle, NULL, SDL_FLIP_HORIZONTAL );
|
||||
SDL_SetAlpha(texture, SDL_SRCALPHA, static_cast<char>( alpha * 255 ));
|
||||
//texture = flip_surface(texture, FLIP_HORIZONTAL);
|
||||
//texture = rotozoomSurfaceXY(texture, viewInfo.Angle, scaleX, scaleY, SMOOTHING_ON);
|
||||
SDL_BlitSurface(texture, src, getWindow(), &dstRect);
|
||||
}*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -16,10 +16,14 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
//#include <SDL/SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <string>
|
||||
#include "Graphics/ViewInfo.h"
|
||||
|
||||
//Flip flags
|
||||
#define FLIP_VERTICAL 1
|
||||
#define FLIP_HORIZONTAL 2
|
||||
|
||||
class Configuration;
|
||||
|
||||
@ -29,10 +33,13 @@ class SDL
|
||||
public:
|
||||
static bool initialize( Configuration &config );
|
||||
static bool deInitialize( );
|
||||
static SDL_Renderer *getRenderer( );
|
||||
//static SDL_Renderer *getRenderer( );
|
||||
static SDL_mutex *getMutex( );
|
||||
static SDL_Window *getWindow( );
|
||||
static bool renderCopy( SDL_Texture *texture, float alpha, SDL_Rect *src, SDL_Rect *dest, ViewInfo &viewInfo );
|
||||
//static SDL_Window *getWindow( );
|
||||
static SDL_Surface *getWindow( );
|
||||
static void renderAndFlipWindow( );
|
||||
//static bool renderCopy( SDL_Texture *texture, float alpha, SDL_Rect *src, SDL_Rect *dest, ViewInfo &viewInfo );
|
||||
static bool renderCopy( SDL_Surface *texture, float alpha, SDL_Rect *src, SDL_Rect *dest, ViewInfo &viewInfo );
|
||||
static int getWindowWidth( )
|
||||
{
|
||||
return windowWidth_;
|
||||
@ -45,14 +52,23 @@ public:
|
||||
{
|
||||
return fullscreen_;
|
||||
}
|
||||
static void SDL_Rotate_270(SDL_Surface * dst, SDL_Surface * src);
|
||||
|
||||
private:
|
||||
static SDL_Window *window_;
|
||||
static SDL_Renderer *renderer_;
|
||||
//static SDL_Window *window_;
|
||||
//static SDL_Renderer *renderer_;
|
||||
static Uint32 get_pixel32( SDL_Surface *surface, int x, int y );
|
||||
static void put_pixel32( SDL_Surface *surface, int x, int y, Uint32 pixel );
|
||||
static SDL_Surface * flip_surface( SDL_Surface *surface, int flags );
|
||||
static SDL_Surface *window_;
|
||||
static SDL_Surface *window_virtual_;
|
||||
static SDL_Surface *texture_copy_alpha_;
|
||||
static SDL_mutex *mutex_;
|
||||
static int displayWidth_;
|
||||
static int displayHeight_;
|
||||
static int windowWidth_;
|
||||
static int windowHeight_;
|
||||
static bool fullscreen_;
|
||||
static bool showFrame_;
|
||||
};
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <SDL2/SDL_mixer.h>
|
||||
#include <SDL/SDL_mixer.h>
|
||||
class Sound
|
||||
{
|
||||
public:
|
||||
|
||||
@ -23,6 +23,13 @@
|
||||
#include <dirent.h>
|
||||
#include <locale>
|
||||
#include <list>
|
||||
#include <linux/vt.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/kd.h>
|
||||
#include <linux/keyboard.h>
|
||||
|
||||
|
||||
Utils::Utils()
|
||||
@ -253,3 +260,30 @@ std::string Utils::trimEnds(std::string str)
|
||||
return str;
|
||||
}
|
||||
|
||||
int Utils::termfix(uint32_t ttyId){
|
||||
// Init tty file path
|
||||
char ttyFilePath[100];
|
||||
sprintf(ttyFilePath, "/dev/tty%d", ttyId);
|
||||
|
||||
// Open tty
|
||||
int fd = open(ttyFilePath, O_RDWR, 0);
|
||||
|
||||
// Unlock virtual terminal
|
||||
int res = ioctl(fd, VT_UNLOCKSWITCH, 1);
|
||||
if(res != 0)
|
||||
{
|
||||
printf("ioctl VT_UNLOCKSWITCH failed");
|
||||
return res;
|
||||
}
|
||||
|
||||
// Set Virtual terminal mode text (not graphical)
|
||||
ioctl(fd, KDSETMODE, KD_TEXT);
|
||||
if(res != 0)
|
||||
{
|
||||
printf("ioctl KDSETMODE failed");
|
||||
return res;
|
||||
}
|
||||
|
||||
//printf("Success\n");
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <stdint.h>
|
||||
class Utils
|
||||
{
|
||||
public:
|
||||
@ -42,6 +43,8 @@ public:
|
||||
static std::string combinePath(std::string path1, std::string path2, std::string path3);
|
||||
static std::string combinePath(std::string path1, std::string path2, std::string path3, std::string path4);
|
||||
static std::string combinePath(std::string path1, std::string path2, std::string path3, std::string path4, std::string path5);
|
||||
|
||||
static int termfix(uint32_t ttyId);
|
||||
|
||||
#ifdef WIN32
|
||||
static const char pathSeparator = '\\';
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <gst/app/gstappsink.h>
|
||||
@ -48,7 +48,7 @@ GStreamerVideo::GStreamerVideo()
|
||||
, videoConvert_(NULL)
|
||||
, videoConvertCaps_(NULL)
|
||||
, videoBus_(NULL)
|
||||
, texture_(NULL)
|
||||
//, texture_(NULL)
|
||||
, height_(0)
|
||||
, width_(0)
|
||||
, videoBuffer_(NULL)
|
||||
@ -68,11 +68,11 @@ GStreamerVideo::~GStreamerVideo()
|
||||
videoBuffer_ = NULL;
|
||||
}
|
||||
|
||||
if (texture_)
|
||||
/*if (texture_)
|
||||
{
|
||||
SDL_DestroyTexture(texture_);
|
||||
texture_ = NULL;
|
||||
}
|
||||
}*/
|
||||
|
||||
freeElements();
|
||||
}
|
||||
@ -82,10 +82,10 @@ void GStreamerVideo::setNumLoops(int n)
|
||||
numLoops_ = n;
|
||||
}
|
||||
|
||||
SDL_Texture *GStreamerVideo::getTexture() const
|
||||
/*SDL_Texture *GStreamerVideo::getTexture() const
|
||||
{
|
||||
return texture_;
|
||||
}
|
||||
}*/
|
||||
|
||||
void GStreamerVideo::processNewBuffer (GstElement * /* fakesink */, GstBuffer *buf, GstPad *new_pad, gpointer userdata)
|
||||
{
|
||||
@ -158,11 +158,11 @@ bool GStreamerVideo::stop()
|
||||
(void)gst_element_set_state(playbin_, GST_STATE_NULL);
|
||||
}
|
||||
|
||||
if(texture_)
|
||||
/*if(texture_)
|
||||
{
|
||||
SDL_DestroyTexture(texture_);
|
||||
texture_ = NULL;
|
||||
}
|
||||
}*/
|
||||
|
||||
if(videoBuffer_)
|
||||
{
|
||||
@ -341,12 +341,12 @@ void GStreamerVideo::draw()
|
||||
void GStreamerVideo::update(float /* dt */)
|
||||
{
|
||||
SDL_LockMutex(SDL::getMutex());
|
||||
if(!texture_ && width_ != 0 && height_ != 0)
|
||||
/*if(!texture_ && width_ != 0 && height_ != 0)
|
||||
{
|
||||
texture_ = SDL_CreateTexture(SDL::getRenderer(), SDL_PIXELFORMAT_IYUV,
|
||||
SDL_TEXTUREACCESS_STREAMING, width_, height_);
|
||||
SDL_SetTextureBlendMode(texture_, SDL_BLENDMODE_BLEND);
|
||||
}
|
||||
}*/
|
||||
|
||||
if(videoBuffer_)
|
||||
{
|
||||
@ -364,9 +364,9 @@ void GStreamerVideo::update(float /* dt */)
|
||||
|
||||
if (bufSize == vbytes)
|
||||
{
|
||||
SDL_LockTexture(texture_, NULL, &pixels, &pitch);
|
||||
//SDL_LockTexture(texture_, NULL, &pixels, &pitch);
|
||||
gst_buffer_extract(videoBuffer_, 0, pixels, vbytes);
|
||||
SDL_UnlockTexture(texture_);
|
||||
//SDL_UnlockTexture(texture_);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -382,10 +382,10 @@ void GStreamerVideo::update(float /* dt */)
|
||||
y_plane = bufInfo.data;
|
||||
u_plane = y_plane + (height_ * y_stride);
|
||||
v_plane = u_plane + ((height_ / 2) * u_stride);
|
||||
SDL_UpdateYUVTexture(texture_, NULL,
|
||||
/*SDL_UpdateYUVTexture(texture_, NULL,
|
||||
(const Uint8*)y_plane, y_stride,
|
||||
(const Uint8*)u_plane, u_stride,
|
||||
(const Uint8*)v_plane, v_stride);
|
||||
(const Uint8*)v_plane, v_stride);*/
|
||||
gst_buffer_unmap(videoBuffer_, &bufInfo);
|
||||
}
|
||||
}
|
||||
@ -398,10 +398,10 @@ void GStreamerVideo::update(float /* dt */)
|
||||
gst_video_meta_map(meta, 0, &y_info, &y_plane, &y_stride, GST_MAP_READ);
|
||||
gst_video_meta_map(meta, 1, &u_info, &u_plane, &u_stride, GST_MAP_READ);
|
||||
gst_video_meta_map(meta, 2, &v_info, &v_plane, &v_stride, GST_MAP_READ);
|
||||
SDL_UpdateYUVTexture(texture_, NULL,
|
||||
/*SDL_UpdateYUVTexture(texture_, NULL,
|
||||
(const Uint8*)y_plane, y_stride,
|
||||
(const Uint8*)u_plane, u_stride,
|
||||
(const Uint8*)v_plane, v_stride);
|
||||
(const Uint8*)v_plane, v_stride);*/
|
||||
gst_video_meta_unmap(meta, 0, &y_info);
|
||||
gst_video_meta_unmap(meta, 1, &u_info);
|
||||
gst_video_meta_unmap(meta, 2, &v_info);
|
||||
|
||||
@ -33,7 +33,7 @@ public:
|
||||
bool play(std::string file);
|
||||
bool stop();
|
||||
bool deInitialize();
|
||||
SDL_Texture *getTexture() const;
|
||||
//SDL_Texture *getTexture() const;
|
||||
void update(float dt);
|
||||
void draw();
|
||||
void setNumLoops(int n);
|
||||
@ -52,7 +52,7 @@ private:
|
||||
GstElement *videoConvert_;
|
||||
GstCaps *videoConvertCaps_;
|
||||
GstBus *videoBus_;
|
||||
SDL_Texture* texture_;
|
||||
//SDL_Texture* texture_;
|
||||
gint height_;
|
||||
gint width_;
|
||||
GstBuffer *videoBuffer_;
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <string>
|
||||
|
||||
class IVideo
|
||||
@ -26,7 +26,7 @@ public:
|
||||
virtual bool play(std::string file) = 0;
|
||||
virtual bool stop() = 0;
|
||||
virtual bool deInitialize() = 0;
|
||||
virtual SDL_Texture *getTexture() const = 0;
|
||||
//virtual SDL_Texture *getTexture() const = 0;
|
||||
virtual void update(float dt) = 0;
|
||||
virtual void draw() = 0;
|
||||
virtual int getHeight() = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user