Photon Engine C API 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ph_c_core.h File Reference

Contains main C APIs of the render engine. More...

#include "ph_c_core_types.h"

Go to the source code of this file.

Classes

struct  PHRenderState
 
struct  PHObservableRenderData
 

Macros

#define PH_API
 **************************************************** Microsoft Visual Studio *‍/
 
#define PH_NUM_RENDER_LAYERS   4
 
#define PH_NUM_RENDER_STATE_INTEGERS   4
 
#define PH_NUM_RENDER_STATE_REALS   4
 
#define PH_MAX_NAME_LENGTH   128
 

Enumerations

enum  PH_EATTRIBUTE { LIGHT_ENERGY , NORMAL , DEPTH }
 
enum  PH_ERenderStateType { INTEGER , REAL }
 

Functions

PH_API void phConfigRendererResourceDirectory (const PhChar *directory)
 
PH_API PhBool phInit ()
 
PH_API PhBool phExit ()
 
PH_API void phCreateEngine (PhUInt64 *out_engineId, const PhUInt32 numRenderThreads)
 Creates an engine.
 
PH_API void phSetNumRenderThreads (PhUInt64 engineId, const PhUInt32 numRenderThreads)
 
PH_API void phEnterCommand (PhUInt64 engineId, const PhChar *commandFragment)
 
PH_API PhBool phLoadCommands (PhUInt64 engineId, const PhChar *filePath)
 
PH_API void phRender (PhUInt64 engineId)
 
PH_API void phUpdate (PhUInt64 engineId)
 
PH_API void phGetRenderDimension (PhUInt64 engineId, PhUInt32 *out_widthPx, PhUInt32 *out_heightPx)
 
PH_API void phGetObservableRenderData (PhUInt64 engineId, struct PHObservableRenderData *out_data)
 
PH_API void phDeleteEngine (PhUInt64 engineId)
 
PH_API void phSetWorkingDirectory (PhUInt64 engineId, const PhChar *workingDirectory)
 
PH_API void phAquireFrame (PhUInt64 engineId, PhUInt64 channelIndex, PhUInt64 frameId)
 
PH_API void phAquireFrameRaw (PhUInt64 engineId, PhUInt64 channelIndex, PhUInt64 frameId)
 
PH_API void phCreateFrame (PhUInt64 *out_frameId, PhUInt32 widthPx, PhUInt32 heightPx)
 
PH_API void phGetFrameDimension (PhUInt64 frameId, PhUInt32 *out_widthPx, PhUInt32 *out_heightPx)
 
PH_API void phGetFrameRgbData (PhUInt64 frameId, const PhFloat32 **out_data)
 
PH_API void phDeleteFrame (PhUInt64 frameId)
 
PH_API PhBool phLoadFrame (PhUInt64 frameId, const PhChar *filePath)
 
PH_API PhBool phSaveFrame (PhUInt64 frameId, const PhChar *filePath, const PhFrameSaveInfo *saveInfo)
 Save a frame to the filesystem.
 
PH_API PhBool phSaveFrameToBuffer (PhUInt64 frameId, PhUInt64 bufferId, PhBufferFormat format, const PhFrameSaveInfo *saveInfo)
 Save a frame to a buffer.
 
PH_API void phFrameOpAbsDifference (PhUInt64 frameAId, PhUInt64 frameBId, PhUInt64 resultFrameId)
 
PH_API PhFloat32 phFrameOpMSE (PhUInt64 expectedFrameId, PhUInt64 estimatedFramIde)
 
PH_API void phCreateBuffer (PhUInt64 *out_bufferId)
 
PH_API void phGetBufferBytes (PhUInt64 bufferId, const PhUChar **out_bytesPtr, PhSize *out_numBytes)
 
PH_API void phDeleteBuffer (PhUInt64 bufferId)
 
PH_API void phAsyncGetRenderProgress (PhUInt64 engineId, PhRenderProgress *out_progress)
 
PH_API void phAsyncGetRenderStatistics (PhUInt64 engineId, PhFloat32 *out_percentageProgress, PhFloat32 *out_samplesPerSecond)
 
PH_API void phAsyncGetRenderState (PhUInt64 engineId, struct PHRenderState *out_state)
 
PH_API PhBool phAsyncPollUpdatedFrameRegion (PhUInt64 engineId, PhFrameRegionInfo *out_regionInfo)
 Polls for a single changed region during engine runtime.
 
PH_API PhSize phAsyncPollUpdatedFrameRegions (PhUInt64 engineId, PhUInt64 bufferId, PhFrameRegionInfo *out_regionInfos, PhSize maxRegionInfos)
 Polls for multiple changed regions during engine runtime.
 
