Added renderer to RenderArea to gain access to camera

This commit is contained in:
Michaël Lemaire 2013-06-11 12:03:50 +02:00
parent d6663d84c6
commit 1b890849a8
4 changed files with 13 additions and 13 deletions

View file

@ -45,6 +45,7 @@ typedef struct
struct RenderArea
{
ColorProfile* hdr_mapping;
Renderer* renderer;
RenderParams params;
int pixel_count;
int pixel_done;
@ -77,7 +78,6 @@ typedef struct {
int pixel_done;
Thread* thread;
RenderArea* area;
Renderer* renderer;
} RenderChunk;
#define RENDER_INVERSE 1
@ -94,11 +94,12 @@ void renderQuit()
{
}
RenderArea* renderCreateArea()
RenderArea* renderCreateArea(Renderer* renderer)
{
RenderArea* result;
result = malloc(sizeof(RenderArea));
result->renderer = renderer;
result->hdr_mapping = colorProfileCreate();
result->params.width = 1;
result->params.height = 1;
@ -605,7 +606,7 @@ void* _renderPostProcessChunk(void* data)
callback = chunk->area->fragment_callbacks[fragment->flags.callback];
if (callback.function)
{
col = callback.function(chunk->renderer, fragment->data.location, callback.data);
col = callback.function(chunk->area->renderer, fragment->data.location, callback.data);
/*colorNormalize(&col);*/
}
else
@ -635,7 +636,7 @@ void* _renderPostProcessChunk(void* data)
}
#define MAX_CHUNKS 8
void renderPostProcess(RenderArea* area, Renderer* renderer, int nbchunks)
void renderPostProcess(RenderArea* area, int nbchunks)
{
volatile RenderChunk chunks[MAX_CHUNKS];
int i;
@ -663,12 +664,11 @@ void renderPostProcess(RenderArea* area, Renderer* renderer, int nbchunks)
{
chunks[i].thread = NULL;
chunks[i].area = area;
chunks[i].renderer = renderer;
}
running = 0;
loops = 0;
while ((y < ny && !renderer->render_interrupt) || running > 0)
while ((y < ny && !area->renderer->render_interrupt) || running > 0)
{
timeSleepMs(100);
@ -682,13 +682,13 @@ void renderPostProcess(RenderArea* area, Renderer* renderer, int nbchunks)
chunks[i].thread = NULL;
running--;
}
else if (renderer->render_interrupt)
else if (area->renderer->render_interrupt)
{
chunks[i].interrupt = 1;
}
}
if (y < ny && !chunks[i].thread && !renderer->render_interrupt)
if (y < ny && !chunks[i].thread && !area->renderer->render_interrupt)
{
chunks[i].finished = 0;
chunks[i].interrupt = 0;

View file

@ -28,7 +28,7 @@ typedef struct
void renderInit();
void renderQuit();
RenderArea* renderCreateArea();
RenderArea* renderCreateArea(Renderer* renderer);
void renderDeleteArea(RenderArea* area);
void renderSetParams(RenderArea* area, RenderParams params);
@ -39,7 +39,7 @@ void renderUpdate(RenderArea* area);
void renderPushTriangle(RenderArea* area, Vector3 pixel1, Vector3 pixel2, Vector3 pixel3, Vector3 location1, Vector3 location2, Vector3 location3, f_RenderFragmentCallback callback, void* callback_data);
void renderPostProcess(RenderArea* area, Renderer* renderer, int nbchunks);
void renderPostProcess(RenderArea* area, int nbchunks);
int renderSaveToFile(RenderArea* area, const char* path);
void renderSetPreviewCallbacks(RenderArea* area, RenderCallbackStart start, RenderCallbackDraw draw, RenderCallbackUpdate update);

View file

@ -122,7 +122,7 @@ Renderer* rendererCreate()
result->render_progress = 0.0;
result->is_rendering = 0;
result->render_camera = cameraCreateDefinition();
result->render_area = renderCreateArea();
result->render_area = renderCreateArea(result);
renderSetParams(result->render_area, params);
@ -213,7 +213,7 @@ void rendererStart(Renderer* renderer, RenderParams params)
threadJoin(thread);
renderer->is_rendering = 1;
renderPostProcess(renderer->render_area, renderer, core_count);
renderPostProcess(renderer->render_area, core_count);
renderer->is_rendering = 0;
}

View file

@ -49,7 +49,7 @@ START_TEST(test_render_quad)
renderClear(renderer->render_area);
renderer->pushQuad(renderer, v3(-1.0, 0.0, 1.0), v3(-1.0, 0.0, -1.0), v3(1.0, 0.0, -1.0), v3(1.0, 0.0, 1.0), _postProcessFragment, NULL);
renderPostProcess(renderer->render_area, renderer, tests_cpu_count);
renderPostProcess(renderer->render_area, tests_cpu_count);
renderSaveToFile(renderer->render_area, "./output/test_render_quad.png");