Skip to content

Commit

Permalink
ozFactory, DDS fixed, File::directory()
Browse files Browse the repository at this point in the history
- ozCore
  * String::fileDirectory(), File::directory()
- ozEngine
  * Shader class (not woking yet)
  * GL, AL loaders for InputStream
- ozFactory: builder library
  * DDS builder moved ozFactory and fixed
  • Loading branch information
ducakar committed May 7, 2013
1 parent e3c6bac commit 113b6d4
Show file tree
Hide file tree
Showing 38 changed files with 1,172 additions and 114 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ set( OZ_VERSION 0.3.81 )
option( OZ_TRACK_ALLOCS "Track memory allocations to detect new/delete mismatches and memory leaks." OFF ) option( OZ_TRACK_ALLOCS "Track memory allocations to detect new/delete mismatches and memory leaks." OFF )
option( OZ_SIMD_MATH "Use SIMD implementation of linear algebra classes." OFF ) option( OZ_SIMD_MATH "Use SIMD implementation of linear algebra classes." OFF )
option( OZ_DYNAMICS "Build complete ozDynamics library with ODE support." OFF ) option( OZ_DYNAMICS "Build complete ozDynamics library with ODE support." OFF )
option( OZ_SDL2 "Use SDL 2.0 instead of SDL 1.2." OFF )
option( OZ_GL_ES "Use OpenGL ES 2.0 instead of OpenGL 2.1." OFF ) option( OZ_GL_ES "Use OpenGL ES 2.0 instead of OpenGL 2.1." OFF )
option( OZ_NONFREE "Enable support for building S3TC textures." OFF )


option( OZ_LUAJIT "Use use LuaJIT 2.0 instead of official Lua." OFF ) option( OZ_LUAJIT "Use use LuaJIT 2.0 instead of official Lua." OFF )
option( OZ_SDL2 "Use SDL 2.0 instead of SDL 1.2." OFF )
option( OZ_NET "Enable networking support." OFF ) option( OZ_NET "Enable networking support." OFF )
option( OZ_NONFREE "Enable support for building S3TC textures." OFF )


option( OZ_STANDALONE "Install layout appropriate for launching from its own folder." OFF ) option( OZ_STANDALONE "Install layout appropriate for launching from its own folder." OFF )
option( OZ_TESTS "Build test programs (that should only be used by me)." OFF ) option( OZ_TESTS "Build test programs (that should only be used by me)." OFF )
Expand Down Expand Up @@ -136,7 +136,7 @@ endif()


if( NOT PLATFORM_EMBEDDED ) if( NOT PLATFORM_EMBEDDED )
find_library( FREEIMAGE_LIBRARY freeimage ) find_library( FREEIMAGE_LIBRARY freeimage )
find_library( FREEIMAGEPLUS_LIBRARY freeimageplus) find_library( FREEIMAGEPLUS_LIBRARY freeimageplus )
mark_as_advanced( FREEIMAGE_LIBRARY ) mark_as_advanced( FREEIMAGE_LIBRARY )
mark_as_advanced( FREEIMAGEPLUS_LIBRARY ) mark_as_advanced( FREEIMAGEPLUS_LIBRARY )


Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ The following alternative launches are available:
NaCl port. If `strip` is passed as the second option, binaries are stripped too. NaCl port. If `strip` is passed as the second option, binaries are stripped too.


Documentation Documentation

------------- -------------


To generate documentation from source code with Doxygen, run To generate documentation from source code with Doxygen, run
Expand Down
4 changes: 3 additions & 1 deletion autogen.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
# #


version=0.3.81 version=0.3.81
components=( ozCore ozDynamics ozEngine common matrix nirvana modules client builder unittest ) components=( ozCore ozDynamics ozEngine ozFactory
common matrix nirvana modules client builder
unittest )


# Generate CMakeLists.txt files. # Generate CMakeLists.txt files.
for component in ${components[@]}; do for component in ${components[@]}; do
Expand Down
6 changes: 3 additions & 3 deletions etc/PKGBUILD
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ function build()