PH_API PhSize phAsyncPollMergedUpdatedFrameRegions (PhUInt64 engineId, PhUInt64 bufferId, PhSize mergeSize, PhFrameRegionInfo *out_regionInfos, PhSize maxRegionInfos)
 Polls for multiple changed regions during engine runtime.
 
PH_API void phAsyncPeekFrame (PhUInt64 engineId, PhUInt64 layerIndex, PhUInt32 xPx, PhUInt32 yPx, PhUInt32 widthPx, PhUInt32 heightPx, PhUInt64 frameId)
 
PH_API void phAsyncPeekFrameRaw (PhUInt64 engineId, PhUInt64 layerIndex, PhUInt32 xPx, PhUInt32 yPx, PhUInt32 widthPx, PhUInt32 heightPx, PhUInt64 frameId)
 

Detailed Description

Contains main C APIs of the render engine.

To correctly use Photon-v2 API, please read the following notes:

  • phInit() and phExit() must be called before and after the use of the API, and should be called on the same thread.
  • phCreate/Delete<X>() and phAsync<X>() functions can be used in a multithreaded environment. They are thread-safe provided the following conditions are met: phDelete<X>() should be called from the same thread its corresponding phCreate<X>() was called from. phAsync<X>() cannot be called during phUpdate() (memory effects must be made visible to the calling thread).
  • Resources created by phCreate<X>() cannot be manipulated concurrently. Any function requiring some resource ID inputs (except phAsync<X>() functions) is considered a resource manipulating operation on those resources.

Macro Definition Documentation

◆ PH_API

#define PH_API

**************************************************** Microsoft Visual Studio *‍/

************************************************************ other compilers *‍/

◆ PH_MAX_NAME_LENGTH

#define PH_MAX_NAME_LENGTH   128

◆ PH_NUM_RENDER_LAYERS

#define PH_NUM_RENDER_LAYERS   4

◆ PH_NUM_RENDER_STATE_INTEGERS

#define PH_NUM_RENDER_STATE_INTEGERS   4

◆ PH_NUM_RENDER_STATE_REALS

#define PH_NUM_RENDER_STATE_REALS   4

Enumeration Type Documentation

◆ PH_EATTRIBUTE

Enumerator
LIGHT_ENERGY 
NORMAL 
DEPTH 

◆ PH_ERenderStateType

Enumerator
INTEGER 
REAL 

Function Documentation

◆ phAquireFrame()

PH_API void phAquireFrame ( PhUInt64 engineId,
PhUInt64 channelIndex,
PhUInt64 frameId )
extern

◆ phAquireFrameRaw()

PH_API void phAquireFrameRaw ( PhUInt64 engineId,
PhUInt64 channelIndex,
PhUInt64 frameId )
extern

◆ phAsyncGetRenderProgress()

PH_API void phAsyncGetRenderProgress ( PhUInt64 engineId,
PhRenderProgress * out_progress )
extern

◆ phAsyncGetRenderState()

PH_API void phAsyncGetRenderState ( PhUInt64 engineId,
struct PHRenderState * out_state )
extern

◆ phAsyncGetRenderStatistics()

PH_API void phAsyncGetRenderStatistics ( PhUInt64 engineId,
PhFloat32 * out_percentageProgress,
PhFloat32 * out_samplesPerSecond )
extern

◆ phAsyncPeekFrame()

PH_API void phAsyncPeekFrame ( PhUInt64 engineId,
PhUInt64 layerIndex,
PhUInt32 xPx,
PhUInt32 yPx,
PhUInt32 widthPx,
PhUInt32 heightPx,
PhUInt64 frameId )
extern

◆ phAsyncPeekFrameRaw()

PH_API void phAsyncPeekFrameRaw ( PhUInt64 engineId,
PhUInt64 layerIndex,
PhUInt32 xPx,
PhUInt32 yPx,
PhUInt32 widthPx,
PhUInt32 heightPx,
PhUInt64 frameId )
extern

◆ phAsyncPollMergedUpdatedFrameRegions()

PH_API PhSize phAsyncPollMergedUpdatedFrameRegions ( PhUInt64 engineId,
PhUInt64 bufferId,
PhSize mergeSize,
PhFrameRegionInfo * out_regionInfos,
PhSize maxRegionInfos )
extern

Polls for multiple changed regions during engine runtime.

Parameters
out_regionInfosOutput buffer for storing the updated regions. The size of the buffer also determines the maximum number of regions that will participate in the merging process.
mergeSizeNumber of regions to merge to a single unit. To obtain a single region, you can specify a number greater or equal to the size of the output buffer.

