Fix CMake support for MinGW, MSVC, and others
This improves the general building experience by integrating with the newly created `sourceball` for windows. Most fixes involves either adding `#ifdef WIN32` or replacing GCC-specific extensions with more portable solutions. Has been tested with MSVC 15 and MinGW64.
This commit is contained in:
parent
f9d144722a
commit
357d4d2aad
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
# windows build crap
|
# windows build crap
|
||||||
winlibs/
|
winlibs/
|
||||||
|
dist/
|
||||||
*.dll
|
*.dll
|
||||||
|
|
||||||
# windows crap i mean why the hell does it do this crap
|
# windows crap i mean why the hell does it do this crap
|
||||||
|
@ -2,62 +2,83 @@
|
|||||||
cmake_minimum_required (VERSION 2.8.4)
|
cmake_minimum_required (VERSION 2.8.4)
|
||||||
project (iceball)
|
project (iceball)
|
||||||
|
|
||||||
#set(CMAKE_BINARY_DIR build)
|
|
||||||
set(CMAKE_SOURCE_DIR src)
|
set(CMAKE_SOURCE_DIR src)
|
||||||
set(OUTDIR ../build)
|
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing -g -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter")
|
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
add_definitions(-fno-strict-aliasing -Wall -Wextra -g) # keep debugging symbols even in Release builds
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
endif ()
|
||||||
|
|
||||||
IF(CMAKE_BUILD_TOOL MATCHES "(msdev|devenv|nmake)")
|
|
||||||
add_definitions(/W4) # warning level
|
|
||||||
add_definitions(/TP) # compile as c++
|
|
||||||
ELSEIF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
|
||||||
add_definitions(-Wall -g) # keep debugging symbols even in Release builds
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
include_directories(include)
|
include_directories(include)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
set_source_files_properties(filename.c PROPERTIES LANGUAGE CXX )
|
set_source_files_properties(filename.c PROPERTIES LANGUAGE CXX )
|
||||||
endif (MSVC)
|
endif (MSVC)
|
||||||
|
|
||||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/winlibs")
|
|
||||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/winlibs/glew")
|
|
||||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/winlibs/lua")
|
|
||||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/winlibs/SDL")
|
|
||||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/winlibs/zlib")
|
|
||||||
|
|
||||||
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/winlibs")
|
|
||||||
|
|
||||||
endif (WIN32)
|
endif (WIN32)
|
||||||
|
|
||||||
# here be sackit
|
if (MINGW)
|
||||||
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/xlibinc")
|
set(CMAKE_PREFIX_PATH "dist/mingw/enet;dist/mingw/sdl2;dist/mingw/lua51;dist/mingw/sackit;dist/mingw/zlib;dist/mingw/glew" CACHE PATH "" FORCE)
|
||||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/xlibinc")
|
elseif (MSVC)
|
||||||
|
set(CMAKE_PREFIX_PATH "dist/msvc/enet;dist/msvc/sdl2;dist/msvc/lua51;dist/msvc/sackit;dist/msvc/zlib;dist/msvc/glew" CACHE PATH "" FORCE)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# find the hidden treasures
|
|
||||||
find_package(ENet REQUIRED)
|
find_package(ENet REQUIRED)
|
||||||
find_package(PNG REQUIRED)
|
|
||||||
find_package(SDL2 REQUIRED)
|
find_package(SDL2 REQUIRED)
|
||||||
find_package(zlib REQUIRED)
|
find_package(zlib REQUIRED)
|
||||||
find_package(Lua REQUIRED)
|
find_package(Lua REQUIRED)
|
||||||
|
find_package(sackit REQUIRED)
|
||||||
find_package(GLEW REQUIRED)
|
find_package(GLEW REQUIRED)
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
|
|
||||||
# include the outcasts
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${PNG_INCLUDE_DIRS}
|
${ENet_INCLUDE_DIRS}
|
||||||
${ENet_INCLUDE_DIRS}
|
${sackit_INCLUDE_DIRS}
|
||||||
${SACKIT_INCLUDE_DIR}
|
${ZLIB_INCLUDE_DIRS}
|
||||||
${ZLIB_INCLUDE_DIRS}
|
${GLEW_INCLUDE_DIRS}
|
||||||
${GLEW_INCLUDE_DIRS}
|
${SDL2_INCLUDE_DIR}
|
||||||
${SDL2_INCLUDE_DIR}
|
${LUA_INCLUDE_DIR}
|
||||||
${LUA_INCLUDE_DIR}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(src)
|
file(GLOB LUA_FILES src/lua*)
|
||||||
|
set(MAIN_FILES
|
||||||
|
src/dsp.c
|
||||||
|
src/img.c
|
||||||
|
src/json.c
|
||||||
|
src/logtxt.c
|
||||||
|
src/main.c
|
||||||
|
src/map.c
|
||||||
|
src/model.c
|
||||||
|
src/network.c
|
||||||
|
src/path.c
|
||||||
|
src/vecmath.c
|
||||||
|
src/wav.c
|
||||||
|
src/png.c
|
||||||
|
)
|
||||||
|
|
||||||
|
set(GL_FILES
|
||||||
|
src/gl/render.c
|
||||||
|
src/gl/render_img.c
|
||||||
|
)
|
||||||
|
|
||||||
|
source_group(gl FILES ${GL_FILES})
|
||||||
|
|
||||||
|
source_group(lua FILES ${LUA_FILES})
|
||||||
|
|
||||||
|
add_custom_command(TARGET iceball POST_BUILD # Adds a post-build event to MyTest
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
|
||||||
|
"${LUA_LIBRARY}" # <--this is in-file
|
||||||
|
$<TARGET_FILE_DIR:MyTest>) # <--this is out-file path
|
||||||
|
|
||||||
|
# iceball target
|
||||||
|
add_executable(iceball ${MAIN_FILES} ${LUA_FILES} ${GL_FILES})
|
||||||
|
message("${ENet_LIBRARIES}\n${sackit_LIBRARY}\n${LUA_LIBRARIES}\n${OPENGL_LIBRARIES}\n${GLEW_LIBRARIES}\n${SDL2_LIBRARIES}")
|
||||||
|
target_link_libraries(iceball ${ENet_LIBRARIES} ${ZLIB_LIBRARIES} ${sackit_LIBRARY} ${LUA_LIBRARIES} ${SDL2_LIBRARIES} ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES})
|
||||||
|
|
||||||
|
set_target_properties(iceball PROPERTIES COMPILE_DEFINITIONS "USE_OPENGL")
|
||||||
|
|
||||||
|
# iceball-dedi target
|
||||||
|
add_executable(iceball-dedi EXCLUDE_FROM_ALL ${MAIN_FILES} ${LUA_FILES})
|
||||||
|
target_link_libraries(iceball-dedi ${ENet_LIBRARIES} ${ZLIB_LIBRARIES} ${LUA_LIBRARIES} ${SDL_LIBRARY})
|
||||||
|
set_target_properties(iceball-dedi PROPERTIES COMPILE_DEFINITIONS "DEDI")
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ FIND_PATH(ENet_INCLUDE_DIRS enet/enet.h
|
|||||||
$ENV{ENETDIR}
|
$ENV{ENETDIR}
|
||||||
/usr/local
|
/usr/local
|
||||||
/usr
|
/usr
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/winlibs"
|
|
||||||
PATH_SUFFIXES include
|
PATH_SUFFIXES include
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,7 +28,6 @@ FIND_LIBRARY(ENet_LIBRARY
|
|||||||
$ENV{ENETDIR}
|
$ENV{ENETDIR}
|
||||||
/usr/local
|
/usr/local
|
||||||
/usr
|
/usr
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/winlibs"
|
|
||||||
PATH_SUFFIXES lib
|
PATH_SUFFIXES lib
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -249,6 +249,15 @@ IF(SDL2_LIBRARY_TEMP)
|
|||||||
SET(SDL2_FOUND "YES")
|
SET(SDL2_FOUND "YES")
|
||||||
ENDIF(SDL2_LIBRARY_TEMP)
|
ENDIF(SDL2_LIBRARY_TEMP)
|
||||||
|
|
||||||
|
IF(SDL2_FOUND)
|
||||||
|
IF(WIN32)
|
||||||
|
SET(WINDOWS_SDL2_DEPENDENCIES "user32;gdi32;winmm;imm32;ole32;oleaut32;version;uuid")
|
||||||
|
SET(SDL2_LIBRARIES ${SDL2_LIBRARY} ${WINDOWS_SDL2_DEPENDENCIES})
|
||||||
|
ELSE(WIN32)
|
||||||
|
SET(SDL2_LIBRARIES ${SDL2_LIBRARY})
|
||||||
|
ENDIF(WIN32)
|
||||||
|
ENDIF (SDL2_FOUND)
|
||||||
|
|
||||||
INCLUDE(FindPackageHandleStandardArgs)
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
|
||||||
|
35
cmake/Findsackit.cmake
Normal file
35
cmake/Findsackit.cmake
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# - Try to find sackit
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# SACKIT_FOUND - system has sackit
|
||||||
|
# sackit_INCLUDE_DIRS - the sackit include directory
|
||||||
|
# sackit_LIBRARIES - the libraries needed to use sackit
|
||||||
|
#
|
||||||
|
# $SACKITDIR is an environment variable used for finding sackit.
|
||||||
|
#
|
||||||
|
|
||||||
|
FIND_PATH(sackit_INCLUDE_DIRS sackit.h
|
||||||
|
PATHS
|
||||||
|
$ENV{SACKITDIR}
|
||||||
|
/usr/local
|
||||||
|
/usr
|
||||||
|
PATH_SUFFIXES include
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_LIBRARY(sackit_LIBRARY
|
||||||
|
NAMES sackit
|
||||||
|
PATHS
|
||||||
|
$ENV{SACKITDIR}
|
||||||
|
/usr/local
|
||||||
|
/usr
|
||||||
|
PATH_SUFFIXES lib
|
||||||
|
)
|
||||||
|
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set SACKIT_FOUND to TRUE if
|
||||||
|
# all listed variables are TRUE
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(sackit DEFAULT_MSG sackit_LIBRARY sackit_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
SET(sackit_LIBRARIES ${sackit_LIBRARY})
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(sackit_LIBRARY sackit_LIBRARIES sackit_INCLUDE_DIRS)
|
@ -44,6 +44,23 @@
|
|||||||
|
|
||||||
//define RENDER_FACE_COUNT 2
|
//define RENDER_FACE_COUNT 2
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
//#define close(x) closesocket(x)
|
||||||
|
|
||||||
|
// TODO: remove?
|
||||||
|
#if _MSC_VER_
|
||||||
|
int bind(SOCKET s, void* name, int namelen)
|
||||||
|
{
|
||||||
|
return bind(s, (const sockaddr*)name, namelen);
|
||||||
|
}
|
||||||
|
int setsockopt(SOCKET s, int level, int optname, void* optval, int optlen)
|
||||||
|
{
|
||||||
|
return setsockopt(s, level, optname, (const char*)optval, optlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
#define PACK_START
|
#define PACK_START
|
||||||
#define PACK_END
|
#define PACK_END
|
||||||
@ -58,7 +75,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#else
|
#else
|
||||||
#define __attribute__(x)
|
|
||||||
#define PACK_START __pragma( pack(push, 1) )
|
#define PACK_START __pragma( pack(push, 1) )
|
||||||
#define PACK_END __pragma( pack(pop) )
|
#define PACK_END __pragma( pack(pop) )
|
||||||
typedef signed __int8 int8_t;
|
typedef signed __int8 int8_t;
|
||||||
@ -69,11 +85,23 @@ typedef signed __int32 int32_t;
|
|||||||
typedef unsigned __int32 uint32_t;
|
typedef unsigned __int32 uint32_t;
|
||||||
typedef signed __int64 int64_t;
|
typedef signed __int64 int64_t;
|
||||||
typedef unsigned __int64 uint64_t;
|
typedef unsigned __int64 uint64_t;
|
||||||
|
#if (_MSC_VER != 1900)
|
||||||
#define snprintf sprintf_s
|
#define snprintf sprintf_s
|
||||||
|
#endif
|
||||||
#define _USE_MATH_DEFINES //M_PI and whatnot from math.h
|
#define _USE_MATH_DEFINES //M_PI and whatnot from math.h
|
||||||
#pragma warning( disable: 4200 4244 4996)
|
#pragma warning( disable: 4200 4244 4996)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#define ALIGNED_(x) __declspec(align(x))
|
||||||
|
#else
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define ALIGNED_(x) __attribute__ ((aligned(x)))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ALIGNED_TYPE_(t,x) typedef t ALIGNED_(x)
|
||||||
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#endif
|
#endif
|
||||||
@ -183,28 +211,24 @@ enum
|
|||||||
#define SCREEN_BSWAP_32_ENDIAN
|
#define SCREEN_BSWAP_32_ENDIAN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __SSE__
|
#pragma pack(push, 1)
|
||||||
__attribute__((aligned(16)))
|
ALIGNED_TYPE_(union, 16) vec4f
|
||||||
#endif
|
|
||||||
PACK_START
|
|
||||||
typedef union vec4f
|
|
||||||
{
|
{
|
||||||
struct { float x,y,z,w; } __attribute__((__packed__)) p;
|
struct { float x,y,z,w; } p;
|
||||||
float a[4];
|
float a[4];
|
||||||
#ifdef __SSE__
|
#if defined(__SSE__) && !defined(_MSC_VER)
|
||||||
float __attribute__ ((vector_size (16))) m;
|
float __attribute__ ((vector_size (16))) m;
|
||||||
#endif
|
#endif
|
||||||
} __attribute__((__packed__)) vec4f_t;
|
} vec4f_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
#ifdef __SSE__
|
#pragma pack(push, 1)
|
||||||
__attribute__((aligned(16)))
|
ALIGNED_TYPE_(struct, 16) matrix
|
||||||
#endif
|
|
||||||
typedef struct matrix
|
|
||||||
{
|
{
|
||||||
//column-major!
|
//column-major!
|
||||||
vec4f_t c[4];
|
vec4f_t c[4];
|
||||||
} __attribute__((__packed__)) matrix_t;
|
} matrix_t;
|
||||||
PACK_END
|
#pragma pack(pop)
|
||||||
|
|
||||||
typedef struct camera
|
typedef struct camera
|
||||||
{
|
{
|
||||||
@ -215,14 +239,14 @@ typedef struct camera
|
|||||||
float mpx,mpy,mpz,mppad;
|
float mpx,mpy,mpz,mppad;
|
||||||
} camera_t;
|
} camera_t;
|
||||||
|
|
||||||
PACK_START
|
#pragma pack(push, 1)
|
||||||
typedef struct model_point
|
typedef struct model_point
|
||||||
{
|
{
|
||||||
uint16_t radius;
|
uint16_t radius;
|
||||||
int16_t x,y,z;
|
int16_t x,y,z;
|
||||||
uint8_t b,g,r,resv1;
|
uint8_t b,g,r,resv1;
|
||||||
} __attribute__((__packed__)) model_point_t;
|
} model_point_t;
|
||||||
PACK_END
|
#pragma pack(pop)
|
||||||
|
|
||||||
typedef struct model model_t;
|
typedef struct model model_t;
|
||||||
typedef struct model_bone
|
typedef struct model_bone
|
||||||
@ -293,8 +317,8 @@ typedef struct fbo
|
|||||||
} fbo_t;
|
} fbo_t;
|
||||||
|
|
||||||
|
|
||||||
PACK_START
|
|
||||||
// source: http://paulbourke.net/dataformats/tga/
|
// source: http://paulbourke.net/dataformats/tga/
|
||||||
|
#pragma pack(push, 1)
|
||||||
typedef struct img_tgahead
|
typedef struct img_tgahead
|
||||||
{
|
{
|
||||||
uint8_t idlen;
|
uint8_t idlen;
|
||||||
@ -309,8 +333,8 @@ typedef struct img_tgahead
|
|||||||
uint16_t height;
|
uint16_t height;
|
||||||
uint8_t bpp;
|
uint8_t bpp;
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
} __attribute__((__packed__)) img_tgahead_t;
|
} img_tgahead_t;
|
||||||
PACK_END
|
#pragma pack(pop)
|
||||||
|
|
||||||
typedef struct img
|
typedef struct img
|
||||||
{
|
{
|
||||||
@ -509,7 +533,7 @@ enum
|
|||||||
// dsp.c
|
// dsp.c
|
||||||
float interp_linear(float y0, float y1, float x);
|
float interp_linear(float y0, float y1, float x);
|
||||||
float interp_cubic(float y0, float y1, float y2, float y3, float x);
|
float interp_cubic(float y0, float y1, float y2, float y3, float x);
|
||||||
float interp_hermite6p(float y0, float y1, float y2, float y3,
|
float interp_hermite6p(float y0, float y1, float y2, float y3,
|
||||||
float y4, float y5, float x);
|
float y4, float y5, float x);
|
||||||
float frequency2wavelength(int rate, float frequency);
|
float frequency2wavelength(int rate, float frequency);
|
||||||
float wavelength2frequency(int rate, float wavelength);
|
float wavelength2frequency(int rate, float wavelength);
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
#/src/CMakeLists.txt
|
|
||||||
|
|
||||||
file(GLOB LUA_FILES lua*)
|
|
||||||
set(MAIN_FILES dsp.c img.c json.c logtxt.c main.c map.c model.c network.c path.c vecmath.c wav.c png.c)
|
|
||||||
|
|
||||||
set(GL_FILES gl/render.c gl/render_img.c)
|
|
||||||
source_group(gl FILES ${GL_FILES})
|
|
||||||
|
|
||||||
set(SOFT_FILES softgm/render.c softgm/render_img.c)
|
|
||||||
source_group(softgm FILES ${SOFT_FILES})
|
|
||||||
source_group(lua FILES ${LUA_FILES})
|
|
||||||
|
|
||||||
# iceball target
|
|
||||||
add_executable(iceball ${MAIN_FILES} ${LUA_FILES} ${GL_FILES})
|
|
||||||
target_link_libraries(iceball ${PNG_LIBRARIES} ${ENet_LIBRARIES} sackit ${LUA_LIBRARIES} ${SDL2_LIBRARY} ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES})
|
|
||||||
set_target_properties(iceball PROPERTIES COMPILE_DEFINITIONS "USE_OPENGL")
|
|
||||||
|
|
||||||
# iceball-dedi target
|
|
||||||
add_executable(iceball-dedi EXCLUDE_FROM_ALL ${MAIN_FILES} ${LUA_FILES})
|
|
||||||
target_link_libraries(iceball-dedi ${PNG_LIBRARIES} ${ENet_LIBRARIES} ${LUA_LIBRARIES} ${SDL_LIBRARY})
|
|
||||||
set_target_properties(iceball-dedi PROPERTIES COMPILE_DEFINITIONS "DEDI")
|
|
@ -1730,7 +1730,7 @@ void render_vertex_array(uint32_t *pixels, int width, int height, int pitch, cam
|
|||||||
{
|
{
|
||||||
glClientActiveTexture(GL_TEXTURE0 + i);
|
glClientActiveTexture(GL_TEXTURE0 + i);
|
||||||
glActiveTexture(GL_TEXTURE0 + i);
|
glActiveTexture(GL_TEXTURE0 + i);
|
||||||
glTexCoordPointer(va->texcoord_size[i%va->texcoord_count], GL_FLOAT, sizeof(float)*va->stride, ((void *)0+sizeof(float)*va->texcoord_offs[i%va->texcoord_count]));
|
glTexCoordPointer(va->texcoord_size[i%va->texcoord_count], GL_FLOAT, sizeof(float)*va->stride, (void *)(sizeof(float)*va->texcoord_offs[i%va->texcoord_count]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(gl_shaders)
|
if(gl_shaders)
|
||||||
|
@ -432,9 +432,13 @@ void render_blit_img_toimg(uint32_t *pixels, int width, int height, int pitch,
|
|||||||
__m128i xmm_src1_alpha0 = _mm_unpackhi_epi16(xmm_src1_alpha,xmm_src1_alpha);
|
__m128i xmm_src1_alpha0 = _mm_unpackhi_epi16(xmm_src1_alpha,xmm_src1_alpha);
|
||||||
__m128i xmm_src1_alpha1 = _mm_unpacklo_epi16(xmm_src1_alpha,xmm_src1_alpha);
|
__m128i xmm_src1_alpha1 = _mm_unpacklo_epi16(xmm_src1_alpha,xmm_src1_alpha);
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
xmm_src0_alpha = _mm_castps_si128(_mm_shuffle_ps(_mm_castsi128_ps(xmm_src0_alpha1),_mm_castsi128_ps(xmm_src0_alpha0),0xFF));
|
||||||
|
xmm_src1_alpha = _mm_castps_si128(_mm_shuffle_ps(_mm_castsi128_ps(xmm_src1_alpha1),_mm_castsi128_ps(xmm_src1_alpha0),0xFF));
|
||||||
|
#else
|
||||||
xmm_src0_alpha = (__m128i)_mm_shuffle_ps((__m128)xmm_src0_alpha1,(__m128)xmm_src0_alpha0,0xFF);
|
xmm_src0_alpha = (__m128i)_mm_shuffle_ps((__m128)xmm_src0_alpha1,(__m128)xmm_src0_alpha0,0xFF);
|
||||||
xmm_src1_alpha = (__m128i)_mm_shuffle_ps((__m128)xmm_src1_alpha1,(__m128)xmm_src1_alpha0,0xFF);
|
xmm_src1_alpha = (__m128i)_mm_shuffle_ps((__m128)xmm_src1_alpha1,(__m128)xmm_src1_alpha0,0xFF);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Found some instructions which should speed this up.
|
// Found some instructions which should speed this up.
|
||||||
// NOTE: actually runs at the same damn speed... maybe even worse.
|
// NOTE: actually runs at the same damn speed... maybe even worse.
|
||||||
|
@ -148,16 +148,13 @@ int icelua_fn_client_mk_sys_execv(lua_State *L)
|
|||||||
#else
|
#else
|
||||||
char *v = strdup("iceball.exe");
|
char *v = strdup("iceball.exe");
|
||||||
arglist[0] = v;
|
arglist[0] = v;
|
||||||
main_argv0 = v;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
printf("argv0: [%s]\n", main_argv0);
|
printf("argv0: [%s]\n", main_argv0);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
#ifdef WIN32
|
|
||||||
execv(v, arglist);
|
|
||||||
#else
|
|
||||||
execv(main_argv0, arglist);
|
execv(main_argv0, arglist);
|
||||||
#endif
|
|
||||||
printf("WORK YOU FUCKASS: %s\n", strerror(errno));
|
printf("WORK YOU FUCKASS: %s\n", strerror(errno));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ int icelua_fn_client_glsl_create(lua_State *L)
|
|||||||
|
|
||||||
glGetShaderiv(sh_v, GL_INFO_LOG_LENGTH, &len);
|
glGetShaderiv(sh_v, GL_INFO_LOG_LENGTH, &len);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
char info[len];
|
char *info = alloca(len);
|
||||||
glGetShaderInfoLog(sh_v, len, NULL, info);
|
glGetShaderInfoLog(sh_v, len, NULL, info);
|
||||||
luaL_addstring(&b, "Vertex shader compile error:\n");
|
luaL_addstring(&b, "Vertex shader compile error:\n");
|
||||||
luaL_addstring(&b, info);
|
luaL_addstring(&b, info);
|
||||||
@ -97,7 +97,7 @@ int icelua_fn_client_glsl_create(lua_State *L)
|
|||||||
|
|
||||||
glGetShaderiv(sh_f, GL_INFO_LOG_LENGTH, &len);
|
glGetShaderiv(sh_f, GL_INFO_LOG_LENGTH, &len);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
char info[len];
|
char *info = alloca(len);
|
||||||
glGetShaderInfoLog(sh_f, len, NULL, info);
|
glGetShaderInfoLog(sh_f, len, NULL, info);
|
||||||
luaL_addstring(&b, "Fragment shader compile error:\n");
|
luaL_addstring(&b, "Fragment shader compile error:\n");
|
||||||
luaL_addstring(&b, info);
|
luaL_addstring(&b, info);
|
||||||
@ -126,7 +126,7 @@ int icelua_fn_client_glsl_create(lua_State *L)
|
|||||||
|
|
||||||
glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &len);
|
glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &len);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
char info[len];
|
char *info = alloca(len);
|
||||||
glGetProgramInfoLog(prog, len, NULL, info);
|
glGetProgramInfoLog(prog, len, NULL, info);
|
||||||
luaL_addstring(&b, "Link error:\n");
|
luaL_addstring(&b, "Link error:\n");
|
||||||
luaL_addstring(&b, info);
|
luaL_addstring(&b, info);
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
along with Iceball. If not, see <http://www.gnu.org/licenses/>.
|
along with Iceball. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
#include <unistd.h> //fixes some warning, some POSIX shit ~Dany0
|
#include <unistd.h> //fixes some warning, some POSIX shit ~Dany0
|
||||||
|
#endif
|
||||||
|
|
||||||
int whitelist_validate(const char *name, int port);
|
int whitelist_validate(const char *name, int port);
|
||||||
|
|
||||||
|
79
src/main.c
79
src/main.c
@ -112,15 +112,62 @@ int platform_init(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* get_gl_debug_type_name(GLenum type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case GL_DEBUG_TYPE_ERROR:
|
||||||
|
return "ERROR";
|
||||||
|
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
|
||||||
|
return "DEPRECATED_BEHAVIOR";
|
||||||
|
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
|
||||||
|
return "UNDEFINED_BEHAVIOR";
|
||||||
|
case GL_DEBUG_TYPE_PORTABILITY:
|
||||||
|
return "PORTABILITY";
|
||||||
|
case GL_DEBUG_TYPE_PERFORMANCE:
|
||||||
|
return "PERFORMANCE";
|
||||||
|
case GL_DEBUG_TYPE_OTHER:
|
||||||
|
return "OTHER";
|
||||||
|
default:
|
||||||
|
return "<UNKNOWN>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* get_gl_debug_severity_name(GLenum severity)
|
||||||
|
{
|
||||||
|
switch (severity) {
|
||||||
|
case GL_DEBUG_SEVERITY_LOW:
|
||||||
|
return "LOW";
|
||||||
|
case GL_DEBUG_SEVERITY_MEDIUM:
|
||||||
|
return "MEDIUM";
|
||||||
|
case GL_DEBUG_SEVERITY_HIGH:
|
||||||
|
return "HIGH";
|
||||||
|
default:
|
||||||
|
return "<UNKNOWN>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void APIENTRY opengl_cb_fun(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, void* userParam)
|
||||||
|
{
|
||||||
|
printf("---------------------opengl-callback-start------------\n");
|
||||||
|
printf("message: %s\n", message);
|
||||||
|
printf("type: %s\n", get_gl_debug_type_name(type));
|
||||||
|
printf("id: %d\n", id);
|
||||||
|
printf("severity: %s\n", get_gl_debug_severity_name(severity));
|
||||||
|
printf("---------------------opengl-callback-end--------------\n");
|
||||||
|
}
|
||||||
|
|
||||||
int video_init(void)
|
int video_init(void)
|
||||||
{
|
{
|
||||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
||||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
||||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
||||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||||
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (screen_antialiasing_level > 0)
|
if (screen_antialiasing_level > 0)
|
||||||
{
|
{
|
||||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
|
||||||
@ -128,10 +175,10 @@ int video_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
window = SDL_CreateWindow("iceball",
|
window = SDL_CreateWindow("iceball",
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
screen_width,
|
screen_width,
|
||||||
screen_height, SDL_WINDOW_OPENGL | (screen_fullscreen ? SDL_WINDOW_FULLSCREEN : 0));
|
screen_height, SDL_WINDOW_OPENGL | (screen_fullscreen ? SDL_WINDOW_FULLSCREEN : 0));
|
||||||
if(window == NULL)
|
if(window == NULL)
|
||||||
return error_sdl("SDL_CreateWindow");
|
return error_sdl("SDL_CreateWindow");
|
||||||
|
|
||||||
@ -154,6 +201,7 @@ int video_init(void)
|
|||||||
//if(screen == NULL)
|
//if(screen == NULL)
|
||||||
// return error_sdl("SDL_GetWindowSurface");
|
// return error_sdl("SDL_GetWindowSurface");
|
||||||
|
|
||||||
|
glewExperimental = 1;
|
||||||
GLenum err_glew = glewInit();
|
GLenum err_glew = glewInit();
|
||||||
if(err_glew != GLEW_OK)
|
if(err_glew != GLEW_OK)
|
||||||
{
|
{
|
||||||
@ -169,6 +217,25 @@ int video_init(void)
|
|||||||
|
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max_texunits);
|
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max_texunits);
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if (glDebugMessageCallbackARB != NULL) {
|
||||||
|
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||||
|
glDebugMessageCallback(opengl_cb_fun, NULL);
|
||||||
|
GLuint unusedIds = 0;
|
||||||
|
glDebugMessageControl(GL_DONT_CARE,
|
||||||
|
GL_DONT_CARE,
|
||||||
|
GL_DONT_CARE,
|
||||||
|
0,
|
||||||
|
&unusedIds,
|
||||||
|
1);
|
||||||
|
|
||||||
|
fprintf(stdout, "Registered ARB_debug_output callback\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stderr, "WARNING: Could not register ARB_debug_output callback\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -862,6 +929,7 @@ int main_dbghelper(int argc, char *argv[])
|
|||||||
main_argv0 = argv[0];
|
main_argv0 = argv[0];
|
||||||
main_oldcwd = NULL;
|
main_oldcwd = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
// necessary for the server list to work, apparently
|
// necessary for the server list to work, apparently
|
||||||
{
|
{
|
||||||
@ -888,6 +956,7 @@ int main_dbghelper(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef DEDI
|
#ifdef DEDI
|
||||||
if(argc <= 1)
|
if(argc <= 1)
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#define PILLAR_SIZE 1028 // (256 + 1) * 4
|
||||||
|
|
||||||
int map_parse_root(map_t *map, const char *dend, const char *data, int xlen, int ylen, int zlen, int wipe_lighting)
|
int map_parse_root(map_t *map, const char *dend, const char *data, int xlen, int ylen, int zlen, int wipe_lighting)
|
||||||
{
|
{
|
||||||
// TODO: refactor a bit
|
// TODO: refactor a bit
|
||||||
@ -41,7 +44,6 @@ int map_parse_root(map_t *map, const char *dend, const char *data, int xlen, int
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int PILLAR_SIZE = (256+1)*4;
|
|
||||||
uint8_t pillar_temp[PILLAR_SIZE];
|
uint8_t pillar_temp[PILLAR_SIZE];
|
||||||
int i,x,z,pi;
|
int i,x,z,pi;
|
||||||
|
|
||||||
|
@ -19,18 +19,6 @@
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
WSADATA wsaStartup;
|
WSADATA wsaStartup;
|
||||||
#define close(x) closesocket(x)
|
|
||||||
#if _MSC_VER
|
|
||||||
int bind( SOCKET s, void* name, int namelen )
|
|
||||||
{
|
|
||||||
return bind( s, (const sockaddr*)name, namelen );
|
|
||||||
}
|
|
||||||
int setsockopt( SOCKET s, int level, int optname, void* optval, int optlen )
|
|
||||||
{
|
|
||||||
return setsockopt( s, level, optname, (const char*)optval, optlen );
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int server_sockfd_ipv4 = SOCKFD_NONE;
|
int server_sockfd_ipv4 = SOCKFD_NONE;
|
||||||
|
10
src/png.c
10
src/png.c
@ -17,10 +17,12 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
typedef struct pngheader {
|
typedef struct pngheader {
|
||||||
uint32_t width, height;
|
uint32_t width, height;
|
||||||
uint8_t bpc, ctyp, cmpr, filt, inter;
|
uint8_t bpc, ctyp, cmpr, filt, inter;
|
||||||
} __attribute__((__packed__)) pngheader_t;
|
} pngheader_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
#ifndef DEDI
|
#ifndef DEDI
|
||||||
void expandtex_gl(int *iw, int *ih);
|
void expandtex_gl(int *iw, int *ih);
|
||||||
@ -524,8 +526,14 @@ void img_write_png(const char *fname, img_t *img)
|
|||||||
size_t img_size = row_size * img->head.height;
|
size_t img_size = row_size * img->head.height;
|
||||||
size_t img_uncomp_len = (row_size - (gap-1)) * img->head.height;
|
size_t img_uncomp_len = (row_size - (gap-1)) * img->head.height;
|
||||||
uint8_t *img_uncomp = malloc(img_uncomp_len);
|
uint8_t *img_uncomp = malloc(img_uncomp_len);
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
// TODO: broken?
|
||||||
|
uint8_t **rowP = alloca(row_size * 1);
|
||||||
|
uint8_t **rowC = alloca(row_size * 5);
|
||||||
|
#else
|
||||||
uint8_t rowP[1][row_size];
|
uint8_t rowP[1][row_size];
|
||||||
uint8_t rowC[5][row_size];
|
uint8_t rowC[5][row_size];
|
||||||
|
#endif
|
||||||
uint8_t *src_pixels = (uint8_t *)(img->pixels);
|
uint8_t *src_pixels = (uint8_t *)(img->pixels);
|
||||||
int rowsel = 0;
|
int rowsel = 0;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ vec4f_t mtx_apply_vec(matrix_t *mtx, vec4f_t *vec)
|
|||||||
{
|
{
|
||||||
int i,j;
|
int i,j;
|
||||||
|
|
||||||
#ifndef __SSE__
|
#if !defined(__SSE__) || defined(_MSC_VER)
|
||||||
|
|
||||||
vec4f_t ret;
|
vec4f_t ret;
|
||||||
|
|
||||||
|
@ -25,12 +25,14 @@ sackit_playback_t *icesackit_pb = NULL;
|
|||||||
float icesackit_vol = 1.0f;
|
float icesackit_vol = 1.0f;
|
||||||
float icesackit_mvol = 1.0f;
|
float icesackit_mvol = 1.0f;
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
typedef struct wavfmt {
|
typedef struct wavfmt {
|
||||||
uint16_t codec, chns;
|
uint16_t codec, chns;
|
||||||
uint32_t freq;
|
uint32_t freq;
|
||||||
uint32_t bytes_sec;
|
uint32_t bytes_sec;
|
||||||
uint16_t blkalign, bps;
|
uint16_t blkalign, bps;
|
||||||
} __attribute__((__packed__)) wavfmt_t;
|
} wavfmt_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
// These 2 tables are from here: http://wiki.multimedia.cx/index.php?title=IMA_ADPCM
|
// These 2 tables are from here: http://wiki.multimedia.cx/index.php?title=IMA_ADPCM
|
||||||
int ima_index_table[16] = {
|
int ima_index_table[16] = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user