commit 45d3b05d65fc4fa2b6737307ba6629912f789634 Author: Laurent Gomila Date: Wed Jul 6 22:39:55 2011 +0200 Initial commit -- moved from https://github.com/LaurentGomila/SFML (bindings/c) diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9691bbf --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,60 @@ + +cmake_minimum_required(VERSION 2.8) + +# set a default build type if none was provided +# this has to be done before the project() instruction! +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build (Debug or Release)" FORCE) +endif() + +# project name +project(CSFML) + +# include the configuration file +include(${CMAKE_SOURCE_DIR}/cmake/Config.cmake) + +# setup version numbers +set(VERSION_MAJOR 2) +set(VERSION_MINOR 0) +set(VERSION_PATCH 0) + +# add the CSFML header path +include_directories(${CMAKE_SOURCE_DIR}/include) + +# force dynamic build (static build is not supported) +set(BUILD_SHARED_LIBS TRUE) + +# add an option for building the API documentation +set(BUILD_DOC FALSE CACHE BOOL "TRUE to generate the API documentation, FALSE to ignore it") + +# disable the rpath stuff +set(CMAKE_SKIP_BUILD_RPATH TRUE) + +# define an option for choosing between static and dynamic C runtime (Windows only) +if(WINDOWS) + set(STATIC_STD_LIBS FALSE CACHE BOOL "TRUE to statically link to the standard libraries, FALSE to use them as DLLs") + + # for VC++, we can apply it globally by modifying the compiler flags + if(COMPILER_MSVC AND STATIC_STD_LIBS) + foreach(flag + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}") + endif() + endforeach() + endif() +endif() + +# add the subdirectories +add_subdirectory(src/SFML) +if(BUILD_DOC) + add_subdirectory(doc) +endif() + +# setup the install rules +install(DIRECTORY include + DESTINATION . + COMPONENT devel + PATTERN ".svn" EXCLUDE) +install(FILES license.txt DESTINATION ${INSTALL_MISC_DIR}) diff --git a/cmake/Config.cmake b/cmake/Config.cmake new file mode 100644 index 0000000..db0f128 --- /dev/null +++ b/cmake/Config.cmake @@ -0,0 +1,48 @@ + +# detect the OS +if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set(WINDOWS 1) +elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(LINUX 1) +elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(MACOSX 1) +else() + message(WARNING "Unsupported operating system") + return() +endif() + +# detect the architecture +# note: this test won't work for cross-compilation +include(CheckTypeSize) +check_type_size(void* SIZEOF_VOID_PTR) +if(${SIZEOF_VOID_PTR} MATCHES "^8$") + set(ARCH_BITS 64) +else() + set(ARCH_BITS 32) +endif() + +# detect the compiler and its version +if(CMAKE_COMPILER_IS_GNUCXX) + set(COMPILER_GCC 1) + execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_OUTPUT) + string(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" GCC_VERSION "${GCC_VERSION_OUTPUT}") +elseif(MSVC_VERSION EQUAL 1400) + set(COMPILER_MSVC 1) + set(MSVC_VERSION 2005) +elseif(MSVC_VERSION EQUAL 1500) + set(COMPILER_MSVC 1) + set(MSVC_VERSION 2008) +elseif(MSVC_VERSION EQUAL 1600) + set(COMPILER_MSVC 1) + set(MSVC_VERSION 2010) +else() + message(WARNING "Unsupported compiler") + return() +endif() + +# define the install directory for miscellaneous files +if(WINDOWS) + set(INSTALL_MISC_DIR .) +elseif(UNIX) + set(INSTALL_MISC_DIR share/CSFML) +endif() diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake new file mode 100644 index 0000000..23ae0de --- /dev/null +++ b/cmake/Macros.cmake @@ -0,0 +1,95 @@ + +# some of these macros are inspired from the boost/cmake macros + +# check if a value is contained in a list +# sets ${var} to TRUE if the value is found +macro(csfml_list_contains var value) + set(${var}) + foreach(value2 ${ARGN}) + if(${value} STREQUAL ${value2}) + set(${var} TRUE) + endif() + endforeach() +endmacro() + +# parse a list of arguments and options +# ex: sfml_parse_arguments(THIS "SOURCES;DEPENDS" "FLAG" FLAG SOURCES s1 s2 s3 DEPENDS d1 d2) +# will define the following variables: +# - THIS_SOURCES (s1 s2 s3) +# - THIS_DEPENDS (d1 d2) +# - THIS_FLAG TRUE +macro(csfml_parse_arguments prefix arg_names option_names) + foreach(arg_name ${arg_names}) + set(${prefix}_${arg_name}) + endforeach() + foreach(option_name ${option_names}) + set(${prefix}_${option_name} FALSE) + endforeach() + set(current_arg_name) + set(current_arg_list) + foreach(arg ${ARGN}) + csfml_list_contains(is_arg_name ${arg} ${arg_names}) + if(is_arg_name) + set(${prefix}_${current_arg_name} ${current_arg_list}) + set(current_arg_name ${arg}) + set(current_arg_list) + else() + csfml_list_contains(is_option ${arg} ${option_names}) + if(is_option) + set(${prefix}_${arg} TRUE) + else() + set(current_arg_list ${current_arg_list} ${arg}) + endif() + endif() + endforeach() + set(${prefix}_${current_arg_name} ${current_arg_list}) +endmacro() + +# add a new target which is a CSFML library +# ex: csfml_add_library(sfml-graphics +# SOURCES sprite.cpp image.cpp ... +# DEPENDS sfml-window sfml-system) +macro(csfml_add_library target) + + # parse the arguments + csfml_parse_arguments(THIS "SOURCES;DEPENDS" "" ${ARGN}) + + # create the target + add_library(${target} ${THIS_SOURCES}) + + # adjust the output file prefix/suffix to match our conventions + if(WINDOWS) + # include the major version number in Windows shared library names (but not import library names) + set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d) + set_target_properties(${target} PROPERTIES SUFFIX "-${VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}") + else() + set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d) + endif() + if (WINDOWS AND COMPILER_GCC) + # on Windows/gcc get rid of "lib" prefix for shared libraries, + # and transform the ".dll.a" suffix into ".a" for import libraries + set_target_properties(${target} PROPERTIES PREFIX "") + set_target_properties(${target} PROPERTIES IMPORT_SUFFIX ".a") + endif() + + # set the version and soversion of the target (for compatible systems -- mostly Linuxes) + set_target_properties(${target} PROPERTIES SOVERSION ${VERSION_MAJOR}) + set_target_properties(${target} PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR}) + + # for gcc 4.x on Windows, apply the STATIC_STD_LIBS option if it is enabled + if(WINDOWS AND COMPILER_GCC AND STATIC_STD_LIBS) + if(${GCC_VERSION} MATCHES "4\\..*") + set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++") + endif() + endif() + + # link the target to its external dependencies (C++ SFML libraries) + target_link_libraries(${target} ${THIS_DEPENDS}) + + # add the install rule + install(TARGETS ${target} + RUNTIME DESTINATION bin COMPONENT bin + LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin + ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel) + +endmacro() diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 0000000..0eb1c8f --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,50 @@ + +# find doxygen +find_package(Doxygen REQUIRED) + +# set the input and output documentation paths +set(DOXYGEN_INPUT_DIR ${CMAKE_SOURCE_DIR}) +set(DOXYGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/doc) + +# see if we can generate the CHM documentation +if(WINDOWS) + # if HHC is found, we can generate the CHM (compressed HTML) output + find_program(DOXYGEN_HHC_PROGRAM + NAMES hhc.exe + PATHS "c:/Program Files/HTML Help Workshop" + DOC "HTML Help Compiler program") + if(DOXYGEN_HHC_PROGRAM) + set(DOXYGEN_GENERATE_HTMLHELP YES) + else() + set(DOXYGEN_GENERATE_HTMLHELP NO) + endif() +else() + set(DOXYGEN_HHC_PROGRAM) + set(DOXYGEN_GENERATE_HTMLHELP NO) +endif() + +# configure the source Doxyfile by copying it and replacing all @variables@ +set(DOXYGEN_CONFIGURED_INPUT ${DOXYGEN_OUTPUT_DIR}/doxyfile) +configure_file(${DOXYGEN_INPUT_DIR}/doc/doxyfile.in ${DOXYGEN_CONFIGURED_INPUT} @ONLY) + +# copy the files needed by the documentation +configure_file(${DOXYGEN_INPUT_DIR}/doc/doxygen.css ${DOXYGEN_OUTPUT_DIR}/html/doxygen.css COPYONLY) +configure_file(${DOXYGEN_INPUT_DIR}/doc/logo.jpg ${DOXYGEN_OUTPUT_DIR}/html/logo.jpg COPYONLY) +configure_file(${DOXYGEN_INPUT_DIR}/doc/logo-bg.jpg ${DOXYGEN_OUTPUT_DIR}/html/logo-bg.jpg COPYONLY) + +# target setup +add_custom_target(doc + COMMAND ${CMAKE_COMMAND} -E echo_append "Building API Documentation..." + COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_CONFIGURED_INPUT} + COMMAND ${CMAKE_COMMAND} -E echo "Done." + WORKING_DIRECTORY ${DOXYGEN_INPUT_DIR}) + +# setup install rules +install(DIRECTORY ${DOXYGEN_OUTPUT_DIR}/html + DESTINATION ${INSTALL_MISC_DIR}/doc + COMPONENT doc) +if(DOXYGEN_HHC_PROGRAM) + install(FILES ${DOXYGEN_OUTPUT_DIR}/SFML.chm + DESTINATION ${INSTALL_MISC_DIR}/doc + COMPONENT doc) +endif() diff --git a/doc/doxyfile.in b/doc/doxyfile.in new file mode 100644 index 0000000..e62ed7d --- /dev/null +++ b/doc/doxyfile.in @@ -0,0 +1,1513 @@ +# Doxyfile 1.5.8 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = SFML + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = @VERSION_MAJOR@.@VERSION_MINOR@ + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = "@DOXYGEN_OUTPUT_DIR@" + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, +# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, +# Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, Slovene, +# Spanish, Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = YES + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = YES + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = YES + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it parses. +# With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this tag. +# The format is ext=language, where ext is a file extension, and language is one of +# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, +# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat +# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = NO + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by +# doxygen. The layout file controls the global structure of the generated output files +# in an output format independent way. The create the layout file that represents +# doxygen's defaults, run doxygen with the -l option. You can optionally specify a +# file name after the option, if omitted DoxygenLayout.xml will be used as the name +# of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = YES + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = "@DOXYGEN_INPUT_DIR@/include/SFML" \ + "@DOXYGEN_INPUT_DIR@/doc/mainpage.hpp" + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = *.h \ + *.hpp + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = .svn + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = NO + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .htm + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = "@DOXYGEN_INPUT_DIR@/doc/header.htm" + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = "@DOXYGEN_INPUT_DIR@/doc/footer.htm" + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = "@DOXYGEN_INPUT_DIR@/doc/doxygen.css" + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = @DOXYGEN_GENERATE_HTMLHELP@ + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = ../SFML.chm + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = "@DOXYGEN_HHC_PROGRAM@" + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER +# are set, an additional index file will be generated that can be used as input for +# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated +# HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. +# For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's +# filter section matches. +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 1 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to FRAME, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. Other possible values +# for this tag are: HIERARCHIES, which will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list; +# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which +# disables this behavior completely. For backwards compatibility with previous +# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE +# respectively. + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = D:/Programmes/mscgen + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Options related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/doc/doxygen.css b/doc/doxygen.css new file mode 100644 index 0000000..83deb81 --- /dev/null +++ b/doc/doxygen.css @@ -0,0 +1,681 @@ +div#logo +{ + margin-bottom : 1em; + background : url("./logo-bg.jpg") repeat-x; +} + +div#logo a +{ + display : block; +} + +p#footer +{ + text-decoration : overline; + color : #606060; + padding-top : 1em; + text-align : center; + font-size : smaller; +} + +p#footer a +{ + color : #007298; + text-decoration : none; +} + +/* The standard CSS for doxygen */ + +body, table, div, p, dl { + font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; + font-size: 12px; +} + +/* @group Heading Levels */ + +h1 { + font-size: 150%; +} + +h2 { + font-size: 120%; +} + +h3 { + font-size: 100%; +} + +dt { + font-weight: bold; +} + +div.multicol { + -moz-column-gap: 1em; + -webkit-column-gap: 1em; + -moz-column-count: 3; + -webkit-column-count: 3; +} + +p.startli, p.startdd, p.starttd { + margin-top: 2px; +} + +p.endli { + margin-bottom: 0px; +} + +p.enddd { + margin-bottom: 4px; +} + +p.endtd { + margin-bottom: 2px; +} + +/* @end */ + +caption { + font-weight: bold; +} + +span.legend { + font-size: 70%; + text-align: center; +} + +h3.version { + font-size: 90%; + text-align: center; +} + +div.qindex, div.navtab{ + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + padding: 2px; +} + +div.qindex, div.navpath { + width: 100%; + line-height: 140%; +} + +div.navtab { + margin-right: 15px; +} + +/* @group Link Styling */ + +a { + color: #3D578C; + font-weight: normal; + text-decoration: none; +} + +.contents a:visited { + color: #4665A2; +} + +a:hover { + text-decoration: underline; +} + +a.qindex { + font-weight: bold; +} + +a.qindexHL { + font-weight: bold; + background-color: #9CAFD4; + color: #ffffff; + border: 1px double #869DCA; +} + +.contents a.qindexHL:visited { + color: #ffffff; +} + +a.el { + font-weight: bold; +} + +a.elRef { +} + +a.code { + color: #4665A2; +} + +a.codeRef { + color: #4665A2; +} + +/* @end */ + +dl.el { + margin-left: -1cm; +} + +.fragment { + font-family: monospace, fixed; + font-size: 105%; +} + +pre.fragment { + border: 1px solid #C4CFE5; + background-color: #FBFCFD; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; +} + +div.ah { + background-color: black; + font-weight: bold; + color: #ffffff; + margin-bottom: 3px; + margin-top: 3px; + padding: 0.2em; + border: solid thin #333; + border-radius: 0.5em; + -webkit-border-radius: .5em; + -moz-border-radius: .5em; + -webkit-box-shadow: 2px 2px 3px #999; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); + background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000); +} + +div.groupHeader { + margin-left: 16px; + margin-top: 12px; + margin-bottom: 6px; + font-weight: bold; +} + +div.groupText { + margin-left: 16px; + font-style: italic; +} + +body { + background: white; + color: black; + margin: 0; +} + +div.contents { + margin-top: 10px; + margin-left: 10px; + margin-right: 10px; +} + +td.indexkey { + background-color: #EBEFF6; + font-weight: bold; + border: 1px solid #C4CFE5; + margin: 2px 0px 2px 0; + padding: 2px 10px; +} + +td.indexvalue { + background-color: #EBEFF6; + border: 1px solid #C4CFE5; + padding: 2px 10px; + margin: 2px 0px; +} + +tr.memlist { + background-color: #EEF1F7; +} + +p.formulaDsp { + text-align: center; +} + +img.formulaDsp { + +} + +img.formulaInl { + vertical-align: middle; +} + +div.center { + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + padding: 0px; +} + +div.center img { + border: 0px; +} + +address.footer { + text-align: right; + padding-right: 12px; +} + +img.footer { + border: 0px; + vertical-align: middle; +} + +/* @group Code Colorization */ + +span.keyword { + color: #008000 +} + +span.keywordtype { + color: #604020 +} + +span.keywordflow { + color: #e08000 +} + +span.comment { + color: #800000 +} + +span.preprocessor { + color: #806020 +} + +span.stringliteral { + color: #002080 +} + +span.charliteral { + color: #008080 +} + +span.vhdldigit { + color: #ff00ff +} + +span.vhdlchar { + color: #000000 +} + +span.vhdlkeyword { + color: #700070 +} + +span.vhdllogic { + color: #ff0000 +} + +/* @end */ + +/* +.search { + color: #003399; + font-weight: bold; +} + +form.search { + margin-bottom: 0px; + margin-top: 0px; +} + +input.search { + font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #e8eef2; +} +*/ + +td.tiny { + font-size: 75%; +} + +.dirtab { + padding: 4px; + border-collapse: collapse; + border: 1px solid #A3B4D7; +} + +th.dirtab { + background: #EBEFF6; + font-weight: bold; +} + +hr { + height: 0px; + border: none; + border-top: 1px solid #4A6AAA; +} + +hr.footer { + height: 1px; +} + +/* @group Member Descriptions */ + +table.memberdecls { + border-spacing: 0px; + padding: 0px; +} + +.mdescLeft, .mdescRight, +.memItemLeft, .memItemRight, +.memTemplItemLeft, .memTemplItemRight, .memTemplParams { + background-color: #F9FAFC; + border: none; + margin: 4px; + padding: 1px 0 0 8px; +} + +.mdescLeft, .mdescRight { + padding: 0px 8px 4px 8px; + color: #555; +} + +.memItemLeft, .memItemRight, .memTemplParams { + border-top: 1px solid #C4CFE5; +} + +.memItemLeft, .memTemplItemLeft { + white-space: nowrap; +} + +.memTemplParams { + color: #4665A2; + white-space: nowrap; +} + +/* @end */ + +/* @group Member Details */ + +/* Styles for detailed member documentation */ + +.memtemplate { + font-size: 80%; + color: #4665A2; + font-weight: normal; + margin-left: 3px; +} + +.memnav { + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; +} + +.memitem { + padding: 0; + margin-bottom: 10px; +} + +.memname { + white-space: nowrap; + font-weight: bold; + margin-left: 6px; +} + +.memproto { + border-top: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 0px 6px 0px; + color: #253555; + font-weight: bold; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + /* firefox specific markup */ + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + -moz-border-radius-topright: 8px; + -moz-border-radius-topleft: 8px; + /* webkit specific markup */ + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + -webkit-border-top-right-radius: 8px; + -webkit-border-top-left-radius: 8px; + background-image:url('nav_f.png'); + background-repeat:repeat-x; + background-color: #E2E8F2; + +} + +.memdoc { + border-bottom: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 2px 5px; + background-color: #FBFCFD; + border-top-width: 0; + /* firefox specific markup */ + -moz-border-radius-bottomleft: 8px; + -moz-border-radius-bottomright: 8px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + background-image: -moz-linear-gradient(center top, #FFFFFF 0%, #FFFFFF 60%, #F7F8FB 95%, #EEF1F7); + /* webkit specific markup */ + -webkit-border-bottom-left-radius: 8px; + -webkit-border-bottom-right-radius: 8px; + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + background-image: -webkit-gradient(linear,center top,center bottom,from(#FFFFFF), color-stop(0.6,#FFFFFF), color-stop(0.60,#FFFFFF), color-stop(0.95,#F7F8FB), to(#EEF1F7)); +} + +.paramkey { + text-align: right; +} + +.paramtype { + white-space: nowrap; +} + +.paramname { + color: #602020; + white-space: nowrap; +} +.paramname em { + font-style: normal; +} + +/* @end */ + +/* @group Directory (tree) */ + +/* for the tree view */ + +.ftvtree { + font-family: sans-serif; + margin: 0px; +} + +/* these are for tree view when used as main index */ + +.directory { + font-size: 9pt; + font-weight: bold; + margin: 5px; +} + +.directory h3 { + margin: 0px; + margin-top: 1em; + font-size: 11pt; +} + +/* +The following two styles can be used to replace the root node title +with an image of your choice. Simply uncomment the next two styles, +specify the name of your image and be sure to set 'height' to the +proper pixel height of your image. +*/ + +/* +.directory h3.swap { + height: 61px; + background-repeat: no-repeat; + background-image: url("yourimage.gif"); +} +.directory h3.swap span { + display: none; +} +*/ + +.directory > h3 { + margin-top: 0; +} + +.directory p { + margin: 0px; + white-space: nowrap; +} + +.directory div { + display: none; + margin: 0px; +} + +.directory img { + vertical-align: -30%; +} + +/* these are for tree view when not used as main index */ + +.directory-alt { + font-size: 100%; + font-weight: bold; +} + +.directory-alt h3 { + margin: 0px; + margin-top: 1em; + font-size: 11pt; +} + +.directory-alt > h3 { + margin-top: 0; +} + +.directory-alt p { + margin: 0px; + white-space: nowrap; +} + +.directory-alt div { + display: none; + margin: 0px; +} + +.directory-alt img { + vertical-align: -30%; +} + +/* @end */ + +div.dynheader { + margin-top: 8px; +} + +address { + font-style: normal; + color: #2A3D61; +} + +table.doxtable { + border-collapse:collapse; +} + +table.doxtable td, table.doxtable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.doxtable th { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; + text-align:left; +} + +.tabsearch { + top: 0px; + left: 10px; + height: 36px; + background-image: url('tab_b.png'); + z-index: 101; + overflow: hidden; + font-size: 13px; +} + +.navpath ul +{ + font-size: 11px; + background-image:url('tab_b.png'); + background-repeat:repeat-x; + height:30px; + line-height:30px; + color:#8AA0CC; + border:solid 1px #C2CDE4; + overflow:hidden; + margin:0px; + padding:0px; +} + +.navpath li +{ + list-style-type:none; + float:left; + padding-left:10px; + padding-right: 15px; + background-image:url('bc_s.png'); + background-repeat:no-repeat; + background-position:right; + color:#364D7C; +} + +.navpath a +{ + height:32px; + display:block; + text-decoration: none; + outline: none; +} + +.navpath a:hover +{ + color:#6884BD; +} + +div.summary +{ + float: right; + font-size: 8pt; + padding-right: 5px; + width: 50%; + text-align: right; +} + +div.summary a +{ + white-space: nowrap; +} + +div.header +{ + background-image:url('nav_h.png'); + background-repeat:repeat-x; + background-color: #F9FAFC; + margin: 0px; + border-bottom: 1px solid #C4CFE5; +} + +div.headertitle +{ + padding: 5px 5px 5px 10px; +} diff --git a/doc/footer.htm b/doc/footer.htm new file mode 100644 index 0000000..97e97d5 --- /dev/null +++ b/doc/footer.htm @@ -0,0 +1,8 @@ + + + + + diff --git a/doc/header.htm b/doc/header.htm new file mode 100644 index 0000000..3bde2f6 --- /dev/null +++ b/doc/header.htm @@ -0,0 +1,12 @@ + + + + SFML - Simple and Fast Multimedia Library + + + + + + diff --git a/doc/logo-bg.jpg b/doc/logo-bg.jpg new file mode 100644 index 0000000..06ecea2 Binary files /dev/null and b/doc/logo-bg.jpg differ diff --git a/doc/logo.jpg b/doc/logo.jpg new file mode 100644 index 0000000..81b0e14 Binary files /dev/null and b/doc/logo.jpg differ diff --git a/doc/mainpage.hpp b/doc/mainpage.hpp new file mode 100644 index 0000000..2f4962c --- /dev/null +++ b/doc/mainpage.hpp @@ -0,0 +1,94 @@ +//////////////////////////////////////////////////////////// +/// \mainpage +/// +/// \section welcome Welcome +/// Welcome to the official SFML documentation for C. Here you will find a detailed +/// view of all the SFML functions, as well as source +/// files.
+/// If you are looking for tutorials, you can visit the official website +/// at www.sfml-dev.org. +/// +/// \section example Short example +/// Here is a short example, to show you how simple it is to use SFML in C : +/// +/// \code +/// +/// #include +/// #include +/// +/// int main() +/// { +/// sfVideoMode mode = {800, 600, 32}; +/// sfRenderWindow* window; +/// sfImage* image; +/// sfSprite* sprite; +/// sfFont* font; +/// sfText* text; +/// sfMusic* music; +/// sfEvent event; +/// +/// /* Create the main window */ +/// window = sfRenderWindow_Create(mode, "SFML window", sfResize | sfClose, NULL); +/// if (!window) +/// return EXIT_FAILURE; +/// +/// /* Load a sprite to display */ +/// image = sfImage_CreateFromFile("cute_image.jpg"); +/// if (!image) +/// return EXIT_FAILURE; +/// sprite = sfSprite_Create(); +/// sfSprite_SetImage(sprite, image, sfTrue); +/// +/// /* Create a graphical text to display */ +/// font = sfFont_CreateFromFile("arial.ttf"); +/// if (!font) +/// return EXIT_FAILURE; +/// text = sfText_Create(); +/// sfText_SetString(text, "Hello SFML"); +/// sfText_SetFont(text, font); +/// sfText_SetCharacterSize(text, 50); +/// +/// /* Load a music to play */ +/// music = sfMusic_CreateFromFile("nice_music.ogg"); +/// if (!music) +/// return EXIT_FAILURE; +/// +/// /* Play the music */ +/// sfMusic_Play(music); +/// +/// /* Start the game loop */ +/// while (sfRenderWindow_IsOpened(window)) +/// { +/// /* Process events */ +/// while (sfRenderWindow_GetEvent(window, &event)) +/// { +/// /* Close window : exit */ +/// if (event.Type == sfEvtClosed) +/// sfRenderWindow_Close(window); +/// } +/// +/// /* Clear the screen */ +/// sfRenderWindow_Clear(window, sfBlack); +/// +/// /* Draw the sprite */ +/// sfRenderWindow_DrawSprite(window, sprite); +/// +/// /* Draw the text */ +/// sfRenderWindow_DrawText(window, text); +/// +/// /* Update the window */ +/// sfRenderWindow_Display(window); +/// } +/// +/// /* Cleanup resources */ +/// sfMusic_Destroy(music); +/// sfText_Destroy(text); +/// sfFont_Destroy(font); +/// sfSprite_Destroy(sprite); +/// sfImage_Destroy(image); +/// sfRenderWindow_Destroy(window); +/// +/// return EXIT_SUCCESS; +/// } +/// \endcode +//////////////////////////////////////////////////////////// diff --git a/include/SFML/Audio.h b/include/SFML/Audio.h new file mode 100644 index 0000000..879b2e7 --- /dev/null +++ b/include/SFML/Audio.h @@ -0,0 +1,41 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_AUDIO_H +#define SFML_AUDIO_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include + + +#endif // SFML_AUDIO_H diff --git a/include/SFML/Audio/Listener.h b/include/SFML/Audio/Listener.h new file mode 100644 index 0000000..ee85653 --- /dev/null +++ b/include/SFML/Audio/Listener.h @@ -0,0 +1,91 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_LISTENER_H +#define SFML_LISTENER_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// Change the global volume of all the sounds +/// +/// \param volume : New global volume, in the range [0, 100] +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfListener_SetGlobalVolume(float volume); + +//////////////////////////////////////////////////////////// +/// Get the current value of the global volume of all the sounds +/// +/// \return Current global volume, in the range [0, 100] +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfListener_GetGlobalVolume(void); + +//////////////////////////////////////////////////////////// +/// Change the position of the listener +/// +/// \param x : X position of the listener in the world +/// \param y : Y position of the listener in the world +/// \param z : Z position of the listener in the world +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfListener_SetPosition(float x, float y, float z); + +//////////////////////////////////////////////////////////// +/// Get the current position of the listener +/// +/// \param x : X position of the listener in the world +/// \param y : Y position of the listener in the world +/// \param z : Z position of the listener in the world +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfListener_GetPosition(float* x, float* y, float* z); + +//////////////////////////////////////////////////////////// +/// Change the orientation of the listener +/// +/// \param x : X component of the listener's direction +/// \param y : Y component of the listener's direction +/// \param z : Z component of the listener's direction +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfListener_SetDirection(float x, float y, float z); + +//////////////////////////////////////////////////////////// +/// Get the current orientation of the listener +/// +/// \param x : X component of the listener's direction +/// \param y : Y component of the listener's direction +/// \param z : Z component of the listener's direction +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfListener_GetDirection(float* x, float* y, float* z); + + +#endif // SFML_LISTENER_H diff --git a/include/SFML/Audio/Music.h b/include/SFML/Audio/Music.h new file mode 100644 index 0000000..2f75570 --- /dev/null +++ b/include/SFML/Audio/Music.h @@ -0,0 +1,292 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_MUSIC_H +#define SFML_MUSIC_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new music and load it from a file +/// +/// \param filename : Path of the music file to open +/// +/// \return A new sfMusic object (NULL if failed) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfMusic* sfMusic_CreateFromFile(const char* filename); + +//////////////////////////////////////////////////////////// +/// Create a new music and load it from a file in memory +/// +/// \param data : Pointer to the file data in memory +/// \param sizeInBytes : Size of the data to load, in bytes +/// +/// \return A new sfMusic object (NULL if failed) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfMusic* sfMusic_CreateFromMemory(const void* data, size_t sizeInBytes); + +//////////////////////////////////////////////////////////// +/// Destroy an existing music +/// +/// \param music : Music to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMusic_Destroy(sfMusic* music); + +//////////////////////////////////////////////////////////// +/// Set a music loop state +/// +/// \param music : Music to set the loop state +/// \param loop : sfTrue to play in loop, sfFalse to play once +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMusic_SetLoop(sfMusic* music, sfBool loop); + +//////////////////////////////////////////////////////////// +/// Tell whether or not a music is looping +/// +/// \param music : Music to get the loop state from +/// +/// \return sfTrue if the music is looping, sfFalse otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfMusic_GetLoop(const sfMusic* music); + +//////////////////////////////////////////////////////////// +/// Get a music duration +/// +/// \param music : Music to get the duration from +/// +/// \return Music duration, in milliseconds +/// +//////////////////////////////////////////////////////////// +CSFML_API sfUint32 sfMusic_GetDuration(const sfMusic* music); + +//////////////////////////////////////////////////////////// +/// Start playing a music +/// +/// \param music : Music to play +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMusic_Play(sfMusic* music); + +//////////////////////////////////////////////////////////// +/// Pause a music +/// +/// \param music : Music to pause +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMusic_Pause(sfMusic* music); + +//////////////////////////////////////////////////////////// +/// Stop playing a music +/// +/// \param music : Music to stop +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMusic_Stop(sfMusic* music); + +//////////////////////////////////////////////////////////// +/// Return the number of channels of a music (1 = mono, 2 = stereo) +/// +/// \param music : Music to get the channels count from +/// +/// \return Number of channels +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfMusic_GetChannelsCount(const sfMusic* music); + +//////////////////////////////////////////////////////////// +/// Get the stream sample rate of a music +/// +/// \param music : Music to get the sample rate from +/// +/// \return Stream frequency (number of samples per second) +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfMusic_GetSampleRate(const sfMusic* music); + +//////////////////////////////////////////////////////////// +/// Get the status of a music (stopped, paused, playing) +/// +/// \param music : Music to get the status from +/// +/// \return Current status of the sound +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSoundStatus sfMusic_GetStatus(const sfMusic* music); + +//////////////////////////////////////////////////////////// +/// Get the current playing position of a music +/// +/// \param music : Music to get the position from +/// +/// \return Current playing position, in milliseconds +/// +//////////////////////////////////////////////////////////// +CSFML_API sfUint32 sfMusic_GetPlayingOffset(const sfMusic* music); + +//////////////////////////////////////////////////////////// +/// Set the pitch of a music +/// +/// \param music : Music to modify +/// \param pitch : New pitch +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMusic_SetPitch(sfMusic* music, float pitch); + +//////////////////////////////////////////////////////////// +/// Set the volume of a music +/// +/// \param music : Music to modify +/// \param volume : Volume (in range [0, 100]) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMusic_SetVolume(sfMusic* music, float volume); + +//////////////////////////////////////////////////////////// +/// Set the position of a music +/// +/// \param music : Music to modify +/// \param x : X position of the sound in the world +/// \param y : Y position of the sound in the world +/// \param z : Z position of the sound in the world +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMusic_SetPosition(sfMusic* music, float x, float y, float z); + +//////////////////////////////////////////////////////////// +/// Make the music's position relative to the listener's +/// position, or absolute. +/// The default value is false (absolute) +/// +/// \param music : Music to modify +/// \param relative : True to set the position relative, false to set it absolute +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMusic_SetRelativeToListener(sfMusic* music, sfBool relative); + +//////////////////////////////////////////////////////////// +/// Set the minimum distance - closer than this distance, +/// the listener will hear the music at its maximum volume. +/// The default minimum distance is 1.0 +/// +/// \param music : Music to modify +/// \param distance : New minimum distance for the music +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMusic_SetMinDistance(sfMusic* music, float distance); + +//////////////////////////////////////////////////////////// +/// Set the attenuation factor - the higher the attenuation, the +/// more the sound will be attenuated with distance from listener. +/// The default attenuation factor 1.0 +/// +/// \param music : Music to modify +/// \param attenuation : New attenuation factor for the sound +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMusic_SetAttenuation(sfMusic* music, float attenuation); + +//////////////////////////////////////////////////////////// +/// Set the current playing position of a music +/// +/// \param music : Music to modify +/// \param timeOffset : New playing position, in milliseconds +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMusic_SetPlayingOffset(sfMusic* music, sfUint32 timeOffset); + +//////////////////////////////////////////////////////////// +/// Get the pitch of a music +/// +/// \param music : Music to get the pitch from +/// +/// \return Pitch value +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfMusic_GetPitch(const sfMusic* music); + +//////////////////////////////////////////////////////////// +/// Get the volume of a music +/// +/// \param music : Music to get the volume from +/// +/// \return Volume value (in range [1, 100]) +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfMusic_GetVolume(const sfMusic* music); + +//////////////////////////////////////////////////////////// +/// Get the position of a music +/// +/// \param music : Music to get the position from +/// \param x : X position of the sound in the world +/// \param y : Y position of the sound in the world +/// \param z : Z position of the sound in the world +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMusic_GetPosition(const sfMusic* music, float* x, float* y, float* z); + +//////////////////////////////////////////////////////////// +/// Tell if the music's position is relative to the listener's +/// position, or if it's absolute +/// +/// \param music : Music to check +/// +/// \return sfTrue if the position is relative, sfFalse if it's absolute +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfMusic_IsRelativeToListener(const sfMusic* music); + +//////////////////////////////////////////////////////////// +/// Get the minimum distance of a music +/// +/// \param music : Music to get the minimum distance from +/// +/// \return Minimum distance for the music +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfMusic_GetMinDistance(const sfMusic* music); + +//////////////////////////////////////////////////////////// +/// Get the attenuation factor of a music +/// +/// \param music : Music to get the attenuation factor from +/// +/// \return Attenuation factor for the a music +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfMusic_GetAttenuation(const sfMusic* music); + + +#endif // SFML_MUSIC_H diff --git a/include/SFML/Audio/Sound.h b/include/SFML/Audio/Sound.h new file mode 100644 index 0000000..ba0ae3d --- /dev/null +++ b/include/SFML/Audio/Sound.h @@ -0,0 +1,278 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SOUND_H +#define SFML_SOUND_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new sound +/// +/// \return A new sfSound object (NULL if failed) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSound* sfSound_Create(void); + +//////////////////////////////////////////////////////////// +/// Copy an existing sound +/// +/// \param sound : Sound to copy +/// +/// \return Copied object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSound* sfSound_Copy(sfSound* sound); + +//////////////////////////////////////////////////////////// +/// Destroy an existing sound +/// +/// \param sound : Sound to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSound_Destroy(sfSound* sound); + +//////////////////////////////////////////////////////////// +/// Start playing a sound +/// +/// \param sound : Sound to play +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSound_Play(sfSound* sound); + +//////////////////////////////////////////////////////////// +/// Pause a sound +/// +/// \param sound : Sound to pause +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSound_Pause(sfSound* sound); + +//////////////////////////////////////////////////////////// +/// Stop playing a sound +/// +/// \param sound : Sound to stop +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSound_Stop(sfSound* sound); + +//////////////////////////////////////////////////////////// +/// Bind a sound buffer to a sound +/// +/// \param sound : Sound to set the loop state +/// \param buffer : Buffer to bind +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSound_SetBuffer(sfSound* sound, const sfSoundBuffer* buffer); + +//////////////////////////////////////////////////////////// +/// Get the sound buffer bound to a sound +/// +/// \param sound : Sound to get the buffer from +/// +/// \return Pointer to the sound's buffer +/// +//////////////////////////////////////////////////////////// +CSFML_API const sfSoundBuffer* sfSound_GetBuffer(const sfSound* sound); + +//////////////////////////////////////////////////////////// +/// Set a sound loop state +/// +/// \param sound : Sound to set the loop state +/// \param loop : sfTrue to play in loop, sfFalse to play once +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSound_SetLoop(sfSound* sound, sfBool loop); + +//////////////////////////////////////////////////////////// +/// Tell whether or not a sound is looping +/// +/// \param sound : Sound to get the loop state from +/// +/// \return sfTrue if the sound is looping, sfFalse otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfSound_GetLoop(const sfSound* sound); + +//////////////////////////////////////////////////////////// +/// Get the status of a sound (stopped, paused, playing) +/// +/// \param sound : Sound to get the status from +/// +/// \return Current status of the sound +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSoundStatus sfSound_GetStatus(const sfSound* sound); + +//////////////////////////////////////////////////////////// +/// Set the pitch of a sound +/// +/// \param sound : Sound to modify +/// \param pitch : New pitch +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSound_SetPitch(sfSound* sound, float pitch); + +//////////////////////////////////////////////////////////// +/// Set the volume of a sound +/// +/// \param sound : Sound to modify +/// \param volume : Volume (in range [0, 100]) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSound_SetVolume(sfSound* sound, float volume); + +//////////////////////////////////////////////////////////// +/// Set the position of a sound +/// +/// \param sound : Sound to modify +/// \param x : X position of the sound in the world +/// \param y : Y position of the sound in the world +/// \param z : Z position of the sound in the world +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSound_SetPosition(sfSound* sound, float x, float y, float z); + +//////////////////////////////////////////////////////////// +/// Make the sound's position relative to the listener's +/// position, or absolute. +/// The default value is false (absolute) +/// +/// \param sound : Sound to modify +/// \param relative : True to set the position relative, false to set it absolute +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSound_SetRelativeToListener(sfSound* sound, sfBool relative); + +//////////////////////////////////////////////////////////// +/// Set the minimum distance - closer than this distance, +/// the listener will hear the sound at its maximum volume. +/// The default minimum distance is 1.0 +/// +/// \param sound : Sound to modify +/// \param distance : New minimum distance for the sound +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSound_SetMinDistance(sfSound* sound, float distance); + +//////////////////////////////////////////////////////////// +/// Set the attenuation factor - the higher the attenuation, the +/// more the sound will be attenuated with distance from listener. +/// The default attenuation factor is 1.0 +/// +/// \param sound : Sound to modify +/// \param attenuation : New attenuation factor for the sound +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSound_SetAttenuation(sfSound* sound, float attenuation); + +//////////////////////////////////////////////////////////// +/// Set the current playing position of a sound +/// +/// \param sound : Sound to modify +/// \param timeOffset : New playing position, in milliseconds +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSound_SetPlayingOffset(sfSound* sound, sfUint32 timeOffset); + +//////////////////////////////////////////////////////////// +/// Get the pitch of a sound +/// +/// \param sound : Sound to get the pitch from +/// +/// \return Pitch value +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSound_GetPitch(const sfSound* sound); + +//////////////////////////////////////////////////////////// +/// Get the volume of a sound +/// +/// \param sound : Sound to get the volume from +/// +/// \return Volume value (in range [1, 100]) +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSound_GetVolume(const sfSound* sound); + +//////////////////////////////////////////////////////////// +/// Get the position of a sound +/// +/// \param sound : Sound to get the position from +/// \param x : X position of the sound in the world +/// \param y : Y position of the sound in the world +/// \param z : Z position of the sound in the world +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSound_GetPosition(const sfSound* sound, float* x, float* y, float* z); + +//////////////////////////////////////////////////////////// +/// Tell if the sound's position is relative to the listener's +/// position, or if it's absolute +/// +/// \param sound : Sound to check +/// +/// \return sfTrue if the position is relative, sfFalse if it's absolute +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfSound_IsRelativeToListener(const sfSound* sound); + +//////////////////////////////////////////////////////////// +/// Get the minimum distance of a sound +/// +/// \param sound : Sound to get the minimum distance from +/// +/// \return Minimum distance for the sound +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSound_GetMinDistance(const sfSound* sound); + +//////////////////////////////////////////////////////////// +/// Get the attenuation factor of a sound +/// +/// \param sound : Sound to get the attenuation factor from +/// +/// \return Attenuation factor for the sound +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSound_GetAttenuation(const sfSound* sound); + +//////////////////////////////////////////////////////////// +/// Get the current playing position of a sound +/// +/// \param sound : Sound to get the position from +/// +/// \return Current playing position, in milliseconds +/// +//////////////////////////////////////////////////////////// +CSFML_API sfUint32 sfSound_GetPlayingOffset(const sfSound* sound); + + +#endif // SFML_SOUND_H diff --git a/include/SFML/Audio/SoundBuffer.h b/include/SFML/Audio/SoundBuffer.h new file mode 100644 index 0000000..b0f2a6a --- /dev/null +++ b/include/SFML/Audio/SoundBuffer.h @@ -0,0 +1,151 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SOUNDBUFFER_H +#define SFML_SOUNDBUFFER_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new sound buffer and load it from a file +/// +/// \param filename : Path of the music file to open +/// +/// \return A new sfSoundBuffer object (NULL if failed) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromFile(const char* filename); + +//////////////////////////////////////////////////////////// +/// Create a new sound buffer and load it from a file in memory +/// +/// \param data : Pointer to the file data in memory +/// \param sizeInBytes : Size of the data to load, in bytes +/// +/// \return A new sfSoundBuffer object (NULL if failed) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromMemory(const void* data, size_t sizeInBytes); + +//////////////////////////////////////////////////////////// +/// Create a new sound buffer and load it from an array of +/// samples in memory - assumed format for samples is +/// 16 bits signed integer +/// +/// \param samples : Pointer to the samples in memory +/// \param samplesCount : Number of samples pointed by Samples +/// \param channelsCount : Number of channels (1 = mono, 2 = stereo, ...) +/// \param sampleRate : Frequency (number of samples to play per second) +/// +/// \return A new sfSoundBuffer object (NULL if failed) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromSamples(const sfInt16* samples, size_t samplesCount, unsigned int channelsCount, unsigned int sampleRate); + +//////////////////////////////////////////////////////////// +/// Copy an existing sound buffer +/// +/// \param soundBuffer : Sound buffer to copy +/// +/// \return Copied object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSoundBuffer* sfSoundBuffer_Copy(sfSoundBuffer* soundBuffer); + +//////////////////////////////////////////////////////////// +/// Destroy an existing sound buffer +/// +/// \param soundBuffer : Sound buffer to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundBuffer_Destroy(sfSoundBuffer* soundBuffer); + +//////////////////////////////////////////////////////////// +/// Save a sound buffer to a file +/// +/// \param soundBuffer : Sound buffer to save +/// \param filename : Path of the sound file to write +/// +/// \return sfTrue if saving has been successful +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfSoundBuffer_SaveToFile(const sfSoundBuffer* soundBuffer, const char* filename); + +//////////////////////////////////////////////////////////// +/// Return the samples contained in a sound buffer +/// +/// \param soundBuffer : Sound buffer to get samples from +/// +/// \return Pointer to the array of sound samples, in 16 bits signed integer format +/// +//////////////////////////////////////////////////////////// +CSFML_API const sfInt16* sfSoundBuffer_GetSamples(const sfSoundBuffer* soundBuffer); + +//////////////////////////////////////////////////////////// +/// Return the number of samples contained in a sound buffer +/// +/// \param soundBuffer : Sound buffer to get samples count from +/// +/// \return Number of samples +/// +//////////////////////////////////////////////////////////// +CSFML_API size_t sfSoundBuffer_GetSamplesCount(const sfSoundBuffer* soundBuffer); + +//////////////////////////////////////////////////////////// +/// Get the sample rate of a sound buffer +/// +/// \param soundBuffer : Sound buffer to get sample rate from +/// +/// \return Sound frequency (number of samples per second) +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfSoundBuffer_GetSampleRate(const sfSoundBuffer* soundBuffer); + +//////////////////////////////////////////////////////////// +/// Return the number of channels of a sound buffer (1 = mono, 2 = stereo, ...) +/// +/// \param soundBuffer : Sound buffer to get channels count from +/// +/// \return Number of channels +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfSoundBuffer_GetChannelsCount(const sfSoundBuffer* soundBuffer); + +//////////////////////////////////////////////////////////// +/// Get the duration of a sound buffer +/// +/// \param soundBuffer : Sound buffer to get duration from +/// +/// \return Sound duration, in milliseconds +/// +//////////////////////////////////////////////////////////// +CSFML_API sfUint32 sfSoundBuffer_GetDuration(const sfSoundBuffer* soundBuffer); + + +#endif // SFML_SOUNDBUFFER_H diff --git a/include/SFML/Audio/SoundBufferRecorder.h b/include/SFML/Audio/SoundBufferRecorder.h new file mode 100644 index 0000000..df03672 --- /dev/null +++ b/include/SFML/Audio/SoundBufferRecorder.h @@ -0,0 +1,91 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SOUNDBUFFERRECORDER_H +#define SFML_SOUNDBUFFERRECORDER_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new sound buffer recorder +/// +/// \return A new sfSoundBufferRecorder object (NULL if failed) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSoundBufferRecorder* sfSoundBufferRecorder_Create(void); + +//////////////////////////////////////////////////////////// +/// Destroy an existing sound buffer recorder +/// +/// \param soundBufferRecorder : Sound buffer recorder to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundBufferRecorder_Destroy(sfSoundBufferRecorder* soundBufferRecorder); + +//////////////////////////////////////////////////////////// +/// Start the capture. +/// Warning : only one capture can happen at the same time +/// +/// \param soundBufferRecorder : Sound buffer recorder to start +/// \param sampleRate : Sound frequency (the more samples, the higher the quality) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundBufferRecorder_Start(sfSoundBufferRecorder* soundBufferRecorder, unsigned int sampleRate); + +//////////////////////////////////////////////////////////// +/// Stop the capture +/// +/// \param soundBufferRecorder : Sound buffer recorder to stop +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundBufferRecorder_Stop(sfSoundBufferRecorder* soundBufferRecorder); + +//////////////////////////////////////////////////////////// +/// Get the sample rate of a sound buffer recorder +/// +/// \param soundBufferRecorder : Sound buffer recorder to get sample rate from +/// +/// \return Frequency, in samples per second +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfSoundBufferRecorder_GetSampleRate(const sfSoundBufferRecorder* soundBufferRecorder); + +//////////////////////////////////////////////////////////// +/// Get the sound buffer containing the captured audio data +/// of a sound buffer recorder +/// +/// \param soundBufferRecorder : Sound buffer recorder to get the sound buffer from +/// +/// \return Pointer to the sound buffer (you don't need to destroy it after use) +/// +//////////////////////////////////////////////////////////// +CSFML_API const sfSoundBuffer* sfSoundBufferRecorder_GetBuffer(const sfSoundBufferRecorder* soundBufferRecorder); + + +#endif // SFML_SOUNDBUFFERRECORDER_H diff --git a/include/SFML/Audio/SoundRecorder.h b/include/SFML/Audio/SoundRecorder.h new file mode 100644 index 0000000..b555c63 --- /dev/null +++ b/include/SFML/Audio/SoundRecorder.h @@ -0,0 +1,103 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SOUNDRECORDER_H +#define SFML_SOUNDRECORDER_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +typedef sfBool (*sfSoundRecorderStartCallback)(void*); ///< Type of the callback used when starting a capture +typedef sfBool (*sfSoundRecorderProcessCallback)(const sfInt16*, size_t, void*); ///< Type of the callback used to process audio data +typedef void (*sfSoundRecorderStopCallback)(void*); ///< Type of the callback used when stopping a capture + + +//////////////////////////////////////////////////////////// +/// Construct a new sound recorder with callback functions +/// for processing captured samples +/// +/// \param onStart : Callback function which will be called when a new capture starts (can be NULL) +/// \param onProcess : Callback function which will be called each time there's audio data to process +/// \param onStop : Callback function which will be called when the current capture stops (can be NULL) +/// \param userData : Data to pass to the callback function (can be NULL) +/// +/// \return A new sfSoundRecorder object (NULL if failed) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSoundRecorder* sfSoundRecorder_Create(sfSoundRecorderStartCallback onStart, + sfSoundRecorderProcessCallback onProcess, + sfSoundRecorderStopCallback onStop, + void* userData); + +//////////////////////////////////////////////////////////// +/// Destroy an existing sound recorder +/// +/// \param soundRecorder : Sound recorder to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundRecorder_Destroy(sfSoundRecorder* soundRecorder); + +//////////////////////////////////////////////////////////// +/// Start the capture. +/// Warning : only one capture can happen at the same time +/// +/// \param soundRecorder : Sound recorder to start +/// \param sampleRate : Sound frequency (the more samples, the higher the quality) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundRecorder_Start(sfSoundRecorder* soundRecorder, unsigned int sampleRate); + +//////////////////////////////////////////////////////////// +/// Stop the capture +/// +/// \param soundRecorder : Sound recorder to stop +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundRecorder_Stop(sfSoundRecorder* soundRecorder); + +//////////////////////////////////////////////////////////// +/// Get the sample rate of a sound recorder +/// +/// \param soundRecorder : Sound recorder to get sample rate from +/// +/// \return Frequency, in samples per second +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfSoundRecorder_GetSampleRate(const sfSoundRecorder* soundRecorder); + +//////////////////////////////////////////////////////////// +/// Tell if the system supports sound capture. +/// If not, this class won't be usable +/// +/// \return sfTrue if audio capture is supported +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfSoundRecorder_IsAvailable(void); + + +#endif // SFML_SOUNDRECORDER_H diff --git a/include/SFML/Audio/SoundStatus.h b/include/SFML/Audio/SoundStatus.h new file mode 100644 index 0000000..18cbf28 --- /dev/null +++ b/include/SFML/Audio/SoundStatus.h @@ -0,0 +1,42 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SOUNDSTATUS_H +#define SFML_SOUNDSTATUS_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +typedef enum +{ + sfStopped, ///< Sound / music is not playing + sfPaused, ///< Sound / music is paused + sfPlaying ///< Sound / music is playing +} sfSoundStatus; + + +#endif // SFML_SOUNDSTATUS_H diff --git a/include/SFML/Audio/SoundStream.h b/include/SFML/Audio/SoundStream.h new file mode 100644 index 0000000..a1c199e --- /dev/null +++ b/include/SFML/Audio/SoundStream.h @@ -0,0 +1,294 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SOUNDSTREAM_H +#define SFML_SOUNDSTREAM_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// sfSoundStreamChunk defines the data to fill by the +/// OnGetData callback +//////////////////////////////////////////////////////////// +typedef struct +{ + sfInt16* Samples; ///< Pointer to the audio samples + unsigned int NbSamples; ///< Number of samples pointed by Samples +} sfSoundStreamChunk; + +typedef sfBool (*sfSoundStreamGetDataCallback)(sfSoundStreamChunk*, void*); ///< Type of the callback used to get a sound stream data +typedef void (*sfSoundStreamSeekCallback)(sfUint32, void*); ///< Type of the callback used to seek in a sound stream + + +//////////////////////////////////////////////////////////// +/// Construct a new sound stream +/// +/// \param onGetData : Function called when the stream needs more data (can't be NULL) +/// \param onSeek : Function called when the stream seeks (can't be NULL) +/// \param channelsCount : Number of channels to use (1 = mono, 2 = stereo) +/// \param sampleRate : Sample rate of the sound (44100 = CD quality) +/// \param userData : Data to pass to the callback functions +/// +/// \return A new sfSoundStream object (NULL if failed) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSoundStream* sfSoundStream_Create(sfSoundStreamGetDataCallback onGetData, + sfSoundStreamSeekCallback onSeek, + unsigned int channelsCount, + unsigned int sampleRate, + void* userData); + +//////////////////////////////////////////////////////////// +/// Destroy an existing sound stream +/// +/// \param soundStream : Sound stream to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundStream_Destroy(sfSoundStream* soundStream); + +//////////////////////////////////////////////////////////// +/// Start playing a sound stream +/// +/// \param soundStream : Sound stream to play +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundStream_Play(sfSoundStream* soundStream); + +//////////////////////////////////////////////////////////// +/// Pause a sound stream +/// +/// \param soundStream : Sound stream to pause +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundStream_Pause(sfSoundStream* soundStream); + +//////////////////////////////////////////////////////////// +/// Stop playing a sound stream +/// +/// \param soundStream : Sound stream to stop +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundStream_Stop(sfSoundStream* soundStream); + +//////////////////////////////////////////////////////////// +/// Get the status of a sound stream (stopped, paused, playing) +/// +/// \param soundStream : Sound stream to get the status from +/// +/// \return Current status of the sound stream +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSoundStatus sfSoundStream_GetStatus(const sfSoundStream* soundStream); + +//////////////////////////////////////////////////////////// +/// Return the number of channels of a sound stream +/// (1 = mono, 2 = stereo) +/// +/// \param soundStream : Sound stream to get the channels count from +/// +/// \return Number of channels +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfSoundStream_GetChannelsCount(const sfSoundStream* soundStream); + +//////////////////////////////////////////////////////////// +/// Get the sample rate of a sound stream +/// +/// \param soundStream : Sound stream to get the sample rate from +/// +/// \return Stream frequency (number of samples per second) +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfSoundStream_GetSampleRate(const sfSoundStream* soundStream); + +//////////////////////////////////////////////////////////// +/// Set the pitch of a sound stream +/// +/// \param soundStream : Sound stream to modify +/// \param pitch : New pitch +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundStream_SetPitch(sfSoundStream* soundStream, float pitch); + +//////////////////////////////////////////////////////////// +/// Set the volume of a sound stream +/// +/// \param soundStream : Sound stream to modify +/// \param volume : Volume (in range [0, 100]) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundStream_SetVolume(sfSoundStream* soundStream, float volume); + +//////////////////////////////////////////////////////////// +/// Set the position of a sound stream +/// +/// \param soundStream : Sound stream to modify +/// \param x : X position of the sound stream in the world +/// \param y : Y position of the sound stream in the world +/// \param z : Z position of the sound stream in the world +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundStream_SetPosition(sfSoundStream* soundStream, float x, float y, float z); + +//////////////////////////////////////////////////////////// +/// Make the sound stream's position relative to the listener's +/// position, or absolute. +/// The default value is false (absolute) +/// +/// \param soundStream : Sound stream to modify +/// \param relative : True to set the position relative, false to set it absolute +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundStream_SetRelativeToListener(sfSoundStream* soundStream, sfBool relative); + +//////////////////////////////////////////////////////////// +/// Set the minimum distance - closer than this distance, +/// the listener will hear the sound stream at its maximum volume. +/// The default minimum distance is 1.0 +/// +/// \param soundStream : Sound stream to modify +/// \param distance : New minimum distance for the sound stream +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundStream_SetMinDistance(sfSoundStream* soundStream, float distance); + +//////////////////////////////////////////////////////////// +/// Set the attenuation factor - the higher the attenuation, the +/// more the sound stream will be attenuated with distance from listener. +/// The default attenuation factor 1.0 +/// +/// \param soundStream : Sound stream to modify +/// \param attenuation : New attenuation factor for the sound stream +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundStream_SetAttenuation(sfSoundStream* soundStream, float attenuation); + +//////////////////////////////////////////////////////////// +/// Set the current playing position of a stream +/// +/// \param soundStream : Sound stream to modify +/// \param timeOffset : New playing position, in milliseconds +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundStream_SetPlayingOffset(sfSoundStream* soundStream, sfUint32 timeOffset); + +//////////////////////////////////////////////////////////// +/// Set a stream loop state +/// +/// \param soundStream : Stream to set the loop state +/// \param loop : sfTrue to play in loop, sfFalse to play once +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundStream_SetLoop(sfSoundStream* soundStream, sfBool loop); + +//////////////////////////////////////////////////////////// +/// Get the pitch of a sound stream +/// +/// \param soundStream : Sound stream to get the pitch from +/// +/// \return Pitch value +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSoundStream_GetPitch(const sfSoundStream* soundStream); + +//////////////////////////////////////////////////////////// +/// Get the volume of a sound stream +/// +/// \param soundStream : Sound stream to get the volume from +/// +/// \return Volume value (in range [1, 100]) +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSoundStream_GetVolume(const sfSoundStream* soundStream); + +//////////////////////////////////////////////////////////// +/// Get the position of a sound stream +/// +/// \param soundStream : Sound stream to get the position from +/// \param x : X position of the sound stream in the world +/// \param y : Y position of the sound stream in the world +/// \param z : Z position of the sound stream in the world +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundStream_GetPosition(const sfSoundStream* soundStream, float* x, float* y, float* z); + +//////////////////////////////////////////////////////////// +/// Tell if the sound stream's position is relative to the listener's +/// position, or if it's absolute +/// +/// \param soundStream : Sound stream to check +/// +/// \return sfTrue if the position is relative, sfFalse if it's absolute +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfSoundStream_IsRelativeToListener(const sfSoundStream* soundStream); + +//////////////////////////////////////////////////////////// +/// Get the minimum distance of a sound stream +/// +/// \param soundStream : Sound stream to get the minimum distance from +/// +/// \return Minimum distance for the sound stream +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSoundStream_GetMinDistance(const sfSoundStream* soundStream); + +//////////////////////////////////////////////////////////// +/// Get the attenuation factor of a sound stream +/// +/// \param soundStream : Sound stream to get the attenuation factor from +/// +/// \return Attenuation factor for the sound stream +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSoundStream_GetAttenuation(const sfSoundStream* soundStream); + +//////////////////////////////////////////////////////////// +/// Tell whether or not a stream is looping +/// +/// \param soundStream : Soundstream to get the loop state from +/// +/// \return sfTrue if the stream is looping, sfFalse otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfSoundStream_GetLoop(const sfSoundStream* soundStream); + +//////////////////////////////////////////////////////////// +/// Get the current playing position of a sound stream +/// +/// \param soundStream : Sound stream to get the position from +/// +/// \return Current playing position, in milliseconds +/// +//////////////////////////////////////////////////////////// +CSFML_API sfUint32 sfSoundStream_GetPlayingOffset(const sfSoundStream* soundStream); + + +#endif // SFML_SOUNDSTREAM_H diff --git a/include/SFML/Audio/Types.h b/include/SFML/Audio/Types.h new file mode 100644 index 0000000..d24e559 --- /dev/null +++ b/include/SFML/Audio/Types.h @@ -0,0 +1,36 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_AUDIO_TYPES_H +#define SFML_AUDIO_TYPES_H + + +typedef struct sfMusic sfMusic; +typedef struct sfSound sfSound; +typedef struct sfSoundBuffer sfSoundBuffer; +typedef struct sfSoundBufferRecorder sfSoundBufferRecorder; +typedef struct sfSoundRecorder sfSoundRecorder; +typedef struct sfSoundStream sfSoundStream; + + +#endif // SFML_AUDIO_TYPES_H diff --git a/include/SFML/Config.h b/include/SFML/Config.h new file mode 100644 index 0000000..8e8f945 --- /dev/null +++ b/include/SFML/Config.h @@ -0,0 +1,150 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_CONFIG_H +#define SFML_CONFIG_H + + +//////////////////////////////////////////////////////////// +// Define the CSFML version +//////////////////////////////////////////////////////////// +#define CSFML_VERSION_MAJOR 2 +#define CSFML_VERSION_MINOR 0 + + +//////////////////////////////////////////////////////////// +// Identify the operating system +//////////////////////////////////////////////////////////// +#if defined(_WIN32) || defined(__WIN32__) + + // Windows + #define CSFML_SYSTEM_WINDOWS + +#elif defined(linux) || defined(__linux) + + // Linux + #define CSFML_SYSTEM_LINUX + +#elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh) + + // MacOS + #define CSFML_SYSTEM_MACOS + +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + + // FreeBSD + #define CSFML_SYSTEM_FREEBSD + +#else + + // Unsupported system + #error This operating system is not supported by SFML library + +#endif + + +//////////////////////////////////////////////////////////// +// Define portable import / export macros +//////////////////////////////////////////////////////////// +#if defined(CSFML_SYSTEM_WINDOWS) + + #ifdef CSFML_EXPORTS + + // From DLL side, we must export + #define CSFML_API extern "C" __declspec(dllexport) + + #else + + // From client application side, we must import + #define CSFML_API extern __declspec(dllimport) + + #endif + +#else + + #ifdef CSFML_EXPORTS + + #define CSFML_API extern "C" + + #else + + #define CSFML_API extern + + #endif + +#endif + + +//////////////////////////////////////////////////////////// +// Define a portable boolean type +//////////////////////////////////////////////////////////// +typedef int sfBool; +#define sfFalse 0 +#define sfTrue 1 + + +//////////////////////////////////////////////////////////// +// Define portable types +//////////////////////////////////////////////////////////// +#include +#include + +// 8 bits integer types +#if UCHAR_MAX == 0xFF + typedef signed char sfInt8; + typedef unsigned char sfUint8; +#else + #error No 8 bits integer type for this platform +#endif + +// 16 bits integer types +#if USHRT_MAX == 0xFFFF + typedef signed short sfInt16; + typedef unsigned short sfUint16; +#elif UINT_MAX == 0xFFFF + typedef signed int sfInt16; + typedef unsigned int sfUint16; +#elif ULONG_MAX == 0xFFFF + typedef signed long sfInt16; + typedef unsigned long sfUint16; +#else + #error No 16 bits integer type for this platform +#endif + +// 32 bits integer types +#if USHRT_MAX == 0xFFFFFFFF + typedef signed short sfInt32; + typedef unsigned short sfUint32; +#elif UINT_MAX == 0xFFFFFFFF + typedef signed int sfInt32; + typedef unsigned int sfUint32; +#elif ULONG_MAX == 0xFFFFFFFF + typedef signed long sfInt32; + typedef unsigned long sfUint32; +#else + #error No 32 bits integer type for this platform +#endif + + +#endif // SFML_CONFIG_H diff --git a/include/SFML/Graphics.h b/include/SFML/Graphics.h new file mode 100644 index 0000000..c0f2b1a --- /dev/null +++ b/include/SFML/Graphics.h @@ -0,0 +1,46 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_GRAPHICS_H +#define SFML_GRAPHICS_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#endif // SFML_GRAPHICS_H diff --git a/include/SFML/Graphics/BlendMode.h b/include/SFML/Graphics/BlendMode.h new file mode 100644 index 0000000..9c9e5ce --- /dev/null +++ b/include/SFML/Graphics/BlendMode.h @@ -0,0 +1,46 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_BLENDMODE_H +#define SFML_BLENDMODE_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// Enumerate the blending modes for drawable objects +//////////////////////////////////////////////////////////// +typedef enum +{ + sfBlendAlpha, ///< Pixel = Src * a + Dest * (1 - a) + sfBlendAdd, ///< Pixel = Src + Dest + sfBlendMultiply, ///< Pixel = Src * Dest + sfBlendNone ///< No blending +} sfBlendMode; + + +#endif // SFML_BLENDMODE_H diff --git a/include/SFML/Graphics/Color.h b/include/SFML/Graphics/Color.h new file mode 100644 index 0000000..3b905c8 --- /dev/null +++ b/include/SFML/Graphics/Color.h @@ -0,0 +1,107 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_COLOR_H +#define SFML_COLOR_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// sfColor is an utility class for manipulating colors +//////////////////////////////////////////////////////////// +typedef struct +{ + sfUint8 r; + sfUint8 g; + sfUint8 b; + sfUint8 a; +} sfColor; + + +//////////////////////////////////////////////////////////// +/// Define some common colors +//////////////////////////////////////////////////////////// +CSFML_API sfColor sfBlack; +CSFML_API sfColor sfWhite; +CSFML_API sfColor sfRed; +CSFML_API sfColor sfGreen; +CSFML_API sfColor sfBlue; +CSFML_API sfColor sfYellow; +CSFML_API sfColor sfMagenta; +CSFML_API sfColor sfCyan; + + +//////////////////////////////////////////////////////////// +/// Construct a color from its 3 RGB components +/// +/// \param red : Red component (0 .. 255) +/// \param green : Green component (0 .. 255) +/// \param blue : Blue component (0 .. 255) +/// +/// \return sfColor constructed from the components +/// +//////////////////////////////////////////////////////////// +CSFML_API sfColor sfColor_FromRGB(sfUint8 red, sfUint8 green, sfUint8 blue); + +//////////////////////////////////////////////////////////// +/// Construct a color from its 4 RGBA components +/// +/// \param red : Red component (0 .. 255) +/// \param green : Green component (0 .. 255) +/// \param blue : Blue component (0 .. 255) +/// \param alpha : Alpha component (0 .. 255) +/// +/// \return sfColor constructed from the components +/// +//////////////////////////////////////////////////////////// +CSFML_API sfColor sfColor_FromRGBA(sfUint8 red, sfUint8 green, sfUint8 blue, sfUint8 alpha); + +//////////////////////////////////////////////////////////// +/// Add two colors +/// +/// \param color1 : First color +/// \param color2 : Second color +/// +/// \return Component-wise saturated addition of the two colors +/// +//////////////////////////////////////////////////////////// +CSFML_API sfColor sfColor_Add(sfColor color1, sfColor color2); + +//////////////////////////////////////////////////////////// +/// Modulate two colors +/// +/// \param color1 : First color +/// \param color2 : Second color +/// +/// \return Component-wise multiplication of the two colors +/// +//////////////////////////////////////////////////////////// +CSFML_API sfColor sfColor_Modulate(sfColor color1, sfColor color2); + + +#endif // SFML_COLOR_H diff --git a/include/SFML/Graphics/Font.h b/include/SFML/Graphics/Font.h new file mode 100644 index 0000000..a946019 --- /dev/null +++ b/include/SFML/Graphics/Font.h @@ -0,0 +1,132 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_FONT_H +#define SFML_FONT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new font from a file +/// +/// \param filename : Path of the font file to load +/// +/// \return A new sfFont object, or NULL if it failed +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFont* sfFont_CreateFromFile(const char* filename); + +//////////////////////////////////////////////////////////// +/// Create a new image font a file in memory +/// +/// \param data : Pointer to the file data in memory +/// \param sizeInBytes : Size of the data to load, in bytes +/// +/// \return A new sfFont object, or NULL if it failed +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFont* sfFont_CreateFromMemory(const void* data, size_t sizeInBytes); + +//////////////////////////////////////////////////////////// +/// Copy an existing font +/// +/// \param font : Font to copy +/// +/// \return Copied object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFont* sfFont_Copy(sfFont* font); + +//////////////////////////////////////////////////////////// +/// Destroy an existing font +/// +/// \param font : Font to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfFont_Destroy(sfFont* font); + +//////////////////////////////////////////////////////////// +/// Get a glyph in a font +/// +/// \param font : Source font +/// \param codePoint : Unicode code point of the character to get +/// \param characterSize : Character size, in pixels +/// \param bold Retrieve the bold version or the regular one? +/// +/// \return The corresponding glyph +/// +//////////////////////////////////////////////////////////// +CSFML_API sfGlyph sfFont_GetGlyph(sfFont* font, sfUint32 codePoint, unsigned int characterSize, sfBool bold); + +//////////////////////////////////////////////////////////// +/// Get the kerning value corresponding to a given pair of characters in a font +/// +/// \param font : Source font +/// \param first : Unicode code point of the first character +/// \param second : Unicode code point of the second character +/// \param characterSize : Character size, in pixels +/// +/// \return Kerning offset, in pixels +/// +//////////////////////////////////////////////////////////// +CSFML_API int sfFont_GetKerning(sfFont* font, sfUint32 first, sfUint32 second, unsigned int characterSize); + +//////////////////////////////////////////////////////////// +/// Get the line spacing value +/// +/// \param font : Source font +/// \param codePoint : Unicode code point of the character to get +/// \param characterSize : Character size, in pixels +/// +/// \return Line spacing, in pixels +/// +//////////////////////////////////////////////////////////// +CSFML_API int sfFont_GetLineSpacing(sfFont* font, unsigned int characterSize); + +//////////////////////////////////////////////////////////// +/// Get the image containing the glyphs of a given size in a font +/// +/// \param font : Source font +/// \param characterSize : Character size, in pixels +/// +/// \return Read-only pointer to the image +/// +//////////////////////////////////////////////////////////// +CSFML_API const sfImage* sfFont_GetImage(sfFont* font, unsigned int characterSize); + +//////////////////////////////////////////////////////////// +/// Get the built-in default font (Arial) +/// +/// \return Pointer to the default font +/// +//////////////////////////////////////////////////////////// +CSFML_API const sfFont* sfFont_GetDefaultFont(void); + + +#endif // SFML_IMAGE_H diff --git a/include/SFML/Graphics/Glyph.h b/include/SFML/Graphics/Glyph.h new file mode 100644 index 0000000..9a556b7 --- /dev/null +++ b/include/SFML/Graphics/Glyph.h @@ -0,0 +1,45 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_GLYPH_H +#define SFML_GLYPH_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// sfGlyph describes a glyph (a visual character) +//////////////////////////////////////////////////////////// +typedef struct +{ + int Advance; ///< Offset to move horizontically to the next character + sfIntRect Bounds; ///< Bounding rectangle of the glyph, in coordinates relative to the baseline + sfIntRect SubRect; ///< Texture coordinates of the glyph inside the font's image +} sfGlyph; + + +#endif // SFML_GLYPH_H diff --git a/include/SFML/Graphics/Image.h b/include/SFML/Graphics/Image.h new file mode 100644 index 0000000..a323474 --- /dev/null +++ b/include/SFML/Graphics/Image.h @@ -0,0 +1,246 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_IMAGE_H +#define SFML_IMAGE_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new image filled with a color +/// +/// \param width : Image width +/// \param height : Image height +/// \param color : Image color +/// +/// \return A new sfImage object, or NULL if it failed +/// +//////////////////////////////////////////////////////////// +CSFML_API sfImage* sfImage_CreateFromColor(unsigned int width, unsigned int height, sfColor color); + +//////////////////////////////////////////////////////////// +/// Create a new image from an array of pixels in memory +/// +/// \param width : Image width +/// \param height : Image height +/// \param data : Pointer to the pixels in memory (assumed format is RGBA) +/// +/// \return A new sfImage object, or NULL if it failed +/// +//////////////////////////////////////////////////////////// +CSFML_API sfImage* sfImage_CreateFromPixels(unsigned int width, unsigned int height, const sfUint8* data); + +//////////////////////////////////////////////////////////// +/// Create a new image from a file +/// +/// \param filename : Path of the image file to load +/// +/// \return A new sfImage object, or NULL if it failed +/// +//////////////////////////////////////////////////////////// +CSFML_API sfImage* sfImage_CreateFromFile(const char* filename); + +//////////////////////////////////////////////////////////// +/// Create a new image from a file in memory +/// +/// \param data : Pointer to the file data in memory +/// \param sizeInBytes : Size of the data to load, in bytes +/// +/// \return A new sfImage object, or NULL if it failed +/// +//////////////////////////////////////////////////////////// +CSFML_API sfImage* sfImage_CreateFromMemory(const void* data, size_t sizeInBytes); + +//////////////////////////////////////////////////////////// +/// Copy an existing image +/// +/// \param image : Image to copy +/// +/// \return Copied object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfImage* sfImage_Copy(sfImage* image); + +//////////////////////////////////////////////////////////// +/// Destroy an existing image +/// +/// \param image : Image to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfImage_Destroy(sfImage* image); + +//////////////////////////////////////////////////////////// +/// Save the content of an image to a file +/// +/// \param image : Image to save +/// \param filename : Path of the file to save (overwritten if already exist) +/// +/// \return sfTrue if saving was successful +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfImage_SaveToFile(const sfImage* image, const char* filename); + +//////////////////////////////////////////////////////////// +/// Create a transparency mask for an image from a specified colorkey +/// +/// \param image : Image to modify +/// \param colorKey : Color to become transparent +/// \param alpha : Alpha value to use for transparent pixels +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfImage_CreateMaskFromColor(sfImage* image, sfColor colorKey, sfUint8 alpha); + +//////////////////////////////////////////////////////////// +/// Copy pixels from another image onto this one. +/// This function does a slow pixel copy and should only +/// be used at initialization time +/// +/// \param image : Destination image +/// \param source : Source image to copy +/// \param destX : X coordinate of the destination position +/// \param destY : Y coordinate of the destination position +/// \param sourceRect : Sub-rectangle of the source image to copy +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfImage_CopyImage(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect); + +//////////////////////////////////////////////////////////// +/// Create the image from the current contents of the +/// given window +/// +/// \param image : Destination image +/// \param window : Window to capture +/// \param sourceRect : Sub-rectangle of the screen to copy (empty by default - entire image) +/// +/// \return True if creation was successful +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfImage_CopyScreen(sfImage* image, sfRenderWindow* window, sfIntRect sourceRect); + +//////////////////////////////////////////////////////////// +/// Change the color of a pixel of an image +/// +/// \param image : Image to modify +/// \param x : X coordinate of pixel in the image +/// \param y : Y coordinate of pixel in the image +/// \param color : New color for pixel (X, Y) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfImage_SetPixel(sfImage* image, unsigned int x, unsigned int y, sfColor color); + +//////////////////////////////////////////////////////////// +/// Get a pixel from an image +/// +/// \param image : Image to read +/// \param x : X coordinate of pixel in the image +/// \param y : Y coordinate of pixel in the image +/// +/// \return Color of pixel (x, y) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfColor sfImage_GetPixel(const sfImage* image, unsigned int x, unsigned int y); + +//////////////////////////////////////////////////////////// +/// Get a read-only pointer to the array of pixels of an image (8 bits integers RGBA) +/// Array size is sfImage_GetWidth(img) x sfImage_GetHeight(img) x 4 +/// This pointer becomes invalid if you reload or resize the image +/// +/// \param image : Image to read +/// +/// \return Pointer to the array of pixels +/// +//////////////////////////////////////////////////////////// +CSFML_API const sfUint8* sfImage_GetPixelsPtr(const sfImage* image); + +//////////////////////////////////////////////////////////// +/// Update a sub-rectangle of the image from an array of pixels +/// +/// Warning: for performances reasons, this function doesn't +/// perform any check; thus you're responsible of ensuring that +/// \a rectangle does not exceed the image size, and that +/// \a pixels contains enough elements. +/// +/// \param image : Image to update +/// \param rectangle : Sub-rectangle of the image to update +/// \param pixels : Array of pixels to write to the image +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfImage_UpdatePixels(const sfImage* image, const sfUint8* pixels, sfIntRect rectangle); + +//////////////////////////////////////////////////////////// +/// Bind the image for rendering +/// +/// \param image : Image to bind +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfImage_Bind(const sfImage* image); + +//////////////////////////////////////////////////////////// +/// Enable or disable image smooth filter +/// +/// \param image : Image to modify +/// \param smooth : sfTrue to enable smoothing filter, false to disable it +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfImage_SetSmooth(sfImage* image, sfBool smooth); + +//////////////////////////////////////////////////////////// +/// Return the width of the image +/// +/// \param image : Image to read +/// +/// \return Width in pixels +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfImage_GetWidth(const sfImage* image); + +//////////////////////////////////////////////////////////// +/// Return the height of the image +/// +/// \param image : Image to read +/// +/// \return Height in pixels +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfImage_GetHeight(const sfImage* image); + +//////////////////////////////////////////////////////////// +/// Tells whether the smoothing filter is enabled or not on an image +/// +/// \param image : Image to read +/// +/// \return sfTrue if the smoothing filter is enabled +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfImage_IsSmooth(const sfImage* image); + + +#endif // SFML_IMAGE_H diff --git a/include/SFML/Graphics/Rect.h b/include/SFML/Graphics/Rect.h new file mode 100644 index 0000000..b9a3a31 --- /dev/null +++ b/include/SFML/Graphics/Rect.h @@ -0,0 +1,81 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_RECT_H +#define SFML_RECT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// sfFloatRect and sfIntRect are utility classes for +/// manipulating rectangles. +//////////////////////////////////////////////////////////// +typedef struct +{ + float Left; + float Top; + float Width; + float Height; +} sfFloatRect; + +typedef struct +{ + int Left; + int Top; + int Width; + int Height; +} sfIntRect; + +//////////////////////////////////////////////////////////// +/// Check if a point is inside a rectangle's area +/// +/// \param rect : Rectangle to test +/// \param x : X coordinate of the point to test +/// \param y : Y coordinate of the point to test +/// +/// \return sfTrue if the point is inside +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfFloatRect_Contains(const sfFloatRect* rect, float x, float y); +CSFML_API sfBool sfIntRect_Contains(const sfIntRect* rect, int x, int y); + +//////////////////////////////////////////////////////////// +/// Check intersection between two rectangles +/// +/// \param rect1 : First rectangle to test +/// \param rect2 : Second rectangle to test +/// \param intersection : Rectangle to be filled with overlapping rect (can be NULL) +/// +/// \return sfTrue if rectangles overlap +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfFloatRect_Intersects(const sfFloatRect* rect1, const sfFloatRect* rect2, sfFloatRect* intersection); +CSFML_API sfBool sfIntRect_Intersects(const sfIntRect* rect1, const sfIntRect* rect2, sfIntRect* intersection); + + +#endif // SFML_RECT_H diff --git a/include/SFML/Graphics/RenderImage.h b/include/SFML/Graphics/RenderImage.h new file mode 100644 index 0000000..06a20c0 --- /dev/null +++ b/include/SFML/Graphics/RenderImage.h @@ -0,0 +1,206 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_RENDERIMAGE_H +#define SFML_RENDERIMAGE_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new renderimage +/// +/// \param width : Width of the renderimage +/// \param height : Height of the renderimage +/// \param depthBuffer : Do you want a depth-buffer attached? (useful only if you're doing 3D OpenGL on the renderimage) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfRenderImage* sfRenderImage_Create(unsigned int width, unsigned int height, sfBool depthBuffer); + +//////////////////////////////////////////////////////////// +/// Destroy an existing renderimage +/// +/// \param renderImage : renderimage to destroy +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderImage_Destroy(sfRenderImage* renderImage); + +//////////////////////////////////////////////////////////// +/// Get the width of the rendering region of a renderimage +/// +/// \param renderImage : Renderimage object +/// +/// \return Width in pixels +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfRenderImage_GetWidth(const sfRenderImage* renderImage); + +//////////////////////////////////////////////////////////// +/// Get the height of the rendering region of a renderimage +/// +/// \param renderImage : Renderimage object +/// +/// \return Height in pixels +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfRenderImage_GetHeight(const sfRenderImage* renderImage); + +//////////////////////////////////////////////////////////// +/// Activate or deactivate a renderimage as the current target for rendering +/// +/// \param renderImage : Renderimage object +/// \param active : sfTrue to activate, sfFalse to deactivate +/// +/// \return True if operation was successful, false otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfRenderImage_SetActive(sfRenderImage* renderImage, sfBool active); + +//////////////////////////////////////////////////////////// +/// Save the current OpenGL render states and matrices +/// +/// \param renderWindow : Renderwindow object +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderImage_SaveGLStates(sfRenderImage* renderImage); + +//////////////////////////////////////////////////////////// +/// Restore the previously saved OpenGL render states and matrices +/// +/// \param renderWindow : Renderwindow object +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderImage_RestoreGLStates(sfRenderImage* renderImage); + +//////////////////////////////////////////////////////////// +/// Update the contents of the target image +/// +/// \param renderImage : Renderimage object +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderImage_Display(sfRenderImage* renderImage); + +//////////////////////////////////////////////////////////// +/// Draw something on a renderimage +/// +/// \param renderImage : Renderimage to draw in +/// \param sprite / text / shape : Object to draw +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderImage_DrawSprite(sfRenderImage* renderImage, const sfSprite* sprite); +CSFML_API void sfRenderImage_DrawShape (sfRenderImage* renderImage, const sfShape* shape); +CSFML_API void sfRenderImage_DrawText (sfRenderImage* renderImage, const sfText* text); + +//////////////////////////////////////////////////////////// +/// Draw something on a renderimage with a shader +/// +/// \param renderImage : Renderimage to draw in +/// \param sprite / text / shape : Object to draw +/// \param shader : Shader to use +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderImage_DrawSpriteWithShader(sfRenderImage* renderImage, const sfSprite* sprite, const sfShader* shader); +CSFML_API void sfRenderImage_DrawShapeWithShader (sfRenderImage* renderImage, const sfShape* shape, const sfShader* shader); +CSFML_API void sfRenderImage_DrawTextWithShader (sfRenderImage* renderImage, const sfText* text, const sfShader* shader); + +//////////////////////////////////////////////////////////// +/// Clear the renderimage with the given color +/// +/// \param renderImage : Renderimage to modify +/// \param color : Fill color +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderImage_Clear(sfRenderImage* renderImage, sfColor color); + +//////////////////////////////////////////////////////////// +/// Change the current active view of a renderimage +/// +/// \param renderImage : Renderimage to modify +/// \param view : Pointer to the new view +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderImage_SetView(sfRenderImage* renderImage, const sfView* view); + +//////////////////////////////////////////////////////////// +/// Get the current active view of a renderimage +/// +/// \param renderImage : Renderimage +/// +/// \return Current active view +/// +//////////////////////////////////////////////////////////// +CSFML_API const sfView* sfRenderImage_GetView(const sfRenderImage* renderImage); + +//////////////////////////////////////////////////////////// +/// Get the default view of a renderimage +/// +/// \param renderImage : Renderimage +/// +/// \return Default view of the renderimage +/// +//////////////////////////////////////////////////////////// +CSFML_API const sfView* sfRenderImage_GetDefaultView(const sfRenderImage* renderImage); + +//////////////////////////////////////////////////////////// +/// Get the viewport of a view applied to this target +/// +/// \param renderImage : Renderimage object +/// \param view : Target view +/// +/// \return Viewport rectangle, expressed in pixels in the current target +/// +//////////////////////////////////////////////////////////// +CSFML_API sfIntRect sfRenderImage_GetViewport(const sfRenderImage* renderImage, const sfView* view); + +//////////////////////////////////////////////////////////// +/// Convert a point in image coordinates into view coordinates +/// +/// \param renderImage : Renderimage object +/// \param windowX : X coordinate of the point to convert, relative to the image +/// \param windowY : Y coordinate of the point to convert, relative to the image +/// \param viewX : Pointer to fill with the X coordinate of the converted point +/// \param viewY : Pointer to fill with the Y coordinate of the converted point +/// \param targetView : Target view to convert the point to (pass NULL to use the current view) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderImage_ConvertCoords(const sfRenderImage* renderImage, unsigned int windowX, unsigned int windowY, float* viewX, float* viewY, const sfView* targetView); + +//////////////////////////////////////////////////////////// +/// Get the target image +/// +/// \param renderImage : Renderimage object +/// +/// \return Pointer to the target image +/// +//////////////////////////////////////////////////////////// +CSFML_API const sfImage* sfRenderImage_GetImage(const sfRenderImage* renderImage); + + +#endif // SFML_RENDERIMAGE_H diff --git a/include/SFML/Graphics/RenderWindow.h b/include/SFML/Graphics/RenderWindow.h new file mode 100644 index 0000000..2579303 --- /dev/null +++ b/include/SFML/Graphics/RenderWindow.h @@ -0,0 +1,385 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_RENDERWINDOW_H +#define SFML_RENDERWINDOW_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new renderwindow +/// +/// \param mode : Video mode to use +/// \param title : Title of the window +/// \param style : Window style +/// \param settings : Creation settings (pass NULL to use default values) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfRenderWindow* sfRenderWindow_Create(sfVideoMode mode, const char* title, unsigned long style, const sfContextSettings* settings); + +//////////////////////////////////////////////////////////// +/// Construct a renderwindow from an existing control +/// +/// \param handle : Platform-specific handle of the control +/// \param settings : Creation settings (pass NULL to use default values) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfRenderWindow* sfRenderWindow_CreateFromHandle(sfWindowHandle handle, const sfContextSettings* settings); + +//////////////////////////////////////////////////////////// +/// Destroy an existing renderwindow +/// +/// \param renderWindow : Renderwindow to destroy +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_Destroy(sfRenderWindow* renderWindow); + +//////////////////////////////////////////////////////////// +/// Close a renderwindow (but doesn't destroy the internal data) +/// +/// \param renderWindow : Renderwindow to close +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_Close(sfRenderWindow* renderWindow); + +//////////////////////////////////////////////////////////// +/// Tell whether or not a renderwindow is opened +/// +/// \param renderWindow : Renderwindow object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfRenderWindow_IsOpened(const sfRenderWindow* renderWindow); + +//////////////////////////////////////////////////////////// +/// Get the width of the rendering region of a window +/// +/// \param renderWindow : Renderwindow object +/// +/// \return Width in pixels +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfRenderWindow_GetWidth(const sfRenderWindow* renderWindow); + +//////////////////////////////////////////////////////////// +/// Get the height of the rendering region of a window +/// +/// \param renderWindow : Renderwindow object +/// +/// \return Height in pixels +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfRenderWindow_GetHeight(const sfRenderWindow* renderWindow); + +//////////////////////////////////////////////////////////// +/// Get the creation settings of a window +/// +/// \param renderWindow : Renderwindow object +/// +/// \return Settings used to create the window +/// +//////////////////////////////////////////////////////////// +CSFML_API sfContextSettings sfRenderWindow_GetSettings(const sfRenderWindow* renderWindow); + +//////////////////////////////////////////////////////////// +/// Get the event on top of events stack of a window, if any, and pop it +/// +/// \param renderWindow : Renderwindow object +/// \param event : Event to fill, if any +/// +/// \return sfTrue if an event was returned, sfFalse if events stack was empty +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfRenderWindow_PollEvent(sfRenderWindow* renderWindow, sfEvent* event); + +//////////////////////////////////////////////////////////// +/// Wait for an event and return it +/// +/// \param renderWindow : Renderwindow object +/// \param event : Event to fill +/// +/// \return sfFalse if an error occured +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfRenderWindow_WaitEvent(sfRenderWindow* renderWindow, sfEvent* event); + +//////////////////////////////////////////////////////////// +/// Enable / disable vertical synchronization on a window +/// +/// \param renderWindow : Renderwindow object +/// \param enabled : sfTrue to enable v-sync, sfFalse to deactivate +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_EnableVerticalSync(sfRenderWindow* renderWindow, sfBool enabled); + +//////////////////////////////////////////////////////////// +/// Show or hide the mouse cursor on a window +/// +/// \param renderWindow : RenderWindow object +/// \param show : sfTrue to show, sfFalse to hide +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_ShowMouseCursor(sfRenderWindow* renderWindow, sfBool show); + +//////////////////////////////////////////////////////////// +/// Change the position of the mouse cursor on a window +/// +/// \param renderWindow : Renderwindow object +/// \param left : Left coordinate of the cursor, relative to the window +/// \param top : Top coordinate of the cursor, relative to the window +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_SetCursorPosition(sfRenderWindow* renderWindow, unsigned int left, unsigned int top); + +//////////////////////////////////////////////////////////// +/// Change the position of a window on screen. +/// Only works for top-level windows +/// +/// \param renderWindow : Renderwindow object +/// \param left : Left position +/// \param top : Top position +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_SetPosition(sfRenderWindow* renderWindow, int left, int top); + +//////////////////////////////////////////////////////////// +/// Change the size of the rendering region of a window +/// +/// \param renderWindow : Renderwindow object +/// \param width : New Width +/// \param height : New Height +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_SetSize(sfRenderWindow* renderWindow, unsigned int width, unsigned int height); + +//////////////////////////////////////////////////////////// +/// Change the title of a window +/// +/// \param renderWindow : Renderwindow object +/// \param title : New title +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_SetTitle(sfRenderWindow* renderWindow, const char* title); + +//////////////////////////////////////////////////////////// +/// Show or hide a window +/// +/// \param renderWindow : Renderwindow object +/// \param show : sfTrue to show, sfFalse to hide +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_Show(sfRenderWindow* renderWindow, sfBool show); + +//////////////////////////////////////////////////////////// +/// Enable or disable automatic key-repeat for keydown events. +/// Automatic key-repeat is enabled by default +/// +/// \param renderWindow : Renderwindow object +/// \param enabled : sfTrue to enable, sfFalse to disable +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_EnableKeyRepeat(sfRenderWindow* renderWindow, sfBool enabled); + +//////////////////////////////////////////////////////////// +/// Change the window's icon +/// +/// \param renderWindow : Renderwindow object +/// \param width : Icon's width, in pixels +/// \param height : Icon's height, in pixels +/// \param pixels : Pointer to the pixels in memory, format must be RGBA 32 bits +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_SetIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfUint8* pixels); + +//////////////////////////////////////////////////////////// +/// Activate or deactivate a window as the current target for rendering +/// +/// \param renderWindow : Renderwindow object +/// \param active : sfTrue to activate, sfFalse to deactivate +/// +/// \return True if operation was successful, false otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfRenderWindow_SetActive(sfRenderWindow* renderWindow, sfBool active); + +//////////////////////////////////////////////////////////// +/// Save the current OpenGL render states and matrices +/// +/// \param renderWindow : Renderwindow object +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_SaveGLStates(sfRenderWindow* renderWindow); + +//////////////////////////////////////////////////////////// +/// Restore the previously saved OpenGL render states and matrices +/// +/// \param renderWindow : Renderwindow object +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_RestoreGLStates(sfRenderWindow* renderWindow); + +//////////////////////////////////////////////////////////// +/// Display a window on screen +/// +/// \param renderWindow : Renderwindow object +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_Display(sfRenderWindow* renderWindow); + +//////////////////////////////////////////////////////////// +/// Limit the framerate to a maximum fixed frequency for a window +/// +/// \param renderWindow : Renderwindow object +/// \param limit : Framerate limit, in frames per seconds (use 0 to disable limit) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_SetFramerateLimit(sfRenderWindow* renderWindow, unsigned int limit); + +//////////////////////////////////////////////////////////// +/// Get time elapsed since last frame of a window +/// +/// \param renderWindow : Renderwindow object +/// +/// \return Time elapsed, in milliseconds +/// +//////////////////////////////////////////////////////////// +CSFML_API sfUint32 sfRenderWindow_GetFrameTime(const sfRenderWindow* renderWindow); + +//////////////////////////////////////////////////////////// +/// Change the joystick threshold, ie. the value below which +/// no move event will be generated +/// +/// \param renderWindow : Renderwindow object +/// \param threshold : New threshold, in range [0, 100] +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_SetJoystickThreshold(sfRenderWindow* renderWindow, float threshold); + +//////////////////////////////////////////////////////////// +/// Retrieve the Os-specific handle of a window +/// +/// \param renderWindow : Renderwindow object +/// +/// \return Window handle +/// +//////////////////////////////////////////////////////////// +CSFML_API sfWindowHandle sfRenderWindow_GetSystemHandle(const sfRenderWindow* renderWindow); + +//////////////////////////////////////////////////////////// +/// Draw something on a renderwindow +/// +/// \param renderWindow : Renderwindow to draw in +/// \param sprite / text / shape : Object to draw +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_DrawSprite(sfRenderWindow* renderWindow, const sfSprite* sprite); +CSFML_API void sfRenderWindow_DrawShape (sfRenderWindow* renderWindow, const sfShape* shape); +CSFML_API void sfRenderWindow_DrawText (sfRenderWindow* renderWindow, const sfText* text); + +//////////////////////////////////////////////////////////// +/// Draw something on a renderwindow with a shader +/// +/// \param renderWindow : Renderwindow to draw in +/// \param sprite / text / shape : Object to draw +/// \param shader : Shader to use +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_DrawSpriteWithShader(sfRenderWindow* renderWindow, const sfSprite* sprite, const sfShader* shader); +CSFML_API void sfRenderWindow_DrawShapeWithShader (sfRenderWindow* renderWindow, const sfShape* shape, const sfShader* shader); +CSFML_API void sfRenderWindow_DrawTextWithShader (sfRenderWindow* renderWindow, const sfText* text, const sfShader* shader); + +//////////////////////////////////////////////////////////// +/// Clear the screen with the given color +/// +/// \param renderWindow : Renderwindow to modify +/// \param color : Fill color +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_Clear(sfRenderWindow* renderWindow, sfColor color); + +//////////////////////////////////////////////////////////// +/// Change the current active view of a renderwindow +/// +/// \param renderWindow : Renderwindow to modify +/// \param view : Pointer to the new view +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_SetView(sfRenderWindow* renderWindow, const sfView* view); + +//////////////////////////////////////////////////////////// +/// Get the current active view of a renderwindow +/// +/// \param renderWindow : Renderwindow +/// +/// \return Current active view +/// +//////////////////////////////////////////////////////////// +CSFML_API const sfView* sfRenderWindow_GetView(const sfRenderWindow* renderWindow); + +//////////////////////////////////////////////////////////// +/// Get the default view of a renderwindow +/// +/// \param renderWindow : Renderwindow +/// +/// \return Default view of the render window +/// +//////////////////////////////////////////////////////////// +CSFML_API const sfView* sfRenderWindow_GetDefaultView(const sfRenderWindow* renderWindow); + +//////////////////////////////////////////////////////////// +/// Get the viewport of a view applied to this target +/// +/// \param renderWindow : Renderwindow +/// \param view : Target view +/// +/// \return Viewport rectangle, expressed in pixels in the current target +/// +//////////////////////////////////////////////////////////// +CSFML_API sfIntRect sfRenderWindow_GetViewport(const sfRenderWindow* renderWindow, const sfView* view); + +//////////////////////////////////////////////////////////// +/// Convert a point in window coordinates into view coordinates +/// +/// \param renderWindow : Target Renderwindow +/// \param windowX : X coordinate of the point to convert, relative to the window +/// \param windowY : Y coordinate of the point to convert, relative to the window +/// \param viewX : Pointer to fill with the X coordinate of the converted point +/// \param viewY : Pointer to fill with the Y coordinate of the converted point +/// \param targetView : Target view to convert the point to (pass NULL to use the current view) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfRenderWindow_ConvertCoords(const sfRenderWindow* renderWindow, unsigned int windowX, unsigned int windowY, float* viewX, float* viewY, const sfView* targetView); + + +#endif // SFML_RENDERWINDOW_H diff --git a/include/SFML/Graphics/Shader.h b/include/SFML/Graphics/Shader.h new file mode 100644 index 0000000..ff5e0e3 --- /dev/null +++ b/include/SFML/Graphics/Shader.h @@ -0,0 +1,157 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SHADER_H +#define SFML_SHADER_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new shader from a file +/// +/// \param filename : File to load +/// +/// \return A new sfShader object, or NULL if it failed +/// +//////////////////////////////////////////////////////////// +CSFML_API sfShader* sfShader_CreateFromFile(const char* filename); + +//////////////////////////////////////////////////////////// +/// Create a new shader from an effect source code +/// +/// \param effect : Source code of the effect +/// +/// \return A new sfShader object, or NULL if it failed +/// +//////////////////////////////////////////////////////////// +CSFML_API sfShader* sfShader_CreateFromMemory(const char* effect); + +//////////////////////////////////////////////////////////// +/// Copy an existing shader +/// +/// \param shader : Shader to copy +/// +/// \return Copied object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfShader* sfShader_Copy(sfShader* shader); + +//////////////////////////////////////////////////////////// +/// Destroy an existing shader +/// +/// \param shader : Shader to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShader_Destroy(sfShader* shader); + +//////////////////////////////////////////////////////////// +/// Change a parameter of a shader (1 float) +/// +/// \param shader : Shader to modify +/// \param name : Parameter name in the effect +/// \param x : Value to assign +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShader_SetParameter1(sfShader* shader, const char* name, float x); + +//////////////////////////////////////////////////////////// +/// Change a parameter of a shader (2 floats) +/// +/// \param shader : Shader to modify +/// \param name : Parameter name in the effect +/// \param x, y : Values to assign +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShader_SetParameter2(sfShader* shader, const char* name, float x, float y); + +//////////////////////////////////////////////////////////// +/// Change a parameter of a shader (3 floats) +/// +/// \param shader : Shader to modify +/// \param name : Parameter name in the effect +/// \param x, y, z : Values to assign +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShader_SetParameter3(sfShader* shader, const char* name, float x, float y, float z); + +//////////////////////////////////////////////////////////// +/// Change a parameter of a shader (4 floats) +/// +/// \param shader : Shader to modify +/// \param name : Parameter name in the effect +/// \param x, y, z, w : Values to assign +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShader_SetParameter4(sfShader* shader, const char* name, float x, float y, float z, float w); + +//////////////////////////////////////////////////////////// +/// Set a texture parameter in a shader +/// +/// \param shader : Shader to modify +/// \param name : Texture name in the effect +/// \param texture : Image to set +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShader_SetTexture(sfShader* shader, const char* name, const sfImage* texture); + +//////////////////////////////////////////////////////////// +/// Set the current texture parameter in a shader +/// +/// \param shader : Shader to modify +/// \param name : Texture name in the effect +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShader_SetCurrentTexture(sfShader* shader, const char* name); + +//////////////////////////////////////////////////////////// +/// Bind a shader for rendering +/// +/// \param shader : Shader to bind +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShader_Bind(const sfShader* shader); + +//////////////////////////////////////////////////////////// +/// Unbind a shader +/// +/// \param shader : Shader to unbind +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShader_Unbind(const sfShader* shader); + +//////////////////////////////////////////////////////////// +/// Tell whether or not the system supports shaders +/// +/// \return sfTrue if the system can use shaders +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfShader_IsAvailable(void); + + +#endif // SFML_SHADER_H diff --git a/include/SFML/Graphics/Shape.h b/include/SFML/Graphics/Shape.h new file mode 100644 index 0000000..f8d35a7 --- /dev/null +++ b/include/SFML/Graphics/Shape.h @@ -0,0 +1,464 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SHAPE_H +#define SFML_SHAPE_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new shape +/// +/// \return A new sfShape object, or NULL if it failed +/// +//////////////////////////////////////////////////////////// +CSFML_API sfShape* sfShape_Create(void); + +//////////////////////////////////////////////////////////// +/// Create a new shape made of a single line +/// +/// \param p1x, p1y : Position of the first point +/// \param p2x, p2y : Position second point +/// \param thickness : Line thickness +/// \param color : Color used to draw the line +/// \param outline : Outline thickness +/// \param outlineColor : Color used to draw the outline +/// +//////////////////////////////////////////////////////////// +CSFML_API sfShape* sfShape_CreateLine(float p1x, float p1y, float p2x, float p2y, float thickness, sfColor color, float outline, sfColor outlineColor); + +//////////////////////////////////////////////////////////// +/// Create a new shape made of a single rectangle +/// +/// \param left, top : Top-left corner of the rectangle +/// \param width, height : Size of the rectangle +/// \param color : Color used to fill the rectangle +/// \param outline : Outline thickness +/// \param outlineColor : Color used to draw the outline +/// +//////////////////////////////////////////////////////////// +CSFML_API sfShape* sfShape_CreateRectangle(float left, float top, float width, float height, sfColor color, float outline, sfColor outlineColor); + +//////////////////////////////////////////////////////////// +/// Create a new shape made of a single circle +/// +/// \param x, y : Position of the center +/// \param radius : Radius +/// \param color : Color used to fill the circle +/// \param outline : Outline thickness +/// \param outlineColor : Color used to draw the outline +/// +//////////////////////////////////////////////////////////// +CSFML_API sfShape* sfShape_CreateCircle(float x, float y, float radius, sfColor color, float outline, sfColor outlineColor); + +//////////////////////////////////////////////////////////// +/// Copy an existing shape +/// +/// \param shape : Shape to copy +/// +/// \return Copied object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfShape* sfShape_Copy(sfShape* shape); + +//////////////////////////////////////////////////////////// +/// Destroy an existing Shape +/// +/// \param Shape : Shape to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_Destroy(sfShape* shape); + +//////////////////////////////////////////////////////////// +/// Set the X position of a shape +/// +/// \param shape : Shape to modify +/// \param x : New X coordinate +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_SetX(sfShape* shape, float x); + +//////////////////////////////////////////////////////////// +/// Set the Y position of a shape +/// +/// \param shape : Shape to modify +/// \param y : New Y coordinate +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_SetY(sfShape* shape, float y); + +//////////////////////////////////////////////////////////// +/// Set the position of a shape +/// +/// \param shape : Shape to modify +/// \param x : New X coordinate +/// \param y : New Y coordinate +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_SetPosition(sfShape* shape, float x, float y); + +//////////////////////////////////////////////////////////// +/// Set the horizontal scale of a shape +/// +/// \param shape : Shape to modify +/// \param scale : New scale (must be strictly positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_SetScaleX(sfShape* shape, float scale); + +//////////////////////////////////////////////////////////// +/// Set the vertical scale of a shape +/// +/// \param shape : Shape to modify +/// \param scale : New scale (must be strictly positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_SetScaleY(sfShape* shape, float scale); + +//////////////////////////////////////////////////////////// +/// Set the scale of a shape +/// +/// \param shape : Shape to modify +/// \param scaleX : New horizontal scale (must be strictly positive) +/// \param scaleY : New vertical scale (must be strictly positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_SetScale(sfShape* shape, float scaleX, float scaleY); + +//////////////////////////////////////////////////////////// +/// Set the orientation of a shape +/// +/// \param shape : Shape to modify +/// \param rotation : Angle of rotation, in degrees +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_SetRotation(sfShape* shape, float rotation); + +//////////////////////////////////////////////////////////// +/// Set the local origin of a shape, in coordinates relative to +/// its left-top corner +/// +/// \param shape : Shape to modify +/// \param x : X coordinate of the origin +/// \param y : Y coordinate of the origin +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_SetOrigin(sfShape* shape, float x, float y); + +//////////////////////////////////////////////////////////// +/// Set the color of a shape +/// +/// \param shape : Shape to modify +/// \param color : New color +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_SetColor(sfShape* shape, sfColor color); + +//////////////////////////////////////////////////////////// +/// Set the blending mode for a shape +/// +/// \param shape : Shape to modify +/// \param mode : New blending mode +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_SetBlendMode(sfShape* shape, sfBlendMode mode); + +//////////////////////////////////////////////////////////// +/// Get the X position of a shape +/// +/// \param shape : Shape to read +/// +/// \return Current X position +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfShape_GetX(const sfShape* shape); + +//////////////////////////////////////////////////////////// +/// Get the Y position of a shape +/// +/// \param shape : Shape to read +/// +/// \return Current Y position +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfShape_GetY(const sfShape* shape); + +//////////////////////////////////////////////////////////// +/// Get the horizontal scale of a shape +/// +/// \param shape : Shape to read +/// +/// \return Current X scale factor (always positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfShape_GetScaleX(const sfShape* shape); + +//////////////////////////////////////////////////////////// +/// Get the vertical scale of a shape +/// +/// \param shape : Shape to read +/// +/// \return Current Y scale factor (always positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfShape_GetScaleY(const sfShape* shape); + +//////////////////////////////////////////////////////////// +/// Get the orientation of a shape +/// +/// \param shape : Shape to read +/// +/// \return Current rotation, in degrees +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfShape_GetRotation(const sfShape* shape); + +//////////////////////////////////////////////////////////// +/// Get the X position of the origin a shape +/// +/// \param shape : Shape to read +/// +/// \return Current X origin +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfShape_GetOriginX(const sfShape* shape); + +//////////////////////////////////////////////////////////// +/// Get the Y position of the origin a shape +/// +/// \param shape : Shape to read +/// +/// \return Current Y origin +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfShape_GetOriginY(const sfShape* shape); + +//////////////////////////////////////////////////////////// +/// Get the color of a shape +/// +/// \param shape : Shape to read +/// +/// \return Current color +/// +//////////////////////////////////////////////////////////// +CSFML_API sfColor sfShape_GetColor(const sfShape* shape); + +//////////////////////////////////////////////////////////// +/// Get the current blending mode of a shape +/// +/// \param shape : Shape to read +/// +/// \return Current blending mode +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBlendMode sfShape_GetBlendMode(const sfShape* shape); + +//////////////////////////////////////////////////////////// +/// Move a shape +/// +/// \param shape : Shape to modify +/// \param offsetX : Offset on the X axis +/// \param offsetY : Offset on the Y axis +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_Move(sfShape* shape, float offsetX, float offsetY); + +//////////////////////////////////////////////////////////// +/// Scale a shape +/// +/// \param shape : Shape to modify +/// \param factorX : Horizontal scaling factor (must be strictly positive) +/// \param factorY : Vertical scaling factor (must be strictly positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_Scale(sfShape* shape, float factorX, float factorY); + +//////////////////////////////////////////////////////////// +/// Rotate a shape +/// +/// \param shape : Shape to modify +/// \param angle : Angle of rotation, in degrees +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_Rotate(sfShape* shape, float angle); + +//////////////////////////////////////////////////////////// +/// Transform a point from global coordinates into the shape's local coordinates +/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point) +/// +/// \param shape : Shape object +/// \param pointX : X coordinate of the point to transform +/// \param pointY : Y coordinate of the point to transform +/// \param x : Value to fill with the X coordinate of the converted point +/// \param y : Value to fill with the y coordinate of the converted point +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_TransformToLocal(const sfShape* shape, float pointX, float pointY, float* x, float* y); + +//////////////////////////////////////////////////////////// +/// Transform a point from the shape's local coordinates into global coordinates +/// (ie it applies the object's origin, translation, rotation and scale to the point) +/// +/// \param shape : Shape object +/// \param pointX : X coordinate of the point to transform +/// \param pointY : Y coordinate of the point to transform +/// \param x : Value to fill with the X coordinate of the converted point +/// \param y : Value to fill with the y coordinate of the converted point +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_TransformToGlobal(const sfShape* shape, float pointX, float pointY, float* x, float* y); + +//////////////////////////////////////////////////////////// +/// Add a point to a shape +/// +/// \param shape : Shape to modify +/// \param x, y : Position of the point +/// \param color : Color of the point +/// \param outlineColor : Outline color of the point +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_AddPoint(sfShape* shape, float x, float y, sfColor color, sfColor outlineColor); + +//////////////////////////////////////////////////////////// +/// Enable or disable filling a shape. +/// Fill is enabled by default +/// +/// \param shape : Shape to modify +/// \param enable : True to enable, false to disable +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_EnableFill(sfShape* shape, sfBool enable); + +//////////////////////////////////////////////////////////// +/// Enable or disable drawing a shape outline. +/// Outline is enabled by default +/// +/// \param shape : Shape to modify +/// \param enable : True to enable, false to disable +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_EnableOutline(sfShape* shape, sfBool enable); + +//////////////////////////////////////////////////////////// +/// Change the thickness of a shape outline +/// +/// \param shape : Shape to modify +/// \param thickness : New thickness +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_SetOutlineThickness(sfShape* shape, float thickness); + +//////////////////////////////////////////////////////////// +/// Get the thickness of a shape outline +/// +/// \param shape : Shape to read +/// +/// \param return Current outline thickness +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfShape_GetOutlineThickness(const sfShape* shape); + +//////////////////////////////////////////////////////////// +/// Get the number of points composing a shape +/// +/// \param shape : Shape to read +/// +/// \return Total number of points +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfShape_GetPointsCount(const sfShape* shape); + +//////////////////////////////////////////////////////////// +/// Get a the position of a shape's point +/// +/// \param shape : Shape to read +/// \param index : Index of the point to get +/// \param x : Variable to fill with the X coordinate of the point +/// \param y : Variable to fill with the Y coordinate of the point +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_GetPointPosition(const sfShape* shape, unsigned int index, float* x, float* y); + +//////////////////////////////////////////////////////////// +/// Get a the color of a shape's point +/// +/// \param shape : Shape to read +/// \param index : Index of the point to get +/// +/// \return Color of the point +/// +//////////////////////////////////////////////////////////// +CSFML_API sfColor sfShape_GetPointColor(const sfShape* shape, unsigned int index); + +//////////////////////////////////////////////////////////// +/// Get a the outline color of a shape's point +/// +/// \param shape : Shape to read +/// \param index : Index of the point to get +/// +/// \return Outline color of the point +/// +//////////////////////////////////////////////////////////// +CSFML_API sfColor sfShape_GetPointOutlineColor(const sfShape* shape, unsigned int index); + +//////////////////////////////////////////////////////////// +/// Set a the position of a shape's point +/// +/// \param shape : Shape to read +/// \param index : Index of the point to get +/// \param x : X coordinate of the point +/// \param y : Y coordinate of the point +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_SetPointPosition(sfShape* shape, unsigned int index, float x, float y); + +//////////////////////////////////////////////////////////// +/// Set a the color of a shape's point +/// +/// \param shape : Shape to read +/// \param index : Index of the point to get +/// \param color : Color of the point +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_SetPointColor(sfShape* shape, unsigned int index, sfColor color); + +//////////////////////////////////////////////////////////// +/// Set a the outline color of a shape's point +/// +/// \param shape : Shape to read +/// \param index : Index of the point to get +/// \param color : Outline color of the point +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfShape_SetPointOutlineColor(sfShape* shape, unsigned int index, sfColor color); + + +#endif // SFML_SHAPE_H diff --git a/include/SFML/Graphics/Sprite.h b/include/SFML/Graphics/Sprite.h new file mode 100644 index 0000000..c6972fd --- /dev/null +++ b/include/SFML/Graphics/Sprite.h @@ -0,0 +1,403 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SPRITE_H +#define SFML_SPRITE_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new sprite +/// +/// \return A new sfSprite object, or NULL if it failed +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSprite* sfSprite_Create(void); + +//////////////////////////////////////////////////////////// +/// Copy an existing sprite +/// +/// \param sprite : Sprite to copy +/// +/// \return Copied object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSprite* sfSprite_Copy(sfSprite* sprite); + +//////////////////////////////////////////////////////////// +/// Destroy an existing sprite +/// +/// \param sprite : Sprite to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_Destroy(sfSprite* sprite); + +//////////////////////////////////////////////////////////// +/// Set the X position of a sprite +/// +/// \param sprite : Sprite to modify +/// \param x : New X coordinate +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_SetX(sfSprite* sprite, float x); + +//////////////////////////////////////////////////////////// +/// Set the T position of a sprite +/// +/// \param sprite : Sprite to modify +/// \param y : New Y coordinate +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_SetY(sfSprite* sprite, float y); + +//////////////////////////////////////////////////////////// +/// Set the position of a sprite +/// +/// \param sprite : Sprite to modify +/// \param x : New X coordinate +/// \param y : New Y coordinate +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_SetPosition(sfSprite* sprite, float x, float y); + +//////////////////////////////////////////////////////////// +/// Set the horizontal scale of a sprite +/// +/// \param sprite : Sprite to modify +/// \param scale : New scale (must be strictly positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_SetScaleX(sfSprite* sprite, float scale); + +//////////////////////////////////////////////////////////// +/// Set the vertical scale of a sprite +/// +/// \param sprite : Sprite to modify +/// \param scale : New scale (must be strictly positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_SetScaleY(sfSprite* sprite, float scale); + +//////////////////////////////////////////////////////////// +/// Set the scale of a sprite +/// +/// \param sprite : Sprite to modify +/// \param scaleX : New horizontal scale (must be strictly positive) +/// \param scaleY : New vertical scale (must be strictly positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_SetScale(sfSprite* sprite, float scaleX, float scaleY); + +//////////////////////////////////////////////////////////// +/// Set the orientation of a sprite +/// +/// \param sprite : Sprite to modify +/// \param rotation : Angle of rotation, in degrees +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_SetRotation(sfSprite* sprite, float rotation); + +//////////////////////////////////////////////////////////// +/// Set the local origin of a sprite, in coordinates relative to +/// its left-top corner +/// +/// \param sprite : Sprite to modify +/// \param x : X coordinate of the origin +/// \param y : Y coordinate of the origin +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_SetOrigin(sfSprite* sprite, float x, float y); + +//////////////////////////////////////////////////////////// +/// Set the color of a sprite +/// +/// \param sprite : Sprite to modify +/// \param color : New color +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_SetColor(sfSprite* sprite, sfColor color); + +//////////////////////////////////////////////////////////// +/// Set the blending mode for a sprite +/// +/// \param sprite : Sprite to modify +/// \param mode : New blending mode +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_SetBlendMode(sfSprite* sprite, sfBlendMode mode); + +//////////////////////////////////////////////////////////// +/// Get the X position of a sprite +/// +/// \param sprite : Sprite to read +/// +/// \return Current X position +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSprite_GetX(const sfSprite* sprite); + +//////////////////////////////////////////////////////////// +/// Get the Y position of a sprite +/// +/// \param sprite : Sprite to read +/// +/// \return Current Y position +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSprite_GetY(const sfSprite* sprite); + +//////////////////////////////////////////////////////////// +/// Get the horizontal scale of a sprite +/// +/// \param sprite : Sprite to read +/// +/// \return Current X scale factor (always positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSprite_GetScaleX(const sfSprite* sprite); + +//////////////////////////////////////////////////////////// +/// Get the vertical scale of a sprite +/// +/// \param sprite : Sprite to read +/// +/// \return Current Y scale factor (always positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSprite_GetScaleY(const sfSprite* sprite); + +//////////////////////////////////////////////////////////// +/// Get the orientation of a sprite +/// +/// \param sprite : Sprite to read +/// +/// \return Current rotation, in degrees +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSprite_GetRotation(const sfSprite* sprite); + +//////////////////////////////////////////////////////////// +/// Get the X position of the origin a sprite +/// +/// \param sprite : Sprite to read +/// +/// \return Current X origin +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSprite_GetOriginX(const sfSprite* sprite); + +//////////////////////////////////////////////////////////// +/// Get the Y position of the origin a sprite +/// +/// \param sprite : Sprite to read +/// +/// \return Current Y origin +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSprite_GetOriginY(const sfSprite* sprite); + +//////////////////////////////////////////////////////////// +/// Get the color of a sprite +/// +/// \param sprite : Sprite to read +/// +/// \return Current color +/// +//////////////////////////////////////////////////////////// +CSFML_API sfColor sfSprite_GetColor(const sfSprite* sprite); + +//////////////////////////////////////////////////////////// +/// Get the current blending mode of a sprite +/// +/// \param sprite : Sprite to read +/// +/// \return Current blending mode +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBlendMode sfSprite_GetBlendMode(const sfSprite* sprite); + +//////////////////////////////////////////////////////////// +/// Move a sprite +/// +/// \param sprite : Sprite to modify +/// \param offsetX : Offset on the X axis +/// \param offsetY : Offset on the Y axis +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_Move(sfSprite* sprite, float offsetX, float offsetY); + +//////////////////////////////////////////////////////////// +/// Scale a sprite +/// +/// \param sprite : Sprite to modify +/// \param factorX : Horizontal scaling factor (must be strictly positive) +/// \param factorY : Vertical scaling factor (must be strictly positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_Scale(sfSprite* sprite, float factorX, float factorY); + +//////////////////////////////////////////////////////////// +/// Rotate a sprite +/// +/// \param sprite : Sprite to modify +/// \param angle : Angle of rotation, in degrees +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_Rotate(sfSprite* sprite, float angle); + +//////////////////////////////////////////////////////////// +/// Transform a point from global coordinates into the sprite's local coordinates +/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point) +/// +/// \param sprite : Sprite object +/// \param pointX : X coordinate of the point to transform +/// \param pointY : Y coordinate of the point to transform +/// \param x : Value to fill with the X coordinate of the converted point +/// \param y : Value to fill with the y coordinate of the converted point +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_TransformToLocal(const sfSprite* sprite, float pointX, float pointY, float* x, float* y); + +//////////////////////////////////////////////////////////// +/// Transform a point from the sprite's local coordinates into global coordinates +/// (ie it applies the object's origin, translation, rotation and scale to the point) +/// +/// \param sprite : Sprite object +/// \param pointX : X coordinate of the point to transform +/// \param pointY : Y coordinate of the point to transform +/// \param x : Value to fill with the X coordinate of the converted point +/// \param y : Value to fill with the y coordinate of the converted point +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_TransformToGlobal(const sfSprite* sprite, float pointX, float pointY, float* x, float* y); + +//////////////////////////////////////////////////////////// +/// Change the image of a sprite +/// +/// \param sprite : Sprite to modify +/// \param image : New image +/// \param adjustToNewSize : If true, the SubRect of the sprite will be adjusted to the size of the new image +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_SetImage(sfSprite* sprite, const sfImage* image, sfBool adjustToNewSize); + +//////////////////////////////////////////////////////////// +/// Set the sub-rectangle of a sprite inside the source image +/// +/// \param sprite : Sprite to modify +/// \param rectangle : New sub-rectangle +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_SetSubRect(sfSprite* sprite, sfIntRect rectangle); + +//////////////////////////////////////////////////////////// +/// Resize a sprite (by changing its scale factors) +/// +/// \param sprite : Sprite to modify +/// \param width : New width (must be strictly positive) +/// \param height : New height (must be strictly positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_Resize(sfSprite* sprite, float width, float height); + +//////////////////////////////////////////////////////////// +/// Flip a sprite horizontally +/// +/// \param sprite : Sprite to modify +/// \param flipped : sfTrue to flip the sprite +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_FlipX(sfSprite* sprite, sfBool flipped); + +//////////////////////////////////////////////////////////// +/// Flip a sprite vertically +/// +/// \param sprite : Sprite to modify +/// \param flipped : sfTrue to flip the sprite +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSprite_FlipY(sfSprite* sprite, sfBool flipped); + +//////////////////////////////////////////////////////////// +/// Get the source image of a sprite +/// +/// \param sprite : Sprite to read +/// +/// \return Pointer to the image (can be NULL) +/// +//////////////////////////////////////////////////////////// +CSFML_API const sfImage* sfSprite_GetImage(const sfSprite* sprite); + +//////////////////////////////////////////////////////////// +/// Get the sub-rectangle of a sprite inside the source image +/// +/// \param sprite : Sprite to read +/// +/// \return Sub-rectangle +/// +//////////////////////////////////////////////////////////// +CSFML_API sfIntRect sfSprite_GetSubRect(const sfSprite* sprite); + +//////////////////////////////////////////////////////////// +/// Get a sprite width +/// +/// \param sprite : Sprite to read +/// +/// \return Width of the sprite +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSprite_GetWidth(const sfSprite* sprite); + +//////////////////////////////////////////////////////////// +/// Get a sprite height +/// +/// \param sprite : Sprite to read +/// +/// \return Height of the sprite +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfSprite_GetHeight(const sfSprite* sprite); + +//////////////////////////////////////////////////////////// +/// Get the color of a given pixel in a sprite +/// +/// \param sprite : Sprite to read +/// \param x : X coordinate of the pixel to get +/// \param y : Y coordinate of the pixel to get +/// +/// \return Color of pixel (X, Y) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfColor sfSprite_GetPixel(const sfSprite* sprite, unsigned int x, unsigned int y); + + +#endif // SFML_SPRITE_H diff --git a/include/SFML/Graphics/Text.h b/include/SFML/Graphics/Text.h new file mode 100644 index 0000000..f5691ac --- /dev/null +++ b/include/SFML/Graphics/Text.h @@ -0,0 +1,434 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_TEXT_H +#define SFML_TEXT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// sfText styles +//////////////////////////////////////////////////////////// +typedef enum +{ + sfTextRegular = 0, ///< Regular characters, no style + sfTextBold = 1 << 0, ///< Characters are bold + sfTextItalic = 1 << 1, ///< Characters are in italic + sfTextUnderlined = 1 << 2 ///< Characters are underlined +} sfTextStyle; + + +//////////////////////////////////////////////////////////// +/// Create a new text +/// +/// \return A new sfText object, or NULL if it failed +/// +//////////////////////////////////////////////////////////// +CSFML_API sfText* sfText_Create(void); + +//////////////////////////////////////////////////////////// +/// Copy an existing text +/// +/// \param text : Text to copy +/// +/// \return Copied object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfText* sfText_Copy(sfText* text); + +//////////////////////////////////////////////////////////// +/// Destroy an existing text +/// +/// \param text : Text to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_Destroy(sfText* text); + +//////////////////////////////////////////////////////////// +/// Set the X position of a text +/// +/// \param text : String to modify +/// \param x : New X coordinate +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_SetX(sfText* text, float x); + +//////////////////////////////////////////////////////////// +/// Set the Y position of a text +/// +/// \param text : String to modify +/// \param y : New Y coordinate +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_SetY(sfText* text, float y); + +//////////////////////////////////////////////////////////// +/// Set the position of a text +/// +/// \param text : String to modify +/// \param x : New X coordinate +/// \param y : New Y coordinate +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_SetPosition(sfText* text, float x, float y); + +//////////////////////////////////////////////////////////// +/// Set the horizontal scale of a text +/// +/// \param text : String to modify +/// \param scale : New scale (must be strictly positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_SetScaleX(sfText* text, float scale); + +//////////////////////////////////////////////////////////// +/// Set the vertical scale of a text +/// +/// \param text : String to modify +/// \param scale : New scale (must be strictly positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_SetScaleY(sfText* text, float scale); + +//////////////////////////////////////////////////////////// +/// Set the scale of a text +/// +/// \param text : String to modify +/// \param scaleX : New horizontal scale (must be strictly positive) +/// \param scaleY : New vertical scale (must be strictly positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_SetScale(sfText* text, float scaleX, float scaleY); + +//////////////////////////////////////////////////////////// +/// Set the orientation of a text +/// +/// \param text : String to modify +/// \param rotation : Angle of rotation, in degrees +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_SetRotation(sfText* text, float rotation); + +//////////////////////////////////////////////////////////// +/// Set the local origin of a text, in coordinates +/// relative to its left-top corner +/// +/// \param text : String to modify +/// \param x : X coordinate of the origin +/// \param y : Y coordinate of the origin +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_SetOrigin(sfText* text, float x, float y); + +//////////////////////////////////////////////////////////// +/// Set the color of a text +/// +/// \param text : String to modify +/// \param color : New color +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_SetColor(sfText* text, sfColor color); + +//////////////////////////////////////////////////////////// +/// Set the blending mode for a text +/// +/// \param text : String to modify +/// \param mode : New blending mode +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_SetBlendMode(sfText* text, sfBlendMode mode); + +//////////////////////////////////////////////////////////// +/// Get the X position of a text +/// +/// \param text : String to read +/// +/// \return Current X position +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfText_GetX(const sfText* text); + +//////////////////////////////////////////////////////////// +/// Get the top Y of a text +/// +/// \param text : String to read +/// +/// \return Current Y position +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfText_GetY(const sfText* text); + +//////////////////////////////////////////////////////////// +/// Get the horizontal scale of a text +/// +/// \param text : String to read +/// +/// \return Current X scale factor (always positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfText_GetScaleX(const sfText* text); + +//////////////////////////////////////////////////////////// +/// Get the vertical scale of a text +/// +/// \param text : String to read +/// +/// \return Current Y scale factor (always positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfText_GetScaleY(const sfText* text); + +//////////////////////////////////////////////////////////// +/// Get the orientation of a text +/// +/// \param text : String to read +/// +/// \return Current rotation, in degrees +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfText_GetRotation(const sfText* text); + +//////////////////////////////////////////////////////////// +/// Get the X position of the origin a text +/// +/// \param text : String to read +/// +/// \return Current X origin position +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfText_GetOriginX(const sfText* text); + +//////////////////////////////////////////////////////////// +/// Get the top Y of the origin of a text +/// +/// \param text : String to read +/// +/// \return Current Y origin position +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfText_GetOriginY(const sfText* text); + +//////////////////////////////////////////////////////////// +/// Get the color of a text +/// +/// \param text : String to read +/// +/// \return Current color +/// +//////////////////////////////////////////////////////////// +CSFML_API sfColor sfText_GetColor(const sfText* text); + +//////////////////////////////////////////////////////////// +/// Get the current blending mode of a text +/// +/// \param text : String to read +/// +/// \return Current blending mode +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBlendMode sfText_GetBlendMode(const sfText* text); + +//////////////////////////////////////////////////////////// +/// Move a text +/// +/// \param text : String to modify +/// \param offsetX : Offset on the X axis +/// \param offsetY : Offset on the Y axis +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_Move(sfText* text, float offsetX, float offsetY); + +//////////////////////////////////////////////////////////// +/// Scale a text +/// +/// \param text : String to modify +/// \param factorX : Horizontal scaling factor (must be strictly positive) +/// \param factorY : Vertical scaling factor (must be strictly positive) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_Scale(sfText* text, float factorX, float factorY); + +//////////////////////////////////////////////////////////// +/// Rotate a text +/// +/// \param text : String to modify +/// \param angle : Angle of rotation, in degrees +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_Rotate(sfText* text, float angle); + +//////////////////////////////////////////////////////////// +/// Transform a point from global coordinates into the string's local coordinates +/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point) +/// +/// \param text : String object +/// \param pointX : X coordinate of the point to transform +/// \param pointY : Y coordinate of the point to transform +/// \param x : Value to fill with the X coordinate of the converted point +/// \param y : Value to fill with the y coordinate of the converted point +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_TransformToLocal(const sfText* text, float pointX, float pointY, float* x, float* y); + +//////////////////////////////////////////////////////////// +/// Transform a point from the string's local coordinates into global coordinates +/// (ie it applies the object's origin, translation, rotation and scale to the point) +/// +/// \param text : String object +/// \param pointX : X coordinate of the point to transform +/// \param pointY : Y coordinate of the point to transform +/// \param x : Value to fill with the X coordinate of the converted point +/// \param y : Value to fill with the y coordinate of the converted point +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_TransformToGlobal(const sfText* text, float pointX, float pointY, float* X, float* y); + +//////////////////////////////////////////////////////////// +/// Set the string of a text (from a multibyte string) +/// +/// \param text : Text to modify +/// \param string : New string +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_SetString(sfText* text, const char* string); + +//////////////////////////////////////////////////////////// +/// Set the string of a text (from a unicode string) +/// +/// \param text : Text to modify +/// \param string : New string +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_SetUnicodeString(sfText* text, const sfUint32* string); + +//////////////////////////////////////////////////////////// +/// Set the font of a text +/// +/// \param text : String to modify +/// \param font : Font to use +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_SetFont(sfText* text, const sfFont* font); + +//////////////////////////////////////////////////////////// +/// Set the size of a text +/// +/// \param text : String to modify +/// \param size : New size, in pixels +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_SetCharacterSize(sfText* text, unsigned int size); + +//////////////////////////////////////////////////////////// +/// Set the style of a text +/// +/// \param text : String to modify +/// \param style : New style (see sfTextStyle enum) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_SetStyle(sfText* text, unsigned long style); + +//////////////////////////////////////////////////////////// +/// Get the string of a text (returns a unicode string) +/// +/// \param text : String to read +/// +/// \return String as UTF-32 +/// +//////////////////////////////////////////////////////////// +CSFML_API const sfUint32* sfText_GetUnicodeString(const sfText* text); + +//////////////////////////////////////////////////////////// +/// Get the text of a text (returns an ANSI string) +/// +/// \param text : String to read +/// +/// \return String an a locale-dependant ANSI string +/// +//////////////////////////////////////////////////////////// +CSFML_API const char* sfText_GetString(const sfText* text); + +//////////////////////////////////////////////////////////// +/// Get the font used by a text +/// +/// \param text : String to read +/// +/// \return Pointer to the font +/// +//////////////////////////////////////////////////////////// +CSFML_API const sfFont* sfText_GetFont(const sfText* text); + +//////////////////////////////////////////////////////////// +/// Get the size of the characters of a text +/// +/// \param text : String to read +/// +/// \return Size of the characters +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfText_GetCharacterSize(const sfText* text); + +//////////////////////////////////////////////////////////// +/// Get the style of a text +/// +/// \param text : String to read +/// +/// \return Current string style (see sfTextStyle enum) +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned long sfText_GetStyle(const sfText* text); + +//////////////////////////////////////////////////////////// +/// Return the visual position of the Index-th character of the text, +/// in coordinates relative to the string +/// (note : translation, origin, rotation and scale are not applied) +/// +/// \param text : String to read +/// \param index : Index of the character +/// \param x : Value to fill with the X coordinate of the position +/// \param y : Value to fill with the y coordinate of the position +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfText_GetCharacterPos(const sfText* text, size_t index, float* x, float* y); + +//////////////////////////////////////////////////////////// +/// Get the bounding rectangle of a text on screen +/// +/// \param text : String to read +/// +/// \return Rectangle contaning the string in screen coordinates +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFloatRect sfText_GetRect(const sfText* text); + + +#endif // SFML_TEXT_H diff --git a/include/SFML/Graphics/Types.h b/include/SFML/Graphics/Types.h new file mode 100644 index 0000000..1c2cb62 --- /dev/null +++ b/include/SFML/Graphics/Types.h @@ -0,0 +1,40 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_GRAPHICS_TYPES_H +#define SFML_GRAPHICS_TYPES_H + + +typedef struct sfFont sfFont; +typedef struct sfImage sfImage; +typedef struct sfShader sfShader; +typedef struct sfRenderImage sfRenderImage; +typedef struct sfRenderWindow sfRenderWindow; +typedef struct sfShape sfShape; +typedef struct sfSprite sfSprite; +typedef struct sfText sfText; +typedef struct sfView sfView; + + +#endif // SFML_GRAPHICS_TYPES_H diff --git a/include/SFML/Graphics/View.h b/include/SFML/Graphics/View.h new file mode 100644 index 0000000..9ba811a --- /dev/null +++ b/include/SFML/Graphics/View.h @@ -0,0 +1,209 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_VIEW_H +#define SFML_VIEW_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a default view (1000x1000) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfView* sfView_Create(void); + +//////////////////////////////////////////////////////////// +/// Construct a view from a rectangle +/// +/// \param rectangle : Rectangle defining the bounds of the view +/// +//////////////////////////////////////////////////////////// +CSFML_API sfView* sfView_CreateFromRect(sfFloatRect rectangle); + +//////////////////////////////////////////////////////////// +/// Copy an existing view +/// +/// \param view : View to copy +/// +/// \return Copied object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfView* sfView_Copy(sfView* view); + +//////////////////////////////////////////////////////////// +/// Destroy an existing view +/// +/// \param view : View to destroy +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfView_Destroy(sfView* view); + +//////////////////////////////////////////////////////////// +/// Change the center of a view +/// +/// \param view : View to modify +/// \param x : X coordinate of the new center +/// \param y : Y coordinate of the new center +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfView_SetCenter(sfView* view, float x, float y); + +//////////////////////////////////////////////////////////// +/// Change the size of a view +/// +/// \param view : View to modify +/// \param width : New width +/// \param height : New height +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfView_SetSize(sfView* view, float width, float height); + +//////////////////////////////////////////////////////////// +/// Set the angle of rotation of a view +/// +/// \param view : View to modify +/// \param angle : New angle, in degrees +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfView_SetRotation(sfView* view, float angle); + +//////////////////////////////////////////////////////////// +/// Set the target viewport of a view +/// +/// The viewport is the rectangle into which the contents of the +/// view are displayed, expressed as a factor (between 0 and 1) +/// of the size of the RenderTarget to which the view is applied. +/// +/// \param view : View to modify +/// \param viewport : New viewport +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfView_SetViewport(sfView* view, sfFloatRect viewport); + +//////////////////////////////////////////////////////////// +/// Reset a view to the given rectangle. +/// Note: this function resets the rotation angle to 0. +/// +/// \param view : View to modify +/// \param rectangle : Rectangle defining the position and size of the view +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfView_Reset(sfView* view, sfFloatRect rectangle); + +//////////////////////////////////////////////////////////// +/// Get the X coordinate of the center of a view +/// +/// \param view : View to read +/// +/// \return X coordinate of the center of the view +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfView_GetCenterX(const sfView* view); + +//////////////////////////////////////////////////////////// +/// Get the Y coordinate of the center of a view +/// +/// \param view : View to read +/// +/// \return Y coordinate of the center of the view +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfView_GetCenterY(const sfView* view); + +//////////////////////////////////////////////////////////// +/// Get the width of the view +/// +/// \param view : View to read +/// +/// \return Width of the view +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfView_GetWidth(const sfView* view); + +//////////////////////////////////////////////////////////// +/// Get the height of the view +/// +/// \param view : View to read +/// +/// \return Height of the view +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfView_GetHeight(const sfView* view); + +//////////////////////////////////////////////////////////// +/// Get the current rotation of a view +/// +/// \param view : View to read +/// +/// \return Rotation of the view, in degrees +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfView_GetRotation(const sfView* view); + +//////////////////////////////////////////////////////////// +/// Get the target viewport of a view +/// +/// \param view : View to read +/// +/// \return Viewport rectangle, expressed as a factor of the target size +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFloatRect sfView_GetViewport(const sfView* view); + +//////////////////////////////////////////////////////////// +/// Move a view +/// +/// \param view : View to move +/// \param offsetX : Offset to move the view, on X axis +/// \param offsetY : Offset to move the view, on Y axis +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfView_Move(sfView* view, float offsetX, float offsetY); + +//////////////////////////////////////////////////////////// +/// Rotate a view +/// +/// \param view : View to rotate +/// \param angle : Angle in degrees +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfView_Rotate(sfView* view, float angle); + +//////////////////////////////////////////////////////////// +/// Resize a view rectangle to simulate a zoom / unzoom effect +/// +/// \param view : View to zoom +/// \param factor : Zoom factor to apply, relative to the current zoom +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfView_Zoom(sfView* view, float factor); + + +#endif // SFML_VIEW_H diff --git a/include/SFML/Network.h b/include/SFML/Network.h new file mode 100644 index 0000000..640af4c --- /dev/null +++ b/include/SFML/Network.h @@ -0,0 +1,41 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_NETWORK_H +#define SFML_NETWORK_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include + + +#endif // SFML_NETWORK_H diff --git a/include/SFML/Network/Ftp.h b/include/SFML/Network/Ftp.h new file mode 100644 index 0000000..05ee283 --- /dev/null +++ b/include/SFML/Network/Ftp.h @@ -0,0 +1,449 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_FTP_H +#define SFML_FTP_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Enumerate all the FTP file transfer modes +//////////////////////////////////////////////////////////// +enum sfFtpTransferMode +{ + sfFtpBinary, ///< Binary mode (file is transfered as a sequence of bytes) + sfFtpAscii, ///< Text mode using ASCII encoding + sfFtpEbcdic ///< Text mode using EBCDIC encoding +}; + + +//////////////////////////////////////////////////////////// +/// Enumerate all the valid status codes returned in +/// a FTP response +//////////////////////////////////////////////////////////// +enum sfFtpStatus +{ + // 1xx: the requested action is being initiated, + // expect another reply before proceeding with a new command + sfFtpRestartMarkerReply = 110, ///< Restart marker reply + sfFtpServiceReadySoon = 120, ///< Service ready in N minutes + sfFtpDataConnectionAlreadyOpened = 125, ///< Data connection already opened, transfer starting + sfFtpOpeningDataConnection = 150, ///< File status ok, about to open data connection + + // 2xx: the requested action has been successfully completed + sfFtpOk = 200, ///< Command ok + sfFtpPointlessCommand = 202, ///< Command not implemented + sfFtpSystemStatus = 211, ///< System status, or system help reply + sfFtpDirectoryStatus = 212, ///< Directory status + sfFtpFileStatus = 213, ///< File status + sfFtpHelpMessage = 214, ///< Help message + sfFtpSystemType = 215, ///< NAME system type, where NAME is an official system name from the list in the Assigned Numbers document + sfFtpServiceReady = 220, ///< Service ready for new user + sfFtpClosingConnection = 221, ///< Service closing control connection + sfFtpDataConnectionOpened = 225, ///< Data connection open, no transfer in progress + sfFtpClosingDataConnection = 226, ///< Closing data connection, requested file action successful + sfFtpEnteringPassiveMode = 227, ///< Entering passive mode + sfFtpLoggedIn = 230, ///< User logged in, proceed. Logged out if appropriate + sfFtpFileActionOk = 250, ///< Requested file action ok + sfFtpDirectoryOk = 257, ///< PATHNAME created + + // 3xx: the command has been accepted, but the requested action + // is dormant, pending receipt of further information + sfFtpNeedPassword = 331, ///< User name ok, need password + sfFtpNeedAccountToLogIn = 332, ///< Need account for login + sfFtpNeedInformation = 350, ///< Requested file action pending further information + + // 4xx: the command was not accepted and the requested action did not take place, + // but the error condition is temporary and the action may be requested again + sfFtpServiceUnavailable = 421, ///< Service not available, closing control connection + sfFtpDataConnectionUnavailable = 425, ///< Can't open data connection + sfFtpTransferAborted = 426, ///< Connection closed, transfer aborted + sfFtpFileActionAborted = 450, ///< Requested file action not taken + sfFtpLocalError = 451, ///< Requested action aborted, local error in processing + sfFtpInsufficientStorageSpace = 452, ///< Requested action not taken; insufficient storage space in system, file unavailable + + // 5xx: the command was not accepted and + // the requested action did not take place + sfFtpCommandUnknown = 500, ///< Syntax error, command unrecognized + sfFtpParametersUnknown = 501, ///< Syntax error in parameters or arguments + sfFtpCommandNotImplemented = 502, ///< Command not implemented + sfFtpBadCommandSequence = 503, ///< Bad sequence of commands + sfFtpParameterNotImplemented = 504, ///< Command not implemented for that parameter + sfFtpNotLoggedIn = 530, ///< Not logged in + sfFtpNeedAccountToStore = 532, ///< Need account for storing files + sfFtpFileUnavailable = 550, ///< Requested action not taken, file unavailable + sfFtpPageTypeUnknown = 551, ///< Requested action aborted, page type unknown + sfFtpNotEnoughMemory = 552, ///< Requested file action aborted, exceeded storage allocation + sfFtpFilenameNotAllowed = 553, ///< Requested action not taken, file name not allowed + + // 10xx: SFML custom codes + sfFtpInvalidResponse = 1000, ///< Response is not a valid FTP one + sfFtpConnectionFailed = 1001, ///< Connection with server failed + sfFtpConnectionClosed = 1002, ///< Connection with server closed + sfFtpInvalidFile = 1003 ///< Invalid file to upload / download +}; + + +//////////////////////////////////////////////////////////// +/// Destroy an existing Ftp listing response +/// +/// \param ftpListingResponse : Ftp listing response to destroy +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfFtpListingResponse_Destroy(sfFtpListingResponse* ftpListingResponse); + +//////////////////////////////////////////////////////////// +/// Convenience function to check if the response status code +/// means a success +/// +/// \param ftpListingResponse : Ftp listing response +/// +/// \return sfTrue if status is success (code < 400) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfFtpListingResponse_IsOk(const sfFtpListingResponse* ftpListingResponse); + +//////////////////////////////////////////////////////////// +/// Get the response status code +/// +/// \param ftpListingResponse : Ftp listing response +/// +/// \return Status code +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpStatus sfFtpListingResponse_GetStatus(const sfFtpListingResponse* ftpListingResponse); + +//////////////////////////////////////////////////////////// +/// Get the full message contained in the response +/// +/// \param ftpListingResponse : Ftp listing response +/// +/// \return The response message +/// +//////////////////////////////////////////////////////////// +CSFML_API const char* sfFtpListingResponse_GetMessage(const sfFtpListingResponse* ftpListingResponse); + +//////////////////////////////////////////////////////////// +/// Get the number of filenames in the listing +/// +/// \param ftpListingResponse : Ftp listing response +/// +/// \return Total number of filenames +/// +//////////////////////////////////////////////////////////// +CSFML_API size_t sfFtpListingResponse_GetCount(const sfFtpListingResponse* ftpListingResponse); + +//////////////////////////////////////////////////////////// +/// Get the Index-th filename in the directory +/// +/// \param ftpListingResponse : Ftp listing response +/// \param index : Index of the filename to get +/// +/// \return Index-th filename +/// +//////////////////////////////////////////////////////////// +CSFML_API const char* sfFtpListingResponse_GetFilename(const sfFtpListingResponse* ftpListingResponse, size_t index); + +//////////////////////////////////////////////////////////// +/// Destroy an existing Ftp directory response +/// +/// \param ftpDirectoryResponse : Ftp directory response to destroy +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfFtpDirectoryResponse_Destroy(sfFtpDirectoryResponse* ftpDirectoryResponse); + +//////////////////////////////////////////////////////////// +/// Convenience function to check if the response status code +/// means a success +/// +/// \param ftpDirectoryResponse : Ftp directory response +/// +/// \return sfTrue if status is success (code < 400) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfFtpDirectoryResponse_IsOk(const sfFtpDirectoryResponse* ftpDirectoryResponse); + +//////////////////////////////////////////////////////////// +/// Get the response status code +/// +/// \param ftpDirectoryResponse : Ftp directory response +/// +/// \return Status code +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpStatus sfFtpDirectoryResponse_GetStatus(const sfFtpDirectoryResponse* ftpDirectoryResponse); + +//////////////////////////////////////////////////////////// +/// Get the full message contained in the response +/// +/// \param ftpDirectoryResponse : Ftp directory response +/// +/// \return The response message +/// +//////////////////////////////////////////////////////////// +CSFML_API const char* sfFtpDirectoryResponse_GetMessage(const sfFtpDirectoryResponse* ftpDirectoryResponse); + +//////////////////////////////////////////////////////////// +/// Get the directory returned in the response +/// +/// \param ftpDirectoryResponse : Ftp directory response +/// +/// \return Directory name +/// +//////////////////////////////////////////////////////////// +CSFML_API const char* sfFtpDirectoryResponse_GetDirectory(const sfFtpDirectoryResponse* ftpDirectoryResponse); + + +//////////////////////////////////////////////////////////// +/// Destroy an existing Ftp response +/// +/// \param ftpResponse : Ftp response to destroy +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfFtpResponse_Destroy(sfFtpResponse* ftpResponse); + +//////////////////////////////////////////////////////////// +/// Convenience function to check if the response status code +/// means a success +/// +/// \param ftpResponse : Ftp response +/// +/// \return sfTrue if status is success (code < 400) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfFtpResponse_IsOk(const sfFtpResponse* ftpResponse); + +//////////////////////////////////////////////////////////// +/// Get the response status code +/// +/// \param ftpResponse : Ftp response +/// +/// \return Status code +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpStatus sfFtpResponse_GetStatus(const sfFtpResponse* ftpResponse); + +//////////////////////////////////////////////////////////// +/// Get the full message contained in the response +/// +/// \param ftpResponse : Ftp response +/// +/// \return The response message +/// +//////////////////////////////////////////////////////////// +CSFML_API const char* sfFtpResponse_GetMessage(const sfFtpResponse* ftpResponse); + +//////////////////////////////////////////////////////////// +/// Construct a new Ftp +/// +/// \return Pointer to the new Ftp +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtp* sfFtp_Create(void); + +//////////////////////////////////////////////////////////// +/// Destroy an existing Ftp +/// +/// \param ftp : Ftp to destroy +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfFtp_Destroy(sfFtp* ftp); + +//////////////////////////////////////////////////////////// +/// Connect to the specified FTP server +/// +/// \param ftp : Ftp instance +/// \param server : FTP server to connect to +/// \param port : Port used for connection (21 by default, standard FTP port) +/// \param timeout : Maximum time to wait, in milliseconds (0 to use no timeout) +/// +/// \return Server response to the request +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpResponse* sfFtp_Connect(sfFtp* ftp, sfIpAddress server, unsigned short port, sfUint32 timeout); + +//////////////////////////////////////////////////////////// +/// Log in using anonymous account +/// +/// \param ftp : Ftp instance +/// +/// \return Server response to the request +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpResponse* sfFtp_LoginAnonymous(sfFtp* ftp); + +//////////////////////////////////////////////////////////// +/// Log in using a username and a password +/// +/// \param ftp : Ftp instance +/// \param userName : User name +/// \param password : Password +/// +/// \return Server response to the request +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpResponse* sfFtp_Login(sfFtp* ftp, const char* userName, const char* password); + +//////////////////////////////////////////////////////////// +/// Close the connection with FTP server +/// +/// \param ftp : Ftp instance +/// +/// \return Server response to the request +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpResponse* sfFtp_Disconnect(sfFtp* ftp); + +//////////////////////////////////////////////////////////// +/// Send a null command just to prevent from being disconnected +/// +/// \param ftp : Ftp instance +/// +/// \return Server response to the request +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpResponse* sfFtp_KeepAlive(sfFtp* ftp); + +//////////////////////////////////////////////////////////// +/// Get the current working directory +/// +/// \param ftp : Ftp instance +/// +/// \return Server response to the request +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpDirectoryResponse* sfFtp_GetWorkingDirectory(sfFtp* ftp); + +//////////////////////////////////////////////////////////// +/// Get the contents of the given directory +/// (subdirectories and files) +/// +/// \param ftp : Ftp instance +/// \param directory : Directory to list ("" by default, the current one) +/// +/// \return Server response to the request +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpListingResponse* sfFtp_GetDirectoryListing(sfFtp* ftp, const char* directory); + +//////////////////////////////////////////////////////////// +/// Change the current working directory +/// +/// \param ftp : Ftp instance +/// \param directory : New directory, relative to the current one +/// +/// \return Server response to the request +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpResponse* sfFtp_ChangeDirectory(sfFtp* ftp, const char* directory); + +//////////////////////////////////////////////////////////// +/// Go to the parent directory of the current one +/// +/// \param ftp : Ftp instance +/// +/// \return Server response to the request +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpResponse* sfFtp_ParentDirectory(sfFtp* ftp); + +//////////////////////////////////////////////////////////// +/// Create a new directory +/// +/// \param ftp : Ftp instance +/// \param name : Name of the directory to create +/// +/// \return Server response to the request +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpResponse* sfFtp_CreateDirectory(sfFtp* ftp, const char* name); + +//////////////////////////////////////////////////////////// +/// Remove an existing directory +/// +/// \param ftp : Ftp instance +/// \param name : Name of the directory to remove +/// +/// \return Server response to the request +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpResponse* sfFtp_DeleteDirectory(sfFtp* ftp, const char* name); + +//////////////////////////////////////////////////////////// +/// Rename a file +/// +/// \param ftp : Ftp instance +/// \param file : File to rename +/// \param newName : New name +/// +/// \return Server response to the request +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpResponse* sfFtp_RenameFile(sfFtp* ftp, const char* file, const char* newName); + +//////////////////////////////////////////////////////////// +/// Remove an existing file +/// +/// \param ftp : Ftp instance +/// \param name : File to remove +/// +/// \return Server response to the request +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpResponse* sfFtp_DeleteFile(sfFtp* ftp, const char* name); + +//////////////////////////////////////////////////////////// +/// Download a file from the server +/// +/// \param ftp : Ftp instance +/// \param distantFile : Path of the distant file to download +/// \param destPath : Where to put to file on the local computer +/// \param mode : Transfer mode (binary by default) +/// +/// \return Server response to the request +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpResponse* sfFtp_Download(sfFtp* ftp, const char* distantFile, const char* destPath, sfFtpTransferMode mode); + +//////////////////////////////////////////////////////////// +/// Upload a file to the server +/// +/// \param ftp : Ftp instance +/// \param localFile : Path of the local file to upload +/// \param destPath : Where to put to file on the server +/// \param mode : Transfer mode (binary by default) +/// +/// \return Server response to the request +/// +//////////////////////////////////////////////////////////// +CSFML_API sfFtpResponse* sfFtp_Upload(sfFtp* ftp, const char* localFile, const char* destPath, sfFtpTransferMode mode); + + +#endif // SFML_FTP_H diff --git a/include/SFML/Network/Http.h b/include/SFML/Network/Http.h new file mode 100644 index 0000000..2cb8468 --- /dev/null +++ b/include/SFML/Network/Http.h @@ -0,0 +1,257 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_HTTP_H +#define SFML_HTTP_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +/// Enumerate the available HTTP methods for a request +//////////////////////////////////////////////////////////// +enum sfHttpMethod +{ + sfHttpGet, ///< Request in get mode, standard method to retrieve a page + sfHttpPost, ///< Request in post mode, usually to send data to a page + sfHttpHead ///< Request a page's header only +}; + + +//////////////////////////////////////////////////////////// +/// Enumerate all the valid status codes returned in +/// a HTTP response +//////////////////////////////////////////////////////////// +enum sfHttpStatus +{ + // 2xx: success + sfHttpOk = 200, ///< Most common code returned when operation was successful + sfHttpCreated = 201, ///< The resource has successfully been created + sfHttpAccepted = 202, ///< The request has been accepted, but will be processed later by the server + sfHttpNoContent = 204, ///< Sent when the server didn't send any data in return + + // 3xx: redirection + sfHttpMultipleChoices = 300, ///< The requested page can be accessed from several locations + sfHttpMovedPermanently = 301, ///< The requested page has permanently moved to a new location + sfHttpMovedTemporarily = 302, ///< The requested page has temporarily moved to a new location + sfHttpNotModified = 304, ///< For conditionnal requests, means the requested page hasn't changed and doesn't need to be refreshed + + // 4xx: client error + sfHttpBadRequest = 400, ///< The server couldn't understand the request (syntax error) + sfHttpUnauthorized = 401, ///< The requested page needs an authentification to be accessed + sfHttpForbidden = 403, ///< The requested page cannot be accessed at all, even with authentification + sfHttpNotFound = 404, ///< The requested page doesn't exist + + // 5xx: server error + sfHttpInternalServerError = 500, ///< The server encountered an unexpected error + sfHttpNotImplemented = 501, ///< The server doesn't implement a requested feature + sfHttpBadGateway = 502, ///< The gateway server has received an error from the source server + sfHttpServiceNotAvailable = 503, ///< The server is temporarily unavailable (overloaded, in maintenance, ...) + + // 10xx: SFML custom codes + sfHttpInvalidResponse = 1000, ///< Response is not a valid HTTP one + sfHttpConnectionFailed = 1001 ///< Connection with server failed +}; + + +//////////////////////////////////////////////////////////// +/// Construct a new Http request +/// +/// \return Pointer to the new Http request +/// +//////////////////////////////////////////////////////////// +CSFML_API sfHttpRequest* sfHttpRequest_Create(void); + +//////////////////////////////////////////////////////////// +/// Destroy an existing Http request +/// +/// \param httpRequest : Http request to destroy +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfHttpRequest_Destroy(sfHttpRequest* httpRequest); + +//////////////////////////////////////////////////////////// +/// Set the value of a field; the field is added if it doesn't exist +/// +/// \param httpRequest : Http request to modify +/// \param field : Name of the field to set (case-insensitive) +/// \param value : Value of the field +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfHttpRequest_SetField(sfHttpRequest* httpRequest, const char* field, const char* value); + +//////////////////////////////////////////////////////////// +/// Set the request method. +/// This parameter is sfHttpGet by default +/// +/// \param httpRequest : Http request to modify +/// \param method : Method to use for the request +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfHttpRequest_SetMethod(sfHttpRequest* httpRequest, sfHttpMethod method); + +//////////////////////////////////////////////////////////// +/// Set the target URI of the request. +/// This parameter is "/" by default +/// +/// \param httpRequest : Http request to modify +/// \param URI : URI to request, local to the host +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfHttpRequest_SetUri(sfHttpRequest* httpRequest, const char* uri); + +//////////////////////////////////////////////////////////// +/// Set the HTTP version of the request. +/// This parameter is 1.0 by default +/// +/// \param httpRequest : Http request to modify +/// \param major : Major version number +/// \param minor : Minor version number +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfHttpRequest_SetHttpVersion(sfHttpRequest* httpRequest, unsigned int major, unsigned int minor); + +//////////////////////////////////////////////////////////// +/// Set the body of the request. This parameter is optional and +/// makes sense only for POST requests. +/// This parameter is empty by default +/// +/// \param httpRequest : Http request to modify +/// \param body : Content of the request body +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfHttpRequest_SetBody(sfHttpRequest* httpRequest, const char* body); + +//////////////////////////////////////////////////////////// +/// Destroy an existing Http response +/// +/// \param httpResponse : Http response to destroy +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfHttpResponse_Destroy(sfHttpResponse* httpResponse); + +//////////////////////////////////////////////////////////// +/// Get the value of a field; returns NULL if the field doesn't exist +/// +/// \param httpResponse : Http response +/// \param field : Field to get +/// +/// \return Value of the field (NULL if it doesn't exist) +/// +//////////////////////////////////////////////////////////// +CSFML_API const char* sfHttpResponse_GetField(const sfHttpResponse* httpResponse, const char* field); + +//////////////////////////////////////////////////////////// +/// Get the status of a response +/// +/// \param httpResponse : Http response +/// +/// \return Status of the response +/// +//////////////////////////////////////////////////////////// +CSFML_API sfHttpStatus sfHttpResponse_GetStatus(const sfHttpResponse* httpResponse); + +//////////////////////////////////////////////////////////// +/// Get the major HTTP version of a response +/// +/// \param httpResponse : Http response +/// +/// \return HTTP major version of the response +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfHttpResponse_GetMajorVersion(const sfHttpResponse* httpResponse); + +//////////////////////////////////////////////////////////// +/// Get the minor HTTP version of a response +/// +/// \param httpResponse : Http response +/// +/// \return HTTP minor version of the response +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfHttpResponse_GetMinorVersion(const sfHttpResponse* httpResponse); + +//////////////////////////////////////////////////////////// +/// Get the body of the response. The body can contain : +/// - the requested page (for GET requests) +/// - a response from the server (for POST requests) +/// - nothing (for HEAD requests) +/// - an error message (in case of an error) +/// +/// \param httpResponse : Http response +/// +/// \return Body of the response (empty string if no body) +/// +//////////////////////////////////////////////////////////// +CSFML_API const char* sfHttpResponse_GetBody(const sfHttpResponse* httpResponse); + +//////////////////////////////////////////////////////////// +/// Construct a new Http object +/// +/// \return Pointer to the new Http +/// +//////////////////////////////////////////////////////////// +CSFML_API sfHttp* sfHttp_Create(void); + +//////////////////////////////////////////////////////////// +/// Destroy an existing Http object +/// +/// \param Http : Http to destroy +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfHttp_Destroy(sfHttp* http); + +//////////////////////////////////////////////////////////// +/// Set the target host of a Http server +/// +/// \param http : Http object +/// \param host : Web server to connect to +/// \param port : Port to use for connection (0 to use the standard port of the protocol used) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfHttp_SetHost(sfHttp* http, const char* host, unsigned short port); + +//////////////////////////////////////////////////////////// +/// Send a HTTP request and return the server's response. +/// You must be connected to a host before sending requests. +/// Any missing mandatory header field will be added with an appropriate value. +/// Warning : this function waits for the server's response and may +/// not return instantly; use a thread if you don't want to block your +/// application. +/// +/// \param http : Http object +/// \param request : Request to send +/// \param timeout : Maximum time to wait, in milliseconds (0 to use no timeout) +/// +/// \return Server's response, or NULL if request is invalid +/// +//////////////////////////////////////////////////////////// +CSFML_API sfHttpResponse* sfHttp_SendRequest(sfHttp* http, const sfHttpRequest* request, sfUint32 timeout); + + +#endif // SFML_HTTP_H diff --git a/include/SFML/Network/IpAddress.h b/include/SFML/Network/IpAddress.h new file mode 100644 index 0000000..5571a22 --- /dev/null +++ b/include/SFML/Network/IpAddress.h @@ -0,0 +1,131 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_IPADDRESS_H +#define SFML_IPADDRESS_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// sfIpAddress provides easy manipulation of IP v4 addresses +//////////////////////////////////////////////////////////// +typedef struct +{ + char Address[16]; +} sfIpAddress; + + +//////////////////////////////////////////////////////////// +/// Construct an address from a string +/// +/// \param string : IP address ("xxx.xxx.xxx.xxx") or network name +/// +/// \return Resulting address +/// +//////////////////////////////////////////////////////////// +CSFML_API sfIpAddress sfIpAddress_FromString(const char* string); + +//////////////////////////////////////////////////////////// +/// Construct an address from 4 bytes +/// +/// \param byte0 : First byte of the address +/// \param byte1 : Second byte of the address +/// \param byte2 : Third byte of the address +/// \param byte3 : Fourth byte of the address +/// +/// \return Resulting address +/// +//////////////////////////////////////////////////////////// +CSFML_API sfIpAddress sfIpAddress_FromBytes(sfUint8 byte0, sfUint8 byte1, sfUint8 byte2, sfUint8 byte3); + +//////////////////////////////////////////////////////////// +/// Construct the address from a 32-bits integer +/// +/// \param address : 4 bytes of the address packed into a 32-bits integer +/// +//////////////////////////////////////////////////////////// +CSFML_API sfIpAddress sfIpAddress_FromInteger(sfUint32 address); + +//////////////////////////////////////////////////////////// +/// Get a string representation of an address +/// +/// \param address : Address to convert +/// \param string : Char array to fill (size must be >= 16) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfIpAddress_ToString(sfIpAddress address, char* string); + +//////////////////////////////////////////////////////////// +/// Get an integer representation of the address +/// +/// \param address : Address to convert +/// +/// \return 32-bits integer containing the 4 bytes of the address, in system endianness +/// +//////////////////////////////////////////////////////////// +CSFML_API sfUint32 sfIpAddress_ToInteger(sfIpAddress address); + +//////////////////////////////////////////////////////////// +/// Get the computer's local IP address (from the LAN point of view) +/// +/// \return Local IP address +/// +//////////////////////////////////////////////////////////// +CSFML_API sfIpAddress sfIpAddress_GetLocalAddress(void); + +//////////////////////////////////////////////////////////// +/// Get the computer's public IP address (from the web point of view). +/// The only way to get a public address is to ask it to a +/// distant website ; as a consequence, this function may be +/// very slow -- use it as few as possible ! +/// +/// \param timeout : Maximum time to wait, in milliseconds (use 0 for no timeout) +/// +/// \return Public IP address +/// +//////////////////////////////////////////////////////////// +CSFML_API sfIpAddress sfIpAddress_GetPublicAddress(sfUint32 timeout); + +//////////////////////////////////////////////////////////// +/// Get the computer's loopback address +/// +/// \return Local host IP address (127.0.0.1, or "localhost") +/// +//////////////////////////////////////////////////////////// +CSFML_API sfIpAddress sfIpAddress_LocalHost(void); + +//////////////////////////////////////////////////////////// +/// Get the empty/invalid address +/// +/// \return Empty object that represents invalid addresses +/// +//////////////////////////////////////////////////////////// +CSFML_API sfIpAddress sfIpAddress_None(void); + + +#endif // SFML_IPADDRESS_H diff --git a/include/SFML/Network/Packet.h b/include/SFML/Network/Packet.h new file mode 100644 index 0000000..15ddc2f --- /dev/null +++ b/include/SFML/Network/Packet.h @@ -0,0 +1,158 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_PACKET_H +#define SFML_PACKET_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new empty packet +/// +/// \return A new sfPacket object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfPacket* sfPacket_Create(void); + +//////////////////////////////////////////////////////////// +/// Copy an existing packet +/// +/// \param packet : Packet to copy +/// +/// \return Copied object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfPacket* sfPacket_Copy(sfPacket* packet); + +//////////////////////////////////////////////////////////// +/// Destroy an existing packet +/// +/// \param packet : Packet to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfPacket_Destroy(sfPacket* packet); + +//////////////////////////////////////////////////////////// +/// Append data to the end of a packet +/// +/// \param packet : Packet to fill +/// \param data : Pointer to the bytes to append +/// \param sizeInBytes : Number of bytes to append +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfPacket_Append(sfPacket* packet, const void* data, size_t sizeInBytes); + +//////////////////////////////////////////////////////////// +/// Clear all the data of a packet +/// +/// \param packet : Packet to clear +/// +/////////////////////////////////////////////////////////// +CSFML_API void sfPacket_Clear(sfPacket* packet); + +//////////////////////////////////////////////////////////// +/// Get a pointer to the data contained in a packet +/// Warning : the returned pointer may be invalid after you +/// append data to the packet +/// +/// \param packet : Packet to get data from +/// +/// \return Pointer to the data +/// +//////////////////////////////////////////////////////////// +CSFML_API const char* sfPacket_GetData(const sfPacket* packet); + +//////////////////////////////////////////////////////////// +/// Get the size of the data contained in a packet +/// +/// \param packet : Packet to get data size from +/// +/// \return Data size, in bytes +/// +//////////////////////////////////////////////////////////// +CSFML_API size_t sfPacket_GetDataSize(const sfPacket* packet); + +//////////////////////////////////////////////////////////// +/// Tell if the reading position has reached the end of the packet +/// +/// \param packet : Packet to check +/// +/// \return sfTrue if all data have been read into the packet +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfPacket_EndOfPacket(const sfPacket* packet); + +//////////////////////////////////////////////////////////// +/// Return the validity of packet +/// +/// \param packet : Packet to check +/// +/// \return sfTrue if last data extraction from packet was successful +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfPacket_CanRead(const sfPacket* packet); + +//////////////////////////////////////////////////////////// +/// Functions to extract data from a packet +/// +/// \param packet : Packet to read +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfPacket_ReadBool(sfPacket* packet); +CSFML_API sfInt8 sfPacket_ReadInt8(sfPacket* packet); +CSFML_API sfUint8 sfPacket_ReadUint8(sfPacket* packet); +CSFML_API sfInt16 sfPacket_ReadInt16(sfPacket* packet); +CSFML_API sfUint16 sfPacket_ReadUint16(sfPacket* packet); +CSFML_API sfInt32 sfPacket_ReadInt32(sfPacket* packet); +CSFML_API sfUint32 sfPacket_ReadUint32(sfPacket* packet); +CSFML_API float sfPacket_ReadFloat(sfPacket* packet); +CSFML_API double sfPacket_ReadDouble(sfPacket* packet); +CSFML_API void sfPacket_ReadString(sfPacket* packet, char* string); +CSFML_API void sfPacket_ReadWideString(sfPacket* packet, wchar_t* string); + +//////////////////////////////////////////////////////////// +/// Functions to insert data into a packet +/// +/// \param packet : Packet to write +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfPacket_WriteBool(sfPacket* packet, sfBool); +CSFML_API void sfPacket_WriteInt8(sfPacket* packet, sfInt8); +CSFML_API void sfPacket_WriteUint8(sfPacket* packet, sfUint8); +CSFML_API void sfPacket_WriteInt16(sfPacket* packet, sfInt16); +CSFML_API void sfPacket_WriteUint16(sfPacket* packet, sfUint16); +CSFML_API void sfPacket_WriteInt32(sfPacket* packet, sfInt32); +CSFML_API void sfPacket_WriteUint32(sfPacket* packet, sfUint32); +CSFML_API void sfPacket_WriteFloat(sfPacket* packet, float); +CSFML_API void sfPacket_WriteDouble(sfPacket* packet, double); +CSFML_API void sfPacket_WriteString(sfPacket* packet, const char* string); +CSFML_API void sfPacket_WriteWideString(sfPacket* packet, const wchar_t* string); + + +#endif // SFML_PACKET_H diff --git a/include/SFML/Network/SocketSelector.h b/include/SFML/Network/SocketSelector.h new file mode 100644 index 0000000..10fe73f --- /dev/null +++ b/include/SFML/Network/SocketSelector.h @@ -0,0 +1,118 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SOCKETSELECTOR_H +#define SFML_SOCKETSELECTOR_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new selector +/// +/// \return A new sfSelector object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSocketSelector* sfSocketSelector_Create(void); + +//////////////////////////////////////////////////////////// +/// Copy an existing selector +/// +/// \param selector : Selector to copy +/// +/// \return Copied object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSocketSelector* sfSocketSelector_Copy(sfSocketSelector* selector); + +//////////////////////////////////////////////////////////// +/// Destroy an existing selector +/// +/// \param selector : Selector to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSocketSelector_Destroy(sfSocketSelector* selector); + +//////////////////////////////////////////////////////////// +/// Add a socket to watch to a selector +/// +/// \param selector : Selector to add the socket to +/// \param socket : Socket to add +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSocketSelector_AddTcpListener(sfSocketSelector* selector, sfTcpListener* socket); +CSFML_API void sfSocketSelector_AddTcpSocket(sfSocketSelector* selector, sfTcpSocket* socket); +CSFML_API void sfSocketSelector_AddUdpSocket(sfSocketSelector* selector, sfUdpSocket* socket); + +//////////////////////////////////////////////////////////// +/// Remove a socket from a selector +/// +/// \param selector : Selector to remove the socket from +/// \param socket : Socket to remove +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSocketSelector_RemoveTcpListener(sfSocketSelector* selector, sfTcpListener* socket); +CSFML_API void sfSocketSelector_RemoveTcpSocket(sfSocketSelector* selector, sfTcpSocket* socket); +CSFML_API void sfSocketSelector_RemoveUdpSocket(sfSocketSelector* selector, sfUdpSocket* socket); + +//////////////////////////////////////////////////////////// +/// Remove all sockets from a selector +/// +/// \param selector : Selector to remove the socket from +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSocketSelector_Clear(sfSocketSelector* selector); + +//////////////////////////////////////////////////////////// +/// Wait and collect sockets which are ready for reading. +/// This functions will return either when at least one socket +/// is ready, or when the given timeout is over +/// +/// \param selector : Selector to check +/// \param timeout : Maximum time to wait, in milliseconds (0 to disable timeout) +/// +/// \return sfTrue if there are sockets ready, sfFalse otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfSocketSelector_Wait(sfSocketSelector* selector, sfUint32 timeout); + +//////////////////////////////////////////////////////////// +/// Test a socket to know if it is ready to receive data +/// +/// \param selector : Selector to check +/// \param socket : Socket to test +/// +/// \return sfTrue if the socket is ready to receive data +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfSocketSelector_IsTcpListenerReady(const sfSocketSelector* selector, sfTcpListener* socket); +CSFML_API sfBool sfSocketSelector_IsTcpSocketReady(const sfSocketSelector* selector, sfTcpSocket* socket); +CSFML_API sfBool sfSocketSelector_IsUdpSocketReady(const sfSocketSelector* selector, sfUdpSocket* socket); + + +#endif // SFML_SOCKETSELECTOR_H diff --git a/include/SFML/Network/SocketStatus.h b/include/SFML/Network/SocketStatus.h new file mode 100644 index 0000000..b810148 --- /dev/null +++ b/include/SFML/Network/SocketStatus.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SOCKETSTATUS_H +#define SFML_SOCKETSTATUS_H + + +//////////////////////////////////////////////////////////// +/// Define the status that can be returned by the socket +/// functions +//////////////////////////////////////////////////////////// +typedef enum +{ + sfSocketDone, + sfSocketNotReady, + sfSocketDisconnected, + sfSocketError + +} sfSocketStatus; + + +#endif // SFML_SOCKETSTATUS_H diff --git a/include/SFML/Network/TcpListener.h b/include/SFML/Network/TcpListener.h new file mode 100644 index 0000000..5af2a87 --- /dev/null +++ b/include/SFML/Network/TcpListener.h @@ -0,0 +1,97 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_TCPLISTENER_H +#define SFML_TCPLISTENER_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new TCP socket +/// +/// \return Pointer to the new socket +/// +//////////////////////////////////////////////////////////// +CSFML_API sfTcpListener* sfTcpListener_Create(void); + +//////////////////////////////////////////////////////////// +/// Destroy an existing TCP socket +/// +/// \param socket : Socket to destroy +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfTcpListener_Destroy(sfTcpListener* socket); + +//////////////////////////////////////////////////////////// +/// Change the blocking state of a TCP socket. +/// The default behaviour of a socket is blocking +/// +/// \param socket : Socket to modify +/// \param blocking : Pass sfTrue to set the socket as blocking, or sfFalse for non-blocking +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfTcpListener_SetBlocking(sfTcpListener* socket, sfBool blocking); + +//////////////////////////////////////////////////////////// +/// Get the blocking state of the socket +/// +/// \param socket : Socket to read +/// +/// \Return sfTrue if the socket is blocking, sfFalse otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfTcpListener_IsBlocking(const sfTcpListener* socket); + +//////////////////////////////////////////////////////////// +/// Listen to a specified port for incoming data or connections +/// +/// \param socket : Socket to use for listening +/// \param port : Port to listen to +/// +/// \return Socket status +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSocketStatus sfTcpListener_Listen(sfTcpListener* socket, unsigned short port); + +//////////////////////////////////////////////////////////// +/// Wait for a connection (must be listening to a port). +/// This function is blocking, ie. it won't return before +/// a connection has been accepted +/// +/// \param socket : Socket to use for accepting +/// \param connected : Pointer to a socket pointer that will be filled with the connected client +/// +/// \return Socket status +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSocketStatus sfTcpListener_Accept(sfTcpListener* socket, sfTcpSocket** connected); + + +#endif // SFML_TCPLISTENER_H diff --git a/include/SFML/Network/TcpSocket.h b/include/SFML/Network/TcpSocket.h new file mode 100644 index 0000000..bea3486 --- /dev/null +++ b/include/SFML/Network/TcpSocket.h @@ -0,0 +1,172 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_TCPSOCKET_H +#define SFML_TCPSOCKET_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new TCP socket +/// +/// \return Pointer to the new socket +/// +//////////////////////////////////////////////////////////// +CSFML_API sfTcpSocket* sfTcpSocket_Create(void); + +//////////////////////////////////////////////////////////// +/// Destroy an existing TCP socket +/// +/// \param socket : Socket to destroy +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfTcpSocket_Destroy(sfTcpSocket* socket); + +//////////////////////////////////////////////////////////// +/// Change the blocking state of a TCP socket. +/// The default behaviour of a socket is blocking +/// +/// \param socket : Socket to modify +/// \param blocking : Pass sfTrue to set the socket as blocking, or false for non-blocking +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfTcpSocket_SetBlocking(sfTcpSocket* socket, sfBool blocking); + +//////////////////////////////////////////////////////////// +/// Get the blocking state of the socket +/// +/// \param socket : Socket to read +/// +/// \Return sfTrue if the socket is blocking, sfFalse otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfTcpSocket_IsBlocking(const sfTcpSocket* socket); + +//////////////////////////////////////////////////////////// +/// Get the port to which a socket is bound locally +/// +/// \param socket : Socket to read +/// +/// \return Port to which the socket is bound +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned short sfTcpSocket_GetLocalPort(const sfTcpSocket* socket); + +//////////////////////////////////////////////////////////// +/// Get the address of the connected peer of a socket +/// +/// \param socket : Socket to read +/// +/// \return Address of the remote peer +/// +//////////////////////////////////////////////////////////// +CSFML_API sfIpAddress sfTcpSocket_GetRemoteAddress(const sfTcpSocket* socket); + +//////////////////////////////////////////////////////////// +/// Get the port of the connected peer to which a socket is connected +/// +/// \param socket : Socket to read +/// +/// \return Remote port to which the socket is connected +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned short sfTcpSocket_GetRemotePort(const sfTcpSocket* socket); + +//////////////////////////////////////////////////////////// +/// Connect a TCP socket to another computer on a specified port +/// +/// \param socket : Socket to connect +/// \param host : IP Address of the host to connect to +/// \param port : Port to use for transfers (warning : ports < 1024 are reserved) +/// \param timeout : Maximum time to wait, in milliseconds (0 to use no timeout) +/// +/// \return sfTrue if operation has been successful +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSocketStatus sfTcpSocket_Connect(sfTcpSocket* socket, sfIpAddress host, unsigned short port, sfUint32 timeout); + +//////////////////////////////////////////////////////////// +/// Disconnect a connect from its remote peer +/// +/// \param socket : Socket to disconnect +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfTcpSocket_Disconnect(sfTcpSocket* socket); + +//////////////////////////////////////////////////////////// +/// Send an array of bytes to the host (must be connected first) +/// +/// \param socket : Socket to use for sending +/// \param data : Pointer to the bytes to send +/// \param size : Number of bytes to send +/// +/// \return Socket status +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSocketStatus sfTcpSocket_Send(sfTcpSocket* socket, const char* data, size_t size); + +//////////////////////////////////////////////////////////// +/// Receive an array of bytes from the host (must be connected first) +/// +/// \param socket : Socket to use for receiving +/// \param data : Pointer to a byte array to fill (make sure it is big enough) +/// \param maxSize : Maximum number of bytes to read +/// \param sizeReceived : Number of bytes received +/// +/// \return Socket status +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSocketStatus sfTcpSocket_Receive(sfTcpSocket* socket, char* data, size_t maxSize, size_t* sizeReceived); + +//////////////////////////////////////////////////////////// +/// Send a packet of data to the host (must be connected first) +/// +/// \param socket : Socket to use for sending +/// \param packet : Packet to send +/// +/// \return Socket status +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSocketStatus sfTcpSocket_SendPacket(sfTcpSocket* socket, sfPacket* packet); + +//////////////////////////////////////////////////////////// +/// Receive a packet from the host (must be connected first) +/// +/// \param socket : Socket to use for receiving +/// \param packet : Packet to fill with received data +/// +/// \return Socket status +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSocketStatus sfTcpSocket_ReceivePacket(sfTcpSocket* socket, sfPacket* packet); + + +#endif // SFML_TCPSOCKET_H diff --git a/include/SFML/Network/Types.h b/include/SFML/Network/Types.h new file mode 100644 index 0000000..ca28150 --- /dev/null +++ b/include/SFML/Network/Types.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_NETWORK_TYPES_H +#define SFML_NETWORK_TYPES_H + + +typedef struct sfFtpDirectoryResponse sfFtpDirectoryResponse; +typedef struct sfFtpListingResponse sfFtpListingResponse; +typedef struct sfFtpResponse sfFtpResponse; +typedef struct sfFtp sfFtp; +typedef struct sfHttpRequest sfHttpRequest; +typedef struct sfHttpResponse sfHttpResponse; +typedef struct sfHttp sfHttp; +typedef struct sfPacket sfPacket; +typedef struct sfSocketSelector sfSocketSelector; +typedef struct sfTcpListener sfTcpListener; +typedef struct sfTcpSocket sfTcpSocket; +typedef struct sfUdpSocket sfUdpSocket; + + +#endif // SFML_NETWORK_TYPES_H diff --git a/include/SFML/Network/UdpSocket.h b/include/SFML/Network/UdpSocket.h new file mode 100644 index 0000000..3badf25 --- /dev/null +++ b/include/SFML/Network/UdpSocket.h @@ -0,0 +1,162 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_UDPSOCKET_H +#define SFML_UDPSOCKET_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new UDP socket +/// +/// \return Pointer to the new socket +/// +//////////////////////////////////////////////////////////// +CSFML_API sfUdpSocket* sfUdpSocket_Create(void); + +//////////////////////////////////////////////////////////// +/// Destroy an existing UDP socket +/// +/// \param socket : Socket to destroy +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfUdpSocket_Destroy(sfUdpSocket* socket); + +//////////////////////////////////////////////////////////// +/// Change the blocking state of a UDP socket. +/// The default behaviour of a socket is blocking +/// +/// \param socket : Socket to modify +/// \param blocking : Pass sfTrue to set the socket as blocking, or false for non-blocking +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfUdpSocket_SetBlocking(sfUdpSocket* socket, sfBool blocking); + +//////////////////////////////////////////////////////////// +/// Get the blocking state of the socket +/// +/// \param socket : Socket to read +/// +/// \Return sfTrue if the socket is blocking, sfFalse otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfUdpSocket_IsBlocking(const sfUdpSocket* socket); + +//////////////////////////////////////////////////////////// +/// Get the port to which a socket is bound locally +/// +/// \param socket : Socket to read +/// +/// \return Port to which the socket is bound +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned short sfUdpSocket_GetLocalPort(const sfUdpSocket* socket); + +//////////////////////////////////////////////////////////// +/// Bind a socket to a specific port +/// +/// \param socket : Socket to bind +/// \param port : Port to bind the socket to +/// +/// \return Socket status +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSocketStatus sfUdpSocket_Bind(sfUdpSocket* socket, unsigned short port); + +//////////////////////////////////////////////////////////// +/// Unbind a socket from its previous port, if any +/// +/// \param socket : Socket to unbind +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfUdpSocket_Unbind(sfUdpSocket* socket); + +//////////////////////////////////////////////////////////// +/// Send an array of bytes +/// +/// \param socket : Socket to use for sending +/// \param data : Pointer to the bytes to send +/// \param size : Number of bytes to send +/// \param address : Address of the computer to send the packet to +/// \param port : Port to use for communication +/// +/// \return Socket status +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSocketStatus sfUdpSocket_Send(sfUdpSocket* socket, const char* data, size_t size, sfIpAddress address, unsigned short port); + +//////////////////////////////////////////////////////////// +/// Receive an array of bytes. +/// This function is blocking, ie. it won't return before some +/// bytes have been received +/// +/// \param socket : Socket to use for receiving +/// \param data : Pointer to a byte array to fill (make sure it is big enough) +/// \param maxSize : Maximum number of bytes to read +/// \param sizeReceived : Number of bytes received +/// \param address : Address of the computer which sent the data +/// \param port : Port on which the remote computer sent the data +/// +/// \return Socket status +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSocketStatus sfUdpSocket_Receive(sfUdpSocket* socket, char* data, size_t maxSize, size_t* sizeReceived, sfIpAddress* address, unsigned short* port); + +//////////////////////////////////////////////////////////// +/// Send a packet of data +/// +/// \param socket : Socket to use for sending +/// \param packet : Packet to send +/// \param address : Address of the computer to send the packet to +/// \param port : Port to use for communication +/// +/// \return Socket status +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSocketStatus sfUdpSocket_SendPacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress address, unsigned short port); + +//////////////////////////////////////////////////////////// +/// Receive a packet. +/// This function is blocking, ie. it won't return before a +/// packet is received +/// +/// \param socket : Socket to use for receiving +/// \param packet : Packet to fill with received data +/// \param address : Address of the computer which sent the packet +/// \param port : Port on which the remote computer sent the data +/// +/// \return Socket status +/// +//////////////////////////////////////////////////////////// +CSFML_API sfSocketStatus sfUdpSocket_ReceivePacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress* address, unsigned short* port); + + +#endif // SFML_UDPSOCKET_H diff --git a/include/SFML/OpenGL.h b/include/SFML/OpenGL.h new file mode 100644 index 0000000..2f4e8b7 --- /dev/null +++ b/include/SFML/OpenGL.h @@ -0,0 +1,58 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_OPENGL_H +#define SFML_OPENGL_H + + +//////////////////////////////////////////////////////////// +/// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// This file just includes the OpenGL (GL and GLU) headers, +/// which have actually different paths on each system +//////////////////////////////////////////////////////////// +#if defined(CSFML_SYSTEM_WINDOWS) + + #include + #include + #include + +#elif defined(CSFML_SYSTEM_LINUX) || defined(CSFML_SYSTEM_FREEBSD) + + #include + #include + +#elif defined(CSFML_SYSTEM_MACOS) + + #include + #include + +#endif + + +#endif // SFML_OPENGL_H diff --git a/include/SFML/System.h b/include/SFML/System.h new file mode 100644 index 0000000..a6769bd --- /dev/null +++ b/include/SFML/System.h @@ -0,0 +1,39 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SYSTEM_H +#define SFML_SYSTEM_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include + + +#endif // SFML_SYSTEM_H diff --git a/include/SFML/System/Clock.h b/include/SFML/System/Clock.h new file mode 100644 index 0000000..2c45fa6 --- /dev/null +++ b/include/SFML/System/Clock.h @@ -0,0 +1,80 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_CLOCK_H +#define SFML_CLOCK_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new clock and start it +/// +/// \return A new sfClock object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfClock* sfClock_Create(void); + +//////////////////////////////////////////////////////////// +/// Copy an existing clock +/// +/// \param clock : Clock to copy +/// +/// \return Copied object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfClock* sfClock_Copy(sfClock* clock); + +//////////////////////////////////////////////////////////// +/// Destroy an existing clock +/// +/// \param clock : Clock to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfClock_Destroy(sfClock* clock); + +//////////////////////////////////////////////////////////// +/// Get the time elapsed for a clock +/// +/// \param clock : Clock to get time from +/// +/// \return Elapsed time, in milliseconds +/// +//////////////////////////////////////////////////////////// +CSFML_API sfUint32 sfClock_GetTime(const sfClock* clock); + +//////////////////////////////////////////////////////////// +/// Restart a clock +/// +/// \param clock : Clock to restart +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfClock_Reset(sfClock* clock); + + +#endif // SFML_CLOCK_H diff --git a/include/SFML/System/Mutex.h b/include/SFML/System/Mutex.h new file mode 100644 index 0000000..1b316d4 --- /dev/null +++ b/include/SFML/System/Mutex.h @@ -0,0 +1,68 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_MUTEX_H +#define SFML_MUTEX_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new mutex +/// +/// \return A new sfMutex object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfMutex* sfMutex_Create(void); + +//////////////////////////////////////////////////////////// +/// Destroy an existing mutex +/// +/// \param mutex : Mutex to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMutex_Destroy(sfMutex* mutex); + +//////////////////////////////////////////////////////////// +/// Lock a mutex +/// +/// \param mutex : Mutex to lock +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMutex_Lock(sfMutex* mutex); + +//////////////////////////////////////////////////////////// +/// Unlock a mutex +/// +/// \param mutex : Mutex to unlock +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMutex_Unlock(sfMutex* mutex); + + +#endif // SFML_MUTEX_H diff --git a/include/SFML/System/Sleep.h b/include/SFML/System/Sleep.h new file mode 100644 index 0000000..e79649e --- /dev/null +++ b/include/SFML/System/Sleep.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SLEEP_H +#define SFML_SLEEP_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// Make the current thread sleep for a given duration +/// +/// \param duration : Time to sleep, in milliseconds +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSleep(sfUint32 duration); + + +#endif // SFML_SLEEP_H diff --git a/include/SFML/System/Thread.h b/include/SFML/System/Thread.h new file mode 100644 index 0000000..9d8cf26 --- /dev/null +++ b/include/SFML/System/Thread.h @@ -0,0 +1,80 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_THREAD_H +#define SFML_THREAD_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new thread from a function pointer +/// +/// \param function : Entry point of the thread +/// \param userData : Data to pass to the thread function +/// +//////////////////////////////////////////////////////////// +CSFML_API sfThread* sfThread_Create(void (*function)(void*), void* userData); + +//////////////////////////////////////////////////////////// +/// Destroy an existing thread +/// +/// \param thread : Thread to delete +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfThread_Destroy(sfThread* thread); + +//////////////////////////////////////////////////////////// +/// Run a thread +/// +/// \param thread : Thread to launch +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfThread_Launch(sfThread* thread); + +//////////////////////////////////////////////////////////// +/// Wait until a thread finishes +/// +/// \param thread : Thread to wait for +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfThread_Wait(sfThread* thread); + +//////////////////////////////////////////////////////////// +/// Terminate a thread +/// Terminating a thread with this function is not safe, +/// you should rather try to make the thread function +/// terminate by itself +/// +/// \param thread : Thread to terminate +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfThread_Terminate(sfThread* thread); + + +#endif // SFML_THREAD_H diff --git a/include/SFML/System/Types.h b/include/SFML/System/Types.h new file mode 100644 index 0000000..3f73af8 --- /dev/null +++ b/include/SFML/System/Types.h @@ -0,0 +1,33 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SYSTEM_TYPES_H +#define SFML_SYSTEM_TYPES_H + + +typedef struct sfClock sfClock; +typedef struct sfMutex sfMutex; +typedef struct sfThread sfThread; + + +#endif // SFML_SYSTEM_TYPES_H diff --git a/include/SFML/Window.h b/include/SFML/Window.h new file mode 100644 index 0000000..625fa0f --- /dev/null +++ b/include/SFML/Window.h @@ -0,0 +1,42 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SFML_WINDOW_H +#define SFML_SFML_WINDOW_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include +#include + + +#endif // SFML_SFML_WINDOW_H diff --git a/include/SFML/Window/Context.h b/include/SFML/Window/Context.h new file mode 100644 index 0000000..b5617f2 --- /dev/null +++ b/include/SFML/Window/Context.h @@ -0,0 +1,61 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_CONTEXT_H +#define SFML_CONTEXT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new context +/// +/// \return New context +/// +//////////////////////////////////////////////////////////// +CSFML_API sfContext* sfContext_Create(void); + +//////////////////////////////////////////////////////////// +/// Destroy an existing context +/// +/// \param context : Context to destroy +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfContext_Destroy(sfContext* context); + +//////////////////////////////////////////////////////////// +/// Activate or deactivate a context +/// +/// \param context : Context to activate or deactivate +/// \param active : sfTrue to activate, sfFalse to deactivate +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfContext_SetActive(sfContext* context, sfBool active); + + +#endif // SFML_CONTEXT_H diff --git a/include/SFML/Window/Event.h b/include/SFML/Window/Event.h new file mode 100644 index 0000000..df97f8a --- /dev/null +++ b/include/SFML/Window/Event.h @@ -0,0 +1,178 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_EVENT_H +#define SFML_EVENT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Definition of all the event types +//////////////////////////////////////////////////////////// +typedef enum +{ + sfEvtClosed, + sfEvtResized, + sfEvtLostFocus, + sfEvtGainedFocus, + sfEvtTextEntered, + sfEvtKeyPressed, + sfEvtKeyReleased, + sfEvtMouseWheelMoved, + sfEvtMouseButtonPressed, + sfEvtMouseButtonReleased, + sfEvtMouseMoved, + sfEvtMouseEntered, + sfEvtMouseLeft, + sfEvtJoystickButtonPressed, + sfEvtJoystickButtonReleased, + sfEvtJoystickMoved, + sfEvtJoystickConnected, + sfEvtJoystickDisconnected +} sfEventType; + + +//////////////////////////////////////////////////////////// +/// Keyboard event parameters +//////////////////////////////////////////////////////////// +struct sfKeyEvent +{ + sfEventType Type; + sfKeyCode Code; + sfBool Alt; + sfBool Control; + sfBool Shift; + sfBool System; +}; + +//////////////////////////////////////////////////////////// +/// Text event parameters +//////////////////////////////////////////////////////////// +struct sfTextEvent +{ + sfEventType Type; + sfUint32 Unicode; +}; + +//////////////////////////////////////////////////////////// +/// Mouse move event parameters +//////////////////////////////////////////////////////////// +struct sfMouseMoveEvent +{ + sfEventType Type; + int X; + int Y; +}; + +//////////////////////////////////////////////////////////// +/// Mouse buttons events parameters +//////////////////////////////////////////////////////////// +struct sfMouseButtonEvent +{ + sfEventType Type; + sfMouseButton Button; + int X; + int Y; +}; + +//////////////////////////////////////////////////////////// +/// Mouse wheel events parameters +//////////////////////////////////////////////////////////// +struct sfMouseWheelEvent +{ + sfEventType Type; + int Delta; + int X; + int Y; +}; + +//////////////////////////////////////////////////////////// +/// Joystick axis move event parameters +//////////////////////////////////////////////////////////// +struct sfJoystickMoveEvent +{ + sfEventType Type; + unsigned int JoystickId; + sfJoystickAxis Axis; + float Position; +}; + +//////////////////////////////////////////////////////////// +/// Joystick buttons events parameters +//////////////////////////////////////////////////////////// +struct sfJoystickButtonEvent +{ + sfEventType Type; + unsigned int JoystickId; + unsigned int Button; +}; + +//////////////////////////////////////////////////////////// +/// Joystick connection/disconnection event parameters +//////////////////////////////////////////////////////////// +struct sfJoystickConnectEvent +{ + sfEventType Type; + unsigned int JoystickId; +}; + +//////////////////////////////////////////////////////////// +/// Size events parameters +//////////////////////////////////////////////////////////// +struct sfSizeEvent +{ + sfEventType Type; + unsigned int Width; + unsigned int Height; +}; + + +//////////////////////////////////////////////////////////// +/// sfEvent defines a system event and its parameters +//////////////////////////////////////////////////////////// +typedef union +{ + //////////////////////////////////////////////////////////// + // Member data + //////////////////////////////////////////////////////////// + sfEventType Type; ///< Type of the event + struct sfSizeEvent Size; + struct sfKeyEvent Key; + struct sfTextEvent Text; + struct sfMouseMoveEvent MouseMove; + struct sfMouseButtonEvent MouseButton; + struct sfMouseWheelEvent MouseWheel; + struct sfJoystickMoveEvent JoystickMove; + struct sfJoystickButtonEvent JoystickButton; + struct sfJoystickConnectEvent JoystickConnect; +} sfEvent; + + +#endif // SFML_EVENT_H diff --git a/include/SFML/Window/Input.h b/include/SFML/Window/Input.h new file mode 100644 index 0000000..2c86724 --- /dev/null +++ b/include/SFML/Window/Input.h @@ -0,0 +1,102 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_INPUT_H +#define SFML_INPUT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Get the state of a key +/// +/// \param input : Input object +/// \param code : Key to check +/// +/// \return sfTrue if key is down, sfFalse if key is up +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfInput_IsKeyDown(const sfInput* input, sfKeyCode code); + +//////////////////////////////////////////////////////////// +/// Get the state of a mouse button +/// +/// \param input : Input object +/// \param button : Button to check +/// +/// \return sfTrue if button is down, sfFalse if button is up +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfInput_IsMouseButtonDown(const sfInput* input, sfMouseButton button); + +//////////////////////////////////////////////////////////// +/// Get the state of a joystick button +/// +/// \param input : Input object +/// \param joyId : Identifier of the joystick to check (0 or 1) +/// \param button : Button to check +/// +/// \return sfTrue if button is down, sfFalse if button is up +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfInput_IsJoystickButtonDown(const sfInput* input, unsigned int joyId, unsigned int button); + +//////////////////////////////////////////////////////////// +/// Get the mouse X position +/// +/// \param input : Input object +/// +/// \return Current mouse left position, relative to owner window +/// +//////////////////////////////////////////////////////////// +CSFML_API int sfInput_GetMouseX(const sfInput* input); + +//////////////////////////////////////////////////////////// +/// Get the mouse Y position +/// +/// \param input : Input object +/// +/// \return Current mouse top position, relative to owner window +/// +//////////////////////////////////////////////////////////// +CSFML_API int sfInput_GetMouseY(const sfInput* input); + +//////////////////////////////////////////////////////////// +/// Get the joystick position on a given axis +/// +/// \param input : Input object +/// \param joyId : Identifier of the joystick to check (0 or 1) +/// \param axis : Identifier of the axis to read +/// +/// \return Current joystick position, in the range [-100, 100] +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfInput_GetJoystickAxis(const sfInput* input, unsigned int joyId, sfJoyAxis axis); + + +#endif // SFML_INPUT_H diff --git a/include/SFML/Window/Joystick.h b/include/SFML/Window/Joystick.h new file mode 100644 index 0000000..197a6a2 --- /dev/null +++ b/include/SFML/Window/Joystick.h @@ -0,0 +1,135 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_JOYSTICK_H +#define SFML_JOYSTICK_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// \brief Global joysticks capabilities +/// +//////////////////////////////////////////////////////////// +enum +{ + sfJoystickCount = 8, ///< Maximum number of supported joysticks + sfJoystickButtonCount = 32, ///< Maximum number of supported buttons + sfJoystickAxisCount = 8 ///< Maximum number of supported axes +}; + + +//////////////////////////////////////////////////////////// +/// \brief Axes supported by SFML joysticks +/// +//////////////////////////////////////////////////////////// +typedef enum +{ + sfJoystickX, ///< The X axis + sfJoystickY, ///< The Y axis + sfJoystickZ, ///< The Z axis + sfJoystickR, ///< The R axis + sfJoystickU, ///< The U axis + sfJoystickV, ///< The V axis + sfJoystickPovX, ///< The X axis of the point-of-view hat + sfJoystickPovY ///< The Y axis of the point-of-view hat +} sfJoystickAxis; + + +//////////////////////////////////////////////////////////// +/// \brief Check if a joystick is connected +/// +/// \param joystick Index of the joystick to check +/// +/// \return sfTrue if the joystick is connected, sfFalse otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfJoystick_IsConnected(unsigned int joystick); + +//////////////////////////////////////////////////////////// +/// \brief Return the number of buttons supported by a joystick +/// +/// If the joystick is not connected, this function returns 0. +/// +/// \param joystick Index of the joystick +/// +/// \return Number of buttons supported by the joystick +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfJoystick_GetButtonCount(unsigned int joystick); + +//////////////////////////////////////////////////////////// +/// \brief Check if a joystick supports a given axis +/// +/// If the joystick is not connected, this function returns false. +/// +/// \param joystick Index of the joystick +/// \param axis Axis to check +/// +/// \return sfTrue if the joystick supports the axis, sfFalse otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfJoystick_HasAxis(unsigned int joystick, sfJoystickAxis axis); + +//////////////////////////////////////////////////////////// +/// \brief Check if a joystick button is pressed +/// +/// If the joystick is not connected, this function returns false. +/// +/// \param joystick Index of the joystick +/// \param button Button to check +/// +/// \return sfTrue if the button is pressed, sfFalse otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfJoystick_IsButtonPressed(unsigned int joystick, unsigned int button); + +//////////////////////////////////////////////////////////// +/// \brief Get the current position of a joystick axis +/// +/// If the joystick is not connected, this function returns 0. +/// +/// \param joystick Index of the joystick +/// \param axis Axis to check +/// +/// \return Current position of the axis, in range [-100 .. 100] +/// +//////////////////////////////////////////////////////////// +CSFML_API float sfJoystick_GetAxisPosition(unsigned int joystick, sfJoystickAxis axis); + +//////////////////////////////////////////////////////////// +/// \brief Update the states of all joysticks +/// +/// This function is used internally by SFML, so you normally +/// don't have to call it explicitely. However, you may need to +/// call it if you have no window yet (or no window at all): +/// in this case the joysticks states are not updated automatically. +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfJoystick_Update(void); + + +#endif // SFML_JOYSTICK_H diff --git a/include/SFML/Window/Keyboard.h b/include/SFML/Window/Keyboard.h new file mode 100644 index 0000000..1901a23 --- /dev/null +++ b/include/SFML/Window/Keyboard.h @@ -0,0 +1,156 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_KEYBOARD_H +#define SFML_KEYBOARD_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// \brief Key codes +/// +//////////////////////////////////////////////////////////// +typedef enum +{ + sfKeyA, ///< The A key + sfKeyB, ///< The B key + sfKeyC, ///< The C key + sfKeyD, ///< The D key + sfKeyE, ///< The E key + sfKeyF, ///< The F key + sfKeyG, ///< The G key + sfKeyH, ///< The H key + sfKeyI, ///< The I key + sfKeyJ, ///< The J key + sfKeyK, ///< The K key + sfKeyL, ///< The L key + sfKeyM, ///< The M key + sfKeyN, ///< The N key + sfKeyO, ///< The O key + sfKeyP, ///< The P key + sfKeyQ, ///< The Q key + sfKeyR, ///< The R key + sfKeyS, ///< The S key + sfKeyT, ///< The T key + sfKeyU, ///< The U key + sfKeyV, ///< The V key + sfKeyW, ///< The W key + sfKeyX, ///< The X key + sfKeyY, ///< The Y key + sfKeyZ, ///< The Z key + sfKeyNum0, ///< The 0 key + sfKeyNum1, ///< The 1 key + sfKeyNum2, ///< The 2 key + sfKeyNum3, ///< The 3 key + sfKeyNum4, ///< The 4 key + sfKeyNum5, ///< The 5 key + sfKeyNum6, ///< The 6 key + sfKeyNum7, ///< The 7 key + sfKeyNum8, ///< The 8 key + sfKeyNum9, ///< The 9 key + sfKeyEscape, ///< The Escape key + sfKeyLControl, ///< The left Control key + sfKeyLShift, ///< The left Shift key + sfKeyLAlt, ///< The left Alt key + sfKeyLSystem, ///< The left OS specific key: window (Windows and Linux), apple (MacOS X), ... + sfKeyRControl, ///< The right Control key + sfKeyRShift, ///< The right Shift key + sfKeyRAlt, ///< The right Alt key + sfKeyRSystem, ///< The right OS specific key: window (Windows and Linux), apple (MacOS X), ... + sfKeyMenu, ///< The Menu key + sfKeyLBracket, ///< The [ key + sfKeyRBracket, ///< The ] key + sfKeySemiColon, ///< The ; key + sfKeyComma, ///< The , key + sfKeyPeriod, ///< The . key + sfKeyQuote, ///< The ' key + sfKeySlash, ///< The / key + sfKeyBackSlash, ///< The \ key + sfKeyTilde, ///< The ~ key + sfKeyEqual, ///< The = key + sfKeyDash, ///< The - key + sfKeySpace, ///< The Space key + sfKeyReturn, ///< The Return key + sfKeyBack, ///< The Backspace key + sfKeyTab, ///< The Tabulation key + sfKeyPageUp, ///< The Page up key + sfKeyPageDown, ///< The Page down key + sfKeyEnd, ///< The End key + sfKeyHome, ///< The Home key + sfKeyInsert, ///< The Insert key + sfKeyDelete, ///< The Delete key + sfKeyAdd, ///< + + sfKeySubtract, ///< - + sfKeyMultiply, ///< * + sfKeyDivide, ///< / + sfKeyLeft, ///< Left arrow + sfKeyRight, ///< Right arrow + sfKeyUp, ///< Up arrow + sfKeyDown, ///< Down arrow + sfKeyNumpad0, ///< The numpad 0 key + sfKeyNumpad1, ///< The numpad 1 key + sfKeyNumpad2, ///< The numpad 2 key + sfKeyNumpad3, ///< The numpad 3 key + sfKeyNumpad4, ///< The numpad 4 key + sfKeyNumpad5, ///< The numpad 5 key + sfKeyNumpad6, ///< The numpad 6 key + sfKeyNumpad7, ///< The numpad 7 key + sfKeyNumpad8, ///< The numpad 8 key + sfKeyNumpad9, ///< The numpad 9 key + sfKeyF1, ///< The F1 key + sfKeyF2, ///< The F2 key + sfKeyF3, ///< The F3 key + sfKeyF4, ///< The F4 key + sfKeyF5, ///< The F5 key + sfKeyF6, ///< The F6 key + sfKeyF7, ///< The F7 key + sfKeyF8, ///< The F8 key + sfKeyF9, ///< The F8 key + sfKeyF10, ///< The F10 key + sfKeyF11, ///< The F11 key + sfKeyF12, ///< The F12 key + sfKeyF13, ///< The F13 key + sfKeyF14, ///< The F14 key + sfKeyF15, ///< The F15 key + sfKeyPause, ///< The Pause key + + sfKeyCount ///< Keep last -- the total number of keyboard keys +} sfKeyCode; + + +//////////////////////////////////////////////////////////// +/// \brief Check if a key is pressed +/// +/// \param key Key to check +/// +/// \return sfTrue if the key is pressed, sfFalse otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfKeyboard_IsKeyPressed(sfKeyCode key); + + +#endif // SFML_KEYBOARD_H diff --git a/include/SFML/Window/Mouse.h b/include/SFML/Window/Mouse.h new file mode 100644 index 0000000..3fb895e --- /dev/null +++ b/include/SFML/Window/Mouse.h @@ -0,0 +1,74 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_MOUSE_H +#define SFML_MOUSE_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// \brief Mouse buttons +/// +//////////////////////////////////////////////////////////// +typedef enum +{ + sfMouseLeft, ///< The left mouse button + sfMouseRight, ///< The right mouse button + sfMouseMiddle, ///< The middle (wheel) mouse button + sfMouseXButton1, ///< The first extra mouse button + sfMouseXButton2, ///< The second extra mouse button + + sfMouseButtonCount ///< Keep last -- the total number of mouse buttons +} sfMouseButton; + + +//////////////////////////////////////////////////////////// +/// \brief Check if a mouse button is pressed +/// +/// \param button Button to check +/// +/// \return sfTrue if the button is pressed, sfFalse otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfMouse_IsButtonPressed(sfMouseButton button); + +//////////////////////////////////////////////////////////// +/// \brief Get the current position of the mouse +/// +/// This function returns the current position of the mouse +/// cursor. +/// If the cursor is over a SFML window, the returned position +/// is relative to this window. Otherwise, the returned position +/// is in desktop coordinates. +/// +/// \return Current position of the mouse +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMouse_GetPosition(int* x, int* y); + + +#endif // SFML_MOUSE_H diff --git a/include/SFML/Window/Types.h b/include/SFML/Window/Types.h new file mode 100644 index 0000000..5dc37c5 --- /dev/null +++ b/include/SFML/Window/Types.h @@ -0,0 +1,33 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_WINDOW_TYPES_H +#define SFML_WINDOW_TYPES_H + + +typedef struct sfContext sfContext; +typedef struct sfWindow sfWindow; + + +#endif // SFML_WINDOW_TYPES_H diff --git a/include/SFML/Window/VideoMode.h b/include/SFML/Window/VideoMode.h new file mode 100644 index 0000000..8b4143b --- /dev/null +++ b/include/SFML/Window/VideoMode.h @@ -0,0 +1,77 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_VIDEOMODE_H +#define SFML_VIDEOMODE_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// sfVideoMode defines a video mode (width, height, bpp, frequency) +/// and provides functions for getting modes supported +/// by the display device +//////////////////////////////////////////////////////////// +typedef struct +{ + unsigned int Width; ///< Video mode width, in pixels + unsigned int Height; ///< Video mode height, in pixels + unsigned int BitsPerPixel; ///< Video mode pixel depth, in bits per pixels +} sfVideoMode; + + +//////////////////////////////////////////////////////////// +/// Get the current desktop video mode +/// +/// \return Current desktop video mode +/// +//////////////////////////////////////////////////////////// +CSFML_API sfVideoMode sfVideoMode_GetDesktopMode(void); + +//////////////////////////////////////////////////////////// +/// Get all the supported video modes for fullscreen mode. +/// Modes are sorted from best to worst. +/// +/// \param Count : Variable that will be filled with the number of modes +/// +/// \return Pointer to an array of \a count video modes +/// +//////////////////////////////////////////////////////////// +CSFML_API const sfVideoMode* sfVideoMode_GetFullscreenModes(size_t* Count); + +//////////////////////////////////////////////////////////// +/// Tell whether or not a video mode is supported +/// +/// \param mode : Video mode to check +/// +/// +/// \return True if video mode is supported, false otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfVideoMode_IsValid(sfVideoMode mode); + + +#endif // SFML_VIDEOMODE_H diff --git a/include/SFML/Window/Window.h b/include/SFML/Window/Window.h new file mode 100644 index 0000000..f25990c --- /dev/null +++ b/include/SFML/Window/Window.h @@ -0,0 +1,319 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_WINDOW_H +#define SFML_WINDOW_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Enumeration of window creation styles +/// +//////////////////////////////////////////////////////////// +enum +{ + sfNone = 0, ///< No border / title bar (this flag and all others are mutually exclusive) + sfTitlebar = 1 << 0, ///< Title bar + fixed border + sfResize = 1 << 1, ///< Titlebar + resizable border + maximize button + sfClose = 1 << 2, ///< Titlebar + close button + sfFullscreen = 1 << 3, ///< Fullscreen mode (this flag and all others are mutually exclusive) + sfDefaultStyle = sfTitlebar | sfResize | sfClose ///< Default window style +}; + + +//////////////////////////////////////////////////////////// +/// Structure defining the window's creation settings +//////////////////////////////////////////////////////////// +typedef struct +{ + unsigned int DepthBits; ///< Bits of the depth buffer + unsigned int StencilBits; ///< Bits of the stencil buffer + unsigned int AntialiasingLevel; ///< Level of antialiasing + unsigned int MajorVersion; ///< Major number of the context version to create + unsigned int MinorVersion; ///< Minor number of the context version to create +} sfContextSettings; + + +//////////////////////////////////////////////////////////// +/// Construct a new window +/// +/// \param mode : Video mode to use +/// \param title : Title of the window +/// \param style : Window style +/// \param settings : Creation settings (pass NULL to use default values) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfWindow* sfWindow_Create(sfVideoMode mode, const char* title, unsigned long style, const sfContextSettings* settings); + +//////////////////////////////////////////////////////////// +/// Construct a window from an existing control +/// +/// \param handle : Platform-specific handle of the control +/// \param settings : Creation settings (pass NULL to use default values) +/// +//////////////////////////////////////////////////////////// +CSFML_API sfWindow* sfWindow_CreateFromHandle(sfWindowHandle handle, const sfContextSettings* settings); + +//////////////////////////////////////////////////////////// +/// Destroy an existing window +/// +/// \param window : Window to destroy +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfWindow_Destroy(sfWindow* window); + +//////////////////////////////////////////////////////////// +/// Close a window (but doesn't destroy the internal data) +/// +/// \param window : Window to close +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfWindow_Close(sfWindow* window); + +//////////////////////////////////////////////////////////// +/// Tell whether or not a window is opened +/// +/// \param window : Window object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfWindow_IsOpened(const sfWindow* window); + +//////////////////////////////////////////////////////////// +/// Get the width of the rendering region of a window +/// +/// \param window : Window object +/// +/// \return Width in pixels +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfWindow_GetWidth(const sfWindow* window); + +//////////////////////////////////////////////////////////// +/// Get the height of the rendering region of a window +/// +/// \param window : Window object +/// +/// \return Height in pixels +/// +//////////////////////////////////////////////////////////// +CSFML_API unsigned int sfWindow_GetHeight(const sfWindow* window); + +//////////////////////////////////////////////////////////// +/// Get the creation settings of a window +/// +/// \param window : Window object +/// +/// \return Settings used to create the window +/// +//////////////////////////////////////////////////////////// +CSFML_API sfContextSettings sfWindow_GetSettings(const sfWindow* window); + +//////////////////////////////////////////////////////////// +/// Get the event on top of events stack of a window, if any, and pop it +/// +/// \param window : Window object +/// \param event : Event to fill, if any +/// +/// \return sfTrue if an event was returned, sfFalse if events stack was empty +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfWindow_PollEvent(sfWindow* window, sfEvent* event); + +//////////////////////////////////////////////////////////// +/// Wait for an event and return it +/// +/// \param window : Window object +/// \param event : Event to fill +/// +/// \return sfFalse if an error occured +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfWindow_WaitEvent(sfWindow* window, sfEvent* event); + +//////////////////////////////////////////////////////////// +/// Enable / disable vertical synchronization on a window +/// +/// \param window : Window object +/// \param enabled : sfTrue to enable v-sync, sfFalse to deactivate +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfWindow_EnableVerticalSync(sfWindow* window, sfBool enabled); + +//////////////////////////////////////////////////////////// +/// Show or hide the mouse cursor on a window +/// +/// \param window : Window object +/// \param show : sfTrue to show, sfFalse to hide +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfWindow_ShowMouseCursor(sfWindow* window, sfBool show); + +//////////////////////////////////////////////////////////// +/// Change the position of the mouse cursor on a window +/// +/// \param window : Window object +/// \param left : Left coordinate of the cursor, relative to the window +/// \param top : Top coordinate of the cursor, relative to the window +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfWindow_SetCursorPosition(sfWindow* window, unsigned int left, unsigned int top); + +//////////////////////////////////////////////////////////// +/// Get the position of the mouse cursor on a window +/// +/// \param window : Window object +/// \param left : Left coordinate of the cursor, relative to the window +/// \param top : Top coordinate of the cursor, relative to the window +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfWindow_GetCursorPosition(sfWindow* window, int* left, int* top); + +//////////////////////////////////////////////////////////// +/// Change the position of a window on screen. +/// Only works for top-level windows +/// +/// \param window : Window object +/// \param left : Left position +/// \param top : Top position +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfWindow_SetPosition(sfWindow* window, int left, int top); + +//////////////////////////////////////////////////////////// +/// Change the size of the rendering region of a window +/// +/// \param window : Window object +/// \param width : New Width +/// \param height : New Height +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfWindow_SetSize(sfWindow* window, unsigned int width, unsigned int height); + +//////////////////////////////////////////////////////////// +/// Change the title of a window +/// +/// \param window : Window object +/// \param title : New title +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfWindow_SetTitle(sfWindow* window, const char* title); + +//////////////////////////////////////////////////////////// +/// Show or hide a window +/// +/// \param window : Window object +/// \param show : sfTrue to show, sfFalse to hide +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfWindow_Show(sfWindow* window, sfBool show); + +//////////////////////////////////////////////////////////// +/// Enable or disable automatic key-repeat for keydown events. +/// Automatic key-repeat is enabled by default +/// +/// \param window : Window object +/// \param enabled : sfTrue to enable, sfFalse to disable +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfWindow_EnableKeyRepeat(sfWindow* window, sfBool enabled); + +//////////////////////////////////////////////////////////// +/// Change the window's icon +/// +/// \param window : Window object +/// \param width : Icon's width, in pixels +/// \param height : Icon's height, in pixels +/// \param pixels : Pointer to the pixels in memory, format must be RGBA 32 bits +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfWindow_SetIcon(sfWindow* window, unsigned int width, unsigned int height, const sfUint8* pixels); + +//////////////////////////////////////////////////////////// +/// Activate or deactivate a window as the current target for rendering +/// +/// \param window : Window object +/// \param active : sfTrue to activate, sfFalse to deactivate +/// +/// \return True if operation was successful, false otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfWindow_SetActive(sfWindow* window, sfBool active); + +//////////////////////////////////////////////////////////// +/// Display a window on screen +/// +/// \param window : Window object +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfWindow_Display(sfWindow* window); + +//////////////////////////////////////////////////////////// +/// Limit the framerate to a maximum fixed frequency for a window +/// +/// \param window : Window object +/// \param limit : Framerate limit, in frames per seconds (use 0 to disable limit) +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfWindow_SetFramerateLimit(sfWindow* window, unsigned int limit); + +//////////////////////////////////////////////////////////// +/// Get time elapsed since last frame of a window +/// +/// \param window : Window object +/// +/// \return Time elapsed, in milliseconds +/// +//////////////////////////////////////////////////////////// +CSFML_API sfUint32 sfWindow_GetFrameTime(const sfWindow* window); + +//////////////////////////////////////////////////////////// +/// Change the joystick threshold, ie. the value below which +/// no move event will be generated +/// +/// \param window : Window object +/// \param threshold : New threshold, in range [0, 100] +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfWindow_SetJoystickThreshold(sfWindow* window, float threshold); + +//////////////////////////////////////////////////////////// +/// Retrieve the Os-specific handle of a window +/// +/// \param window : Window object +/// +/// \return Window handle +/// +//////////////////////////////////////////////////////////// +CSFML_API sfWindowHandle sfWindow_GetSystemHandle(const sfWindow* window); + + +#endif // SFML_WINDOW_H diff --git a/include/SFML/Window/WindowHandle.h b/include/SFML/Window/WindowHandle.h new file mode 100644 index 0000000..2a137bc --- /dev/null +++ b/include/SFML/Window/WindowHandle.h @@ -0,0 +1,57 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_WINDOWHANDLE_H +#define SFML_WINDOWHANDLE_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// Define a low-level window handle type, specific to +/// each platform +//////////////////////////////////////////////////////////// +#if defined(CSFML_SYSTEM_WINDOWS) + + // Window handle is HWND (HWND__*) on Windows + struct HWND__; + typedef HWND__* sfWindowHandle; + +#elif defined(CSFML_SYSTEM_LINUX) || defined(CSFML_SYSTEM_FREEBSD) + + // Window handle is Window (unsigned long) on Unix - X11 + typedef unsigned long sfWindowHandle; + +#elif defined(CSFML_SYSTEM_MACOS) + + // Window handle is NSWindow (void*) on Mac OS X - Cocoa + typedef void* sfWindowHandle; + +#endif + + +#endif // SFML_WINDOWHANDLE_H diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..0e203bb --- /dev/null +++ b/license.txt @@ -0,0 +1,31 @@ +CSFML +----- + +CSFML - Copyright (c) 2007-2011 Laurent Gomila - laurent.gom@gmail.com + +This software is provided 'as-is', without any express or +implied warranty. In no event will the authors be held +liable for any damages arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute +it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; + you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment + in the product documentation would be appreciated but + is not required. + +2. Altered source versions must be plainly marked as such, + and must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any + source distribution. + + + +External libraries used by CSFML +-------------------------------- + +* SFML is under the zlib/png license diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..b3a8443 --- /dev/null +++ b/readme.txt @@ -0,0 +1,36 @@ +CSFML - Simple and Fast Multimedia Library for C +================================================ + +SFML is a simple, fast, cross-platform and object-oriented multimedia API. It provides access to windowing, graphics, +audio and network. +It is originally written in C++, and this project is its official binding for the C language. + +Authors +------- + +Laurent Gomila - main developer (laurent.gom@gmail.com) + +Download +-------- + +You can get the latest official release on SFML website (http://www.sfml-dev.org/download.php). +You can also get the current development version from the git repository (https://github.com/LaurentGomila/CSFML). + +Learn +----- + +There is no tutorial for CSFML, but since it's a binding you can use the C++ resources: +* The official tutorials (http://www.sfml-dev.org/tutorials/) +* The online API documentation (http://www.sfml-dev.org/documentation/) +* The community wiki (https://github.com/LaurentGomila/SFML/wiki/) +* The community forum (http://www.sfml-dev.org/forum/) + +Of course, you can also find the CSFM API documentation in the SDK. + +Contribute +---------- + +SFML and CSFML are open-source projects, and they need your help to go on growing and improving. +Don't hesitate to post suggestions or bug reports on the forum (http://www.sfml-dev.org/forum/), +submit patches by e-mail, or post new bugs/features requests on the task tracker (https://github.com/LaurentGomila/CSFML/issues/). +You can even fork the project on github, maintain your own version and send us pull requests periodically to merge your work. diff --git a/src/SFML/Audio/CMakeLists.txt b/src/SFML/Audio/CMakeLists.txt new file mode 100644 index 0000000..c2d66d3 --- /dev/null +++ b/src/SFML/Audio/CMakeLists.txt @@ -0,0 +1,34 @@ + +set(INCROOT ${CMAKE_SOURCE_DIR}/include/SFML/Audio) +set(SRCROOT ${CMAKE_SOURCE_DIR}/src/SFML/Audio) + +# all source files +set(SRC + ${SRCROOT}/Listener.cpp + ${INCROOT}/Listener.h + ${SRCROOT}/Music.cpp + ${SRCROOT}/MusicStruct.h + ${INCROOT}/Music.h + ${SRCROOT}/Sound.cpp + ${SRCROOT}/SoundStruct.h + ${INCROOT}/Sound.h + ${SRCROOT}/SoundBuffer.cpp + ${SRCROOT}/SoundBufferStruct.h + ${INCROOT}/SoundBuffer.h + ${SRCROOT}/SoundBufferRecorder.cpp + ${SRCROOT}/SoundBufferRecorderStruct.h + ${INCROOT}/SoundBufferRecorder.h + ${SRCROOT}/SoundRecorder.cpp + ${SRCROOT}/SoundRecorderStruct.h + ${INCROOT}/SoundRecorder.h + ${INCROOT}/SoundStatus.h + ${SRCROOT}/SoundStream.cpp + ${SRCROOT}/SoundStreamStruct.h + ${INCROOT}/SoundStream.h + ${INCROOT}/Types.h +) + +# define the csfml-audio target +csfml_add_library(csfml-audio + SOURCES ${SRC} + DEPENDS ${SFML_AUDIO_LIBRARY} ${SFML_SYSTEM_LIBRARY}) diff --git a/src/SFML/Audio/Listener.cpp b/src/SFML/Audio/Listener.cpp new file mode 100644 index 0000000..953142d --- /dev/null +++ b/src/SFML/Audio/Listener.cpp @@ -0,0 +1,96 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + + +//////////////////////////////////////////////////////////// +/// Change the global volume of all the sounds +//////////////////////////////////////////////////////////// +void sfListener_SetGlobalVolume(float volume) +{ + sf::Listener::SetGlobalVolume(volume); +} + + +//////////////////////////////////////////////////////////// +/// Get the current value of the global volume of all the sounds +//////////////////////////////////////////////////////////// +float sfListener_GetGlobalVolume(void) +{ + return sf::Listener::GetGlobalVolume(); +} + + +//////////////////////////////////////////////////////////// +/// Change the position of the listener +//////////////////////////////////////////////////////////// +void sfListener_SetPosition(float x, float y, float z) +{ + sf::Listener::SetPosition(x, y, z); +} + + +//////////////////////////////////////////////////////////// +/// Get the current position of the listener +//////////////////////////////////////////////////////////// +void sfListener_GetPosition(float* x, float* y, float* z) +{ + if (x && y && z) + { + sf::Vector3f position = sf::Listener::GetPosition(); + *x = position.x; + *y = position.y; + *z = position.z; + } +} + + +//////////////////////////////////////////////////////////// +/// Change the orientation of the listener +//////////////////////////////////////////////////////////// +void sfListener_SetDirection(float x, float y, float z) +{ + sf::Listener::SetDirection(x, y, z); +} + + +//////////////////////////////////////////////////////////// +/// Get the current orientation of the listener +//////////////////////////////////////////////////////////// +void sfListener_GetDirection(float* x, float* y, float* z) +{ + if (x && y && z) + { + sf::Vector3f direction = sf::Listener::GetDirection(); + *x = direction.x; + *y = direction.y; + *z = direction.z; + } +} diff --git a/src/SFML/Audio/Music.cpp b/src/SFML/Audio/Music.cpp new file mode 100644 index 0000000..1dd293f --- /dev/null +++ b/src/SFML/Audio/Music.cpp @@ -0,0 +1,297 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new music and load it from a file +//////////////////////////////////////////////////////////// +sfMusic* sfMusic_CreateFromFile(const char* filename) +{ + sfMusic* music = new sfMusic; + + if (!music->This.OpenFromFile(filename)) + { + delete music; + music = NULL; + } + + return music; +} + + +//////////////////////////////////////////////////////////// +/// Create a new music and load it from a file in memory +//////////////////////////////////////////////////////////// +sfMusic* sfMusic_CreateFromMemory(const void* data, size_t sizeInBytes) +{ + sfMusic* music = new sfMusic; + + if (!music->This.OpenFromMemory(data, sizeInBytes)) + { + delete music; + music = NULL; + } + + return music; +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing music +//////////////////////////////////////////////////////////// +void sfMusic_Destroy(sfMusic* music) +{ + delete music; +} + + +//////////////////////////////////////////////////////////// +/// Set a music loop state +//////////////////////////////////////////////////////////// +void sfMusic_SetLoop(sfMusic* music, sfBool loop) +{ + CSFML_CALL(music, SetLoop(loop != 0)); +} + + +//////////////////////////////////////////////////////////// +/// Tell whether or not a music is looping +//////////////////////////////////////////////////////////// +sfBool sfMusic_GetLoop(const sfMusic* music) +{ + CSFML_CALL_RETURN(music, GetLoop(), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Get a music duration +//////////////////////////////////////////////////////////// +sfUint32 sfMusic_GetDuration(const sfMusic* music) +{ + CSFML_CALL_RETURN(music, GetDuration(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Start playing a music +//////////////////////////////////////////////////////////// +void sfMusic_Play(sfMusic* music) +{ + CSFML_CALL(music, Play()); +} + + +//////////////////////////////////////////////////////////// +/// Pause a music +//////////////////////////////////////////////////////////// +void sfMusic_Pause(sfMusic* music) +{ + CSFML_CALL(music, Pause()); +} + + +//////////////////////////////////////////////////////////// +/// Stop playing a music +//////////////////////////////////////////////////////////// +void sfMusic_Stop(sfMusic* music) +{ + CSFML_CALL(music, Stop()); +} + + +//////////////////////////////////////////////////////////// +/// Return the number of channels of a music (1 = mono, 2 = stereo) +//////////////////////////////////////////////////////////// +unsigned int sfMusic_GetChannelsCount(const sfMusic* music) +{ + CSFML_CALL_RETURN(music, GetChannelsCount(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Get the stream sample rate of a music +//////////////////////////////////////////////////////////// +unsigned int sfMusic_GetSampleRate(const sfMusic* music) +{ + CSFML_CALL_RETURN(music, GetSampleRate(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Get the status of a music (stopped, paused, playing) +//////////////////////////////////////////////////////////// +sfSoundStatus sfMusic_GetStatus(const sfMusic* music) +{ + CSFML_CHECK_RETURN(music, sfStopped); + + return static_cast(music->This.GetStatus()); +} + + +//////////////////////////////////////////////////////////// +/// Get the current playing position of a music +//////////////////////////////////////////////////////////// +sfUint32 sfMusic_GetPlayingOffset(const sfMusic* music) +{ + CSFML_CALL_RETURN(music, GetPlayingOffset(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Set the pitch of a music +//////////////////////////////////////////////////////////// +void sfMusic_SetPitch(sfMusic* music, float pitch) +{ + CSFML_CALL(music, SetPitch(pitch)); +} + + +//////////////////////////////////////////////////////////// +/// Set the volume of a music +//////////////////////////////////////////////////////////// +void sfMusic_SetVolume(sfMusic* music, float volume) +{ + CSFML_CALL(music, SetVolume(volume)); +} + + +//////////////////////////////////////////////////////////// +/// Set the position of a music +//////////////////////////////////////////////////////////// +void sfMusic_SetPosition(sfMusic* music, float x, float y, float z) +{ + CSFML_CALL(music, SetPosition(sf::Vector3f(x, y, z))); +} + + +//////////////////////////////////////////////////////////// +/// Make the music's position relative to the listener's +/// position, or absolute. +/// The default value is false (absolute) +//////////////////////////////////////////////////////////// +void sfMusic_SetRelativeToListener(sfMusic* music, sfBool relative) +{ + CSFML_CALL(music, SetRelativeToListener(relative == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +/// Set the minimum distance - closer than this distance, +/// the listener will hear the music at its maximum volume. +/// The default minimum distance is 1.0 +//////////////////////////////////////////////////////////// +void sfMusic_SetMinDistance(sfMusic* music, float distance) +{ + CSFML_CALL(music, SetMinDistance(distance)); +} + + +//////////////////////////////////////////////////////////// +/// Set the attenuation factor - the higher the attenuation, the +/// more the sound will be attenuated with distance from listener. +/// The default attenuation factor 1.0 +//////////////////////////////////////////////////////////// +void sfMusic_SetAttenuation(sfMusic* music, float attenuation) +{ + CSFML_CALL(music, SetAttenuation(attenuation)); +} + + +//////////////////////////////////////////////////////////// +/// Set the current playing position of a stream +//////////////////////////////////////////////////////////// +void sfMusic_SetPlayingOffset(sfMusic* music, sfUint32 timeOffset) +{ + CSFML_CALL(music, SetPlayingOffset(timeOffset)); +} + + +//////////////////////////////////////////////////////////// +/// Get the pitch of a music +//////////////////////////////////////////////////////////// +float sfMusic_GetPitch(const sfMusic* music) +{ + CSFML_CALL_RETURN(music, GetPitch(), 0.f); +} + + +//////////////////////////////////////////////////////////// +/// Get the volume of a music +//////////////////////////////////////////////////////////// +float sfMusic_GetVolume(const sfMusic* music) +{ + CSFML_CALL_RETURN(music, GetVolume(), 0.f); +} + + +//////////////////////////////////////////////////////////// +/// Get the position of a music +//////////////////////////////////////////////////////////// +void sfMusic_GetPosition(const sfMusic* music, float* x, float* y, float* z) +{ + CSFML_CHECK(music); + + if (x && y && z) + { + sf::Vector3f position = music->This.GetPosition(); + *x = position.x; + *y = position.y; + *z = position.z; + } +} + + +//////////////////////////////////////////////////////////// +/// Tell if the music's position is relative to the listener's +/// position, or if it's absolute +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfMusic_IsRelativeToListener(const sfMusic* music) +{ + CSFML_CALL_RETURN(music, IsRelativeToListener(), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Get the minimum distance of a music +//////////////////////////////////////////////////////////// +float sfMusic_GetMinDistance(const sfMusic* music) +{ + CSFML_CALL_RETURN(music, GetMinDistance(), 0.f); +} + + +//////////////////////////////////////////////////////////// +/// Get the attenuation factor of a music +//////////////////////////////////////////////////////////// +float sfMusic_GetAttenuation(const sfMusic* music) +{ + CSFML_CALL_RETURN(music, GetAttenuation(), 0.f); +} diff --git a/src/SFML/Audio/MusicStruct.h b/src/SFML/Audio/MusicStruct.h new file mode 100644 index 0000000..80b653c --- /dev/null +++ b/src/SFML/Audio/MusicStruct.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_MUSICSTRUCT_H +#define SFML_MUSICSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfMusic +//////////////////////////////////////////////////////////// +struct sfMusic +{ + sf::Music This; +}; + + +#endif // SFML_MUSICSTRUCT_H diff --git a/src/SFML/Audio/Sound.cpp b/src/SFML/Audio/Sound.cpp new file mode 100644 index 0000000..cfd0aa3 --- /dev/null +++ b/src/SFML/Audio/Sound.cpp @@ -0,0 +1,277 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new sound +//////////////////////////////////////////////////////////// +sfSound* sfSound_Create(void) +{ + return new sfSound; +} + + +//////////////////////////////////////////////////////////// +/// Copy an existing sound +//////////////////////////////////////////////////////////// +sfSound* sfSound_Copy(sfSound* sound) +{ + CSFML_CHECK_RETURN(sound, NULL); + + return new sfSound(*sound); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing sound +//////////////////////////////////////////////////////////// +void sfSound_Destroy(sfSound* sound) +{ + delete sound; +} + + +//////////////////////////////////////////////////////////// +/// Start playing a sound +//////////////////////////////////////////////////////////// +void sfSound_Play(sfSound* sound) +{ + CSFML_CALL(sound, Play()) +} + + +//////////////////////////////////////////////////////////// +/// Pause a sound +//////////////////////////////////////////////////////////// +void sfSound_Pause(sfSound* sound) +{ + CSFML_CALL(sound, Pause()) +} + + +//////////////////////////////////////////////////////////// +/// Stop playing a sound +//////////////////////////////////////////////////////////// +void sfSound_Stop(sfSound* sound) +{ + CSFML_CALL(sound, Stop()) +} + + +//////////////////////////////////////////////////////////// +/// Bind a sound buffer to a sound +//////////////////////////////////////////////////////////// +void sfSound_SetBuffer(sfSound* sound, const sfSoundBuffer* buffer) +{ + if (buffer) + { + CSFML_CALL(sound, SetBuffer(buffer->This)) + sound->Buffer = buffer; + } +} + + +//////////////////////////////////////////////////////////// +/// Get the sound buffer bound to a sound +//////////////////////////////////////////////////////////// +const sfSoundBuffer* sfSound_GetBuffer(const sfSound* sound) +{ + CSFML_CHECK_RETURN(sound, NULL) + + return sound->Buffer; +} + + +//////////////////////////////////////////////////////////// +/// Set a sound loop state +//////////////////////////////////////////////////////////// +void sfSound_SetLoop(sfSound* sound, sfBool loop) +{ + CSFML_CALL(sound, SetLoop(loop == sfTrue)) +} + + +//////////////////////////////////////////////////////////// +/// Tell whether or not a sound is looping +//////////////////////////////////////////////////////////// +sfBool sfSound_GetLoop(const sfSound* sound) +{ + CSFML_CALL_RETURN(sound, GetLoop(), sfFalse) +} + + +//////////////////////////////////////////////////////////// +/// Get the status of a sound (stopped, paused, playing) +//////////////////////////////////////////////////////////// +sfSoundStatus sfSound_GetStatus(const sfSound* sound) +{ + CSFML_CHECK_RETURN(sound, sfStopped); + + return static_cast(sound->This.GetStatus()); +} + + +//////////////////////////////////////////////////////////// +/// Set the pitch of a sound +//////////////////////////////////////////////////////////// +void sfSound_SetPitch(sfSound* sound, float pitch) +{ + CSFML_CALL(sound, SetPitch(pitch)) +} + + +//////////////////////////////////////////////////////////// +/// Set the volume of a sound +//////////////////////////////////////////////////////////// +void sfSound_SetVolume(sfSound* sound, float volume) +{ + CSFML_CALL(sound, SetVolume(volume)) +} + + +//////////////////////////////////////////////////////////// +/// Set the position of a sound +//////////////////////////////////////////////////////////// +void sfSound_SetPosition(sfSound* sound, float x, float y, float z) +{ + CSFML_CALL(sound, SetPosition(sf::Vector3f(x, y, z))) +} + + +//////////////////////////////////////////////////////////// +/// Make the sound's position relative to the listener's +/// position, or absolute. +/// The default value is false (absolute) +//////////////////////////////////////////////////////////// +void sfSound_SetRelativeToListener(sfSound* sound, sfBool relative) +{ + CSFML_CALL(sound, SetRelativeToListener(relative == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +/// Set the minimum distance - closer than this distance, +/// the listener will hear the sound at its maximum volume. +/// The default minimum distance is 1.0 +//////////////////////////////////////////////////////////// +void sfSound_SetMinDistance(sfSound* sound, float distance) +{ + CSFML_CALL(sound, SetMinDistance(distance)); +} + + +//////////////////////////////////////////////////////////// +/// Set the attenuation factor - the higher the attenuation, the +/// more the sound will be attenuated with distance from listener. +/// The default attenuation factor is 1.0 +//////////////////////////////////////////////////////////// +void sfSound_SetAttenuation(sfSound* sound, float attenuation) +{ + CSFML_CALL(sound, SetAttenuation(attenuation)); +} + + +//////////////////////////////////////////////////////////// +/// Set the current playing position of a sound +//////////////////////////////////////////////////////////// +void sfSound_SetPlayingOffset(sfSound* sound, sfUint32 timeOffset) +{ + CSFML_CALL(sound, SetPlayingOffset(timeOffset)); +} + + +//////////////////////////////////////////////////////////// +/// Get the pitch of a sound +//////////////////////////////////////////////////////////// +float sfSound_GetPitch(const sfSound* sound) +{ + CSFML_CALL_RETURN(sound, GetPitch(), 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the volume of a sound +//////////////////////////////////////////////////////////// +float sfSound_GetVolume(const sfSound* sound) +{ + CSFML_CALL_RETURN(sound, GetVolume(), 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the position of a sound +//////////////////////////////////////////////////////////// +void sfSound_GetPosition(const sfSound* sound, float* x, float* y, float* z) +{ + CSFML_CHECK(sound); + + sf::Vector3f position = sound->This.GetPosition(); + if (x) *x = position.x; + if (y) *y = position.y; + if (z) *z = position.z; +} + + +//////////////////////////////////////////////////////////// +/// Tell if the sound's position is relative to the listener's +/// position, or if it's absolute +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfSound_IsRelativeToListener(const sfSound* sound) +{ + CSFML_CALL_RETURN(sound, IsRelativeToListener(), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Get the minimum distance of a sound +//////////////////////////////////////////////////////////// +float sfSound_GetMinDistance(const sfSound* sound) +{ + CSFML_CALL_RETURN(sound, GetMinDistance(), 0.f); +} + + +//////////////////////////////////////////////////////////// +/// Get the attenuation factor of a sound +//////////////////////////////////////////////////////////// +float sfSound_GetAttenuation(const sfSound* sound) +{ + CSFML_CALL_RETURN(sound, GetAttenuation(), 0.f); +} + + +//////////////////////////////////////////////////////////// +/// Get the current playing position of a sound +//////////////////////////////////////////////////////////// +sfUint32 sfSound_GetPlayingOffset(const sfSound* sound) +{ + CSFML_CALL_RETURN(sound, GetPlayingOffset(), 0) +} diff --git a/src/SFML/Audio/SoundBuffer.cpp b/src/SFML/Audio/SoundBuffer.cpp new file mode 100644 index 0000000..eb0040f --- /dev/null +++ b/src/SFML/Audio/SoundBuffer.cpp @@ -0,0 +1,157 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new sound buffer and load it from a file +//////////////////////////////////////////////////////////// +sfSoundBuffer* sfSoundBuffer_CreateFromFile(const char* filename) +{ + sfSoundBuffer* buffer = new sfSoundBuffer; + + if (!buffer->This.LoadFromFile(filename)) + { + delete buffer; + buffer = NULL; + } + + return buffer; +} + + +//////////////////////////////////////////////////////////// +/// Create a new sound buffer and load it from a file in memory +//////////////////////////////////////////////////////////// +sfSoundBuffer* sfSoundBuffer_CreateFromMemory(const void* data, size_t sizeInBytes) +{ + sfSoundBuffer* buffer = new sfSoundBuffer; + + if (!buffer->This.LoadFromMemory(data, sizeInBytes)) + { + delete buffer; + buffer = NULL; + } + + return buffer; +} + + +//////////////////////////////////////////////////////////// +/// Create a new sound buffer and load it from an array of +/// samples in memory - assumed format for samples is +/// 16 bits signed integer +//////////////////////////////////////////////////////////// +sfSoundBuffer* sfSoundBuffer_CreateFromSamples(const sfInt16* samples, size_t samplesCount, unsigned int channelsCount, unsigned int sampleRate) +{ + sfSoundBuffer* buffer = new sfSoundBuffer; + + if (!buffer->This.LoadFromSamples(samples, samplesCount, channelsCount, sampleRate)) + { + delete buffer; + buffer = NULL; + } + + return buffer; +} + + +//////////////////////////////////////////////////////////// +/// Copy an existing sound buffer +//////////////////////////////////////////////////////////// +sfSoundBuffer* sfSoundBuffer_Copy(sfSoundBuffer* soundBuffer) +{ + CSFML_CHECK_RETURN(soundBuffer, NULL); + + return new sfSoundBuffer(*soundBuffer); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing sound buffer +//////////////////////////////////////////////////////////// +void sfSoundBuffer_Destroy(sfSoundBuffer* soundBuffer) +{ + delete soundBuffer; +} + + +//////////////////////////////////////////////////////////// +/// Save a sound buffer to a file +//////////////////////////////////////////////////////////// +sfBool sfSoundBuffer_SaveToFile(const sfSoundBuffer* soundBuffer, const char* filename) +{ + CSFML_CALL_RETURN(soundBuffer, SaveToFile(filename), sfFalse) +} + + +//////////////////////////////////////////////////////////// +/// Return the samples contained in a sound buffer +//////////////////////////////////////////////////////////// +const sfInt16* sfSoundBuffer_GetSamples(const sfSoundBuffer* soundBuffer) +{ + CSFML_CALL_RETURN(soundBuffer, GetSamples(), NULL) +} + + +//////////////////////////////////////////////////////////// +/// Return the number of samples contained in a sound buffer +//////////////////////////////////////////////////////////// +size_t sfSoundBuffer_GetSamplesCount(const sfSoundBuffer* soundBuffer) +{ + CSFML_CALL_RETURN(soundBuffer, GetSamplesCount(), 0) +} + + +//////////////////////////////////////////////////////////// +/// Get the sample rate of a sound buffer +//////////////////////////////////////////////////////////// +unsigned int sfSoundBuffer_GetSampleRate(const sfSoundBuffer* soundBuffer) +{ + CSFML_CALL_RETURN(soundBuffer, GetSampleRate(), 0) +} + + +//////////////////////////////////////////////////////////// +/// Return the number of channels of a sound buffer (1 = mono, 2 = stereo, ...) +//////////////////////////////////////////////////////////// +unsigned int sfSoundBuffer_GetChannelsCount(const sfSoundBuffer* soundBuffer) +{ + CSFML_CALL_RETURN(soundBuffer, GetChannelsCount(), 0) +} + + +//////////////////////////////////////////////////////////// +/// Get the duration of a sound buffer +//////////////////////////////////////////////////////////// +sfUint32 sfSoundBuffer_GetDuration(const sfSoundBuffer* soundBuffer) +{ + CSFML_CALL_RETURN(soundBuffer, GetDuration(), 0) +} diff --git a/src/SFML/Audio/SoundBufferRecorder.cpp b/src/SFML/Audio/SoundBufferRecorder.cpp new file mode 100644 index 0000000..04d8fc3 --- /dev/null +++ b/src/SFML/Audio/SoundBufferRecorder.cpp @@ -0,0 +1,90 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new sound buffer recorder +//////////////////////////////////////////////////////////// +sfSoundBufferRecorder* sfSoundBufferRecorder_Create(void) +{ + return new sfSoundBufferRecorder; +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing sound buffer recorder +//////////////////////////////////////////////////////////// +void sfSoundBufferRecorder_Destroy(sfSoundBufferRecorder* soundBufferRecorder) +{ + delete soundBufferRecorder; +} + + +//////////////////////////////////////////////////////////// +/// Start the capture. +/// Warning : only one capture can happen at the same time +//////////////////////////////////////////////////////////// +void sfSoundBufferRecorder_Start(sfSoundBufferRecorder* soundBufferRecorder, unsigned int sampleRate) +{ + CSFML_CALL(soundBufferRecorder, Start(sampleRate)); +} + + +//////////////////////////////////////////////////////////// +/// Stop the capture +//////////////////////////////////////////////////////////// +void sfSoundBufferRecorder_Stop(sfSoundBufferRecorder* soundBufferRecorder) +{ + CSFML_CALL(soundBufferRecorder, Stop()); +} + + +//////////////////////////////////////////////////////////// +/// Get the sample rate of a sound buffer recorder +//////////////////////////////////////////////////////////// +unsigned int sfSoundBufferRecorder_GetSampleRate(const sfSoundBufferRecorder* soundBufferRecorder) +{ + CSFML_CALL_RETURN(soundBufferRecorder, GetSampleRate(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Get the sound buffer containing the captured audio data +/// of a sound buffer recorder +//////////////////////////////////////////////////////////// +const sfSoundBuffer* sfSoundBufferRecorder_GetBuffer(const sfSoundBufferRecorder* soundBufferRecorder) +{ + CSFML_CHECK_RETURN(soundBufferRecorder, NULL); + + soundBufferRecorder->SoundBuffer.This = soundBufferRecorder->This.GetBuffer(); + + return &soundBufferRecorder->SoundBuffer; +} diff --git a/src/SFML/Audio/SoundBufferRecorderStruct.h b/src/SFML/Audio/SoundBufferRecorderStruct.h new file mode 100644 index 0000000..aa8a091 --- /dev/null +++ b/src/SFML/Audio/SoundBufferRecorderStruct.h @@ -0,0 +1,45 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SOUNDBUFFERRECORDERSTRUCT_H +#define SFML_SOUNDBUFFERRECORDERSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfSoundBufferRecorder +//////////////////////////////////////////////////////////// +struct sfSoundBufferRecorder +{ + sf::SoundBufferRecorder This; + mutable sfSoundBuffer SoundBuffer; +}; + + +#endif // SFML_SOUNDBUFFERRECORDERSTRUCT_H diff --git a/src/SFML/Audio/SoundBufferStruct.h b/src/SFML/Audio/SoundBufferStruct.h new file mode 100644 index 0000000..27424c7 --- /dev/null +++ b/src/SFML/Audio/SoundBufferStruct.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SOUNDBUFFERSTRUCT_H +#define SFML_SOUNDBUFFERSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfSoundBuffer +//////////////////////////////////////////////////////////// +struct sfSoundBuffer +{ + sf::SoundBuffer This; +}; + + +#endif // SFML_SOUNDBUFFERSTRUCT_H diff --git a/src/SFML/Audio/SoundRecorder.cpp b/src/SFML/Audio/SoundRecorder.cpp new file mode 100644 index 0000000..a925cf9 --- /dev/null +++ b/src/SFML/Audio/SoundRecorder.cpp @@ -0,0 +1,90 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new sound recorder with callback functions +/// for processing captured samples +//////////////////////////////////////////////////////////// +sfSoundRecorder* sfSoundRecorder_Create(sfSoundRecorderStartCallback onStart, + sfSoundRecorderProcessCallback onProcess, + sfSoundRecorderStopCallback onStop, + void* userData) +{ + return new sfSoundRecorder(onStart, onProcess, onStop, userData); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing sound recorder +//////////////////////////////////////////////////////////// +void sfSoundRecorder_Destroy(sfSoundRecorder* soundRecorder) +{ + delete soundRecorder; +} + + +//////////////////////////////////////////////////////////// +/// Start the capture. +/// Warning : only one capture can happen at the same time +//////////////////////////////////////////////////////////// +void sfSoundRecorder_Start(sfSoundRecorder* soundRecorder, unsigned int sampleRate) +{ + CSFML_CALL(soundRecorder, Start(sampleRate)); +} + + +//////////////////////////////////////////////////////////// +/// Stop the capture +//////////////////////////////////////////////////////////// +void sfSoundRecorder_Stop(sfSoundRecorder* soundRecorder) +{ + CSFML_CALL(soundRecorder, Stop()); +} + + +//////////////////////////////////////////////////////////// +/// Get the sample rate of a sound recorder +//////////////////////////////////////////////////////////// +unsigned int sfSoundRecorder_GetSampleRate(const sfSoundRecorder* soundRecorder) +{ + CSFML_CALL_RETURN(soundRecorder, GetSampleRate(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Tell if the system supports sound capture. +/// If not, this class won't be usable +//////////////////////////////////////////////////////////// +sfBool sfSoundRecorder_IsAvailable(void) +{ + return sf::SoundRecorder::IsAvailable() ? sfTrue : sfFalse; +} diff --git a/src/SFML/Audio/SoundRecorderStruct.h b/src/SFML/Audio/SoundRecorderStruct.h new file mode 100644 index 0000000..9bf5b13 --- /dev/null +++ b/src/SFML/Audio/SoundRecorderStruct.h @@ -0,0 +1,102 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SOUNDRECORDERSTRUCT_H +#define SFML_SOUNDRECORDERSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +// Helper class implementing the callback forwarding from +// C++ to C in sfSoundRecorder +//////////////////////////////////////////////////////////// +class sfSoundRecorderImpl : public sf::SoundRecorder +{ +public : + + sfSoundRecorderImpl(sfSoundRecorderStartCallback OnStart, + sfSoundRecorderProcessCallback OnProcess, + sfSoundRecorderStopCallback OnStop, + void* UserData) : + myStartCallback (OnStart), + myProcessCallback(OnProcess), + myStopCallback (OnStop), + myUserData (UserData) + { + } + +private : + + virtual bool OnStart() + { + if (myStartCallback) + return myStartCallback(myUserData) == sfTrue; + else + return true; + } + + virtual bool OnProcessSamples(const sf::Int16* Samples, std::size_t SamplesCount) + { + if (myProcessCallback) + return myProcessCallback(Samples, SamplesCount, myUserData) == sfTrue; + else + return true; + } + + virtual void OnStop() + { + if (myStopCallback) + myStopCallback(myUserData); + } + + sfSoundRecorderStartCallback myStartCallback; + sfSoundRecorderProcessCallback myProcessCallback; + sfSoundRecorderStopCallback myStopCallback; + void* myUserData; +}; + + +//////////////////////////////////////////////////////////// +// Internal structure of sfPacket +//////////////////////////////////////////////////////////// +struct sfSoundRecorder +{ + sfSoundRecorder(sfSoundRecorderStartCallback OnStart, + sfSoundRecorderProcessCallback OnProcess, + sfSoundRecorderStopCallback OnStop, + void* UserData) : + This(OnStart, OnProcess, OnStop, UserData) + { + } + + sfSoundRecorderImpl This; +}; + + +#endif // SFML_SOUNDRECORDERSTRUCT_H diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp new file mode 100644 index 0000000..da3d36c --- /dev/null +++ b/src/SFML/Audio/SoundStream.cpp @@ -0,0 +1,265 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new sound stream +//////////////////////////////////////////////////////////// +sfSoundStream* sfSoundStream_Create(sfSoundStreamGetDataCallback onGetData, + sfSoundStreamSeekCallback onSeek, + unsigned int channelsCount, + unsigned int sampleRate, + void* userData) +{ + return new sfSoundStream(onGetData, onSeek, channelsCount, sampleRate, userData); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing sound stream +//////////////////////////////////////////////////////////// +void sfSoundStream_Destroy(sfSoundStream* soundStream) +{ + delete soundStream; +} + + +//////////////////////////////////////////////////////////// +/// Start playing a sound stream +//////////////////////////////////////////////////////////// +void sfSoundStream_Play(sfSoundStream* soundStream) +{ + CSFML_CALL(soundStream, Play()); +} + + +//////////////////////////////////////////////////////////// +/// Pause a sound stream +//////////////////////////////////////////////////////////// +void sfSoundStream_Pause(sfSoundStream* soundStream) +{ + CSFML_CALL(soundStream, Pause()); +} + + +//////////////////////////////////////////////////////////// +/// Stop playing a sound stream +//////////////////////////////////////////////////////////// +void sfSoundStream_Stop(sfSoundStream* soundStream) +{ + CSFML_CALL(soundStream, Stop()); +} + + +//////////////////////////////////////////////////////////// +/// Get the status of a sound stream (stopped, paused, playing) +//////////////////////////////////////////////////////////// +sfSoundStatus sfSoundStream_GetStatus(const sfSoundStream* soundStream) +{ + CSFML_CHECK_RETURN(soundStream, sfStopped); + + return static_cast(soundStream->This.GetStatus()); +} + + +//////////////////////////////////////////////////////////// +/// Return the number of channels of a sound stream +/// (1 = mono, 2 = stereo) +//////////////////////////////////////////////////////////// +unsigned int sfSoundStream_GetChannelsCount(const sfSoundStream* soundStream) +{ + CSFML_CALL_RETURN(soundStream, GetChannelsCount(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Get the sample rate of a sound stream +//////////////////////////////////////////////////////////// +unsigned int sfSoundStream_GetSampleRate(const sfSoundStream* soundStream) +{ + CSFML_CALL_RETURN(soundStream, GetSampleRate(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Set the pitch of a sound stream +//////////////////////////////////////////////////////////// +void sfSoundStream_SetPitch(sfSoundStream* soundStream, float pitch) +{ + CSFML_CALL(soundStream, SetPitch(pitch)); +} + + +//////////////////////////////////////////////////////////// +/// Set the volume of a sound stream +//////////////////////////////////////////////////////////// +void sfSoundStream_SetVolume(sfSoundStream* soundStream, float volume) +{ + CSFML_CALL(soundStream, SetVolume(volume)); +} + + +//////////////////////////////////////////////////////////// +/// Set the position of a sound stream +//////////////////////////////////////////////////////////// +void sfSoundStream_SetPosition(sfSoundStream* soundStream, float x, float y, float z) +{ + CSFML_CALL(soundStream, SetPosition(x, y, z)); +} + + +//////////////////////////////////////////////////////////// +/// Make the sound stream's position relative to the listener's +/// position, or absolute. +/// The default value is false (absolute) +//////////////////////////////////////////////////////////// +void sfSoundStream_SetRelativeToListener(sfSoundStream* soundStream, sfBool relative) +{ + CSFML_CALL(soundStream, SetRelativeToListener(relative == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +/// Set the minimum distance - closer than this distance, +/// the listener will hear the sound stream at its maximum volume. +/// The default minimum distance is 1.0 +//////////////////////////////////////////////////////////// +void sfSoundStream_SetMinDistance(sfSoundStream* soundStream, float distance) +{ + CSFML_CALL(soundStream, SetMinDistance(distance)); +} + + +//////////////////////////////////////////////////////////// +/// Set the attenuation factor - the higher the attenuation, the +/// more the sound stream will be attenuated with distance from listener. +/// The default attenuation factor 1.0 +//////////////////////////////////////////////////////////// +void sfSoundStream_SetAttenuation(sfSoundStream* soundStream, float attenuation) +{ + CSFML_CALL(soundStream, SetAttenuation(attenuation)); +} + + +//////////////////////////////////////////////////////////// +/// Set the current playing position of a stream +//////////////////////////////////////////////////////////// +void sfSoundStream_SetPlayingOffset(sfSoundStream* soundStream, sfUint32 timeOffset) +{ + CSFML_CALL(soundStream, SetPlayingOffset(timeOffset)); +} + + +//////////////////////////////////////////////////////////// +/// Set a stream loop state +//////////////////////////////////////////////////////////// +void sfSoundStream_SetLoop(sfSoundStream* soundStream, sfBool loop) +{ + CSFML_CALL(soundStream, SetLoop(loop == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +/// Get the pitch of a sound stream +//////////////////////////////////////////////////////////// +float sfSoundStream_GetPitch(const sfSoundStream* soundStream) +{ + CSFML_CALL_RETURN(soundStream, GetPitch(), 0.f); +} + + +//////////////////////////////////////////////////////////// +/// Get the volume of a sound stream +//////////////////////////////////////////////////////////// +float sfSoundStream_GetVolume(const sfSoundStream* soundStream) +{ + CSFML_CALL_RETURN(soundStream, GetVolume(), 0.f); +} + + +//////////////////////////////////////////////////////////// +/// Get the position of a sound stream +//////////////////////////////////////////////////////////// +void sfSoundStream_GetPosition(const sfSoundStream* soundStream, float* x, float* y, float* z) +{ + CSFML_CHECK(soundStream); + + sf::Vector3f position = soundStream->This.GetPosition(); + if (x) *x = position.x; + if (y) *y = position.y; + if (z) *z = position.z; +} + + +//////////////////////////////////////////////////////////// +/// Tell if the sound stream's position is relative to the listener's +/// position, or if it's absolute +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfSoundStream_IsRelativeToListener(const sfSoundStream* soundStream) +{ + CSFML_CALL_RETURN(soundStream, IsRelativeToListener(), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Get the minimum distance of a sound stream +//////////////////////////////////////////////////////////// +float sfSoundStream_GetMinDistance(const sfSoundStream* soundStream) +{ + CSFML_CALL_RETURN(soundStream, GetMinDistance(), 0.f); +} + + +//////////////////////////////////////////////////////////// +/// Get the attenuation factor of a sound stream +//////////////////////////////////////////////////////////// +float sfSoundStream_GetAttenuation(const sfSoundStream* soundStream) +{ + CSFML_CALL_RETURN(soundStream, GetAttenuation(), 0.f); +} + + +//////////////////////////////////////////////////////////// +/// Tell whether or not a stream is looping +//////////////////////////////////////////////////////////// +sfBool sfSoundStream_GetLoop(const sfSoundStream* soundStream) +{ + CSFML_CALL_RETURN(soundStream, GetLoop(), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Get the current playing position of a sound stream +//////////////////////////////////////////////////////////// +sfUint32 sfSoundStream_GetPlayingOffset(const sfSoundStream* soundStream) +{ + CSFML_CALL_RETURN(soundStream, GetPlayingOffset(), 0); +} diff --git a/src/SFML/Audio/SoundStreamStruct.h b/src/SFML/Audio/SoundStreamStruct.h new file mode 100644 index 0000000..a5a1828 --- /dev/null +++ b/src/SFML/Audio/SoundStreamStruct.h @@ -0,0 +1,97 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SOUNDSTREAMSTRUCT_H +#define SFML_SOUNDSTREAMSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Helper class implementing the callback forwarding from +// C++ to C in sfSoundStream +//////////////////////////////////////////////////////////// +class sfSoundStreamImpl : public sf::SoundStream +{ +public : + + sfSoundStreamImpl(sfSoundStreamGetDataCallback OnGetData, + sfSoundStreamSeekCallback OnSeek, + unsigned int ChannelsCount, + unsigned int SampleRate, + void* UserData) : + myGetDataCallback(OnGetData), + mySeekCallback (OnSeek), + myUserData (UserData) + { + Initialize(ChannelsCount, SampleRate); + } + +private : + + virtual bool OnGetData(Chunk& Data) + { + sfSoundStreamChunk Chunk = {NULL, 0}; + bool Continue = (myGetDataCallback(&Chunk, myUserData) == sfTrue); + + Data.Samples = Chunk.Samples; + Data.NbSamples = Chunk.NbSamples; + + return Continue; + } + + virtual void OnSeek(sfUint32 TimeOffset) + { + if (mySeekCallback) + mySeekCallback(TimeOffset, myUserData); + } + + sfSoundStreamGetDataCallback myGetDataCallback; + sfSoundStreamSeekCallback mySeekCallback; + void* myUserData; +}; + + +//////////////////////////////////////////////////////////// +// Internal structure of sfSoundStream +//////////////////////////////////////////////////////////// +struct sfSoundStream +{ + sfSoundStream(sfSoundStreamGetDataCallback OnGetData, + sfSoundStreamSeekCallback OnSeek, + unsigned int ChannelsCount, + unsigned int SampleRate, + void* UserData) : + This(OnGetData, OnSeek, ChannelsCount, SampleRate, UserData) + { + } + + sfSoundStreamImpl This; +}; + + +#endif // SFML_SOUNDSTREAMSTRUCT_H diff --git a/src/SFML/Audio/SoundStruct.h b/src/SFML/Audio/SoundStruct.h new file mode 100644 index 0000000..136a32c --- /dev/null +++ b/src/SFML/Audio/SoundStruct.h @@ -0,0 +1,45 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SOUNDSTRUCT_H +#define SFML_SOUNDSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfSound +//////////////////////////////////////////////////////////// +struct sfSound +{ + sf::Sound This; + const sfSoundBuffer* Buffer; +}; + + +#endif // SFML_SOUNDSTRUCT_H diff --git a/src/SFML/CMakeLists.txt b/src/SFML/CMakeLists.txt new file mode 100644 index 0000000..1155007 --- /dev/null +++ b/src/SFML/CMakeLists.txt @@ -0,0 +1,33 @@ + +# include the SFML specific macros +include(${CMAKE_SOURCE_DIR}/cmake/Macros.cmake) + +# add the CSFML sources path +include_directories(${CMAKE_SOURCE_DIR}/src) + +# define the path of our additional CMake modules +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/") + +# set the output directory for CSFML libraries +set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib") + +# define the export symbol +add_definitions(-DCSFML_EXPORTS) + +# find SFML libraries (C++) +if(WINDOWS) + set(SFML_STATIC_LIBRARIES TRUE) + add_definitions(-DSFML_STATIC) +endif() +find_package(SFML 2.0 COMPONENTS system window network graphics audio REQUIRED) +include_directories(${SFML_INCLUDE_DIR}) + +# add the modules subdirectories +add_subdirectory(System) +add_subdirectory(Window) +add_subdirectory(Network) +add_subdirectory(Graphics) +add_subdirectory(Audio) +if(WINDOWS) + add_subdirectory(Main) +endif() diff --git a/src/SFML/ConvertEvent.h b/src/SFML/ConvertEvent.h new file mode 100644 index 0000000..31c4dad --- /dev/null +++ b/src/SFML/ConvertEvent.h @@ -0,0 +1,107 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_CONVERTEVENT_H +#define SFML_CONVERTEVENT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +// Define a function to convert a sf::Event ot a sfEvent +//////////////////////////////////////////////////////////// +inline void ConvertEvent(const sf::Event& SFMLEvent, sfEvent* event) +{ + // Convert its type + event->Type = static_cast(SFMLEvent.Type); + + // Fill its fields + switch (event->Type) + { + case sfEvtResized : + event->Size.Width = SFMLEvent.Size.Width; + event->Size.Height = SFMLEvent.Size.Height; + break; + + case sfEvtTextEntered : + event->Text.Unicode = SFMLEvent.Text.Unicode; + break; + + case sfEvtKeyReleased : + case sfEvtKeyPressed : + event->Key.Code = static_cast(SFMLEvent.Key.Code); + event->Key.Alt = SFMLEvent.Key.Alt ? sfTrue : sfFalse; + event->Key.Control = SFMLEvent.Key.Control ? sfTrue : sfFalse; + event->Key.Shift = SFMLEvent.Key.Shift ? sfTrue : sfFalse; + event->Key.System = SFMLEvent.Key.System ? sfTrue : sfFalse; + break; + + case sfEvtMouseWheelMoved : + event->MouseWheel.Delta = SFMLEvent.MouseWheel.Delta; + event->MouseWheel.X = SFMLEvent.MouseWheel.X; + event->MouseWheel.Y = SFMLEvent.MouseWheel.Y; + break; + + case sfEvtMouseButtonPressed : + case sfEvtMouseButtonReleased : + event->MouseButton.Button = static_cast(SFMLEvent.MouseButton.Button); + event->MouseButton.X = SFMLEvent.MouseButton.X; + event->MouseButton.Y = SFMLEvent.MouseButton.Y; + break; + + case sfEvtMouseMoved : + event->MouseMove.X = SFMLEvent.MouseMove.X; + event->MouseMove.Y = SFMLEvent.MouseMove.Y; + break; + + case sfEvtJoystickButtonPressed : + case sfEvtJoystickButtonReleased : + event->JoystickButton.JoystickId = SFMLEvent.JoystickButton.JoystickId; + event->JoystickButton.Button = SFMLEvent.JoystickButton.Button; + break; + + case sfEvtJoystickMoved : + event->JoystickMove.JoystickId = SFMLEvent.JoystickMove.JoystickId; + event->JoystickMove.Axis = static_cast(SFMLEvent.JoystickMove.Axis); + event->JoystickMove.Position = SFMLEvent.JoystickMove.Position; + break; + + case sfEvtJoystickConnected : + event->JoystickConnect.JoystickId = SFMLEvent.JoystickConnect.JoystickId; + break; + + case sfEvtJoystickDisconnected : + event->JoystickConnect.JoystickId = SFMLEvent.JoystickConnect.JoystickId; + break; + + default : + break; + } +} + +#endif // SFML_CONVERTEVENT_H diff --git a/src/SFML/Graphics/CMakeLists.txt b/src/SFML/Graphics/CMakeLists.txt new file mode 100644 index 0000000..28afee7 --- /dev/null +++ b/src/SFML/Graphics/CMakeLists.txt @@ -0,0 +1,46 @@ + +set(INCROOT ${CMAKE_SOURCE_DIR}/include/SFML/Graphics) +set(SRCROOT ${CMAKE_SOURCE_DIR}/src/SFML/Graphics) + +# all source files +set(SRC + ${INCROOT}/BlendMode.h + ${SRCROOT}/Color.cpp + ${INCROOT}/Color.h + ${SRCROOT}/Font.cpp + ${SRCROOT}/FontStruct.h + ${INCROOT}/Font.h + ${INCROOT}/Glyph.h + ${SRCROOT}/Image.cpp + ${SRCROOT}/ImageStruct.h + ${INCROOT}/Image.h + ${SRCROOT}/Rect.cpp + ${INCROOT}/Rect.h + ${SRCROOT}/RenderImage.cpp + ${SRCROOT}/RenderImageStruct.h + ${INCROOT}/RenderImage.h + ${SRCROOT}/RenderWindow.cpp + ${SRCROOT}/RenderWindowStruct.h + ${INCROOT}/RenderWindow.h + ${SRCROOT}/Shader.cpp + ${SRCROOT}/ShaderStruct.h + ${INCROOT}/Shader.h + ${SRCROOT}/Shape.cpp + ${SRCROOT}/ShapeStruct.h + ${INCROOT}/Shape.h + ${SRCROOT}/Sprite.cpp + ${SRCROOT}/SpriteStruct.h + ${INCROOT}/Sprite.h + ${SRCROOT}/Text.cpp + ${SRCROOT}/TextStruct.h + ${INCROOT}/Text.h + ${INCROOT}/Types.h + ${SRCROOT}/View.cpp + ${SRCROOT}/ViewStruct.h + ${INCROOT}/View.h +) + +# define the csfml-graphics target +csfml_add_library(csfml-graphics + SOURCES ${SRC} + DEPENDS ${SFML_GRAPHICS_LIBRARY} ${SFML_WINDOW_LIBRARY} ${SFML_SYSTEM_LIBRARY}) diff --git a/src/SFML/Graphics/Color.cpp b/src/SFML/Graphics/Color.cpp new file mode 100644 index 0000000..6ff2009 --- /dev/null +++ b/src/SFML/Graphics/Color.cpp @@ -0,0 +1,102 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Define some common colors +//////////////////////////////////////////////////////////// +sfColor sfBlack = sfColor_FromRGB( 0, 0, 0); +sfColor sfWhite = sfColor_FromRGB(255, 255, 255); +sfColor sfRed = sfColor_FromRGB(255, 0, 0); +sfColor sfGreen = sfColor_FromRGB( 0, 255, 0); +sfColor sfBlue = sfColor_FromRGB( 0, 0, 255); +sfColor sfYellow = sfColor_FromRGB(255, 255, 0); +sfColor sfMagenta = sfColor_FromRGB(255, 0, 255); +sfColor sfCyan = sfColor_FromRGB( 0, 255, 255); + + +//////////////////////////////////////////////////////////// +/// Construct a color from its 3 RGB components +//////////////////////////////////////////////////////////// +sfColor sfColor_FromRGB(sfUint8 red, sfUint8 green, sfUint8 blue) +{ + return sfColor_FromRGBA(red, green, blue, 255); +} + + +//////////////////////////////////////////////////////////// +/// Construct a color from its 4 RGBA components +//////////////////////////////////////////////////////////// +sfColor sfColor_FromRGBA(sfUint8 red, sfUint8 green, sfUint8 blue, sfUint8 alpha) +{ + sfColor color; + + color.r = red; + color.g = green; + color.b = blue; + color.a = alpha; + + return color; +} + + +//////////////////////////////////////////////////////////// +/// Add two colors +//////////////////////////////////////////////////////////// +sfColor sfColor_Add(sfColor color1, sfColor color2) +{ + int red = std::min(color1.r + color2.r, 255); + int green = std::min(color1.g + color2.g, 255); + int blue = std::min(color1.b + color2.b, 255); + int alpha = std::min(color1.a + color2.a, 255); + + return sfColor_FromRGBA(static_cast(red), + static_cast(green), + static_cast(blue), + static_cast(alpha)); +} + + +//////////////////////////////////////////////////////////// +/// Modulate two colors +//////////////////////////////////////////////////////////// +sfColor sfColor_Modulate(sfColor color1, sfColor color2) +{ + int red = color1.r * color2.r / 255; + int green = color1.g * color2.g / 255; + int blue = color1.b * color2.b / 255; + int alpha = color1.a * color2.a / 255; + + return sfColor_FromRGBA(static_cast(red), + static_cast(green), + static_cast(blue), + static_cast(alpha)); +} diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp new file mode 100644 index 0000000..2e4c510 --- /dev/null +++ b/src/SFML/Graphics/Font.cpp @@ -0,0 +1,148 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new font from a file +//////////////////////////////////////////////////////////// +sfFont* sfFont_CreateFromFile(const char* filename) +{ + sfFont* font = new sfFont; + if (!font->This.LoadFromFile(filename)) + { + delete font; + font = NULL; + } + + return font; +} + + +//////////////////////////////////////////////////////////// +/// Create a new font from a file in memory +//////////////////////////////////////////////////////////// +sfFont* sfFont_CreateFromMemory(const void* data, size_t sizeInBytes) +{ + sfFont* font = new sfFont; + if (!font->This.LoadFromMemory(data, sizeInBytes)) + { + delete font; + font = NULL; + } + + return font; +} + + +//////////////////////////////////////////////////////////// +/// Copy an existing font +//////////////////////////////////////////////////////////// +sfFont* sfFont_Copy(sfFont* font) +{ + CSFML_CHECK_RETURN(font, NULL); + + return new sfFont(*font); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing font +//////////////////////////////////////////////////////////// +void sfFont_Destroy(sfFont* font) +{ + delete font; +} + + +//////////////////////////////////////////////////////////// +/// Get a glyph in a font +//////////////////////////////////////////////////////////// +sfGlyph sfFont_GetGlyph(sfFont* font, sfUint32 codePoint, unsigned int characterSize, sfBool bold) +{ + sfGlyph glyph = {0, {0, 0, 0, 0}, {0, 0, 0, 0}}; + CSFML_CHECK_RETURN(font, glyph); + + sf::Glyph SFMLGlyph = font->This.GetGlyph(codePoint, characterSize, bold == sfTrue); + + glyph.Advance = SFMLGlyph.Advance; + glyph.Bounds.Left = SFMLGlyph.Bounds.Left; + glyph.Bounds.Top = SFMLGlyph.Bounds.Top; + glyph.Bounds.Width = SFMLGlyph.Bounds.Width; + glyph.Bounds.Height = SFMLGlyph.Bounds.Height; + glyph.SubRect.Left = SFMLGlyph.SubRect.Left; + glyph.SubRect.Top = SFMLGlyph.SubRect.Top; + glyph.SubRect.Width = SFMLGlyph.SubRect.Width; + glyph.SubRect.Height = SFMLGlyph.SubRect.Height; + + return glyph; +} + + +//////////////////////////////////////////////////////////// +/// Get the kerning value corresponding to a given pair of characters in a font +//////////////////////////////////////////////////////////// +int sfFont_GetKerning(sfFont* font, sfUint32 first, sfUint32 second, unsigned int characterSize) +{ + CSFML_CALL_RETURN(font, GetKerning(first, second, characterSize), 0); +} + + +//////////////////////////////////////////////////////////// +/// Get the line spacing value +//////////////////////////////////////////////////////////// +int sfFont_GetLineSpacing(sfFont* font, unsigned int characterSize) +{ + CSFML_CALL_RETURN(font, GetLineSpacing(characterSize), 0); +} + + +//////////////////////////////////////////////////////////// +/// Get the image containing the glyphs of a given size in a font +//////////////////////////////////////////////////////////// +const sfImage* sfFont_GetImage(sfFont* font, unsigned int characterSize) +{ + CSFML_CHECK_RETURN(font, NULL); + + *font->Images[characterSize].This = font->This.GetImage(characterSize); + + return &font->Images[characterSize]; +} + + +//////////////////////////////////////////////////////////// +/// Get the built-in default font (Arial) +//////////////////////////////////////////////////////////// +const sfFont* sfFont_GetDefaultFont(void) +{ + static sfFont defaultFont = {sf::Font::GetDefaultFont(), std::map()}; + + return &defaultFont; +} diff --git a/src/SFML/Graphics/FontStruct.h b/src/SFML/Graphics/FontStruct.h new file mode 100644 index 0000000..8336194 --- /dev/null +++ b/src/SFML/Graphics/FontStruct.h @@ -0,0 +1,46 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_FONTSTRUCT_H +#define SFML_FONTSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfFont +//////////////////////////////////////////////////////////// +struct sfFont +{ + sf::Font This; + std::map Images; +}; + + +#endif // SFML_FONTSTRUCT_H diff --git a/src/SFML/Graphics/Image.cpp b/src/SFML/Graphics/Image.cpp new file mode 100644 index 0000000..33761b2 --- /dev/null +++ b/src/SFML/Graphics/Image.cpp @@ -0,0 +1,254 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new image filled with a color +//////////////////////////////////////////////////////////// +sfImage* sfImage_CreateFromColor(unsigned int width, unsigned int height, sfColor color) +{ + sfImage* image = new sfImage; + + if (!image->This->Create(width, height, sf::Color(color.r, color.g, color.b, color.a))) + { + delete image; + image = NULL; + } + + return image; +} + + +//////////////////////////////////////////////////////////// +/// Create a new image from an array of pixels in memory +//////////////////////////////////////////////////////////// +sfImage* sfImage_CreateFromPixels(unsigned int width, unsigned int height, const sfUint8* data) +{ + sfImage* image = new sfImage; + + if (!image->This->LoadFromPixels(width, height, data)) + { + delete image; + image = NULL; + } + + return image; +} + + +//////////////////////////////////////////////////////////// +/// Create a new image from a file +//////////////////////////////////////////////////////////// +sfImage* sfImage_CreateFromFile(const char* filename) +{ + sfImage* image = new sfImage; + + if (!image->This->LoadFromFile(filename)) + { + delete image; + image = NULL; + } + + return image; +} + + +//////////////////////////////////////////////////////////// +/// Create a new image from a file in memory +//////////////////////////////////////////////////////////// +sfImage* sfImage_CreateFromMemory(const void* data, size_t sizeInBytes) +{ + sfImage* image = new sfImage; + + if (!image->This->LoadFromMemory(data, sizeInBytes)) + { + delete image; + image = NULL; + } + + return image; +} + + +//////////////////////////////////////////////////////////// +/// Copy an existing image +//////////////////////////////////////////////////////////// +sfImage* sfImage_Copy(sfImage* image) +{ + CSFML_CHECK_RETURN(image, NULL); + + return new sfImage(*image); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing image +//////////////////////////////////////////////////////////// +void sfImage_Destroy(sfImage* image) +{ + delete image; +} + + +//////////////////////////////////////////////////////////// +/// Save the content of an image to a file +//////////////////////////////////////////////////////////// +sfBool sfImage_SaveToFile(const sfImage* image, const char* filename) +{ + CSFML_CALL_PTR_RETURN(image, SaveToFile(filename), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Create a transparency mask for an image from a specified colorkey +//////////////////////////////////////////////////////////// +void sfImage_CreateMaskFromColor(sfImage* image, sfColor colorKey, sfUint8 alpha) +{ + sf::Color SFMLColor(colorKey.r, colorKey.g, colorKey.b, colorKey.a); + CSFML_CALL_PTR(image, CreateMaskFromColor(SFMLColor, alpha)); +} + + +//////////////////////////////////////////////////////////// +/// Copy pixels from another image onto this one. +/// This function does a slow pixel copy and should only +/// be used at initialization time +//////////////////////////////////////////////////////////// +void sfImage_CopyImage(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect) +{ + CSFML_CHECK(source); + sf::IntRect SFMLRect(sourceRect.Left, sourceRect.Top, sourceRect.Width, sourceRect.Height); + CSFML_CALL_PTR(image, Copy(*source->This, destX, destY, SFMLRect)); +} + + +//////////////////////////////////////////////////////////// +/// Create the image from the current contents of the +/// given window +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfImage_CopyScreen(sfImage* image, sfRenderWindow* window, sfIntRect sourceRect) +{ + CSFML_CHECK_RETURN(window, sfFalse); + sf::IntRect SFMLRect(sourceRect.Left, sourceRect.Top, sourceRect.Width, sourceRect.Height); + CSFML_CALL_PTR_RETURN(image, CopyScreen(window->This, SFMLRect), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Change the color of a pixel of an image +/// Don't forget to call Update when you end modifying pixels +//////////////////////////////////////////////////////////// +void sfImage_SetPixel(sfImage* image, unsigned int x, unsigned int y, sfColor color) +{ + sf::Color SFMLColor(color.r, color.g, color.b, color.a); + CSFML_CALL_PTR(image, SetPixel(x, y, SFMLColor)); +} + + +//////////////////////////////////////////////////////////// +/// Get a pixel from an image +//////////////////////////////////////////////////////////// +sfColor sfImage_GetPixel(const sfImage* image, unsigned int x, unsigned int y) +{ + sfColor color = {0, 0, 0, 0}; + CSFML_CHECK_RETURN(image, color); + + sf::Color SFMLColor = image->This->GetPixel(x, y); + + return sfColor_FromRGBA(SFMLColor.r, SFMLColor.g, SFMLColor.b, SFMLColor.a); +} + + +//////////////////////////////////////////////////////////// +/// Get a read-only pointer to the array of pixels of an image (8 bits integers RGBA) +/// Array size is sfImage_GetWidth() x sfImage_GetHeight() x 4 +/// This pointer becomes invalid if you reload or resize the image +//////////////////////////////////////////////////////////// +const sfUint8* sfImage_GetPixelsPtr(const sfImage* image) +{ + CSFML_CALL_PTR_RETURN(image, GetPixelsPtr(), NULL); +} + + +//////////////////////////////////////////////////////////// +/// Update a sub-rectangle of the image from an array of pixels +//////////////////////////////////////////////////////////// +void sfImage_UpdatePixels(const sfImage* image, const sfUint8* pixels, sfIntRect rectangle) +{ + sf::IntRect rect(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height); + CSFML_CALL_PTR(image, UpdatePixels(pixels, rect)); +} + + +//////////////////////////////////////////////////////////// +/// Bind the image for rendering +//////////////////////////////////////////////////////////// +void sfImage_Bind(const sfImage* image) +{ + CSFML_CALL_PTR(image, Bind()); +} + + +//////////////////////////////////////////////////////////// +/// Enable or disable image smooth filter +//////////////////////////////////////////////////////////// +void sfImage_SetSmooth(sfImage* image, sfBool smooth) +{ + CSFML_CALL_PTR(image, SetSmooth(smooth == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +/// Return the width of the image +//////////////////////////////////////////////////////////// +unsigned int sfImage_GetWidth(const sfImage* image) +{ + CSFML_CALL_PTR_RETURN(image, GetWidth(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Return the height of the image +//////////////////////////////////////////////////////////// +unsigned int sfImage_GetHeight(const sfImage* image) +{ + CSFML_CALL_PTR_RETURN(image, GetHeight(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Tells whether the smoothing filter is enabled or not on an image +//////////////////////////////////////////////////////////// +sfBool sfImage_IsSmooth(const sfImage* image) +{ + CSFML_CALL_PTR_RETURN(image, IsSmooth(), sfFalse); +} diff --git a/src/SFML/Graphics/ImageStruct.h b/src/SFML/Graphics/ImageStruct.h new file mode 100644 index 0000000..b4f65a7 --- /dev/null +++ b/src/SFML/Graphics/ImageStruct.h @@ -0,0 +1,68 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_IMAGESTRUCT_H +#define SFML_IMAGESTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfImage +//////////////////////////////////////////////////////////// +struct sfImage +{ + sfImage() + { + This = new sf::Image; + OwnInstance = true; + } + + sfImage(sf::Image* image) + { + This = image; + OwnInstance = false; + } + + sfImage(const sfImage& image) + { + This = image.This ? new sf::Image(*image.This) : NULL; + OwnInstance = true; + } + + ~sfImage() + { + if (OwnInstance) + delete This; + } + + sf::Image* This; + bool OwnInstance; +}; + + +#endif // SFML_IMAGESTRUCT_H diff --git a/src/SFML/Graphics/Rect.cpp b/src/SFML/Graphics/Rect.cpp new file mode 100644 index 0000000..f78207a --- /dev/null +++ b/src/SFML/Graphics/Rect.cpp @@ -0,0 +1,100 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Check if a point is inside a rectangle's area +//////////////////////////////////////////////////////////// +sfBool sfFloatRect_Contains(const sfFloatRect* rect, float x, float y) +{ + CSFML_CHECK_RETURN(rect, sfFalse) + return sf::FloatRect(rect->Left, rect->Top, rect->Width, rect->Height).Contains(x, y); +} +sfBool sfIntRect_Contains(const sfIntRect* rect, int x, int y) +{ + CSFML_CHECK_RETURN(rect, sfFalse) + return sf::IntRect(rect->Left, rect->Top, rect->Width, rect->Height).Contains(x, y); +} + + +//////////////////////////////////////////////////////////// +/// Check intersection between two rectangles +//////////////////////////////////////////////////////////// +sfBool sfFloatRect_Intersects(const sfFloatRect* rect1, const sfFloatRect* rect2, sfFloatRect* intersection) +{ + CSFML_CHECK_RETURN(rect1, sfFalse) + CSFML_CHECK_RETURN(rect2, sfFalse) + + sf::FloatRect SFMLRect1(rect1->Left, rect1->Top, rect1->Width, rect1->Height); + sf::FloatRect SFMLRect2(rect2->Left, rect2->Top, rect2->Width, rect2->Height); + + if (intersection) + { + sf::FloatRect overlap; + bool intersects = SFMLRect1.Intersects(SFMLRect2, overlap); + + intersection->Left = overlap.Left; + intersection->Top = overlap.Top; + intersection->Width = overlap.Width; + intersection->Height = overlap.Height; + + return intersects; + } + else + { + return SFMLRect1.Intersects(SFMLRect2); + } +} +sfBool sfIntRect_Intersects(const sfIntRect* rect1, const sfIntRect* rect2, sfIntRect* intersection) +{ + CSFML_CHECK_RETURN(rect1, sfFalse) + CSFML_CHECK_RETURN(rect2, sfFalse) + + sf::IntRect SFMLRect1(rect1->Left, rect1->Top, rect1->Width, rect1->Height); + sf::IntRect SFMLRect2(rect2->Left, rect2->Top, rect2->Width, rect2->Height); + + if (intersection) + { + sf::IntRect overlap; + bool intersects = SFMLRect1.Intersects(SFMLRect2, overlap); + + intersection->Left = overlap.Left; + intersection->Top = overlap.Top; + intersection->Width = overlap.Width; + intersection->Height = overlap.Height; + + return intersects; + } + else + { + return SFMLRect1.Intersects(SFMLRect2); + } +} diff --git a/src/SFML/Graphics/RenderImage.cpp b/src/SFML/Graphics/RenderImage.cpp new file mode 100644 index 0000000..4a25e1c --- /dev/null +++ b/src/SFML/Graphics/RenderImage.cpp @@ -0,0 +1,248 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new renderimage +//////////////////////////////////////////////////////////// +sfRenderImage* sfRenderImage_Create(unsigned int width, unsigned int height, sfBool depthBuffer) +{ + sfRenderImage* renderImage = new sfRenderImage; + renderImage->This.Create(width, height, depthBuffer == sfTrue); + renderImage->Target = new sfImage(const_cast(&renderImage->This.GetImage())); + renderImage->DefaultView.This = renderImage->This.GetDefaultView(); + renderImage->CurrentView.This = renderImage->This.GetView(); + + return renderImage; +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing renderimage +//////////////////////////////////////////////////////////// +void sfRenderImage_Destroy(sfRenderImage* renderImage) +{ + delete renderImage->Target; + delete renderImage; +} + + +//////////////////////////////////////////////////////////// +/// Get the width of the rendering region of a renderimage +//////////////////////////////////////////////////////////// +unsigned int sfRenderImage_GetWidth(const sfRenderImage* renderImage) +{ + CSFML_CALL_RETURN(renderImage, GetWidth(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Get the height of the rendering region of a renderimage +//////////////////////////////////////////////////////////// +unsigned int sfRenderImage_GetHeight(const sfRenderImage* renderImage) +{ + CSFML_CALL_RETURN(renderImage, GetHeight(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Set a renderimage as the current target for rendering +//////////////////////////////////////////////////////////// +sfBool sfRenderImage_SetActive(sfRenderImage* renderImage, sfBool active) +{ + CSFML_CALL_RETURN(renderImage, SetActive(active == sfTrue), sfFalse) +} + + +//////////////////////////////////////////////////////////// +/// Save the current OpenGL render states and matrices +//////////////////////////////////////////////////////////// +void sfRenderImage_SaveGLStates(sfRenderImage* renderImage) +{ + CSFML_CALL(renderImage, SaveGLStates()); +} + + +//////////////////////////////////////////////////////////// +/// Restore the previously saved OpenGL render states and matrices +//////////////////////////////////////////////////////////// +void sfRenderImage_RestoreGLStates(sfRenderImage* renderImage) +{ + CSFML_CALL(renderImage, RestoreGLStates()); +} + + +//////////////////////////////////////////////////////////// +/// Update the contents of the target image +//////////////////////////////////////////////////////////// +void sfRenderImage_Display(sfRenderImage* renderImage) +{ + CSFML_CALL(renderImage, Display()) +} + + +//////////////////////////////////////////////////////////// +/// Draw something on a renderimage +//////////////////////////////////////////////////////////// +void sfRenderImage_DrawSprite(sfRenderImage* renderImage, const sfSprite* sprite) +{ + CSFML_CHECK(sprite); + CSFML_CALL(renderImage, Draw(sprite->This)); +} +void sfRenderImage_DrawShape(sfRenderImage* renderImage, const sfShape* shape) +{ + CSFML_CHECK(shape); + CSFML_CALL(renderImage, Draw(shape->This)); +} +void sfRenderImage_DrawText(sfRenderImage* renderImage, const sfText* text) +{ + CSFML_CHECK(text); + CSFML_CALL(renderImage, Draw(text->This)); +} + + +//////////////////////////////////////////////////////////// +/// Draw something on a renderimage with a shader +//////////////////////////////////////////////////////////// +void sfRenderImage_DrawSpriteWithShader(sfRenderImage* renderImage, const sfSprite* sprite, const sfShader* shader) +{ + CSFML_CHECK(sprite); + CSFML_CHECK(shader); + CSFML_CALL(renderImage, Draw(sprite->This, shader->This)); +} +void sfRenderImage_DrawShapeWithShader(sfRenderImage* renderImage, const sfShape* shape, const sfShader* shader) +{ + CSFML_CHECK(shape); + CSFML_CHECK(shader); + CSFML_CALL(renderImage, Draw(shape->This, shader->This)); +} +void sfRenderImage_DrawTextWithShader(sfRenderImage* renderImage, const sfText* text, const sfShader* shader) +{ + CSFML_CHECK(text); + CSFML_CHECK(shader); + CSFML_CALL(renderImage, Draw(text->This, shader->This)); +} + + +//////////////////////////////////////////////////////////// +/// Clear the renderimage with the given color +//////////////////////////////////////////////////////////// +void sfRenderImage_Clear(sfRenderImage* renderImage, sfColor color) +{ + sf::Color SFMLColor(color.r, color.g, color.b, color.a); + + CSFML_CALL(renderImage, Clear(SFMLColor)); +} + + +//////////////////////////////////////////////////////////// +/// Change the current active view of a renderimage +//////////////////////////////////////////////////////////// +void sfRenderImage_SetView(sfRenderImage* renderImage, const sfView* view) +{ + CSFML_CHECK(view); + CSFML_CALL(renderImage, SetView(view->This)); + renderImage->CurrentView.This = view->This; +} + + +//////////////////////////////////////////////////////////// +/// Get the current active view of a renderimage +//////////////////////////////////////////////////////////// +const sfView* sfRenderImage_GetView(const sfRenderImage* renderImage) +{ + CSFML_CHECK_RETURN(renderImage, NULL); + + return &renderImage->CurrentView; +} + + +//////////////////////////////////////////////////////////// +/// Get the default view of a renderimage +//////////////////////////////////////////////////////////// +const sfView* sfRenderImage_GetDefaultView(const sfRenderImage* renderImage) +{ + CSFML_CHECK_RETURN(renderImage, NULL); + + return &renderImage->DefaultView; +} + + +//////////////////////////////////////////////////////////// +/// Get the viewport of a view applied to this target +//////////////////////////////////////////////////////////// +sfIntRect sfRenderImage_GetViewport(const sfRenderImage* renderImage, const sfView* view) +{ + sfIntRect rect = {0, 0, 0, 0}; + CSFML_CHECK_RETURN(view, rect); + CSFML_CHECK_RETURN(renderImage, rect); + + sf::IntRect SFMLrect = renderImage->This.GetViewport(view->This); + rect.Left = SFMLrect.Left; + rect.Top = SFMLrect.Top; + rect.Width = SFMLrect.Width; + rect.Height = SFMLrect.Height; + + return rect; +} + + +//////////////////////////////////////////////////////////// +/// Convert a point in image coordinates into view coordinates +//////////////////////////////////////////////////////////// +void sfRenderImage_ConvertCoords(const sfRenderImage* renderImage, unsigned int imageX, unsigned int imageY, float* viewX, float* viewY, const sfView* targetView) +{ + CSFML_CHECK(renderImage); + + sf::Vector2f point; + if (targetView) + point = renderImage->This.ConvertCoords(imageX, imageY, targetView->This); + else + point = renderImage->This.ConvertCoords(imageX, imageY); + + if (viewX) *viewX = point.x; + if (viewY) *viewY = point.y; +} + + +//////////////////////////////////////////////////////////// +/// Get the target image +//////////////////////////////////////////////////////////// +const sfImage* sfRenderImage_GetImage(const sfRenderImage* renderImage) +{ + CSFML_CHECK_RETURN(renderImage, NULL); + + return renderImage->Target; +} diff --git a/src/SFML/Graphics/RenderImageStruct.h b/src/SFML/Graphics/RenderImageStruct.h new file mode 100644 index 0000000..5bbb547 --- /dev/null +++ b/src/SFML/Graphics/RenderImageStruct.h @@ -0,0 +1,48 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_RENDERIMAGESTRUCT_H +#define SFML_RENDERIMAGESTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfRenderWindow +//////////////////////////////////////////////////////////// +struct sfRenderImage +{ + sf::RenderImage This; + const sfImage* Target; + sfView DefaultView; + sfView CurrentView; +}; + + +#endif // SFML_RENDERIMAGESTRUCT_H diff --git a/src/SFML/Graphics/RenderWindow.cpp b/src/SFML/Graphics/RenderWindow.cpp new file mode 100644 index 0000000..304e23b --- /dev/null +++ b/src/SFML/Graphics/RenderWindow.cpp @@ -0,0 +1,481 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new renderwindow +//////////////////////////////////////////////////////////// +sfRenderWindow* sfRenderWindow_Create(sfVideoMode mode, const char* title, unsigned long style, const sfContextSettings* settings) +{ + // Convert video mode + sf::VideoMode videoMode(mode.Width, mode.Height, mode.BitsPerPixel); + + // Convert context settings + sf::ContextSettings params; + if (settings) + { + params.DepthBits = settings->DepthBits; + params.StencilBits = settings->StencilBits; + params.AntialiasingLevel = settings->AntialiasingLevel; + params.MajorVersion = settings->MajorVersion; + params.MinorVersion = settings->MinorVersion; + } + + // Create the window + sfRenderWindow* renderWindow = new sfRenderWindow; + renderWindow->This.Create(videoMode, title, style, params); + renderWindow->DefaultView.This = renderWindow->This.GetDefaultView(); + renderWindow->CurrentView.This = renderWindow->This.GetView(); + + return renderWindow; +} + + +//////////////////////////////////////////////////////////// +/// Construct a renderwindow from an existing control +//////////////////////////////////////////////////////////// +sfRenderWindow* sfRenderWindow_CreateFromHandle(sfWindowHandle handle, const sfContextSettings* settings) +{ + // Convert context settings + sf::ContextSettings params; + if (settings) + { + params.DepthBits = settings->DepthBits; + params.StencilBits = settings->StencilBits; + params.AntialiasingLevel = settings->AntialiasingLevel; + params.MajorVersion = settings->MajorVersion; + params.MinorVersion = settings->MinorVersion; + } + + // Create the window + sfRenderWindow* renderWindow = new sfRenderWindow; + renderWindow->This.Create(handle, params); + renderWindow->DefaultView.This = renderWindow->This.GetDefaultView(); + renderWindow->CurrentView.This = renderWindow->This.GetView(); + + return renderWindow; +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing renderwindow +//////////////////////////////////////////////////////////// +void sfRenderWindow_Destroy(sfRenderWindow* renderWindow) +{ + delete renderWindow; +} + +//////////////////////////////////////////////////////////// +/// Close a renderwindow (but doesn't destroy the internal data) +//////////////////////////////////////////////////////////// +void sfRenderWindow_Close(sfRenderWindow* renderWindow) +{ + CSFML_CALL(renderWindow, Close()); +} + + +//////////////////////////////////////////////////////////// +/// Tell whether or not a renderwindow is opened +//////////////////////////////////////////////////////////// +sfBool sfRenderWindow_IsOpened(const sfRenderWindow* renderWindow) +{ + CSFML_CALL_RETURN(renderWindow, IsOpened(), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Get the width of the rendering region of a window +//////////////////////////////////////////////////////////// +unsigned int sfRenderWindow_GetWidth(const sfRenderWindow* renderWindow) +{ + CSFML_CALL_RETURN(renderWindow, GetWidth(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Get the height of the rendering region of a window +//////////////////////////////////////////////////////////// +unsigned int sfRenderWindow_GetHeight(const sfRenderWindow* renderWindow) +{ + CSFML_CALL_RETURN(renderWindow, GetHeight(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Get the creation settings of a window +//////////////////////////////////////////////////////////// +sfContextSettings sfRenderWindow_GetSettings(const sfRenderWindow* renderWindow) +{ + sfContextSettings settings = {0, 0, 0, 2, 0}; + CSFML_CHECK_RETURN(renderWindow, settings); + + const sf::ContextSettings& params = renderWindow->This.GetSettings(); + settings.DepthBits = params.DepthBits; + settings.StencilBits = params.StencilBits; + settings.AntialiasingLevel = params.AntialiasingLevel; + + return settings; +} + + + +//////////////////////////////////////////////////////////// +/// Get the event on top of events stack of a window, if any, and pop it +//////////////////////////////////////////////////////////// +sfBool sfRenderWindow_PollEvent(sfRenderWindow* renderWindow, sfEvent* event) +{ + CSFML_CHECK_RETURN(renderWindow, sfFalse); + CSFML_CHECK_RETURN(event, sfFalse); + + // Get the event + sf::Event SFMLEvent; + sfBool ret = renderWindow->This.PollEvent(SFMLEvent); + + // No event, return + if (!ret) + return sfFalse; + + // Convert the sf::Event event to a sfEvent + ConvertEvent(SFMLEvent, event); + + return sfTrue; +} + + +//////////////////////////////////////////////////////////// +/// Wait for an event and return it +//////////////////////////////////////////////////////////// +sfBool sfRenderWindow_WaitEvent(sfRenderWindow* renderWindow, sfEvent* event) +{ + CSFML_CHECK_RETURN(renderWindow, sfFalse); + CSFML_CHECK_RETURN(event, sfFalse); + + // Get the event + sf::Event SFMLEvent; + sfBool ret = renderWindow->This.WaitEvent(SFMLEvent); + + // Error, return + if (!ret) + return sfFalse; + + // Convert the sf::Event event to a sfEvent + ConvertEvent(SFMLEvent, event); + + return sfTrue; +} + + +//////////////////////////////////////////////////////////// +/// Enable / disable vertical synchronization on a window +//////////////////////////////////////////////////////////// +void sfRenderWindow_EnableVerticalSync(sfRenderWindow* renderWindow, sfBool enabled) +{ + CSFML_CALL(renderWindow, EnableVerticalSync(enabled == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +/// Show or hide the mouse cursor on a window +//////////////////////////////////////////////////////////// +void sfRenderWindow_ShowMouseCursor(sfRenderWindow* renderWindow, sfBool show) +{ + CSFML_CALL(renderWindow, ShowMouseCursor(show == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +/// Change the position of the mouse cursor on a window +//////////////////////////////////////////////////////////// +void sfRenderWindow_SetCursorPosition(sfRenderWindow* renderWindow, unsigned int left, unsigned int top) +{ + CSFML_CALL(renderWindow, SetCursorPosition(left, top)); +} + + +//////////////////////////////////////////////////////////// +/// Change the position of a window on screen. +/// Only works for top-level windows +//////////////////////////////////////////////////////////// +void sfRenderWindow_SetPosition(sfRenderWindow* renderWindow, int left, int top) +{ + CSFML_CALL(renderWindow, SetPosition(left, top)); +} + + +//////////////////////////////////////////////////////////// +/// Change the size of the rendering region of a window +//////////////////////////////////////////////////////////// +void sfRenderWindow_SetSize(sfRenderWindow* renderWindow, unsigned int width, unsigned int height) +{ + CSFML_CALL(renderWindow, SetSize(width, height)) +} + + +//////////////////////////////////////////////////////////// +/// Change the title of a window +//////////////////////////////////////////////////////////// +void sfRenderWindow_SetTitle(sfRenderWindow* renderWindow, const char* title) +{ + CSFML_CALL(renderWindow, SetTitle(title)) +} + + +//////////////////////////////////////////////////////////// +/// Show or hide a window +//////////////////////////////////////////////////////////// +void sfRenderWindow_Show(sfRenderWindow* renderWindow, sfBool show) +{ + CSFML_CALL(renderWindow, Show(show == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +/// Enable or disable automatic key-repeat for keydown events. +/// Automatic key-repeat is enabled by default +//////////////////////////////////////////////////////////// +void sfRenderWindow_EnableKeyRepeat(sfRenderWindow* renderWindow, sfBool enabled) +{ + CSFML_CALL(renderWindow, EnableKeyRepeat(enabled == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +/// Change the window's icon +//////////////////////////////////////////////////////////// +void sfRenderWindow_SetIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfUint8* pixels) +{ + CSFML_CALL(renderWindow, SetIcon(width, height, pixels)) +} + + +//////////////////////////////////////////////////////////// +/// Set a window as the current target for rendering +//////////////////////////////////////////////////////////// +sfBool sfRenderWindow_SetActive(sfRenderWindow* renderWindow, sfBool active) +{ + CSFML_CALL_RETURN(renderWindow, SetActive(active == sfTrue), sfFalse) +} + + +//////////////////////////////////////////////////////////// +/// Save the current OpenGL render states and matrices +//////////////////////////////////////////////////////////// +void sfRenderWindow_SaveGLStates(sfRenderWindow* renderWindow) +{ + CSFML_CALL(renderWindow, SaveGLStates()); +} + + +//////////////////////////////////////////////////////////// +/// Restore the previously saved OpenGL render states and matrices +//////////////////////////////////////////////////////////// +void sfRenderWindow_RestoreGLStates(sfRenderWindow* renderWindow) +{ + CSFML_CALL(renderWindow, RestoreGLStates()); +} + + +//////////////////////////////////////////////////////////// +/// Display a window on screen +//////////////////////////////////////////////////////////// +void sfRenderWindow_Display(sfRenderWindow* renderWindow) +{ + CSFML_CALL(renderWindow, Display()); +} + + +//////////////////////////////////////////////////////////// +/// Limit the framerate to a maximum fixed frequency for a window +//////////////////////////////////////////////////////////// +void sfRenderWindow_SetFramerateLimit(sfRenderWindow* renderWindow, unsigned int limit) +{ + CSFML_CALL(renderWindow, SetFramerateLimit(limit)); +} + + +//////////////////////////////////////////////////////////// +/// Get time elapsed since last frame of a window +//////////////////////////////////////////////////////////// +sfUint32 sfRenderWindow_GetFrameTime(const sfRenderWindow* renderWindow) +{ + CSFML_CALL_RETURN(renderWindow, GetFrameTime(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Change the joystick threshold, ie. the value below which +/// no move event will be generated +//////////////////////////////////////////////////////////// +void sfRenderWindow_SetJoystickThreshold(sfRenderWindow* renderWindow, float threshold) +{ + CSFML_CALL(renderWindow, SetJoystickThreshold(threshold)); +} + + +//////////////////////////////////////////////////////////// +/// Retrieve the Os-specific handle of a window +//////////////////////////////////////////////////////////// +sfWindowHandle sfRenderWindow_GetSystemHandle(const sfRenderWindow* renderWindow) +{ + CSFML_CHECK_RETURN(renderWindow, NULL); + + return (sfWindowHandle)renderWindow->This.GetSystemHandle(); +} + + +//////////////////////////////////////////////////////////// +/// Draw something on a renderwindow +//////////////////////////////////////////////////////////// +void sfRenderWindow_DrawSprite(sfRenderWindow* renderWindow, const sfSprite* sprite) +{ + CSFML_CHECK(sprite); + CSFML_CALL(renderWindow, Draw(sprite->This)); +} +void sfRenderWindow_DrawShape(sfRenderWindow* renderWindow, const sfShape* shape) +{ + CSFML_CHECK(shape); + CSFML_CALL(renderWindow, Draw(shape->This)); +} +void sfRenderWindow_DrawText(sfRenderWindow* renderWindow, const sfText* text) +{ + CSFML_CHECK(text); + CSFML_CALL(renderWindow, Draw(text->This)); +} + + +//////////////////////////////////////////////////////////// +/// Draw something on a renderwindow with a shader +//////////////////////////////////////////////////////////// +void sfRenderWindow_DrawSpriteWithShader(sfRenderWindow* renderWindow, const sfSprite* sprite, const sfShader* shader) +{ + CSFML_CHECK(sprite); + CSFML_CHECK(shader); + CSFML_CALL(renderWindow, Draw(sprite->This, shader->This)); +} +void sfRenderWindow_DrawShapeWithShader(sfRenderWindow* renderWindow, const sfShape* shape, const sfShader* shader) +{ + CSFML_CHECK(shape); + CSFML_CHECK(shader); + CSFML_CALL(renderWindow, Draw(shape->This, shader->This)); +} +void sfRenderWindow_DrawTextWithShader(sfRenderWindow* renderWindow, const sfText* text, const sfShader* shader) +{ + CSFML_CHECK(text); + CSFML_CHECK(shader); + CSFML_CALL(renderWindow, Draw(text->This, shader->This)); +} + + +//////////////////////////////////////////////////////////// +/// Clear the screen with the given color +//////////////////////////////////////////////////////////// +void sfRenderWindow_Clear(sfRenderWindow* renderWindow, sfColor color) +{ + sf::Color SFMLColor(color.r, color.g, color.b, color.a); + + CSFML_CALL(renderWindow, Clear(SFMLColor)); +} + + +//////////////////////////////////////////////////////////// +/// Change the current active view of a renderwindow +//////////////////////////////////////////////////////////// +void sfRenderWindow_SetView(sfRenderWindow* renderWindow, const sfView* view) +{ + CSFML_CHECK(view); + CSFML_CALL(renderWindow, SetView(view->This)); + renderWindow->CurrentView.This = view->This; +} + + +//////////////////////////////////////////////////////////// +/// Get the current active view of a renderwindow +//////////////////////////////////////////////////////////// +const sfView* sfRenderWindow_GetView(const sfRenderWindow* renderWindow) +{ + CSFML_CHECK_RETURN(renderWindow, NULL); + + return &renderWindow->CurrentView; +} + + +//////////////////////////////////////////////////////////// +/// Get the default view of a renderwindow +//////////////////////////////////////////////////////////// +const sfView* sfRenderWindow_GetDefaultView(const sfRenderWindow* renderWindow) +{ + CSFML_CHECK_RETURN(renderWindow, NULL); + + return &renderWindow->DefaultView; +} + + +//////////////////////////////////////////////////////////// +/// Get the viewport of a view applied to this target +//////////////////////////////////////////////////////////// +sfIntRect sfRenderWindow_GetViewport(const sfRenderWindow* renderWindow, const sfView* view) +{ + sfIntRect rect = {0, 0, 0, 0}; + CSFML_CHECK_RETURN(view, rect); + CSFML_CHECK_RETURN(renderWindow, rect); + + sf::IntRect SFMLrect = renderWindow->This.GetViewport(view->This); + rect.Left = SFMLrect.Left; + rect.Top = SFMLrect.Top; + rect.Width = SFMLrect.Width; + rect.Height = SFMLrect.Height; + + return rect; +} + + +//////////////////////////////////////////////////////////// +/// Convert a point in window coordinates into view coordinates +//////////////////////////////////////////////////////////// +void sfRenderWindow_ConvertCoords(const sfRenderWindow* renderWindow, unsigned int windowX, unsigned int windowY, float* viewX, float* viewY, const sfView* targetView) +{ + CSFML_CHECK(renderWindow); + + sf::Vector2f point; + if (targetView) + point = renderWindow->This.ConvertCoords(windowX, windowY, targetView->This); + else + point = renderWindow->This.ConvertCoords(windowX, windowY); + + if (viewX) *viewX = point.x; + if (viewY) *viewY = point.y; +} diff --git a/src/SFML/Graphics/RenderWindowStruct.h b/src/SFML/Graphics/RenderWindowStruct.h new file mode 100644 index 0000000..dc99348 --- /dev/null +++ b/src/SFML/Graphics/RenderWindowStruct.h @@ -0,0 +1,46 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_RENDERWINDOWSTRUCT_H +#define SFML_RENDERWINDOWSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfRenderWindow +//////////////////////////////////////////////////////////// +struct sfRenderWindow +{ + sf::RenderWindow This; + sfView DefaultView; + sfView CurrentView; +}; + + +#endif // SFML_RENDERWINDOWSTRUCT_H diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp new file mode 100644 index 0000000..ee542d4 --- /dev/null +++ b/src/SFML/Graphics/Shader.cpp @@ -0,0 +1,167 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new shader from a file +//////////////////////////////////////////////////////////// +sfShader* sfShader_CreateFromFile(const char* filename) +{ + sfShader* shader = new sfShader; + + if (!shader->This.LoadFromFile(filename)) + { + delete shader; + shader = NULL; + } + + return shader; +} + + +//////////////////////////////////////////////////////////// +/// Create a new shader from an effect source code +//////////////////////////////////////////////////////////// +sfShader* sfShader_CreateFromMemory(const char* effect) +{ + sfShader* shader = new sfShader; + + if (!shader->This.LoadFromMemory(effect)) + { + delete shader; + shader = NULL; + } + + return shader; +} + + +//////////////////////////////////////////////////////////// +/// Copy an existing clock +//////////////////////////////////////////////////////////// +sfShader* sfShader_Copy(sfShader* shader) +{ + CSFML_CHECK_RETURN(shader, NULL); + + return new sfShader(*shader); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing shader +//////////////////////////////////////////////////////////// +void sfShader_Destroy(sfShader* shader) +{ + delete shader; +} + + +//////////////////////////////////////////////////////////// +/// Change a parameter of a shader (1 float) +//////////////////////////////////////////////////////////// +void sfShader_SetParameter1(sfShader* shader, const char* name, float x) +{ + CSFML_CALL(shader, SetParameter(name, x)) +} + + +//////////////////////////////////////////////////////////// +/// Change a parameter of a shader (2 floats) +//////////////////////////////////////////////////////////// +void sfShader_SetParameter2(sfShader* shader, const char* name, float x, float y) +{ + CSFML_CALL(shader, SetParameter(name, x, y)) +} + + +//////////////////////////////////////////////////////////// +/// Change a parameter of a shader (3 floats) +//////////////////////////////////////////////////////////// +void sfShader_SetParameter3(sfShader* shader, const char* name, float x, float y, float z) +{ + CSFML_CALL(shader, SetParameter(name, x, y, z)) +} + + +//////////////////////////////////////////////////////////// +/// Change a parameter of a shader (4 floats) +//////////////////////////////////////////////////////////// +void sfShader_SetParameter4(sfShader* shader, const char* name, float x, float y, float z, float w) +{ + CSFML_CALL(shader, SetParameter(name, x, y, z, w)) +} + + +//////////////////////////////////////////////////////////// +/// Set a texture parameter in a shader +//////////////////////////////////////////////////////////// +void sfShader_SetTexture(sfShader* shader, const char* name, const sfImage* texture) +{ + CSFML_CHECK(texture); + CSFML_CALL(shader, SetTexture(name, *texture->This)) +} + + +//////////////////////////////////////////////////////////// +/// Set the current texture parameter in a shader +//////////////////////////////////////////////////////////// +void sfShader_SetCurrentTexture(sfShader* shader, const char* name) +{ + CSFML_CALL(shader, SetCurrentTexture(name)) +} + + +//////////////////////////////////////////////////////////// +/// Bind a shader for rendering +//////////////////////////////////////////////////////////// +void sfShader_Bind(const sfShader* shader) +{ + CSFML_CALL(shader, Bind()) +} + + +//////////////////////////////////////////////////////////// +/// Unbind a shader +//////////////////////////////////////////////////////////// +void sfShader_Unbind(const sfShader* shader) +{ + CSFML_CALL(shader, Unbind()) +} + + +//////////////////////////////////////////////////////////// +/// Tell whether or not the system supports shaders +//////////////////////////////////////////////////////////// +sfBool sfShader_IsAvailable(void) +{ + return sf::Shader::IsAvailable() ? sfTrue : sfFalse; +} diff --git a/src/SFML/Graphics/ShaderStruct.h b/src/SFML/Graphics/ShaderStruct.h new file mode 100644 index 0000000..f20bfdf --- /dev/null +++ b/src/SFML/Graphics/ShaderStruct.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SHADERSTRUCT_H +#define SFML_SHADERSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfShader +//////////////////////////////////////////////////////////// +struct sfShader +{ + sf::Shader This; +}; + + +#endif // SFML_SHADERSTRUCT_H diff --git a/src/SFML/Graphics/Shape.cpp b/src/SFML/Graphics/Shape.cpp new file mode 100644 index 0000000..ab7bde6 --- /dev/null +++ b/src/SFML/Graphics/Shape.cpp @@ -0,0 +1,469 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new shape +//////////////////////////////////////////////////////////// +sfShape* sfShape_Create(void) +{ + return new sfShape; +} + + +//////////////////////////////////////////////////////////// +/// Create a new shape made of a single line +//////////////////////////////////////////////////////////// +sfShape* sfShape_CreateLine(float p1x, float p1y, float p2x, float p2y, float thickness, sfColor color, float outline, sfColor outlineColor) +{ + sf::Color SFMLColor(color.r, color.g, color.b, color.a); + sf::Color SFMLOutlineColor(outlineColor.r, outlineColor.g, outlineColor.b, outlineColor.a); + + sfShape* shape = new sfShape; + shape->This = sf::Shape::Line(p1x, p1y, p2x, p2y, thickness, SFMLColor, outline, SFMLOutlineColor); + return shape; +} + + +//////////////////////////////////////////////////////////// +/// Create a new shape made of a single rectangle +//////////////////////////////////////////////////////////// +sfShape* sfShape_CreateRectangle(float left, float top, float width, float height, sfColor color, float outline, sfColor outlineColor) +{ + sf::Color SFMLColor(color.r, color.g, color.b, color.a); + sf::Color SFMLOutlineColor(outlineColor.r, outlineColor.g, outlineColor.b, outlineColor.a); + + sfShape* shape = new sfShape; + shape->This = sf::Shape::Rectangle(left, top, width, height, SFMLColor, outline, SFMLOutlineColor); + return shape; +} + + +//////////////////////////////////////////////////////////// +/// Create a new shape made of a single circle +//////////////////////////////////////////////////////////// +sfShape* sfShape_CreateCircle(float x, float y, float radius, sfColor color, float outline, sfColor outlineColor) +{ + sf::Color SFMLColor(color.r, color.g, color.b, color.a); + sf::Color SFMLOutlineColor(outlineColor.r, outlineColor.g, outlineColor.b, outlineColor.a); + + sfShape* shape = new sfShape; + shape->This = sf::Shape::Circle(x, y, radius, SFMLColor, outline, SFMLOutlineColor); + return shape; +} + + +//////////////////////////////////////////////////////////// +/// Copy an existing shape +//////////////////////////////////////////////////////////// +sfShape* sfShape_Copy(sfShape* shape) +{ + CSFML_CHECK_RETURN(shape, NULL); + + return new sfShape(*shape); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing shape +//////////////////////////////////////////////////////////// +void sfShape_Destroy(sfShape* shape) +{ + delete shape; +} + + +//////////////////////////////////////////////////////////// +/// Set the X position of a shape +//////////////////////////////////////////////////////////// +void sfShape_SetX(sfShape* shape, float x) +{ + CSFML_CALL(shape, SetX(x)) +} + + +//////////////////////////////////////////////////////////// +/// Set the Y position of a shape +//////////////////////////////////////////////////////////// +void sfShape_SetY(sfShape* shape, float y) +{ + CSFML_CALL(shape, SetY(y)) +} + + +//////////////////////////////////////////////////////////// +/// Set the position of a shape +//////////////////////////////////////////////////////////// +void sfShape_SetPosition(sfShape* shape, float x, float y) +{ + CSFML_CALL(shape, SetPosition(sf::Vector2f(x, y))) +} + + +//////////////////////////////////////////////////////////// +/// Set the horizontal scale of a shape +//////////////////////////////////////////////////////////// +void sfShape_SetScaleX(sfShape* shape, float scale) +{ + CSFML_CALL(shape, SetScaleX(scale)) +} + + +//////////////////////////////////////////////////////////// +/// Set the vertical scale of a shape +//////////////////////////////////////////////////////////// +void sfShape_SetScaleY(sfShape* shape, float scale) +{ + CSFML_CALL(shape, SetScaleY(scale)) +} + + +//////////////////////////////////////////////////////////// +/// Set the scale of a shape +//////////////////////////////////////////////////////////// +void sfShape_SetScale(sfShape* shape, float scaleX, float scaleY) +{ + CSFML_CALL(shape, SetScale(sf::Vector2f(scaleX, scaleY))) +} + + +//////////////////////////////////////////////////////////// +/// Set the orientation of a shape +//////////////////////////////////////////////////////////// +void sfShape_SetRotation(sfShape* shape, float rotation) +{ + CSFML_CALL(shape, SetRotation(rotation)) +} + + +//////////////////////////////////////////////////////////// +/// Set the local origin of a shape, in coordinates +/// relative to its left-top corner +//////////////////////////////////////////////////////////// +void sfShape_SetOrigin(sfShape* shape, float x, float y) +{ + CSFML_CALL(shape, SetOrigin(sf::Vector2f(x, y))) +} + + +//////////////////////////////////////////////////////////// +/// Set the color of a shape +//////////////////////////////////////////////////////////// +void sfShape_SetColor(sfShape* shape, sfColor color) +{ + CSFML_CALL(shape, SetColor(sf::Color(color.r, color.g, color.b, color.a))) +} + + +//////////////////////////////////////////////////////////// +/// Set the blending mode for a shape +//////////////////////////////////////////////////////////// +void sfShape_SetBlendMode(sfShape* shape, sfBlendMode mode) +{ + CSFML_CALL(shape, SetBlendMode(static_cast(mode))) +} + + +//////////////////////////////////////////////////////////// +/// Get the X position of a shape +//////////////////////////////////////////////////////////// +float sfShape_GetX(const sfShape* shape) +{ + CSFML_CALL_RETURN(shape, GetPosition().x, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the Y position of a shape +//////////////////////////////////////////////////////////// +float sfShape_GetY(const sfShape* shape) +{ + CSFML_CALL_RETURN(shape, GetPosition().y, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the horizontal scale of a shape +//////////////////////////////////////////////////////////// +float sfShape_GetScaleX(const sfShape* shape) +{ + CSFML_CALL_RETURN(shape, GetScale().x, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the vertical scale of a shape +//////////////////////////////////////////////////////////// +float sfShape_GetScaleY(const sfShape* shape) +{ + CSFML_CALL_RETURN(shape, GetScale().y, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the orientation of a shape +//////////////////////////////////////////////////////////// +float sfShape_GetRotation(const sfShape* shape) +{ + CSFML_CALL_RETURN(shape, GetRotation(), 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the X position of the origin a shape +//////////////////////////////////////////////////////////// +float sfShape_GetOriginX(const sfShape* shape) +{ + CSFML_CALL_RETURN(shape, GetOrigin().x, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the Y position of the origin a shape +//////////////////////////////////////////////////////////// +float sfShape_GetOriginY(const sfShape* shape) +{ + CSFML_CALL_RETURN(shape, GetOrigin().y, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the color of a shape +//////////////////////////////////////////////////////////// +sfColor sfShape_GetColor(const sfShape* shape) +{ + sfColor color = {0, 0, 0, 0}; + CSFML_CHECK_RETURN(shape, color) + + sf::Color SFMLColor = shape->This.GetColor(); + return sfColor_FromRGBA(SFMLColor.r, SFMLColor.g, SFMLColor.b, SFMLColor.a); +} + + +//////////////////////////////////////////////////////////// +/// Get the current blending mode of a shape +//////////////////////////////////////////////////////////// +sfBlendMode sfShape_GetBlendMode(const sfShape* shape) +{ + CSFML_CHECK_RETURN(shape, sfBlendNone) + + return static_cast(shape->This.GetBlendMode()); +} + + +//////////////////////////////////////////////////////////// +/// Move a shape +//////////////////////////////////////////////////////////// +void sfShape_Move(sfShape* shape, float offsetX, float offsetY) +{ + CSFML_CALL(shape, Move(sf::Vector2f(offsetX, offsetY))) +} + + +//////////////////////////////////////////////////////////// +/// Scale a shape +//////////////////////////////////////////////////////////// +void sfShape_Scale(sfShape* shape, float factorX, float factorY) +{ + CSFML_CALL(shape, Scale(sf::Vector2f(factorX, factorY))) +} + + +//////////////////////////////////////////////////////////// +/// Rotate a shape +//////////////////////////////////////////////////////////// +void sfShape_Rotate(sfShape* shape, float angle) +{ + CSFML_CALL(shape, Rotate(angle)) +} + + +//////////////////////////////////////////////////////////// +/// Transform a point from global coordinates into the shape's local coordinates +/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point) +//////////////////////////////////////////////////////////// +void sfShape_TransformToLocal(const sfShape* shape, float pointX, float pointY, float* x, float* y) +{ + CSFML_CHECK(shape) + + sf::Vector2f point = shape->This.TransformToLocal(sf::Vector2f(pointX, pointY)); + if (x) *x = point.x; + if (y) *y = point.y; +} + + +//////////////////////////////////////////////////////////// +/// Transform a point from the shape's local coordinates into global coordinates +/// (ie it applies the object's origin, translation, rotation and scale to the point) +//////////////////////////////////////////////////////////// +void sfShape_TransformToGlobal(const sfShape* shape, float pointX, float pointY, float* x, float* y) +{ + CSFML_CHECK(shape) + + sf::Vector2f point = shape->This.TransformToGlobal(sf::Vector2f(pointX, pointY)); + if (x) *x = point.x; + if (y) *y = point.y; +} + + +//////////////////////////////////////////////////////////// +/// Add a point to a shape +//////////////////////////////////////////////////////////// +void sfShape_AddPoint(sfShape* shape, float x, float y, sfColor color, sfColor outlineColor) +{ + sf::Color SFMLColor(color.r, color.g, color.b, color.a); + sf::Color SFMLOutlineColor(outlineColor.r, outlineColor.g, outlineColor.b, outlineColor.a); + + CSFML_CALL(shape, AddPoint(x, y, SFMLColor, SFMLOutlineColor)) +} + + +//////////////////////////////////////////////////////////// +/// Enable or disable filling a shape. +/// Fill is enabled by default +//////////////////////////////////////////////////////////// +void sfShape_EnableFill(sfShape* shape, sfBool enable) +{ + CSFML_CALL(shape, EnableFill(enable == sfTrue)) +} + + +//////////////////////////////////////////////////////////// +/// Enable or disable drawing a shape outline. +/// Outline is enabled by default +//////////////////////////////////////////////////////////// +void sfShape_EnableOutline(sfShape* shape, sfBool enable) +{ + CSFML_CALL(shape, EnableOutline(enable == sfTrue)) +} + + +//////////////////////////////////////////////////////////// +/// Change the thickness of a shape outline +//////////////////////////////////////////////////////////// +void sfShape_SetOutlineThickness(sfShape* shape, float thickness) +{ + CSFML_CALL(shape, SetOutlineThickness(thickness)) +} + + +//////////////////////////////////////////////////////////// +/// Get the thickness of a shape outline +//////////////////////////////////////////////////////////// +float sfShape_GetOutlineThickness(const sfShape* shape) +{ + CSFML_CALL_RETURN(shape, GetOutlineThickness(), 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the number of points composing a shape +//////////////////////////////////////////////////////////// +unsigned int sfShape_GetPointsCount(const sfShape* shape) +{ + CSFML_CALL_RETURN(shape, GetPointsCount(), 0) +} + + +//////////////////////////////////////////////////////////// +/// Get a point of a shape +//////////////////////////////////////////////////////////// +void sfShape_GetPointPosition(const sfShape* shape, unsigned int index, float* x, float* y) +{ + CSFML_CHECK(shape) + + sf::Vector2f point = shape->This.GetPointPosition(index); + if (x) *x = point.x; + if (y) *y = point.y; +} + + +//////////////////////////////////////////////////////////// +/// Get a the color of a shape's point +//////////////////////////////////////////////////////////// +sfColor sfShape_GetPointColor(const sfShape* shape, unsigned int index) +{ + sfColor color = {255, 255, 255, 255}; + CSFML_CHECK_RETURN(shape, color) + + const sf::Color& SFMLColor = shape->This.GetPointColor(index); + color.r = SFMLColor.r; + color.g = SFMLColor.g; + color.b = SFMLColor.b; + color.a = SFMLColor.a; + + return color; +} + + +//////////////////////////////////////////////////////////// +/// Get a the outline color of a shape's point +//////////////////////////////////////////////////////////// +sfColor sfShape_GetPointOutlineColor(const sfShape* shape, unsigned int index) +{ + sfColor color = {255, 255, 255, 255}; + CSFML_CHECK_RETURN(shape, color) + + const sf::Color& SFMLColor = shape->This.GetPointOutlineColor(index); + color.r = SFMLColor.r; + color.g = SFMLColor.g; + color.b = SFMLColor.b; + color.a = SFMLColor.a; + + return color; +} + +//////////////////////////////////////////////////////////// +/// Set a the position of a shape's point +//////////////////////////////////////////////////////////// +void sfShape_SetPointPosition(sfShape* shape, unsigned int index, float x, float y) +{ + CSFML_CALL(shape, SetPointPosition(index, x, y)); +} + + +//////////////////////////////////////////////////////////// +/// Set a the color of a shape's point +//////////////////////////////////////////////////////////// +void sfShape_SetPointColor(sfShape* shape, unsigned int index, sfColor color) +{ + CSFML_CALL(shape, SetPointColor(index, sf::Color(color.r, color.g, color.b, color.a))); +} + + +//////////////////////////////////////////////////////////// +/// Set a the outline color of a shape's point +//////////////////////////////////////////////////////////// +void sfShape_SetPointOutlineColor(sfShape* shape, unsigned int index, sfColor color) +{ + CSFML_CALL(shape, SetPointOutlineColor(index, sf::Color(color.r, color.g, color.b, color.a))); +} diff --git a/src/SFML/Graphics/ShapeStruct.h b/src/SFML/Graphics/ShapeStruct.h new file mode 100644 index 0000000..1eb54c3 --- /dev/null +++ b/src/SFML/Graphics/ShapeStruct.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SHAPESTRUCT_H +#define SFML_SHAPESTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfShape +//////////////////////////////////////////////////////////// +struct sfShape +{ + sf::Shape This; +}; + + +#endif // SFML_SHAPESTRUCT_H diff --git a/src/SFML/Graphics/Sprite.cpp b/src/SFML/Graphics/Sprite.cpp new file mode 100644 index 0000000..988c8ab --- /dev/null +++ b/src/SFML/Graphics/Sprite.cpp @@ -0,0 +1,405 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new sprite +//////////////////////////////////////////////////////////// +sfSprite* sfSprite_Create(void) +{ + sfSprite* sprite = new sfSprite; + sprite->Image = NULL; + sprite->SubRect.Left = sprite->This.GetSubRect().Left; + sprite->SubRect.Top = sprite->This.GetSubRect().Top; + sprite->SubRect.Width = sprite->This.GetSubRect().Width; + sprite->SubRect.Height = sprite->This.GetSubRect().Height; + + return sprite; +} + + +//////////////////////////////////////////////////////////// +/// Copy an existing sprite +//////////////////////////////////////////////////////////// +sfSprite* sfSprite_Copy(sfSprite* sprite) +{ + CSFML_CHECK_RETURN(sprite, NULL); + + return new sfSprite(*sprite); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing sprite +//////////////////////////////////////////////////////////// +void sfSprite_Destroy(sfSprite* sprite) +{ + delete sprite; +} + + +//////////////////////////////////////////////////////////// +/// Set the X position of a sprite +//////////////////////////////////////////////////////////// +void sfSprite_SetX(sfSprite* sprite, float x) +{ + CSFML_CALL(sprite, SetX(x)) +} + + +//////////////////////////////////////////////////////////// +/// Set the Y position of a sprite +//////////////////////////////////////////////////////////// +void sfSprite_SetY(sfSprite* sprite, float y) +{ + CSFML_CALL(sprite, SetY(y)) +} + + +//////////////////////////////////////////////////////////// +/// Set the position of a sprite +//////////////////////////////////////////////////////////// +void sfSprite_SetPosition(sfSprite* sprite, float x, float y) +{ + CSFML_CALL(sprite, SetPosition(sf::Vector2f(x, y))) +} + + +//////////////////////////////////////////////////////////// +/// Set the horizontal scale of a sprite +//////////////////////////////////////////////////////////// +void sfSprite_SetScaleX(sfSprite* sprite, float scale) +{ + CSFML_CALL(sprite, SetScaleX(scale)) +} + + +//////////////////////////////////////////////////////////// +/// Set the vertical scale of a sprite +//////////////////////////////////////////////////////////// +void sfSprite_SetScaleY(sfSprite* sprite, float scale) +{ + CSFML_CALL(sprite, SetScaleY(scale)) +} + + +//////////////////////////////////////////////////////////// +/// Set the scale of a sprite +//////////////////////////////////////////////////////////// +void sfSprite_SetScale(sfSprite* sprite, float scaleX, float scaleY) +{ + CSFML_CALL(sprite, SetScale(sf::Vector2f(scaleX, scaleY))) +} + + +//////////////////////////////////////////////////////////// +/// Set the orientation of a sprite +//////////////////////////////////////////////////////////// +void sfSprite_SetRotation(sfSprite* sprite, float rotation) +{ + CSFML_CALL(sprite, SetRotation(rotation)) +} + + +//////////////////////////////////////////////////////////// +/// Set the local origin of a sprite, in coordinates +/// relative to its left-top corner +//////////////////////////////////////////////////////////// +void sfSprite_SetOrigin(sfSprite* sprite, float x, float y) +{ + CSFML_CALL(sprite, SetOrigin(sf::Vector2f(x, y))) +} + + +//////////////////////////////////////////////////////////// +/// Set the color of a sprite +//////////////////////////////////////////////////////////// +void sfSprite_SetColor(sfSprite* sprite, sfColor color) +{ + CSFML_CALL(sprite, SetColor(sf::Color(color.r, color.g, color.b, color.a))) +} + + +//////////////////////////////////////////////////////////// +/// Set the blending mode for a sprite +//////////////////////////////////////////////////////////// +void sfSprite_SetBlendMode(sfSprite* sprite, sfBlendMode mode) +{ + CSFML_CALL(sprite, SetBlendMode(static_cast(mode))) +} + + +//////////////////////////////////////////////////////////// +/// Get the X position of a sprite +//////////////////////////////////////////////////////////// +float sfSprite_GetX(const sfSprite* sprite) +{ + CSFML_CALL_RETURN(sprite, GetPosition().x, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the Y position of a sprite +//////////////////////////////////////////////////////////// +float sfSprite_GetY(const sfSprite* sprite) +{ + CSFML_CALL_RETURN(sprite, GetPosition().y, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the horizontal scale of a sprite +//////////////////////////////////////////////////////////// +float sfSprite_GetScaleX(const sfSprite* sprite) +{ + CSFML_CALL_RETURN(sprite, GetScale().x, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the vertical scale of a sprite +//////////////////////////////////////////////////////////// +float sfSprite_GetScaleY(const sfSprite* sprite) +{ + CSFML_CALL_RETURN(sprite, GetScale().y, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the orientation of a sprite +//////////////////////////////////////////////////////////// +float sfSprite_GetRotation(const sfSprite* sprite) +{ + CSFML_CALL_RETURN(sprite, GetRotation(), 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the X position of the origin a sprite +//////////////////////////////////////////////////////////// +float sfSprite_GetOriginX(const sfSprite* sprite) +{ + CSFML_CALL_RETURN(sprite, GetOrigin().x, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the Y position of the origin a sprite +//////////////////////////////////////////////////////////// +float sfSprite_GetOriginY(const sfSprite* sprite) +{ + CSFML_CALL_RETURN(sprite, GetOrigin().y, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the color of a sprite +//////////////////////////////////////////////////////////// +sfColor sfSprite_GetColor(const sfSprite* sprite) +{ + sfColor color = {0, 0, 0, 0}; + CSFML_CHECK_RETURN(sprite, color) + + sf::Color SFMLColor = sprite->This.GetColor(); + return sfColor_FromRGBA(SFMLColor.r, SFMLColor.g, SFMLColor.b, SFMLColor.a); +} + + +//////////////////////////////////////////////////////////// +/// Get the current blending mode of a sprite +//////////////////////////////////////////////////////////// +sfBlendMode sfSprite_GetBlendMode(const sfSprite* sprite) +{ + CSFML_CHECK_RETURN(sprite, sfBlendNone) + + return static_cast(sprite->This.GetBlendMode()); +} + + +//////////////////////////////////////////////////////////// +/// Move a sprite +//////////////////////////////////////////////////////////// +void sfSprite_Move(sfSprite* sprite, float offsetX, float offsetY) +{ + CSFML_CALL(sprite, Move(sf::Vector2f(offsetX, offsetY))) +} + + +//////////////////////////////////////////////////////////// +/// Scale a sprite +//////////////////////////////////////////////////////////// +void sfSprite_Scale(sfSprite* sprite, float factorX, float factorY) +{ + CSFML_CALL(sprite, Scale(sf::Vector2f(factorX, factorY))) +} + + +//////////////////////////////////////////////////////////// +/// Rotate a sprite +//////////////////////////////////////////////////////////// +void sfSprite_Rotate(sfSprite* sprite, float angle) +{ + CSFML_CALL(sprite, Rotate(angle)) +} + + +//////////////////////////////////////////////////////////// +/// Transform a point from global coordinates into the sprite's local coordinates +/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point) +//////////////////////////////////////////////////////////// +void sfSprite_TransformToLocal(const sfSprite* sprite, float pointX, float pointY, float* x, float* y) +{ + CSFML_CHECK(sprite) + + sf::Vector2f point = sprite->This.TransformToLocal(sf::Vector2f(pointX, pointY)); + if (x) *x = point.x; + if (y) *y = point.y; +} + + +//////////////////////////////////////////////////////////// +/// Transform a point from the sprite's local coordinates into global coordinates +/// (ie it applies the object's origin, translation, rotation and scale to the point) +//////////////////////////////////////////////////////////// +void sfSprite_TransformToGlobal(const sfSprite* sprite, float pointX, float pointY, float* x, float* y) +{ + CSFML_CHECK(sprite) + + sf::Vector2f point = sprite->This.TransformToGlobal(sf::Vector2f(pointX, pointY)); + if (x) *x = point.x; + if (y) *y = point.y; +} + + +//////////////////////////////////////////////////////////// +/// Change the image of a sprite +//////////////////////////////////////////////////////////// +void sfSprite_SetImage(sfSprite* sprite, const sfImage* image, sfBool adjustToNewSize) +{ + if (image) + { + CSFML_CALL(sprite, SetImage(*image->This, adjustToNewSize == sfTrue)) + sprite->Image = image; + } +} + + +//////////////////////////////////////////////////////////// +/// Set the sub-rectangle of a sprite inside the source image +//////////////////////////////////////////////////////////// +void sfSprite_SetSubRect(sfSprite* sprite, sfIntRect rectangle) +{ + CSFML_CALL(sprite, SetSubRect(sf::IntRect(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height))) + sprite->SubRect = rectangle; +} + + +//////////////////////////////////////////////////////////// +/// Resize a sprite (by changing its scale factors) +//////////////////////////////////////////////////////////// +void sfSprite_Resize(sfSprite* sprite, float width, float height) +{ + CSFML_CALL(sprite, Resize(sf::Vector2f(width, height))) +} + + +//////////////////////////////////////////////////////////// +/// Flip a sprite horizontally +//////////////////////////////////////////////////////////// +void sfSprite_FlipX(sfSprite* sprite, sfBool flipped) +{ + CSFML_CALL(sprite, FlipX(flipped == sfTrue)) +} + + +//////////////////////////////////////////////////////////// +/// Flip a sprite vertically +//////////////////////////////////////////////////////////// +void sfSprite_FlipY(sfSprite* sprite, sfBool flipped) +{ + CSFML_CALL(sprite, FlipY(flipped == sfTrue)) +} + + +//////////////////////////////////////////////////////////// +/// Get the source image of a sprite +//////////////////////////////////////////////////////////// +const sfImage* sfSprite_GetImage(const sfSprite* sprite) +{ + CSFML_CHECK_RETURN(sprite, NULL) + + return sprite->Image; +} + + +//////////////////////////////////////////////////////////// +/// Get the sub-rectangle of a sprite inside the source image +//////////////////////////////////////////////////////////// +sfIntRect sfSprite_GetSubRect(const sfSprite* sprite) +{ + sfIntRect rect = {0, 0, 0, 0}; + CSFML_CHECK_RETURN(sprite, rect) + + return sprite->SubRect; +} + + +//////////////////////////////////////////////////////////// +/// Get a sprite width +//////////////////////////////////////////////////////////// +float sfSprite_GetWidth(const sfSprite* sprite) +{ + CSFML_CALL_RETURN(sprite, GetSize().x, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get a sprite height +//////////////////////////////////////////////////////////// +float sfSprite_GetHeight(const sfSprite* sprite) +{ + CSFML_CALL_RETURN(sprite, GetSize().y, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the color of a given pixel in a sprite +//////////////////////////////////////////////////////////// +sfColor sfSprite_GetPixel(const sfSprite* sprite, unsigned int x, unsigned int y) +{ + sfColor color = {0, 0, 0, 0}; + CSFML_CHECK_RETURN(sprite, color) + + sf::Color SFMLColor = sprite->This.GetPixel(x, y); + return sfColor_FromRGBA(SFMLColor.r, SFMLColor.g, SFMLColor.b, SFMLColor.a); +} diff --git a/src/SFML/Graphics/SpriteStruct.h b/src/SFML/Graphics/SpriteStruct.h new file mode 100644 index 0000000..fe86343 --- /dev/null +++ b/src/SFML/Graphics/SpriteStruct.h @@ -0,0 +1,47 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SPRITESTRUCT_H +#define SFML_SPRITESTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfMusic +//////////////////////////////////////////////////////////// +struct sfSprite +{ + sf::Sprite This; + const sfImage* Image; + sfIntRect SubRect; +}; + + +#endif // SFML_SPRITESTRUCT_H diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp new file mode 100644 index 0000000..9738482 --- /dev/null +++ b/src/SFML/Graphics/Text.cpp @@ -0,0 +1,432 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new text +//////////////////////////////////////////////////////////// +sfText* sfText_Create(void) +{ + sfText* text = new sfText; + text->Font = sfFont_GetDefaultFont(); + + return text; +} + + +//////////////////////////////////////////////////////////// +/// Copy an existing text +//////////////////////////////////////////////////////////// +sfText* sfText_Copy(sfText* text) +{ + CSFML_CHECK_RETURN(text, NULL); + + return new sfText(*text); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing text +//////////////////////////////////////////////////////////// +void sfText_Destroy(sfText* text) +{ + delete text; +} + + +//////////////////////////////////////////////////////////// +/// Set the X position of a text +//////////////////////////////////////////////////////////// +void sfText_SetX(sfText* text, float x) +{ + CSFML_CALL(text, SetX(x)) +} + + +//////////////////////////////////////////////////////////// +/// Set the Y position of a text +//////////////////////////////////////////////////////////// +void sfText_SetY(sfText* text, float y) +{ + CSFML_CALL(text, SetY(y)) +} + + +//////////////////////////////////////////////////////////// +/// Set the position of a text +//////////////////////////////////////////////////////////// +void sfText_SetPosition(sfText* text, float x, float y) +{ + CSFML_CALL(text, SetPosition(sf::Vector2f(x, y))) +} + + +//////////////////////////////////////////////////////////// +/// Set the horizontal scale of a text +//////////////////////////////////////////////////////////// +void sfText_SetScaleX(sfText* text, float scale) +{ + CSFML_CALL(text, SetScaleX(scale)) +} + + +//////////////////////////////////////////////////////////// +/// Set the vertical scale of a text +//////////////////////////////////////////////////////////// +void sfText_SetScaleY(sfText* text, float scale) +{ + CSFML_CALL(text, SetScaleY(scale)) +} + + +//////////////////////////////////////////////////////////// +/// Set the scale of a text +//////////////////////////////////////////////////////////// +void sfText_SetScale(sfText* text, float scaleX, float scaleY) +{ + CSFML_CALL(text, SetScale(sf::Vector2f(scaleX, scaleY))) +} + + +//////////////////////////////////////////////////////////// +/// Set the orientation of a text +//////////////////////////////////////////////////////////// +void sfText_SetRotation(sfText* text, float rotation) +{ + CSFML_CALL(text, SetRotation(rotation)) +} + + +//////////////////////////////////////////////////////////// +/// Set the local origin of a text, in coordinates +/// relative to its left-top corner +//////////////////////////////////////////////////////////// +void sfText_SetOrigin(sfText* text, float x, float y) +{ + CSFML_CALL(text, SetOrigin(sf::Vector2f(x, y))) +} + + +//////////////////////////////////////////////////////////// +/// Set the color of a text +//////////////////////////////////////////////////////////// +void sfText_SetColor(sfText* text, sfColor color) +{ + CSFML_CALL(text, SetColor(sf::Color(color.r, color.g, color.b, color.a))) +} + + +//////////////////////////////////////////////////////////// +/// Set the blending mode for a text +//////////////////////////////////////////////////////////// +void sfText_SetBlendMode(sfText* text, sfBlendMode mode) +{ + CSFML_CALL(text, SetBlendMode(static_cast(mode))) +} + + +//////////////////////////////////////////////////////////// +/// Get the X position of a text +//////////////////////////////////////////////////////////// +float sfText_GetX(const sfText* text) +{ + CSFML_CALL_RETURN(text, GetPosition().x, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the Y position of a text +//////////////////////////////////////////////////////////// +float sfText_GetY(const sfText* text) +{ + CSFML_CALL_RETURN(text, GetPosition().y, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the horizontal scale of a text +//////////////////////////////////////////////////////////// +float sfText_GetScaleX(const sfText* text) +{ + CSFML_CALL_RETURN(text, GetScale().x, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the vertical scale of a text +//////////////////////////////////////////////////////////// +float sfText_GetScaleY(const sfText* text) +{ + CSFML_CALL_RETURN(text, GetScale().y, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the orientation of a text +//////////////////////////////////////////////////////////// +float sfText_GetRotation(const sfText* text) +{ + CSFML_CALL_RETURN(text, GetRotation(), 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the X position of the origin a text +//////////////////////////////////////////////////////////// +float sfText_GetOriginX(const sfText* text) +{ + CSFML_CALL_RETURN(text, GetOrigin().x, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the top Y of the origin of a text +//////////////////////////////////////////////////////////// +float sfText_GetOriginY(const sfText* text) +{ + CSFML_CALL_RETURN(text, GetOrigin().y, 0.f) +} + + +//////////////////////////////////////////////////////////// +/// Get the color of a text +//////////////////////////////////////////////////////////// +sfColor sfText_GetColor(const sfText* text) +{ + sfColor color = {0, 0, 0, 0}; + CSFML_CHECK_RETURN(text, color) + + sf::Color SFMLColor = text->This.GetColor(); + return sfColor_FromRGBA(SFMLColor.r, SFMLColor.g, SFMLColor.b, SFMLColor.a); +} + + +//////////////////////////////////////////////////////////// +/// Get the current blending mode of a text +//////////////////////////////////////////////////////////// +sfBlendMode sfText_GetBlendMode(const sfText* text) +{ + CSFML_CHECK_RETURN(text, sfBlendNone) + + return static_cast(text->This.GetBlendMode()); +} + + +//////////////////////////////////////////////////////////// +/// Move a text +//////////////////////////////////////////////////////////// +void sfText_Move(sfText* text, float offsetX, float offsetY) +{ + CSFML_CALL(text, Move(sf::Vector2f(offsetX, offsetY))) +} + + +//////////////////////////////////////////////////////////// +/// Scale a text +//////////////////////////////////////////////////////////// +void sfText_Scale(sfText* text, float factorX, float factorY) +{ + CSFML_CALL(text, Scale(sf::Vector2f(factorX, factorY))) +} + + +//////////////////////////////////////////////////////////// +/// Rotate a text +//////////////////////////////////////////////////////////// +void sfText_Rotate(sfText* text, float angle) +{ + CSFML_CALL(text, Rotate(angle)) +} + + +//////////////////////////////////////////////////////////// +/// Transform a point from global coordinates into the text's local coordinates +/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point) +//////////////////////////////////////////////////////////// +void sfText_TransformToLocal(const sfText* text, float pointX, float pointY, float* x, float* y) +{ + CSFML_CHECK(text) + + sf::Vector2f point = text->This.TransformToLocal(sf::Vector2f(pointX, pointY)); + if (x) *x = point.x; + if (y) *y = point.y; +} + + +//////////////////////////////////////////////////////////// +/// Transform a point from the text's local coordinates into global coordinates +/// (ie it applies the object's origin, translation, rotation and scale to the point) +//////////////////////////////////////////////////////////// +void sfText_TransformToGlobal(const sfText* text, float pointX, float pointY, float* x, float* y) +{ + CSFML_CHECK(text) + + sf::Vector2f point = text->This.TransformToGlobal(sf::Vector2f(pointX, pointY)); + if (x) *x = point.x; + if (y) *y = point.y; +} + + +//////////////////////////////////////////////////////////// +/// Set the string of a text (from a multibyte string) +//////////////////////////////////////////////////////////// +void sfText_SetString(sfText* text, const char* string) +{ + CSFML_CALL(text, SetString(string)) +} + + +//////////////////////////////////////////////////////////// +/// Set the string of a text (from a unicode string) +//////////////////////////////////////////////////////////// +void sfText_SetUnicodeString(sfText* text, const sfUint32* string) +{ + sf::String UTF32Text = string; + CSFML_CALL(text, SetString(UTF32Text)) +} + + +//////////////////////////////////////////////////////////// +/// Set the font of a string +//////////////////////////////////////////////////////////// +void sfText_SetFont(sfText* text, const sfFont* font) +{ + CSFML_CHECK(font); + + CSFML_CALL(text, SetFont(font->This)) + text->Font = font; +} + + +//////////////////////////////////////////////////////////// +/// Set the size of a string +//////////////////////////////////////////////////////////// +void sfText_SetCharacterSize(sfText* text, unsigned int size) +{ + CSFML_CALL(text, SetCharacterSize(size)) +} + + +//////////////////////////////////////////////////////////// +/// Set the style of a string +//////////////////////////////////////////////////////////// +void sfText_SetStyle(sfText* text, unsigned long style) +{ + CSFML_CALL(text, SetStyle(style)) +} + + +//////////////////////////////////////////////////////////// +/// Get the string of a text (returns a unicode string) +//////////////////////////////////////////////////////////// +const sfUint32* sfText_GetUnicodeString(const sfText* text) +{ + CSFML_CHECK_RETURN(text, NULL) + + return text->This.GetString().GetData(); +} + + +//////////////////////////////////////////////////////////// +/// Get the string of a text (returns an ANSI string) +//////////////////////////////////////////////////////////// +const char* sfText_GetString(const sfText* text) +{ + CSFML_CHECK_RETURN(text, NULL) + + text->String = text->This.GetString().ToAnsiString(); + + return text->String.c_str(); +} + + +//////////////////////////////////////////////////////////// +/// Get the font used by a text +//////////////////////////////////////////////////////////// +const sfFont* sfText_GetFont(const sfText* text) +{ + CSFML_CHECK_RETURN(text, NULL) + + return text->Font; +} + + +//////////////////////////////////////////////////////////// +/// Get the size of the characters of a text +//////////////////////////////////////////////////////////// +unsigned int sfText_GetCharacterSize(const sfText* text) +{ + CSFML_CALL_RETURN(text, GetCharacterSize(), 0) +} + + +//////////////////////////////////////////////////////////// +/// Get the style of a text +//////////////////////////////////////////////////////////// +unsigned long sfText_GetStyle(const sfText* text) +{ + CSFML_CALL_RETURN(text, GetStyle(), 0) +} + + +//////////////////////////////////////////////////////////// +/// Return the visual position of the Index-th character of the text, +/// in coordinates relative to the text +/// (note : translation, origin, rotation and scale are not applied) +//////////////////////////////////////////////////////////// +void sfText_GetCharacterPos(const sfText* text, size_t index, float* x, float* y) +{ + CSFML_CHECK(text); + + sf::Vector2f pos = text->This.GetCharacterPos(index); + if (x) *x = pos.x; + if (y) *y = pos.y; +} + + +//////////////////////////////////////////////////////////// +/// Get the bounding rectangle of a text on screen +//////////////////////////////////////////////////////////// +sfFloatRect sfText_GetRect(const sfText* text) +{ + sfFloatRect rect = {0.f, 0.f, 0.f, 0.f}; + CSFML_CHECK_RETURN(text, rect) + + sf::FloatRect SFMLRect = text->This.GetRect(); + text->Rect.Left = SFMLRect.Left; + text->Rect.Top = SFMLRect.Top; + text->Rect.Width = SFMLRect.Width; + text->Rect.Height = SFMLRect.Height; + + return text->Rect; +} diff --git a/src/SFML/Graphics/TextStruct.h b/src/SFML/Graphics/TextStruct.h new file mode 100644 index 0000000..161507c --- /dev/null +++ b/src/SFML/Graphics/TextStruct.h @@ -0,0 +1,49 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_TEXTSTRUCT_H +#define SFML_TEXTSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfText +//////////////////////////////////////////////////////////// +struct sfText +{ + sf::Text This; + const sfFont* Font; + mutable std::string String; + mutable sfFloatRect Rect; +}; + + +#endif // SFML_TEXTSTRUCT_H diff --git a/src/SFML/Graphics/View.cpp b/src/SFML/Graphics/View.cpp new file mode 100644 index 0000000..573af0f --- /dev/null +++ b/src/SFML/Graphics/View.cpp @@ -0,0 +1,215 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a default view (1000x1000) +//////////////////////////////////////////////////////////// +sfView* sfView_Create(void) +{ + return new sfView; +} + + +//////////////////////////////////////////////////////////// +/// Construct a view from a rectangle +//////////////////////////////////////////////////////////// +sfView* sfView_CreateFromRect(sfFloatRect rectangle) +{ + sfView* view = new sfView; + sfView_Reset(view, rectangle); + + return view; +} + + +//////////////////////////////////////////////////////////// +/// Copy an existing view +//////////////////////////////////////////////////////////// +sfView* sfView_Copy(sfView* view) +{ + CSFML_CHECK_RETURN(view, NULL); + + return new sfView(*view); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing view +//////////////////////////////////////////////////////////// +void sfView_Destroy(sfView* view) +{ + delete view; +} + + +//////////////////////////////////////////////////////////// +/// Change the center of a view +//////////////////////////////////////////////////////////// +void sfView_SetCenter(sfView* view, float x, float y) +{ + CSFML_CALL(view, SetCenter(x, y)); +} + + +//////////////////////////////////////////////////////////// +/// Change the size of a view +//////////////////////////////////////////////////////////// +void sfView_SetSize(sfView* view, float width, float height) +{ + CSFML_CALL(view, SetSize(width, height)); +} + + +//////////////////////////////////////////////////////////// +/// Set the angle of rotation of a view +//////////////////////////////////////////////////////////// +void sfView_SetRotation(sfView* view, float angle) +{ + CSFML_CALL(view, SetRotation(angle)); +} + + +//////////////////////////////////////////////////////////// +/// Set the target viewport of a view +//////////////////////////////////////////////////////////// +void sfView_SetViewport(sfView* view, sfFloatRect viewport) +{ + CSFML_CALL(view, SetViewport(sf::FloatRect(viewport.Left, viewport.Top, viewport.Width, viewport.Height))); +} + + +//////////////////////////////////////////////////////////// +/// Reset a view to the given rectangle. +/// Note: this function resets the rotation angle to 0. +//////////////////////////////////////////////////////////// +void sfView_Reset(sfView* view, sfFloatRect rectangle) +{ + CSFML_CALL(view, Reset(sf::FloatRect(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height))); +} + + +//////////////////////////////////////////////////////////// +/// Get the X coordinate of the center of a view +//////////////////////////////////////////////////////////// +float sfView_GetCenterX(const sfView* view) +{ + CSFML_CHECK_RETURN(view, 0.f); + + return view->This.GetCenter().x; +} + + +//////////////////////////////////////////////////////////// +/// Get the Y coordinate of the center of a view +//////////////////////////////////////////////////////////// +float sfView_GetCenterY(const sfView* view) +{ + CSFML_CHECK_RETURN(view, 0.f); + + return view->This.GetCenter().y; +} + + +//////////////////////////////////////////////////////////// +/// Get the width of the view +//////////////////////////////////////////////////////////// +float sfView_GetWidth(const sfView* view) +{ + CSFML_CHECK_RETURN(view, 0.f); + + return view->This.GetSize().x; +} + + +//////////////////////////////////////////////////////////// +/// Get the height of the view +//////////////////////////////////////////////////////////// +float sfView_GetHeight(const sfView* view) +{ + CSFML_CHECK_RETURN(view, 0.f); + + return view->This.GetSize().y; +} + + +//////////////////////////////////////////////////////////// +/// Get the current rotation of a view +//////////////////////////////////////////////////////////// +float sfView_GetRotation(const sfView* view) +{ + CSFML_CALL_RETURN(view, GetRotation(), 0.f); +} + + +//////////////////////////////////////////////////////////// +/// Get the target viewport of a view +//////////////////////////////////////////////////////////// +sfFloatRect sfView_GetViewport(const sfView* view) +{ + sfFloatRect rect = {0, 0, 0, 0}; + CSFML_CHECK_RETURN(view, rect); + + sf::FloatRect SFMLRect = view->This.GetViewport(); + rect.Left = SFMLRect.Left; + rect.Top = SFMLRect.Top; + rect.Width = SFMLRect.Width; + rect.Height = SFMLRect.Height; + + return rect; +} + + +//////////////////////////////////////////////////////////// +/// Move a view +//////////////////////////////////////////////////////////// +void sfView_Move(sfView* view, float offsetX, float offsetY) +{ + CSFML_CALL(view, Move(offsetX, offsetY)); +} + + +//////////////////////////////////////////////////////////// +/// Rotate a view +//////////////////////////////////////////////////////////// +void sfView_Rotate(sfView* view, float angle) +{ + CSFML_CALL(view, Rotate(angle)); +} + + +//////////////////////////////////////////////////////////// +/// Resize a view rectangle to simulate a zoom / unzoom effect +//////////////////////////////////////////////////////////// +void sfView_Zoom(sfView* view, float factor) +{ + CSFML_CALL(view, Zoom(factor)); +} diff --git a/src/SFML/Graphics/ViewStruct.h b/src/SFML/Graphics/ViewStruct.h new file mode 100644 index 0000000..a96fdd9 --- /dev/null +++ b/src/SFML/Graphics/ViewStruct.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_VIEWSTRUCT_H +#define SFML_VIEWSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfMusic +//////////////////////////////////////////////////////////// +struct sfView +{ + sf::View This; +}; + + +#endif // SFML_VIEWSTRUCT_H diff --git a/src/SFML/Internal.h b/src/SFML/Internal.h new file mode 100644 index 0000000..68b149b --- /dev/null +++ b/src/SFML/Internal.h @@ -0,0 +1,108 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_INTERNAL_H +#define SFML_INTERNAL_H + +//////////////////////////////////////////////////////////// +// Define macros to check the validity of CSFML objects +// in debug run +//////////////////////////////////////////////////////////// +#include + +#ifndef NDEBUG + + #define CSFML_CHECK(Object) \ + if (Object == NULL) \ + { \ + fprintf(stderr, "SFML warning : trying to use a null " #Object " object\n"); \ + return; \ + } + + #define CSFML_CALL(Object, Function) \ + if (Object) \ + { \ + (Object->This.Function); \ + } \ + else \ + { \ + fprintf(stderr, "SFML warning : trying to use a null " #Object " object\n"); \ + } \ + + #define CSFML_CALL_PTR(Object, Function) \ + if (Object) \ + { \ + (Object->This->Function); \ + } \ + else \ + { \ + fprintf(stderr, "SFML warning : trying to use a null " #Object " object\n"); \ + } \ + + #define CSFML_CHECK_RETURN(Object, Default) \ + if (Object == NULL) \ + { \ + fprintf(stderr, "SFML warning : trying to use a null " #Object " object\n"); \ + return Default; \ + } + + #define CSFML_CALL_RETURN(Object, Function, Default) \ + if (Object) \ + { \ + return (Object->This.Function); \ + } \ + else \ + { \ + fprintf(stderr, "SFML warning : trying to use a null " #Object " object\n"); \ + return Default; \ + } \ + + #define CSFML_CALL_PTR_RETURN(Object, Function, Default) \ + if (Object) \ + { \ + return (Object->This->Function); \ + } \ + else \ + { \ + fprintf(stderr, "SFML warning : trying to use a null " #Object " object\n"); \ + return Default; \ + } \ + +#else + + #define CSFML_CHECK(Object) + + #define CSFML_CALL(Object, Function) (Object->This.Function); + + #define CSFML_CALL_PTR(Object, Function) (Object->This->Function); + + #define CSFML_CHECK_RETURN(Object, Default) (void)Default; + + #define CSFML_CALL_RETURN(Object, Function, Default) (void)Default; return (Object->This.Function); + + #define CSFML_CALL_PTR_RETURN(Object, Function, Default) (void)Default; return (Object->This->Function); + +#endif + +#endif // SFML_INTERNAL_H diff --git a/src/SFML/Main/CMakeLists.txt b/src/SFML/Main/CMakeLists.txt new file mode 100644 index 0000000..fe5057c --- /dev/null +++ b/src/SFML/Main/CMakeLists.txt @@ -0,0 +1,9 @@ + +# define the csfml-main target +add_library(csfml-main STATIC ${CMAKE_SOURCE_DIR}/src/SFML/Main/SFML_Main.cpp) + +# set the debug suffix +set_target_properties(csfml-main PROPERTIES DEBUG_POSTFIX -d) + +# insert the major version number in the output filename +set_target_properties(csfml-main PROPERTIES OUTPUT_NAME "csfml-main") diff --git a/src/SFML/Main/SFML_Main.cpp b/src/SFML/Main/SFML_Main.cpp new file mode 100644 index 0000000..ae4262c --- /dev/null +++ b/src/SFML/Main/SFML_Main.cpp @@ -0,0 +1,44 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////// +// Windows specific : defines the WinMain entry function, +// so that developers can use the standard main function +// even in a Win32 Application project, and keep a portable code +//////////////////////////////////////////////////////////// + + +#if defined(_WIN32) + + #include + + extern int main(int argc, char* argv[]); + + int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, INT) + { + return main(__argc, __argv); + } + +#endif // _WIN32 diff --git a/src/SFML/Network/CMakeLists.txt b/src/SFML/Network/CMakeLists.txt new file mode 100644 index 0000000..465b99a --- /dev/null +++ b/src/SFML/Network/CMakeLists.txt @@ -0,0 +1,37 @@ + +set(INCROOT ${CMAKE_SOURCE_DIR}/include/SFML/Network) +set(SRCROOT ${CMAKE_SOURCE_DIR}/src/SFML/Network) + +# all source files +set(SRC + ${SRCROOT}/Ftp.cpp + ${SRCROOT}/FtpStruct.h + ${INCROOT}/Ftp.h + ${SRCROOT}/Http.cpp + ${SRCROOT}/HttpStruct.h + ${INCROOT}/Http.h + ${SRCROOT}/IpAddress.cpp + ${INCROOT}/IpAddress.h + ${SRCROOT}/Packet.cpp + ${SRCROOT}/PacketStruct.h + ${INCROOT}/Packet.h + ${SRCROOT}/SocketSelector.cpp + ${SRCROOT}/SocketSelectorStruct.h + ${INCROOT}/SocketSelector.h + ${INCROOT}/SocketStatus.h + ${SRCROOT}/TcpListener.cpp + ${SRCROOT}/TcpListenerStruct.h + ${INCROOT}/TcpListener.h + ${SRCROOT}/TcpSocket.cpp + ${SRCROOT}/TcpSocketStruct.h + ${INCROOT}/TcpSocket.h + ${INCROOT}/Types.h + ${SRCROOT}/UdpSocket.cpp + ${SRCROOT}/UdpSocketStruct.h + ${INCROOT}/UdpSocket.h +) + +# define the csfml-network target +csfml_add_library(csfml-network + SOURCES ${SRC} + DEPENDS ${SFML_NETWORK_LIBRARY} ${SFML_SYSTEM_LIBRARY}) diff --git a/src/SFML/Network/Ftp.cpp b/src/SFML/Network/Ftp.cpp new file mode 100644 index 0000000..da144c6 --- /dev/null +++ b/src/SFML/Network/Ftp.cpp @@ -0,0 +1,377 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Destroy an existing Ftp directory response +//////////////////////////////////////////////////////////// +void sfFtpListingResponse_Destroy(sfFtpListingResponse* ftpListingResponse) +{ + delete ftpListingResponse; +} + + +//////////////////////////////////////////////////////////// +/// Convenience function to check if the response status code +/// means a success +//////////////////////////////////////////////////////////// +sfBool sfFtpListingResponse_IsOk(const sfFtpListingResponse* ftpListingResponse) +{ + CSFML_CALL_RETURN(ftpListingResponse, IsOk(), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Get the response status code +//////////////////////////////////////////////////////////// +sfFtpStatus sfFtpListingResponse_GetStatus(const sfFtpListingResponse* ftpListingResponse) +{ + CSFML_CHECK_RETURN(ftpListingResponse, sfFtpInvalidResponse); + + return static_cast(ftpListingResponse->This.GetStatus()); +} + + +//////////////////////////////////////////////////////////// +/// Get the full message contained in the response +//////////////////////////////////////////////////////////// +const char* sfFtpListingResponse_GetMessage(const sfFtpListingResponse* ftpListingResponse) +{ + CSFML_CHECK_RETURN(ftpListingResponse, NULL); + + return ftpListingResponse->This.GetMessage().c_str(); +} + + +//////////////////////////////////////////////////////////// +/// Get the number of filenames in the listing +//////////////////////////////////////////////////////////// +size_t sfFtpListingResponse_GetCount(const sfFtpListingResponse* ftpListingResponse) +{ + CSFML_CHECK_RETURN(ftpListingResponse, 0); + + return ftpListingResponse->This.GetFilenames().size(); +} + + +//////////////////////////////////////////////////////////// +/// Get the Index-th filename in the directory +//////////////////////////////////////////////////////////// +const char* sfFtpListingResponse_GetFilename(const sfFtpListingResponse* ftpListingResponse, size_t index) +{ + CSFML_CHECK_RETURN(ftpListingResponse, NULL); + + return ftpListingResponse->This.GetFilenames()[index].c_str(); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing Ftp directory response +//////////////////////////////////////////////////////////// +void sfFtpDirectoryResponse_Destroy(sfFtpDirectoryResponse* ftpDirectoryResponse) +{ + delete ftpDirectoryResponse; +} + + +//////////////////////////////////////////////////////////// +/// Convenience function to check if the response status code +/// means a success +//////////////////////////////////////////////////////////// +sfBool sfFtpDirectoryResponse_IsOk(const sfFtpDirectoryResponse* ftpDirectoryResponse) +{ + CSFML_CALL_RETURN(ftpDirectoryResponse, IsOk(), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Get the response status code +//////////////////////////////////////////////////////////// +sfFtpStatus sfFtpDirectoryResponse_GetStatus(const sfFtpDirectoryResponse* ftpDirectoryResponse) +{ + CSFML_CHECK_RETURN(ftpDirectoryResponse, sfFtpInvalidResponse); + + return static_cast(ftpDirectoryResponse->This.GetStatus()); +} + + +//////////////////////////////////////////////////////////// +/// Get the full message contained in the response +//////////////////////////////////////////////////////////// +const char* sfFtpDirectoryResponse_GetMessage(const sfFtpDirectoryResponse* ftpDirectoryResponse) +{ + CSFML_CHECK_RETURN(ftpDirectoryResponse, NULL); + + return ftpDirectoryResponse->This.GetMessage().c_str(); +} + + +//////////////////////////////////////////////////////////// +/// Get the directory returned in the response +//////////////////////////////////////////////////////////// +const char* sfFtpDirectoryResponse_GetDirectory(const sfFtpDirectoryResponse* ftpDirectoryResponse) +{ + CSFML_CHECK_RETURN(ftpDirectoryResponse, NULL); + + return ftpDirectoryResponse->This.GetDirectory().c_str(); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing Ftp response +//////////////////////////////////////////////////////////// +void sfFtpResponse_Destroy(sfFtpResponse* ftpResponse) +{ + delete ftpResponse; +} + + +//////////////////////////////////////////////////////////// +/// Convenience function to check if the response status code +/// means a success +//////////////////////////////////////////////////////////// +sfBool sfFtpResponse_IsOk(const sfFtpResponse* ftpResponse) +{ + CSFML_CALL_RETURN(ftpResponse, IsOk(), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Get the response status code +//////////////////////////////////////////////////////////// +sfFtpStatus sfFtpResponse_GetStatus(const sfFtpResponse* ftpResponse) +{ + CSFML_CHECK_RETURN(ftpResponse, sfFtpInvalidResponse); + + return static_cast(ftpResponse->This.GetStatus()); +} + + +//////////////////////////////////////////////////////////// +/// Get the full message contained in the response +//////////////////////////////////////////////////////////// +const char* sfFtpResponse_GetMessage(const sfFtpResponse* ftpResponse) +{ + CSFML_CHECK_RETURN(ftpResponse, NULL); + + return ftpResponse->This.GetMessage().c_str(); +} + + +//////////////////////////////////////////////////////////// +/// Construct a new Ftp +//////////////////////////////////////////////////////////// +sfFtp* sfFtp_Create(void) +{ + return new sfFtp; +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing Ftp +//////////////////////////////////////////////////////////// +void sfFtp_Destroy(sfFtp* ftp) +{ + delete ftp; +} + + +//////////////////////////////////////////////////////////// +/// Connect to the specified FTP server +//////////////////////////////////////////////////////////// +sfFtpResponse* sfFtp_Connect(sfFtp* ftp, sfIpAddress server, unsigned short port, sfUint32 timeout) +{ + CSFML_CHECK_RETURN(ftp, NULL); + + sf::IpAddress SFMLServer(server.Address); + + return new sfFtpResponse(ftp->This.Connect(SFMLServer, port, timeout)); +} + + +//////////////////////////////////////////////////////////// +/// Log in using anonymous account +//////////////////////////////////////////////////////////// +sfFtpResponse* sfFtp_LoginAnonymous(sfFtp* ftp) +{ + CSFML_CHECK_RETURN(ftp, NULL); + + return new sfFtpResponse(ftp->This.Login()); +} + + +//////////////////////////////////////////////////////////// +/// Log in using a username and a password +//////////////////////////////////////////////////////////// +sfFtpResponse* sfFtp_Login(sfFtp* ftp, const char* userName, const char* password) +{ + CSFML_CHECK_RETURN(ftp, NULL); + + return new sfFtpResponse(ftp->This.Login(userName ? userName : "", password ? password : "")); +} + + +//////////////////////////////////////////////////////////// +/// Close the connection with FTP server +//////////////////////////////////////////////////////////// +sfFtpResponse* sfFtp_Disconnect(sfFtp* ftp) +{ + CSFML_CHECK_RETURN(ftp, NULL); + + return new sfFtpResponse(ftp->This.Disconnect()); +} + + +//////////////////////////////////////////////////////////// +/// Send a null command just to prevent from being disconnected +//////////////////////////////////////////////////////////// +sfFtpResponse* sfFtp_KeepAlive(sfFtp* ftp) +{ + CSFML_CHECK_RETURN(ftp, NULL); + + return new sfFtpResponse(ftp->This.KeepAlive()); +} + + +//////////////////////////////////////////////////////////// +/// Get the current working directory +//////////////////////////////////////////////////////////// +sfFtpDirectoryResponse* sfFtp_GetWorkingDirectory(sfFtp* ftp) +{ + CSFML_CHECK_RETURN(ftp, NULL); + + return new sfFtpDirectoryResponse(ftp->This.GetWorkingDirectory()); +} + + +//////////////////////////////////////////////////////////// +/// Get the contents of the given directory +/// (subdirectories and files) +//////////////////////////////////////////////////////////// +sfFtpListingResponse* sfFtp_GetDirectoryListing(sfFtp* ftp, const char* directory) +{ + CSFML_CHECK_RETURN(ftp, NULL); + + return new sfFtpListingResponse(ftp->This.GetDirectoryListing(directory ? directory : "")); +} + + +//////////////////////////////////////////////////////////// +/// Change the current working directory +//////////////////////////////////////////////////////////// +sfFtpResponse* sfFtp_ChangeDirectory(sfFtp* ftp, const char* directory) +{ + CSFML_CHECK_RETURN(ftp, NULL); + + return new sfFtpResponse(ftp->This.ChangeDirectory(directory ? directory : "")); +} + + +//////////////////////////////////////////////////////////// +/// Go to the parent directory of the current one +//////////////////////////////////////////////////////////// +sfFtpResponse* sfFtp_ParentDirectory(sfFtp* ftp) +{ + CSFML_CHECK_RETURN(ftp, NULL); + + return new sfFtpResponse(ftp->This.ParentDirectory()); +} + + +//////////////////////////////////////////////////////////// +/// Create a new directory +//////////////////////////////////////////////////////////// +sfFtpResponse* sfFtp_CreateDirectory(sfFtp* ftp, const char* name) +{ + CSFML_CHECK_RETURN(ftp, NULL); + + return new sfFtpResponse(ftp->This.CreateDirectory(name ? name : "")); +} + + +//////////////////////////////////////////////////////////// +/// Remove an existing directory +//////////////////////////////////////////////////////////// +sfFtpResponse* sfFtp_DeleteDirectory(sfFtp* ftp, const char* name) +{ + CSFML_CHECK_RETURN(ftp, NULL); + + return new sfFtpResponse(ftp->This.DeleteDirectory(name ? name : "")); +} + + +//////////////////////////////////////////////////////////// +/// Rename a file +//////////////////////////////////////////////////////////// +sfFtpResponse* sfFtp_RenameFile(sfFtp* ftp, const char* file, const char* newName) +{ + CSFML_CHECK_RETURN(ftp, NULL); + + return new sfFtpResponse(ftp->This.RenameFile(file ? file : "", newName ? newName : "")); +} + + +//////////////////////////////////////////////////////////// +/// Remove an existing file +//////////////////////////////////////////////////////////// +sfFtpResponse* sfFtp_DeleteFile(sfFtp* ftp, const char* name) +{ + CSFML_CHECK_RETURN(ftp, NULL); + + return new sfFtpResponse(ftp->This.DeleteFile(name ? name : "")); +} + + +//////////////////////////////////////////////////////////// +/// Download a file from the server +//////////////////////////////////////////////////////////// +sfFtpResponse* sfFtp_Download(sfFtp* ftp, const char* distantFile, const char* destPath, sfFtpTransferMode mode) +{ + CSFML_CHECK_RETURN(ftp, NULL); + + return new sfFtpResponse(ftp->This.Download(distantFile ? distantFile : "", + destPath ? destPath : "", + static_cast(mode))); +} + + +//////////////////////////////////////////////////////////// +/// Upload a file to the server +//////////////////////////////////////////////////////////// +sfFtpResponse* sfFtp_Upload(sfFtp* ftp, const char* localFile, const char* destPath, sfFtpTransferMode mode) +{ + CSFML_CHECK_RETURN(ftp, NULL); + + return new sfFtpResponse(ftp->This.Upload(localFile ? localFile : "", + destPath ? destPath : "", + static_cast(mode))); +} diff --git a/src/SFML/Network/FtpStruct.h b/src/SFML/Network/FtpStruct.h new file mode 100644 index 0000000..3981743 --- /dev/null +++ b/src/SFML/Network/FtpStruct.h @@ -0,0 +1,93 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_FTPSTRUCT_H +#define SFML_FTPSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfFtp +//////////////////////////////////////////////////////////// +struct sfFtp +{ + sf::Ftp This; +}; + + +//////////////////////////////////////////////////////////// +// Internal structure of sfFtpResponse +//////////////////////////////////////////////////////////// +struct sfFtpResponse +{ + sfFtpResponse(const sf::Ftp::Response& Response) + : This(Response) + { + } + + sf::Ftp::Response This; +}; + + +//////////////////////////////////////////////////////////// +// Internal structure of sfFtpDirectoryResponse +//////////////////////////////////////////////////////////// +struct sfFtpDirectoryResponse +{ + sfFtpDirectoryResponse(const sf::Ftp::DirectoryResponse& Response) + : This(Response) + { + } + + sf::Ftp::DirectoryResponse This; +}; + + +//////////////////////////////////////////////////////////// +// Internal structure of sfFtpListingResponse +//////////////////////////////////////////////////////////// +struct sfFtpListingResponse +{ + sfFtpListingResponse(const sf::Ftp::ListingResponse& Response) + : This(Response) + { + } + + ~sfFtpListingResponse() + { + for (std::vector::iterator it = Filenames.begin(); it != Filenames.end(); ++it) + delete[] *it; + } + + sf::Ftp::ListingResponse This; + std::vector Filenames; +}; + + +#endif // SFML_FTPSTRUCT_H diff --git a/src/SFML/Network/Http.cpp b/src/SFML/Network/Http.cpp new file mode 100644 index 0000000..21f32f4 --- /dev/null +++ b/src/SFML/Network/Http.cpp @@ -0,0 +1,213 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new Http request +//////////////////////////////////////////////////////////// +sfHttpRequest* sfHttpRequest_Create(void) +{ + return new sfHttpRequest; +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing Http request +//////////////////////////////////////////////////////////// +void sfHttpRequest_Destroy(sfHttpRequest* httpRequest) +{ + delete httpRequest; +} + + +//////////////////////////////////////////////////////////// +/// Set the value of a field; the field is added if it doesn't exist +//////////////////////////////////////////////////////////// +void sfHttpRequest_SetField(sfHttpRequest* httpRequest, const char* field, const char* value) +{ + CSFML_CHECK(httpRequest); + if (field) + httpRequest->This.SetField(field, value); +} + + +//////////////////////////////////////////////////////////// +/// Set the request method. +/// This parameter is sfHttpGet by default +//////////////////////////////////////////////////////////// +void sfHttpRequest_SetMethod(sfHttpRequest* httpRequest, sfHttpMethod method) +{ + CSFML_CALL(httpRequest, SetMethod(static_cast(method))); +} + + +//////////////////////////////////////////////////////////// +/// Set the target URI of the request. +/// This parameter is "/" by default +//////////////////////////////////////////////////////////// +void sfHttpRequest_SetUri(sfHttpRequest* httpRequest, const char* uri) +{ + CSFML_CALL(httpRequest, SetUri(uri ? uri : "")); +} + + +//////////////////////////////////////////////////////////// +/// Set the HTTP version of the request. +/// This parameter is 1.0 by default +//////////////////////////////////////////////////////////// +void sfHttpRequest_SetHttpVersion(sfHttpRequest* httpRequest, unsigned int major, unsigned int minor) +{ + CSFML_CALL(httpRequest, SetHttpVersion(major, minor)); +} + + +//////////////////////////////////////////////////////////// +/// Set the body of the request. This parameter is optional and +/// makes sense only for POST requests. +/// This parameter is empty by default +//////////////////////////////////////////////////////////// +void sfHttpRequest_SetBody(sfHttpRequest* httpRequest, const char* body) +{ + CSFML_CALL(httpRequest, SetBody(body ? body : "")); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing Http response +//////////////////////////////////////////////////////////// +void sfHttpResponse_Destroy(sfHttpResponse* httpResponse) +{ + delete httpResponse; +} + + +//////////////////////////////////////////////////////////// +/// Get the value of a field; returns NULL if the field doesn't exist +//////////////////////////////////////////////////////////// +const char* sfHttpResponse_GetField(const sfHttpResponse* httpResponse, const char* field) +{ + CSFML_CHECK_RETURN(httpResponse, NULL); + if (!field) + return NULL; + + return httpResponse->This.GetField(field).c_str(); +} + + +//////////////////////////////////////////////////////////// +/// Get the status of a response +//////////////////////////////////////////////////////////// +sfHttpStatus sfHttpResponse_GetStatus(const sfHttpResponse* httpResponse) +{ + CSFML_CHECK_RETURN(httpResponse, sfHttpInvalidResponse); + + return static_cast(httpResponse->This.GetStatus()); +} + + +//////////////////////////////////////////////////////////// +/// Get the major HTTP version of a response +//////////////////////////////////////////////////////////// +unsigned int sfHttpResponse_GetMajorVersion(const sfHttpResponse* httpResponse) +{ + CSFML_CALL_RETURN(httpResponse, GetMajorHttpVersion(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Get the minor HTTP version of a response +//////////////////////////////////////////////////////////// +unsigned int sfHttpResponse_GetMinorVersion(const sfHttpResponse* httpResponse) +{ + CSFML_CALL_RETURN(httpResponse, GetMinorHttpVersion(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Get the body of the response. The body can contain : +/// - the requested page (for GET requests) +/// - a response from the server (for POST requests) +/// - nothing (for HEAD requests) +/// - an error message (in case of an error) +//////////////////////////////////////////////////////////// +const char* sfHttpResponse_GetBody(const sfHttpResponse* httpResponse) +{ + CSFML_CHECK_RETURN(httpResponse, NULL); + + return httpResponse->This.GetBody().c_str(); +} + + +//////////////////////////////////////////////////////////// +/// Construct a new Http object +//////////////////////////////////////////////////////////// +sfHttp* sfHttp_Create(void) +{ + return new sfHttp; +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing Http object +//////////////////////////////////////////////////////////// +void sfHttp_Destroy(sfHttp* http) +{ + delete http; +} + + +//////////////////////////////////////////////////////////// +/// Set the target host of a Http server +//////////////////////////////////////////////////////////// +void sfHttp_SetHost(sfHttp* http, const char* host, unsigned short port) +{ + CSFML_CALL(http, SetHost(host ? host : "", port)); +} + + +//////////////////////////////////////////////////////////// +/// Send a HTTP request and return the server's response. +/// You must be connected to a host before sending requests. +/// Any missing mandatory header field will be added with an appropriate value. +/// Warning : this function waits for the server's response and may +/// not return instantly; use a thread if you don't want to block your +/// application. +//////////////////////////////////////////////////////////// +sfHttpResponse* sfHttp_SendRequest(sfHttp* http, const sfHttpRequest* request, sfUint32 timeout) +{ + CSFML_CHECK_RETURN(http, NULL); + CSFML_CHECK_RETURN(request, NULL); + + sfHttpResponse* response = new sfHttpResponse; + response->This = http->This.SendRequest(request->This, timeout); + + return response; +} diff --git a/src/SFML/Network/HttpStruct.h b/src/SFML/Network/HttpStruct.h new file mode 100644 index 0000000..a33a372 --- /dev/null +++ b/src/SFML/Network/HttpStruct.h @@ -0,0 +1,61 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_HTTPSTRUCT_H +#define SFML_HTTPSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfHttp +//////////////////////////////////////////////////////////// +struct sfHttp +{ + sf::Http This; +}; + + +//////////////////////////////////////////////////////////// +// Internal structure of sfHttpRequest +//////////////////////////////////////////////////////////// +struct sfHttpRequest +{ + sf::Http::Request This; +}; + + +//////////////////////////////////////////////////////////// +// Internal structure of sfHttpResponse +//////////////////////////////////////////////////////////// +struct sfHttpResponse +{ + sf::Http::Response This; +}; + + +#endif // SFML_HTTPSTRUCT_H diff --git a/src/SFML/Network/IpAddress.cpp b/src/SFML/Network/IpAddress.cpp new file mode 100644 index 0000000..fb0c482 --- /dev/null +++ b/src/SFML/Network/IpAddress.cpp @@ -0,0 +1,137 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +namespace +{ + //////////////////////////////////////////////////////////// + /// Helper function for converting a SFML address to a CSFML one + //////////////////////////////////////////////////////////// + sfIpAddress FromSFMLAddress(sf::IpAddress address) + { + sfIpAddress result; + strncpy(result.Address, address.ToString().c_str(), 16); + + return result; + } + + //////////////////////////////////////////////////////////// + /// Helper function for converting a CSFML address to a SFML one + //////////////////////////////////////////////////////////// + sf::IpAddress ToSFMLAddress(sfIpAddress address) + { + return sf::IpAddress(address.Address); + } +} + + +//////////////////////////////////////////////////////////// +/// Construct an address from a string +//////////////////////////////////////////////////////////// +sfIpAddress sfIpAddress_FromString(const char* string) +{ + return FromSFMLAddress(sf::IpAddress(string)); +} + + +//////////////////////////////////////////////////////////// +/// Construct an address from 4 bytes +//////////////////////////////////////////////////////////// +sfIpAddress sfIpAddress_FromBytes(sfUint8 byte0, sfUint8 byte1, sfUint8 byte2, sfUint8 byte3) +{ + return FromSFMLAddress(sf::IpAddress(byte0, byte1, byte2, byte3)); +} + + +//////////////////////////////////////////////////////////// +/// Construct the address from a 32-bits integer +//////////////////////////////////////////////////////////// +sfIpAddress sfIpAddress_FromInteger(sfUint32 address) +{ + return FromSFMLAddress(sf::IpAddress(address)); +} + + +//////////////////////////////////////////////////////////// +/// Get a string representation of an address +//////////////////////////////////////////////////////////// +void sfIpAddress_ToString(sfIpAddress address, char* string) +{ + if (string) + strcpy(string, address.Address); +} + + +//////////////////////////////////////////////////////////// +/// Get an integer representation of the address +//////////////////////////////////////////////////////////// +sfUint32 sfIpAddress_ToInteger(sfIpAddress address) +{ + return ToSFMLAddress(address).ToInteger(); +} + + +//////////////////////////////////////////////////////////// +/// Get the computer's local IP address (from the LAN point of view) +//////////////////////////////////////////////////////////// +sfIpAddress sfIpAddress_GetLocalAddress(void) +{ + return FromSFMLAddress(sf::IpAddress::GetLocalAddress()); +} + + +//////////////////////////////////////////////////////////// +/// Get the computer's public IP address (from the web point of view). +/// The only way to get a public address is to ask it to a +/// distant website ; as a consequence, this function may be +/// very slow -- use it as few as possible ! +//////////////////////////////////////////////////////////// +sfIpAddress sfIpAddress_GetPublicAddress(sfUint32 timeout) +{ + return FromSFMLAddress(sf::IpAddress::GetPublicAddress(timeout)); +} + + +//////////////////////////////////////////////////////////// +/// Get the computer's loopback address +//////////////////////////////////////////////////////////// +sfIpAddress sfIpAddress_LocalHost(void) +{ + return FromSFMLAddress(sf::IpAddress::LocalHost); +} + +//////////////////////////////////////////////////////////// +/// Get the empty/invalid address +//////////////////////////////////////////////////////////// +sfIpAddress sfIpAddress_None(void) +{ + return FromSFMLAddress(sf::IpAddress::None); +} diff --git a/src/SFML/Network/Packet.cpp b/src/SFML/Network/Packet.cpp new file mode 100644 index 0000000..6317f72 --- /dev/null +++ b/src/SFML/Network/Packet.cpp @@ -0,0 +1,210 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +namespace +{ + //////////////////////////////////////////////////////////// + /// Helper function to read a variable from a packet + //////////////////////////////////////////////////////////// + template + T PacketRead(sfPacket* packet) + { + CSFML_CHECK_RETURN(packet, 0); + + T value; + packet->This >> value; + return value; + } + + //////////////////////////////////////////////////////////// + /// Helper function to write a variable to a packet + //////////////////////////////////////////////////////////// + template + void PacketWrite(sfPacket* packet, T value) + { + CSFML_CHECK(packet); + + packet->This << value; + } +} + + +//////////////////////////////////////////////////////////// +/// Create a new empty packet +//////////////////////////////////////////////////////////// +sfPacket* sfPacket_Create(void) +{ + return new sfPacket; +} + + +//////////////////////////////////////////////////////////// +/// Copy an existing packet +//////////////////////////////////////////////////////////// +sfPacket* sfPacket_Copy(sfPacket* packet) +{ + CSFML_CHECK_RETURN(packet, NULL); + + return new sfPacket(*packet); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing packet +//////////////////////////////////////////////////////////// +void sfPacket_Destroy(sfPacket* packet) +{ + delete packet; +} + + +//////////////////////////////////////////////////////////// +/// Append data to the end of a packet +//////////////////////////////////////////////////////////// +void sfPacket_Append(sfPacket* packet, const void* data, size_t sizeInBytes) +{ + CSFML_CALL(packet, Append(data, sizeInBytes)); +} + + +//////////////////////////////////////////////////////////// +/// Clear all the data of a packet +/////////////////////////////////////////////////////////// +void sfPacket_Clear(sfPacket* packet) +{ + CSFML_CALL(packet, Clear()); +} + + +//////////////////////////////////////////////////////////// +/// Get a pointer to the data contained in a packet +/// Warning : the returned pointer may be invalid after you +/// append data to the packet +//////////////////////////////////////////////////////////// +const char* sfPacket_GetData(const sfPacket* packet) +{ + CSFML_CALL_RETURN(packet, GetData(), NULL); +} + + +//////////////////////////////////////////////////////////// +/// Get the size of the data contained in a packet +//////////////////////////////////////////////////////////// +size_t sfPacket_GetDataSize(const sfPacket* packet) +{ + CSFML_CALL_RETURN(packet, GetDataSize(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Tell if the reading position has reached the end of the packet +//////////////////////////////////////////////////////////// +sfBool sfPacket_EndOfPacket(const sfPacket* packet) +{ + CSFML_CALL_RETURN(packet, EndOfPacket(), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Check if a packet is in a valid reading state +//////////////////////////////////////////////////////////// +sfBool sfPacket_CanRead(const sfPacket* packet) +{ + CSFML_CHECK_RETURN(packet, sfFalse); + return packet->This ? sfTrue : sfFalse; +} + + +//////////////////////////////////////////////////////////// +/// Functions to extract data from a packet +/// +/// \param Packet : Packet to read +/// +//////////////////////////////////////////////////////////// +sfBool sfPacket_ReadBool(sfPacket* packet) {return PacketRead(packet);} +sfInt8 sfPacket_ReadInt8(sfPacket* packet) {return PacketRead(packet);} +sfUint8 sfPacket_ReadUint8(sfPacket* packet) {return PacketRead(packet);} +sfInt16 sfPacket_ReadInt16(sfPacket* packet) {return PacketRead(packet);} +sfUint16 sfPacket_ReadUint16(sfPacket* packet) {return PacketRead(packet);} +sfInt32 sfPacket_ReadInt32(sfPacket* packet) {return PacketRead(packet);} +sfUint32 sfPacket_ReadUint32(sfPacket* packet) {return PacketRead(packet);} +float sfPacket_ReadFloat(sfPacket* packet) {return PacketRead(packet);} +double sfPacket_ReadDouble(sfPacket* packet) {return PacketRead(packet);} + +void sfPacket_ReadString(sfPacket* packet, char* string) +{ + CSFML_CHECK(packet); + + if (string) + packet->This >> string; +} + +void sfPacket_ReadWideString(sfPacket* packet, wchar_t* string) +{ + CSFML_CHECK(packet); + + if (string) + packet->This >> string; +} + + +//////////////////////////////////////////////////////////// +/// Functions to insert data into a packet +/// +/// \param Packet : Packet to write +/// +//////////////////////////////////////////////////////////// +void sfPacket_WriteBool(sfPacket* packet, sfBool value) {PacketWrite(packet, static_cast(value));} +void sfPacket_WriteInt8(sfPacket* packet, sfInt8 value) {PacketWrite(packet, value);} +void sfPacket_WriteUint8(sfPacket* packet, sfUint8 value) {PacketWrite(packet, value);} +void sfPacket_WriteInt16(sfPacket* packet, sfInt16 value) {PacketWrite(packet, value);} +void sfPacket_WriteUint16(sfPacket* packet, sfUint16 value) {PacketWrite(packet, value);} +void sfPacket_WriteInt32(sfPacket* packet, sfInt32 value) {PacketWrite(packet, value);} +void sfPacket_WriteUint32(sfPacket* packet, sfUint32 value) {PacketWrite(packet, value);} +void sfPacket_WriteFloat(sfPacket* packet, float value) {PacketWrite(packet, value);} +void sfPacket_WriteDouble(sfPacket* packet, double value) {PacketWrite(packet, value);} + +void sfPacket_WriteString(sfPacket* packet, const char* string) +{ + CSFML_CHECK(packet); + + if (string) + packet->This << string; +} + +void sfPacket_WriteWideString(sfPacket* packet, const wchar_t* string) +{ + CSFML_CHECK(packet); + + if (string) + packet->This << string; +} diff --git a/src/SFML/Network/PacketStruct.h b/src/SFML/Network/PacketStruct.h new file mode 100644 index 0000000..9e6b46b --- /dev/null +++ b/src/SFML/Network/PacketStruct.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_PACKETSTRUCT_H +#define SFML_PACKETSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfPacket +//////////////////////////////////////////////////////////// +struct sfPacket +{ + sf::Packet This; +}; + + +#endif // SFML_PACKETSTRUCT_H diff --git a/src/SFML/Network/SocketSelector.cpp b/src/SFML/Network/SocketSelector.cpp new file mode 100644 index 0000000..8132127 --- /dev/null +++ b/src/SFML/Network/SocketSelector.cpp @@ -0,0 +1,142 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new selector +//////////////////////////////////////////////////////////// +sfSocketSelector* sfSocketSelector_Create(void) +{ + return new sfSocketSelector; +} + + +//////////////////////////////////////////////////////////// +/// Copy an existing selector +//////////////////////////////////////////////////////////// +sfSocketSelector* sfSocketSelector_Copy(sfSocketSelector* selector) +{ + CSFML_CHECK_RETURN(selector, NULL); + + return new sfSocketSelector(*selector); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing selector +//////////////////////////////////////////////////////////// +void sfSocketSelector_Destroy(sfSocketSelector* selector) +{ + delete selector; +} + + +//////////////////////////////////////////////////////////// +/// Add a socket to watch to a selector +//////////////////////////////////////////////////////////// +void sfSocketSelector_AddTcpListener(sfSocketSelector* selector, sfTcpListener* socket) +{ + CSFML_CHECK(socket); + CSFML_CALL(selector, Add(socket->This)); +} +void sfSocketSelector_AddTcpSocket(sfSocketSelector* selector, sfTcpSocket* socket) +{ + CSFML_CHECK(socket); + CSFML_CALL(selector, Add(socket->This)); +} +void sfSocketSelector_AddUdpSocket(sfSocketSelector* selector, sfUdpSocket* socket) +{ + CSFML_CHECK(socket); + CSFML_CALL(selector, Add(socket->This)); +} + + +//////////////////////////////////////////////////////////// +/// Remove a socket from a selector +//////////////////////////////////////////////////////////// +void sfSocketSelector_RemoveTcpListener(sfSocketSelector* selector, sfTcpListener* socket) +{ + CSFML_CHECK(socket); + CSFML_CALL(selector, Remove(socket->This)); +} +void sfSocketSelector_RemoveTcpSocket(sfSocketSelector* selector, sfTcpSocket* socket) +{ + CSFML_CHECK(socket); + CSFML_CALL(selector, Remove(socket->This)); +} +void sfSocketSelector_RemoveUdpSocket(sfSocketSelector* selector, sfUdpSocket* socket) +{ + CSFML_CHECK(socket); + CSFML_CALL(selector, Remove(socket->This)); +} + + +//////////////////////////////////////////////////////////// +/// Remove all sockets from a selector +//////////////////////////////////////////////////////////// +void sfSocketSelector_Clear(sfSocketSelector* selector) +{ + CSFML_CALL(selector, Clear()); +} + + +//////////////////////////////////////////////////////////// +/// Wait and collect sockets which are ready for reading. +/// This functions will return either when at least one socket +/// is ready, or when the given timeout is over +//////////////////////////////////////////////////////////// +sfBool sfSocketSelector_Wait(sfSocketSelector* selector, sfUint32 timeout) +{ + CSFML_CALL_RETURN(selector, Wait(timeout), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Test a socket to know if it is ready to receive data +//////////////////////////////////////////////////////////// +sfBool sfSocketSelector_IsTcpListenerReady(const sfSocketSelector* selector, sfTcpListener* socket) +{ + CSFML_CHECK_RETURN(socket, sfFalse); + CSFML_CALL_RETURN(selector, IsReady(socket->This), sfFalse); +} +sfBool sfSocketSelector_IsTcpSocketReady(const sfSocketSelector* selector, sfTcpSocket* socket) +{ + CSFML_CHECK_RETURN(socket, sfFalse); + CSFML_CALL_RETURN(selector, IsReady(socket->This), sfFalse); +} +sfBool sfSocketSelector_IsUdpSocketReady(const sfSocketSelector* selector, sfUdpSocket* socket) +{ + CSFML_CHECK_RETURN(socket, sfFalse); + CSFML_CALL_RETURN(selector, IsReady(socket->This), sfFalse); +} diff --git a/src/SFML/Network/SocketSelectorStruct.h b/src/SFML/Network/SocketSelectorStruct.h new file mode 100644 index 0000000..a61456a --- /dev/null +++ b/src/SFML/Network/SocketSelectorStruct.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SOCKETSELECTORSTRUCT_H +#define SFML_SOCKETSELECTORSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfSocketSelector +//////////////////////////////////////////////////////////// +struct sfSocketSelector +{ + sf::SocketSelector This; +}; + + +#endif // SFML_SOCKETSELECTORSTRUCT_H diff --git a/src/SFML/Network/TcpListener.cpp b/src/SFML/Network/TcpListener.cpp new file mode 100644 index 0000000..a0f4ffb --- /dev/null +++ b/src/SFML/Network/TcpListener.cpp @@ -0,0 +1,94 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new TCP socket +//////////////////////////////////////////////////////////// +sfTcpListener* sfTcpListener_Create(void) +{ + return new sfTcpListener; +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing TCP socket +//////////////////////////////////////////////////////////// +void sfTcpListener_Destroy(sfTcpListener* socket) +{ + delete socket; +} + + +//////////////////////////////////////////////////////////// +/// Change the blocking state of a TCP socket. +/// The default behaviour of a socket is blocking +//////////////////////////////////////////////////////////// +void sfTcpListener_SetBlocking(sfTcpListener* socket, sfBool blocking) +{ + CSFML_CALL(socket, SetBlocking(blocking == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +/// Get the blocking state of the socket +//////////////////////////////////////////////////////////// +sfBool sfTcpListener_IsBlocking(const sfTcpListener* socket) +{ + CSFML_CALL_RETURN(socket, IsBlocking(), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Listen to a specified port for incoming data or connections +//////////////////////////////////////////////////////////// +sfSocketStatus sfTcpListener_Listen(sfTcpListener* socket, unsigned short port) +{ + CSFML_CHECK_RETURN(socket, sfSocketError); + + return static_cast(socket->This.Listen(port)); +} + + +//////////////////////////////////////////////////////////// +/// Wait for a connection (must be listening to a port). +/// This function is blocking, ie. it won't return before +/// a connection has been accepted +//////////////////////////////////////////////////////////// +sfSocketStatus sfTcpListener_Accept(sfTcpListener* socket, sfTcpSocket** connected) +{ + CSFML_CHECK_RETURN(socket, sfSocketError); + CSFML_CHECK_RETURN(connected, sfSocketError); + + *connected = new sfTcpSocket; + return static_cast(socket->This.Accept((*connected)->This)); +} diff --git a/src/SFML/Network/TcpListenerStruct.h b/src/SFML/Network/TcpListenerStruct.h new file mode 100644 index 0000000..d58ad78 --- /dev/null +++ b/src/SFML/Network/TcpListenerStruct.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_TCPLISTENERSTRUCT_H +#define SFML_TCPLISTENERSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfTcpListener +//////////////////////////////////////////////////////////// +struct sfTcpListener +{ + sf::TcpListener This; +}; + + +#endif // SFML_TCPLISTENERSTRUCT_H diff --git a/src/SFML/Network/TcpSocket.cpp b/src/SFML/Network/TcpSocket.cpp new file mode 100644 index 0000000..ad4adde --- /dev/null +++ b/src/SFML/Network/TcpSocket.cpp @@ -0,0 +1,179 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new TCP socket +//////////////////////////////////////////////////////////// +sfTcpSocket* sfTcpSocket_Create(void) +{ + return new sfTcpSocket; +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing TCP socket +//////////////////////////////////////////////////////////// +void sfTcpSocket_Destroy(sfTcpSocket* socket) +{ + delete socket; +} + + +//////////////////////////////////////////////////////////// +/// Change the blocking state of a TCP socket. +/// The default behaviour of a socket is blocking +//////////////////////////////////////////////////////////// +void sfTcpSocket_SetBlocking(sfTcpSocket* socket, sfBool blocking) +{ + CSFML_CALL(socket, SetBlocking(blocking == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +/// Get the blocking state of the socket +//////////////////////////////////////////////////////////// +sfBool sfTcpSocket_IsBlocking(const sfTcpSocket* socket) +{ + CSFML_CALL_RETURN(socket, IsBlocking(), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Get the port to which a socket is bound locally +//////////////////////////////////////////////////////////// +unsigned short sfTcpSocket_GetLocalPort(const sfTcpSocket* socket) +{ + CSFML_CALL_RETURN(socket, GetLocalPort(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Get the address of the connected peer of a socket +//////////////////////////////////////////////////////////// +sfIpAddress sfTcpSocket_GetRemoteAddress(const sfTcpSocket* socket) +{ + sfIpAddress result; + CSFML_CHECK_RETURN(socket, result); + + sf::IpAddress address = socket->This.GetRemoteAddress(); + strncpy(result.Address, address.ToString().c_str(), 16); + + return result; +} + + +//////////////////////////////////////////////////////////// +/// Get the port of the connected peer to which a socket is connected +//////////////////////////////////////////////////////////// +unsigned short sfTcpSocket_GetRemotePort(const sfTcpSocket* socket) +{ + CSFML_CALL_RETURN(socket, GetRemotePort(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Connect a TCP socket to another computer on a specified port +//////////////////////////////////////////////////////////// +sfSocketStatus sfTcpSocket_Connect(sfTcpSocket* socket, sfIpAddress host, unsigned short port, sfUint32 timeout) +{ + sf::IpAddress address(host.Address); + + CSFML_CHECK_RETURN(socket, sfSocketError); + + return static_cast(socket->This.Connect(address, port, timeout)); +} + + +//////////////////////////////////////////////////////////// +/// Disconnect a connect from its remote peer +//////////////////////////////////////////////////////////// +void sfTcpSocket_Disconnect(sfTcpSocket* socket) +{ + CSFML_CALL(socket, Disconnect()); +} + + +//////////////////////////////////////////////////////////// +/// Send an array of bytes to the host (must be connected first) +//////////////////////////////////////////////////////////// +sfSocketStatus sfTcpSocket_Send(sfTcpSocket* socket, const char* data, size_t size) +{ + CSFML_CHECK_RETURN(socket, sfSocketError); + + return static_cast(socket->This.Send(data, size)); +} + + +//////////////////////////////////////////////////////////// +/// Receive an array of bytes from the host (must be connected first) +//////////////////////////////////////////////////////////// +sfSocketStatus sfTcpSocket_Receive(sfTcpSocket* socket, char* data, size_t maxSize, size_t* sizeReceived) +{ + CSFML_CHECK_RETURN(socket, sfSocketError); + + if (sizeReceived) + { + return static_cast(socket->This.Receive(data, maxSize, *sizeReceived)); + } + else + { + std::size_t size = 0; + return static_cast(socket->This.Receive(data, maxSize, size)); + } +} + + +//////////////////////////////////////////////////////////// +/// Send a packet of data to the host (must be connected first) +//////////////////////////////////////////////////////////// +sfSocketStatus sfTcpSocket_SendPacket(sfTcpSocket* socket, sfPacket* packet) +{ + CSFML_CHECK_RETURN(socket, sfSocketError); + CSFML_CHECK_RETURN(packet, sfSocketError); + + return static_cast(socket->This.Send(packet->This)); +} + + +//////////////////////////////////////////////////////////// +/// Receive a packet from the host (must be connected first) +//////////////////////////////////////////////////////////// +sfSocketStatus sfTcpSocket_ReceivePacket(sfTcpSocket* socket, sfPacket* packet) +{ + CSFML_CHECK_RETURN(socket, sfSocketError); + CSFML_CHECK_RETURN(packet, sfSocketError); + + return static_cast(socket->This.Receive(packet->This)); +} diff --git a/src/SFML/Network/TcpSocketStruct.h b/src/SFML/Network/TcpSocketStruct.h new file mode 100644 index 0000000..887ac87 --- /dev/null +++ b/src/SFML/Network/TcpSocketStruct.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_TCPSOCKETSTRUCT_H +#define SFML_TCPSOCKETSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfTcpSocket +//////////////////////////////////////////////////////////// +struct sfTcpSocket +{ + sf::TcpSocket This; +}; + + +#endif // SFML_TCPSOCKETSTRUCT_H diff --git a/src/SFML/Network/UdpSocket.cpp b/src/SFML/Network/UdpSocket.cpp new file mode 100644 index 0000000..1b14f7e --- /dev/null +++ b/src/SFML/Network/UdpSocket.cpp @@ -0,0 +1,184 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new UDP socket +//////////////////////////////////////////////////////////// +sfUdpSocket* sfUdpSocket_Create(void) +{ + return new sfUdpSocket; +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing UDP socket +//////////////////////////////////////////////////////////// +void sfUdpSocket_Destroy(sfUdpSocket* socket) +{ + delete socket; +} + + +//////////////////////////////////////////////////////////// +/// Change the blocking state of a UDP socket. +/// The default behaviour of a socket is blocking +//////////////////////////////////////////////////////////// +void sfUdpSocket_SetBlocking(sfUdpSocket* socket, sfBool blocking) +{ + CSFML_CALL(socket, SetBlocking(blocking == sfTrue)); +} + +//////////////////////////////////////////////////////////// +/// Get the blocking state of the socket +//////////////////////////////////////////////////////////// +sfBool sfUdpSocket_IsBlocking(const sfUdpSocket* socket) +{ + CSFML_CALL_RETURN(socket, IsBlocking(), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Get the port to which the socket is bound locally +//////////////////////////////////////////////////////////// +unsigned short sfUdpSocket_GetLocalPort(const sfUdpSocket* socket) +{ + CSFML_CALL_RETURN(socket, GetLocalPort(), 0); +} + + +//////////////////////////////////////////////////////////// +/// Bind a socket to a specific port +//////////////////////////////////////////////////////////// +sfSocketStatus sfUdpSocket_Bind(sfUdpSocket* socket, unsigned short port) +{ + CSFML_CHECK_RETURN(socket, sfSocketError); + + return static_cast(socket->This.Bind(port)); +} + + +//////////////////////////////////////////////////////////// +/// Unbind a socket from its previous port, if any +//////////////////////////////////////////////////////////// +void sfUdpSocket_Unbind(sfUdpSocket* socket) +{ + CSFML_CALL(socket, Unbind()); +} + + +//////////////////////////////////////////////////////////// +/// Send an array of bytes +//////////////////////////////////////////////////////////// +sfSocketStatus sfUdpSocket_Send(sfUdpSocket* socket, const char* data, size_t size, sfIpAddress address, unsigned short port) +{ + CSFML_CHECK_RETURN(socket, sfSocketError) + + // Convert the address + sf::IpAddress receiver(address.Address); + + return static_cast(socket->This.Send(data, size, receiver, port)); +} + + +//////////////////////////////////////////////////////////// +/// Receive an array of bytes. +/// This function is blocking, ie. it won't return before some +/// bytes have been received +//////////////////////////////////////////////////////////// +sfSocketStatus sfUdpSocket_Receive(sfUdpSocket* socket, char* data, size_t maxSize, size_t* sizeReceived, sfIpAddress* address, unsigned short* port) +{ + CSFML_CHECK_RETURN(socket, sfSocketError); + + // Call SFML internal function + sf::IpAddress sender; + unsigned short senderPort; + std::size_t received; + + sf::Socket::Status status = socket->This.Receive(data, maxSize, received, sender, senderPort); + if (status != sf::Socket::Done) + return static_cast(status); + + if (sizeReceived) + *sizeReceived = received; + + if (address) + strncpy(address->Address, sender.ToString().c_str(), 16); + + if (port) + *port = senderPort; + + return sfSocketDone; +} + + +//////////////////////////////////////////////////////////// +/// Send a packet of data +//////////////////////////////////////////////////////////// +sfSocketStatus sfUdpSocket_SendPacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress address, unsigned short port) +{ + CSFML_CHECK_RETURN(socket, sfSocketError); + CSFML_CHECK_RETURN(packet, sfSocketError); + + // Convert the address + sf::IpAddress receiver(address.Address); + + return static_cast(socket->This.Send(packet->This, receiver, port)); +} + + +//////////////////////////////////////////////////////////// +/// Receive a packet. +/// This function is blocking, ie. it won't return before a +/// packet is received +//////////////////////////////////////////////////////////// +sfSocketStatus sfUdpSocket_ReceivePacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress* address, unsigned short* port) +{ + CSFML_CHECK_RETURN(socket, sfSocketError); + CSFML_CHECK_RETURN(packet, sfSocketError); + + sf::IpAddress sender; + unsigned short senderPort; + sf::Socket::Status status = socket->This.Receive(packet->This, sender, senderPort); + if (status != sf::Socket::Done) + return static_cast(status); + + if (address) + strncpy(address->Address, sender.ToString().c_str(), 16); + + if (port) + *port = senderPort; + + return sfSocketDone; +} diff --git a/src/SFML/Network/UdpSocketStruct.h b/src/SFML/Network/UdpSocketStruct.h new file mode 100644 index 0000000..219d4a3 --- /dev/null +++ b/src/SFML/Network/UdpSocketStruct.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_UDPSOCKETSTRUCT_H +#define SFML_UDPSOCKETSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfUdpSocket +//////////////////////////////////////////////////////////// +struct sfUdpSocket +{ + sf::UdpSocket This; +}; + + +#endif // SFML_UDPSOCKETSTRUCT_H diff --git a/src/SFML/System/CMakeLists.txt b/src/SFML/System/CMakeLists.txt new file mode 100644 index 0000000..d8f295c --- /dev/null +++ b/src/SFML/System/CMakeLists.txt @@ -0,0 +1,24 @@ + +set(INCROOT ${CMAKE_SOURCE_DIR}/include/SFML/System) +set(SRCROOT ${CMAKE_SOURCE_DIR}/src/SFML/System) + +# all source files +set(SRC + ${SRCROOT}/Clock.cpp + ${SRCROOT}/ClockStruct.h + ${INCROOT}/Clock.h + ${SRCROOT}/Mutex.cpp + ${SRCROOT}/MutexStruct.h + ${INCROOT}/Mutex.h + ${SRCROOT}/Sleep.cpp + ${INCROOT}/Sleep.h + ${SRCROOT}/Thread.cpp + ${SRCROOT}/ThreadStruct.h + ${INCROOT}/Thread.h + ${INCROOT}/Types.h +) + +# define the csfml-system target +csfml_add_library(csfml-system + SOURCES ${SRC} + DEPENDS ${SFML_SYSTEM_LIBRARY}) diff --git a/src/SFML/System/Clock.cpp b/src/SFML/System/Clock.cpp new file mode 100644 index 0000000..9761e00 --- /dev/null +++ b/src/SFML/System/Clock.cpp @@ -0,0 +1,77 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new clock and start it +//////////////////////////////////////////////////////////// +sfClock* sfClock_Create(void) +{ + return new sfClock; +} + + +//////////////////////////////////////////////////////////// +/// Copy an existing clock +//////////////////////////////////////////////////////////// +sfClock* sfClock_Copy(sfClock* clock) +{ + CSFML_CHECK_RETURN(clock, NULL); + + return new sfClock(*clock); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing clock +//////////////////////////////////////////////////////////// +void sfClock_Destroy(sfClock* clock) +{ + delete clock; +} + + +//////////////////////////////////////////////////////////// +/// Get the time elapsed for a clock +//////////////////////////////////////////////////////////// +sfUint32 sfClock_GetTime(const sfClock* clock) +{ + CSFML_CALL_RETURN(clock, GetElapsedTime(), 0) +} + + +//////////////////////////////////////////////////////////// +/// Restart a clock +//////////////////////////////////////////////////////////// +void sfClock_Reset(sfClock* clock) +{ + CSFML_CALL(clock, Reset()) +} diff --git a/src/SFML/System/ClockStruct.h b/src/SFML/System/ClockStruct.h new file mode 100644 index 0000000..dc50433 --- /dev/null +++ b/src/SFML/System/ClockStruct.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_CLOCKSTRUCT_H +#define SFML_CLOCKSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfClock +//////////////////////////////////////////////////////////// +struct sfClock +{ + sf::Clock This; +}; + + +#endif // SFML_CLOCKSTRUCT_H diff --git a/src/SFML/System/Mutex.cpp b/src/SFML/System/Mutex.cpp new file mode 100644 index 0000000..1bfbf1b --- /dev/null +++ b/src/SFML/System/Mutex.cpp @@ -0,0 +1,66 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Create a new mutex +//////////////////////////////////////////////////////////// +sfMutex* sfMutex_Create(void) +{ + return new sfMutex; +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing mutex +//////////////////////////////////////////////////////////// +void sfMutex_Destroy(sfMutex* mutex) +{ + delete mutex; +} + + +//////////////////////////////////////////////////////////// +/// Lock a mutex +//////////////////////////////////////////////////////////// +void sfMutex_Lock(sfMutex* mutex) +{ + CSFML_CALL(mutex, Lock()) +} + + +//////////////////////////////////////////////////////////// +/// Unlock a mutex +//////////////////////////////////////////////////////////// +void sfMutex_Unlock(sfMutex* mutex) +{ + CSFML_CALL(mutex, Unlock()) +} diff --git a/src/SFML/System/MutexStruct.h b/src/SFML/System/MutexStruct.h new file mode 100644 index 0000000..0181e1c --- /dev/null +++ b/src/SFML/System/MutexStruct.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_MUTEXSTRUCT_H +#define SFML_MUTEXSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfMutex +//////////////////////////////////////////////////////////// +struct sfMutex +{ + sf::Mutex This; +}; + + +#endif // SFML_MUTEXSTRUCT_H diff --git a/src/SFML/System/Sleep.cpp b/src/SFML/System/Sleep.cpp new file mode 100644 index 0000000..79cfcc7 --- /dev/null +++ b/src/SFML/System/Sleep.cpp @@ -0,0 +1,39 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Make the current thread sleep for a given duration +//////////////////////////////////////////////////////////// +void sfSleep(sfUint32 Duration) +{ + sf::Sleep(Duration); +} diff --git a/src/SFML/System/Thread.cpp b/src/SFML/System/Thread.cpp new file mode 100644 index 0000000..678bea5 --- /dev/null +++ b/src/SFML/System/Thread.cpp @@ -0,0 +1,78 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new thread from a function pointer +//////////////////////////////////////////////////////////// +sfThread* sfThread_Create(void (*function)(void*), void* userData) +{ + return new sfThread(function, userData); +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing thread +//////////////////////////////////////////////////////////// +void sfThread_Destroy(sfThread* thread) +{ + delete thread; +} + + +//////////////////////////////////////////////////////////// +/// Run a thread +//////////////////////////////////////////////////////////// +void sfThread_Launch(sfThread* thread) +{ + CSFML_CALL(thread, Launch()); +} + + +//////////////////////////////////////////////////////////// +/// Wait until a thread finishes +//////////////////////////////////////////////////////////// +void sfThread_Wait(sfThread* thread) +{ + CSFML_CALL(thread, Wait()); +} + + +//////////////////////////////////////////////////////////// +/// Terminate a thread +/// Terminating a thread with this function is not safe, +/// you should rather try to make the thread function +/// terminate by itself +//////////////////////////////////////////////////////////// +void sfThread_Terminate(sfThread* thread) +{ + CSFML_CALL(thread, Terminate()); +} diff --git a/src/SFML/System/ThreadStruct.h b/src/SFML/System/ThreadStruct.h new file mode 100644 index 0000000..3f3630a --- /dev/null +++ b/src/SFML/System/ThreadStruct.h @@ -0,0 +1,48 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_THREADSTRUCT_H +#define SFML_THREADSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfThread +//////////////////////////////////////////////////////////// +struct sfThread +{ + sfThread(void (*Function)(void*), void* UserData) : + This(Function, UserData) + { + } + + sf::Thread This; +}; + + +#endif // SFML_THREADSTRUCT_H diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt new file mode 100644 index 0000000..9c4dce4 --- /dev/null +++ b/src/SFML/Window/CMakeLists.txt @@ -0,0 +1,29 @@ + +set(INCROOT ${CMAKE_SOURCE_DIR}/include/SFML/Window) +set(SRCROOT ${CMAKE_SOURCE_DIR}/src/SFML/Window) + +# all source files +set(SRC + ${SRCROOT}/Context.cpp + ${SRCROOT}/ContextStruct.h + ${INCROOT}/Context.h + ${INCROOT}/Event.h + ${SRCROOT}/Joystick.cpp + ${SRCROOT}/Keyboard.cpp + ${SRCROOT}/Mouse.cpp + ${INCROOT}/Joystick.h + ${INCROOT}/Keyboard.h + ${INCROOT}/Mouse.h + ${INCROOT}/Types.h + ${SRCROOT}/VideoMode.cpp + ${INCROOT}/VideoMode.h + ${SRCROOT}/Window.cpp + ${SRCROOT}/WindowStruct.h + ${INCROOT}/Window.h + ${INCROOT}/WindowHandle.h +) + +# define the csfml-window target +csfml_add_library(csfml-window + SOURCES ${SRC} + DEPENDS ${SFML_WINDOW_LIBRARY} ${SFML_SYSTEM_LIBRARY}) diff --git a/src/SFML/Window/Context.cpp b/src/SFML/Window/Context.cpp new file mode 100644 index 0000000..27e5841 --- /dev/null +++ b/src/SFML/Window/Context.cpp @@ -0,0 +1,57 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new context +//////////////////////////////////////////////////////////// +sfContext* sfContext_Create(void) +{ + return new sfContext; +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing context +//////////////////////////////////////////////////////////// +void sfContext_Destroy(sfContext* context) +{ + delete context; +} + + +//////////////////////////////////////////////////////////// +/// Activate or deactivate a context +//////////////////////////////////////////////////////////// +void sfContext_SetActive(sfContext* context, sfBool active) +{ + CSFML_CALL(context, SetActive(active == sfTrue)) +} diff --git a/src/SFML/Window/ContextStruct.h b/src/SFML/Window/ContextStruct.h new file mode 100644 index 0000000..3b67061 --- /dev/null +++ b/src/SFML/Window/ContextStruct.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_CONTEXTSTRUCT_H +#define SFML_CONTEXTSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfContext +//////////////////////////////////////////////////////////// +struct sfContext +{ + sf::Context This; +}; + + +#endif // SFML_CONTEXTSTRUCT_H diff --git a/src/SFML/Window/Joystick.cpp b/src/SFML/Window/Joystick.cpp new file mode 100644 index 0000000..cc60c4c --- /dev/null +++ b/src/SFML/Window/Joystick.cpp @@ -0,0 +1,84 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Check if a joystick is connected +//////////////////////////////////////////////////////////// +sfBool sfJoystick_IsConnected(unsigned int joystick) +{ + return sf::Joystick::IsConnected(joystick) ? sfTrue : sfFalse; +} + + +//////////////////////////////////////////////////////////// +/// Return the number of buttons supported by a joystick +//////////////////////////////////////////////////////////// +unsigned int sfJoystick_GetButtonCount(unsigned int joystick) +{ + return sf::Joystick::GetButtonCount(joystick); +} + + +//////////////////////////////////////////////////////////// +/// Check if a joystick supports a given axis +//////////////////////////////////////////////////////////// +sfBool sfJoystick_HasAxis(unsigned int joystick, sfJoystickAxis axis) +{ + return sf::Joystick::HasAxis(joystick, static_cast(axis)) ? sfTrue : sfFalse; +} + + +//////////////////////////////////////////////////////////// +/// Check if a joystick button is pressed +//////////////////////////////////////////////////////////// +sfBool sfJoystick_IsButtonPressed(unsigned int joystick, unsigned int button) +{ + return sf::Joystick::IsButtonPressed(joystick, button) ? sfTrue : sfFalse; +} + + +//////////////////////////////////////////////////////////// +/// Get the current position of a joystick axis +//////////////////////////////////////////////////////////// +float sfJoystick_GetAxisPosition(unsigned int joystick, sfJoystickAxis axis) +{ + return sf::Joystick::GetAxisPosition(joystick, static_cast(axis)); +} + + +//////////////////////////////////////////////////////////// +/// Update the states of all joysticks +//////////////////////////////////////////////////////////// +void sfJoystick_Update(void) +{ + sf::Joystick::Update(); +} diff --git a/src/SFML/Window/Keyboard.cpp b/src/SFML/Window/Keyboard.cpp new file mode 100644 index 0000000..190c118 --- /dev/null +++ b/src/SFML/Window/Keyboard.cpp @@ -0,0 +1,39 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Check if a key is pressed +//////////////////////////////////////////////////////////// +sfBool sfKeyboard_IsKeyPressed(sfKeyCode key) +{ + return sf::Keyboard::IsKeyPressed(static_cast(key)); +} diff --git a/src/SFML/Window/Mouse.cpp b/src/SFML/Window/Mouse.cpp new file mode 100644 index 0000000..ac0a266 --- /dev/null +++ b/src/SFML/Window/Mouse.cpp @@ -0,0 +1,53 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Check if a mouse button is pressed +//////////////////////////////////////////////////////////// +sfBool sfMouse_IsButtonPressed(sfMouseButton button) +{ + return sf::Mouse::IsButtonPressed(static_cast(button)) ? sfTrue : sfFalse; +} + + +//////////////////////////////////////////////////////////// +/// Get the current position of the mouse +//////////////////////////////////////////////////////////// +void sfMouse_GetPosition(int* x, int* y) +{ + sf::Vector2i position = sf::Mouse::GetPosition(); + + if (x) + *x = position.x; + if (y) + *y = position.y; +} diff --git a/src/SFML/Window/VideoMode.cpp b/src/SFML/Window/VideoMode.cpp new file mode 100644 index 0000000..a213a94 --- /dev/null +++ b/src/SFML/Window/VideoMode.cpp @@ -0,0 +1,84 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Get the current desktop video mode +//////////////////////////////////////////////////////////// +sfVideoMode sfVideoMode_GetDesktopMode(void) +{ + sf::VideoMode desktop = sf::VideoMode::GetDesktopMode(); + sfVideoMode ret; + ret.Width = desktop.Width; + ret.Height = desktop.Height; + ret.BitsPerPixel = desktop.BitsPerPixel; + + return ret; +} + + +//////////////////////////////////////////////////////////// +/// Get all the supported video modes for fullscreen mode. +/// Modes are sorted from best to worst. +//////////////////////////////////////////////////////////// +const sfVideoMode* sfVideoMode_GetFullscreenModes(size_t* Count) +{ + static std::vector modes; + + // Populate the array on first call + if (modes.empty()) + { + const std::vector& SFMLModes = sf::VideoMode::GetFullscreenModes(); + for (std::vector::const_iterator it = SFMLModes.begin(); it != SFMLModes.end(); ++it) + { + sfVideoMode mode; + mode.Width = it->Width; + mode.Height = it->Height; + mode.BitsPerPixel = it->BitsPerPixel; + modes.push_back(mode); + } + } + + if (Count) + *Count = modes.size(); + + return !modes.empty() ? &modes[0] : NULL; +} + + +//////////////////////////////////////////////////////////// +/// Tell whether or not a video mode is supported +//////////////////////////////////////////////////////////// +sfBool sfVideoMode_IsValid(sfVideoMode mode) +{ + sf::VideoMode videoMode(mode.Width, mode.Height, mode.BitsPerPixel); + return videoMode.IsValid() ? sfTrue : sfFalse; +} diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp new file mode 100644 index 0000000..1226982 --- /dev/null +++ b/src/SFML/Window/Window.cpp @@ -0,0 +1,346 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// Construct a new window +//////////////////////////////////////////////////////////// +sfWindow* sfWindow_Create(sfVideoMode mode, const char* title, unsigned long style, const sfContextSettings* settings) +{ + // Convert video mode + sf::VideoMode videoMode(mode.Width, mode.Height, mode.BitsPerPixel); + + // Convert context settings + sf::ContextSettings params; + if (settings) + { + params.DepthBits = settings->DepthBits; + params.StencilBits = settings->StencilBits; + params.AntialiasingLevel = settings->AntialiasingLevel; + params.MajorVersion = settings->MajorVersion; + params.MinorVersion = settings->MinorVersion; + } + + // Create the window + sfWindow* window = new sfWindow; + window->This.Create(videoMode, title, style, params); + + return window; +} + + +//////////////////////////////////////////////////////////// +/// Construct a window from an existing control +//////////////////////////////////////////////////////////// +sfWindow* sfWindow_CreateFromHandle(sfWindowHandle handle, const sfContextSettings* settings) +{ + // Convert context settings + sf::ContextSettings params; + if (settings) + { + params.DepthBits = settings->DepthBits; + params.StencilBits = settings->StencilBits; + params.AntialiasingLevel = settings->AntialiasingLevel; + params.MajorVersion = settings->MajorVersion; + params.MinorVersion = settings->MinorVersion; + } + + // Create the window + sfWindow* window = new sfWindow; + window->This.Create(handle, params); + + return window; +} + + +//////////////////////////////////////////////////////////// +/// Destroy an existing window +//////////////////////////////////////////////////////////// +void sfWindow_Destroy(sfWindow* window) +{ + delete window; +} + +//////////////////////////////////////////////////////////// +/// Close a window (but doesn't destroy the internal data) +//////////////////////////////////////////////////////////// +void sfWindow_Close(sfWindow* window) +{ + CSFML_CALL(window, Close()); +} + + +//////////////////////////////////////////////////////////// +/// Tell whether or not a window is opened +//////////////////////////////////////////////////////////// +sfBool sfWindow_IsOpened(const sfWindow* window) +{ + CSFML_CALL_RETURN(window, IsOpened(), sfFalse); +} + + +//////////////////////////////////////////////////////////// +/// Get the width of the rendering region of a window +//////////////////////////////////////////////////////////// +unsigned int sfWindow_GetWidth(const sfWindow* window) +{ + CSFML_CALL_RETURN(window, GetWidth(), 0) +} + + +//////////////////////////////////////////////////////////// +/// Get the height of the rendering region of a window +//////////////////////////////////////////////////////////// +unsigned int sfWindow_GetHeight(const sfWindow* window) +{ + CSFML_CALL_RETURN(window, GetHeight(), 0) +} + + +//////////////////////////////////////////////////////////// +/// Get the creation settings of a window +//////////////////////////////////////////////////////////// +sfContextSettings sfWindow_GetSettings(const sfWindow* window) +{ + sfContextSettings settings = {0, 0, 0, 0, 0}; + CSFML_CHECK_RETURN(window, settings); + + const sf::ContextSettings& params = window->This.GetSettings(); + settings.DepthBits = params.DepthBits; + settings.StencilBits = params.StencilBits; + settings.AntialiasingLevel = params.AntialiasingLevel; + settings.MajorVersion = params.MajorVersion; + settings.MinorVersion = params.MinorVersion; + + return settings; +} + + +//////////////////////////////////////////////////////////// +/// Get the event on top of events stack of a window, if any, and pop it +//////////////////////////////////////////////////////////// +sfBool sfWindow_PollEvent(sfWindow* window, sfEvent* event) +{ + CSFML_CHECK_RETURN(window, sfFalse); + CSFML_CHECK_RETURN(event, sfFalse); + + // Get the event + sf::Event SFMLEvent; + sfBool ret = window->This.PollEvent(SFMLEvent); + + // No event, return + if (!ret) + return sfFalse; + + // Convert the sf::Event event to a sfEvent + ConvertEvent(SFMLEvent, event); + + return sfTrue; +} + + +//////////////////////////////////////////////////////////// +/// Wait for an event and return it +//////////////////////////////////////////////////////////// +sfBool sfWindow_WaitEvent(sfWindow* window, sfEvent* event) +{ + CSFML_CHECK_RETURN(window, sfFalse); + CSFML_CHECK_RETURN(event, sfFalse); + + // Get the event + sf::Event SFMLEvent; + sfBool ret = window->This.WaitEvent(SFMLEvent); + + // Error, return + if (!ret) + return sfFalse; + + // Convert the sf::Event event to a sfEvent + ConvertEvent(SFMLEvent, event); + + return sfTrue; +} + + +//////////////////////////////////////////////////////////// +/// Enable / disable vertical synchronization on a window +//////////////////////////////////////////////////////////// +void sfWindow_EnableVerticalSync(sfWindow* window, sfBool enabled) +{ + CSFML_CALL(window, EnableVerticalSync(enabled == sfTrue)) +} + + +//////////////////////////////////////////////////////////// +/// Show or hide the mouse cursor on a window +//////////////////////////////////////////////////////////// +void sfWindow_ShowMouseCursor(sfWindow* window, sfBool show) +{ + CSFML_CALL(window, ShowMouseCursor(show == sfTrue)) +} + + +//////////////////////////////////////////////////////////// +/// Change the position of the mouse cursor on a window +//////////////////////////////////////////////////////////// +void sfWindow_SetCursorPosition(sfWindow* window, unsigned int left, unsigned int top) +{ + CSFML_CALL(window, SetCursorPosition(left, top)) +} + + +//////////////////////////////////////////////////////////// +/// Get the position of the mouse cursor on a window +//////////////////////////////////////////////////////////// +void sfWindow_GetCursorPosition(sfWindow* window, int* left, int* top) +{ + CSFML_CHECK(window); + sf::Vector2i position = window->This.GetCursorPosition(); + + if (left) + *left = position.x; + if (top) + *top = position.y; +} + + +//////////////////////////////////////////////////////////// +/// Change the position of a window on screen. +/// Only works for top-level windows +//////////////////////////////////////////////////////////// +void sfWindow_SetPosition(sfWindow* window, int left, int top) +{ + CSFML_CALL(window, SetPosition(left, top)) +} + + +//////////////////////////////////////////////////////////// +/// Change the size of the rendering region of a window +//////////////////////////////////////////////////////////// +void sfWindow_SetSize(sfWindow* window, unsigned int width, unsigned int height) +{ + CSFML_CALL(window, SetSize(width, height)) +} + + +//////////////////////////////////////////////////////////// +/// Change the title of a window +//////////////////////////////////////////////////////////// +void sfWindow_SetTitle(sfWindow* window, const char* title) +{ + CSFML_CALL(window, SetTitle(title)) +} + + +//////////////////////////////////////////////////////////// +/// Show or hide a window +//////////////////////////////////////////////////////////// +void sfWindow_Show(sfWindow* window, sfBool show) +{ + CSFML_CALL(window, Show(show == sfTrue)) +} + + +//////////////////////////////////////////////////////////// +/// Enable or disable automatic key-repeat for keydown events. +/// Automatic key-repeat is enabled by default +//////////////////////////////////////////////////////////// +void sfWindow_EnableKeyRepeat(sfWindow* window, sfBool enabled) +{ + CSFML_CALL(window, EnableKeyRepeat(enabled == sfTrue)) +} + + +//////////////////////////////////////////////////////////// +/// Change the window's icon +//////////////////////////////////////////////////////////// +void sfWindow_SetIcon(sfWindow* window, unsigned int width, unsigned int height, const sfUint8* pixels) +{ + CSFML_CALL(window, SetIcon(width, height, pixels)) +} + + +//////////////////////////////////////////////////////////// +/// Activate or deactivate a window as the current target for rendering +//////////////////////////////////////////////////////////// +sfBool sfWindow_SetActive(sfWindow* window, sfBool active) +{ + CSFML_CALL_RETURN(window, SetActive(active == sfTrue), sfFalse) +} + + +//////////////////////////////////////////////////////////// +/// Display a window on screen +//////////////////////////////////////////////////////////// +void sfWindow_Display(sfWindow* window) +{ + CSFML_CALL(window, Display()) +} + + +//////////////////////////////////////////////////////////// +/// Limit the framerate to a maximum fixed frequency for a window +//////////////////////////////////////////////////////////// +void sfWindow_SetFramerateLimit(sfWindow* window, unsigned int limit) +{ + CSFML_CALL(window, SetFramerateLimit(limit)) +} + + +//////////////////////////////////////////////////////////// +/// Get time elapsed since last frame of a window +//////////////////////////////////////////////////////////// +sfUint32 sfWindow_GetFrameTime(const sfWindow* window) +{ + CSFML_CALL_RETURN(window, GetFrameTime(), 0) +} + + +//////////////////////////////////////////////////////////// +/// Change the joystick threshold, ie. the value below which +/// no move event will be generated +//////////////////////////////////////////////////////////// +void sfWindow_SetJoystickThreshold(sfWindow* window, float threshold) +{ + CSFML_CALL(window, SetJoystickThreshold(threshold)) +} + + +//////////////////////////////////////////////////////////// +/// Retrieve the Os-specific handle of a window +//////////////////////////////////////////////////////////// +sfWindowHandle sfWindow_GetSystemHandle(const sfWindow* window) +{ + CSFML_CHECK_RETURN(window, NULL); + + return (sfWindowHandle)window->This.GetSystemHandle(); +} diff --git a/src/SFML/Window/WindowStruct.h b/src/SFML/Window/WindowStruct.h new file mode 100644 index 0000000..428a572 --- /dev/null +++ b/src/SFML/Window/WindowStruct.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_WINDOWSTRUCT_H +#define SFML_WINDOWSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfWindow +//////////////////////////////////////////////////////////// +struct sfWindow +{ + sf::Window This; +}; + + +#endif // SFML_WINDOWSTRUCT_H