Skip to content
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

SFX Refactor #1376

Open
wants to merge 20 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/build-linux-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ jobs:
libx11-dev \
libxxf86vm-dev \
libopenal-dev \
libasound2-dev \
libpipewire-0.3-dev \
portaudio19-dev \
oss4-dev \
libjack-dev \
libpulse-dev \
libdbus-1-dev \
libfreetype6-dev \
libxcursor-dev \
libxinerama-dev \
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ set(TORQUE_APP_GAME_DIRECTORY "${TORQUE_APP_ROOT_DIRECTORY}/game")
set(TORQUE_LIB_ROOT_DIRECTORY "${CMAKE_SOURCE_DIR}/Engine/lib")
set(TORQUE_LIB_TARG_DIRECTORY "${CMAKE_BINARY_DIR}/Engine/lib")
set(TORQUE_SOURCE_DIRECTROY "${CMAKE_SOURCE_DIR}/Engine/source")
set(TORQUE_LIB_OUTPUT "${TORQUE_APP_DIRECTORY}")

if(APPLE)
set(TORQUE_LIB_OUTPUT "${TORQUE_APP_GAME_DIRECTORY}/${TORQUE_APP_NAME}.app/Contents/Frameworks")
endif(APPLE)

# Ensure all possible configurations end up in the project directory
set(CMAKE_INSTALL_PREFIX "${TORQUE_APP_ROOT_DIRECTORY}" CACHE STRING "" FORCE)
Expand All @@ -32,6 +37,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Tools/CMake/finders")
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${TORQUE_APP_GAME_DIRECTORY}" )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${TORQUE_LIB_OUTPUT}")
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )

# Detect CPU Information
Expand Down
4 changes: 0 additions & 4 deletions Engine/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ else()
advanced_option(AL_ALEXT_PROTOTYPES "Use Extended OpenAL options" ON)
endif()

if(AL_ALEXT_PROTOTYPES)
addDef( "AL_ALEXT_PROTOTYPES" )
endif()

