Compare commits
15 Commits
2397fcdc6c
...
61a5e88068
Author | SHA1 | Date | |
---|---|---|---|
61a5e88068 | |||
824966e951 | |||
ec5afc0477 | |||
399714353c | |||
e8322442d4 | |||
248e314644 | |||
e33445b4e2 | |||
0b521a3a63 | |||
cb648b2e20 | |||
a08a18424a | |||
b05e22b110 | |||
4314254c04 | |||
9ffb3c116a | |||
b8a0410d25 | |||
6dc659a4e2 |
@ -44,21 +44,28 @@ endif()
|
||||
include_directories("${GLFW3_INCLUDE_DIR}")
|
||||
target_link_libraries(${PROJECT_NAME} "${GLFW3_LIBRARY}")
|
||||
|
||||
if(UNIX AND NOT APPLE) # linux
|
||||
if(NOT ALSA_INCLUDE_DIRS OR NOT ALSA_LIBRARIES)
|
||||
find_package(ALSA REQUIRED)
|
||||
endif()
|
||||
include_directories("${ALSA_INCLUDE_DIRS}")
|
||||
target_link_libraries(${PROJECT_NAME} "${ALSA_LIBRARIES}")
|
||||
if(NOT OPENAL_INCLUDE_DIR OR NOT OPENAL_LIBRARY)
|
||||
find_package(OpenAL REQUIRED)
|
||||
endif()
|
||||
include_directories("${OPENAL_INCLUDE_DIR}")
|
||||
target_link_libraries(${PROJECT_NAME} "${OPENAL_LIBRARY}")
|
||||
|
||||
if(NOT OGG_INCLUDE_DIR OR NOT OGG_LIBRARY OR NOT VORBIS_INCLUDE_DIR OR NOT VORBIS_LIBRARY)
|
||||
find_package(OggVorbis REQUIRED)
|
||||
endif()
|
||||
include_directories("${OGG_INCLUDE_DIR}")
|
||||
include_directories("${VORBIS_INCLUDE_DIR}")
|
||||
target_link_libraries(${PROJECT_NAME} "${VORBIS_LIBRARY}")
|
||||
target_link_libraries(${PROJECT_NAME} "${OGG_LIBRARY}")
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(${PROJECT_NAME} "ws2_32")
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
target_link_libraries(${PROJECT_NAME} "dl")
|
||||
endif()
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} "${CMAKE_THREAD_LIBS_INIT}")
|
||||
|
||||
# Temporary until we use OggVorbis
|
||||
target_link_libraries(${PROJECT_NAME} "sndfile")
|
||||
target_link_libraries(${PROJECT_NAME} "openal")
|
||||
|
186
cmake/FindOggVorbis.cmake
Normal file
186
cmake/FindOggVorbis.cmake
Normal file
@ -0,0 +1,186 @@
|
||||
# Taken from https://github.com/sidch/CMake/blob/main/Modules/FindOggVorbis.cmake
|
||||
# - Try to find the OggVorbis libraries
|
||||
# Once done this will define
|
||||
#
|
||||
# OGGVORBIS_FOUND - system has OggVorbis (i.e. it has the Ogg and Vorbis headers, as well as libogg and libvorbis)
|
||||
# OGGVORBIS_VERSION - set either to 1 or 2
|
||||
# OGGVORBIS_INCLUDE_DIRS - the Ogg and Vorbis include directories
|
||||
# OGG_INCLUDE_DIR - the Ogg include directory
|
||||
# VORBIS_INCLUDE_DIR - the Vorbis include directory
|
||||
# OGGVORBIS_LIBRARIES - The libraries needed to use OggVorbis
|
||||
# OGG_LIBRARY - The Ogg library
|
||||
# VORBIS_LIBRARY - The Vorbis library
|
||||
# VORBISFILE_LIBRARY - The VorbisFile library (optional)
|
||||
# VORBISENC_LIBRARY - The VorbisEnc library (optional)
|
||||
#
|
||||
# To specify an additional directory to search for Ogg, set Ogg_ROOT.
|
||||
# To specify an additional directory to search for Vorbis, set Vorbis_ROOT.
|
||||
#
|
||||
# Copyright (c) 2006, Richard Laerkaeng, <richard@goteborg.utfors.se>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
# (Copied and slightly modified from the KDE project)
|
||||
#
|
||||
|
||||
INCLUDE(CheckLibraryExists)
|
||||
|
||||
FIND_PATH(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h PATHS ${Vorbis_ROOT} ${Vorbis_ROOT}/include NO_DEFAULT_PATH)
|
||||
IF(NOT VORBIS_INCLUDE_DIR)
|
||||
FIND_PATH(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
|
||||
ENDIF(NOT VORBIS_INCLUDE_DIR)
|
||||
|
||||
FIND_PATH(OGG_INCLUDE_DIR ogg/ogg.h PATHS ${Ogg_ROOT} ${Ogg_ROOT}/include NO_DEFAULT_PATH)
|
||||
IF(NOT OGG_INCLUDE_DIR)
|
||||
FIND_PATH(OGG_INCLUDE_DIR ogg/ogg.h)
|
||||
ENDIF(NOT OGG_INCLUDE_DIR)
|
||||
|
||||
# Debug libraries
|
||||
FIND_LIBRARY(OGG_DEBUG_LIBRARY NAMES oggd ogg_d liboggd libogg_d PATH_SUFFIXES "" Debug
|
||||
PATHS ${Ogg_ROOT} ${Ogg_ROOT}/lib NO_DEFAULT_PATH)
|
||||
IF(NOT OGG_DEBUG_LIBRARY) # now look in system locations
|
||||
FIND_LIBRARY(OGG_DEBUG_LIBRARY NAMES oggd ogg_d liboggd libogg_d PATH_SUFFIXES "" Debug)
|
||||
ENDIF(NOT OGG_DEBUG_LIBRARY)
|
||||
|
||||
FIND_LIBRARY(VORBIS_DEBUG_LIBRARY NAMES vorbisd vorbis_d libvorbisd libvorbis_d PATH_SUFFIXES "" Debug
|
||||
PATHS ${Vorbis_ROOT} ${Vorbis_ROOT}/lib NO_DEFAULT_PATH)
|
||||
IF(NOT VORBIS_DEBUG_LIBRARY) # now look in system locations
|
||||
FIND_LIBRARY(VORBIS_DEBUG_LIBRARY NAMES vorbisd vorbis_d libvorbisd libvorbis_d PATH_SUFFIXES "" Debug)
|
||||
ENDIF(NOT VORBIS_DEBUG_LIBRARY)
|
||||
|
||||
FIND_LIBRARY(VORBISFILE_DEBUG_LIBRARY NAMES vorbisfiled vorbisfile_d libvorbisfiled libvorbisfile_d PATH_SUFFIXES "" Debug
|
||||
PATHS ${Vorbis_ROOT} ${Vorbis_ROOT}/lib NO_DEFAULT_PATH)
|
||||
IF(NOT VORBISFILE_DEBUG_LIBRARY) # now look in system locations
|
||||
FIND_LIBRARY(VORBISFILE_DEBUG_LIBRARY NAMES vorbisfiled vorbisfile_d libvorbisfiled libvorbisfile_d PATH_SUFFIXES "" Debug)
|
||||
ENDIF(NOT VORBISFILE_DEBUG_LIBRARY)
|
||||
|
||||
FIND_LIBRARY(VORBISENC_DEBUG_LIBRARY NAMES vorbisencd vorbisenc_d libvorbisencd libvorbisenc_d PATH_SUFFIXES "" Debug
|
||||
PATHS ${Vorbis_ROOT} ${Vorbis_ROOT}/lib NO_DEFAULT_PATH)
|
||||
IF(NOT VORBISENC_DEBUG_LIBRARY) # now look in system locations
|
||||
FIND_LIBRARY(VORBISENC_DEBUG_LIBRARY NAMES vorbisencd vorbisenc_d libvorbisencd libvorbisenc_d PATH_SUFFIXES "" Debug)
|
||||
ENDIF(NOT VORBISENC_DEBUG_LIBRARY)
|
||||
|
||||
|
||||
# Release libraries
|
||||
FIND_LIBRARY(OGG_RELEASE_LIBRARY NAMES ogg libogg PATH_SUFFIXES "" Release
|
||||
PATHS ${Ogg_ROOT} ${Ogg_ROOT}/lib NO_DEFAULT_PATH)
|
||||
IF(NOT OGG_RELEASE_LIBRARY) # now look in system locations
|
||||
FIND_LIBRARY(OGG_RELEASE_LIBRARY NAMES ogg libogg PATH_SUFFIXES "" Release)
|
||||
ENDIF(NOT OGG_RELEASE_LIBRARY)
|
||||
|
||||
FIND_LIBRARY(VORBIS_RELEASE_LIBRARY NAMES vorbis libvorbis PATH_SUFFIXES "" Release
|
||||
PATHS ${Vorbis_ROOT} ${Vorbis_ROOT}/lib NO_DEFAULT_PATH)
|
||||
IF(NOT VORBIS_RELEASE_LIBRARY) # now look in system locations
|
||||
FIND_LIBRARY(VORBIS_RELEASE_LIBRARY NAMES vorbis libvorbis PATH_SUFFIXES "" Release)
|
||||
ENDIF(NOT VORBIS_RELEASE_LIBRARY)
|
||||
|
||||
FIND_LIBRARY(VORBISFILE_RELEASE_LIBRARY NAMES vorbisfile libvorbisfile PATH_SUFFIXES "" Release
|
||||
PATHS ${Vorbis_ROOT} ${Vorbis_ROOT}/lib NO_DEFAULT_PATH)
|
||||
IF(NOT VORBISFILE_RELEASE_LIBRARY) # now look in system locations
|
||||
FIND_LIBRARY(VORBISFILE_RELEASE_LIBRARY NAMES vorbisfile libvorbisfile PATH_SUFFIXES "" Release)
|
||||
ENDIF(NOT VORBISFILE_RELEASE_LIBRARY)
|
||||
|
||||
FIND_LIBRARY(VORBISENC_RELEASE_LIBRARY NAMES vorbisenc libvorbisenc PATH_SUFFIXES "" Release
|
||||
PATHS ${Vorbis_ROOT} ${Vorbis_ROOT}/lib NO_DEFAULT_PATH)
|
||||
IF(NOT VORBISENC_RELEASE_LIBRARY) # now look in system locations
|
||||
FIND_LIBRARY(VORBISENC_RELEASE_LIBRARY NAMES vorbisenc libvorbisenc PATH_SUFFIXES "" Release)
|
||||
ENDIF(NOT VORBISENC_RELEASE_LIBRARY)
|
||||
|
||||
|
||||
SET(OGG_LIBRARY)
|
||||
IF(OGG_DEBUG_LIBRARY AND OGG_RELEASE_LIBRARY)
|
||||
SET(OGG_LIBRARY debug ${OGG_DEBUG_LIBRARY} optimized ${OGG_RELEASE_LIBRARY})
|
||||
ELSEIF(OGG_DEBUG_LIBRARY)
|
||||
SET(OGG_LIBRARY ${OGG_DEBUG_LIBRARY})
|
||||
ELSEIF(OGG_RELEASE_LIBRARY)
|
||||
SET(OGG_LIBRARY ${OGG_RELEASE_LIBRARY})
|
||||
ENDIF(OGG_DEBUG_LIBRARY AND OGG_RELEASE_LIBRARY)
|
||||
|
||||
SET(VORBIS_LIBRARY)
|
||||
IF(VORBIS_DEBUG_LIBRARY AND VORBIS_RELEASE_LIBRARY)
|
||||
SET(VORBIS_LIBRARY debug ${VORBIS_DEBUG_LIBRARY} optimized ${VORBIS_RELEASE_LIBRARY})
|
||||
ELSEIF(VORBIS_DEBUG_LIBRARY)
|
||||
SET(VORBIS_LIBRARY ${VORBIS_DEBUG_LIBRARY})
|
||||
ELSEIF(VORBIS_RELEASE_LIBRARY)
|
||||
SET(VORBIS_LIBRARY ${VORBIS_RELEASE_LIBRARY})
|
||||
ENDIF(VORBIS_DEBUG_LIBRARY AND VORBIS_RELEASE_LIBRARY)
|
||||
|
||||
SET(VORBISFILE_LIBRARY)
|
||||
IF(VORBISFILE_DEBUG_LIBRARY AND VORBISFILE_RELEASE_LIBRARY)
|
||||
SET(VORBISFILE_LIBRARY debug ${VORBISFILE_DEBUG_LIBRARY} optimized ${VORBISFILE_RELEASE_LIBRARY})
|
||||
ELSEIF(VORBISFILE_DEBUG_LIBRARY)
|
||||
SET(VORBISFILE_LIBRARY ${VORBISFILE_DEBUG_LIBRARY})
|
||||
ELSEIF(VORBISFILE_RELEASE_LIBRARY)
|
||||
SET(VORBISFILE_LIBRARY ${VORBISFILE_RELEASE_LIBRARY})
|
||||
ENDIF(VORBISFILE_DEBUG_LIBRARY AND VORBISFILE_RELEASE_LIBRARY)
|
||||
|
||||
SET(VORBISENC_LIBRARY)
|
||||
IF(VORBISENC_DEBUG_LIBRARY AND VORBISENC_RELEASE_LIBRARY)
|
||||
SET(VORBISENC_LIBRARY debug ${VORBISENC_DEBUG_LIBRARY} optimized ${VORBISENC_RELEASE_LIBRARY})
|
||||
ELSEIF(VORBISENC_DEBUG_LIBRARY)
|
||||
SET(VORBISENC_LIBRARY ${VORBISENC_DEBUG_LIBRARY})
|
||||
ELSEIF(VORBISENC_RELEASE_LIBRARY)
|
||||
SET(VORBISENC_LIBRARY ${VORBISENC_RELEASE_LIBRARY})
|
||||
ENDIF(VORBISENC_DEBUG_LIBRARY AND VORBISENC_RELEASE_LIBRARY)
|
||||
|
||||
# Should the check also test for the OGG... variables?
|
||||
IF(OGG_INCLUDE_DIR AND VORBIS_INCLUDE_DIR AND OGG_LIBRARY AND VORBIS_LIBRARY)
|
||||
SET(OGGVORBIS_FOUND TRUE)
|
||||
|
||||
SET(OGGVORBIS_INCLUDE_DIRS ${OGG_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR})
|
||||
SET(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBISENC_LIBRARY})
|
||||
|
||||
IF(NOT WIN32) # not quite sure what to do on Windows yet
|
||||
SET(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES})
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OGGVORBIS_LIBRARIES})
|
||||
CHECK_LIBRARY_EXISTS(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP})
|
||||
|
||||
IF(HAVE_LIBVORBISENC2)
|
||||
SET(OGGVORBIS_VERSION 2)
|
||||
ELSE(HAVE_LIBVORBISENC2)
|
||||
SET(OGGVORBIS_VERSION 1)
|
||||
ENDIF(HAVE_LIBVORBISENC2)
|
||||
ENDIF(NOT WIN32)
|
||||
|
||||
ELSE(OGG_INCLUDE_DIR AND VORBIS_INCLUDE_DIR AND OGG_LIBRARY AND VORBIS_LIBRARY)
|
||||
SET(OGGVORBIS_VERSION)
|
||||
SET(OGGVORBIS_FOUND FALSE)
|
||||
ENDIF(OGG_INCLUDE_DIR AND VORBIS_INCLUDE_DIR AND OGG_LIBRARY AND VORBIS_LIBRARY)
|
||||
|
||||
|
||||
IF(OGGVORBIS_FOUND)
|
||||
IF(NOT OggVorbis_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}")
|
||||
ENDIF(NOT OggVorbis_FIND_QUIETLY)
|
||||
ELSE(OGGVORBIS_FOUND)
|
||||
IF(OggVorbis_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find OggVorbis libraries")
|
||||
ENDIF(OggVorbis_FIND_REQUIRED)
|
||||
IF(NOT OggVorbis_FIND_QUITELY)
|
||||
MESSAGE(STATUS "Could not find OggVorbis libraries")
|
||||
ENDIF(NOT OggVorbis_FIND_QUITELY)
|
||||
ENDIF(OGGVORBIS_FOUND)
|
||||
|
||||
#CHECK_INCLUDE_FILES(vorbis/vorbisfile.h HAVE_VORBISFILE_H)
|
||||
#CHECK_LIBRARY_EXISTS(ogg ogg_page_version "" HAVE_LIBOGG)
|
||||
#CHECK_LIBRARY_EXISTS(vorbis vorbis_info_init "" HAVE_LIBVORBIS)
|
||||
#CHECK_LIBRARY_EXISTS(vorbisfile ov_open "" HAVE_LIBVORBISFILE)
|
||||
#CHECK_LIBRARY_EXISTS(vorbisenc vorbis_info_clear "" HAVE_LIBVORBISENC)
|
||||
#CHECK_LIBRARY_EXISTS(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
|
||||
|
||||
#IF(HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)
|
||||
# MESSAGE(STATUS "Ogg/Vorbis found")
|
||||
# SET(VORBIS_LIBS "-lvorbis -logg")
|
||||
# SET(VORBISFILE_LIBS "-lvorbisfile")
|
||||
# SET(VORBISENC_LIBS "-lvorbisenc")
|
||||
# SET(OGGVORBIS_FOUND TRUE)
|
||||
# IF(HAVE_LIBVORBISENC2)
|
||||
# SET(HAVE_VORBIS 2)
|
||||
# ELSE(HAVE_LIBVORBISENC2)
|
||||
# SET(HAVE_VORBIS 1)
|
||||
# ENDIF(HAVE_LIBVORBISENC2)
|
||||
#ELSE(HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)
|
||||
# MESSAGE(STATUS "Ogg/Vorbis not found")
|
||||
#ENDIF(HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)
|
@ -1,2 +1,26 @@
|
||||
/*
|
||||
PolyGun
|
||||
|
||||
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#cmakedefine BUILD_CLIENT
|
||||
#cmakedefine BUILD_SERVER
|
||||
|
@ -3,9 +3,9 @@ out vec4 FragColor;
|
||||
|
||||
in vec2 TexCoord;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform sampler2D texture_atlas;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = texture(texture1, TexCoord);
|
||||
FragColor = texture(texture_atlas, TexCoord);
|
||||
}
|
@ -1,3 +1,27 @@
|
||||
/*
|
||||
PolyGun
|
||||
|
||||
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "common/binary_utils.hpp"
|
||||
|
||||
static bool is_little_endian(){
|
||||
|
@ -1,3 +1,27 @@
|
||||
/*
|
||||
PolyGun
|
||||
|
||||
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef POLYGUN_UTILS_BINARY_UTILS_HPP
|
||||
#define POLYGUN_UTILS_BINARY_UTILS_HPP
|
||||
|
||||
|
@ -1,3 +1,27 @@
|
||||
/*
|
||||
PolyGun
|
||||
|
||||
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "common/logger.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
|
@ -1,3 +1,27 @@
|
||||
/*
|
||||
PolyGun
|
||||
|
||||
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef POLYGUN_UTILS_LOGGER_HPP
|
||||
#define POLYGUN_UTILS_LOGGER_HPP
|
||||
|
||||
|
@ -1,3 +1,27 @@
|
||||
/*
|
||||
PolyGun
|
||||
|
||||
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef POLYGUN_NETWORK_NETWORK_ENDPOINT_HPP
|
||||
#define POLYGUN_NETWORK_NETWORK_ENDPOINT_HPP
|
||||
|
||||
|
@ -1,3 +1,27 @@
|
||||
/*
|
||||
PolyGun
|
||||
|
||||
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "common/network/network_manager.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -1,3 +1,27 @@
|
||||
/*
|
||||
PolyGun
|
||||
|
||||
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef POLYGUN_NETWORK_NETWORK_MANAGER_HPP
|
||||
#define POLYGUN_NETWORK_NETWORK_MANAGER_HPP
|
||||
|
||||
|
@ -1,3 +1,27 @@
|
||||
/*
|
||||
PolyGun
|
||||
|
||||
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "common/network/network_packet.hpp"
|
||||
|
||||
#include "common/binary_utils.hpp"
|
||||
|
@ -1,3 +1,27 @@
|
||||
/*
|
||||
PolyGun
|
||||
|
||||
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef POLYGUN_NETWORK_NETWORK_PACKET_HPP
|
||||
#define POLYGUN_NETWORK_NETWORK_PACKET_HPP
|
||||
|
||||
|
@ -1,3 +1,27 @@
|
||||
/*
|
||||
PolyGun
|
||||
|
||||
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "common/network/udp_socket.hpp"
|
||||
|
||||
#if defined(__unix__)
|
||||
|
@ -1,3 +1,27 @@
|
||||
/*
|
||||
PolyGun
|
||||
|
||||
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef POLYGUN_NETWORK_UDP_SOCKET_HPP
|
||||
#define POLYGUN_NETWORK_UDP_SOCKET_HPP
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "./audio.hpp"
|
||||
#include "../core.hpp"
|
||||
#include "game/audio/audio.hpp"
|
||||
|
||||
#include <sndfile.h>
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
|
||||
#include <AL/al.h>
|
||||
#include <AL/alc.h>
|
||||
#include "game/core.hpp"
|
||||
#include "common/logger.hpp"
|
||||
|
||||
static struct {
|
||||
ALCcontext* context;
|
||||
@ -16,22 +16,14 @@ static struct {
|
||||
|
||||
namespace polygun::audio {
|
||||
|
||||
// void configure_device(snd_pcm_t* pcm, unsigned int channels, unsigned int rate)
|
||||
// {
|
||||
// }
|
||||
|
||||
void init() {
|
||||
audio_structures.device = alcOpenDevice(0);
|
||||
if (audio_structures.device == NULL) {
|
||||
std::cout << "Couldn't open the device, audio is not initalized" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
if (audio_structures.device == NULL)
|
||||
LOG_FATAL("Couldn't open the device, audio won't be initalized");
|
||||
|
||||
audio_structures.context = alcCreateContext(audio_structures.device, 0);
|
||||
if (!alcMakeContextCurrent(audio_structures.context)) {
|
||||
std::cout << "Couldn't make the context current, audio is not initalized" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
if (!alcMakeContextCurrent(audio_structures.context))
|
||||
LOG_FATAL("Couldn't make the context current, audio won't be initalized");
|
||||
|
||||
// Create main source on which everything would be played
|
||||
// TODO: create other sources for music, sound effects etc.
|
||||
@ -44,35 +36,9 @@ namespace polygun::audio {
|
||||
alSource3f(audio_structures.main_source, AL_VELOCITY, 0, 0, 0);
|
||||
}
|
||||
|
||||
void _play_sound_thread(std::string filename) {
|
||||
|
||||
}
|
||||
|
||||
void play_sound(std::string filename) {
|
||||
// std::thread play(_play_sound_thread, filename);
|
||||
// play.join();
|
||||
auto sfinfo = SF_INFO {};
|
||||
auto file = sf_open(filename.c_str(), SFM_READ, &sfinfo);
|
||||
|
||||
if (file == NULL) {
|
||||
std::cout << "Couldn't open the file \"" << filename << "\"" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
auto sound_buf = (short*)malloc(sfinfo.frames * sfinfo.channels * sizeof(short));
|
||||
auto frames = sf_readf_short(file, sound_buf, sfinfo.frames);
|
||||
|
||||
// configure_device(device, sfinfo.channels, sfinfo.samplerate);
|
||||
// snd_pcm_writei(device, sound_buf, frames);
|
||||
alGenBuffers(1, &audio_structures.buffer);
|
||||
alBufferData(audio_structures.buffer, sfinfo.channels == 1
|
||||
? AL_FORMAT_MONO16
|
||||
: AL_FORMAT_STEREO16,
|
||||
sound_buf, frames * sfinfo.channels * sizeof(short),
|
||||
sfinfo.samplerate);
|
||||
|
||||
free(sound_buf);
|
||||
sf_close(file);
|
||||
}
|
||||
|
||||
}
|
||||
void cleanup() {
|
||||
alcMakeContextCurrent(nullptr);
|
||||
alcDestroyContext(audio_structures.context);
|
||||
alcCloseDevice(audio_structures.device);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,9 @@
|
||||
#ifndef POLYGUN_AUDIO_HPP
|
||||
#define POLYGUN_AUDIO_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace polygun::audio {
|
||||
|
||||
void init();
|
||||
|
||||
void play_sound(std::string filename);
|
||||
|
||||
void cleanup();
|
||||
}
|
||||
|
||||
#endif // POLYGUN_AUDIO_HPP
|
||||
#endif // POLYGUN_AUDIO_HPP
|
||||
|
220
src/game/audio/buffer.cpp
Normal file
220
src/game/audio/buffer.cpp
Normal file
@ -0,0 +1,220 @@
|
||||
#include "game/audio/buffer.hpp"
|
||||
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
#include <ogg/ogg.h>
|
||||
#include <vorbis/codec.h>
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
|
||||
#include "common/logger.hpp"
|
||||
|
||||
using namespace polygun::audio;
|
||||
|
||||
AudioBuffer::AudioBuffer() :
|
||||
m_buffer_id(0),
|
||||
m_valid(false)
|
||||
{
|
||||
alGenBuffers(1, &m_buffer_id);
|
||||
|
||||
ALCenum error = alGetError();
|
||||
if(error!=AL_NO_ERROR) {
|
||||
LOG_ERROR("Failed to create OpenAL bufferf (OpenAL error: %d)", error);
|
||||
return;
|
||||
}
|
||||
m_valid = true;
|
||||
}
|
||||
|
||||
AudioBuffer::~AudioBuffer() {
|
||||
if(m_valid)
|
||||
alDeleteBuffers(1,&m_buffer_id);
|
||||
}
|
||||
|
||||
bool AudioBuffer::load_from_file(const std::string& filename) {
|
||||
if(!m_valid) {
|
||||
LOG_ERROR("Attempt to load sound file to invalid buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ifstream file(filename, std::ios::binary);
|
||||
if(!file.good()) {
|
||||
LOG_ERROR("Failed to open file '%s'", filename.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
char magic[4];
|
||||
file.read(magic, 4);
|
||||
bool result = false;
|
||||
if(strncmp(magic, "OggS", 4)==0) {
|
||||
result = load_ogg(file);
|
||||
if(!result)
|
||||
LOG_ERROR("Failed to load Ogg file '%s'", filename.c_str());
|
||||
}
|
||||
else
|
||||
LOG_ERROR("File '%s' has unsupported format", filename.c_str());
|
||||
|
||||
file.close();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AudioBuffer::load_ogg(std::istream& stream) {
|
||||
stream.seekg(0);
|
||||
ogg_sync_state state;
|
||||
if(ogg_sync_init(&state)!=0) {
|
||||
LOG_VERBOSE("Failed to init Ogg sync state");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool continue_reading = true;
|
||||
bool reading_vorbis_header = true;
|
||||
bool first_vorbis_header_packet = true;
|
||||
unsigned char vorbis_header_page_counter = 0;
|
||||
ogg_page page;
|
||||
vorbis_info vorb;
|
||||
vorbis_comment vorb_comment;
|
||||
std::vector<int16_t> decoded_samples;
|
||||
vorbis_dsp_state dsp;
|
||||
vorbis_block block;
|
||||
std::map<int, ogg_stream_state> ogg_streams;
|
||||
while(continue_reading) {
|
||||
while(ogg_sync_pageout(&state, &page)==0) {
|
||||
char* sync_buffer = ogg_sync_buffer(&state, 4096);
|
||||
if(!sync_buffer) {
|
||||
LOG_VERBOSE("Failed to obtain Ogg buffer");
|
||||
ogg_sync_clear(&state);
|
||||
return false;
|
||||
}
|
||||
stream.read(sync_buffer, 4096);
|
||||
std::streamsize bytes_read = stream.gcount();
|
||||
if(bytes_read==0) {
|
||||
continue_reading = false;
|
||||
break;
|
||||
}
|
||||
if(bytes_read>0)
|
||||
ogg_sync_wrote(&state, bytes_read);
|
||||
}
|
||||
if(!continue_reading)
|
||||
break;
|
||||
|
||||
int page_serialno = ogg_page_serialno(&page);
|
||||
ogg_stream_state* ogg_stream = &ogg_streams[page_serialno];
|
||||
if(ogg_page_bos(&page)) {
|
||||
if(ogg_stream_init(ogg_stream, page_serialno)!=0) {
|
||||
LOG_VERBOSE("Failed to init Ogg stream");
|
||||
ogg_sync_clear(&state);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(ogg_stream_pagein(ogg_stream, &page)==-1) {
|
||||
LOG_VERBOSE("Failed to supply page to Ogg stream");
|
||||
ogg_stream_clear(ogg_stream);
|
||||
ogg_sync_clear(&state);
|
||||
return false;
|
||||
}
|
||||
|
||||
ogg_packet packet;
|
||||
if(reading_vorbis_header) {
|
||||
if(ogg_stream_packetout(ogg_stream, &packet)!=1) {
|
||||
LOG_VERBOSE("Failed to obtain packet from Ogg stream");
|
||||
ogg_sync_clear(&state);
|
||||
return false;
|
||||
}
|
||||
if(first_vorbis_header_packet) {
|
||||
if(!vorbis_synthesis_idheader(&packet)) {
|
||||
LOG_VERBOSE("Ogg file doesn't contain Vorbis encoded audio");
|
||||
ogg_sync_clear(&state);
|
||||
return false;
|
||||
}
|
||||
vorbis_info_init(&vorb);
|
||||
vorbis_comment_init(&vorb_comment);
|
||||
first_vorbis_header_packet = false;
|
||||
}
|
||||
if(vorbis_synthesis_headerin(&vorb, &vorb_comment, &packet)!=0) {
|
||||
LOG_VERBOSE("Failed to supply Vorbis header part from Ogg packet");
|
||||
vorbis_info_clear(&vorb);
|
||||
vorbis_comment_clear(&vorb_comment);
|
||||
ogg_sync_clear(&state);
|
||||
return false;
|
||||
}
|
||||
vorbis_header_page_counter++;
|
||||
if(vorbis_header_page_counter==3) {
|
||||
reading_vorbis_header = false;
|
||||
if(vorbis_synthesis_init(&dsp, &vorb)!=0) {
|
||||
LOG_VERBOSE("Failed to init Vorbis synthesis");
|
||||
vorbis_info_clear(&vorb);
|
||||
vorbis_comment_clear(&vorb_comment);
|
||||
ogg_sync_clear(&state);
|
||||
return false;
|
||||
}
|
||||
if(vorbis_block_init(&dsp, &block)!=0) {
|
||||
LOG_VERBOSE("Failed to init Vorbis block");
|
||||
vorbis_dsp_clear(&dsp);
|
||||
vorbis_info_clear(&vorb);
|
||||
vorbis_comment_clear(&vorb_comment);
|
||||
ogg_sync_clear(&state);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if(ogg_stream_packetout(ogg_stream, &packet)!=1)
|
||||
continue;
|
||||
|
||||
do{
|
||||
if(vorbis_synthesis(&block, &packet)!=0) {
|
||||
LOG_VERBOSE("Failed to synthesis Ogg packet");
|
||||
vorbis_block_clear(&block);
|
||||
vorbis_dsp_clear(&dsp);
|
||||
vorbis_info_clear(&vorb);
|
||||
vorbis_comment_clear(&vorb_comment);
|
||||
ogg_sync_clear(&state);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(vorbis_synthesis_blockin(&dsp, &block)!=0) {
|
||||
LOG_VERBOSE("Failed to supply block to Vorbis synthesis");
|
||||
vorbis_block_clear(&block);
|
||||
vorbis_dsp_clear(&dsp);
|
||||
vorbis_info_clear(&vorb);
|
||||
vorbis_comment_clear(&vorb_comment);
|
||||
ogg_sync_clear(&state);
|
||||
return false;
|
||||
}
|
||||
|
||||
float** samples;
|
||||
int sample_count = vorbis_synthesis_pcmout(&dsp, &samples);
|
||||
if(sample_count>0) {
|
||||
for(int a = 0; a<sample_count; a++) {
|
||||
for(int i = 0; i<(vorb.channels>2?2:vorb.channels); i++) {
|
||||
decoded_samples.push_back(samples[i][a]*std::numeric_limits<int16_t>::max());
|
||||
}
|
||||
}
|
||||
vorbis_synthesis_read(&dsp, sample_count);
|
||||
}
|
||||
}
|
||||
while(ogg_stream_packetout(ogg_stream, &packet)==1);
|
||||
}
|
||||
|
||||
ALenum al_format = -1;
|
||||
if(vorb.channels==1)
|
||||
al_format = AL_FORMAT_MONO16;
|
||||
else if(vorb.channels>=2)
|
||||
al_format = AL_FORMAT_STEREO16;
|
||||
alBufferData(m_buffer_id, al_format, decoded_samples.data(), decoded_samples.size()*2, vorb.rate);
|
||||
ALCenum error = alGetError();
|
||||
if(error!=AL_NO_ERROR)
|
||||
LOG_ERROR("Failed to submit decoded Vorbis sound data to OpenAL buffer (OpenAL error: %d)", error);
|
||||
|
||||
vorbis_block_clear(&block);
|
||||
vorbis_info_clear(&vorb);
|
||||
vorbis_comment_clear(&vorb_comment);
|
||||
vorbis_dsp_clear(&dsp);
|
||||
for(std::map<int, ogg_stream_state>::iterator it = ogg_streams.begin(); it!=ogg_streams.end(); it++)
|
||||
ogg_stream_clear(&it->second);
|
||||
ogg_sync_clear(&state);
|
||||
return true;
|
||||
}
|
26
src/game/audio/buffer.hpp
Normal file
26
src/game/audio/buffer.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef POLYGUN_AUDIO_BUFFER_HPP
|
||||
#define POLYGUN_AUDIO_BUFFER_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace polygun::audio {
|
||||
class AudioBuffer final {
|
||||
public:
|
||||
AudioBuffer();
|
||||
~AudioBuffer();
|
||||
|
||||
bool load_from_file(const std::string& filename);
|
||||
|
||||
unsigned get_buffer_id() const { return m_buffer_id; }
|
||||
bool is_valid() const { return m_valid; }
|
||||
|
||||
private:
|
||||
unsigned m_buffer_id;
|
||||
bool m_valid;
|
||||
|
||||
private:
|
||||
bool load_ogg(std::istream& stream);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
84
src/game/audio/source.cpp
Normal file
84
src/game/audio/source.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
#include "game/audio/source.hpp"
|
||||
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
|
||||
#include "game/audio/buffer.hpp"
|
||||
#include "common/logger.hpp"
|
||||
|
||||
using namespace polygun::audio;
|
||||
|
||||
AudioSource::AudioSource() :
|
||||
m_buffer(),
|
||||
m_source_id(0),
|
||||
m_valid(false)
|
||||
{
|
||||
alGenSources(1, &m_source_id);
|
||||
ALCenum error = alGetError();
|
||||
if(error!=AL_NO_ERROR) {
|
||||
LOG_ERROR("Failed to create OpenAL source (OpenAL error: %d)", error);
|
||||
return;
|
||||
}
|
||||
m_valid = true;
|
||||
}
|
||||
|
||||
AudioSource::AudioSource(const std::shared_ptr<AudioBuffer>& buffer) :
|
||||
m_buffer(),
|
||||
m_source_id(0),
|
||||
m_valid(false)
|
||||
{
|
||||
alGenSources(1, &m_source_id);
|
||||
ALCenum error = alGetError();
|
||||
if(error!=AL_NO_ERROR) {
|
||||
LOG_ERROR("Failed to create OpenAL source (OpenAL error: %d)", error);
|
||||
return;
|
||||
}
|
||||
m_valid = true;
|
||||
set_buffer(buffer);
|
||||
}
|
||||
|
||||
AudioSource::~AudioSource() {
|
||||
if(m_valid)
|
||||
alDeleteSources(1, &m_source_id);
|
||||
}
|
||||
|
||||
void AudioSource::set_buffer(const std::shared_ptr<AudioBuffer>& buffer) {
|
||||
if(m_valid) {
|
||||
m_buffer = buffer;
|
||||
alSourcei(m_source_id, AL_BUFFER, m_buffer->get_buffer_id());
|
||||
}
|
||||
}
|
||||
|
||||
void AudioSource::set_gain(float gain) {
|
||||
if(m_valid)
|
||||
alSourcef(m_source_id, AL_GAIN, gain);
|
||||
}
|
||||
|
||||
void AudioSource::set_position(const glm::vec3& pos) {
|
||||
if(m_valid)
|
||||
alSource3f(m_source_id, AL_POSITION, pos.x, pos.y, pos.z);
|
||||
}
|
||||
|
||||
void AudioSource::set_velocity(const glm::vec3& vel) {
|
||||
if(m_valid)
|
||||
alSource3f(m_source_id, AL_VELOCITY, vel.x, vel.y, vel.z);
|
||||
}
|
||||
|
||||
void AudioSource::play(bool looping) {
|
||||
alSourcei(m_source_id, AL_LOOPING, looping);
|
||||
alSourcePlay(m_source_id);
|
||||
}
|
||||
|
||||
void AudioSource::stop() {
|
||||
alSourceStop(m_source_id);
|
||||
}
|
||||
|
||||
void AudioSource::pause() {
|
||||
alSourcePause(m_source_id);
|
||||
}
|
||||
|
||||
bool AudioSource::is_playing() const {
|
||||
int source_state;
|
||||
alGetSourcei(m_source_id, AL_SOURCE_STATE, &source_state);
|
||||
return source_state==AL_PLAYING;
|
||||
}
|
33
src/game/audio/source.hpp
Normal file
33
src/game/audio/source.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef POLYGUN_AUDIO_SOURCE_HPP
|
||||
#define POLYGUN_AUDIO_SOURCE_HPP
|
||||
|
||||
#include <memory>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace polygun::audio {
|
||||
class AudioBuffer;
|
||||
class AudioSource final {
|
||||
public:
|
||||
AudioSource();
|
||||
AudioSource(const std::shared_ptr<AudioBuffer>& buffer);
|
||||
~AudioSource();
|
||||
|
||||
void set_buffer(const std::shared_ptr<AudioBuffer>& buffer);
|
||||
AudioBuffer& get_buffer() { return *m_buffer; }
|
||||
void set_gain(float gain);
|
||||
void set_position(const glm::vec3& pos);
|
||||
void set_velocity(const glm::vec3& vel);
|
||||
|
||||
void play(bool looping = false);
|
||||
void stop();
|
||||
void pause();
|
||||
bool is_playing() const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<AudioBuffer> m_buffer;
|
||||
unsigned m_source_id;
|
||||
bool m_valid;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // POLYGUN_AUDIO_SOURCE_HPP
|
@ -1,8 +1,8 @@
|
||||
#ifndef POLYGUN_CORE_HPP
|
||||
#define POLYGUN_CORE_HPP
|
||||
|
||||
#define SCR_HEIGHT 600
|
||||
#define SCR_WIDTH 800
|
||||
#define SCR_WIDTH 1280
|
||||
#define SCR_HEIGHT 720
|
||||
|
||||
/* C++ Libraries */
|
||||
#include <set>
|
||||
|
@ -1,29 +0,0 @@
|
||||
#include "chunk.hpp"
|
||||
|
||||
namespace polygun::engine {
|
||||
Chunk::Chunk() {
|
||||
for (int x = 0; x < CHUNK_SIZE; x++) {
|
||||
for (int y = 0; y < CHUNK_SIZE; y++) {
|
||||
for (int z = 0; z < CHUNK_SIZE; z++) {
|
||||
chunk_data[x][y][z] = 0 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Chunk::~Chunk() {
|
||||
delete chunk_data;
|
||||
}
|
||||
|
||||
void Chunk::add_node(int node_to_add, glm::vec3 pos) {
|
||||
chunk_data[(int)pos.x][(int)pos.y][(int)pos.z] = node_to_add;
|
||||
}
|
||||
|
||||
bool Chunk::is_air(glm::vec3 pos) {
|
||||
return chunk_data[(int)pos.x][(int)pos.y][(int)pos.z] == 0;
|
||||
}
|
||||
|
||||
int Chunk::get_node(glm::vec3 pos) {
|
||||
return chunk_data[(int)pos.x][(int)pos.y][(int)pos.z];
|
||||
}
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
#include "chunk_renderer.hpp"
|
||||
#include "common/logger.hpp"
|
||||
|
||||
namespace polygun::engine {
|
||||
ChunkRenderer::ChunkRenderer() {
|
||||
m_chunk_shader = renderer::Shader("shaders/chunk_vertex.glsl", "shaders/chunk_fragment.glsl");
|
||||
}
|
||||
|
||||
ChunkRenderer::~ChunkRenderer() {
|
||||
glDeleteVertexArrays(1, &m_vao);
|
||||
glDeleteBuffers(1, &m_vbo);
|
||||
}
|
||||
|
||||
void ChunkRenderer::init() {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
float vertices[] = {
|
||||
-0.1f, -0.1f, -0.1f, 0.0f, 0.0f,
|
||||
0.1f, -0.1f, -0.1f, 1.0f, 0.0f,
|
||||
0.1f, 0.1f, -0.1f, 1.0f, 1.0f,
|
||||
0.1f, 0.1f, -0.1f, 1.0f, 1.0f,
|
||||
-0.1f, 0.1f, -0.1f, 0.0f, 1.0f,
|
||||
-0.1f, -0.1f, -0.1f, 0.0f, 0.0f,
|
||||
|
||||
-0.1f, -0.1f, 0.1f, 0.0f, 0.0f,
|
||||
0.1f, -0.1f, 0.1f, 1.0f, 0.0f,
|
||||
0.1f, 0.1f, 0.1f, 1.0f, 1.0f,
|
||||
0.1f, 0.1f, 0.1f, 1.0f, 1.0f,
|
||||
-0.1f, 0.1f, 0.1f, 0.0f, 1.0f,
|
||||
-0.1f, -0.1f, 0.1f, 0.0f, 0.0f,
|
||||
|
||||
-0.1f, 0.1f, 0.1f, 1.0f, 0.0f,
|
||||
-0.1f, 0.1f, -0.1f, 1.0f, 1.0f,
|
||||
-0.1f, -0.1f, -0.1f, 0.0f, 1.0f,
|
||||
-0.1f, -0.1f, -0.1f, 0.0f, 1.0f,
|
||||
-0.1f, -0.1f, 0.1f, 0.0f, 0.0f,
|
||||
-0.1f, 0.1f, 0.1f, 1.0f, 0.0f,
|
||||
|
||||
0.1f, 0.1f, 0.1f, 1.0f, 0.0f,
|
||||
0.1f, 0.1f, -0.1f, 1.0f, 1.0f,
|
||||
0.1f, -0.1f, -0.1f, 0.0f, 1.0f,
|
||||
0.1f, -0.1f, -0.1f, 0.0f, 1.0f,
|
||||
0.1f, -0.1f, 0.1f, 0.0f, 0.0f,
|
||||
0.1f, 0.1f, 0.1f, 1.0f, 0.0f,
|
||||
|
||||
-0.1f, -0.1f, -0.1f, 0.0f, 1.0f,
|
||||
0.1f, -0.1f, -0.1f, 1.0f, 1.0f,
|
||||
0.1f, -0.1f, 0.1f, 1.0f, 0.0f,
|
||||
0.1f, -0.1f, 0.1f, 1.0f, 0.0f,
|
||||
-0.1f, -0.1f, 0.1f, 0.0f, 0.0f,
|
||||
-0.1f, -0.1f, -0.1f, 0.0f, 1.0f,
|
||||
|
||||
-0.1f, 0.1f, -0.1f, 0.0f, 1.0f,
|
||||
0.1f, 0.1f, -0.1f, 1.0f, 1.0f,
|
||||
0.1f, 0.1f, 0.1f, 1.0f, 0.0f,
|
||||
0.1f, 0.1f, 0.1f, 1.0f, 0.0f,
|
||||
-0.1f, 0.1f, 0.1f, 0.0f, 0.0f,
|
||||
-0.1f, 0.1f, -0.1f, 0.0f, 1.0f
|
||||
};
|
||||
|
||||
Chunk chnk;
|
||||
|
||||
unsigned int m_vbo, m_vao;
|
||||
glGenVertexArrays(1, &m_vao);
|
||||
glGenBuffers(1, &m_vbo);
|
||||
|
||||
glBindVertexArray(m_vao);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
|
||||
|
||||
// position attribute
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0);
|
||||
glEnableVertexAttribArray(0);
|
||||
// texture coord attribute
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3 * sizeof(float)));
|
||||
glEnableVertexAttribArray(1);
|
||||
|
||||
glGenTextures(1, &m_texture1);
|
||||
glBindTexture(GL_TEXTURE_2D, m_texture1);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
int width, height, nrChannels;
|
||||
stbi_set_flip_vertically_on_load(true);
|
||||
unsigned char *data = stbi_load("res/textures/gold.png", &width, &height, &nrChannels, 0);
|
||||
if (data)
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Failed to load texture" << std::endl;
|
||||
}
|
||||
stbi_image_free(data);
|
||||
|
||||
m_chunk_shader.bind();
|
||||
m_chunk_shader.set_uniform("texture1", 0);
|
||||
}
|
||||
|
||||
void ChunkRenderer::render(glm::mat4 projection, glm::mat4 view, Chunk chunk) {
|
||||
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_texture1);
|
||||
|
||||
m_chunk_shader.bind();
|
||||
m_chunk_shader.set_uniform("projection", projection);
|
||||
m_chunk_shader.set_uniform("view", view);
|
||||
|
||||
glBindVertexArray(m_vao);
|
||||
|
||||
for (unsigned int x = 0; x < 32; x++) {
|
||||
for (unsigned int y = 0; y < 32; y++) {
|
||||
for (unsigned int z = 0; z < 32; z++) {
|
||||
if (chunk.get_node(glm::vec3(x,y,z))!= 0) {
|
||||
glm::mat4 model = glm::mat4(1.0f);
|
||||
model = glm::translate(model, glm::vec3(x/5.0f, y/5.0f, z/5.0f));
|
||||
m_chunk_shader.set_uniform("model", model);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 36);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
#ifndef POLYGUN_ENGINE_CHUNK_RENDERER_HPP
|
||||
#define POLYGUN_ENGINE_CHUNK_RENDERER_HPP
|
||||
|
||||
#include "chunk.hpp"
|
||||
#include "engine.hpp"
|
||||
|
||||
namespace polygun::engine {
|
||||
class ChunkRenderer {
|
||||
public:
|
||||
ChunkRenderer();
|
||||
~ChunkRenderer();
|
||||
|
||||
void init();
|
||||
void render(glm::mat4 projection, glm::mat4 view, Chunk chunk_to_render);
|
||||
private:
|
||||
void load_textures();
|
||||
void generate_mesh();
|
||||
|
||||
renderer::Shader m_chunk_shader;
|
||||
unsigned int m_vbo, m_vao;
|
||||
Chunk m_chunk;
|
||||
//unsigned int m_textures[sizeof(nodes)];
|
||||
unsigned int m_texture1;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //POLYGUN_ENGINE_CHUNK_RENDERER_HPP
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "../audio/audio.hpp"
|
||||
|
||||
#include "chunk_renderer.hpp"
|
||||
#include "game/world/chunk_renderer.hpp"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
#include "vendor/imgui.h"
|
||||
@ -10,6 +10,7 @@
|
||||
#include "vendor/imgui_impl_opengl3.h"
|
||||
|
||||
using namespace polygun::renderer;
|
||||
using namespace polygun::world;
|
||||
|
||||
int sizex = SCR_WIDTH, sizey = SCR_HEIGHT;
|
||||
|
||||
@ -118,10 +119,10 @@ namespace polygun::engine {
|
||||
glEnableVertexAttribArray(1);
|
||||
|
||||
|
||||
unsigned int texture1;
|
||||
unsigned int texture_atlas;
|
||||
|
||||
glGenTextures(1, &texture1);
|
||||
glBindTexture(GL_TEXTURE_2D, texture1);
|
||||
glGenTextures(1, &texture_atlas);
|
||||
glBindTexture(GL_TEXTURE_2D, texture_atlas);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
@ -143,7 +144,7 @@ namespace polygun::engine {
|
||||
|
||||
|
||||
chunk_shader.bind();
|
||||
chunk_shader.set_uniform("texture1", 0);
|
||||
chunk_shader.set_uniform("texture_atlas", 0);
|
||||
|
||||
m_delta_time = 0;
|
||||
m_last_frame = 0;
|
||||
@ -204,12 +205,12 @@ namespace polygun::engine {
|
||||
|
||||
// bind textures on corresponding texture units
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture1);
|
||||
glBindTexture(GL_TEXTURE_2D, texture_atlas);
|
||||
|
||||
// activate shader
|
||||
chunk_shader.bind();
|
||||
|
||||
glm::mat4 projection = glm::perspective(glm::radians(m_camera.m_zoom), (float)sizex / (float)sizey, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(m_camera.m_fov), (float)sizex / (float)sizey, 0.1f, 100.0f);
|
||||
chunk_shader.set_uniform("projection", projection);
|
||||
|
||||
glm::mat4 view = m_camera.get_view_matrix();
|
||||
@ -230,18 +231,23 @@ namespace polygun::engine {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// imgui
|
||||
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
|
||||
ImGui::SetNextWindowSize(ImVec2(340, 200));
|
||||
|
||||
ImGui::Begin("Debug");
|
||||
|
||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||
// Camera pos
|
||||
ImGui::Text("Player Pos: %.3f, %.3f, %.3f", m_camera.m_position.x, m_camera.m_position.y, m_camera.m_position.z);
|
||||
// Camera rot
|
||||
ImGui::Text("Player Rot: %.3f, %.3f", m_camera.m_yaw, m_camera.m_pitch);
|
||||
|
||||
int x_d, y_d, z_d, id_d;
|
||||
|
||||
ImGui::InputInt("ID", &id_d);
|
||||
|
9
src/game/engine/greedy_merging.cpp
Normal file
9
src/game/engine/greedy_merging.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include "greedy_merging.hpp"
|
||||
|
||||
namespace polygun::engine {
|
||||
cuboid_list greedy_merging::merge(world::Chunk& chunk) {
|
||||
// code here
|
||||
//cuboid_list list; EXAMPLE
|
||||
//return list;
|
||||
}
|
||||
}
|
28
src/game/engine/greedy_merging.hpp
Normal file
28
src/game/engine/greedy_merging.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef POLYGUN_ENGINE_GREEDY_MERGING_HPP
|
||||
#define POLYGUN_ENGINE_GREEDY_MERGING_HPP
|
||||
|
||||
#include "game/world/chunk.hpp"
|
||||
|
||||
namespace polygun::engine {
|
||||
struct cuboid {
|
||||
int x1, y1, z1, x2, y2, z2, material;
|
||||
};
|
||||
|
||||
struct cuboid_list {
|
||||
cuboid* cuboids;
|
||||
int count;
|
||||
};
|
||||
class greedy_merging {
|
||||
public:
|
||||
greedy_merging() = default;
|
||||
~greedy_merging() = default;
|
||||
|
||||
cuboid_list merge(world::Chunk& chunk);
|
||||
private:
|
||||
|
||||
// greedy merging variables
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif // POLYGUN_ENGINE_GREEDY_MERGING_HPP
|
@ -3,10 +3,12 @@
|
||||
using namespace polygun::engine;
|
||||
|
||||
static float mx,my;
|
||||
float pitch_cos;
|
||||
|
||||
Camera::Camera(glm::vec3 position, glm::vec3 up, float yaw, float pitch) :
|
||||
m_position(position),
|
||||
m_front(glm::vec3(0.0f, 0.0f, -1.0f)),
|
||||
m_movement_front(),
|
||||
m_up(),
|
||||
m_right(),
|
||||
m_worldup(up),
|
||||
@ -14,7 +16,7 @@ Camera::Camera(glm::vec3 position, glm::vec3 up, float yaw, float pitch) :
|
||||
m_pitch(pitch),
|
||||
m_movement_speed(SPEED),
|
||||
m_mouse_sensitivity(SENSITIVITY),
|
||||
m_zoom(ZOOM),
|
||||
m_fov(FOV),
|
||||
m_last_x(SCR_WIDTH / 2.0f),
|
||||
m_last_y(SCR_HEIGHT / 2.0f),
|
||||
m_first_mouse(true)
|
||||
@ -25,6 +27,7 @@ Camera::Camera(glm::vec3 position, glm::vec3 up, float yaw, float pitch) :
|
||||
Camera::Camera(float pos_x, float pos_y, float pos_z, float up_x, float up_y, float up_z, float yaw, float pitch) :
|
||||
m_position(pos_x, pos_y, pos_z),
|
||||
m_front(glm::vec3(0.0f, 0.0f, -1.0f)),
|
||||
m_movement_front(),
|
||||
m_up(),
|
||||
m_right(),
|
||||
m_worldup(up_x, up_y, up_z),
|
||||
@ -32,7 +35,7 @@ Camera::Camera(float pos_x, float pos_y, float pos_z, float up_x, float up_y, fl
|
||||
m_pitch(pitch),
|
||||
m_movement_speed(SPEED),
|
||||
m_mouse_sensitivity(SENSITIVITY),
|
||||
m_zoom(ZOOM),
|
||||
m_fov(FOV),
|
||||
m_last_x(SCR_WIDTH / 2.0f),
|
||||
m_last_y(SCR_HEIGHT / 2.0f),
|
||||
m_first_mouse(true)
|
||||
@ -53,23 +56,26 @@ void Camera::update(bool reset) {
|
||||
m_last_x = mx;
|
||||
m_last_y = my;
|
||||
|
||||
process_mouse_movement(x_offset, y_offset);
|
||||
// only if mouse moved
|
||||
if (x_offset != 0.0f || y_offset != 0.0f)
|
||||
process_mouse_movement(x_offset, y_offset);
|
||||
|
||||
}
|
||||
|
||||
void Camera::process_movement(camera_movement direction, float delta_time) {
|
||||
float velocity = m_movement_speed * delta_time;
|
||||
if (direction == FORWARD)
|
||||
m_position += glm::vec3(m_front.x,0.0f,m_front.z) * velocity;
|
||||
m_position += glm::vec3(m_movement_front.x, 0.0f, m_movement_front.y) * velocity;
|
||||
if (direction == BACKWARD)
|
||||
m_position -= glm::vec3(m_front.x,0.0f,m_front.z) * velocity;
|
||||
m_position -= glm::vec3(m_movement_front.x, 0.0f, m_movement_front.y) * velocity;
|
||||
if (direction == LEFT)
|
||||
m_position -= glm::vec3(m_right.x,0.0f,m_right.z) * velocity;
|
||||
m_position -= glm::vec3(m_right.x, 0.0f, m_right.z) * velocity;
|
||||
if (direction == RIGHT)
|
||||
m_position += glm::vec3(m_right.x,0.0f,m_right.z) * velocity;
|
||||
m_position += glm::vec3(m_right.x, 0.0f, m_right.z) * velocity;
|
||||
if (direction == UP)
|
||||
m_position += glm::vec3(0.0F, 1.0F, 0.0F) * velocity;
|
||||
m_position += glm::vec3(0.0f, 1.0f, 0.0f) * velocity;
|
||||
if (direction == DOWN)
|
||||
m_position += glm::vec3(0.0F, -1.0F, 0.0F) * velocity;
|
||||
m_position += glm::vec3(0.0f, -1.0f, 0.0f) * velocity;
|
||||
}
|
||||
|
||||
void Camera::process_mouse_movement(float x_offset, float y_offset, GLboolean constrain_pitch) {
|
||||
@ -80,21 +86,21 @@ void Camera::process_mouse_movement(float x_offset, float y_offset, GLboolean co
|
||||
m_pitch += y_offset;
|
||||
|
||||
if (constrain_pitch) {
|
||||
if (m_pitch > 89.0f)
|
||||
m_pitch = 89.0f;
|
||||
if (m_pitch < -89.0f)
|
||||
m_pitch = -89.0f;
|
||||
if (m_pitch > 89.9f)
|
||||
m_pitch = 89.9f;
|
||||
else if (m_pitch < -89.9f)
|
||||
m_pitch = -89.9f;
|
||||
}
|
||||
|
||||
update_camera_vectors();
|
||||
}
|
||||
|
||||
void Camera::process_mouse_scroll(float y_offset) {
|
||||
m_zoom -= y_offset;
|
||||
if (m_zoom < 1.0f)
|
||||
m_zoom = 1.0f;
|
||||
if (m_zoom > 45.0f)
|
||||
m_zoom = 45.0f;
|
||||
m_fov -= y_offset;
|
||||
if (m_fov < 1.0f)
|
||||
m_fov = 1.0f;
|
||||
if (m_fov > 45.0f)
|
||||
m_fov = 45.0f;
|
||||
}
|
||||
|
||||
void Camera::mouse_callback(GLFWwindow* window, double x_pos_in, double y_pos_in) {
|
||||
@ -104,9 +110,15 @@ void Camera::mouse_callback(GLFWwindow* window, double x_pos_in, double y_pos_in
|
||||
|
||||
void Camera::update_camera_vectors() {
|
||||
glm::vec3 front;
|
||||
front.x = cos(glm::radians(m_yaw)) * cos(glm::radians(m_pitch));
|
||||
pitch_cos = cos(glm::radians(m_pitch));
|
||||
|
||||
m_movement_front.x = cos(glm::radians(m_yaw));
|
||||
m_movement_front.y = sin(glm::radians(m_yaw));
|
||||
|
||||
front.x = m_movement_front.x * pitch_cos;
|
||||
front.y = sin(glm::radians(m_pitch));
|
||||
front.z = sin(glm::radians(m_yaw)) * cos(glm::radians(m_pitch));
|
||||
front.z = m_movement_front.y * pitch_cos;
|
||||
|
||||
m_front = glm::normalize(front);
|
||||
m_right = glm::normalize(glm::cross(m_front, m_worldup));
|
||||
m_up = glm::normalize(glm::cross(m_right, m_front));
|
||||
|
@ -17,12 +17,13 @@ namespace polygun::engine {
|
||||
const float PITCH = 0.0f;
|
||||
const float SPEED = 2.5f;
|
||||
const float SENSITIVITY = 0.1f;
|
||||
const float ZOOM = 45.0f;
|
||||
const float FOV = 90.0f;
|
||||
|
||||
class Camera {
|
||||
public:
|
||||
glm::vec3 m_position;
|
||||
glm::vec3 m_front;
|
||||
glm::vec2 m_movement_front;
|
||||
glm::vec3 m_up;
|
||||
glm::vec3 m_right;
|
||||
glm::vec3 m_worldup;
|
||||
@ -30,7 +31,7 @@ namespace polygun::engine {
|
||||
float m_pitch;
|
||||
float m_movement_speed;
|
||||
float m_mouse_sensitivity;
|
||||
float m_zoom;
|
||||
float m_fov;
|
||||
|
||||
Camera(glm::vec3 position = glm::vec3(-0.5f, 0.25f, -0.5f), glm::vec3 up = glm::vec3(0.0f, 1.0f, 0.0f), float yaw = YAW, float pitch = PITCH);
|
||||
Camera(float pos_x, float pos_y, float pos_z, float up_x, float up_y, float up_z, float yaw, float pitch);
|
||||
|
0
src/game/renderer/mesh.cpp
Normal file
0
src/game/renderer/mesh.cpp
Normal file
10
src/game/renderer/mesh.hpp
Normal file
10
src/game/renderer/mesh.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef POLUGUN_RENDERER_MESH_HPP
|
||||
#define POLUGUN_RENDERER_MESH_HPP
|
||||
|
||||
#include "../core.hpp"
|
||||
|
||||
namespace polygun::renderer {
|
||||
|
||||
}
|
||||
|
||||
#endif // POLUGUN_RENDERER_MESH_HPP
|
22
src/game/renderer/vertex.hpp
Normal file
22
src/game/renderer/vertex.hpp
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef POLYGUN_RENDERER_VERTEX_HPP
|
||||
#define POLYGUN_RENDERER_VERTEX_HPP
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace polygun::renderer {
|
||||
struct Vertex {
|
||||
Vertex() = default;
|
||||
Vertex(float x, float y, float z) : m_position(glm::vec3(x, y, z)) {}
|
||||
Vertex(glm::vec3 position) : m_position(position), m_normal(0), m_tex_coords(0) {}
|
||||
Vertex(glm::vec3 position, glm::vec3 normal) : m_position(position), m_normal(normal), m_tex_coords(0) {}
|
||||
Vertex(glm::vec3 position, glm::vec3 normal, glm::vec2 tex_coord) : m_position(position), m_normal(normal), m_tex_coords(tex_coord) {}
|
||||
|
||||
// position
|
||||
glm::vec3 m_position = glm::vec3(0.0f);
|
||||
// normal
|
||||
glm::vec3 m_normal = glm::vec3(0.0f);
|
||||
// coords
|
||||
glm::vec2 m_tex_coords = glm::vec2(0.0f);
|
||||
};
|
||||
}
|
||||
#endif // POLYGUN_RENDERER_VERTEX_HPP
|
77
src/game/renderer/vertex_array.hpp
Normal file
77
src/game/renderer/vertex_array.hpp
Normal file
@ -0,0 +1,77 @@
|
||||
#ifndef POLYGUN_RENDERER_VERTEX_ARRAY_HPP
|
||||
#define POLYGUN_RENDERER_VERTEX_ARRAY_HPP
|
||||
|
||||
#include "../core.hpp"
|
||||
#include "vertex.hpp"
|
||||
|
||||
namespace polygun::renderer {
|
||||
class VertexArray {
|
||||
public:
|
||||
VertexArray(): m_vao(0), m_ebo(0), m_vbo(0), m_num_of_indices(0),
|
||||
m_num_of_vertices(0) {}
|
||||
|
||||
VertexArray(Vertex* vertices, GLsizei v_size, GLuint* indices = nullptr, GLsizei i_size = 0):
|
||||
m_num_of_indices(i_size), m_num_of_vertices(v_size) {
|
||||
glGenVertexArrays(1, &m_vao);
|
||||
glGenBuffers(1, &m_vbo);
|
||||
glGenBuffers(1, &m_ebo);
|
||||
|
||||
glBindVertexArray(m_vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, m_num_of_vertices * sizeof(Vertex), vertices, GL_STATIC_DRAW);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_num_of_indices * sizeof(GLuint), indices, GL_STATIC_DRAW);
|
||||
|
||||
// Positions
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)0);
|
||||
// Normals
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)offsetof(Vertex, m_normal));
|
||||
// Texcoords
|
||||
glEnableVertexAttribArray(2);
|
||||
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)offsetof(Vertex, m_tex_coords));
|
||||
|
||||
glBindVertexArray(0);
|
||||
m_num_of_vertices /= sizeof(Vertex);
|
||||
}
|
||||
|
||||
~VertexArray() {
|
||||
glDeleteVertexArrays(1, &m_vao);
|
||||
glDeleteBuffers(1, &m_vbo);
|
||||
glDeleteBuffers(1, &m_ebo);
|
||||
}
|
||||
|
||||
void push_attrib(GLuint index, GLint size, GLsizei stride, GLvoid* ptr) {
|
||||
glEnableVertexAttribArray(index);
|
||||
glVertexAttribPointer(index, size, GL_FLOAT, GL_FALSE, size, ptr);
|
||||
}
|
||||
|
||||
void bind() {
|
||||
glBindVertexArray(m_vao);
|
||||
}
|
||||
|
||||
void unbind() {
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void draw_elements(GLenum mode = GL_TRIANGLE_STRIP) {
|
||||
glBindVertexArray(m_vao);
|
||||
glDrawElements(mode, m_num_of_indices, GL_UNSIGNED_INT, 0);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void draw_arrays(GLenum mode = GL_TRIANGLES) {
|
||||
glBindVertexArray(m_vao);
|
||||
glDrawArrays(mode, 0, m_num_of_vertices);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
private:
|
||||
GLuint m_vao, m_vbo, m_ebo;
|
||||
GLsizei m_num_of_indices, m_num_of_vertices;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // POLYGUN_RENDERER_VERTEX_ARRAY_HPP
|
71
src/game/world/chunk.cpp
Normal file
71
src/game/world/chunk.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
#include "chunk.hpp"
|
||||
|
||||
namespace polygun::world {
|
||||
Chunk::Chunk() {
|
||||
for (int x = 0; x < CHUNK_SIZE; x++) {
|
||||
for (int y = 0; y < CHUNK_SIZE; y++) {
|
||||
for (int z = 0; z < CHUNK_SIZE; z++) {
|
||||
chunk_data[x][y][z] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Chunk::~Chunk() {
|
||||
delete chunk_data;
|
||||
}
|
||||
|
||||
void Chunk::add_node(int node_to_add, glm::vec3 pos) {
|
||||
chunk_data[(int)pos.x][(int)pos.y][(int)pos.z] = node_to_add;
|
||||
}
|
||||
|
||||
bool Chunk::is_air(glm::vec3 pos) {
|
||||
return chunk_data[(int)pos.x][(int)pos.y][(int)pos.z] == 0;
|
||||
}
|
||||
|
||||
int Chunk::get_node(glm::vec3 pos) {
|
||||
return chunk_data[(int)pos.x][(int)pos.y][(int)pos.z];
|
||||
}
|
||||
|
||||
bool Chunk::is_neighbour_air(glm::vec3 pos) {
|
||||
if (pos.x+1 == CHUNK_SIZE) {
|
||||
return true;
|
||||
}
|
||||
if (pos.x-1 == CHUNK_SIZE) {
|
||||
return true;
|
||||
}
|
||||
if (pos.y+1 == CHUNK_SIZE) {
|
||||
return true;
|
||||
}
|
||||
if (pos.y-1 == CHUNK_SIZE) {
|
||||
return true;
|
||||
}
|
||||
if (pos.z+1 == CHUNK_SIZE) {
|
||||
return true;
|
||||
}
|
||||
if (pos.z-1 == CHUNK_SIZE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pos.x+1 == 0) {
|
||||
return true;
|
||||
}
|
||||
if (pos.x-1 == 0) {
|
||||
return true;
|
||||
}
|
||||
if (pos.y+1 == 0) {
|
||||
return true;
|
||||
}
|
||||
if (pos.y-1 == 0) {
|
||||
return true;
|
||||
}
|
||||
if (pos.z+1 == 0) {
|
||||
return true;
|
||||
}
|
||||
if (pos.z-1 == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
#ifndef POLYGUN_ENGINE_CHUNK_HPP
|
||||
#define POLYGUN_ENGINE_CHUNK_HPP
|
||||
#ifndef POLYGUN_WORLD_CHUNK_HPP
|
||||
#define POLYGUN_WORLD_CHUNK_HPP
|
||||
|
||||
#include "nodes.hpp"
|
||||
|
||||
namespace polygun::engine {
|
||||
namespace polygun::world {
|
||||
class Chunk {
|
||||
public:
|
||||
Chunk();
|
||||
@ -12,6 +12,7 @@ namespace polygun::engine {
|
||||
void add_node(int node_to_add, glm::vec3 pos);
|
||||
bool is_air(glm::vec3 pos);
|
||||
int get_node(glm::vec3 pos);
|
||||
bool is_neighbour_air(glm::vec3 pos);
|
||||
|
||||
static const int CHUNK_SIZE = 32;
|
||||
|
||||
@ -22,4 +23,4 @@ namespace polygun::engine {
|
||||
};
|
||||
}
|
||||
|
||||
#endif // POLYGUN_ENGINE_CHUNK_HPP
|
||||
#endif // POLYGUN_WORLD_CHUNK_HPP
|
38
src/game/world/chunk_renderer.cpp
Normal file
38
src/game/world/chunk_renderer.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include "chunk_renderer.hpp"
|
||||
#include "common/logger.hpp"
|
||||
|
||||
namespace polygun::world {
|
||||
ChunkRenderer::ChunkRenderer() : chunk_shader("shaders/chunk_vertex.glsl", "shaders/chunk_fragment.glsl") {}
|
||||
|
||||
ChunkRenderer::~ChunkRenderer() {}
|
||||
|
||||
void ChunkRenderer::init() {/*
|
||||
float vertices[] = {
|
||||
// Add your vertex data here
|
||||
};
|
||||
GLsizei v_size = sizeof(vertices);
|
||||
GLuint indices[] = {
|
||||
// Add your indices data here
|
||||
};
|
||||
GLsizei i_size = sizeof(indices);
|
||||
|
||||
vertex_array = polygun::renderer::VertexArray(vertices, v_size, indices, i_size);
|
||||
|
||||
// Load and configure textures here
|
||||
|
||||
chunk_shader.bind();
|
||||
chunk_shader.set_uniform("texture", 0);*/
|
||||
}
|
||||
|
||||
void ChunkRenderer::render(const glm::mat4& view, const glm::mat4& projection) {
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
|
||||
chunk_shader.bind();
|
||||
|
||||
chunk_shader.set_uniform("projection", projection);
|
||||
chunk_shader.set_uniform("view", view);
|
||||
|
||||
vertex_array.draw_elements();
|
||||
}
|
||||
}
|
27
src/game/world/chunk_renderer.hpp
Normal file
27
src/game/world/chunk_renderer.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef POLYGUN_ENGINE_CHUNK_RENDERER_HPP
|
||||
#define POLYGUN_ENGINE_CHUNK_RENDERER_HPP
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include "chunk.hpp"
|
||||
#include "../renderer/shader.hpp"
|
||||
#include "../renderer/vertex_array.hpp"
|
||||
|
||||
namespace polygun::world {
|
||||
|
||||
class ChunkRenderer {
|
||||
public:
|
||||
ChunkRenderer();
|
||||
~ChunkRenderer();
|
||||
|
||||
void init();
|
||||
void render(const glm::mat4& view, const glm::mat4& projection);
|
||||
|
||||
private:
|
||||
unsigned int texture;
|
||||
renderer::Shader chunk_shader;
|
||||
renderer::VertexArray vertex_array;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //POLYGUN_ENGINE_CHUNK_RENDERER_HPP
|
@ -1,9 +1,9 @@
|
||||
#ifndef POLYGUN_ENGINE_NODES_HPP
|
||||
#define POLYGUN_ENGINE_NODES_HPP
|
||||
#ifndef POLYGUN_WORLD_NODES_HPP
|
||||
#define POLYGUN_WORLD_NODES_HPP
|
||||
|
||||
#include "../core.hpp"
|
||||
|
||||
namespace polygun::engine {
|
||||
namespace polygun::world {
|
||||
struct NodeType {
|
||||
std::string name;
|
||||
std::string texture;
|
||||
@ -18,4 +18,4 @@ namespace polygun::engine {
|
||||
};
|
||||
}
|
||||
|
||||
#endif // POLYGUN_ENGINE_NODES_HPP
|
||||
#endif // POLYGUN_WORLD_NODES_HPP
|
@ -3,6 +3,7 @@
|
||||
|
||||
#if defined(BUILD_CLIENT)
|
||||
#include "game/engine/engine.hpp"
|
||||
#include "game/audio/audio.hpp"
|
||||
#endif
|
||||
#if defined(BUILD_SERVER)
|
||||
#include "server/server.hpp"
|
||||
@ -34,8 +35,10 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
else {
|
||||
#if defined(BUILD_CLIENT)
|
||||
polygun::audio::init();
|
||||
polygun::engine::Engine engine;
|
||||
engine.init();
|
||||
polygun::audio::cleanup();
|
||||
#endif
|
||||
}
|
||||
polygun::utils::Logger::cleanup();
|
||||
|
@ -1,3 +1,27 @@
|
||||
/*
|
||||
PolyGun
|
||||
|
||||
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "server/client.hpp"
|
||||
|
||||
using namespace polygun::server;
|
||||
|
@ -1,3 +1,27 @@
|
||||
/*
|
||||
PolyGun
|
||||
|
||||
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef POLYGUN_SERVER_CLIENT_HPP
|
||||
#define POLYGUN_SERVER_CLIENT_HPP
|
||||
|
||||
|
@ -1,3 +1,27 @@
|
||||
/*
|
||||
PolyGun
|
||||
|
||||
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "server/server.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
@ -1,3 +1,27 @@
|
||||
/*
|
||||
PolyGun
|
||||
|
||||
Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef POLYGUN_SERVER_SERVER_HPP
|
||||
#define POLYGUN_SERVER_SERVER_HPP
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user