last merge without Curl

This commit is contained in:
vincent 2013-04-09 22:17:59 +02:00
parent 56aac7077c
commit 4f41aab89a
10 changed files with 57 additions and 14 deletions

View file

@ -18,8 +18,7 @@ endif (APPLE)
if (WIN32)
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
#include <GL/glew.h>\n#include <GL/wglew.h>\n#include <GL/freeglut_std.h>\n#include <GL/freeglut_ext.h>")
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>")
endif (WIN32)
# create the InterfaceConfig.h file based on GL_HEADERS above

View file

@ -69,7 +69,7 @@ public:
*/
bool addShader(GLenum type, GLchar const* cString) {
addShader(type, 1, & cString);
return addShader(type, 1, & cString);
}
/**

View file

@ -6,6 +6,7 @@
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#include "InterfaceConfig.h"
#include "FieldOfView.h"
#include "Stars.h"

View file

@ -137,7 +137,7 @@ namespace starfield {
// ww + ww aa = dd
// ww = dd / (1 + aa)
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 hh = hw * aspect;
@ -165,11 +165,11 @@ namespace starfield {
#if STARFIELD_DEBUG_LOD
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);
#endif
matrix = glm::frustum(-hw,hw, -hh,hh, near,10.0f)
matrix = glm::frustum(-hw,hw, -hh,hh, near2,10.0f)
* glm::affineInverse(matrix);
this->_itrOutIndex = (unsigned*) _arrBatchOffs;
@ -374,11 +374,11 @@ namespace starfield {
float halfSlice = 0.5f * slice;
float daz = halfSlice * cos(abs(altitude) - 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) {

View file

@ -13,8 +13,19 @@
#error "This is an implementation file - not intended for direct inclusion."
#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 {
class Tiling {

View file

@ -17,12 +17,13 @@ include_directories(
${EXTERNAL_ROOT_DIR}
)
endif (WIN32)
if (NOT WIN32)
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIRS})
# link target to common, external libraries
target_link_libraries(HifiShared ${CURL_LIBRARY})
endif (NOT WIN32)
# link required libraries on UNIX
if (UNIX AND NOT APPLE)

View file

@ -11,7 +11,12 @@
#include "CounterStats.h"
#include <cstdio>
#ifdef _WIN32
#include "Systime.h"
#else
#include <sys/time.h>
#endif
#include <string>
#include <map>

View file

@ -11,7 +11,7 @@
#include "PerfStat.h"
#include <cstdio>
#include <sys/time.h>
#include <string>
#include <map>

View file

@ -12,6 +12,15 @@
#ifndef __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 <string>
#include <map>

View file

@ -10,9 +10,16 @@
#include "UrlReader.h"
#include <new>
#ifdef _WIN32
#define NOCURL_IN_WINDOWS
#endif
#ifndef NOCURL_IN_WINDOWS
#include <curl/curl.h>
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::error_init_failed = "UrlReader: Initialization failed.";
@ -27,21 +34,26 @@ UrlReader::UrlReader()
_arrXtra = new(std::nothrow) char[max_read_ahead];
if (! _arrXtra) { _strError = error_init_failed; return; }
#ifndef NOCURL_IN_WINDOWS
_ptrImpl = curl_easy_init();
if (! _ptrImpl) { _strError = error_init_failed; return; }
curl_easy_setopt(hnd_curl, CURLOPT_NOSIGNAL, 1l);
curl_easy_setopt(hnd_curl, CURLOPT_FAILONERROR, 1l);
curl_easy_setopt(hnd_curl, CURLOPT_FILETIME, 1l);
#endif
}
UrlReader::~UrlReader() {
delete _arrXtra;
#ifndef NOCURL_IN_WINDOWS
if (! hnd_curl) return;
curl_easy_cleanup(hnd_curl);
#endif
}
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_WRITEFUNCTION, cb);
@ -58,10 +70,14 @@ bool UrlReader::perform(char const* url, transfer_callback* cb) {
_strError = curl_easy_strerror(rc);
return rc == CURLE_OK;
#else
return false;
#endif
}
void UrlReader::getinfo(char const*& url,
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_CONTENT_TYPE, & type);
@ -73,5 +89,6 @@ void UrlReader::getinfo(char const*& url,
long time;
curl_easy_getinfo(hnd_curl, CURLINFO_FILETIME, & time);
stardate = time;
#endif
}