#SDL
set(SDL_SHARED ON CACHE BOOL "Build a shared version of the library" FORCE)
set(SDL_STATIC OFF CACHE BOOL "Build a static version of the library" FORCE)
Expand Down
55 changes: 3 additions & 52 deletions Engine/source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,10 @@ torqueAddSourceDirectories("ts" "ts/collada" "ts/assimp" "ts/loader" "ts/arch")
# Handle SFX - OpenAL is handled as a module later on
torqueAddSourceDirectories("sfx" "sfx/media" "sfx/null")
if(TORQUE_SFX_OPENAL AND NOT TORQUE_DEDICATED)
if(AL_ALEXT_PROTOTYPES)
addDef( "AL_ALEXT_PROTOTYPES" )
endif()
torqueAddSourceDirectories("sfx/openal")
if(WIN32)
torqueAddSourceDirectories("sfx/openal/win32")
elseif(UNIX AND NOT APPLE)
torqueAddSourceDirectories("sfx/openal/linux")
elseif(APPLE)
torqueAddSourceDirectories("sfx/openal/mac")
endif()
endif()
# Handle GFX
torqueAddSourceDirectories("gfx" "gfx/Null" "gfx/test" "gfx/bitmap" "gfx/bitmap/loaders" "gfx/bitmap/loaders/ies"
Expand Down Expand Up @@ -535,48 +531,3 @@ if(TORQUE_TESTING)
endif(TORQUE_TESTING)

append_defs()

# Process library binaries - these are coming from modules that are providing links to external, precompiled code that should be included
# with the executable. This is done because on Windows, the .lib is separate from the .dll so we can't automatically scan for shared
# objects in our link libraries in that case.
foreach (LIBRARY_BINARY ${TORQUE_ADDITIONAL_LIBRARY_BINARIES})
if (APPLE)
# For OSX, we want these binaries to be copied to the Frameworks directory
add_custom_command(TARGET ${TORQUE_APP_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${TORQUE_APP_GAME_DIRECTORY}/${TORQUE_APP_NAME}.app/Contents/Frameworks"
COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_BINARY} "${TORQUE_APP_GAME_DIRECTORY}/${TORQUE_APP_NAME}.app/Contents/Frameworks/$(CONFIGURATION)")
else()
# All other platforms expect the file next to the executable
add_custom_command(TARGET ${TORQUE_APP_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_BINARY} "${TORQUE_APP_GAME_DIRECTORY}")
endif (APPLE)
endforeach()

# Process link libraries for dynamic links - we do this on OSX/Linux to ensure the binaries end up in the correct App directory
# as in the root CMake we force everything to be in game. This is necessary because on these platforms these are considered "libraries"
# and not runtime binaries like we configure in the root CMake. We don't globally set library outputs to avoid outputting eg. a files to
# our game directory.
if (UNIX)
get_target_property(GAME_LINK_LIBRARIES ${TORQUE_APP_NAME} LINK_LIBRARIES)
foreach (GAME_LINK_LIBRARY ${GAME_LINK_LIBRARIES})
# For eg. OSX some links are not valid targets - for example frameworks provided by OS
if (TARGET ${GAME_LINK_LIBRARY})
get_target_property(LINK_LIBRARY_TYPE ${GAME_LINK_LIBRARY} TYPE)
# Only pay attention to shared libraries and make them output to the app resources
if ("${LINK_LIBRARY_TYPE}" STREQUAL "SHARED_LIBRARY")
if (APPLE)
set_target_properties(${GAME_LINK_LIBRARY} PROPERTIES
XCODE_ATTRIBUTE_SKIP_INSTALL YES
)
add_custom_command(TARGET ${TORQUE_APP_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${TORQUE_APP_GAME_DIRECTORY}/${TORQUE_APP_NAME}.app/Contents/Frameworks"
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:${GAME_LINK_LIBRARY}>" "${TORQUE_APP_GAME_DIRECTORY}/${TORQUE_APP_NAME}.app/Contents/Frameworks/$<TARGET_FILE_NAME:${GAME_LINK_LIBRARY}>"
COMMAND ${CMAKE_COMMAND} -E create_symlink "$<TARGET_FILE:${GAME_LINK_LIBRARY}>" "${TORQUE_APP_GAME_DIRECTORY}/${TORQUE_APP_NAME}.app/Contents/Frameworks/$<TARGET_LINKER_FILE_NAME:${GAME_LINK_LIBRARY}>"
COMMAND ${CMAKE_COMMAND} -E create_symlink "$<TARGET_FILE:${GAME_LINK_LIBRARY}>" "${TORQUE_APP_GAME_DIRECTORY}/${TORQUE_APP_NAME}.app/Contents/Frameworks/lib$<TARGET_LINKER_FILE_BASE_NAME:${GAME_LINK_LIBRARY}>.1.dylib"
)
else()
set_target_properties(${GAME_LINK_LIBRARY} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${TORQUE_APP_GAME_DIRECTORY}")
endif(APPLE)
endif()
endif()
endforeach()
endif (UNIX)
4 changes: 2 additions & 2 deletions Engine/source/core/ogg/oggTheoraDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ bool OggTheoraDecoder::_packetin( ogg_packet* packet )
TimeSourceRef timeSource = mTimeSource;
if( timeSource )
{
F32 currentTick = F32( timeSource->getPosition() ) / 1000.f;
F32 currentTick = F32( timeSource->getTimeIndex() ) / 1000.f;

if( currentTick >= ( mCurrentFrameTime + mFrameDuration ) )
dropThisFrame = true;
Expand Down Expand Up @@ -691,4 +691,4 @@ void OggTheoraDecoder::_transcode420toRGBA_SSE2( th_ycbcr_buffer ycbcr, U8* buff

#endif
}
#endif
#endif
4 changes: 2 additions & 2 deletions Engine/source/core/stream/tStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class IPositionable
typedef P PositionType;

/// @return the current position.
virtual PositionType getPosition() const = 0;
virtual PositionType getTimeIndex() const = 0;

/// Set the current position to be "pos".
/// @param pos The new position.
virtual void setPosition( PositionType pos ) = 0;
virtual void setTimeIndex( PositionType pos ) = 0;
};

/// Interface for structures that allow their state to be reset.
Expand Down
4 changes: 2 additions & 2 deletions Engine/source/core/util/timeSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class GenericTimeSource : public IPositionable< Tick >,

/// Return the number of ticks since the time source
/// has been started.
TickType getPosition() const override
TickType getTimeIndex() const override
{
if( !isStarted() )
return TypeTraits< TickType >::ZERO;
Expand All @@ -117,7 +117,7 @@ class GenericTimeSource : public IPositionable< Tick >,
}

///
void setPosition( TickType pos ) override
void setTimeIndex( TickType pos ) override
{
if( !isStarted() )
mStartTime = pos;
Expand Down
18 changes: 9 additions & 9 deletions Engine/source/gfx/gfxAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ DefineEnumType( GFXAdapterType );

DECLARE_STRUCT( GFXVideoMode );

DefineConsoleType( TypeGFXAdapterType, GFXAdapterType );
DefineConsoleType( TypeGFXBlend, GFXBlend );
DefineConsoleType( TypeGFXCmpFunc, GFXCmpFunc );
DefineConsoleType( TypeGFXTextureAddressMode, GFXTextureAddressMode );
DefineConsoleType( TypeGFXFormat, GFXFormat );
DefineConsoleType( TypeGFXTextureFilterType, GFXTextureFilterType );
DefineConsoleType( TypeGFXCullMode, GFXCullMode );
DefineConsoleType( TypeGFXStencilOp, GFXStencilOp );
DefineConsoleType( TypeGFXBlendOp, GFXBlendOp );
DefineConsoleType( TypeGFXAdapterType, GFXAdapterType )
DefineConsoleType( TypeGFXBlend, GFXBlend )
DefineConsoleType( TypeGFXCmpFunc, GFXCmpFunc )
DefineConsoleType( TypeGFXTextureAddressMode, GFXTextureAddressMode )
DefineConsoleType( TypeGFXFormat, GFXFormat )
DefineConsoleType( TypeGFXTextureFilterType, GFXTextureFilterType )
DefineConsoleType( TypeGFXCullMode, GFXCullMode )
DefineConsoleType( TypeGFXStencilOp, GFXStencilOp )
DefineConsoleType( TypeGFXBlendOp, GFXBlendOp )

#endif // !_GFXAPI_H_
2 changes: 1 addition & 1 deletion Engine/source/gfx/video/theoraTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ void TheoraTexture::refresh()
// lifetime of our time sources isn't bound to the
// threaded state.

mAsyncState->syncTime( _getTimeSource()->getPosition() );
mAsyncState->syncTime( _getTimeSource()->getTimeIndex() );

// Update the texture, if necessary.

Expand Down
8 changes: 4 additions & 4 deletions Engine/source/gfx/video/theoraTexture.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ class TheoraTexture : private IOutputStream< TheoraTextureFrame* >,
private:

// IPositionable.
U32 getPosition() const override { return mCurrentTime; }
void setPosition( U32 pos ) override {}
U32 getTimeIndex() const override { return mCurrentTime; }
void setTimeIndex( U32 pos ) override {}
};

/// The Theora video file.
Expand Down Expand Up @@ -410,8 +410,8 @@ class TheoraTexture : private IOutputStream< TheoraTextureFrame* >,
GFXTexHandle& getTexture() { return mCurrentFrame->mTexture; }

// IPositionable.
U32 getPosition() const override { return _getTimeSource()->getPosition(); }
void setPosition( U32 pos ) override {} // Not (yet?) implemented.
U32 getTimeIndex() const override { return _getTimeSource()->getTimeIndex(); }
void setTimeIndex( U32 pos ) override {} // Not (yet?) implemented.
};

#endif // TORQUE_OGGTHEORA
Expand Down
2 changes: 1 addition & 1 deletion Engine/source/gui/theora/guiTheoraCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void GuiTheoraCtrl::onRender(Point2I offset, const RectI &updateRect)
String info = String::ToString( "Frame Number: %i | Frame Time: %.2fs | Playback Time: %.2fs | Dropped: %i",
mTheoraTexture.getFrameNumber(),
mTheoraTexture.getFrameTime(),
F32( mTheoraTexture.getPosition() ) / 1000.f,
F32( mTheoraTexture.getTimeIndex() ) / 1000.f,
mTheoraTexture.getNumDroppedFrames() );

drawUtil->setBitmapModulation( mProfile->mFontColors[ 0 ] );
Expand Down
2 changes: 1 addition & 1 deletion Engine/source/gui/theora/guiTheoraCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class GuiTheoraCtrl : public GuiControl
/// Return the current playback position.
F32 getCurrentTime()
{
return F32( mTheoraTexture.getPosition() ) / 1000.f;
return F32( mTheoraTexture.getTimeIndex() ) / 1000.f;
}

// GuiControl.
Expand Down
2 changes: 1 addition & 1 deletion Engine/source/platform/async/asyncPacketQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class AsyncPacketQueue
TickType packetPos = TypeTraits< TickType >::MAX );

/// Return the current playback position according to the time source.
TickType getCurrentTick() const { return Deref( mTimeSource ).getPosition(); }
TickType getCurrentTick() const { return Deref( mTimeSource ).getTimeIndex(); }

/// Return the total number of ticks that have been queued so far.
TickType getTotalQueuedTicks() const { return mTotalQueuedTicks; }
Expand Down
6 changes: 3 additions & 3 deletions Engine/source/platform/async/asyncPacketStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ AsyncPacketBufferedInputStream< Stream, Packet >::AsyncPacketBufferedInputStream

IPositionable< U32 >* positionable = dynamic_cast< IPositionable< U32 >* >( &Deref( stream ) );
if( positionable )
mNumTotalSourceElements += positionable->getPosition();
mNumTotalSourceElements += positionable->getTimeIndex();
else
{
ISizeable< U32 >* sizeable = dynamic_cast< ISizeable< U32 >* >( &Deref( stream ) );
Expand Down Expand Up @@ -284,15 +284,15 @@ void AsyncPacketBufferedInputStream< Stream, Packet >::_requestNext()
IPositionable< U32 >* positionable = dynamic_cast< IPositionable< U32 >* >( &Deref( stream ) );
U32 pos = 0;
if(positionable)
pos = positionable->getPosition();
pos = positionable->getTimeIndex();

resettable->reset();
isEOS = false;
this->mNumRemainingSourceElements = mNumTotalSourceElements;

if( positionable )
{
positionable->setPosition(pos);
positionable->setTimeIndex(pos);
U32 dur = stream->getDuration();
if(dur != 0) //avoiding division by zero? not needed, probably
this->mNumRemainingSourceElements -= (U32)(mNumTotalSourceElements*(F32)pos/dur);
Expand Down
Loading
Loading