function package_liboz() function package_liboz()
{ {
pkgdesc='OpenZone Core, Dynamics and Engine Libraries' pkgdesc='OpenZone ozCore, ozDynamics, ozEngine and ozFactory libraries'
license=('ZLIB') license=('ZLIB')
depends=('libpulse' 'physfs') depends=('libpulse' 'physfs' 'sdl_ttf' 'libgl' 'openal' 'freeimage')


cd "${srcdir}/${pkgbase}-${pkgver}" cd "${srcdir}/${pkgbase}-${pkgver}"


Expand All @@ -47,7 +47,7 @@ function package_liboz()
function package_openzone() function package_openzone()
{ {
pkgdesc='Simple cross-platform FPS/RTS game engine' pkgdesc='Simple cross-platform FPS/RTS game engine'
depends=('freeimage' 'libgl' 'liboz' 'luajit' 'openal' 'openzone-data' 'sdl_ttf') depends=('liboz' 'luajit' 'openzone-data')
optdepends=('espeak: speech synthesis' optdepends=('espeak: speech synthesis'
'libmad: MP3 streaming' 'libmad: MP3 streaming'
'faad2: AAC streaming' 'faad2: AAC streaming'
Expand Down
27 changes: 14 additions & 13 deletions etc/openzone.spec
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,30 +31,28 @@ and front-end that renders it and enables the player to manipulate with the
simulated world. simulated world.


%package -n liboz %package -n liboz
Summary: OpenZone Core, Dynamics and Engine Libraries Summary: OpenZone ozCore, ozDynamics, ozEngine and ozFactory libraries
Group: System Environment/Libraries Group: System Environment/Libraries
License: zlib License: zlib


%description -n liboz %description -n liboz
OpenZone Core Library provides facilities like container templates, array ozCore library provides facilities like container templates, array utilities,
utilities, string class, memory manager with memory leak tracing, crash string class, memory manager with memory leak tracing, crash handlers,
handlers, I/O buffers and classes for filesystem access with PhysicsFS support, I/O buffers and classes for filesystem access with PhysicsFS support,
log writer, JSON file manipulation class, math functions and linear algebra log writer, JSON file manipulation class, math functions and math classes.
classes. ozDynamics library is a rigid body physics engine used in OpenZone engine.
OpenZone Dynamics Library is a rigid body physics engine used in OpenZone ozEngine library contains basic engine building blocks for OpenZone game.
engine. ozFactory library contains functions for building OpenZone assets.
OpenZone Engine Library contains basic engine building blocks for OpenZone
game.


%package -n liboz-devel %package -n liboz-devel
Summary: Headers for OpenZone Core, Dynamics and Engine Libraries Summary: Headers for liboz
Group: Development/Libraries Group: Development/Libraries
License: zlib License: zlib
Requires: liboz = %{version} Requires: liboz = %{version}


%description -n liboz-devel %description -n liboz-devel
This package contains header files for OpenZone Core, Dynamics and Engine This package contains header files for OpenZone ozCore, ozDynamics, ozEngine and
Libraries. ozFactory libraries.


%package data %package data
Summary: OpenZone game data Summary: OpenZone game data
Expand Down Expand Up @@ -106,16 +104,19 @@ install -m644 share/openzone/*.zip "$RPM_BUILD_ROOT"%{_datadir}/openzone
%{_libdir}/libozCore.so* %{_libdir}/libozCore.so*
%{_libdir}/libozDynamics.so* %{_libdir}/libozDynamics.so*
%{_libdir}/libozEngine.so* %{_libdir}/libozEngine.so*
%{_libdir}/libozFactory.so*
%doc src/ozCore/COPYING %doc src/ozCore/COPYING


%files -n liboz-devel %files -n liboz-devel
%defattr(-, root, root, -) %defattr(-, root, root, -)
%{_libdir}/pkgconfig/ozCore.pc %{_libdir}/pkgconfig/ozCore.pc
%{_libdir}/pkgconfig/ozDynamics.pc %{_libdir}/pkgconfig/ozDynamics.pc
%{_libdir}/pkgconfig/ozEngine.pc %{_libdir}/pkgconfig/ozEngine.pc
%{_libdir}/pkgconfig/ozFactory.pc
%{_includedir}/ozCore %{_includedir}/ozCore
%{_includedir}/ozDynamics %{_includedir}/ozDynamics
%{_includedir}/ozEngine %{_includedir}/ozEngine
%{_includedir}/ozFactory
%doc src/ozCore/COPYING %doc src/ozCore/COPYING


%files data %files data
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
add_subdirectory( ozCore ) add_subdirectory( ozCore )
add_subdirectory( ozDynamics ) add_subdirectory( ozDynamics )
add_subdirectory( ozEngine ) add_subdirectory( ozEngine )
add_subdirectory( ozFactory )
add_subdirectory( unittest ) add_subdirectory( unittest )


add_pch( pch stable.hh stable.cc ) add_pch( pch stable.hh stable.cc )
Expand Down
2 changes: 1 addition & 1 deletion src/builder/MD3.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void MD3::readAnimData()
{ {
File animFile( sPath + "/animation.cfg" ); File animFile( sPath + "/animation.cfg" );


String realPath = animFile.realDir() + "/" + animFile.path(); String realPath = animFile.realDirectory() + "/" + animFile.path();


FILE* fs = fopen( realPath, "r" ); FILE* fs = fopen( realPath, "r" );
if( fs == nullptr ) { if( fs == nullptr ) {
Expand Down
2 changes: 1 addition & 1 deletion src/builder/OBJ.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void OBJ::load()


config.clear( true ); config.clear( true );


String realPath = modelFile.realDir() + "/" + &path[1]; String realPath = modelFile.realDirectory() + "/" + &path[1];


loadMaterials( realPath + "/data.mtl" ); loadMaterials( realPath + "/data.mtl" );


Expand Down
1 change: 1 addition & 0 deletions src/builder/common.hh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#pragma once #pragma once


#include <client/common.hh> #include <client/common.hh>
#include <ozFactory/ozFactory.hh>
#include <builder/config.hh> #include <builder/config.hh>


namespace oz namespace oz
Expand Down
15 changes: 10 additions & 5 deletions src/ozCore/CMakeLists.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -76,16 +76,21 @@ add_library( ozCore
) )


if( ANDROID ) if( ANDROID )
target_link_libraries( ozCore ${PHYSFS_LIBRARY} ${ZLIB_LIBRARY} -ldl -lOpenSLES -llog ${PLATFORM_STL_LIBRARY} ) target_link_libraries( ozCore ${PLATFORM_STL_LIBRARY} -llog -lOpenSLES -ldl )
elseif( NACL ) elseif( NACL )
target_link_libraries( ozCore ${PHYSFS_LIBRARY} ${ZLIB_LIBRARY} -lppapi_cpp -lppapi -lpthread ) target_link_libraries( ozCore -lpthread -lppapi -lppapi_cpp )
elseif( WIN32 ) elseif( WIN32 )
target_link_libraries( ozCore ${PHYSFS_LIBRARY} -lwinmm ) target_link_libraries( ozCore -lwinmm )
elseif( NOT CMAKE_SYSTEM_NAME STREQUAL Linux ) elseif( NOT CMAKE_SYSTEM_NAME STREQUAL Linux )
target_link_libraries( ozCore ${PHYSFS_LIBRARY} -ldl -lpulse-simple -lrt -lpthread ) target_link_libraries( ozCore -lpthread -lrt -lpulse-simple -ldl )
else() else()
# TODO: Remove -lrt once glibc 2.17 becomes minimum. # TODO: Remove -lrt once glibc 2.17 becomes minimum.
target_link_libraries( ozCore ${PHYSFS_LIBRARY} -ldl -lpulse-simple -lasound -lrt -lpthread ) target_link_libraries( ozCore -lpthread -lrt -lasound -lpulse-simple -ldl )
endif()

target_link_libraries( ozCore ${PHYSFS_LIBRARY} )
if( PLATFORM_EMBEDDED )
target_link_libraries( ozCore ${ZLIB_LIBRARY} )
endif() endif()


set_target_properties( ozCore PROPERTIES VERSION ${OZ_VERSION} SOVERSION 0 ) set_target_properties( ozCore PROPERTIES VERSION ${OZ_VERSION} SOVERSION 0 )
Expand Down
2 changes: 1 addition & 1 deletion src/ozCore/File.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ bool File::stat()
return fileType != MISSING; return fileType != MISSING;
} }


String File::realDir() const String File::realDirectory() const
{ {
if( filePath.fileIsVirtual() ) { if( filePath.fileIsVirtual() ) {
const char* realDir = PHYSFS_getRealDir( &filePath[1] ); const char* realDir = PHYSFS_getRealDir( &filePath[1] );
Expand Down
22 changes: 16 additions & 6 deletions src/ozCore/File.hh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -180,33 +180,43 @@ class File
} }


/** /**
* %File name. * Extract directory from the path (substring before the last `/`).
*/
String directory() const
{
return filePath.fileDirectory();
}

/**
* Extract file name from the path (substring after the last `/`).
*/ */
String name() const String name() const
{ {
return filePath.fileName(); return filePath.fileName();
} }


/** /**
* Name without the extension (and the dot). * Extract base file name from the path (substring after the last `/` till the last dot
* following it).
*/ */
String baseName() const String baseName() const
{ {
return filePath.fileBaseName(); return filePath.fileBaseName();
} }


/** /**
* Extension (part of base name after the last dot) or "" if no dot in base name. * Extract file extension from the path (substring after the last dot in file name or "" if no
* extension).
*/ */
String extension() const String extension() const
{ {
return filePath.fileExtension(); return filePath.fileExtension();
} }


/** /**
* True iff the extension (without dot) is equal to the given string. * True iff file name has the given extension.
* *
* Empty string matches both no extension and files ending with dot. * Empty string matches both no extension and files names ending with dot.
*/ */
bool hasExtension( const char* ext ) const bool hasExtension( const char* ext ) const
{ {
Expand All @@ -216,7 +226,7 @@ class File
/** /**
* %Path to the archive or mount-point of a VFS, "" for native files. * %Path to the archive or mount-point of a VFS, "" for native files.
*/ */
String realDir() const; String realDirectory() const;


/** /**
* %Path to file in native file system. * %Path to file in native file system.
Expand Down
2 changes: 1 addition & 1 deletion src/ozCore/Math.hh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ class Math
} }


/** /**
* Index (counting from the least significant side) of the first 1 bit or -1 if `v` is 0. * Index of the first 1 bit (counting from the least significant bit) or -1 if `v` is 0.
*/ */
template <typename Value = int> template <typename Value = int>
OZ_ALWAYS_INLINE OZ_ALWAYS_INLINE
Expand Down
17 changes: 16 additions & 1 deletion src/ozCore/String.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ String::String( int count_, int ) :
} }


OZ_HIDDEN OZ_HIDDEN
inline void String::ensureCapacity( int newCount ) void String::ensureCapacity( int newCount )
{ {
hard_assert( buffer != nullptr && count >= 0 && newCount >= 0 ); hard_assert( buffer != nullptr && count >= 0 && newCount >= 0 );


Expand Down Expand Up @@ -164,6 +164,13 @@ DArray<String> String::split( const char* s, char delimiter )
return array; return array;
} }


String String::fileDirectory( const char* s )
{
int slash = lastIndex( s, '/' );

return slash >= 0 ? substring( s, 0, slash ) : String( s );
}

String String::fileName( const char* s ) String String::fileName( const char* s )
{ {
int begin = s[0] == '@'; int begin = s[0] == '@';
Expand Down Expand Up @@ -678,6 +685,7 @@ String String::create( int length, char** buffer_ )
{ {
String r( length, 0 ); String r( length, 0 );


r.buffer[length] = '\0';
*buffer_ = r.buffer; *buffer_ = r.buffer;
return r; return r;
} }
Expand Down Expand Up @@ -854,6 +862,13 @@ DArray<String> String::split( char delimiter ) const
return array; return array;
} }


String String::fileDirectory() const
{
int slash = lastIndex( '/' );

return slash >= 0 ? substring( 0, slash ) : String( buffer );
}

String String::fileName() const String String::fileName() const
{ {
int begin = buffer[0] == '@'; int begin = buffer[0] == '@';
Expand Down
Loading

0 comments on commit 113b6d4

Please sign in to comment.