Fix linux compile errors

This commit is contained in:
Magnus Norddahl 2021-11-12 17:08:15 +01:00
parent edc22ed06f
commit e54477cb93
9 changed files with 28 additions and 17 deletions

View file

@ -398,6 +398,11 @@ if(MSVC)
set_source_files_properties(${THIRDPARTY_SOURCES} PROPERTIES COMPILE_FLAGS "/wd4244 /wd4267 /wd4005 /wd4018 -D_CRT_SECURE_NO_WARNINGS")
endif()
if (WIN32)
else()
set(PLATFORM_LIB "dl")
endif()
if( CMAKE_COMPILER_IS_GNUCXX )
set( ZDRAY_LIBS "${ZLIB_LIBRARIES}" pthread )
endif( CMAKE_COMPILER_IS_GNUCXX )
@ -419,7 +424,7 @@ set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${REL_C_F
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEB_C_FLAGS} -D_DEBUG" )
add_executable( zdray ${SOURCES} ${HEADERS} ${THIRDPARTY_SOURCES} )
target_link_libraries( zdray ${ZDRAY_LIBS} ${PROF_LIB} )
target_link_libraries( zdray ${ZDRAY_LIBS} ${PROF_LIB} ${PLATFORM_LIB} )
include_directories( src "${ZLIB_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty" )
source_group("Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/src/.+")

View file

@ -139,7 +139,7 @@ void CPURaytracer::RunBounceTrace(CPUTraceState& state)
if (state.PassType == 2)
{
origin = state.Position;
surface = state.Surface;
surface = state.Surf;
}
else
{
@ -220,7 +220,7 @@ void CPURaytracer::RunBounceTrace(CPUTraceState& state)
}
state.Position = origin;
state.Surface = surface;
state.Surf = surface;
state.Output = incoming;
state.OutputAttenuation = incomingAttenuation;
}
@ -232,7 +232,7 @@ void CPURaytracer::RunLightTrace(CPUTraceState& state)
if (incomingAttenuation <= 0.0f)
return;
Surface* surface = state.Surface;
Surface* surface = state.Surf;
Vec3 origin = state.Position;
Vec3 normal;

View file

@ -35,7 +35,7 @@ struct CPUTraceState
Surface* StartSurface;
Vec3 Position;
Surface* Surface;
Surface* Surf;
Vec3 Output;
float OutputAttenuation;

View file

@ -11,6 +11,7 @@
#include <stdexcept>
#include <memory>
#include <cmath>
#include <string.h>
void PNGWriter::save(const std::string& filename, int width, int height, int bytes_per_pixel, void* pixels)
{

View file

@ -9,6 +9,7 @@
VulkanDevice::VulkanDevice(int vk_device, bool vk_debug) : vk_device(vk_device), vk_debug(vk_debug)
{
#ifdef WIN32
if (HMODULE mod = GetModuleHandle(TEXT("renderdoc.dll")))
{
pRENDERDOC_GetAPI RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)GetProcAddress(mod, "RENDERDOC_GetAPI");
@ -16,6 +17,7 @@ VulkanDevice::VulkanDevice(int vk_device, bool vk_debug) : vk_device(vk_device),
if (ret != 1)
renderdoc = nullptr;
}
#endif
try
{
@ -491,8 +493,8 @@ std::vector<const char *> VulkanDevice::getPlatformExtensions()
{
return
{
VK_KHR_SURFACE_EXTENSION_NAME,
VK_KHR_XLIB_SURFACE_EXTENSION_NAME
VK_KHR_SURFACE_EXTENSION_NAME/*,
VK_KHR_XLIB_SURFACE_EXTENSION_NAME*/
};
}
#endif

View file

@ -1,5 +1,6 @@
#pragma once
#include "model.h"
#include <climits>
#define MD2_MAGIC 0x32504449
#define DMD_MAGIC 0x4D444D44

View file

@ -1,5 +1,6 @@
#pragma once
#include "model.h"
#include <climits>
#define MD3_MAGIC 0x33504449

View file

@ -30,10 +30,11 @@
#include "modelrenderer.h"
#include "m_swap.h"
#include <string.h>
#include <cmath>
namespace
{
const double M_PI = 3.14159265358979323846; // matches value in gcc v2 math.h
const double MM_PI = 3.14159265358979323846; // matches value in gcc v2 math.h
}
#ifdef _MSC_VER
@ -56,13 +57,13 @@ static float avertexnormals[NUMVERTEXNORMALS][3] = {
static void UnpackVector(unsigned short packed, float vec[3])
{
float yaw = (packed & 511) / 512.0f * 2 * M_PI;
float pitch = ((packed >> 9) / 127.0f - 0.5f) * M_PI;
float cosp = (float) cos(pitch);
float yaw = (packed & 511) / 512.0f * 2 * MM_PI;
float pitch = ((packed >> 9) / 127.0f - 0.5f) * MM_PI;
float cosp = (float) std::cos(pitch);
vec[VX] = (float) cos(yaw) * cosp;
vec[VY] = (float) sin(yaw) * cosp;
vec[VZ] = (float) sin(pitch);
vec[VX] = (float) std::cos(yaw) * cosp;
vec[VY] = (float) std::sin(yaw) * cosp;
vec[VZ] = (float) std::sin(pitch);
}

View file

@ -29,7 +29,7 @@
namespace
{
const double M_PI = 3.14159265358979323846; // matches value in gcc v2 math.h
const double MM_PI = 3.14159265358979323846; // matches value in gcc v2 math.h
}
#define MAX_QPATH 64
@ -48,8 +48,8 @@ static void UnpackVector(unsigned short packed, float & nx, float & ny, float &
{
double lat = ( packed >> 8 ) & 0xff;
double lng = ( packed & 0xff );
lat *= M_PI/128;
lng *= M_PI/128;
lat *= MM_PI/128;
lng *= MM_PI/128;
nx = std::cos(lat) * std::sin(lng);
ny = std::sin(lat) * std::sin(lng);