mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 19:02:55 +02:00
last merge without Curl
This commit is contained in:
parent
56aac7077c
commit
4f41aab89a
10 changed files with 57 additions and 14 deletions
|
@ -18,8 +18,7 @@ endif (APPLE)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
set(GLUT_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external/glut)
|
set(GLUT_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external/glut)
|
||||||
set(GL_HEADERS "#define GLEW_STATIC\n#define FREEGLUT_STATIC\n#define FREEGLUT_LIB_PRAGMAS 0
|
set(GL_HEADERS "#define GLEW_STATIC\n#define FREEGLUT_STATIC\n#define FREEGLUT_LIB_PRAGMAS 0\n#include <GL/glew.h>\n#include <GL/wglew.h>\n#include <GL/freeglut_std.h>\n#include <GL/freeglut_ext.h>")
|
||||||
#include <GL/glew.h>\n#include <GL/wglew.h>\n#include <GL/freeglut_std.h>\n#include <GL/freeglut_ext.h>")
|
|
||||||
endif (WIN32)
|
endif (WIN32)
|
||||||
|
|
||||||
# create the InterfaceConfig.h file based on GL_HEADERS above
|
# create the InterfaceConfig.h file based on GL_HEADERS above
|
||||||
|
|
|
@ -69,7 +69,7 @@ public:
|
||||||
*/
|
*/
|
||||||
bool addShader(GLenum type, GLchar const* cString) {
|
bool addShader(GLenum type, GLchar const* cString) {
|
||||||
|
|
||||||
addShader(type, 1, & cString);
|
return addShader(type, 1, & cString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include "InterfaceConfig.h"
|
#include "InterfaceConfig.h"
|
||||||
#include "FieldOfView.h"
|
#include "FieldOfView.h"
|
||||||
#include "Stars.h"
|
#include "Stars.h"
|
||||||
|
|
|
@ -137,7 +137,7 @@ namespace starfield {
|
||||||
// ww + ww aa = dd
|
// ww + ww aa = dd
|
||||||
// ww = dd / (1 + aa)
|
// ww = dd / (1 + aa)
|
||||||
float diag = 2.0f * std::sin(halfPersp);
|
float diag = 2.0f * std::sin(halfPersp);
|
||||||
float near = std::cos(halfPersp);
|
float near2 = std::cos(halfPersp);
|
||||||
|
|
||||||
float hw = 0.5f * sqrt(diag * diag / (1.0f + aspect * aspect));
|
float hw = 0.5f * sqrt(diag * diag / (1.0f + aspect * aspect));
|
||||||
float hh = hw * aspect;
|
float hh = hw * aspect;
|
||||||
|
@ -165,11 +165,11 @@ namespace starfield {
|
||||||
|
|
||||||
#if STARFIELD_DEBUG_LOD
|
#if STARFIELD_DEBUG_LOD
|
||||||
mat4 matrix_debug = glm::translate(
|
mat4 matrix_debug = glm::translate(
|
||||||
glm::frustum(-hw,hw, -hh,hh, near,10.0f),
|
glm::frustum(-hw,hw, -hh,hh, near2,10.0f),
|
||||||
vec3(0.0f, 0.0f, -4.0f)) * glm::affineInverse(matrix);
|
vec3(0.0f, 0.0f, -4.0f)) * glm::affineInverse(matrix);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
matrix = glm::frustum(-hw,hw, -hh,hh, near,10.0f)
|
matrix = glm::frustum(-hw,hw, -hh,hh, near2,10.0f)
|
||||||
* glm::affineInverse(matrix);
|
* glm::affineInverse(matrix);
|
||||||
|
|
||||||
this->_itrOutIndex = (unsigned*) _arrBatchOffs;
|
this->_itrOutIndex = (unsigned*) _arrBatchOffs;
|
||||||
|
@ -374,11 +374,11 @@ namespace starfield {
|
||||||
float halfSlice = 0.5f * slice;
|
float halfSlice = 0.5f * slice;
|
||||||
float daz = halfSlice * cos(abs(altitude) - halfSlice);
|
float daz = halfSlice * cos(abs(altitude) - halfSlice);
|
||||||
float dal = halfSlice;
|
float dal = halfSlice;
|
||||||
float near = cos(_valHalfPersp + sqrt(daz*daz+dal*dal));
|
float near2 = cos(_valHalfPersp + sqrt(daz*daz+dal*dal));
|
||||||
|
|
||||||
// fprintf(stderr, "Stars.cpp: checking tile #%d, w = %f, near = %f\n", i, w, near);
|
// fprintf(stderr, "Stars.cpp: checking tile #%d, w = %f, near = %f\n", i, w, near2);
|
||||||
|
|
||||||
return w > near;
|
return w > near2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateVertexCount(Tile* t, BrightnessLevel minBright) {
|
void updateVertexCount(Tile* t, BrightnessLevel minBright) {
|
||||||
|
|
|
@ -13,8 +13,19 @@
|
||||||
#error "This is an implementation file - not intended for direct inclusion."
|
#error "This is an implementation file - not intended for direct inclusion."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "starfield/Config.h"
|
#ifdef _WIN32
|
||||||
|
#include "../Config.h"
|
||||||
|
#define lrint(x) (floor(x+(x>0) ? 0.5 : -0.5))
|
||||||
|
inline float remainder(float x,float y) { return std::fmod(x,y); }
|
||||||
|
inline int round(float x) { return (floor(x + 0.5)); }
|
||||||
|
double log2( double n )
|
||||||
|
{
|
||||||
|
// log(n)/log(2) is log2.
|
||||||
|
return log( n ) / log( 2 );
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#include "../starfield/Config.h"
|
||||||
|
#endif
|
||||||
namespace starfield {
|
namespace starfield {
|
||||||
|
|
||||||
class Tiling {
|
class Tiling {
|
||||||
|
|
|
@ -17,12 +17,13 @@ include_directories(
|
||||||
${EXTERNAL_ROOT_DIR}
|
${EXTERNAL_ROOT_DIR}
|
||||||
)
|
)
|
||||||
endif (WIN32)
|
endif (WIN32)
|
||||||
|
if (NOT WIN32)
|
||||||
|
|
||||||
find_package(CURL REQUIRED)
|
find_package(CURL REQUIRED)
|
||||||
include_directories(${CURL_INCLUDE_DIRS})
|
include_directories(${CURL_INCLUDE_DIRS})
|
||||||
# link target to common, external libraries
|
# link target to common, external libraries
|
||||||
target_link_libraries(HifiShared ${CURL_LIBRARY})
|
target_link_libraries(HifiShared ${CURL_LIBRARY})
|
||||||
|
endif (NOT WIN32)
|
||||||
|
|
||||||
# link required libraries on UNIX
|
# link required libraries on UNIX
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
|
|
|
@ -11,7 +11,12 @@
|
||||||
|
|
||||||
#include "CounterStats.h"
|
#include "CounterStats.h"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "Systime.h"
|
||||||
|
#else
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include "PerfStat.h"
|
#include "PerfStat.h"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,15 @@
|
||||||
#ifndef __hifi__PerfStat__
|
#ifndef __hifi__PerfStat__
|
||||||
#define __hifi__PerfStat__
|
#define __hifi__PerfStat__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define snprintf _snprintf
|
||||||
|
#include "Systime.h"
|
||||||
|
#else
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
|
@ -10,9 +10,16 @@
|
||||||
#include "UrlReader.h"
|
#include "UrlReader.h"
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define NOCURL_IN_WINDOWS
|
||||||
|
#endif
|
||||||
|
#ifndef NOCURL_IN_WINDOWS
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
size_t const UrlReader::max_read_ahead = CURL_MAX_WRITE_SIZE;
|
size_t const UrlReader::max_read_ahead = CURL_MAX_WRITE_SIZE;
|
||||||
|
#else
|
||||||
|
size_t const UrlReader::max_read_ahead = 0;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
char const* const UrlReader::success = "UrlReader: Success!";
|
char const* const UrlReader::success = "UrlReader: Success!";
|
||||||
char const* const UrlReader::error_init_failed = "UrlReader: Initialization failed.";
|
char const* const UrlReader::error_init_failed = "UrlReader: Initialization failed.";
|
||||||
|
@ -27,21 +34,26 @@ UrlReader::UrlReader()
|
||||||
|
|
||||||
_arrXtra = new(std::nothrow) char[max_read_ahead];
|
_arrXtra = new(std::nothrow) char[max_read_ahead];
|
||||||
if (! _arrXtra) { _strError = error_init_failed; return; }
|
if (! _arrXtra) { _strError = error_init_failed; return; }
|
||||||
|
#ifndef NOCURL_IN_WINDOWS
|
||||||
_ptrImpl = curl_easy_init();
|
_ptrImpl = curl_easy_init();
|
||||||
if (! _ptrImpl) { _strError = error_init_failed; return; }
|
if (! _ptrImpl) { _strError = error_init_failed; return; }
|
||||||
curl_easy_setopt(hnd_curl, CURLOPT_NOSIGNAL, 1l);
|
curl_easy_setopt(hnd_curl, CURLOPT_NOSIGNAL, 1l);
|
||||||
curl_easy_setopt(hnd_curl, CURLOPT_FAILONERROR, 1l);
|
curl_easy_setopt(hnd_curl, CURLOPT_FAILONERROR, 1l);
|
||||||
curl_easy_setopt(hnd_curl, CURLOPT_FILETIME, 1l);
|
curl_easy_setopt(hnd_curl, CURLOPT_FILETIME, 1l);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
UrlReader::~UrlReader() {
|
UrlReader::~UrlReader() {
|
||||||
|
|
||||||
delete _arrXtra;
|
delete _arrXtra;
|
||||||
|
#ifndef NOCURL_IN_WINDOWS
|
||||||
if (! hnd_curl) return;
|
if (! hnd_curl) return;
|
||||||
curl_easy_cleanup(hnd_curl);
|
curl_easy_cleanup(hnd_curl);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UrlReader::perform(char const* url, transfer_callback* cb) {
|
bool UrlReader::perform(char const* url, transfer_callback* cb) {
|
||||||
|
#ifndef NOCURL_IN_WINDOWS
|
||||||
|
|
||||||
curl_easy_setopt(hnd_curl, CURLOPT_URL, url);
|
curl_easy_setopt(hnd_curl, CURLOPT_URL, url);
|
||||||
curl_easy_setopt(hnd_curl, CURLOPT_WRITEFUNCTION, cb);
|
curl_easy_setopt(hnd_curl, CURLOPT_WRITEFUNCTION, cb);
|
||||||
|
@ -58,10 +70,14 @@ bool UrlReader::perform(char const* url, transfer_callback* cb) {
|
||||||
_strError = curl_easy_strerror(rc);
|
_strError = curl_easy_strerror(rc);
|
||||||
|
|
||||||
return rc == CURLE_OK;
|
return rc == CURLE_OK;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void UrlReader::getinfo(char const*& url,
|
void UrlReader::getinfo(char const*& url,
|
||||||
char const*& type, int64_t& length, int64_t& stardate) {
|
char const*& type, int64_t& length, int64_t& stardate) {
|
||||||
|
#ifndef NOCURL_IN_WINDOWS
|
||||||
|
|
||||||
curl_easy_getinfo(hnd_curl, CURLINFO_EFFECTIVE_URL, & url);
|
curl_easy_getinfo(hnd_curl, CURLINFO_EFFECTIVE_URL, & url);
|
||||||
curl_easy_getinfo(hnd_curl, CURLINFO_CONTENT_TYPE, & type);
|
curl_easy_getinfo(hnd_curl, CURLINFO_CONTENT_TYPE, & type);
|
||||||
|
@ -73,5 +89,6 @@ void UrlReader::getinfo(char const*& url,
|
||||||
long time;
|
long time;
|
||||||
curl_easy_getinfo(hnd_curl, CURLINFO_FILETIME, & time);
|
curl_easy_getinfo(hnd_curl, CURLINFO_FILETIME, & time);
|
||||||
stardate = time;
|
stardate = time;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue