Switched rendering lib to c++ compiling
This will allow to avoid #if __cplusplus directives, and C-apis.
This commit is contained in:
parent
d2620ae2e3
commit
abd463d29d
56 changed files with 197 additions and 197 deletions
|
@ -754,7 +754,7 @@ static int _inscatterNWorker(ParallelWork* work, int layer, void* data)
|
||||||
{
|
{
|
||||||
UNUSED(work);
|
UNUSED(work);
|
||||||
|
|
||||||
InscatterNParams* params = data;
|
InscatterNParams* params = (InscatterNParams*)data;
|
||||||
|
|
||||||
double r;
|
double r;
|
||||||
Color dhdH;
|
Color dhdH;
|
|
@ -42,7 +42,7 @@ static AtmosphereDefinition* _createDefinition()
|
||||||
brunetonInit();
|
brunetonInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
result = malloc(sizeof(AtmosphereDefinition));
|
result = new AtmosphereDefinition;
|
||||||
|
|
||||||
atmosphereAutoPreset(result, ATMOSPHERE_PRESET_CLEAR_DAY);
|
atmosphereAutoPreset(result, ATMOSPHERE_PRESET_CLEAR_DAY);
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ static AtmosphereDefinition* _createDefinition()
|
||||||
|
|
||||||
static void _deleteDefinition(AtmosphereDefinition* definition)
|
static void _deleteDefinition(AtmosphereDefinition* definition)
|
||||||
{
|
{
|
||||||
free(definition);
|
delete definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _copyDefinition(AtmosphereDefinition* source, AtmosphereDefinition* destination)
|
static void _copyDefinition(AtmosphereDefinition* source, AtmosphereDefinition* destination)
|
|
@ -222,8 +222,8 @@ static AtmosphereRenderer* _createRenderer()
|
||||||
{
|
{
|
||||||
AtmosphereRenderer* result;
|
AtmosphereRenderer* result;
|
||||||
|
|
||||||
result = malloc(sizeof(AtmosphereRenderer));
|
result = new AtmosphereRenderer;
|
||||||
result->definition = AtmosphereDefinitionClass.create();
|
result->definition = (AtmosphereDefinition*)AtmosphereDefinitionClass.create();
|
||||||
|
|
||||||
result->getLightingStatus = _fakeGetLightingStatus;
|
result->getLightingStatus = _fakeGetLightingStatus;
|
||||||
result->getSunDirection = _realGetSunDirection;
|
result->getSunDirection = _realGetSunDirection;
|
||||||
|
@ -236,7 +236,7 @@ static AtmosphereRenderer* _createRenderer()
|
||||||
static void _deleteRenderer(AtmosphereRenderer* renderer)
|
static void _deleteRenderer(AtmosphereRenderer* renderer)
|
||||||
{
|
{
|
||||||
AtmosphereDefinitionClass.destroy(renderer->definition);
|
AtmosphereDefinitionClass.destroy(renderer->definition);
|
||||||
free(renderer);
|
delete renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _bindRenderer(Renderer* renderer, AtmosphereDefinition* definition)
|
static void _bindRenderer(Renderer* renderer, AtmosphereDefinition* definition)
|
|
@ -52,7 +52,7 @@ CameraDefinition* cameraCreateDefinition()
|
||||||
{
|
{
|
||||||
CameraDefinition* definition;
|
CameraDefinition* definition;
|
||||||
|
|
||||||
definition = malloc(sizeof (CameraDefinition));
|
definition = new CameraDefinition;
|
||||||
|
|
||||||
definition->location.x = 0.0;
|
definition->location.x = 0.0;
|
||||||
definition->location.y = 0.0;
|
definition->location.y = 0.0;
|
||||||
|
@ -76,7 +76,7 @@ CameraDefinition* cameraCreateDefinition()
|
||||||
|
|
||||||
void cameraDeleteDefinition(CameraDefinition* definition)
|
void cameraDeleteDefinition(CameraDefinition* definition)
|
||||||
{
|
{
|
||||||
free(definition);
|
delete definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cameraCopyDefinition(CameraDefinition* source, CameraDefinition* destination)
|
void cameraCopyDefinition(CameraDefinition* source, CameraDefinition* destination)
|
|
@ -10,7 +10,7 @@ static void _validateDefinition(CloudsDefinition* definition)
|
||||||
|
|
||||||
static CloudsDefinition* _createDefinition()
|
static CloudsDefinition* _createDefinition()
|
||||||
{
|
{
|
||||||
CloudsDefinition* definition = malloc(sizeof(CloudsDefinition));
|
CloudsDefinition* definition = new CloudsDefinition;
|
||||||
|
|
||||||
definition->layers = layersCreate(cloudsGetLayerType(), CLOUDS_MAX_LAYERS);
|
definition->layers = layersCreate(cloudsGetLayerType(), CLOUDS_MAX_LAYERS);
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ static CloudsDefinition* _createDefinition()
|
||||||
static void _deleteDefinition(CloudsDefinition* definition)
|
static void _deleteDefinition(CloudsDefinition* definition)
|
||||||
{
|
{
|
||||||
layersDelete(definition->layers);
|
layersDelete(definition->layers);
|
||||||
free(definition);
|
delete definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _copyDefinition(CloudsDefinition* source, CloudsDefinition* destination)
|
static void _copyDefinition(CloudsDefinition* source, CloudsDefinition* destination)
|
||||||
|
@ -125,7 +125,7 @@ CloudsLayerDefinition* cloudsLayerCreateDefinition()
|
||||||
{
|
{
|
||||||
CloudsLayerDefinition* result;
|
CloudsLayerDefinition* result;
|
||||||
|
|
||||||
result = malloc(sizeof(CloudsLayerDefinition));
|
result = new CloudsLayerDefinition;
|
||||||
result->_coverage_by_altitude = curveCreate();
|
result->_coverage_by_altitude = curveCreate();
|
||||||
result->_coverage_noise = noiseCreateGenerator();
|
result->_coverage_noise = noiseCreateGenerator();
|
||||||
result->_shape_noise = noiseCreateGenerator();
|
result->_shape_noise = noiseCreateGenerator();
|
||||||
|
@ -142,7 +142,7 @@ void cloudsLayerDeleteDefinition(CloudsLayerDefinition* definition)
|
||||||
noiseDeleteGenerator(definition->_coverage_noise);
|
noiseDeleteGenerator(definition->_coverage_noise);
|
||||||
noiseDeleteGenerator(definition->_shape_noise);
|
noiseDeleteGenerator(definition->_shape_noise);
|
||||||
noiseDeleteGenerator(definition->_edge_noise);
|
noiseDeleteGenerator(definition->_edge_noise);
|
||||||
free(definition);
|
delete definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cloudsLayerCopyDefinition(CloudsLayerDefinition* source, CloudsLayerDefinition* destination)
|
void cloudsLayerCopyDefinition(CloudsLayerDefinition* source, CloudsLayerDefinition* destination)
|
|
@ -16,7 +16,7 @@ void cloudsAutoPreset(CloudsDefinition* definition, CloudsPreset preset)
|
||||||
if (preset == CLOUDS_PRESET_PARTLY_CLOUDY)
|
if (preset == CLOUDS_PRESET_PARTLY_CLOUDY)
|
||||||
{
|
{
|
||||||
layer = layersAddLayer(definition->layers, NULL);
|
layer = layersAddLayer(definition->layers, NULL);
|
||||||
cloudsLayerAutoPreset(layersGetLayer(definition->layers, layer), CLOUDS_LAYER_PRESET_CIRRUS);
|
cloudsLayerAutoPreset((CloudsLayerDefinition*)layersGetLayer(definition->layers, layer), CLOUDS_LAYER_PRESET_CIRRUS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ void cloudsPreviewMaterialBindLayer(Renderer* renderer, CloudsLayerDefinition* l
|
||||||
CloudsRendererClass.bind(renderer, definition);
|
CloudsRendererClass.bind(renderer, definition);
|
||||||
CloudsDefinitionClass.destroy(definition);
|
CloudsDefinitionClass.destroy(definition);
|
||||||
|
|
||||||
layer = layersGetLayer(renderer->clouds->definition->layers, 0);
|
layer = (CloudsLayerDefinition*)layersGetLayer(renderer->clouds->definition->layers, 0);
|
||||||
layer->thickness = layer->shape_scaling;
|
layer->thickness = layer->shape_scaling;
|
||||||
layer->lower_altitude = -layer->thickness / 2.0;
|
layer->lower_altitude = -layer->thickness / 2.0;
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ void cloudsPreviewMaterialBindLayer(Renderer* renderer, CloudsLayerDefinition* l
|
||||||
Color cloudsPreviewMaterialGetPixel(Renderer* renderer, double x, double y)
|
Color cloudsPreviewMaterialGetPixel(Renderer* renderer, double x, double y)
|
||||||
{
|
{
|
||||||
Vector3 start, end;
|
Vector3 start, end;
|
||||||
CloudsLayerDefinition* layer = layersGetLayer(renderer->clouds->definition->layers, 0);
|
CloudsLayerDefinition* layer = (CloudsLayerDefinition*)layersGetLayer(renderer->clouds->definition->layers, 0);
|
||||||
double thickness = layer->thickness;
|
double thickness = layer->thickness;
|
||||||
|
|
||||||
start.x = x * thickness * 0.5;
|
start.x = x * thickness * 0.5;
|
|
@ -248,8 +248,8 @@ static CloudsRenderer* _createRenderer()
|
||||||
{
|
{
|
||||||
CloudsRenderer* result;
|
CloudsRenderer* result;
|
||||||
|
|
||||||
result = malloc(sizeof(CloudsRenderer));
|
result = new CloudsRenderer;
|
||||||
result->definition = CloudsDefinitionClass.create();
|
result->definition = (CloudsDefinition*)CloudsDefinitionClass.create();
|
||||||
|
|
||||||
result->getColor = _fakeGetColor;
|
result->getColor = _fakeGetColor;
|
||||||
result->alterLight = (FuncLightingAlterLight)_fakeAlterLight;
|
result->alterLight = (FuncLightingAlterLight)_fakeAlterLight;
|
||||||
|
@ -262,7 +262,7 @@ static CloudsRenderer* _createRenderer()
|
||||||
static void _deleteRenderer(CloudsRenderer* renderer)
|
static void _deleteRenderer(CloudsRenderer* renderer)
|
||||||
{
|
{
|
||||||
CloudsDefinitionClass.destroy(renderer->definition);
|
CloudsDefinitionClass.destroy(renderer->definition);
|
||||||
free(renderer);
|
delete renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _bindRenderer(Renderer* renderer, CloudsDefinition* definition)
|
static void _bindRenderer(Renderer* renderer, CloudsDefinition* definition)
|
|
@ -73,7 +73,7 @@ NoiseGenerator* noiseCreateGenerator()
|
||||||
NoiseGenerator* result;
|
NoiseGenerator* result;
|
||||||
|
|
||||||
/* initialize */
|
/* initialize */
|
||||||
result = malloc(sizeof(NoiseGenerator));
|
result = new NoiseGenerator;
|
||||||
result->function.algorithm = NOISE_FUNCTION_SIMPLEX;
|
result->function.algorithm = NOISE_FUNCTION_SIMPLEX;
|
||||||
result->function.ridge_factor = 0.0;
|
result->function.ridge_factor = 0.0;
|
||||||
result->function.curve_factor = 0.0;
|
result->function.curve_factor = 0.0;
|
||||||
|
@ -88,7 +88,7 @@ NoiseGenerator* noiseCreateGenerator()
|
||||||
|
|
||||||
void noiseDeleteGenerator(NoiseGenerator* generator)
|
void noiseDeleteGenerator(NoiseGenerator* generator)
|
||||||
{
|
{
|
||||||
free(generator);
|
delete generator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void noiseSaveGenerator(PackStream* stream, NoiseGenerator* generator)
|
void noiseSaveGenerator(PackStream* stream, NoiseGenerator* generator)
|
|
@ -17,7 +17,7 @@ void noiseNaiveInit()
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
_noise_pool_size = 1048576;
|
_noise_pool_size = 1048576;
|
||||||
_noise_pool = malloc(sizeof(double) * _noise_pool_size);
|
_noise_pool = new double[_noise_pool_size];
|
||||||
|
|
||||||
for (i = 0; i < _noise_pool_size; i++)
|
for (i = 0; i < _noise_pool_size; i++)
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ void noiseNaiveInit()
|
||||||
|
|
||||||
void noiseNaiveQuit()
|
void noiseNaiveQuit()
|
||||||
{
|
{
|
||||||
free(_noise_pool);
|
delete[] _noise_pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
void noiseNaiveSave(PackStream* stream)
|
void noiseNaiveSave(PackStream* stream)
|
||||||
|
@ -46,7 +46,8 @@ void noiseNaiveLoad(PackStream* stream)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
packReadInt(stream, &_noise_pool_size);
|
packReadInt(stream, &_noise_pool_size);
|
||||||
_noise_pool = realloc(_noise_pool, sizeof(double) * _noise_pool_size);
|
delete[] _noise_pool;
|
||||||
|
_noise_pool = new double[_noise_pool_size];
|
||||||
for (i = 0; i < _noise_pool_size; i++)
|
for (i = 0; i < _noise_pool_size; i++)
|
||||||
{
|
{
|
||||||
packReadDouble(stream, _noise_pool + i);
|
packReadDouble(stream, _noise_pool + i);
|
|
@ -1,4 +1,4 @@
|
||||||
#include "noisesimplex.h"
|
#include "noiseperlin.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Perlin noise implementation.
|
* Perlin noise implementation.
|
|
@ -89,9 +89,9 @@ typedef struct
|
||||||
RenderArea* area;
|
RenderArea* area;
|
||||||
} RenderChunk;
|
} RenderChunk;
|
||||||
|
|
||||||
static void _callbackStart(int width, int height, Color background) {}
|
static void _callbackStart(int, int, Color) {}
|
||||||
static void _callbackDraw(int x, int y, Color col) {}
|
static void _callbackDraw(int, int, Color) {}
|
||||||
static void _callbackUpdate(double progress) {}
|
static void _callbackUpdate(double) {}
|
||||||
|
|
||||||
void renderInit()
|
void renderInit()
|
||||||
{
|
{
|
||||||
|
@ -105,7 +105,7 @@ RenderArea* renderCreateArea(Renderer* renderer)
|
||||||
{
|
{
|
||||||
RenderArea* result;
|
RenderArea* result;
|
||||||
|
|
||||||
result = malloc(sizeof(RenderArea));
|
result = new RenderArea;
|
||||||
result->renderer = renderer;
|
result->renderer = renderer;
|
||||||
result->hdr_mapping = colorProfileCreate();
|
result->hdr_mapping = colorProfileCreate();
|
||||||
result->params.width = 1;
|
result->params.width = 1;
|
||||||
|
@ -113,7 +113,7 @@ RenderArea* renderCreateArea(Renderer* renderer)
|
||||||
result->params.antialias = 1;
|
result->params.antialias = 1;
|
||||||
result->params.quality = 5;
|
result->params.quality = 5;
|
||||||
result->pixel_count = 1;
|
result->pixel_count = 1;
|
||||||
result->pixels = malloc(sizeof(RenderFragment));
|
result->pixels = new RenderFragment[1];
|
||||||
result->fragment_callbacks_count = 0;
|
result->fragment_callbacks_count = 0;
|
||||||
result->background_color = COLOR_TRANSPARENT;
|
result->background_color = COLOR_TRANSPARENT;
|
||||||
result->dirty_left = 1;
|
result->dirty_left = 1;
|
||||||
|
@ -153,7 +153,8 @@ void renderSetParams(RenderArea* area, RenderParams params)
|
||||||
height = params.height * params.antialias;
|
height = params.height * params.antialias;
|
||||||
|
|
||||||
area->params = params;
|
area->params = params;
|
||||||
area->pixels = realloc(area->pixels, sizeof(RenderFragment) * width * height);
|
delete[] area->pixels;
|
||||||
|
area->pixels = new RenderFragment[width * height];
|
||||||
area->pixel_count = width * height;
|
area->pixel_count = width * height;
|
||||||
|
|
||||||
area->dirty_left = width;
|
area->dirty_left = width;
|
||||||
|
@ -562,8 +563,8 @@ void renderPushTriangle(RenderArea* area, Vector3 pixel1, Vector3 pixel2, Vector
|
||||||
int width = area->params.width * area->params.antialias;
|
int width = area->params.width * area->params.antialias;
|
||||||
scanlines.left = width;
|
scanlines.left = width;
|
||||||
scanlines.right = -1;
|
scanlines.right = -1;
|
||||||
scanlines.up = malloc(sizeof(ScanPoint) * width);
|
scanlines.up = new ScanPoint[width];
|
||||||
scanlines.down = malloc(sizeof(ScanPoint) * width);
|
scanlines.down = new ScanPoint[width];
|
||||||
for (x = 0; x < width; x++)
|
for (x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
/* TODO Do not initialize whole width each time, init only when needed on point push */
|
/* TODO Do not initialize whole width each time, init only when needed on point push */
|
|
@ -120,7 +120,7 @@ static Color _applyMediumTraversal(Renderer* renderer, Vector3 location, Color c
|
||||||
|
|
||||||
Renderer* rendererCreate()
|
Renderer* rendererCreate()
|
||||||
{
|
{
|
||||||
Renderer* result = malloc(sizeof (Renderer));
|
Renderer* result = new Renderer;
|
||||||
RenderParams params = {1, 1, 1, 5};
|
RenderParams params = {1, 1, 1, 5};
|
||||||
|
|
||||||
result->render_quality = 5;
|
result->render_quality = 5;
|
||||||
|
@ -152,11 +152,11 @@ Renderer* rendererCreate()
|
||||||
|
|
||||||
result->lighting = lightingManagerCreate();
|
result->lighting = lightingManagerCreate();
|
||||||
|
|
||||||
result->atmosphere = AtmosphereRendererClass.create();
|
result->atmosphere = (AtmosphereRenderer*)AtmosphereRendererClass.create();
|
||||||
result->clouds = CloudsRendererClass.create();
|
result->clouds = (CloudsRenderer*)CloudsRendererClass.create();
|
||||||
result->terrain = TerrainRendererClass.create();
|
result->terrain = (TerrainRenderer*)TerrainRendererClass.create();
|
||||||
result->textures = TexturesRendererClass.create();
|
result->textures = (TexturesRenderer*)TexturesRendererClass.create();
|
||||||
result->water = WaterRendererClass.create();
|
result->water = (WaterRenderer*)WaterRendererClass.create();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ void rendererDelete(Renderer* renderer)
|
||||||
|
|
||||||
renderDeleteArea(renderer->render_area);
|
renderDeleteArea(renderer->render_area);
|
||||||
|
|
||||||
free(renderer);
|
delete renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rendererSetPreviewCallbacks(Renderer* renderer, RenderCallbackStart start, RenderCallbackDraw draw, RenderCallbackUpdate update)
|
void rendererSetPreviewCallbacks(Renderer* renderer, RenderCallbackStart start, RenderCallbackDraw draw, RenderCallbackUpdate update)
|
|
@ -9,58 +9,58 @@ CONFIG(release, debug|release): DEFINES += NDEBUG
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/..
|
INCLUDEPATH += $$PWD/..
|
||||||
|
|
||||||
SOURCES += main.c \
|
SOURCES += main.cpp \
|
||||||
tools.c \
|
tools.cpp \
|
||||||
renderer.c \
|
renderer.cpp \
|
||||||
render.c \
|
render.cpp \
|
||||||
opencl.c \
|
opencl.cpp \
|
||||||
noisesimplex.c \
|
noisesimplex.cpp \
|
||||||
noiseperlin.c \
|
noiseperlin.cpp \
|
||||||
noisenaive.c \
|
noisenaive.cpp \
|
||||||
noise.c \
|
noise.cpp \
|
||||||
geoarea.c \
|
geoarea.cpp \
|
||||||
camera.c \
|
camera.cpp \
|
||||||
atmosphere/atm_render.c \
|
atmosphere/atm_render.cpp \
|
||||||
atmosphere/atm_raster.c \
|
atmosphere/atm_raster.cpp \
|
||||||
atmosphere/atm_preview.c \
|
atmosphere/atm_preview.cpp \
|
||||||
atmosphere/atm_presets.c \
|
atmosphere/atm_presets.cpp \
|
||||||
atmosphere/atm_definition.c \
|
atmosphere/atm_definition.cpp \
|
||||||
atmosphere/atm_bruneton.c \
|
atmosphere/atm_bruneton.cpp \
|
||||||
clouds/clo_walking.c \
|
clouds/clo_walking.cpp \
|
||||||
clouds/clo_rendering.c \
|
clouds/clo_rendering.cpp \
|
||||||
clouds/clo_preview.c \
|
clouds/clo_preview.cpp \
|
||||||
clouds/clo_presets.c \
|
clouds/clo_presets.cpp \
|
||||||
clouds/clo_density.c \
|
clouds/clo_density.cpp \
|
||||||
clouds/clo_definition.c \
|
clouds/clo_definition.cpp \
|
||||||
shared/preview.c \
|
shared/preview.cpp \
|
||||||
terrain/ter_render.c \
|
terrain/ter_render.cpp \
|
||||||
terrain/ter_raster.c \
|
terrain/ter_raster.cpp \
|
||||||
terrain/ter_preview.c \
|
terrain/ter_preview.cpp \
|
||||||
terrain/ter_presets.c \
|
terrain/ter_presets.cpp \
|
||||||
terrain/ter_painting.c \
|
terrain/ter_painting.cpp \
|
||||||
terrain/ter_definition.c \
|
terrain/ter_definition.cpp \
|
||||||
textures/tex_tools.c \
|
textures/tex_tools.cpp \
|
||||||
textures/tex_rendering.c \
|
textures/tex_rendering.cpp \
|
||||||
textures/tex_preview.c \
|
textures/tex_preview.cpp \
|
||||||
textures/tex_presets.c \
|
textures/tex_presets.cpp \
|
||||||
textures/tex_definition.c \
|
textures/tex_definition.cpp \
|
||||||
tools/zone.c \
|
tools/zone.cpp \
|
||||||
tools/texture.c \
|
tools/texture.cpp \
|
||||||
tools/parallel.c \
|
tools/parallel.cpp \
|
||||||
tools/memory.c \
|
tools/memory.cpp \
|
||||||
tools/lighting.c \
|
tools/lighting.cpp \
|
||||||
tools/euclid.c \
|
tools/euclid.cpp \
|
||||||
tools/data.c \
|
tools/data.cpp \
|
||||||
tools/curve.c \
|
tools/curve.cpp \
|
||||||
tools/color.c \
|
tools/color.cpp \
|
||||||
tools/cache.c \
|
tools/cache.cpp \
|
||||||
tools/boundingbox.c \
|
tools/boundingbox.cpp \
|
||||||
tools/array.c \
|
tools/array.cpp \
|
||||||
water/wat_render.c \
|
water/wat_render.cpp \
|
||||||
water/wat_raster.c \
|
water/wat_raster.cpp \
|
||||||
water/wat_preview.c \
|
water/wat_preview.cpp \
|
||||||
water/wat_presets.c \
|
water/wat_presets.cpp \
|
||||||
water/wat_definition.c \
|
water/wat_definition.cpp \
|
||||||
Scenery.cpp
|
Scenery.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
|
|
@ -25,7 +25,7 @@ static void _validateDefinition(TerrainDefinition* definition)
|
||||||
|
|
||||||
static TerrainDefinition* _createDefinition()
|
static TerrainDefinition* _createDefinition()
|
||||||
{
|
{
|
||||||
TerrainDefinition* definition = malloc(sizeof(TerrainDefinition));
|
TerrainDefinition* definition = new TerrainDefinition;
|
||||||
|
|
||||||
definition->height = 1.0;
|
definition->height = 1.0;
|
||||||
definition->scaling = 1.0;
|
definition->scaling = 1.0;
|
||||||
|
@ -46,7 +46,7 @@ static void _deleteDefinition(TerrainDefinition* definition)
|
||||||
{
|
{
|
||||||
terrainHeightmapDelete(definition->height_map);
|
terrainHeightmapDelete(definition->height_map);
|
||||||
noiseDeleteGenerator(definition->_height_noise);
|
noiseDeleteGenerator(definition->_height_noise);
|
||||||
free(definition);
|
delete definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _copyDefinition(TerrainDefinition* source, TerrainDefinition* destination)
|
static void _copyDefinition(TerrainDefinition* source, TerrainDefinition* destination)
|
|
@ -43,7 +43,7 @@ struct TerrainHeightMap
|
||||||
static void _initData(HeightMapData* data)
|
static void _initData(HeightMapData* data)
|
||||||
{
|
{
|
||||||
data->rows_count = 0;
|
data->rows_count = 0;
|
||||||
data->rows = malloc(1);
|
data->rows = new HeightMapRow[1];
|
||||||
data->memsize = 0;
|
data->memsize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,14 +59,15 @@ static void _clearData(HeightMapData* data)
|
||||||
free(data->rows[i].pixel_groups);
|
free(data->rows[i].pixel_groups);
|
||||||
}
|
}
|
||||||
data->rows_count = 0;
|
data->rows_count = 0;
|
||||||
data->rows = realloc(data->rows, 1);
|
delete[] data->rows;
|
||||||
|
data->rows = new HeightMapRow[1];
|
||||||
data->memsize = 0;
|
data->memsize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _deleteData(HeightMapData* data)
|
static void _deleteData(HeightMapData* data)
|
||||||
{
|
{
|
||||||
_clearData(data);
|
_clearData(data);
|
||||||
free(data->rows);
|
delete[] data->rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _copyData(HeightMapData* source, HeightMapData* destination)
|
static void _copyData(HeightMapData* source, HeightMapData* destination)
|
||||||
|
@ -80,14 +81,14 @@ static void _copyData(HeightMapData* source, HeightMapData* destination)
|
||||||
if (destination->rows_count > 0)
|
if (destination->rows_count > 0)
|
||||||
{
|
{
|
||||||
size = sizeof(HeightMapRow) * destination->rows_count;
|
size = sizeof(HeightMapRow) * destination->rows_count;
|
||||||
destination->rows = realloc(destination->rows, size);
|
destination->rows = (HeightMapRow*)realloc(destination->rows, size);
|
||||||
destination->memsize += size;
|
destination->memsize += size;
|
||||||
for (i = 0; i < destination->rows_count; i++)
|
for (i = 0; i < destination->rows_count; i++)
|
||||||
{
|
{
|
||||||
destination->rows[i].z = source->rows[i].z;
|
destination->rows[i].z = source->rows[i].z;
|
||||||
destination->rows[i].pixel_groups_count = source->rows[i].pixel_groups_count;
|
destination->rows[i].pixel_groups_count = source->rows[i].pixel_groups_count;
|
||||||
size = sizeof(HeightMapPixelGroup) * destination->rows[i].pixel_groups_count;
|
size = sizeof(HeightMapPixelGroup) * destination->rows[i].pixel_groups_count;
|
||||||
destination->rows[i].pixel_groups = malloc(size);
|
destination->rows[i].pixel_groups = (HeightMapPixelGroup*)malloc(size);
|
||||||
destination->memsize += size;
|
destination->memsize += size;
|
||||||
for (j = 0; j < destination->rows[i].pixel_groups_count; j++)
|
for (j = 0; j < destination->rows[i].pixel_groups_count; j++)
|
||||||
{
|
{
|
||||||
|
@ -95,7 +96,7 @@ static void _copyData(HeightMapData* source, HeightMapData* destination)
|
||||||
destination->rows[i].pixel_groups[j].xend = source->rows[i].pixel_groups[j].xend;
|
destination->rows[i].pixel_groups[j].xend = source->rows[i].pixel_groups[j].xend;
|
||||||
n = destination->rows[i].pixel_groups[j].xend - destination->rows[i].pixel_groups[j].xstart + 1;
|
n = destination->rows[i].pixel_groups[j].xend - destination->rows[i].pixel_groups[j].xstart + 1;
|
||||||
size = sizeof(double) * n;
|
size = sizeof(double) * n;
|
||||||
destination->rows[i].pixel_groups[j].height = malloc(size);
|
destination->rows[i].pixel_groups[j].height = (double*)malloc(size);
|
||||||
destination->memsize += size;
|
destination->memsize += size;
|
||||||
memcpy(destination->rows[i].pixel_groups[j].height, source->rows[i].pixel_groups[j].height, size);
|
memcpy(destination->rows[i].pixel_groups[j].height, source->rows[i].pixel_groups[j].height, size);
|
||||||
}
|
}
|
||||||
|
@ -134,14 +135,14 @@ static void _loadData(PackStream* stream, HeightMapData* data)
|
||||||
if (data->rows_count > 0)
|
if (data->rows_count > 0)
|
||||||
{
|
{
|
||||||
size = sizeof(HeightMapRow) * data->rows_count;
|
size = sizeof(HeightMapRow) * data->rows_count;
|
||||||
data->rows = realloc(data->rows, size);
|
data->rows = (HeightMapRow*)realloc(data->rows, size);
|
||||||
data->memsize += size;
|
data->memsize += size;
|
||||||
for (i = 0; i < data->rows_count; i++)
|
for (i = 0; i < data->rows_count; i++)
|
||||||
{
|
{
|
||||||
packReadInt(stream, &data->rows[i].z);
|
packReadInt(stream, &data->rows[i].z);
|
||||||
packReadInt(stream, &data->rows[i].pixel_groups_count);
|
packReadInt(stream, &data->rows[i].pixel_groups_count);
|
||||||
size = sizeof(HeightMapPixelGroup) * data->rows[i].pixel_groups_count;
|
size = sizeof(HeightMapPixelGroup) * data->rows[i].pixel_groups_count;
|
||||||
data->rows[i].pixel_groups = malloc(size);
|
data->rows[i].pixel_groups = (HeightMapPixelGroup*)malloc(size);
|
||||||
data->memsize += size;
|
data->memsize += size;
|
||||||
for (j = 0; j < data->rows[i].pixel_groups_count; j++)
|
for (j = 0; j < data->rows[i].pixel_groups_count; j++)
|
||||||
{
|
{
|
||||||
|
@ -149,7 +150,7 @@ static void _loadData(PackStream* stream, HeightMapData* data)
|
||||||
packReadInt(stream, &data->rows[i].pixel_groups[j].xend);
|
packReadInt(stream, &data->rows[i].pixel_groups[j].xend);
|
||||||
n = data->rows[i].pixel_groups[j].xend - data->rows[i].pixel_groups[j].xstart;
|
n = data->rows[i].pixel_groups[j].xend - data->rows[i].pixel_groups[j].xstart;
|
||||||
size = sizeof(double) * n;
|
size = sizeof(double) * n;
|
||||||
data->rows[i].pixel_groups[j].height = malloc(size);
|
data->rows[i].pixel_groups[j].height = (double*)malloc(size);
|
||||||
data->memsize += size;
|
data->memsize += size;
|
||||||
for (k = 0; k < n; k++)
|
for (k = 0; k < n; k++)
|
||||||
{
|
{
|
||||||
|
@ -183,11 +184,11 @@ static double* _getDataPointer(HeightMapData* data, int x, int z, HeightMapData*
|
||||||
}
|
}
|
||||||
else if (grow)
|
else if (grow)
|
||||||
{
|
{
|
||||||
row = naiveArrayInsert((void**)&data->rows, sizeof(HeightMapRow), data->rows_count, i);
|
row = (HeightMapRow*)naiveArrayInsert((void**)&data->rows, sizeof(HeightMapRow), data->rows_count, i);
|
||||||
|
|
||||||
row->z = z;
|
row->z = z;
|
||||||
row->pixel_groups_count = 0;
|
row->pixel_groups_count = 0;
|
||||||
row->pixel_groups = malloc(1);
|
row->pixel_groups = (HeightMapPixelGroup*)malloc(1);
|
||||||
|
|
||||||
data->rows_count++;
|
data->rows_count++;
|
||||||
data->memsize += sizeof(HeightMapRow);
|
data->memsize += sizeof(HeightMapRow);
|
||||||
|
@ -236,11 +237,11 @@ static double* _getDataPointer(HeightMapData* data, int x, int z, HeightMapData*
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the pixel group with one pixel */
|
/* Create the pixel group with one pixel */
|
||||||
pixel_group = naiveArrayInsert((void**)&row->pixel_groups, sizeof(HeightMapPixelGroup), row->pixel_groups_count, i);
|
pixel_group = (HeightMapPixelGroup*)naiveArrayInsert((void**)&row->pixel_groups, sizeof(HeightMapPixelGroup), row->pixel_groups_count, i);
|
||||||
|
|
||||||
pixel_group->xstart = x;
|
pixel_group->xstart = x;
|
||||||
pixel_group->xend = x;
|
pixel_group->xend = x;
|
||||||
pixel_group->height = malloc(sizeof(double));
|
pixel_group->height = (double*)malloc(sizeof(double));
|
||||||
|
|
||||||
pixel = pixel_group->height;
|
pixel = pixel_group->height;
|
||||||
|
|
||||||
|
@ -256,7 +257,7 @@ static double* _getDataPointer(HeightMapData* data, int x, int z, HeightMapData*
|
||||||
|
|
||||||
/* Extend the rowgroup at start */
|
/* Extend the rowgroup at start */
|
||||||
pixel_group->xstart--;
|
pixel_group->xstart--;
|
||||||
pixel = naiveArrayInsert((void**)&pixel_group->height, sizeof(double), pixel_group->xend - pixel_group->xstart, 0);
|
pixel = (double*)naiveArrayInsert((void**)&pixel_group->height, sizeof(double), pixel_group->xend - pixel_group->xstart, 0);
|
||||||
data->memsize += sizeof(double);
|
data->memsize += sizeof(double);
|
||||||
}
|
}
|
||||||
else if (x == pixel_group->xend + 1)
|
else if (x == pixel_group->xend + 1)
|
||||||
|
@ -268,7 +269,7 @@ static double* _getDataPointer(HeightMapData* data, int x, int z, HeightMapData*
|
||||||
|
|
||||||
/* Extend the rowgroup at end */
|
/* Extend the rowgroup at end */
|
||||||
pixel_group->xend++;
|
pixel_group->xend++;
|
||||||
pixel = naiveArrayInsert((void**)&pixel_group->height, sizeof(double), pixel_group->xend - pixel_group->xstart, pixel_group->xend - pixel_group->xstart);
|
pixel = (double*)naiveArrayInsert((void**)&pixel_group->height, sizeof(double), pixel_group->xend - pixel_group->xstart, pixel_group->xend - pixel_group->xstart);
|
||||||
data->memsize += sizeof(double);
|
data->memsize += sizeof(double);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -322,7 +323,7 @@ TerrainHeightMap* terrainHeightMapCreate(TerrainDefinition* terrain)
|
||||||
{
|
{
|
||||||
TerrainHeightMap* result;
|
TerrainHeightMap* result;
|
||||||
|
|
||||||
result = malloc(sizeof(TerrainHeightMap));
|
result = new TerrainHeightMap;
|
||||||
result->terrain = terrain;
|
result->terrain = terrain;
|
||||||
_initData(&result->merged_data);
|
_initData(&result->merged_data);
|
||||||
_initData(&result->brush_data);
|
_initData(&result->brush_data);
|
||||||
|
@ -334,7 +335,7 @@ void terrainHeightmapDelete(TerrainHeightMap* heightmap)
|
||||||
{
|
{
|
||||||
_deleteData(&heightmap->merged_data);
|
_deleteData(&heightmap->merged_data);
|
||||||
_deleteData(&heightmap->brush_data);
|
_deleteData(&heightmap->brush_data);
|
||||||
free(heightmap);
|
delete heightmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void terrainHeightmapCopy(TerrainHeightMap* source, TerrainHeightMap* destination)
|
void terrainHeightmapCopy(TerrainHeightMap* source, TerrainHeightMap* destination)
|
||||||
|
@ -516,7 +517,7 @@ void terrainBrushElevation(TerrainHeightMap* heightmap, TerrainBrush* brush, dou
|
||||||
_applyBrush(heightmap, brush, value, NULL, _applyBrushElevation);
|
_applyBrush(heightmap, brush, value, NULL, _applyBrushElevation);
|
||||||
}
|
}
|
||||||
|
|
||||||
static double _applyBrushFlatten(TerrainHeightMap* heightmap, TerrainBrush* brush, double x, double z, double basevalue, double influence, double force, void* data)
|
static double _applyBrushFlatten(TerrainHeightMap* heightmap, TerrainBrush* brush, double, double, double basevalue, double influence, double force, void* data)
|
||||||
{
|
{
|
||||||
UNUSED(heightmap);
|
UNUSED(heightmap);
|
||||||
UNUSED(brush);
|
UNUSED(brush);
|
|
@ -58,9 +58,9 @@ Renderer* terrainCreatePreviewRenderer()
|
||||||
result->atmosphere->getLightingStatus = _getLightingStatus;
|
result->atmosphere->getLightingStatus = _getLightingStatus;
|
||||||
|
|
||||||
TexturesDefinition* textures;
|
TexturesDefinition* textures;
|
||||||
textures = TexturesDefinitionClass.create();
|
textures = (TexturesDefinition*)TexturesDefinitionClass.create();
|
||||||
layersClear(textures->layers);
|
layersClear(textures->layers);
|
||||||
TexturesLayerDefinition* layer = layersGetLayer(textures->layers, layersAddLayer(textures->layers, NULL));
|
TexturesLayerDefinition* layer = (TexturesLayerDefinition*)layersGetLayer(textures->layers, layersAddLayer(textures->layers, NULL));
|
||||||
zoneClear(layer->terrain_zone);
|
zoneClear(layer->terrain_zone);
|
||||||
layer->displacement_height = 0.0;
|
layer->displacement_height = 0.0;
|
||||||
layer->material.base = colorToHSL(COLOR_WHITE);
|
layer->material.base = colorToHSL(COLOR_WHITE);
|
|
@ -26,7 +26,7 @@ static inline Vector3 _getPoint(TerrainDefinition* definition, Renderer* rendere
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Color _postProcessFragment(Renderer* renderer, Vector3 point, void* data)
|
static Color _postProcessFragment(Renderer* renderer, Vector3 point, void*)
|
||||||
{
|
{
|
||||||
double precision;
|
double precision;
|
||||||
|
|
||||||
|
@ -228,14 +228,14 @@ static int _parallelJobCallback(ParallelQueue* queue, int job_id, void* data, in
|
||||||
|
|
||||||
static int _standardTessellationCallback(Renderer* renderer, TerrainChunkInfo* chunk, double progress)
|
static int _standardTessellationCallback(Renderer* renderer, TerrainChunkInfo* chunk, double progress)
|
||||||
{
|
{
|
||||||
ParallelRasterInfo* info = malloc(sizeof(ParallelRasterInfo));
|
ParallelRasterInfo* info = new ParallelRasterInfo;
|
||||||
|
|
||||||
info->renderer = renderer;
|
info->renderer = renderer;
|
||||||
info->chunk = *chunk;
|
info->chunk = *chunk;
|
||||||
|
|
||||||
if (!parallelQueueAddJob(renderer->customData[0], _parallelJobCallback, info))
|
if (!parallelQueueAddJob((ParallelQueue*)renderer->customData[0], _parallelJobCallback, info))
|
||||||
{
|
{
|
||||||
free(info);
|
delete info;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer->render_progress = 0.05 * progress;
|
renderer->render_progress = 0.05 * progress;
|
|
@ -311,8 +311,8 @@ static TerrainRenderer* _createRenderer()
|
||||||
{
|
{
|
||||||
TerrainRenderer* result;
|
TerrainRenderer* result;
|
||||||
|
|
||||||
result = malloc(sizeof (TerrainRenderer));
|
result = new TerrainRenderer;
|
||||||
result->definition = TerrainDefinitionClass.create();
|
result->definition = (TerrainDefinition*)TerrainDefinitionClass.create();
|
||||||
|
|
||||||
result->castRay = _fakeCastRay;
|
result->castRay = _fakeCastRay;
|
||||||
result->getHeight = _fakeGetHeight;
|
result->getHeight = _fakeGetHeight;
|
||||||
|
@ -326,7 +326,7 @@ static TerrainRenderer* _createRenderer()
|
||||||
static void _deleteRenderer(TerrainRenderer* renderer)
|
static void _deleteRenderer(TerrainRenderer* renderer)
|
||||||
{
|
{
|
||||||
TerrainDefinitionClass.destroy(renderer->definition);
|
TerrainDefinitionClass.destroy(renderer->definition);
|
||||||
free(renderer);
|
delete renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _bindRenderer(Renderer* renderer, TerrainDefinition* definition)
|
static void _bindRenderer(Renderer* renderer, TerrainDefinition* definition)
|
|
@ -11,7 +11,7 @@ static void _validateDefinition(TexturesDefinition* definition)
|
||||||
|
|
||||||
static TexturesDefinition* _createDefinition()
|
static TexturesDefinition* _createDefinition()
|
||||||
{
|
{
|
||||||
TexturesDefinition* definition = malloc(sizeof(TexturesDefinition));
|
TexturesDefinition* definition = new TexturesDefinition;
|
||||||
|
|
||||||
definition->layers = layersCreate(texturesGetLayerType(), TEXTURES_MAX_LAYERS);
|
definition->layers = layersCreate(texturesGetLayerType(), TEXTURES_MAX_LAYERS);
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ static TexturesDefinition* _createDefinition()
|
||||||
static void _deleteDefinition(TexturesDefinition* definition)
|
static void _deleteDefinition(TexturesDefinition* definition)
|
||||||
{
|
{
|
||||||
layersDelete(definition->layers);
|
layersDelete(definition->layers);
|
||||||
free(definition);
|
delete definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _copyDefinition(TexturesDefinition* source, TexturesDefinition* destination)
|
static void _copyDefinition(TexturesDefinition* source, TexturesDefinition* destination)
|
||||||
|
@ -82,7 +82,7 @@ static TexturesLayerDefinition* _layerCreateDefinition()
|
||||||
{
|
{
|
||||||
TexturesLayerDefinition* result;
|
TexturesLayerDefinition* result;
|
||||||
|
|
||||||
result = malloc(sizeof(TexturesLayerDefinition));
|
result = new TexturesLayerDefinition;
|
||||||
|
|
||||||
result->terrain_zone = zoneCreate();
|
result->terrain_zone = zoneCreate();
|
||||||
result->_displacement_noise = noiseCreateGenerator();
|
result->_displacement_noise = noiseCreateGenerator();
|
||||||
|
@ -100,7 +100,7 @@ static void _layerDeleteDefinition(TexturesLayerDefinition* definition)
|
||||||
zoneDelete(definition->terrain_zone);
|
zoneDelete(definition->terrain_zone);
|
||||||
noiseDeleteGenerator(definition->_displacement_noise);
|
noiseDeleteGenerator(definition->_displacement_noise);
|
||||||
noiseDeleteGenerator(definition->_detail_noise);
|
noiseDeleteGenerator(definition->_detail_noise);
|
||||||
free(definition);
|
delete definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _layerCopyDefinition(TexturesLayerDefinition* source, TexturesLayerDefinition* destination)
|
static void _layerCopyDefinition(TexturesLayerDefinition* source, TexturesLayerDefinition* destination)
|
|
@ -5,45 +5,45 @@ void texturesAutoPreset(TexturesDefinition* definition, TexturesPreset preset)
|
||||||
TexturesLayerDefinition* layer;
|
TexturesLayerDefinition* layer;
|
||||||
layersClear(definition->layers);
|
layersClear(definition->layers);
|
||||||
|
|
||||||
layer = layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_MUD);
|
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_MUD);
|
||||||
layersSetName(definition->layers, 0, "Mud");
|
layersSetName(definition->layers, 0, "Mud");
|
||||||
|
|
||||||
if (preset == TEXTURES_PRESET_FULL)
|
if (preset == TEXTURES_PRESET_FULL)
|
||||||
{
|
{
|
||||||
layer = layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_ROCK);
|
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_ROCK);
|
||||||
layersSetName(definition->layers, 1, "Ground");
|
layersSetName(definition->layers, 1, "Ground");
|
||||||
|
|
||||||
layer = layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_GRASS);
|
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_GRASS);
|
||||||
layersSetName(definition->layers, 2, "Grass");
|
layersSetName(definition->layers, 2, "Grass");
|
||||||
|
|
||||||
layer = layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_SAND);
|
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_SAND);
|
||||||
layersSetName(definition->layers, 3, "Sand");
|
layersSetName(definition->layers, 3, "Sand");
|
||||||
|
|
||||||
layer = layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_SNOW);
|
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_SNOW);
|
||||||
layersSetName(definition->layers, 4, "Snow");
|
layersSetName(definition->layers, 4, "Snow");
|
||||||
}
|
}
|
||||||
else if (preset == TEXTURES_PRESET_IRELAND)
|
else if (preset == TEXTURES_PRESET_IRELAND)
|
||||||
{
|
{
|
||||||
layer = layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_ROCK);
|
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_ROCK);
|
||||||
layersSetName(definition->layers, 1, "Ground");
|
layersSetName(definition->layers, 1, "Ground");
|
||||||
|
|
||||||
layer = layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_GRASS);
|
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_GRASS);
|
||||||
layersSetName(definition->layers, 2, "Grass");
|
layersSetName(definition->layers, 2, "Grass");
|
||||||
}
|
}
|
||||||
else if (preset == TEXTURES_PRESET_ALPS)
|
else if (preset == TEXTURES_PRESET_ALPS)
|
||||||
{
|
{
|
||||||
layer = layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_ROCK);
|
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_ROCK);
|
||||||
layersSetName(definition->layers, 1, "Ground");
|
layersSetName(definition->layers, 1, "Ground");
|
||||||
|
|
||||||
layer = layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
layer = (TexturesLayerDefinition*)layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL));
|
||||||
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_SNOW);
|
texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_SNOW);
|
||||||
layersSetName(definition->layers, 2, "Snow");
|
layersSetName(definition->layers, 2, "Snow");
|
||||||
}
|
}
|
|
@ -1,13 +1,13 @@
|
||||||
#ifndef TEX_PREVIEW_H
|
#ifndef TEX_PREVIEW_H
|
||||||
#define TEX_PREVIEW_H
|
#define TEX_PREVIEW_H
|
||||||
|
|
||||||
|
#include "rendering/renderer.h"
|
||||||
|
#include "rendering/textures/public.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "rendering/renderer.h"
|
|
||||||
#include "rendering/textures/public.h"
|
|
||||||
|
|
||||||
/* Single layer coverage */
|
/* Single layer coverage */
|
||||||
RENDERINGSHARED_EXPORT void TexturesPreviewLayerCoverage_bind(Renderer* renderer, TexturesDefinition* definition);
|
RENDERINGSHARED_EXPORT void TexturesPreviewLayerCoverage_bind(Renderer* renderer, TexturesDefinition* definition);
|
||||||
RENDERINGSHARED_EXPORT Color TexturesPreviewLayerCoverage_getColor(Renderer* renderer, double x, double y, double scaling, int layer);
|
RENDERINGSHARED_EXPORT Color TexturesPreviewLayerCoverage_getColor(Renderer* renderer, double x, double y, double scaling, int layer);
|
||||||
|
|
|
@ -91,7 +91,7 @@ static Vector3 _realDisplaceTerrain(Renderer* renderer, TerrainResult terrain)
|
||||||
n = layersCount(textures->layers);
|
n = layersCount(textures->layers);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
TexturesLayerDefinition* layer = layersGetLayer(textures->layers, i);
|
TexturesLayerDefinition* layer = (TexturesLayerDefinition*)layersGetLayer(textures->layers, i);
|
||||||
|
|
||||||
if (layer->displacement_height > 0.0)
|
if (layer->displacement_height > 0.0)
|
||||||
{
|
{
|
||||||
|
@ -106,7 +106,7 @@ static Vector3 _realDisplaceTerrain(Renderer* renderer, TerrainResult terrain)
|
||||||
|
|
||||||
static double _realGetBasePresence(Renderer* renderer, int layer, TerrainResult terrain)
|
static double _realGetBasePresence(Renderer* renderer, int layer, TerrainResult terrain)
|
||||||
{
|
{
|
||||||
TexturesLayerDefinition* layerdef = layersGetLayer(renderer->textures->definition->layers, layer);
|
TexturesLayerDefinition* layerdef = (TexturesLayerDefinition*)layersGetLayer(renderer->textures->definition->layers, layer);
|
||||||
return texturesGetLayerBasePresence(layerdef, terrain);
|
return texturesGetLayerBasePresence(layerdef, terrain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ static TexturesResult _realApplyToTerrain(Renderer* renderer, double x, double z
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
TexturesLayerResult* info = result.layers + i;
|
TexturesLayerResult* info = result.layers + i;
|
||||||
info->layer = layersGetLayer(textures->layers, i);
|
info->layer = (TexturesLayerDefinition*)layersGetLayer(textures->layers, i);
|
||||||
info->presence = renderer->textures->getBasePresence(renderer, i, terrain);
|
info->presence = renderer->textures->getBasePresence(renderer, i, terrain);
|
||||||
if (info->presence > 0.0)
|
if (info->presence > 0.0)
|
||||||
{
|
{
|
||||||
|
@ -195,8 +195,8 @@ static TexturesRenderer* _createRenderer()
|
||||||
{
|
{
|
||||||
TexturesRenderer* result;
|
TexturesRenderer* result;
|
||||||
|
|
||||||
result = malloc(sizeof(TexturesRenderer));
|
result = new TexturesRenderer;
|
||||||
result->definition = TexturesDefinitionClass.create();
|
result->definition = (TexturesDefinition*)TexturesDefinitionClass.create();
|
||||||
|
|
||||||
result->displaceTerrain = _fakeDisplaceTerrain;
|
result->displaceTerrain = _fakeDisplaceTerrain;
|
||||||
result->getBasePresence = _fakeGetBasePresence;
|
result->getBasePresence = _fakeGetBasePresence;
|
||||||
|
@ -208,7 +208,7 @@ static TexturesRenderer* _createRenderer()
|
||||||
static void _deleteRenderer(TexturesRenderer* renderer)
|
static void _deleteRenderer(TexturesRenderer* renderer)
|
||||||
{
|
{
|
||||||
TexturesDefinitionClass.destroy(renderer->definition);
|
TexturesDefinitionClass.destroy(renderer->definition);
|
||||||
free(renderer);
|
delete renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _bindRenderer(Renderer* renderer, TexturesDefinition* definition)
|
static void _bindRenderer(Renderer* renderer, TexturesDefinition* definition)
|
|
@ -40,7 +40,7 @@ double texturesGetMaximalDisplacement(TexturesDefinition* textures)
|
||||||
n = layersCount(textures->layers);
|
n = layersCount(textures->layers);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
TexturesLayerDefinition* layer = layersGetLayer(textures->layers, i);
|
TexturesLayerDefinition* layer = (TexturesLayerDefinition*)layersGetLayer(textures->layers, i);
|
||||||
|
|
||||||
if (layer->displacement_height > 0.0)
|
if (layer->displacement_height > 0.0)
|
||||||
{
|
{
|
|
@ -14,9 +14,9 @@ CacheFile* cacheFileCreateAccessor(const char* module, const char* ext, const ch
|
||||||
{
|
{
|
||||||
CacheFile* result;
|
CacheFile* result;
|
||||||
|
|
||||||
result = (CacheFile*)malloc(sizeof(CacheFile));
|
result = new CacheFile;
|
||||||
result->datapath = malloc(sizeof(char) * 501);
|
result->datapath = (char*)malloc(sizeof(char) * 501);
|
||||||
result->filepath = malloc(sizeof(char) * 501);
|
result->filepath = (char*)malloc(sizeof(char) * 501);
|
||||||
|
|
||||||
snprintf(result->datapath, 500, "/usr/share/paysages3d/%s-%s-%d-%d-%d-%d-%d.%s", module, tag1, tag2, tag3, tag4, tag5, tag6, ext);
|
snprintf(result->datapath, 500, "/usr/share/paysages3d/%s-%s-%d-%d-%d-%d-%d.%s", module, tag1, tag2, tag3, tag4, tag5, tag6, ext);
|
||||||
snprintf(result->filepath, 500, "./cache/%s-%s-%d-%d-%d-%d-%d.%s", module, tag1, tag2, tag3, tag4, tag5, tag6, ext);
|
snprintf(result->filepath, 500, "./cache/%s-%s-%d-%d-%d-%d-%d.%s", module, tag1, tag2, tag3, tag4, tag5, tag6, ext);
|
||||||
|
@ -28,7 +28,7 @@ void cacheFileDeleteAccessor(CacheFile* cache)
|
||||||
{
|
{
|
||||||
free(cache->datapath);
|
free(cache->datapath);
|
||||||
free(cache->filepath);
|
free(cache->filepath);
|
||||||
free(cache);
|
delete cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cacheFileIsReadable(CacheFile* cache)
|
int cacheFileIsReadable(CacheFile* cache)
|
|
@ -223,7 +223,7 @@ ColorProfile* colorProfileCreate()
|
||||||
{
|
{
|
||||||
ColorProfile* profile;
|
ColorProfile* profile;
|
||||||
|
|
||||||
profile = malloc(sizeof (ColorProfile));
|
profile = new ColorProfile;
|
||||||
|
|
||||||
colorProfileSetToneMapping(profile, TONE_MAPPING_UNCHARTED, 2.0);
|
colorProfileSetToneMapping(profile, TONE_MAPPING_UNCHARTED, 2.0);
|
||||||
colorProfileClear(profile);
|
colorProfileClear(profile);
|
||||||
|
@ -233,7 +233,7 @@ ColorProfile* colorProfileCreate()
|
||||||
|
|
||||||
void colorProfileDelete(ColorProfile* profile)
|
void colorProfileDelete(ColorProfile* profile)
|
||||||
{
|
{
|
||||||
free(profile);
|
delete profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double _uncharted2Tonemap(double x)
|
static inline double _uncharted2Tonemap(double x)
|
||||||
|
@ -347,7 +347,7 @@ ColorGradation* colorGradationCreate()
|
||||||
{
|
{
|
||||||
ColorGradation* result;
|
ColorGradation* result;
|
||||||
|
|
||||||
result = malloc(sizeof (ColorGradation));
|
result = new ColorGradation;
|
||||||
result->red = curveCreate();
|
result->red = curveCreate();
|
||||||
result->green = curveCreate();
|
result->green = curveCreate();
|
||||||
result->blue = curveCreate();
|
result->blue = curveCreate();
|
||||||
|
@ -360,7 +360,7 @@ void colorGradationDelete(ColorGradation* gradation)
|
||||||
curveDelete(gradation->red);
|
curveDelete(gradation->red);
|
||||||
curveDelete(gradation->green);
|
curveDelete(gradation->green);
|
||||||
curveDelete(gradation->blue);
|
curveDelete(gradation->blue);
|
||||||
free(gradation);
|
delete gradation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void colorGradationCopy(ColorGradation* source, ColorGradation* destination)
|
void colorGradationCopy(ColorGradation* source, ColorGradation* destination)
|
|
@ -17,7 +17,7 @@ Curve* curveCreate()
|
||||||
{
|
{
|
||||||
Curve* result;
|
Curve* result;
|
||||||
|
|
||||||
result = malloc(sizeof(Curve));
|
result = new Curve;
|
||||||
result->nbpoints = 0;
|
result->nbpoints = 0;
|
||||||
result->default_value = 0.0;
|
result->default_value = 0.0;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ Curve* curveCreate()
|
||||||
|
|
||||||
void curveDelete(Curve* curve)
|
void curveDelete(Curve* curve)
|
||||||
{
|
{
|
||||||
free(curve);
|
delete curve;
|
||||||
}
|
}
|
||||||
|
|
||||||
void curveCopy(Curve* source, Curve* destination)
|
void curveCopy(Curve* source, Curve* destination)
|
|
@ -10,7 +10,7 @@ static int _tryDataPath(const char* path)
|
||||||
{
|
{
|
||||||
char* buffer;
|
char* buffer;
|
||||||
|
|
||||||
buffer = malloc(sizeof (char) * (strlen(path) + 30));
|
buffer = (char*)malloc(sizeof (char) * (strlen(path) + 30));
|
||||||
strcpy(buffer, path);
|
strcpy(buffer, path);
|
||||||
strcat(buffer, "/.paysages_data");
|
strcat(buffer, "/.paysages_data");
|
||||||
|
|
|
@ -34,7 +34,7 @@ LightingManager* lightingManagerCreate()
|
||||||
{
|
{
|
||||||
LightingManager* result;
|
LightingManager* result;
|
||||||
|
|
||||||
result = malloc(sizeof(LightingManager));
|
result = new LightingManager;
|
||||||
result->callbacks_count = 0;
|
result->callbacks_count = 0;
|
||||||
result->specularity_enabled = 1;
|
result->specularity_enabled = 1;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ LightingManager* lightingManagerCreate()
|
||||||
|
|
||||||
void lightingManagerDelete(LightingManager* filter)
|
void lightingManagerDelete(LightingManager* filter)
|
||||||
{
|
{
|
||||||
free(filter);
|
delete filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lightingManagerRegisterFilter(LightingManager* filter, FuncLightingAlterLight callback, void* data)
|
void lightingManagerRegisterFilter(LightingManager* filter, FuncLightingAlterLight callback, void* data)
|
||||||
|
@ -76,7 +76,7 @@ LightStatus* lightingCreateStatus(LightingManager* manager, Vector3 location, Ve
|
||||||
{
|
{
|
||||||
LightStatus* result;
|
LightStatus* result;
|
||||||
|
|
||||||
result = malloc(sizeof(LightStatus));
|
result = new LightStatus;
|
||||||
result->manager = manager;
|
result->manager = manager;
|
||||||
result->location = location;
|
result->location = location;
|
||||||
result->eye = eye;
|
result->eye = eye;
|
||||||
|
@ -87,7 +87,7 @@ LightStatus* lightingCreateStatus(LightingManager* manager, Vector3 location, Ve
|
||||||
|
|
||||||
void lightingDeleteStatus(LightStatus* status)
|
void lightingDeleteStatus(LightStatus* status)
|
||||||
{
|
{
|
||||||
free(status);
|
delete status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lightingPushLight(LightStatus* status, LightDefinition* light)
|
void lightingPushLight(LightStatus* status, LightDefinition* light)
|
|
@ -50,8 +50,3 @@ void* memory2dRealloc(void* data, int datasize, int oldxsize, int oldysize, int
|
||||||
free(data);
|
free(data);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void memory2dScrolling(void* data, int datasize, int xsize, int ysize, int xoffset, int yoffset)
|
|
||||||
{
|
|
||||||
/* TODO */
|
|
||||||
}
|
|
|
@ -12,7 +12,6 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT void* memory2dRealloc(void* data, int datasize, int oldxsize, int oldysize, int newxsize, int newysize, int xoffset, int yoffset);
|
RENDERINGSHARED_EXPORT void* memory2dRealloc(void* data, int datasize, int oldxsize, int oldysize, int newxsize, int newysize, int xoffset, int yoffset);
|
||||||
RENDERINGSHARED_EXPORT void memory2dScrolling(void* data, int datasize, int xsize, int ysize, int xoffset, int yoffset);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,13 +239,13 @@ ParallelQueue* parallelQueueCreate(int collect)
|
||||||
|
|
||||||
assert(!collect); /* Not fully implemented yet ! */
|
assert(!collect); /* Not fully implemented yet ! */
|
||||||
|
|
||||||
ParallelQueue* queue = malloc(sizeof(ParallelQueue));
|
ParallelQueue* queue = new ParallelQueue;
|
||||||
|
|
||||||
queue->collect = collect;
|
queue->collect = collect;
|
||||||
queue->stopping = 0;
|
queue->stopping = 0;
|
||||||
queue->lock = mutexCreate();
|
queue->lock = mutexCreate();
|
||||||
|
|
||||||
queue->jobs = malloc(sizeof(ParallelJob) * QUEUE_SIZE);
|
queue->jobs = new ParallelJob[QUEUE_SIZE];
|
||||||
for (i = 0; i < QUEUE_SIZE; i++)
|
for (i = 0; i < QUEUE_SIZE; i++)
|
||||||
{
|
{
|
||||||
queue->jobs[i].state = JOB_STATE_FREE;
|
queue->jobs[i].state = JOB_STATE_FREE;
|
||||||
|
@ -258,7 +258,7 @@ ParallelQueue* parallelQueueCreate(int collect)
|
||||||
|
|
||||||
/* Start workers */
|
/* Start workers */
|
||||||
queue->workers_count = systemGetCoreCount();
|
queue->workers_count = systemGetCoreCount();
|
||||||
queue->workers = malloc(sizeof(Thread*) * queue->workers_count);
|
queue->workers = new Thread*[queue->workers_count];
|
||||||
for (i = 0; i < queue->workers_count; i++)
|
for (i = 0; i < queue->workers_count; i++)
|
||||||
{
|
{
|
||||||
queue->workers[i] = threadCreate((ThreadFunction)_queueThreadCallback, queue);
|
queue->workers[i] = threadCreate((ThreadFunction)_queueThreadCallback, queue);
|
||||||
|
@ -275,9 +275,9 @@ void parallelQueueDelete(ParallelQueue* queue)
|
||||||
assert(queue->jobs_count == 0);
|
assert(queue->jobs_count == 0);
|
||||||
|
|
||||||
mutexDestroy(queue->lock);
|
mutexDestroy(queue->lock);
|
||||||
free(queue->jobs);
|
delete[] queue->jobs;
|
||||||
free(queue->workers);
|
delete[] queue->workers;
|
||||||
free(queue);
|
delete queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void parallelQueueInterrupt(ParallelQueue* queue)
|
void parallelQueueInterrupt(ParallelQueue* queue)
|
||||||
|
@ -350,7 +350,7 @@ int parallelQueueAddJob(ParallelQueue* queue, FuncParallelJob func_process, void
|
||||||
return job.id;
|
return job.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parallelQueueCollectJobs(FuncParallelJob func_collect)
|
int parallelQueueCollectJobs(FuncParallelJob)
|
||||||
{
|
{
|
||||||
/* TODO */
|
/* TODO */
|
||||||
return 0;
|
return 0;
|
|
@ -51,18 +51,18 @@ Texture2D* texture2DCreate(int xsize, int ysize)
|
||||||
|
|
||||||
assert(xsize > 0 && ysize > 0);
|
assert(xsize > 0 && ysize > 0);
|
||||||
|
|
||||||
result = (Texture2D*)malloc(sizeof(Texture2D));
|
result = new Texture2D;
|
||||||
result->xsize = xsize;
|
result->xsize = xsize;
|
||||||
result->ysize = ysize;
|
result->ysize = ysize;
|
||||||
result->data = malloc(sizeof(Color) * xsize * ysize);
|
result->data = new Color[xsize * ysize];
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void texture2DDelete(Texture2D* tex)
|
void texture2DDelete(Texture2D* tex)
|
||||||
{
|
{
|
||||||
free(tex->data);
|
delete[] tex->data;
|
||||||
free(tex);
|
delete tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void texture2DGetSize(Texture2D* tex, int* xsize, int* ysize)
|
void texture2DGetSize(Texture2D* tex, int* xsize, int* ysize)
|
||||||
|
@ -186,7 +186,8 @@ void texture2DLoad(PackStream* stream, Texture2D* tex)
|
||||||
packReadInt(stream, &tex->xsize);
|
packReadInt(stream, &tex->xsize);
|
||||||
packReadInt(stream, &tex->ysize);
|
packReadInt(stream, &tex->ysize);
|
||||||
n = tex->xsize * tex->ysize;
|
n = tex->xsize * tex->ysize;
|
||||||
tex->data = realloc(tex->data, sizeof(Color) * n);
|
delete[] tex->data;
|
||||||
|
tex->data = new Color[n];
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
colorLoad(stream, tex->data + i);
|
colorLoad(stream, tex->data + i);
|
||||||
|
@ -207,19 +208,19 @@ Texture3D* texture3DCreate(int xsize, int ysize, int zsize)
|
||||||
|
|
||||||
assert(xsize > 0 && ysize > 0 && zsize > 0);
|
assert(xsize > 0 && ysize > 0 && zsize > 0);
|
||||||
|
|
||||||
result = (Texture3D*)malloc(sizeof(Texture3D));
|
result = new Texture3D;
|
||||||
result->xsize = xsize;
|
result->xsize = xsize;
|
||||||
result->ysize = ysize;
|
result->ysize = ysize;
|
||||||
result->zsize = zsize;
|
result->zsize = zsize;
|
||||||
result->data = malloc(sizeof(Color) * xsize * ysize * zsize);
|
result->data = new Color[xsize * ysize * zsize];
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void texture3DDelete(Texture3D* tex)
|
void texture3DDelete(Texture3D* tex)
|
||||||
{
|
{
|
||||||
free(tex->data);
|
delete[] tex->data;
|
||||||
free(tex);
|
delete tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void texture3DGetSize(Texture3D* tex, int* xsize, int* ysize, int* zsize)
|
void texture3DGetSize(Texture3D* tex, int* xsize, int* ysize, int* zsize)
|
||||||
|
@ -368,7 +369,8 @@ void texture3DLoad(PackStream* stream, Texture3D* tex)
|
||||||
packReadInt(stream, &tex->ysize);
|
packReadInt(stream, &tex->ysize);
|
||||||
packReadInt(stream, &tex->zsize);
|
packReadInt(stream, &tex->zsize);
|
||||||
n = tex->xsize * tex->ysize * tex->zsize;
|
n = tex->xsize * tex->ysize * tex->zsize;
|
||||||
tex->data = realloc(tex->data, sizeof(Color) * n);
|
delete[] tex->data;
|
||||||
|
tex->data = new Color[n];
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
colorLoad(stream, tex->data + i);
|
colorLoad(stream, tex->data + i);
|
||||||
|
@ -400,20 +402,20 @@ Texture4D* texture4DCreate(int xsize, int ysize, int zsize, int wsize)
|
||||||
|
|
||||||
assert(xsize > 0 && ysize > 0 && zsize > 0 && wsize > 0);
|
assert(xsize > 0 && ysize > 0 && zsize > 0 && wsize > 0);
|
||||||
|
|
||||||
result = (Texture4D*)malloc(sizeof(Texture4D));
|
result = new Texture4D;
|
||||||
result->xsize = xsize;
|
result->xsize = xsize;
|
||||||
result->ysize = ysize;
|
result->ysize = ysize;
|
||||||
result->zsize = zsize;
|
result->zsize = zsize;
|
||||||
result->wsize = wsize;
|
result->wsize = wsize;
|
||||||
result->data = malloc(sizeof(Color) * xsize * ysize * zsize * wsize);
|
result->data = new Color[xsize * ysize * zsize * wsize];
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void texture4DDelete(Texture4D* tex)
|
void texture4DDelete(Texture4D* tex)
|
||||||
{
|
{
|
||||||
free(tex->data);
|
delete[] tex->data;
|
||||||
free(tex);
|
delete tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void texture4DGetSize(Texture4D* tex, int* xsize, int* ysize, int* zsize, int* wsize)
|
void texture4DGetSize(Texture4D* tex, int* xsize, int* ysize, int* zsize, int* wsize)
|
||||||
|
@ -595,7 +597,8 @@ void texture4DLoad(PackStream* stream, Texture4D* tex)
|
||||||
packReadInt(stream, &tex->zsize);
|
packReadInt(stream, &tex->zsize);
|
||||||
packReadInt(stream, &tex->wsize);
|
packReadInt(stream, &tex->wsize);
|
||||||
n = tex->xsize * tex->ysize * tex->zsize * tex->wsize;
|
n = tex->xsize * tex->ysize * tex->zsize * tex->wsize;
|
||||||
tex->data = realloc(tex->data, sizeof(Color) * n);
|
delete[] tex->data;
|
||||||
|
tex->data = new Color[n];
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
colorLoad(stream, tex->data + i);
|
colorLoad(stream, tex->data + i);
|
|
@ -5,14 +5,14 @@
|
||||||
* Pixel based textures.
|
* Pixel based textures.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../rendering_global.h"
|
#include "../rendering_global.h"
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "PackStream.h"
|
#include "PackStream.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct Texture2D Texture2D;
|
typedef struct Texture2D Texture2D;
|
||||||
typedef struct Texture3D Texture3D;
|
typedef struct Texture3D Texture3D;
|
||||||
typedef struct Texture4D Texture4D;
|
typedef struct Texture4D Texture4D;
|
||||||
|
|
|
@ -23,7 +23,7 @@ static void _validateDefinition(WaterDefinition* definition)
|
||||||
|
|
||||||
static WaterDefinition* _createDefinition()
|
static WaterDefinition* _createDefinition()
|
||||||
{
|
{
|
||||||
WaterDefinition* definition = malloc(sizeof(WaterDefinition));
|
WaterDefinition* definition = new WaterDefinition;
|
||||||
|
|
||||||
definition->_waves_noise = noiseCreateGenerator();
|
definition->_waves_noise = noiseCreateGenerator();
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ static WaterDefinition* _createDefinition()
|
||||||
static void _deleteDefinition(WaterDefinition* definition)
|
static void _deleteDefinition(WaterDefinition* definition)
|
||||||
{
|
{
|
||||||
noiseDeleteGenerator(definition->_waves_noise);
|
noiseDeleteGenerator(definition->_waves_noise);
|
||||||
free(definition);
|
delete definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _copyDefinition(WaterDefinition* source, WaterDefinition* destination)
|
static void _copyDefinition(WaterDefinition* source, WaterDefinition* destination)
|
|
@ -99,7 +99,7 @@ void waterRenderSurface(Renderer* renderer)
|
||||||
|
|
||||||
for (i = 0; i < chunk_count - 1; i++)
|
for (i = 0; i < chunk_count - 1; i++)
|
||||||
{
|
{
|
||||||
info = malloc(sizeof(ParallelRasterInfo));
|
info = new ParallelRasterInfo;
|
||||||
|
|
||||||
info->renderer = renderer;
|
info->renderer = renderer;
|
||||||
info->cx = cx;
|
info->cx = cx;
|
||||||
|
@ -111,7 +111,7 @@ void waterRenderSurface(Renderer* renderer)
|
||||||
|
|
||||||
if (!parallelQueueAddJob(queue, _parallelJobCallback, info))
|
if (!parallelQueueAddJob(queue, _parallelJobCallback, info))
|
||||||
{
|
{
|
||||||
free(info);
|
delete info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,8 +302,8 @@ static WaterRenderer* _createRenderer()
|
||||||
{
|
{
|
||||||
WaterRenderer* result;
|
WaterRenderer* result;
|
||||||
|
|
||||||
result = malloc(sizeof(WaterRenderer));
|
result = new WaterRenderer;
|
||||||
result->definition = WaterDefinitionClass.create();
|
result->definition = (WaterDefinition*)WaterDefinitionClass.create();
|
||||||
|
|
||||||
result->getHeightInfo = _fakeGetHeightInfo;
|
result->getHeightInfo = _fakeGetHeightInfo;
|
||||||
result->getHeight = _fakeGetHeight;
|
result->getHeight = _fakeGetHeight;
|
||||||
|
@ -315,7 +315,7 @@ static WaterRenderer* _createRenderer()
|
||||||
static void _deleteRenderer(WaterRenderer* renderer)
|
static void _deleteRenderer(WaterRenderer* renderer)
|
||||||
{
|
{
|
||||||
WaterDefinitionClass.destroy(renderer->definition);
|
WaterDefinitionClass.destroy(renderer->definition);
|
||||||
free(renderer);
|
delete renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _bindRenderer(Renderer* renderer, WaterDefinition* definition)
|
static void _bindRenderer(Renderer* renderer, WaterDefinition* definition)
|
Loading…
Reference in a new issue