◆ phAsyncPollUpdatedFrameRegion()

PH_API PhBool phAsyncPollUpdatedFrameRegion ( PhUInt64 engineId,
PhFrameRegionInfo * out_regionInfo )
extern

Polls for a single changed region during engine runtime.

◆ phAsyncPollUpdatedFrameRegions()

PH_API PhSize phAsyncPollUpdatedFrameRegions ( PhUInt64 engineId,
PhUInt64 bufferId,
PhFrameRegionInfo * out_regionInfos,
PhSize maxRegionInfos )
extern

Polls for multiple changed regions during engine runtime.

◆ phConfigRendererResourceDirectory()

PH_API void phConfigRendererResourceDirectory ( const PhChar * directory)
extern

◆ phCreateBuffer()

PH_API void phCreateBuffer ( PhUInt64 * out_bufferId)
extern

◆ phCreateEngine()

PH_API void phCreateEngine ( PhUInt64 * out_engineId,
const PhUInt32 numRenderThreads )
extern

Creates an engine.

◆ phCreateFrame()

PH_API void phCreateFrame ( PhUInt64 * out_frameId,
PhUInt32 widthPx,
PhUInt32 heightPx )
extern

◆ phDeleteBuffer()

PH_API void phDeleteBuffer ( PhUInt64 bufferId)
extern

◆ phDeleteEngine()

PH_API void phDeleteEngine ( PhUInt64 engineId)
extern

◆ phDeleteFrame()

PH_API void phDeleteFrame ( PhUInt64 frameId)
extern

◆ phEnterCommand()

PH_API void phEnterCommand ( PhUInt64 engineId,
const PhChar * commandFragment )
extern

◆ phExit()

PH_API PhBool phExit ( )
extern

◆ phFrameOpAbsDifference()

PH_API void phFrameOpAbsDifference ( PhUInt64 frameAId,
PhUInt64 frameBId,
PhUInt64 resultFrameId )
extern

◆ phFrameOpMSE()

PH_API PhFloat32 phFrameOpMSE ( PhUInt64 expectedFrameId,
PhUInt64 estimatedFramIde )
extern

◆ phGetBufferBytes()

PH_API void phGetBufferBytes ( PhUInt64 bufferId,
const PhUChar ** out_bytesPtr,
PhSize * out_numBytes )
extern

◆ phGetFrameDimension()

PH_API void phGetFrameDimension ( PhUInt64 frameId,
PhUInt32 * out_widthPx,
PhUInt32 * out_heightPx )
extern

◆ phGetFrameRgbData()

PH_API void phGetFrameRgbData ( PhUInt64 frameId,
const PhFloat32 ** out_data )
extern

◆ phGetObservableRenderData()

PH_API void phGetObservableRenderData ( PhUInt64 engineId,
struct PHObservableRenderData * out_data )
extern

◆ phGetRenderDimension()

PH_API void phGetRenderDimension ( PhUInt64 engineId,
PhUInt32 * out_widthPx,
PhUInt32 * out_heightPx )
extern

◆ phInit()

PH_API PhBool phInit ( )
extern

◆ phLoadCommands()

PH_API PhBool phLoadCommands ( PhUInt64 engineId,
const PhChar * filePath )
extern

◆ phLoadFrame()

PH_API PhBool phLoadFrame ( PhUInt64 frameId,
const PhChar * filePath )
extern

◆ phRender()

PH_API void phRender ( PhUInt64 engineId)
extern

◆ phSaveFrame()

PH_API PhBool phSaveFrame ( PhUInt64 frameId,
const PhChar * filePath,
const PhFrameSaveInfo * saveInfo )
extern

Save a frame to the filesystem.

◆ phSaveFrameToBuffer()

PH_API PhBool phSaveFrameToBuffer ( PhUInt64 frameId,
PhUInt64 bufferId,
PhBufferFormat format,
const PhFrameSaveInfo * saveInfo )
extern

Save a frame to a buffer.

Parameters
saveInBigEndianIf applicable to the format, specifies whether the result is saved in big endian. This is useful, for example, transferring the data through the Internet, where big-endian is the standard byte order.

◆ phSetNumRenderThreads()

PH_API void phSetNumRenderThreads ( PhUInt64 engineId,
const PhUInt32 numRenderThreads )
extern

◆ phSetWorkingDirectory()

PH_API void phSetWorkingDirectory ( PhUInt64 engineId,
const PhChar * workingDirectory )
extern

◆ phUpdate()

PH_API void phUpdate ( PhUInt64 engineId)
extern