include FNA3D.h

pull/8/head
cosmonaut 2020-12-15 15:27:06 -08:00
parent 715950f44a
commit cb3cc4007b
5 changed files with 47 additions and 284 deletions

2
.gitignore vendored
View File

@ -13,3 +13,5 @@ Release/
xcuserdata/
*.xcworkspace/
build/
CMakeCache.text
cmake.check_cache

38
CMakeCache.txt Normal file
View File

@ -0,0 +1,38 @@
# This is the CMakeCache file.
# For build in directory: /home/cosmonaut/programming/Refresh
# It was generated by CMake: /usr/bin/cmake
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# If you do want to change a value, simply edit, save, and exit the editor.
# The syntax for the file is as follows:
# KEY:TYPE=VALUE
# KEY is the name of a variable in the cache.
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
# VALUE is the current value for the KEY.
########################
# EXTERNAL cache entries
########################
########################
# INTERNAL cache entries
########################
//This is the directory where this CMakeCache.txt was created
CMAKE_CACHEFILE_DIR:INTERNAL=/home/cosmonaut/programming/Refresh
//Major version of cmake used to create the current loaded cache
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
//Minor version of cmake used to create the current loaded cache
CMAKE_CACHE_MINOR_VERSION:INTERNAL=18
//Patch version of cmake used to create the current loaded cache
CMAKE_CACHE_PATCH_VERSION:INTERNAL=4
//Path to CMake executable.
CMAKE_COMMAND:INTERNAL=/usr/bin/cmake
//Path to cpack program executable.
CMAKE_CPACK_COMMAND:INTERNAL=/usr/bin/cpack
//Path to ctest program executable.
CMAKE_CTEST_COMMAND:INTERNAL=/usr/bin/ctest
//Path to CMake installation.
CMAKE_ROOT:INTERNAL=/usr/share/cmake

View File

