Updated C99 header.

This commit is contained in:
Branimir Karadžić 2014-06-01 13:25:31 -07:00
parent c4b040a382
commit 97090e826c
3 changed files with 131 additions and 3 deletions

View file

@ -1,6 +1,8 @@
/* /*
* Copyright 2011-2014 Branimir Karadzic. All rights reserved. * Copyright 2011-2014 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*
* vim: set tabstop=4 expandtab:
*/ */
#ifndef BGFX_C99_H_HEADER_GUARD #ifndef BGFX_C99_H_HEADER_GUARD
@ -393,6 +395,74 @@ BGFX_C_API void bgfx_vertex_decl_skip(bgfx_vertex_decl_t* _decl, uint8_t _num);
*/ */
BGFX_C_API void bgfx_vertex_decl_end(bgfx_vertex_decl_t* _decl); BGFX_C_API void bgfx_vertex_decl_end(bgfx_vertex_decl_t* _decl);
/**
* Pack vec4 into vertex stream format.
*/
BGFX_C_API void bgfx_vertex_pack(const float _input[4], bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_decl* _decl, void* _data, uint32_t _index);
/**
* Unpack vec4 from vertex stream format.
*/
BGFX_C_API void bgfx_vertex_unpack(float _output[4], bgfx_attrib_t _attr, const bgfx_vertex_decl_t* _decl, const void* _data, uint32_t _index);
/**
* Converts vertex stream data from one vertex stream format to another.
*
* @param _destDecl Destination vertex stream declaration.
* @param _destData Destination vertex stream.
* @param _srcDecl Source vertex stream declaration.
* @param _srcData Source vertex stream data.
* @param _num Number of vertices to convert from source to destination.
*/
BGFX_C_API void bgfx_vertex_convert(const bgfx_vertex_decl_t* _destDecl, void* _destData, const bgfx_vertex_decl_t* _srcDecl, const void* _srcData, uint32_t _num);
/**
* Weld vertices.
*
* @param _output Welded vertices remapping table. The size of buffer
* must be the same as number of vertices.
* @param _decl Vertex stream declaration.
* @param _data Vertex stream.
* @param _num Number of vertices in vertex stream.
* @param _epsilon Error tolerance for vertex position comparison.
* @returns Number of unique vertices after vertex welding.
*/
BGFX_C_API uint16_t bgfx_weld_vertices(uint16_t* _output, const bgfx_vertex_decl_t* _decl, const void* _data, uint16_t _num, float _epsilon);
/**
* Swizzle RGBA8 image to BGRA8.
*
* @param _width Width of input image (pixels).
* @param _height Height of input image (pixels).
* @param _pitch Pitch of input image (bytes).
* @param _src Source image.
* @param _dst Destination image. Must be the same size as input image.
* _dst might be pointer to the same memory as _src.
*/
BGFX_C_API void bgfx_image_swizzle_bgra8(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
/**
* Downsample RGBA8 image with 2x2 pixel average filter.
*
* @param _width Width of input image (pixels).
* @param _height Height of input image (pixels).
* @param _pitch Pitch of input image (bytes).
* @param _src Source image.
* @param _dst Destination image. Must be at least quarter size of
* input image. _dst might be pointer to the same memory as _src.
*/
BGFX_C_API void bgfx_image_rgba8_downsample_2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
/**
* Returns supported backend API renderers.
*/
BGFX_C_API uint8_t bgfx_get_supported_renderers(bgfx_renderer_type_t _enum[BGFX_RENDERER_TYPE_COUNT]);
/**
* Returns name of renderer.
*/
BGFX_C_API const char* bgfx_get_renderer_name(bgfx_renderer_type_t _type);
/** /**
* Initialize bgfx library. * Initialize bgfx library.
* *
@ -437,6 +507,14 @@ BGFX_C_API uint32_t bgfx_frame();
*/ */
BGFX_C_API bgfx_renderer_type_t bgfx_get_renderer_type(); BGFX_C_API bgfx_renderer_type_t bgfx_get_renderer_type();
/**
* Returns renderer capabilities.
*
* NOTE:
* Library must be initialized.
*/
BGFX_C_API bgfx_caps_t* bgfx_get_caps();
/** /**
* Allocate buffer to pass to bgfx calls. Data will be freed inside bgfx. * Allocate buffer to pass to bgfx calls. Data will be freed inside bgfx.
*/ */

View file

@ -1,6 +1,6 @@
/* /*
* Copyright 2011-2014 Branimir Karadzic. All rights reserved. * Copyright 2011-2014 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#ifndef BGFX_H_HEADER_GUARD #ifndef BGFX_H_HEADER_GUARD

View file

@ -2650,6 +2650,51 @@ BGFX_C_API void bgfx_vertex_decl_end(bgfx_vertex_decl_t* _decl)
decl->end(); decl->end();
} }
BGFX_C_API void bgfx_vertex_pack(const float _input[4], bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_decl* _decl, void* _data, uint32_t _index)
{
bgfx::VertexDecl& decl = *(bgfx::VertexDecl*)_decl;
bgfx::vertexPack(_input, _inputNormalized, bgfx::Attrib::Enum(_attr), decl, _data, _index);
}
BGFX_C_API void bgfx_vertex_unpack(float _output[4], bgfx_attrib_t _attr, const bgfx_vertex_decl_t* _decl, const void* _data, uint32_t _index)
{
bgfx::VertexDecl& decl = *(bgfx::VertexDecl*)_decl;
bgfx::vertexUnpack(_output, bgfx::Attrib::Enum(_attr), decl, _data, _index);
}
BGFX_C_API void bgfx_vertex_convert(const bgfx_vertex_decl_t* _destDecl, void* _destData, const bgfx_vertex_decl_t* _srcDecl, const void* _srcData, uint32_t _num)
{
bgfx::VertexDecl& destDecl = *(bgfx::VertexDecl*)_destDecl;
bgfx::VertexDecl& srcDecl = *(bgfx::VertexDecl*)_srcDecl;
bgfx::vertexConvert(destDecl, _destData, srcDecl, _srcData, _num);
}
BGFX_C_API uint16_t bgfx_weld_vertices(uint16_t* _output, const bgfx_vertex_decl_t* _decl, const void* _data, uint16_t _num, float _epsilon)
{
bgfx::VertexDecl& decl = *(bgfx::VertexDecl*)_decl;
return bgfx::weldVertices(_output, decl, _data, _num, _epsilon);
}
BGFX_C_API void bgfx_image_swizzle_bgra8(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
{
bgfx::imageSwizzleBgra8(_width, _height, _pitch, _src, _dst);
}
BGFX_C_API void bgfx_image_rgba8_downsample_2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
{
bgfx::imageRgba8Downsample2x2(_width, _height, _pitch, _src, _dst);
}
BGFX_C_API uint8_t bgfx_get_supported_renderers(bgfx_renderer_type_t _enum[BGFX_RENDERER_TYPE_COUNT])
{
return bgfx::getSupportedRenderers( (bgfx::RendererType::Enum*)_enum);
}
BGFX_C_API const char* bgfx_get_renderer_name(bgfx_renderer_type_t _type)
{
return bgfx::getRendererName(bgfx::RendererType::Enum(_type) );
}
BGFX_C_API void bgfx_init(bgfx_renderer_type_t _type, struct bgfx_callback_interface* _callback, struct bgfx_reallocator_interface* _allocator) BGFX_C_API void bgfx_init(bgfx_renderer_type_t _type, struct bgfx_callback_interface* _callback, struct bgfx_reallocator_interface* _allocator)
{ {
return bgfx::init(bgfx::RendererType::Enum(_type) return bgfx::init(bgfx::RendererType::Enum(_type)
@ -2678,6 +2723,11 @@ BGFX_C_API bgfx_renderer_type_t bgfx_get_renderer_type()
return bgfx_renderer_type_t(bgfx::getRendererType() ); return bgfx_renderer_type_t(bgfx::getRendererType() );
} }
BGFX_C_API bgfx_caps_t* bgfx_get_caps()
{
return (bgfx_caps_t*)bgfx::getCaps();
}
BGFX_C_API const bgfx_memory_t* bgfx_alloc(uint32_t _size) BGFX_C_API const bgfx_memory_t* bgfx_alloc(uint32_t _size)
{ {
return (const bgfx_memory_t*)bgfx::alloc(_size); return (const bgfx_memory_t*)bgfx::alloc(_size);