Removed C-API from 'system'
This commit is contained in:
parent
abd463d29d
commit
1a69b1de1d
48 changed files with 379 additions and 545 deletions
|
@ -8,7 +8,8 @@ INCLUDEPATH += $$PWD/..
|
|||
|
||||
CONFIG(release, debug|release): DEFINES += NDEBUG
|
||||
|
||||
SOURCES += main.c
|
||||
SOURCES += \
|
||||
main.cpp
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../rendering/release/ -lpaysages_rendering
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../rendering/debug/ -lpaysages_rendering
|
||||
|
|
|
@ -164,7 +164,7 @@ int main(int argc, char** argv)
|
|||
for (outputcount = 0; outputcount < conf_first_picture + conf_nb_pictures; outputcount++)
|
||||
{
|
||||
AtmosphereDefinition* atmo;
|
||||
atmo = AtmosphereDefinitionClass.create();
|
||||
atmo = (AtmosphereDefinition*)AtmosphereDefinitionClass.create();
|
||||
sceneryGetAtmosphere(atmo);
|
||||
atmo->hour = (int)floor(conf_daytime_start * 24.0);
|
||||
atmo->minute = (int)floor(fmod(conf_daytime_start, 1.0 / 24.0) * 24.0 * 60.0);
|
|
@ -1,5 +1,7 @@
|
|||
#include "BaseDefinition.h"
|
||||
|
||||
#include "PackStream.h"
|
||||
|
||||
BaseDefinition::BaseDefinition(BaseDefinition* parent):
|
||||
parent(parent)
|
||||
{
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include "PackStream.h" // TODO Delete when c++ migration is done
|
||||
|
||||
namespace paysages {
|
||||
namespace system {class PackStream;}
|
||||
namespace definition {
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
#define LAYERS_H
|
||||
|
||||
#include "definition_global.h"
|
||||
|
||||
#include "PackStream.h"
|
||||
#include "LegacyLayer.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -11,6 +9,7 @@
|
|||
#include "BaseDefinition.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace system {class PackStream;}
|
||||
namespace definition {
|
||||
|
||||
class Layers;
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
#ifndef LEGACYLAYER_H
|
||||
#define LEGACYLAYER_H
|
||||
|
||||
#include <PackStream.h>
|
||||
#include <BaseDefinition.h>
|
||||
|
||||
namespace paysages {
|
||||
namespace system {class PackStream;}
|
||||
namespace definition {
|
||||
|
||||
typedef void* (*LayerCallbackCreate)();
|
||||
typedef void (*LayerCallbackDelete)(void* layer);
|
||||
|
@ -19,10 +23,6 @@ typedef struct {
|
|||
LayerCallbackLoad callback_load;
|
||||
} LayerType;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <BaseDefinition.h>
|
||||
|
||||
/**
|
||||
* @brief Wrapper around the old LayerType, used by C code.
|
||||
*/
|
||||
|
@ -49,6 +49,7 @@ private:
|
|||
char legacy_name[100];
|
||||
};
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif // LEGACYLAYER_H
|
||||
|
|
|
@ -407,18 +407,18 @@ void BasePreview::addOsd(QString name)
|
|||
|
||||
void BasePreview::savePack(PackStream* stream)
|
||||
{
|
||||
packWriteDouble(stream, &this->xoffset);
|
||||
packWriteDouble(stream, &this->yoffset);
|
||||
packWriteDouble(stream, &this->scalingbase);
|
||||
stream->write(&this->xoffset);
|
||||
stream->write(&this->yoffset);
|
||||
stream->write(&this->scalingbase);
|
||||
|
||||
// TODO Save choices and toggles
|
||||
}
|
||||
|
||||
void BasePreview::loadPack(PackStream* stream)
|
||||
{
|
||||
packReadDouble(stream, &this->xoffset);
|
||||
packReadDouble(stream, &this->yoffset);
|
||||
packReadDouble(stream, &this->scalingbase);
|
||||
stream->read(&this->xoffset);
|
||||
stream->read(&this->yoffset);
|
||||
stream->read(&this->scalingbase);
|
||||
|
||||
// TODO Save choices and toggles
|
||||
|
||||
|
|
|
@ -135,20 +135,20 @@ void FormRender::savePack(PackStream* stream)
|
|||
{
|
||||
BaseForm::savePack(stream);
|
||||
|
||||
packWriteInt(stream, &_params.width);
|
||||
packWriteInt(stream, &_params.height);
|
||||
packWriteInt(stream, &_params.antialias);
|
||||
packWriteInt(stream, &_params.quality);
|
||||
stream->write(&_params.width);
|
||||
stream->write(&_params.height);
|
||||
stream->write(&_params.antialias);
|
||||
stream->write(&_params.quality);
|
||||
}
|
||||
|
||||
void FormRender::loadPack(PackStream* stream)
|
||||
{
|
||||
BaseForm::loadPack(stream);
|
||||
|
||||
packReadInt(stream, &_params.width);
|
||||
packReadInt(stream, &_params.height);
|
||||
packReadInt(stream, &_params.antialias);
|
||||
packReadInt(stream, &_params.quality);
|
||||
stream->read(&_params.width);
|
||||
stream->read(&_params.height);
|
||||
stream->read(&_params.antialias);
|
||||
stream->read(&_params.quality);
|
||||
|
||||
revertConfig();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ CONFIG(release, debug|release): DEFINES += NDEBUG
|
|||
|
||||
INCLUDEPATH += $$PWD/..
|
||||
|
||||
SOURCES += main.c
|
||||
SOURCES += \
|
||||
main.cpp
|
||||
|
||||
HEADERS += main.h \
|
||||
exploring_global.h
|
||||
|
|
|
@ -10,7 +10,7 @@ SUBDIRS = \
|
|||
editing \
|
||||
controlling
|
||||
|
||||
unix:SUBDIRS += testing tests
|
||||
#unix:SUBDIRS += testing tests
|
||||
|
||||
basics.depends = system
|
||||
definition.depends = basics
|
||||
|
@ -18,5 +18,5 @@ rendering.depends = definition
|
|||
exploring.depends = rendering
|
||||
editing.depends = exploring rendering
|
||||
controlling.depends = rendering
|
||||
unix:testing.depends = rendering
|
||||
#unix:testing.depends = rendering
|
||||
unix:tests.depends = rendering
|
||||
|
|
|
@ -943,10 +943,9 @@ static int _tryLoadCache2D(Texture2D* tex, const char* tag, int order)
|
|||
cache = cacheFileCreateAccessor("atmo-br", "cache", tag, xsize, ysize, 0, 0, order);
|
||||
if (cacheFileIsReadable(cache))
|
||||
{
|
||||
PackStream* stream;
|
||||
stream = packReadFile(cacheFileGetPath(cache));
|
||||
texture2DLoad(stream, tex);
|
||||
packCloseStream(stream);
|
||||
PackStream stream;
|
||||
stream.bindToFile(cacheFileGetPath(cache));
|
||||
texture2DLoad(&stream, tex);
|
||||
|
||||
cacheFileDeleteAccessor(cache);
|
||||
return 1;
|
||||
|
@ -967,10 +966,9 @@ static void _saveCache2D(Texture2D* tex, const char* tag, int order)
|
|||
cache = cacheFileCreateAccessor("atmo-br", "cache", tag, xsize, ysize, 0, 0, order);
|
||||
if (cacheFileIsWritable(cache))
|
||||
{
|
||||
PackStream* stream;
|
||||
stream = packWriteFile(cacheFileGetPath(cache));
|
||||
texture2DSave(stream, tex);
|
||||
packCloseStream(stream);
|
||||
PackStream stream;
|
||||
stream.bindToFile(cacheFileGetPath(cache));
|
||||
texture2DSave(&stream, tex);
|
||||
}
|
||||
cacheFileDeleteAccessor(cache);
|
||||
}
|
||||
|
@ -998,10 +996,9 @@ static int _tryLoadCache4D(Texture4D* tex, const char* tag, int order)
|
|||
cache = cacheFileCreateAccessor("atmo-br", "cache", tag, xsize, ysize, zsize, wsize, order);
|
||||
if (cacheFileIsReadable(cache))
|
||||
{
|
||||
PackStream* stream;
|
||||
stream = packReadFile(cacheFileGetPath(cache));
|
||||
texture4DLoad(stream, tex);
|
||||
packCloseStream(stream);
|
||||
PackStream stream;
|
||||
stream.bindToFile(cacheFileGetPath(cache));
|
||||
texture4DLoad(&stream, tex);
|
||||
|
||||
cacheFileDeleteAccessor(cache);
|
||||
return 1;
|
||||
|
@ -1022,10 +1019,9 @@ static void _saveCache4D(Texture4D* tex, const char* tag, int order)
|
|||
cache = cacheFileCreateAccessor("atmo-br", "cache", tag, xsize, ysize, zsize, wsize, order);
|
||||
if (cacheFileIsWritable(cache))
|
||||
{
|
||||
PackStream* stream;
|
||||
stream = packWriteFile(cacheFileGetPath(cache));
|
||||
texture4DSave(stream, tex);
|
||||
packCloseStream(stream);
|
||||
PackStream stream;
|
||||
stream.bindToFile(cacheFileGetPath(cache));
|
||||
texture4DSave(&stream, tex);
|
||||
}
|
||||
cacheFileDeleteAccessor(cache);
|
||||
}
|
||||
|
|
|
@ -69,24 +69,24 @@ static void _copyDefinition(AtmosphereDefinition* source, AtmosphereDefinition*
|
|||
|
||||
static void _saveDefinition(PackStream* stream, AtmosphereDefinition* definition)
|
||||
{
|
||||
packWriteInt(stream, (int*)&definition->model);
|
||||
packWriteInt(stream, &definition->hour);
|
||||
packWriteInt(stream, &definition->minute);
|
||||
stream->write((int*)&definition->model);
|
||||
stream->write(&definition->hour);
|
||||
stream->write(&definition->minute);
|
||||
colorSave(stream, &definition->sun_color);
|
||||
packWriteDouble(stream, &definition->sun_radius);
|
||||
packWriteDouble(stream, &definition->dome_lighting);
|
||||
packWriteDouble(stream, &definition->humidity);
|
||||
stream->write(&definition->sun_radius);
|
||||
stream->write(&definition->dome_lighting);
|
||||
stream->write(&definition->humidity);
|
||||
}
|
||||
|
||||
static void _loadDefinition(PackStream* stream, AtmosphereDefinition* definition)
|
||||
{
|
||||
packReadInt(stream, (int*)&definition->model);
|
||||
packReadInt(stream, &definition->hour);
|
||||
packReadInt(stream, &definition->minute);
|
||||
stream->read((int*)&definition->model);
|
||||
stream->read(&definition->hour);
|
||||
stream->read(&definition->minute);
|
||||
colorLoad(stream, &definition->sun_color);
|
||||
packReadDouble(stream, &definition->sun_radius);
|
||||
packReadDouble(stream, &definition->dome_lighting);
|
||||
packReadDouble(stream, &definition->humidity);
|
||||
stream->read(&definition->sun_radius);
|
||||
stream->read(&definition->dome_lighting);
|
||||
stream->read(&definition->humidity);
|
||||
|
||||
_validateDefinition(definition);
|
||||
}
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
#include "../tools/lighting.h"
|
||||
#include "../tools/euclid.h"
|
||||
#include "../tools/color.h"
|
||||
#include "PackStream.h"
|
||||
#include "../shared/types.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace system {class PackStream;}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
@ -31,19 +31,19 @@ struct CameraDefinition
|
|||
void cameraSave(PackStream* stream, CameraDefinition* camera)
|
||||
{
|
||||
v3Save(stream, &camera->location);
|
||||
packWriteDouble(stream , &camera->direction.r);
|
||||
packWriteDouble(stream, &camera->direction.phi);
|
||||
packWriteDouble(stream, &camera->direction.theta);
|
||||
packWriteDouble(stream, &camera->roll);
|
||||
stream->write(&camera->direction.r);
|
||||
stream->write(&camera->direction.phi);
|
||||
stream->write(&camera->direction.theta);
|
||||
stream->write(&camera->roll);
|
||||
}
|
||||
|
||||
void cameraLoad(PackStream* stream, CameraDefinition* camera)
|
||||
{
|
||||
v3Load(stream, &camera->location);
|
||||
packReadDouble(stream, &camera->direction.r);
|
||||
packReadDouble(stream, &camera->direction.phi);
|
||||
packReadDouble(stream, &camera->direction.theta);
|
||||
packReadDouble(stream, &camera->roll);
|
||||
stream->read(&camera->direction.r);
|
||||
stream->read(&camera->direction.phi);
|
||||
stream->read(&camera->direction.theta);
|
||||
stream->read(&camera->roll);
|
||||
|
||||
cameraValidateDefinition(camera, 0);
|
||||
}
|
||||
|
|
|
@ -2,10 +2,13 @@
|
|||
#define _PAYSAGES_CAMERA_H_
|
||||
|
||||
#include "rendering_global.h"
|
||||
#include "PackStream.h"
|
||||
#include "tools/euclid.h"
|
||||
#include "tools/boundingbox.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace system {class PackStream;}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "private.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "PackStream.h"
|
||||
|
||||
/******************** Global definition ********************/
|
||||
static void _validateDefinition(CloudsDefinition* definition)
|
||||
|
@ -169,45 +170,45 @@ void _cloudsLayerSave(PackStream* stream, CloudsLayerDefinition* layer)
|
|||
{
|
||||
int clouds_type = (int)layer->type;
|
||||
|
||||
packWriteInt(stream, &clouds_type);
|
||||
packWriteDouble(stream, &layer->lower_altitude);
|
||||
packWriteDouble(stream, &layer->thickness);
|
||||
stream->write(&clouds_type);
|
||||
stream->write(&layer->lower_altitude);
|
||||
stream->write(&layer->thickness);
|
||||
curveSave(stream, layer->_coverage_by_altitude);
|
||||
noiseSaveGenerator(stream, layer->_coverage_noise);
|
||||
noiseSaveGenerator(stream, layer->_shape_noise);
|
||||
noiseSaveGenerator(stream, layer->_edge_noise);
|
||||
materialSave(stream, &layer->material);
|
||||
packWriteDouble(stream, &layer->hardness);
|
||||
packWriteDouble(stream, &layer->transparencydepth);
|
||||
packWriteDouble(stream, &layer->lighttraversal);
|
||||
packWriteDouble(stream, &layer->minimumlight);
|
||||
packWriteDouble(stream, &layer->shape_scaling);
|
||||
packWriteDouble(stream, &layer->edge_scaling);
|
||||
packWriteDouble(stream, &layer->edge_length);
|
||||
packWriteDouble(stream, &layer->base_coverage);
|
||||
stream->write(&layer->hardness);
|
||||
stream->write(&layer->transparencydepth);
|
||||
stream->write(&layer->lighttraversal);
|
||||
stream->write(&layer->minimumlight);
|
||||
stream->write(&layer->shape_scaling);
|
||||
stream->write(&layer->edge_scaling);
|
||||
stream->write(&layer->edge_length);
|
||||
stream->write(&layer->base_coverage);
|
||||
}
|
||||
|
||||
void _cloudsLayerLoad(PackStream* stream, CloudsLayerDefinition* layer)
|
||||
{
|
||||
int clouds_type;
|
||||
|
||||
packReadInt(stream, &clouds_type);
|
||||
stream->read(&clouds_type);
|
||||
layer->type = (CloudsType)clouds_type;
|
||||
packReadDouble(stream, &layer->lower_altitude);
|
||||
packReadDouble(stream, &layer->thickness);
|
||||
stream->read(&layer->lower_altitude);
|
||||
stream->read(&layer->thickness);
|
||||
curveLoad(stream, layer->_coverage_by_altitude);
|
||||
noiseLoadGenerator(stream, layer->_coverage_noise);
|
||||
noiseLoadGenerator(stream, layer->_shape_noise);
|
||||
noiseLoadGenerator(stream, layer->_edge_noise);
|
||||
materialLoad(stream, &layer->material);
|
||||
packReadDouble(stream, &layer->hardness);
|
||||
packReadDouble(stream, &layer->transparencydepth);
|
||||
packReadDouble(stream, &layer->lighttraversal);
|
||||
packReadDouble(stream, &layer->minimumlight);
|
||||
packReadDouble(stream, &layer->shape_scaling);
|
||||
packReadDouble(stream, &layer->edge_scaling);
|
||||
packReadDouble(stream, &layer->edge_length);
|
||||
packReadDouble(stream, &layer->base_coverage);
|
||||
stream->read(&layer->hardness);
|
||||
stream->read(&layer->transparencydepth);
|
||||
stream->read(&layer->lighttraversal);
|
||||
stream->read(&layer->minimumlight);
|
||||
stream->read(&layer->shape_scaling);
|
||||
stream->read(&layer->edge_scaling);
|
||||
stream->read(&layer->edge_length);
|
||||
stream->read(&layer->base_coverage);
|
||||
|
||||
cloudsLayerValidateDefinition(layer);
|
||||
}
|
||||
|
|
|
@ -38,18 +38,18 @@ void geoareaValidate(GeoArea* geoarea)
|
|||
|
||||
void geoareaSave(PackStream* stream, GeoArea* geoarea)
|
||||
{
|
||||
packWriteDouble(stream, &geoarea->location_x);
|
||||
packWriteDouble(stream, &geoarea->location_z);
|
||||
packWriteDouble(stream, &geoarea->size_x);
|
||||
packWriteDouble(stream, &geoarea->size_z);
|
||||
stream->write(&geoarea->location_x);
|
||||
stream->write(&geoarea->location_z);
|
||||
stream->write(&geoarea->size_x);
|
||||
stream->write(&geoarea->size_z);
|
||||
}
|
||||
|
||||
void geoareaLoad(PackStream* stream, GeoArea* geoarea)
|
||||
{
|
||||
packReadDouble(stream, &geoarea->location_x);
|
||||
packReadDouble(stream, &geoarea->location_z);
|
||||
packReadDouble(stream, &geoarea->size_x);
|
||||
packReadDouble(stream, &geoarea->size_z);
|
||||
stream->read(&geoarea->location_x);
|
||||
stream->read(&geoarea->location_z);
|
||||
stream->read(&geoarea->size_x);
|
||||
stream->read(&geoarea->size_z);
|
||||
}
|
||||
|
||||
void geoareaToLocal(GeoArea* geoarea, double absolute_x, double absolute_z, double* local_x, double* local_z)
|
||||
|
|
|
@ -33,53 +33,47 @@ void paysagesQuit()
|
|||
|
||||
FileOperationResult paysagesSave(char* filepath)
|
||||
{
|
||||
PackStream* stream = packWriteFile(filepath);
|
||||
PackStream stream;
|
||||
double app_header, version_header;
|
||||
|
||||
if (!stream)
|
||||
if (!stream.bindToFile(filepath, true))
|
||||
{
|
||||
return FILE_OPERATION_IOERROR;
|
||||
}
|
||||
|
||||
app_header = (double)APP_HEADER;
|
||||
packWriteDouble(stream, &app_header);
|
||||
stream.write(&app_header);
|
||||
version_header = (double)PAYSAGES_CURRENT_DATA_VERSION;
|
||||
packWriteDouble(stream, &version_header);
|
||||
stream.write(&version_header);
|
||||
|
||||
scenerySave(stream);
|
||||
|
||||
packCloseStream(stream);
|
||||
scenerySave(&stream);
|
||||
|
||||
return FILE_OPERATION_OK;
|
||||
}
|
||||
|
||||
FileOperationResult paysagesLoad(char* filepath)
|
||||
{
|
||||
PackStream* stream = packReadFile(filepath);
|
||||
PackStream stream;
|
||||
double app_header, version_header;
|
||||
|
||||
if (!stream)
|
||||
if (!stream.bindToFile(filepath, false))
|
||||
{
|
||||
return FILE_OPERATION_IOERROR;
|
||||
}
|
||||
|
||||
packReadDouble(stream, &app_header);
|
||||
stream.read(&app_header);
|
||||
if (app_header != APP_HEADER)
|
||||
{
|
||||
packCloseStream(stream);
|
||||
return FILE_OPERATION_APP_MISMATCH;
|
||||
}
|
||||
|
||||
packReadDouble(stream, &version_header);
|
||||
stream.read(&version_header);
|
||||
if ((int)version_header != PAYSAGES_CURRENT_DATA_VERSION)
|
||||
{
|
||||
packCloseStream(stream);
|
||||
return FILE_OPERATION_VERSION_MISMATCH;
|
||||
}
|
||||
|
||||
sceneryLoad(stream);
|
||||
|
||||
packCloseStream(stream);
|
||||
sceneryLoad(&stream);
|
||||
|
||||
return FILE_OPERATION_OK;
|
||||
}
|
||||
|
|
|
@ -96,23 +96,23 @@ void noiseSaveGenerator(PackStream* stream, NoiseGenerator* generator)
|
|||
int x;
|
||||
|
||||
x = (int)generator->function.algorithm;
|
||||
packWriteInt(stream, &x);
|
||||
packWriteDouble(stream, &generator->function.ridge_factor);
|
||||
packWriteDouble(stream, &generator->function.curve_factor);
|
||||
stream->write(&x);
|
||||
stream->write(&generator->function.ridge_factor);
|
||||
stream->write(&generator->function.curve_factor);
|
||||
|
||||
packWriteDouble(stream, &generator->height_offset);
|
||||
packWriteInt(stream, &generator->level_count);
|
||||
stream->write(&generator->height_offset);
|
||||
stream->write(&generator->level_count);
|
||||
|
||||
for (x = 0; x < generator->level_count; x++)
|
||||
{
|
||||
NoiseLevel* level = generator->levels + x;
|
||||
|
||||
packWriteDouble(stream, &level->wavelength);
|
||||
packWriteDouble(stream, &level->amplitude);
|
||||
packWriteDouble(stream, &level->minvalue);
|
||||
packWriteDouble(stream, &level->xoffset);
|
||||
packWriteDouble(stream, &level->yoffset);
|
||||
packWriteDouble(stream, &level->zoffset);
|
||||
stream->write(&level->wavelength);
|
||||
stream->write(&level->amplitude);
|
||||
stream->write(&level->minvalue);
|
||||
stream->write(&level->xoffset);
|
||||
stream->write(&level->yoffset);
|
||||
stream->write(&level->zoffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,24 +120,24 @@ void noiseLoadGenerator(PackStream* stream, NoiseGenerator* generator)
|
|||
{
|
||||
int x;
|
||||
|
||||
packReadInt(stream, &x);
|
||||
stream->read(&x);
|
||||
generator->function.algorithm = (NoiseFunctionAlgorithm)x;
|
||||
packReadDouble(stream, &generator->function.ridge_factor);
|
||||
packReadDouble(stream, &generator->function.curve_factor);
|
||||
stream->read(&generator->function.ridge_factor);
|
||||
stream->read(&generator->function.curve_factor);
|
||||
|
||||
packReadDouble(stream, &generator->height_offset);
|
||||
packReadInt(stream, &generator->level_count);
|
||||
stream->read(&generator->height_offset);
|
||||
stream->read(&generator->level_count);
|
||||
|
||||
for (x = 0; x < generator->level_count; x++)
|
||||
{
|
||||
NoiseLevel* level = generator->levels + x;
|
||||
|
||||
packReadDouble(stream, &level->wavelength);
|
||||
packReadDouble(stream, &level->amplitude);
|
||||
packReadDouble(stream, &level->minvalue);
|
||||
packReadDouble(stream, &level->xoffset);
|
||||
packReadDouble(stream, &level->yoffset);
|
||||
packReadDouble(stream, &level->zoffset);
|
||||
stream->read(&level->wavelength);
|
||||
stream->read(&level->amplitude);
|
||||
stream->read(&level->minvalue);
|
||||
stream->read(&level->xoffset);
|
||||
stream->read(&level->yoffset);
|
||||
stream->read(&level->zoffset);
|
||||
}
|
||||
|
||||
noiseValidate(generator);
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
#define _PAYSAGES_NOISE_H_
|
||||
|
||||
#include "rendering_global.h"
|
||||
#include "PackStream.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace system {class PackStream;}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -34,10 +34,10 @@ void noiseNaiveSave(PackStream* stream)
|
|||
{
|
||||
int i;
|
||||
|
||||
packWriteInt(stream, &_noise_pool_size);
|
||||
stream->write(&_noise_pool_size);
|
||||
for (i = 0; i < _noise_pool_size; i++)
|
||||
{
|
||||
packWriteDouble(stream, _noise_pool + i);
|
||||
stream->write(_noise_pool + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,12 +45,12 @@ void noiseNaiveLoad(PackStream* stream)
|
|||
{
|
||||
int i;
|
||||
|
||||
packReadInt(stream, &_noise_pool_size);
|
||||
stream->read(&_noise_pool_size);
|
||||
delete[] _noise_pool;
|
||||
_noise_pool = new double[_noise_pool_size];
|
||||
for (i = 0; i < _noise_pool_size; i++)
|
||||
{
|
||||
packReadDouble(stream, _noise_pool + i);
|
||||
stream->read(_noise_pool + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ RenderArea* renderCreateArea(Renderer* renderer)
|
|||
result->dirty_down = 1;
|
||||
result->dirty_up = -1;
|
||||
result->dirty_count = 0;
|
||||
result->lock = mutexCreate();
|
||||
result->lock = new Mutex();
|
||||
result->callback_start = _callbackStart;
|
||||
result->callback_draw = _callbackDraw;
|
||||
result->callback_update = _callbackUpdate;
|
||||
|
@ -132,7 +132,7 @@ RenderArea* renderCreateArea(Renderer* renderer)
|
|||
void renderDeleteArea(RenderArea* area)
|
||||
{
|
||||
colorProfileDelete(area->hdr_mapping);
|
||||
mutexDestroy(area->lock);
|
||||
delete area->lock;
|
||||
free(area->pixels);
|
||||
free(area);
|
||||
}
|
||||
|
@ -302,9 +302,9 @@ static void _processDirtyPixels(RenderArea* area)
|
|||
|
||||
void renderUpdate(RenderArea* area)
|
||||
{
|
||||
mutexAcquire(area->lock);
|
||||
area->lock->acquire();
|
||||
_processDirtyPixels(area);
|
||||
mutexRelease(area->lock);
|
||||
area->lock->release();
|
||||
}
|
||||
|
||||
static inline unsigned int _pushCallback(RenderArea* area, FragmentCallback callback)
|
||||
|
@ -541,9 +541,9 @@ void renderPushTriangle(RenderArea* area, Vector3 pixel1, Vector3 pixel2, Vector
|
|||
}
|
||||
|
||||
/* Prepare fragment callback */
|
||||
mutexAcquire(area->lock);
|
||||
area->lock->acquire();
|
||||
point1.callback = _pushCallback(area, fragment_callback);
|
||||
mutexRelease(area->lock);
|
||||
area->lock->release();
|
||||
|
||||
/* Prepare vertices */
|
||||
point1.pixel = pixel1;
|
||||
|
@ -578,9 +578,9 @@ void renderPushTriangle(RenderArea* area, Vector3 pixel1, Vector3 pixel2, Vector
|
|||
_pushScanLineEdge(area, &scanlines, &point3, &point1);
|
||||
|
||||
/* Commit scanlines to area */
|
||||
mutexAcquire(area->lock);
|
||||
area->lock->acquire();
|
||||
_renderScanLines(area, &scanlines);
|
||||
mutexRelease(area->lock);
|
||||
area->lock->release();
|
||||
|
||||
/* Free scalines */
|
||||
free(scanlines.up);
|
||||
|
@ -591,9 +591,9 @@ Color renderGetPixel(RenderArea* area, int x, int y)
|
|||
{
|
||||
Color result;
|
||||
|
||||
mutexAcquire(area->lock);
|
||||
area->lock->acquire();
|
||||
result = _getFinalPixel(area, x, y);
|
||||
mutexRelease(area->lock);
|
||||
area->lock->release();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -629,10 +629,10 @@ void* _renderPostProcessChunk(void* data)
|
|||
fragment->data.color.g = col.g;
|
||||
fragment->data.color.b = col.b;
|
||||
|
||||
mutexAcquire(chunk->area->lock);
|
||||
chunk->area->lock->acquire();
|
||||
fragment->flags.dirty = 0;
|
||||
_setDirtyPixel(chunk->area, x, y);
|
||||
mutexRelease(chunk->area->lock);
|
||||
chunk->area->lock->release();
|
||||
}
|
||||
chunk->area->pixel_done++;
|
||||
}
|
||||
|
@ -681,7 +681,7 @@ void renderPostProcess(RenderArea* area, int nbchunks)
|
|||
loops = 0;
|
||||
while ((x < nx && !area->renderer->render_interrupt) || running > 0)
|
||||
{
|
||||
timeSleepMs(50);
|
||||
Thread::timeSleepMs(50);
|
||||
|
||||
for (i = 0; i < nbchunks; i++)
|
||||
{
|
||||
|
@ -689,7 +689,8 @@ void renderPostProcess(RenderArea* area, int nbchunks)
|
|||
{
|
||||
if (chunks[i].finished)
|
||||
{
|
||||
threadJoin(chunks[i].thread);
|
||||
chunks[i].thread->join();
|
||||
delete chunks[i].thread;
|
||||
chunks[i].thread = NULL;
|
||||
running--;
|
||||
}
|
||||
|
@ -724,7 +725,8 @@ void renderPostProcess(RenderArea* area, int nbchunks)
|
|||
chunks[i].endy = (y + 1) * dy - 1;
|
||||
}
|
||||
|
||||
chunks[i].thread = threadCreate(_renderPostProcessChunk, (void*)(chunks + i));
|
||||
chunks[i].thread = new Thread(_renderPostProcessChunk);
|
||||
chunks[i].thread->start((void*)(chunks + i));
|
||||
running++;
|
||||
|
||||
if (++y >= ny)
|
||||
|
@ -737,9 +739,9 @@ void renderPostProcess(RenderArea* area, int nbchunks)
|
|||
|
||||
if (++loops >= 10)
|
||||
{
|
||||
mutexAcquire(area->lock);
|
||||
area->lock->acquire();
|
||||
_processDirtyPixels(area);
|
||||
mutexRelease(area->lock);
|
||||
area->lock->release();
|
||||
|
||||
loops = 0;
|
||||
}
|
||||
|
|
|
@ -184,9 +184,9 @@ void rendererSetPreviewCallbacks(Renderer* renderer, RenderCallbackStart start,
|
|||
|
||||
void rendererStart(Renderer* renderer, RenderParams params)
|
||||
{
|
||||
Thread* thread;
|
||||
Thread thread(_renderFirstPass);
|
||||
int loops;
|
||||
int core_count = systemGetCoreCount();
|
||||
int core_count = System::getCoreCount();
|
||||
|
||||
params.antialias = (params.antialias < 1) ? 1 : params.antialias;
|
||||
params.antialias = (params.antialias > 4) ? 4 : params.antialias;
|
||||
|
@ -204,12 +204,12 @@ void rendererStart(Renderer* renderer, RenderParams params)
|
|||
renderClear(renderer->render_area);
|
||||
|
||||
renderer->is_rendering = 1;
|
||||
thread = threadCreate(_renderFirstPass, renderer);
|
||||
thread.start(renderer);
|
||||
loops = 0;
|
||||
|
||||
while (renderer->is_rendering)
|
||||
{
|
||||
timeSleepMs(100);
|
||||
Thread::timeSleepMs(100);
|
||||
|
||||
if (++loops >= 10)
|
||||
{
|
||||
|
@ -218,7 +218,7 @@ void rendererStart(Renderer* renderer, RenderParams params)
|
|||
loops = 0;
|
||||
}
|
||||
}
|
||||
threadJoin(thread);
|
||||
thread.join();
|
||||
|
||||
renderer->is_rendering = 1;
|
||||
renderPostProcess(renderer->render_area, core_count);
|
||||
|
|
|
@ -66,21 +66,21 @@ static void _copyDefinition(TerrainDefinition* source, TerrainDefinition* destin
|
|||
|
||||
static void _saveDefinition(PackStream* stream, TerrainDefinition* definition)
|
||||
{
|
||||
packWriteDouble(stream, &definition->height);
|
||||
packWriteDouble(stream, &definition->scaling);
|
||||
packWriteDouble(stream, &definition->shadow_smoothing);
|
||||
stream->write(&definition->height);
|
||||
stream->write(&definition->scaling);
|
||||
stream->write(&definition->shadow_smoothing);
|
||||
terrainHeightmapSave(stream, definition->height_map);
|
||||
packWriteDouble(stream, &definition->water_height);
|
||||
stream->write(&definition->water_height);
|
||||
noiseSaveGenerator(stream, definition->_height_noise);
|
||||
}
|
||||
|
||||
static void _loadDefinition(PackStream* stream, TerrainDefinition* definition)
|
||||
{
|
||||
packReadDouble(stream, &definition->height);
|
||||
packReadDouble(stream, &definition->scaling);
|
||||
packReadDouble(stream, &definition->shadow_smoothing);
|
||||
stream->read(&definition->height);
|
||||
stream->read(&definition->scaling);
|
||||
stream->read(&definition->shadow_smoothing);
|
||||
terrainHeightmapLoad(stream, definition->height_map);
|
||||
packReadDouble(stream, &definition->water_height);
|
||||
stream->read(&definition->water_height);
|
||||
noiseLoadGenerator(stream, definition->_height_noise);
|
||||
|
||||
_validateDefinition(definition);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "../tools/memory.h"
|
||||
#include "../tools.h"
|
||||
#include "../tools/array.h"
|
||||
#include "PackStream.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -107,18 +108,18 @@ static void _copyData(HeightMapData* source, HeightMapData* destination)
|
|||
static void _saveData(PackStream* stream, HeightMapData* data)
|
||||
{
|
||||
int i, j, k;
|
||||
packWriteInt(stream, &data->rows_count);
|
||||
stream->write(&data->rows_count);
|
||||
for (i = 0; i < data->rows_count; i++)
|
||||
{
|
||||
packWriteInt(stream, &data->rows[i].z);
|
||||
packWriteInt(stream, &data->rows[i].pixel_groups_count);
|
||||
stream->write(&data->rows[i].z);
|
||||
stream->write(&data->rows[i].pixel_groups_count);
|
||||
for (j = 0; j < data->rows[i].pixel_groups_count; j++)
|
||||
{
|
||||
packWriteInt(stream, &data->rows[i].pixel_groups[j].xstart);
|
||||
packWriteInt(stream, &data->rows[i].pixel_groups[j].xend);
|
||||
stream->write(&data->rows[i].pixel_groups[j].xstart);
|
||||
stream->write(&data->rows[i].pixel_groups[j].xend);
|
||||
for (k = 0; k < data->rows[i].pixel_groups[j].xend - data->rows[i].pixel_groups[j].xstart; k++)
|
||||
{
|
||||
packWriteDouble(stream, &data->rows[i].pixel_groups[j].height[k]);
|
||||
stream->write(&data->rows[i].pixel_groups[j].height[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +132,7 @@ static void _loadData(PackStream* stream, HeightMapData* data)
|
|||
|
||||
_clearData(data);
|
||||
|
||||
packReadInt(stream, &data->rows_count);
|
||||
stream->read(&data->rows_count);
|
||||
if (data->rows_count > 0)
|
||||
{
|
||||
size = sizeof(HeightMapRow) * data->rows_count;
|
||||
|
@ -139,22 +140,22 @@ static void _loadData(PackStream* stream, HeightMapData* data)
|
|||
data->memsize += size;
|
||||
for (i = 0; i < data->rows_count; i++)
|
||||
{
|
||||
packReadInt(stream, &data->rows[i].z);
|
||||
packReadInt(stream, &data->rows[i].pixel_groups_count);
|
||||
stream->read(&data->rows[i].z);
|
||||
stream->read(&data->rows[i].pixel_groups_count);
|
||||
size = sizeof(HeightMapPixelGroup) * data->rows[i].pixel_groups_count;
|
||||
data->rows[i].pixel_groups = (HeightMapPixelGroup*)malloc(size);
|
||||
data->memsize += size;
|
||||
for (j = 0; j < data->rows[i].pixel_groups_count; j++)
|
||||
{
|
||||
packReadInt(stream, &data->rows[i].pixel_groups[j].xstart);
|
||||
packReadInt(stream, &data->rows[i].pixel_groups[j].xend);
|
||||
stream->read(&data->rows[i].pixel_groups[j].xstart);
|
||||
stream->read(&data->rows[i].pixel_groups[j].xend);
|
||||
n = data->rows[i].pixel_groups[j].xend - data->rows[i].pixel_groups[j].xstart;
|
||||
size = sizeof(double) * n;
|
||||
data->rows[i].pixel_groups[j].height = (double*)malloc(size);
|
||||
data->memsize += size;
|
||||
for (k = 0; k < n; k++)
|
||||
{
|
||||
packReadDouble(stream, &data->rows[i].pixel_groups[j].height[k]);
|
||||
stream->read(&data->rows[i].pixel_groups[j].height[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,9 +118,9 @@ static void _layerCopyDefinition(TexturesLayerDefinition* source, TexturesLayerD
|
|||
static void _layerSave(PackStream* stream, TexturesLayerDefinition* layer)
|
||||
{
|
||||
zoneSave(stream, layer->terrain_zone);
|
||||
packWriteDouble(stream, &layer->displacement_scaling);
|
||||
packWriteDouble(stream, &layer->displacement_height);
|
||||
packWriteDouble(stream, &layer->displacement_offset);
|
||||
stream->write(&layer->displacement_scaling);
|
||||
stream->write(&layer->displacement_height);
|
||||
stream->write(&layer->displacement_offset);
|
||||
materialSave(stream, &layer->material);
|
||||
|
||||
noiseSaveGenerator(stream, layer->_displacement_noise);
|
||||
|
@ -130,9 +130,9 @@ static void _layerSave(PackStream* stream, TexturesLayerDefinition* layer)
|
|||
static void _layerLoad(PackStream* stream, TexturesLayerDefinition* layer)
|
||||
{
|
||||
zoneLoad(stream, layer->terrain_zone);
|
||||
packReadDouble(stream, &layer->displacement_scaling);
|
||||
packReadDouble(stream, &layer->displacement_height);
|
||||
packReadDouble(stream, &layer->displacement_offset);
|
||||
stream->read(&layer->displacement_scaling);
|
||||
stream->read(&layer->displacement_height);
|
||||
stream->read(&layer->displacement_offset);
|
||||
materialLoad(stream, &layer->material);
|
||||
|
||||
noiseLoadGenerator(stream, layer->_displacement_noise);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "../tools.h"
|
||||
#include "PackStream.h"
|
||||
|
||||
/******************************** Color ********************************/
|
||||
|
||||
|
@ -18,18 +19,18 @@ Color COLOR_GREY = {0.5, 0.5, 0.5, 1.0};
|
|||
|
||||
void colorSave(PackStream* stream, Color* col)
|
||||
{
|
||||
packWriteDouble(stream, &col->r);
|
||||
packWriteDouble(stream, &col->g);
|
||||
packWriteDouble(stream, &col->b);
|
||||
packWriteDouble(stream, &col->a);
|
||||
stream->write(&col->r);
|
||||
stream->write(&col->g);
|
||||
stream->write(&col->b);
|
||||
stream->write(&col->a);
|
||||
}
|
||||
|
||||
void colorLoad(PackStream* stream, Color* col)
|
||||
{
|
||||
packReadDouble(stream, &col->r);
|
||||
packReadDouble(stream, &col->g);
|
||||
packReadDouble(stream, &col->b);
|
||||
packReadDouble(stream, &col->a);
|
||||
stream->read(&col->r);
|
||||
stream->read(&col->g);
|
||||
stream->read(&col->b);
|
||||
stream->read(&col->a);
|
||||
}
|
||||
|
||||
Color colorFromValues(double r, double g, double b, double a)
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
|
||||
#include "../rendering_global.h"
|
||||
#include "curve.h"
|
||||
#include "PackStream.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace system {class PackStream;}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "../tools.h"
|
||||
#include "PackStream.h"
|
||||
|
||||
#define MAX_NB_POINTS 40
|
||||
|
||||
|
@ -38,12 +39,12 @@ void curveSave(PackStream* stream, Curve* curve)
|
|||
{
|
||||
int i;
|
||||
|
||||
packWriteDouble(stream, &curve->default_value);
|
||||
packWriteInt(stream, &curve->nbpoints);
|
||||
stream->write(&curve->default_value);
|
||||
stream->write(&curve->nbpoints);
|
||||
for (i = 0; i < curve->nbpoints; i++)
|
||||
{
|
||||
packWriteDouble(stream, &curve->points[i].position);
|
||||
packWriteDouble(stream, &curve->points[i].value);
|
||||
stream->write(&curve->points[i].position);
|
||||
stream->write(&curve->points[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,12 +52,12 @@ void curveLoad(PackStream* stream, Curve* curve)
|
|||
{
|
||||
int i;
|
||||
|
||||
packReadDouble(stream, &curve->default_value);
|
||||
packReadInt(stream, &curve->nbpoints);
|
||||
stream->read(&curve->default_value);
|
||||
stream->read(&curve->nbpoints);
|
||||
for (i = 0; i < curve->nbpoints; i++)
|
||||
{
|
||||
packReadDouble(stream, &curve->points[i].position);
|
||||
packReadDouble(stream, &curve->points[i].value);
|
||||
stream->read(&curve->points[i].position);
|
||||
stream->read(&curve->points[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
#define _PAYSAGES_TOOLS_CURVE_H_
|
||||
|
||||
#include "../rendering_global.h"
|
||||
#include "PackStream.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace system {class PackStream;}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <math.h>
|
||||
#include "../tools.h"
|
||||
#include "PackStream.h"
|
||||
|
||||
Vector3 VECTOR_ZERO = {0.0, 0.0, 0.0};
|
||||
Vector3 VECTOR_DOWN = {0.0, -1.0, 0.0};
|
||||
|
@ -13,16 +14,16 @@ Vector3 VECTOR_EAST = {1.0, 0.0, 0.0};
|
|||
|
||||
void v3Save(PackStream* stream, Vector3* v)
|
||||
{
|
||||
packWriteDouble(stream, &v->x);
|
||||
packWriteDouble(stream, &v->y);
|
||||
packWriteDouble(stream, &v->z);
|
||||
stream->write(&v->x);
|
||||
stream->write(&v->y);
|
||||
stream->write(&v->z);
|
||||
}
|
||||
|
||||
void v3Load(PackStream* stream, Vector3* v)
|
||||
{
|
||||
packReadDouble(stream, &v->x);
|
||||
packReadDouble(stream, &v->y);
|
||||
packReadDouble(stream, &v->z);
|
||||
stream->read(&v->x);
|
||||
stream->read(&v->y);
|
||||
stream->read(&v->z);
|
||||
}
|
||||
|
||||
Vector3 v3Translate(Vector3 v1, double x, double y, double z)
|
||||
|
@ -125,42 +126,42 @@ Vector3 v3FromSpherical(VectorSpherical v)
|
|||
|
||||
void m4Save(PackStream* stream, Matrix4* m)
|
||||
{
|
||||
packWriteDouble(stream, &m->a);
|
||||
packWriteDouble(stream, &m->b);
|
||||
packWriteDouble(stream, &m->c);
|
||||
packWriteDouble(stream, &m->d);
|
||||
packWriteDouble(stream, &m->e);
|
||||
packWriteDouble(stream, &m->f);
|
||||
packWriteDouble(stream, &m->g);
|
||||
packWriteDouble(stream, &m->h);
|
||||
packWriteDouble(stream, &m->i);
|
||||
packWriteDouble(stream, &m->j);
|
||||
packWriteDouble(stream, &m->k);
|
||||
packWriteDouble(stream, &m->l);
|
||||
packWriteDouble(stream, &m->m);
|
||||
packWriteDouble(stream, &m->n);
|
||||
packWriteDouble(stream, &m->o);
|
||||
packWriteDouble(stream, &m->p);
|
||||
stream->write(&m->a);
|
||||
stream->write(&m->b);
|
||||
stream->write(&m->c);
|
||||
stream->write(&m->d);
|
||||
stream->write(&m->e);
|
||||
stream->write(&m->f);
|
||||
stream->write(&m->g);
|
||||
stream->write(&m->h);
|
||||
stream->write(&m->i);
|
||||
stream->write(&m->j);
|
||||
stream->write(&m->k);
|
||||
stream->write(&m->l);
|
||||
stream->write(&m->m);
|
||||
stream->write(&m->n);
|
||||
stream->write(&m->o);
|
||||
stream->write(&m->p);
|
||||
}
|
||||
|
||||
void m4Load(PackStream* stream, Matrix4* m)
|
||||
{
|
||||
packReadDouble(stream, &m->a);
|
||||
packReadDouble(stream, &m->b);
|
||||
packReadDouble(stream, &m->c);
|
||||
packReadDouble(stream, &m->d);
|
||||
packReadDouble(stream, &m->e);
|
||||
packReadDouble(stream, &m->f);
|
||||
packReadDouble(stream, &m->g);
|
||||
packReadDouble(stream, &m->h);
|
||||
packReadDouble(stream, &m->i);
|
||||
packReadDouble(stream, &m->j);
|
||||
packReadDouble(stream, &m->k);
|
||||
packReadDouble(stream, &m->l);
|
||||
packReadDouble(stream, &m->m);
|
||||
packReadDouble(stream, &m->n);
|
||||
packReadDouble(stream, &m->o);
|
||||
packReadDouble(stream, &m->p);
|
||||
stream->read(&m->a);
|
||||
stream->read(&m->b);
|
||||
stream->read(&m->c);
|
||||
stream->read(&m->d);
|
||||
stream->read(&m->e);
|
||||
stream->read(&m->f);
|
||||
stream->read(&m->g);
|
||||
stream->read(&m->h);
|
||||
stream->read(&m->i);
|
||||
stream->read(&m->j);
|
||||
stream->read(&m->k);
|
||||
stream->read(&m->l);
|
||||
stream->read(&m->m);
|
||||
stream->read(&m->n);
|
||||
stream->read(&m->o);
|
||||
stream->read(&m->p);
|
||||
}
|
||||
|
||||
Matrix4 m4NewIdentity()
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
#define _PAYSAGES_TOOLS_EUCLID_H_
|
||||
|
||||
#include "../rendering_global.h"
|
||||
#include "PackStream.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace system {class PackStream;}
|
||||
}
|
||||
|
||||
/*
|
||||
* Cartesian coordinates (X, Y, Z) - right handed :
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "PackStream.h"
|
||||
|
||||
#define MAX_CALLBACK_COUNT 10
|
||||
#define MAX_LIGHT_COUNT 30
|
||||
|
@ -215,28 +216,28 @@ Vector3 lightingGetStatusLocation(LightStatus* status)
|
|||
|
||||
void materialSave(PackStream* stream, SurfaceMaterial* material)
|
||||
{
|
||||
packWriteDouble(stream, &material->base.h);
|
||||
packWriteDouble(stream, &material->base.l);
|
||||
packWriteDouble(stream, &material->base.s);
|
||||
stream->write(&material->base.h);
|
||||
stream->write(&material->base.l);
|
||||
stream->write(&material->base.s);
|
||||
|
||||
packWriteDouble(stream, &material->hardness);
|
||||
packWriteDouble(stream, &material->reflection);
|
||||
packWriteDouble(stream, &material->shininess);
|
||||
stream->write(&material->hardness);
|
||||
stream->write(&material->reflection);
|
||||
stream->write(&material->shininess);
|
||||
|
||||
packWriteDouble(stream, &material->receive_shadows);
|
||||
stream->write(&material->receive_shadows);
|
||||
}
|
||||
|
||||
void materialLoad(PackStream* stream, SurfaceMaterial* material)
|
||||
{
|
||||
packReadDouble(stream, &material->base.h);
|
||||
packReadDouble(stream, &material->base.l);
|
||||
packReadDouble(stream, &material->base.s);
|
||||
stream->read(&material->base.h);
|
||||
stream->read(&material->base.l);
|
||||
stream->read(&material->base.s);
|
||||
|
||||
packReadDouble(stream, &material->hardness);
|
||||
packReadDouble(stream, &material->reflection);
|
||||
packReadDouble(stream, &material->shininess);
|
||||
stream->read(&material->hardness);
|
||||
stream->read(&material->reflection);
|
||||
stream->read(&material->shininess);
|
||||
|
||||
packReadDouble(stream, &material->receive_shadows);
|
||||
stream->read(&material->receive_shadows);
|
||||
|
||||
materialValidate(material);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
#include "../rendering_global.h"
|
||||
#include "euclid.h"
|
||||
#include "color.h"
|
||||
#include "PackStream.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace system {class PackStream;}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -73,7 +73,8 @@ static int _runNextWorker(ParallelWorker workers[], int worker_count, int unit)
|
|||
worker->status = PARALLEL_WORKER_STATUS_RUNNING;
|
||||
worker->result = 0;
|
||||
worker->unit = unit;
|
||||
worker->thread = threadCreate((ThreadFunction)_workerThreadCallback, worker);
|
||||
worker->thread = new Thread((ThreadFunction)_workerThreadCallback);
|
||||
worker->thread->start(worker);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -84,13 +85,15 @@ static int _runNextWorker(ParallelWorker workers[], int worker_count, int unit)
|
|||
worker->status = PARALLEL_WORKER_STATUS_RUNNING;
|
||||
worker->result = 0;
|
||||
worker->unit = unit;
|
||||
threadJoin(worker->thread);
|
||||
worker->thread = threadCreate((ThreadFunction)_workerThreadCallback, worker);
|
||||
worker->thread->join();
|
||||
delete worker->thread;
|
||||
worker->thread = new Thread((ThreadFunction)_workerThreadCallback);
|
||||
worker->thread->start(worker);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
timeSleepMs(50);
|
||||
Thread::timeSleepMs(50);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +106,7 @@ int parallelWorkPerform(ParallelWork* work, int workers)
|
|||
|
||||
if (workers <= 0)
|
||||
{
|
||||
workers = systemGetCoreCount();
|
||||
workers = System::getCoreCount();
|
||||
}
|
||||
if (workers > PARALLEL_MAX_THREADS)
|
||||
{
|
||||
|
@ -132,7 +135,8 @@ int parallelWorkPerform(ParallelWork* work, int workers)
|
|||
{
|
||||
if (work->workers[i].status != PARALLEL_WORKER_STATUS_VOID)
|
||||
{
|
||||
threadJoin(work->workers[i].thread);
|
||||
work->workers[i].thread->join();
|
||||
delete work->workers[i].thread;
|
||||
if (work->workers[i].result)
|
||||
{
|
||||
result++;
|
||||
|
@ -187,7 +191,7 @@ static void* _queueThreadCallback(ParallelQueue* queue)
|
|||
while (!queue->stopping)
|
||||
{
|
||||
/* Try to take a job */
|
||||
mutexAcquire(queue->lock);
|
||||
queue->lock->acquire();
|
||||
job = queue->jobs + queue->jobs_index_pending;
|
||||
if (job->state == JOB_STATE_PENDING)
|
||||
{
|
||||
|
@ -205,14 +209,14 @@ static void* _queueThreadCallback(ParallelQueue* queue)
|
|||
{
|
||||
job = NULL;
|
||||
}
|
||||
mutexRelease(queue->lock);
|
||||
queue->lock->release();
|
||||
|
||||
if (job)
|
||||
{
|
||||
/* Process the job */
|
||||
job->process(queue, job->id, job->data, 0);
|
||||
|
||||
mutexAcquire(queue->lock);
|
||||
queue->lock->acquire();
|
||||
if (queue->collect)
|
||||
{
|
||||
job->state = JOB_STATE_TOCOLLECT;
|
||||
|
@ -223,11 +227,11 @@ static void* _queueThreadCallback(ParallelQueue* queue)
|
|||
job->state = JOB_STATE_FREE;
|
||||
queue->jobs_count--;
|
||||
}
|
||||
mutexRelease(queue->lock);
|
||||
queue->lock->release();
|
||||
}
|
||||
else
|
||||
{
|
||||
timeSleepMs(50);
|
||||
Thread::timeSleepMs(50);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
@ -243,7 +247,7 @@ ParallelQueue* parallelQueueCreate(int collect)
|
|||
|
||||
queue->collect = collect;
|
||||
queue->stopping = 0;
|
||||
queue->lock = mutexCreate();
|
||||
queue->lock = new Mutex();
|
||||
|
||||
queue->jobs = new ParallelJob[QUEUE_SIZE];
|
||||
for (i = 0; i < QUEUE_SIZE; i++)
|
||||
|
@ -257,11 +261,12 @@ ParallelQueue* parallelQueueCreate(int collect)
|
|||
queue->jobs_next_id = 1;
|
||||
|
||||
/* Start workers */
|
||||
queue->workers_count = systemGetCoreCount();
|
||||
queue->workers_count = System::getCoreCount();
|
||||
queue->workers = new Thread*[queue->workers_count];
|
||||
for (i = 0; i < queue->workers_count; i++)
|
||||
{
|
||||
queue->workers[i] = threadCreate((ThreadFunction)_queueThreadCallback, queue);
|
||||
queue->workers[i] = new Thread((ThreadFunction)_queueThreadCallback);
|
||||
queue->workers[i]->start(queue);
|
||||
}
|
||||
|
||||
return queue;
|
||||
|
@ -274,7 +279,7 @@ void parallelQueueDelete(ParallelQueue* queue)
|
|||
assert(!queue->collect || queue->jobs[queue->jobs_index_collect].state != JOB_STATE_TOCOLLECT);
|
||||
assert(queue->jobs_count == 0);
|
||||
|
||||
mutexDestroy(queue->lock);
|
||||
delete queue->lock;
|
||||
delete[] queue->jobs;
|
||||
delete[] queue->workers;
|
||||
delete queue;
|
||||
|
@ -290,7 +295,8 @@ void parallelQueueInterrupt(ParallelQueue* queue)
|
|||
|
||||
for (i = 0; i < queue->workers_count; i++)
|
||||
{
|
||||
threadJoin(queue->workers[i]);
|
||||
queue->workers[i]->join();
|
||||
delete queue->workers[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +305,7 @@ void parallelQueueWait(ParallelQueue* queue)
|
|||
{
|
||||
while (queue->jobs_count > 0)
|
||||
{
|
||||
timeSleepMs(100);
|
||||
Thread::timeSleepMs(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,7 +319,7 @@ int parallelQueueAddJob(ParallelQueue* queue, FuncParallelJob func_process, void
|
|||
/* Wait for a free slot */
|
||||
while (queue->jobs[queue->jobs_index_free].state != JOB_STATE_FREE)
|
||||
{
|
||||
timeSleepMs(50);
|
||||
Thread::timeSleepMs(50);
|
||||
if (queue->stopping)
|
||||
{
|
||||
return 0;
|
||||
|
@ -328,10 +334,10 @@ int parallelQueueAddJob(ParallelQueue* queue, FuncParallelJob func_process, void
|
|||
job.data = data;
|
||||
|
||||
/* Add the job to the queue */
|
||||
mutexAcquire(queue->lock);
|
||||
queue->lock->acquire();
|
||||
if (queue->stopping)
|
||||
{
|
||||
mutexRelease(queue->lock);
|
||||
queue->lock->release();
|
||||
return 0;
|
||||
}
|
||||
queue->jobs[queue->jobs_index_free] = job;
|
||||
|
@ -345,7 +351,7 @@ int parallelQueueAddJob(ParallelQueue* queue, FuncParallelJob func_process, void
|
|||
}
|
||||
queue->jobs_count++;
|
||||
assert(queue->jobs_count <= QUEUE_SIZE);
|
||||
mutexRelease(queue->lock);
|
||||
queue->lock->release();
|
||||
|
||||
return job.id;
|
||||
}
|
||||
|
|
|
@ -171,8 +171,8 @@ void texture2DAdd(Texture2D* source, Texture2D* destination)
|
|||
void texture2DSave(PackStream* stream, Texture2D* tex)
|
||||
{
|
||||
int i, n;
|
||||
packWriteInt(stream, &tex->xsize);
|
||||
packWriteInt(stream, &tex->ysize);
|
||||
stream->write(&tex->xsize);
|
||||
stream->write(&tex->ysize);
|
||||
n = tex->xsize * tex->ysize;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
|
@ -183,8 +183,8 @@ void texture2DSave(PackStream* stream, Texture2D* tex)
|
|||
void texture2DLoad(PackStream* stream, Texture2D* tex)
|
||||
{
|
||||
int i, n;
|
||||
packReadInt(stream, &tex->xsize);
|
||||
packReadInt(stream, &tex->ysize);
|
||||
stream->read(&tex->xsize);
|
||||
stream->read(&tex->ysize);
|
||||
n = tex->xsize * tex->ysize;
|
||||
delete[] tex->data;
|
||||
tex->data = new Color[n];
|
||||
|
@ -352,9 +352,9 @@ void texture3DAdd(Texture3D* source, Texture3D* destination)
|
|||
void texture3DSave(PackStream* stream, Texture3D* tex)
|
||||
{
|
||||
int i, n;
|
||||
packWriteInt(stream, &tex->xsize);
|
||||
packWriteInt(stream, &tex->ysize);
|
||||
packWriteInt(stream, &tex->zsize);
|
||||
stream->write(&tex->xsize);
|
||||
stream->write(&tex->ysize);
|
||||
stream->write(&tex->zsize);
|
||||
n = tex->xsize * tex->ysize * tex->zsize;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
|
@ -365,9 +365,9 @@ void texture3DSave(PackStream* stream, Texture3D* tex)
|
|||
void texture3DLoad(PackStream* stream, Texture3D* tex)
|
||||
{
|
||||
int i, n;
|
||||
packReadInt(stream, &tex->xsize);
|
||||
packReadInt(stream, &tex->ysize);
|
||||
packReadInt(stream, &tex->zsize);
|
||||
stream->read(&tex->xsize);
|
||||
stream->read(&tex->ysize);
|
||||
stream->read(&tex->zsize);
|
||||
n = tex->xsize * tex->ysize * tex->zsize;
|
||||
delete[] tex->data;
|
||||
tex->data = new Color[n];
|
||||
|
@ -578,10 +578,10 @@ void texture4DAdd(Texture4D* source, Texture4D* destination)
|
|||
void texture4DSave(PackStream* stream, Texture4D* tex)
|
||||
{
|
||||
int i, n;
|
||||
packWriteInt(stream, &tex->xsize);
|
||||
packWriteInt(stream, &tex->ysize);
|
||||
packWriteInt(stream, &tex->zsize);
|
||||
packWriteInt(stream, &tex->wsize);
|
||||
stream->write(&tex->xsize);
|
||||
stream->write(&tex->ysize);
|
||||
stream->write(&tex->zsize);
|
||||
stream->write(&tex->wsize);
|
||||
n = tex->xsize * tex->ysize * tex->zsize * tex->wsize;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
|
@ -592,10 +592,10 @@ void texture4DSave(PackStream* stream, Texture4D* tex)
|
|||
void texture4DLoad(PackStream* stream, Texture4D* tex)
|
||||
{
|
||||
int i, n;
|
||||
packReadInt(stream, &tex->xsize);
|
||||
packReadInt(stream, &tex->ysize);
|
||||
packReadInt(stream, &tex->zsize);
|
||||
packReadInt(stream, &tex->wsize);
|
||||
stream->read(&tex->xsize);
|
||||
stream->read(&tex->ysize);
|
||||
stream->read(&tex->zsize);
|
||||
stream->read(&tex->wsize);
|
||||
n = tex->xsize * tex->ysize * tex->zsize * tex->wsize;
|
||||
delete[] tex->data;
|
||||
tex->data = new Color[n];
|
||||
|
|
|
@ -55,22 +55,22 @@ void zoneSave(PackStream* stream, Zone* zone)
|
|||
{
|
||||
int i;
|
||||
|
||||
packWriteInt(stream, &zone->absolute_height);
|
||||
packWriteDouble(stream, &zone->relative_height_min);
|
||||
packWriteDouble(stream, &zone->relative_height_middle);
|
||||
packWriteDouble(stream, &zone->relative_height_max);
|
||||
stream->write(&zone->absolute_height);
|
||||
stream->write(&zone->relative_height_min);
|
||||
stream->write(&zone->relative_height_middle);
|
||||
stream->write(&zone->relative_height_max);
|
||||
|
||||
curveSave(stream, zone->value_by_height);
|
||||
curveSave(stream, zone->value_by_slope);
|
||||
|
||||
packWriteInt(stream, &zone->circles_included_count);
|
||||
stream->write(&zone->circles_included_count);
|
||||
for (i = 0; i < zone->circles_included_count; i++)
|
||||
{
|
||||
packWriteDouble(stream, &zone->circles_included[i].value);
|
||||
packWriteDouble(stream, &zone->circles_included[i].centerx);
|
||||
packWriteDouble(stream, &zone->circles_included[i].centerz);
|
||||
packWriteDouble(stream, &zone->circles_included[i].softradius);
|
||||
packWriteDouble(stream, &zone->circles_included[i].hardradius);
|
||||
stream->write(&zone->circles_included[i].value);
|
||||
stream->write(&zone->circles_included[i].centerx);
|
||||
stream->write(&zone->circles_included[i].centerz);
|
||||
stream->write(&zone->circles_included[i].softradius);
|
||||
stream->write(&zone->circles_included[i].hardradius);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,22 +78,22 @@ void zoneLoad(PackStream* stream, Zone* zone)
|
|||
{
|
||||
int i;
|
||||
|
||||
packReadInt(stream, &zone->absolute_height);
|
||||
packReadDouble(stream, &zone->relative_height_min);
|
||||
packReadDouble(stream, &zone->relative_height_middle);
|
||||
packReadDouble(stream, &zone->relative_height_max);
|
||||
stream->read(&zone->absolute_height);
|
||||
stream->read(&zone->relative_height_min);
|
||||
stream->read(&zone->relative_height_middle);
|
||||
stream->read(&zone->relative_height_max);
|
||||
|
||||
curveLoad(stream, zone->value_by_height);
|
||||
curveLoad(stream, zone->value_by_slope);
|
||||
|
||||
packReadInt(stream, &zone->circles_included_count);
|
||||
stream->read(&zone->circles_included_count);
|
||||
for (i = 0; i < zone->circles_included_count; i++)
|
||||
{
|
||||
packReadDouble(stream, &zone->circles_included[i].value);
|
||||
packReadDouble(stream, &zone->circles_included[i].centerx);
|
||||
packReadDouble(stream, &zone->circles_included[i].centerz);
|
||||
packReadDouble(stream, &zone->circles_included[i].softradius);
|
||||
packReadDouble(stream, &zone->circles_included[i].hardradius);
|
||||
stream->read(&zone->circles_included[i].value);
|
||||
stream->read(&zone->circles_included[i].centerx);
|
||||
stream->read(&zone->circles_included[i].centerz);
|
||||
stream->read(&zone->circles_included[i].softradius);
|
||||
stream->read(&zone->circles_included[i].hardradius);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "private.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "PackStream.h"
|
||||
|
||||
static void _validateDefinition(WaterDefinition* definition)
|
||||
{
|
||||
|
@ -52,17 +53,17 @@ static void _saveDefinition(PackStream* stream, WaterDefinition* definition)
|
|||
{
|
||||
materialSave(stream, &definition->material);
|
||||
colorSave(stream, &definition->depth_color);
|
||||
packWriteDouble(stream, &definition->transparency_depth);
|
||||
packWriteDouble(stream, &definition->transparency);
|
||||
packWriteDouble(stream, &definition->reflection);
|
||||
packWriteDouble(stream, &definition->lighting_depth);
|
||||
stream->write(&definition->transparency_depth);
|
||||
stream->write(&definition->transparency);
|
||||
stream->write(&definition->reflection);
|
||||
stream->write(&definition->lighting_depth);
|
||||
|
||||
packWriteDouble(stream, &definition->scaling);
|
||||
packWriteDouble(stream, &definition->waves_height);
|
||||
packWriteDouble(stream, &definition->detail_height);
|
||||
packWriteDouble(stream, &definition->turbulence);
|
||||
stream->write(&definition->scaling);
|
||||
stream->write(&definition->waves_height);
|
||||
stream->write(&definition->detail_height);
|
||||
stream->write(&definition->turbulence);
|
||||
|
||||
packWriteDouble(stream, &definition->foam_coverage);
|
||||
stream->write(&definition->foam_coverage);
|
||||
materialSave(stream, &definition->foam_material);
|
||||
|
||||
noiseSaveGenerator(stream, definition->_waves_noise);
|
||||
|
@ -72,17 +73,17 @@ static void _loadDefinition(PackStream* stream, WaterDefinition* definition)
|
|||
{
|
||||
materialLoad(stream, &definition->material);
|
||||
colorLoad(stream, &definition->depth_color);
|
||||
packReadDouble(stream, &definition->transparency_depth);
|
||||
packReadDouble(stream, &definition->transparency);
|
||||
packReadDouble(stream, &definition->reflection);
|
||||
packReadDouble(stream, &definition->lighting_depth);
|
||||
stream->read(&definition->transparency_depth);
|
||||
stream->read(&definition->transparency);
|
||||
stream->read(&definition->reflection);
|
||||
stream->read(&definition->lighting_depth);
|
||||
|
||||
packReadDouble(stream, &definition->scaling);
|
||||
packReadDouble(stream, &definition->waves_height);
|
||||
packReadDouble(stream, &definition->detail_height);
|
||||
packReadDouble(stream, &definition->turbulence);
|
||||
stream->read(&definition->scaling);
|
||||
stream->read(&definition->waves_height);
|
||||
stream->read(&definition->detail_height);
|
||||
stream->read(&definition->turbulence);
|
||||
|
||||
packReadDouble(stream, &definition->foam_coverage);
|
||||
stream->read(&definition->foam_coverage);
|
||||
materialLoad(stream, &definition->foam_material);
|
||||
|
||||
noiseLoadGenerator(stream, definition->_waves_noise);
|
||||
|
|
|
@ -3,25 +3,3 @@
|
|||
Mutex::Mutex()
|
||||
{
|
||||
}
|
||||
|
||||
// Transitional C-API
|
||||
|
||||
Mutex* mutexCreate()
|
||||
{
|
||||
return new Mutex();
|
||||
}
|
||||
|
||||
void mutexDestroy(Mutex* mutex)
|
||||
{
|
||||
delete mutex;
|
||||
}
|
||||
|
||||
void mutexAcquire(Mutex* mutex)
|
||||
{
|
||||
mutex->acquire();
|
||||
}
|
||||
|
||||
void mutexRelease(Mutex* mutex)
|
||||
{
|
||||
mutex->release();
|
||||
}
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define MUTEX_H
|
||||
|
||||
#include "system_global.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <QMutex>
|
||||
|
||||
namespace paysages
|
||||
|
@ -30,22 +27,4 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Transitional C-API
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef struct Mutex Mutex;
|
||||
#endif
|
||||
|
||||
SYSTEMSHARED_EXPORT Mutex* mutexCreate();
|
||||
SYSTEMSHARED_EXPORT void mutexDestroy(Mutex* mutex);
|
||||
SYSTEMSHARED_EXPORT void mutexAcquire(Mutex* mutex);
|
||||
SYSTEMSHARED_EXPORT void mutexRelease(Mutex* mutex);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // MUTEX_H
|
||||
|
|
|
@ -22,15 +22,19 @@ PackStream::~PackStream()
|
|||
}
|
||||
}
|
||||
|
||||
void PackStream::bindToFile(const char* filepath, bool write)
|
||||
bool PackStream::bindToFile(const char* filepath, bool write)
|
||||
{
|
||||
if (not file and not stream)
|
||||
{
|
||||
file = new QFile(filepath);
|
||||
file->open(write ? QIODevice::WriteOnly : QIODevice::ReadOnly);
|
||||
if (not file->open(write ? QIODevice::WriteOnly : QIODevice::ReadOnly))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stream = new QDataStream(file);
|
||||
}
|
||||
return stream != NULL;
|
||||
}
|
||||
|
||||
void PackStream::write(int* value)
|
||||
|
@ -110,54 +114,3 @@ QString PackStream::readString()
|
|||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
// Transitional C-API
|
||||
|
||||
PackStream* packReadFile(const char* filepath)
|
||||
{
|
||||
PackStream* result = new PackStream();
|
||||
result->bindToFile(filepath, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
PackStream* packWriteFile(const char* filepath)
|
||||
{
|
||||
PackStream* result = new PackStream();
|
||||
result->bindToFile(filepath, true);
|
||||
return result;
|
||||
}
|
||||
|
||||
void packCloseStream(PackStream* stream)
|
||||
{
|
||||
delete stream;
|
||||
}
|
||||
|
||||
void packWriteDouble(PackStream* stream, double* value)
|
||||
{
|
||||
stream->write(value);
|
||||
}
|
||||
|
||||
void packReadDouble(PackStream* stream, double* value)
|
||||
{
|
||||
stream->read(value);
|
||||
}
|
||||
|
||||
void packWriteInt(PackStream* stream, int* value)
|
||||
{
|
||||
stream->write(value);
|
||||
}
|
||||
|
||||
void packReadInt(PackStream* stream, int* value)
|
||||
{
|
||||
stream->read(value);
|
||||
}
|
||||
|
||||
void packWriteString(PackStream* stream, char* value, int max_length)
|
||||
{
|
||||
stream->write(value, max_length);
|
||||
}
|
||||
|
||||
void packReadString(PackStream* stream, char* value, int max_length)
|
||||
{
|
||||
stream->read(value, max_length);
|
||||
}
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#define PACKSTREAM_H
|
||||
|
||||
#include "system_global.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <QString>
|
||||
class QFile;
|
||||
class QDataStream;
|
||||
|
@ -23,7 +20,7 @@ public:
|
|||
PackStream();
|
||||
~PackStream();
|
||||
|
||||
void bindToFile(const char* filepath, bool write=false);
|
||||
bool bindToFile(const char* filepath, bool write=false);
|
||||
|
||||
void write(int* value);
|
||||
void write(double* value);
|
||||
|
@ -43,28 +40,4 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Transitional C-API
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef struct PackStream PackStream;
|
||||
#endif
|
||||
|
||||
SYSTEMSHARED_EXPORT PackStream* packReadFile(const char* filepath);
|
||||
SYSTEMSHARED_EXPORT PackStream* packWriteFile(const char* filepath);
|
||||
SYSTEMSHARED_EXPORT void packCloseStream(PackStream* stream);
|
||||
|
||||
SYSTEMSHARED_EXPORT void packWriteDouble(PackStream* stream, double* value);
|
||||
SYSTEMSHARED_EXPORT void packReadDouble(PackStream* stream, double* value);
|
||||
SYSTEMSHARED_EXPORT void packWriteInt(PackStream* stream, int* value);
|
||||
SYSTEMSHARED_EXPORT void packReadInt(PackStream* stream, int* value);
|
||||
SYSTEMSHARED_EXPORT void packWriteString(PackStream* stream, char* value, int max_length);
|
||||
SYSTEMSHARED_EXPORT void packReadString(PackStream* stream, char* value, int max_length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // PACKSTREAM_H
|
||||
|
|
|
@ -18,10 +18,3 @@ int System::getCoreCount()
|
|||
}
|
||||
return core_count;
|
||||
}
|
||||
|
||||
// Transitional C-API
|
||||
|
||||
int systemGetCoreCount()
|
||||
{
|
||||
return System::getCoreCount();
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
#include "system_global.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace paysages
|
||||
{
|
||||
namespace system
|
||||
|
@ -22,14 +20,4 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Transitional C-API
|
||||
int systemGetCoreCount();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SYSTEM_H
|
||||
|
|
|
@ -21,30 +21,3 @@ void Thread::run()
|
|||
{
|
||||
result = function(data);
|
||||
}
|
||||
|
||||
// Transitional C-API
|
||||
|
||||
Thread* threadCreate(ThreadFunction function, void* data)
|
||||
{
|
||||
Thread* result = new Thread(function);
|
||||
|
||||
result->start(data);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void* threadJoin(Thread* thread)
|
||||
{
|
||||
void* result;
|
||||
|
||||
result = thread->join();
|
||||
|
||||
delete thread;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void timeSleepMs(unsigned long ms)
|
||||
{
|
||||
QThread::msleep(ms);
|
||||
}
|
||||
|
|
|
@ -2,11 +2,6 @@
|
|||
#define THREAD_H
|
||||
|
||||
#include "system_global.h"
|
||||
|
||||
typedef void* (*ThreadFunction)(void* data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <QThread>
|
||||
|
||||
namespace paysages
|
||||
|
@ -14,6 +9,8 @@ namespace paysages
|
|||
namespace system
|
||||
{
|
||||
|
||||
typedef void* (*ThreadFunction)(void* data);
|
||||
|
||||
/*!
|
||||
* \brief System thread
|
||||
*/
|
||||
|
@ -22,9 +19,9 @@ class SYSTEMSHARED_EXPORT Thread: private QThread
|
|||
public:
|
||||
/*!
|
||||
* \brief Create a new thread
|
||||
* \param function Function to call inside the thread once it is started
|
||||
*
|
||||
* The thread is not started automatically. A call to method start() needs to be done.
|
||||
* \param function Function to call inside the thread once it is started
|
||||
*/
|
||||
Thread(ThreadFunction function);
|
||||
|
||||
|
@ -40,6 +37,8 @@ public:
|
|||
*/
|
||||
void* join();
|
||||
|
||||
static inline void timeSleepMs(unsigned long ms){ QThread::msleep(ms); }
|
||||
|
||||
protected:
|
||||
virtual void run();
|
||||
|
||||
|
@ -52,22 +51,4 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Transitional C-API
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef struct Thread Thread;
|
||||
#endif
|
||||
|
||||
SYSTEMSHARED_EXPORT Thread* threadCreate(ThreadFunction function, void* data);
|
||||
SYSTEMSHARED_EXPORT void* threadJoin(Thread* thread);
|
||||
|
||||
SYSTEMSHARED_EXPORT void timeSleepMs(unsigned long ms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // THREAD_H
|
||||
|
|
|
@ -2,17 +2,7 @@
|
|||
#define SYSTEM_GLOBAL_H
|
||||
|
||||
/* Shared object helpers */
|
||||
#ifdef __cplusplus
|
||||
#include <QtCore/qglobal.h>
|
||||
#else
|
||||
# if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
|
||||
# define Q_DECL_EXPORT __declspec(dllexport)
|
||||
# define Q_DECL_IMPORT __declspec(dllimport)
|
||||
# else
|
||||
# define Q_DECL_EXPORT
|
||||
# define Q_DECL_IMPORT
|
||||
# endif
|
||||
#endif
|
||||
#if defined(SYSTEM_LIBRARY)
|
||||
# define SYSTEMSHARED_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
|
@ -20,14 +10,10 @@
|
|||
#endif
|
||||
|
||||
/* Namespace using */
|
||||
#ifdef __cplusplus
|
||||
namespace paysages
|
||||
{
|
||||
namespace system {}
|
||||
}
|
||||
using namespace paysages::system;
|
||||
#endif
|
||||
|
||||
/* Global imports */
|
||||
|
||||
#endif // SYSTEM_GLOBAL_H
|
||||
|
|
Loading…
Reference in a new issue