@ -58,8 +58,6 @@ if(NOT MSVC)
set_property(TARGET Refresh PROPERTY COMPILE_FLAGS "-std=gnu99 -Wall -Wno-strict-aliasing -pedantic")
endif()
add_subdirectory(FNA3D)
# Refresh folders as includes, for other targets to consume
target_include_directories(Refresh PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
@ -78,6 +76,8 @@ set_target_properties(Refresh PROPERTIES OUTPUT_NAME "Refresh"
SOVERSION ${LIB_MAJOR_VERSION}
)
target_include_directories(Refresh PUBLIC ../FNA3D/include)
# SDL2 Dependency
if (DEFINED SDL2_INCLUDE_DIRS AND DEFINED SDL2_LIBRARIES)
message(STATUS "using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES")

3
README
View File

@ -14,7 +14,8 @@ For shaders, we plan to consume SPIR-V bytecode.
Dependencies
------------
Refresh depends solely on SDL2. Refresh never explicitly uses the C runtime.
Refresh depends on SDL2. It also depends on FNA3D to ease interoperability in FNA.
Refresh never explicitly uses the C runtime.
Building Refresh
----------------

View File

@ -54,18 +54,9 @@ extern "C" {
/* Type Declarations */
typedef struct REFRESH_Device REFRESH_Device;
typedef struct REFRESH_Texture REFRESH_Texture;
typedef struct REFRESH_Buffer REFRESH_Buffer;
typedef struct REFRESH_Renderbuffer REFRESH_Renderbuffer;
typedef enum REFRESH_PresentMode
{
REFRESH_PRESENTMODE_IMMEDIATE,
REFRESH_PRESENTMODE_MAILBOX,
REFRESH_PRESENTMODE_FIFO,
REFRESH_PRESENTMODE_FIFO_RELAXED
} REFRESH_PresentMode;
typedef struct REFRESH_RenderBuffer REFRESH_RenderBuffer;
typedef enum REFRESH_ClearOptions
{
@ -74,15 +65,6 @@ typedef enum REFRESH_ClearOptions
REFRESH_CLEAROPTIONS_STENCIL = 4,
} REFRESH_ClearOptions;
typedef enum REFRESH_PrimitiveType
{
REFRESH_PRIMITIVETYPE_POINTLIST,
REFRESH_PRIMITIVETYPE_LINELIST,
REFRESH_PRIMITIVETYPE_LINESTRIP,
REFRESH_PRIMITIVETYPE_TRIANGLELIST,
REFRESH_PRIMITIVETYPE_TRIANGLESTRIP
} REFRESH_PrimitiveType;
typedef enum REFRESH_IndexElementSize
{
REFRESH_INDEXELEMENTSIZE_16BIT,
@ -135,220 +117,12 @@ typedef enum REFRESH_BufferUsage
REFRESH_BUFFERUSAGE_DYNAMIC
} REFRESH_BufferUsage;
typedef enum REFRESH_Blend
{
REFRESH_BLEND_ONE,
REFRESH_BLEND_ZERO,
REFRESH_BLEND_SOURCECOLOR,
REFRESH_BLEND_INVERSESOURCECOLOR,
REFRESH_BLEND_SOURCEALPHA,
REFRESH_BLEND_INVERSESOURCEALPHA,
REFRESH_BLEND_DESTINATIONCOLOR,
REFRESH_BLEND_INVERSEDESTINATIONCOLOR,
REFRESH_BLEND_DESTINATIONALPHA,
REFRESH_BLEND_INVERSEDESTINATIONALPHA,
REFRESH_BLEND_BLENDFACTOR,
REFRESH_BLEND_INVERSEBLENDFACTOR,
REFRESH_BLEND_SOURCEALPHASATURATION
} REFRESH_Blend;
typedef enum REFRESH_BlendFunction
{
REFRESH_BLENDFUNCTION_ADD,
REFRESH_BLENDFUNCTION_SUBTRACT,
REFRESH_BLENDFUNCTION_REVERSESUBTRACT,
REFRESH_BLENDFUNCTION_MAX,
REFRESH_BLENDFUNCTION_MIN
} REFRESH_BlendFunction;
typedef enum REFRESH_ColorWriteChannels
{
REFRESH_COLORWRITECHANNELS_NONE = 0,
REFRESH_COLORWRITECHANNELS_RED = 1,
REFRESH_COLORWRITECHANNELS_GREEN = 2,
REFRESH_COLORWRITECHANNELS_BLUE = 4,
REFRESH_COLORWRITECHANNELS_ALPHA = 8,
REFRESH_COLORWRITECHANNELS_ALL = 15
} REFRESH_ColorWriteChannels;
typedef enum REFRESH_StencilOperation
{
REFRESH_STENCILOPERATION_KEEP,
REFRESH_STENCILOPERATION_ZERO,
REFRESH_STENCILOPERATION_REPLACE,
REFRESH_STENCILOPERATION_INCREMENT,
REFRESH_STENCILOPERATION_DECREMENT,
REFRESH_STENCILOPERATION_INCREMENTSATURATION,
REFRESH_STENCILOPERATION_DECREMENTSATURATION,
REFRESH_STENCILOPERATION_INVERT
} REFRESH_StencilOperation;
typedef enum REFRESH_CompareFunction
{
REFRESH_COMPAREFUNCTION_ALWAYS,
REFRESH_COMPAREFUNCTION_NEVER,
REFRESH_COMPAREFUNCTION_LESS,
REFRESH_COMPAREFUNCTION_LESSEQUAL,
REFRESH_COMPAREFUNCTION_EQUAL,
REFRESH_COMPAREFUNCTION_GREATEREQUAL,
REFRESH_COMPAREFUNCTION_GREATER,
REFRESH_COMPAREFUNCTION_NOTEQUAL
} REFRESH_CompareFunction;
typedef enum REFRESH_CullMode
{
REFRESH_CULLMODE_NONE,
REFRESH_CULLMODE_CULLCLOCKWISEFACE,
REFRESH_CULLMODE_CULLCOUNTERCLOCKWISEFACE
} REFRESH_CullMode;
typedef enum REFRESH_FillMode
{
REFRESH_FILLMODE_SOLID,
REFRESH_FILLMODE_WIREFRAME
} REFRESH_FillMode;
typedef enum REFRESH_TextureAddressMode
{
REFRESH_TEXTUREADDRESSMODE_WRAP,
REFRESH_TEXTUREADDRESSMODE_CLAMP,
REFRESH_TEXTUREADDRESSMODE_MIRROR
} REFRESH_TextureAddressMode;
typedef enum REFRESH_TextureFilter
{
REFRESH_TEXTUREFILTER_LINEAR,
REFRESH_TEXTUREFILTER_POINT,
REFRESH_TEXTUREFILTER_ANISOTROPIC,
REFRESH_TEXTUREFILTER_LINEAR_MIPPOINT,
REFRESH_TEXTUREFILTER_POINT_MIPLINEAR,
REFRESH_TEXTUREFILTER_MINLINEAR_MAGPOINT_MIPLINEAR,
REFRESH_TEXTUREFILTER_MINLINEAR_MAGPOINT_MIPPOINT,
REFRESH_TEXTUREFILTER_MINPOINT_MAGLINEAR_MIPLINEAR,
REFRESH_TEXTUREFILTER_MINPOINT_MAGLINEAR_MIPPOINT
} REFRESH_TextureFilter;
typedef enum REFRESH_VertexElementFormat
{
REFRESH_VERTEXELEMENTFORMAT_SINGLE,
REFRESH_VERTEXELEMENTFORMAT_VECTOR2,
REFRESH_VERTEXELEMENTFORMAT_VECTOR3,
REFRESH_VERTEXELEMENTFORMAT_VECTOR4,
REFRESH_VERTEXELEMENTFORMAT_COLOR,
REFRESH_VERTEXELEMENTFORMAT_BYTE4,
REFRESH_VERTEXELEMENTFORMAT_SHORT2,
REFRESH_VERTEXELEMENTFORMAT_SHORT4,
REFRESH_VERTEXELEMENTFORMAT_NORMALIZEDSHORT2,
REFRESH_VERTEXELEMENTFORMAT_NORMALIZEDSHORT4,
REFRESH_VERTEXELEMENTFORMAT_HALFVECTOR2,
REFRESH_VERTEXELEMENTFORMAT_HALFVECTOR4
} REFRESH_VertexElementFormat;
/* Structures, should match XNA 4.0 */
typedef struct REFRESH_Color
{
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
} REFRESH_Color;
typedef struct REFRESH_Rect
{
int32_t x;
int32_t y;
int32_t w;
int32_t h;
} REFRESH_Rect;
typedef struct REFRESH_Vec4
{
float x;
float y;
float z;
float w;
} REFRESH_Vec4;
typedef struct REFRESH_Viewport
{
int32_t x;
int32_t y;
int32_t w;
int32_t h;
float minDepth;
float maxDepth;
} REFRESH_Viewport;
typedef struct REFRESH_PresentationParameters
{
uint32_t backBufferWidth;
uint32_t backBufferHeight;
void* deviceWindowHandle;
REFRESH_PresentMode presentMode;
} REFRESH_PresentationParameters;
typedef struct REFRESH_BlendState
{
REFRESH_Blend colorSourceBlend;
REFRESH_Blend colorDestinationBlend;
REFRESH_BlendFunction colorBlendFunction;
REFRESH_Blend alphaSourceBlend;
REFRESH_Blend alphaDestinationBlend;
REFRESH_BlendFunction alphaBlendFunction;
REFRESH_ColorWriteChannels colorWriteEnable;
REFRESH_ColorWriteChannels colorWriteEnable1;
REFRESH_ColorWriteChannels colorWriteEnable2;
REFRESH_ColorWriteChannels colorWriteEnable3;
REFRESH_Color blendFactor;
int32_t multiSampleMask;
} REFRESH_BlendState;
typedef struct REFRESH_DepthStencilState
{
uint8_t depthBufferEnable;
uint8_t depthBufferWriteEnable;
REFRESH_CompareFunction depthBufferFunction;
uint8_t stencilEnable;
int32_t stencilMask;
int32_t stencilWriteMask;
uint8_t twoSidedStencilMode;
REFRESH_StencilOperation stencilFail;
REFRESH_StencilOperation stencilDepthBufferFail;
REFRESH_StencilOperation stencilPass;
REFRESH_CompareFunction stencilFunction;
REFRESH_StencilOperation ccwStencilFail;
REFRESH_StencilOperation ccwStencilDepthBufferFail;
REFRESH_StencilOperation ccwStencilPass;
REFRESH_CompareFunction ccwStencilFunction;
int32_t referenceStencil;
} REFRESH_DepthStencilState;
typedef struct REFRESH_RasterizerState
{
REFRESH_FillMode fillMode;
REFRESH_CullMode cullMode;
float depthBias;
float slopeScaleDepthBias;
uint8_t scissorTestEnable;
uint8_t multiSampleAntiAlias;
} REFRESH_RasterizerState;
typedef struct REFRESH_SamplerState
{
REFRESH_TextureFilter filter;
REFRESH_TextureAddressMode addressU;
REFRESH_TextureAddressMode addressV;
REFRESH_TextureAddressMode addressW;
float mipMapLevelOfDetailBias;
int32_t maxAnisotropy;
int32_t maxMipLevel;
} REFRESH_SamplerState;
/* Structures */
typedef struct REFRESH_VertexElement
{
int32_t offset;
REFRESH_VertexElementFormat vertexElementFormat;
FNA3D_VertexElementFormat vertexElementFormat;
int32_t usageIndex;
} REFRESH_VertexElement;
@ -367,40 +141,6 @@ typedef struct REFRESH_VertexBufferBinding
int32_t instanceFrequency;
} REFRESH_VertexBufferBinding;
/* FIXME: can we deviate from FNA3D in a nice way user-side here? */
typedef struct REFRESH_RenderTargetBinding
{
/* Basic target information */
#define REFRESH_RENDERTARGET_TYPE_2D 0
#define REFRESH_RENDERTARGET_TYPE_CUBE 1
uint8_t type;
REFRESHNAMELESS union
{
struct
{
int32_t width;
int32_t height;
} twod;
struct
{
int32_t size;
REFRESH_CubeMapFace face;
} cube;
};
/* If this is >1, you MUST call ResolveTarget after rendering! */
int32_t levelCount;
/* If this is >1, colorBuffer MUST be non-NULL! */
int32_t multiSampleCount;
/* Destination texture. This MUST be non-NULL! */
REFRESH_Texture *texture;
/* If this is non-NULL, you MUST call ResolveTarget after rendering! */
REFRESH_Renderbuffer *colorBuffer;
} FNA3D_RenderTargetBinding;
/* Version API */
#define REFRESH_ABI_VERSION 0
@ -419,24 +159,6 @@ REFRESHAPI uint32_t REFRESH_LinkedVersion(void);
/* Functions */
/* Logging */
typedef void (REFRESHCALL * REFRESH_LogFunc)(const char *msg);
/* Reroutes Refresh's logging to custom logging functions.
*
* info: Basic logs that might be useful to have stored for support.
* warn: Something went wrong, but it's really just annoying, not fatal.
* error: You better have this stored somewhere because it's crashing now!
*/
REFRESHAPI void REFRESH_HookLogFunctions(
REFRESH_LogFunc info,
REFRESH_LogFunc warn,
REFRESH_LogFunc error
);
#ifdef __cplusplus
}
#endif /* __cplusplus */