Photon Engine C API 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ph_c_core.h
Go to the documentation of this file.
1#pragma once
2
25// Note that this header should always be compatible to C.
26
27// HACK
28//#define PH_EXPORT_API
29
30// Checking the compiling environment.
31//#if defined(_MSC_VER)
33//
34// // Note: The use of dllexport implies a definition, while dllimport implies a declaration. To force a declaration,
35// // an "extern" keyword with dllexport is needed; otherwise, a definition is implied.
36//
37// #ifdef PH_EXPORT_API
38// #define PH_API __declspec(dllexport)
39// #else
40// #define PH_API __declspec(dllimport)
41// #endif
42//
43//#else
45//
46// // TODO
47// #ifdef EXPORT_PHOTON_API
48// #define PH_API
49// #else
50// #define PH_API
51// #endif
52//
53//#endif
54// end compiling environment check
55
56// FIXME: sort of hacked
57#define PH_API
58
59#include "ph_c_core_types.h"
60
61// HACK
68
69// HACK
70#define PH_NUM_RENDER_LAYERS 4
71#define PH_NUM_RENDER_STATE_INTEGERS 4
72#define PH_NUM_RENDER_STATE_REALS 4
73#define PH_MAX_NAME_LENGTH 128
74
75// HACK
81
82// HACK
89
90// HACK
96
97#ifdef __cplusplus
98extern "C" {
99#endif
100
102// starting and exiting Photon
103//
104
105extern PH_API void phConfigRendererResourceDirectory(const PhChar* directory);
106
107extern PH_API PhBool phInit();
108extern PH_API PhBool phExit();
109
111// Core Operations
112//
113
114// TODO: remove the word "film" from develop functions
115
118extern PH_API void phCreateEngine(PhUInt64* out_engineId, const PhUInt32 numRenderThreads);
119
120extern PH_API void phSetNumRenderThreads(PhUInt64 engineId, const PhUInt32 numRenderThreads);
121extern PH_API void phEnterCommand(PhUInt64 engineId, const PhChar* commandFragment);
122extern PH_API PhBool phLoadCommands(PhUInt64 engineId, const PhChar* filePath);
123extern PH_API void phRender(PhUInt64 engineId);
124
125// TODO: documentation
126extern PH_API void phUpdate(PhUInt64 engineId);
127
128extern PH_API void phGetRenderDimension(PhUInt64 engineId, PhUInt32* out_widthPx, PhUInt32* out_heightPx);
129
130// HACK
132 PhUInt64 engineId,
133 struct PHObservableRenderData* out_data);
134
135extern PH_API void phDeleteEngine(PhUInt64 engineId);
136extern PH_API void phSetWorkingDirectory(PhUInt64 engineId, const PhChar* workingDirectory);
137
138// REFACTOR: rename aquire to retrieve
139extern PH_API void phAquireFrame(PhUInt64 engineId, PhUInt64 channelIndex, PhUInt64 frameId);
140extern PH_API void phAquireFrameRaw(PhUInt64 engineId, PhUInt64 channelIndex, PhUInt64 frameId);
141
143// Frame Operations
144//
145
146extern PH_API void phCreateFrame(PhUInt64* out_frameId, PhUInt32 widthPx, PhUInt32 heightPx);
147extern PH_API void phGetFrameDimension(PhUInt64 frameId, PhUInt32* out_widthPx, PhUInt32* out_heightPx);
148extern PH_API void phGetFrameRgbData(PhUInt64 frameId, const PhFloat32** out_data);
149extern PH_API void phDeleteFrame(PhUInt64 frameId);
150extern PH_API PhBool phLoadFrame(PhUInt64 frameId, const PhChar* filePath);
151
155 PhUInt64 frameId,
156 const PhChar* filePath,
157 const PhFrameSaveInfo* saveInfo);
158
165 PhUInt64 frameId,
166 PhUInt64 bufferId,
167 PhBufferFormat format,
168 const PhFrameSaveInfo* saveInfo);
169
170extern PH_API void phFrameOpAbsDifference(PhUInt64 frameAId, PhUInt64 frameBId, PhUInt64 resultFrameId);
171extern PH_API PhFloat32 phFrameOpMSE(PhUInt64 expectedFrameId, PhUInt64 estimatedFramIde);
172
174// General Buffer Operations
175//
176
177extern PH_API void phCreateBuffer(PhUInt64* out_bufferId);
178extern PH_API void phGetBufferBytes(PhUInt64 bufferId, const PhUChar** out_bytesPtr, PhSize* out_numBytes);
179extern PH_API void phDeleteBuffer(PhUInt64 bufferId);
180
182// Asynchronous Operations
183//
184
185extern PH_API void phAsyncGetRenderProgress(PhUInt64 engineId, PhRenderProgress* out_progress);
186
187// TODO: async queries should tolerate invalid operations such as being called
188// after underlying resource is already deleted, this can ease the burden of
189// callers
190
192 PhUInt64 engineId,
193 PhFloat32* out_percentageProgress,
194 PhFloat32* out_samplesPerSecond);
195
196// HACK
197extern PH_API void phAsyncGetRenderState(
198 PhUInt64 engineId,
199 struct PHRenderState* out_state);
200
204 PhUInt64 engineId,
205 PhFrameRegionInfo* out_regionInfo);
206
210 PhUInt64 engineId,
211 PhUInt64 bufferId,
212 PhFrameRegionInfo* out_regionInfos,
213 PhSize maxRegionInfos);
214
222 PhUInt64 engineId,
223 PhUInt64 bufferId,
224 PhSize mergeSize,
225 PhFrameRegionInfo* out_regionInfos,
226 PhSize maxRegionInfos);
227
228extern PH_API void phAsyncPeekFrame(
229 PhUInt64 engineId,
230 PhUInt64 layerIndex,
231 PhUInt32 xPx,
232 PhUInt32 yPx,
233 PhUInt32 widthPx,
234 PhUInt32 heightPx,
235 PhUInt64 frameId);
236
237extern PH_API void phAsyncPeekFrameRaw(
238 PhUInt64 engineId,
239 PhUInt64 layerIndex,
240 PhUInt32 xPx,
241 PhUInt32 yPx,
242 PhUInt32 widthPx,
243 PhUInt32 heightPx,
244 PhUInt64 frameId);
245
246#ifdef __cplusplus
247}
248#endif
PH_API PhBool phInit()
Definition ph_c_core.cpp:44
PH_API void phDeleteFrame(PhUInt64 frameId)
Definition ph_c_core.cpp:271
PH_API PhBool phSaveFrame(PhUInt64 frameId, const PhChar *filePath, const PhFrameSaveInfo *saveInfo)
Save a frame to the filesystem.
Definition ph_c_core.cpp:301
PH_API void phAsyncGetRenderStatistics(PhUInt64 engineId, PhFloat32 *out_percentageProgress, PhFloat32 *out_samplesPerSecond)
Definition ph_c_core.cpp:476
#define PH_MAX_NAME_LENGTH
Definition ph_c_core.h:73
#define PH_NUM_RENDER_LAYERS
Definition ph_c_core.h:70
PH_API PhSize phAsyncPollUpdatedFrameRegions(PhUInt64 engineId, PhUInt64 bufferId, PhFrameRegionInfo *out_regionInfos, PhSize maxRegionInfos)
Polls for multiple changed regions during engine runtime.
Definition ph_c_core.cpp:541
PH_API PhBool phExit()
Definition ph_c_core.cpp:55
#define PH_NUM_RENDER_STATE_REALS
Definition ph_c_core.h:72
PH_API void phConfigRendererResourceDirectory(const PhChar *directory)
Definition ph_c_core.cpp:37
PH_API void phGetRenderDimension(PhUInt64 engineId, PhUInt32 *out_widthPx, PhUInt32 *out_heightPx)
Definition ph_c_core.cpp:173
PH_API PhBool phLoadFrame(PhUInt64 frameId, const PhChar *filePath)
Definition ph_c_core.cpp:283
PH_API void phGetObservableRenderData(PhUInt64 engineId, struct PHObservableRenderData *out_data)
Definition ph_c_core.cpp:184
PH_API void phGetFrameRgbData(PhUInt64 frameId, const PhFloat32 **out_data)
Definition ph_c_core.cpp:260
PH_API void phDeleteEngine(PhUInt64 engineId)
Definition ph_c_core.cpp:86
PH_API void phDeleteBuffer(PhUInt64 bufferId)
Definition ph_c_core.cpp:676
PH_API void phRender(PhUInt64 engineId)
Definition ph_c_core.cpp:124
PH_API PhFloat32 phFrameOpMSE(PhUInt64 expectedFrameId, PhUInt64 estimatedFramIde)
Definition ph_c_core.cpp:444
PH_ERenderStateType
Definition ph_c_core.h:92
@ REAL
Definition ph_c_core.h:94
@ INTEGER
Definition ph_c_core.h:93
PH_API void phAsyncPeekFrameRaw(PhUInt64 engineId, PhUInt64 layerIndex, PhUInt32 xPx, PhUInt32 yPx, PhUInt32 widthPx, PhUInt32 heightPx, PhUInt64 frameId)
Definition ph_c_core.cpp:620
PH_API void phAquireFrameRaw(PhUInt64 engineId, PhUInt64 channelIndex, PhUInt64 frameId)
Definition ph_c_core.cpp:157
PH_API void phAsyncGetRenderState(PhUInt64 engineId, struct PHRenderState *out_state)
Definition ph_c_core.cpp:495
PH_API PhSize phAsyncPollMergedUpdatedFrameRegions(PhUInt64 engineId, PhUInt64 bufferId, PhSize mergeSize, PhFrameRegionInfo *out_regionInfos, PhSize maxRegionInfos)
Polls for multiple changed regions during engine runtime.
Definition ph_c_core.cpp:571
PH_API PhBool phSaveFrameToBuffer(PhUInt64 frameId, PhUInt64 bufferId, PhBufferFormat format, const PhFrameSaveInfo *saveInfo)
Save a frame to a buffer.
Definition ph_c_core.cpp:337
PH_API void phUpdate(PhUInt64 engineId)
Definition ph_c_core.cpp:133
PH_EATTRIBUTE
Definition ph_c_core.h:63
@ NORMAL
Definition ph_c_core.h:65
@ DEPTH
Definition ph_c_core.h:66
@ LIGHT_ENERGY
Definition ph_c_core.h:64
PH_API void phEnterCommand(PhUInt64 engineId, const PhChar *commandFragment)
Definition ph_c_core.cpp:98
PH_API void phAquireFrame(PhUInt64 engineId, PhUInt64 channelIndex, PhUInt64 frameId)
Definition ph_c_core.cpp:142
PH_API PhBool phLoadCommands(PhUInt64 engineId, const PhChar *filePath)
Definition ph_c_core.cpp:110
PH_API void phCreateEngine(PhUInt64 *out_engineId, const PhUInt32 numRenderThreads)
Creates an engine.
Definition ph_c_core.cpp:66
PH_API void phCreateFrame(PhUInt64 *out_frameId, PhUInt32 widthPx, PhUInt32 heightPx)
Definition ph_c_core.cpp:236
#define PH_API
**************************************************** Microsoft Visual Studio *‍/
Definition ph_c_core.h:57
PH_API void phGetBufferBytes(PhUInt64 bufferId, const PhUChar **out_bytesPtr, PhSize *out_numBytes)
Definition ph_c_core.cpp:659
PH_API void phSetWorkingDirectory(PhUInt64 engineId, const PhChar *workingDirectory)
Definition ph_c_core.cpp:638
PH_API void phAsyncGetRenderProgress(PhUInt64 engineId, PhRenderProgress *out_progress)
Definition ph_c_core.cpp:462
PH_API void phGetFrameDimension(PhUInt64 frameId, PhUInt32 *out_widthPx, PhUInt32 *out_heightPx)
Definition ph_c_core.cpp:247
PH_API void phCreateBuffer(PhUInt64 *out_bufferId)
Definition ph_c_core.cpp:650
PH_API void phSetNumRenderThreads(PhUInt64 engineId, const PhUInt32 numRenderThreads)
Definition ph_c_core.cpp:77
PH_API void phAsyncPeekFrame(PhUInt64 engineId, PhUInt64 layerIndex, PhUInt32 xPx, PhUInt32 yPx, PhUInt32 widthPx, PhUInt32 heightPx, PhUInt64 frameId)
Definition ph_c_core.cpp:602
PH_API PhBool phAsyncPollUpdatedFrameRegion(PhUInt64 engineId, PhFrameRegionInfo *out_regionInfo)
Polls for a single changed region during engine runtime.
Definition ph_c_core.cpp:517
PH_API void phFrameOpAbsDifference(PhUInt64 frameAId, PhUInt64 frameBId, PhUInt64 resultFrameId)
Definition ph_c_core.cpp:433
#define PH_NUM_RENDER_STATE_INTEGERS
Definition ph_c_core.h:71
uint32_t PhUInt32
Definition ph_c_core_types.h:13
char PhChar
Definition ph_c_core_types.h:18
float PhFloat32
Definition ph_c_core_types.h:16
unsigned char PhUChar
Definition ph_c_core_types.h:19
PhBool
Definition ph_c_core_types.h:23
size_t PhSize
Definition ph_c_core_types.h:20
PhBufferFormat
Definition ph_c_core_types.h:42
uint64_t PhUInt64
Definition ph_c_core_types.h:15
int64_t PhInt64
Definition ph_c_core_types.h:14
Definition ph_c_core.h:84
PhChar layers[PH_NUM_RENDER_LAYERS][PH_MAX_NAME_LENGTH+1]
Definition ph_c_core.h:85
PhChar reals[PH_NUM_RENDER_STATE_REALS][PH_MAX_NAME_LENGTH+1]
Definition ph_c_core.h:87
PhChar integers[PH_NUM_RENDER_STATE_INTEGERS][PH_MAX_NAME_LENGTH+1]
Definition ph_c_core.h:86
Definition ph_c_core.h:77
PhFloat32 reals[PH_NUM_RENDER_STATE_REALS]
Definition ph_c_core.h:79
PhInt64 integers[PH_NUM_RENDER_STATE_INTEGERS]
Definition ph_c_core.h:78
Definition ph_c_core_types.h:65
Definition ph_c_core_types.h:82
Definition ph_c_core_types.h:58